1
0

feat: put account name copy button (#2347)

This commit is contained in:
TAKAHASHI Shuuji 2023-11-14 23:34:56 +09:00 committed by GitHub
parent 7ec76ffed9
commit e00e4074e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 1 deletions

View File

@ -22,6 +22,7 @@ const namedFields = ref<mastodon.v1.AccountField[]>([])
const iconFields = ref<mastodon.v1.AccountField[]>([])
const isEditingPersonalNote = ref<boolean>(false)
const hasHeader = $computed(() => !account.header.endsWith('/original/missing.png'))
const isCopied = ref<boolean>(false)
function getFieldIconTitle(fieldName: string) {
return fieldName === 'Joined' ? t('account.joined') : fieldName
@ -105,6 +106,23 @@ const isSelf = $(useSelfAccount(() => account))
const isNotifiedOnPost = $computed(() => !!relationship?.notifying)
const personalNoteMaxLength = 2000
async function copyAccountName() {
try {
const shortHandle = getShortHandle(account)
const serverName = getServerName(account)
const accountName = `${shortHandle}@${serverName}`
await navigator.clipboard.writeText(accountName)
}
catch (err) {
console.error('Failed to copy account name:', err)
}
isCopied.value = true
setTimeout(() => {
isCopied.value = false
}, 2000)
}
</script>
<template>
@ -175,7 +193,15 @@ const personalNoteMaxLength = 2000
<AccountLockIndicator v-if="account.locked" show-label />
<AccountBotIndicator v-if="account.bot" show-label />
</div>
<AccountHandle :account="account" overflow-unset line-clamp-unset />
<div flex items-center gap-1>
<AccountHandle :account="account" overflow-unset line-clamp-unset />
<CommonTooltip placement="bottom" :content="$t('account.copy_account_name')" no-auto-focus flex>
<button text-secondary-light text-sm :class="isCopied ? 'i-ri:check-fill text-green' : 'i-ri:file-copy-line'" @click="copyAccountName">
<span sr-only>{{ $t('account.copy_account_name') }}</span>
</button>
</CommonTooltip>
</div>
</div>
</div>
<label

View File

@ -15,6 +15,7 @@
"blocked_users": "Blocked users",
"blocking": "Blocked",
"bot": "BOT",
"copy_account_name": "Copy account name",
"favourites": "Favorites",
"follow": "Follow",
"follow_back": "Follow back",

View File

@ -13,6 +13,7 @@
"blocked_users": "ブロックしたユーザー",
"blocking": "ブロック中",
"bot": "BOT",
"copy_account_name": "アカウント名をコピー",
"favourites": "お気に入り",
"follow": "フォローする",
"follow_back": "フォローバックする",