2018-12-12 13:06:05 +09:00
|
|
|
<template>
|
2023-04-08 09:01:42 +09:00
|
|
|
<MkA
|
|
|
|
v-if="url.startsWith('/')"
|
|
|
|
v-user-preview="canonical"
|
|
|
|
class="akbvjaqn"
|
|
|
|
:class="{ isMe }"
|
|
|
|
:to="url"
|
|
|
|
:style="{ background: bgCss }"
|
|
|
|
@click.stop
|
|
|
|
>
|
|
|
|
<img class="icon" :src="`/avatar/@${username}@${host}`" alt="" />
|
|
|
|
<span class="main">
|
|
|
|
<span class="username">@{{ username }}</span>
|
|
|
|
<span
|
|
|
|
v-if="host != localHost || $store.state.showFullAcct"
|
|
|
|
class="host"
|
|
|
|
>@{{ toUnicode(host) }}</span
|
|
|
|
>
|
|
|
|
</span>
|
|
|
|
</MkA>
|
|
|
|
<a
|
|
|
|
v-else
|
|
|
|
class="akbvjaqn"
|
|
|
|
:href="url"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener"
|
|
|
|
:style="{ background: bgCss }"
|
|
|
|
@click.stop
|
|
|
|
>
|
|
|
|
<span class="main">
|
|
|
|
<span class="username">@{{ username }}</span>
|
|
|
|
<span class="host">@{{ toUnicode(host) }}</span>
|
|
|
|
</span>
|
|
|
|
</a>
|
2018-12-12 13:06:05 +09:00
|
|
|
</template>
|
|
|
|
|
2022-06-24 10:34:36 +09:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 09:01:42 +09:00
|
|
|
import { toUnicode } from "punycode";
|
|
|
|
import {} from "vue";
|
|
|
|
import tinycolor from "tinycolor2";
|
|
|
|
import { host as localHost } from "@/config";
|
|
|
|
import { $i } from "@/account";
|
2018-12-12 13:06:05 +09:00
|
|
|
|
2022-06-24 10:34:36 +09:00
|
|
|
const props = defineProps<{
|
|
|
|
username: string;
|
|
|
|
host: string;
|
|
|
|
}>();
|
2021-10-31 20:19:49 +09:00
|
|
|
|
2023-04-08 09:01:42 +09:00
|
|
|
const canonical =
|
|
|
|
props.host === localHost
|
|
|
|
? `@${props.username}`
|
|
|
|
: `@${props.username}@${toUnicode(props.host)}`;
|
2021-10-31 20:19:49 +09:00
|
|
|
|
2022-06-24 10:34:36 +09:00
|
|
|
const url = `/${canonical}`;
|
2021-10-31 20:19:49 +09:00
|
|
|
|
2023-04-08 09:01:42 +09:00
|
|
|
const isMe =
|
|
|
|
$i &&
|
|
|
|
`@${props.username}@${toUnicode(props.host)}` ===
|
|
|
|
`@${$i.username}@${toUnicode(localHost)}`.toLowerCase();
|
2021-10-31 20:19:49 +09:00
|
|
|
|
2023-04-08 09:01:42 +09:00
|
|
|
const bg = tinycolor(
|
|
|
|
getComputedStyle(document.documentElement).getPropertyValue(
|
|
|
|
isMe ? "--mentionMe" : "--mention"
|
|
|
|
)
|
|
|
|
);
|
2022-06-24 10:34:36 +09:00
|
|
|
bg.setAlpha(0.1);
|
|
|
|
const bgCss = bg.toRgbString();
|
2018-12-12 13:06:05 +09:00
|
|
|
</script>
|
|
|
|
|
2022-07-10 13:16:11 +09:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.akbvjaqn {
|
2021-10-31 20:19:49 +09:00
|
|
|
display: inline-block;
|
2023-02-21 12:24:06 +09:00
|
|
|
padding: 2px 8px 2px 2px;
|
|
|
|
margin-block: 2px;
|
2021-10-31 20:19:49 +09:00
|
|
|
border-radius: 999px;
|
2023-02-21 12:24:06 +09:00
|
|
|
max-width: 100%;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
2020-01-30 04:37:25 +09:00
|
|
|
color: var(--mention);
|
2020-06-04 22:19:08 +09:00
|
|
|
|
|
|
|
&.isMe {
|
|
|
|
color: var(--mentionMe);
|
|
|
|
}
|
2018-12-12 13:06:05 +09:00
|
|
|
|
2022-07-10 13:16:11 +09:00
|
|
|
> .icon {
|
|
|
|
width: 1.5em;
|
|
|
|
height: 1.5em;
|
|
|
|
object-fit: cover;
|
|
|
|
margin: 0 0.2em 0 0;
|
|
|
|
vertical-align: bottom;
|
|
|
|
border-radius: 100%;
|
|
|
|
}
|
2021-10-24 21:02:50 +09:00
|
|
|
|
2022-07-13 16:33:39 +09:00
|
|
|
> .main > .host {
|
2022-07-10 13:16:11 +09:00
|
|
|
opacity: 0.5;
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
2018-12-12 13:06:05 +09:00
|
|
|
</style>
|