mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-24 18:26:17 +03:00
feat: put account name copy button (#2347)
This commit is contained in:
parent
7ec76ffed9
commit
e00e4074e1
3 changed files with 29 additions and 1 deletions
|
@ -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>
|
||||
|
||||
<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
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"blocked_users": "ブロックしたユーザー",
|
||||
"blocking": "ブロック中",
|
||||
"bot": "BOT",
|
||||
"copy_account_name": "アカウント名をコピー",
|
||||
"favourites": "お気に入り",
|
||||
"follow": "フォローする",
|
||||
"follow_back": "フォローバックする",
|
||||
|
|
Loading…
Reference in a new issue