2020-02-10 03:48:45 +09:00
|
|
|
<template>
|
2023-04-08 09:01:42 +09:00
|
|
|
<component
|
|
|
|
:is="self ? 'MkA' : 'a'"
|
|
|
|
ref="el"
|
|
|
|
class="xlcxczvw _link"
|
|
|
|
:[attr]="self ? url.substr(local.length) : url"
|
|
|
|
:rel="rel"
|
|
|
|
:target="target"
|
|
|
|
:title="url"
|
|
|
|
@click.stop
|
|
|
|
>
|
|
|
|
<slot></slot>
|
|
|
|
<i
|
|
|
|
v-if="target === '_blank'"
|
|
|
|
class="ph-arrow-square-out ph-bold ph-lg icon"
|
|
|
|
></i>
|
|
|
|
</component>
|
2020-02-10 03:48:45 +09:00
|
|
|
</template>
|
|
|
|
|
2022-01-16 08:38:55 +09:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 09:01:42 +09:00
|
|
|
import { defineAsyncComponent } from "vue";
|
|
|
|
import { url as local } from "@/config";
|
|
|
|
import { useTooltip } from "@/scripts/use-tooltip";
|
|
|
|
import * as os from "@/os";
|
2020-02-10 03:48:45 +09:00
|
|
|
|
2023-04-08 09:01:42 +09:00
|
|
|
const props = withDefaults(
|
|
|
|
defineProps<{
|
|
|
|
url: string;
|
|
|
|
rel?: null | string;
|
|
|
|
}>(),
|
|
|
|
{}
|
|
|
|
);
|
2020-02-10 03:48:45 +09:00
|
|
|
|
2022-01-16 08:38:55 +09:00
|
|
|
const self = props.url.startsWith(local);
|
2023-04-08 09:01:42 +09:00
|
|
|
const attr = self ? "to" : "href";
|
|
|
|
const target = self ? null : "_blank";
|
2020-02-10 03:48:45 +09:00
|
|
|
|
2022-01-16 08:38:55 +09:00
|
|
|
const el = $ref();
|
2020-10-17 20:12:00 +09:00
|
|
|
|
2022-01-16 08:38:55 +09:00
|
|
|
useTooltip($$(el), (showing) => {
|
2023-04-08 09:01:42 +09:00
|
|
|
os.popup(
|
|
|
|
defineAsyncComponent(
|
|
|
|
() => import("@/components/MkUrlPreviewPopup.vue")
|
|
|
|
),
|
|
|
|
{
|
|
|
|
showing,
|
|
|
|
url: props.url,
|
|
|
|
source: el,
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
"closed"
|
|
|
|
);
|
2020-02-10 03:48:45 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.xlcxczvw {
|
|
|
|
word-break: break-all;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
padding-left: 2px;
|
2023-04-08 09:01:42 +09:00
|
|
|
font-size: 0.9em;
|
2020-02-10 03:48:45 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|