2018-12-12 06:06:05 +02:00
|
|
|
<template>
|
2020-10-24 19:21:41 +03:00
|
|
|
<MkA class="ldlomzub" :class="{ isMe }" :to="url" v-user-preview="canonical" v-if="url.startsWith('/')">
|
2020-12-26 03:47:36 +02:00
|
|
|
<span class="me" v-if="isMe">{{ $ts.you }}</span>
|
2021-10-24 15:02:50 +03:00
|
|
|
<img class="icon" :src="`/avatar/@${username}@${host}`" alt="">
|
2018-12-12 06:06:05 +02:00
|
|
|
<span class="main">
|
|
|
|
<span class="username">@{{ username }}</span>
|
2020-12-19 03:55:52 +02:00
|
|
|
<span class="host" v-if="(host != localHost) || $store.state.showFullAcct">@{{ toUnicode(host) }}</span>
|
2018-12-12 06:06:05 +02:00
|
|
|
</span>
|
2020-10-24 19:21:41 +03:00
|
|
|
</MkA>
|
2019-07-18 21:13:47 +03:00
|
|
|
<a class="ldlomzub" :href="url" target="_blank" rel="noopener" v-else>
|
|
|
|
<span class="main">
|
|
|
|
<span class="username">@{{ username }}</span>
|
2020-01-29 21:37:25 +02:00
|
|
|
<span class="host">@{{ toUnicode(host) }}</span>
|
2019-07-18 21:13:47 +03:00
|
|
|
</span>
|
|
|
|
</a>
|
2018-12-12 06:06:05 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { defineComponent } from 'vue';
|
2021-04-04 07:00:39 +03:00
|
|
|
import { toUnicode } from 'punycode/';
|
2021-03-23 10:30:14 +02:00
|
|
|
import { host as localHost } from '@client/config';
|
2020-08-07 05:27:37 +03:00
|
|
|
import { wellKnownServices } from '../../well-known-services';
|
2021-03-23 10:30:14 +02:00
|
|
|
import * as os from '@client/os';
|
2018-12-12 06:06:05 +02:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
export default defineComponent({
|
2018-12-12 06:06:05 +02:00
|
|
|
props: {
|
|
|
|
username: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
host: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
localHost
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2019-07-18 21:13:47 +03:00
|
|
|
url(): string {
|
2020-08-07 05:27:37 +03:00
|
|
|
const wellKnown = wellKnownServices.find(x => x[0] === this.host);
|
|
|
|
if (wellKnown) {
|
|
|
|
return wellKnown[1](this.username);
|
|
|
|
} else {
|
|
|
|
return `/${this.canonical}`;
|
2019-07-18 21:13:47 +03:00
|
|
|
}
|
|
|
|
},
|
2018-12-12 06:06:05 +02:00
|
|
|
canonical(): string {
|
2019-04-07 15:50:36 +03:00
|
|
|
return this.host === localHost ? `@${this.username}` : `@${this.username}@${toUnicode(this.host)}`;
|
2018-12-12 06:06:05 +02:00
|
|
|
},
|
|
|
|
isMe(): boolean {
|
2020-12-19 03:55:52 +02:00
|
|
|
return this.$i && (
|
|
|
|
`@${this.username}@${toUnicode(this.host)}` === `@${this.$i.username}@${toUnicode(localHost)}`.toLowerCase()
|
2019-04-15 14:41:56 +03:00
|
|
|
);
|
2018-12-12 06:06:05 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toUnicode
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ldlomzub {
|
|
|
|
color: var(--mention);
|
2020-06-04 16:19:08 +03:00
|
|
|
|
|
|
|
&.isMe {
|
|
|
|
color: var(--mentionMe);
|
|
|
|
}
|
2020-01-29 21:37:25 +02:00
|
|
|
|
|
|
|
> .me {
|
|
|
|
pointer-events: none;
|
|
|
|
user-select: none;
|
|
|
|
font-size: 70%;
|
|
|
|
vertical-align: top;
|
|
|
|
}
|
2018-12-12 06:06:05 +02:00
|
|
|
|
2021-10-24 15:02:50 +03:00
|
|
|
> .icon {
|
|
|
|
width: 1.5em;
|
|
|
|
margin: 0 0.2em;
|
|
|
|
vertical-align: bottom;
|
|
|
|
border-radius: 100%;
|
|
|
|
}
|
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
> .main {
|
|
|
|
> .host {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-12 06:06:05 +02:00
|
|
|
</style>
|