特定ホストへのメンションの特別処理をクライアントに追加 (#5185)

* 特定ホストへのメンションの特別処理をクライアントに追加

Fix #5168

* Apply suggestions from code review

Co-Authored-By: Acid Chicken (硫酸鶏) <root@acid-chicken.com>

* Apply suggestions from code review

Co-Authored-By: Acid Chicken (硫酸鶏) <root@acid-chicken.com>

* Apply suggestions from code review

Co-Authored-By: Acid Chicken (硫酸鶏) <root@acid-chicken.com>

* Fix indent
This commit is contained in:
rinsuki 2019-07-19 03:13:47 +09:00 committed by syuilo
parent f6ac6f9c6f
commit 2af79e9855
1 changed files with 16 additions and 1 deletions

View File

@ -1,11 +1,17 @@
<template> <template>
<router-link class="ldlomzub" :to="`/${ canonical }`" v-user-preview="canonical"> <router-link class="ldlomzub" :to="url" v-user-preview="canonical" v-if="url.startsWith('/')">
<span class="me" v-if="isMe">{{ $t('@.you') }}</span> <span class="me" v-if="isMe">{{ $t('@.you') }}</span>
<span class="main"> <span class="main">
<span class="username">@{{ username }}</span> <span class="username">@{{ username }}</span>
<span class="host" :class="{ fade: $store.state.settings.contrastedAcct }" v-if="(host != localHost) || $store.state.settings.showFullAcct">@{{ toUnicode(host) }}</span> <span class="host" :class="{ fade: $store.state.settings.contrastedAcct }" v-if="(host != localHost) || $store.state.settings.showFullAcct">@{{ toUnicode(host) }}</span>
</span> </span>
</router-link> </router-link>
<a class="ldlomzub" :href="url" target="_blank" rel="noopener" v-else>
<span class="main">
<span class="username">@{{ username }}</span>
<span class="host" :class="{ fade: $store.state.settings.contrastedAcct }">@{{ toUnicode(host) }}</span>
</span>
</a>
</template> </template>
<script lang="ts"> <script lang="ts">
@ -32,6 +38,15 @@ export default Vue.extend({
}; };
}, },
computed: { computed: {
url(): string {
switch (this.host) {
case 'twitter.com':
case 'github.com':
return `https://${this.host}/${this.username}`;
default:
return `/${this.canonical}`;
}
},
canonical(): string { canonical(): string {
return this.host === localHost ? `@${this.username}` : `@${this.username}@${toUnicode(this.host)}`; return this.host === localHost ? `@${this.username}` : `@${this.username}@${toUnicode(this.host)}`;
}, },