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