2018-12-12 06:06:05 +02:00
|
|
|
<template>
|
2019-07-18 21:13:47 +03:00
|
|
|
<router-link class="ldlomzub" :to="url" v-user-preview="canonical" v-if="url.startsWith('/')">
|
2020-01-29 21:37:25 +02:00
|
|
|
<span class="me" v-if="isMe">{{ $t('you') }}</span>
|
2018-12-12 06:06:05 +02:00
|
|
|
<span class="main">
|
|
|
|
<span class="username">@{{ username }}</span>
|
2020-01-29 21:37:25 +02:00
|
|
|
<span class="host" v-if="(host != localHost) || $store.state.settings.showFullAcct">@{{ toUnicode(host) }}</span>
|
2018-12-12 06:06:05 +02:00
|
|
|
</span>
|
|
|
|
</router-link>
|
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">
|
|
|
|
import Vue from 'vue';
|
2020-01-29 21:37:25 +02:00
|
|
|
import i18n from '../i18n';
|
2018-12-12 06:06:05 +02:00
|
|
|
import { toUnicode } from 'punycode';
|
2020-01-29 21:37:25 +02:00
|
|
|
import { host as localHost } from '../config';
|
2018-12-12 06:06:05 +02:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2020-01-29 21:37:25 +02:00
|
|
|
i18n,
|
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 {
|
|
|
|
switch (this.host) {
|
|
|
|
case 'twitter.com':
|
|
|
|
case 'github.com':
|
|
|
|
return `https://${this.host}/${this.username}`;
|
|
|
|
default:
|
|
|
|
return `/${this.canonical}`;
|
|
|
|
}
|
|
|
|
},
|
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 {
|
2019-04-15 14:41:56 +03:00
|
|
|
return this.$store.getters.isSignedIn && (
|
|
|
|
`@${this.username}@${toUnicode(this.host)}` === `@${this.$store.state.i.username}@${toUnicode(localHost)}`.toLowerCase()
|
|
|
|
);
|
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);
|
|
|
|
|
|
|
|
> .me {
|
|
|
|
pointer-events: none;
|
|
|
|
user-select: none;
|
|
|
|
font-size: 70%;
|
|
|
|
vertical-align: top;
|
|
|
|
}
|
2018-12-12 06:06:05 +02:00
|
|
|
|
2020-01-29 21:37:25 +02:00
|
|
|
> .main {
|
|
|
|
> .host {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-12 06:06:05 +02:00
|
|
|
</style>
|