Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Motion Bank
MB.js
Quasar Components Shared
Commits
c926ad17
Commit
c926ad17
authored
Mar 04, 2019
by
Anton
Browse files
Add ConditionalLink component to handle local and external links differently in cells
parent
8805558e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
partials/ConditionalLink.vue
partials/ConditionalLink.vue
+44
-0
No files found.
partials/ConditionalLink.vue
0 → 100644
View file @
c926ad17
<
template
lang=
"pug"
>
span
router-link(v-if="isLocal && routerTo", :to="routerTo")
slot
a(v-else, :href="url", target="_blank")
slot
</
template
>
<
script
>
import
qs
from
'
qs
'
export
default
{
props
:
{
url
:
String
},
computed
:
{
isLocal
()
{
return
this
.
url
&&
(
this
.
url
.
indexOf
(
process
.
env
.
UI_HOST
)
===
0
||
this
.
url
[
0
]
===
'
/
'
)
},
routerTo
()
{
let
url
try
{
url
=
new
URL
(
this
.
url
)
}
catch
(
e
)
{
if
(
this
.
url
)
{
const
parts
=
this
.
url
.
split
(
'
?
'
)
url
=
{
pathname
:
parts
[
0
],
search
:
parts
.
length
>
1
?
`?
${
parts
[
1
]}
`
:
''
}
}
}
if
(
url
)
{
const
query
=
url
.
search
.
length
?
qs
.
parse
(
url
.
search
.
substr
(
1
))
:
undefined
return
{
path
:
url
.
pathname
,
query
:
query
}
}
else
return
{}
}
}
}
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment