diff --git a/frontend/src/i18n/locales/en/accounts.json b/frontend/src/i18n/locales/en/accounts.json index 9019fa031..837371e3e 100644 --- a/frontend/src/i18n/locales/en/accounts.json +++ b/frontend/src/i18n/locales/en/accounts.json @@ -240,9 +240,9 @@ "cleanupRemove": "Remove", "cleanupSelected": "Remove ({count})" }, - "notes": { - "viewAccountNotes": "View account notes", - "title": "Account notes" + "identity": { + "notes": "Account notes", + "email": "Account email" }, "overview": { "totalAccounts": "Total accounts", diff --git a/frontend/src/i18n/locales/zh-Hans/accounts.json b/frontend/src/i18n/locales/zh-Hans/accounts.json index 7d695003f..7df6e9183 100644 --- a/frontend/src/i18n/locales/zh-Hans/accounts.json +++ b/frontend/src/i18n/locales/zh-Hans/accounts.json @@ -240,9 +240,9 @@ "cleanupRemove": "移除", "cleanupSelected": "移除 {count} 项" }, - "notes": { - "viewAccountNotes": "查看账号备注", - "title": "账号备注" + "identity": { + "notes": "账号备注", + "email": "账号邮箱" }, "overview": { "totalAccounts": "总账号", diff --git a/frontend/src/i18n/locales/zh-Hant/accounts.json b/frontend/src/i18n/locales/zh-Hant/accounts.json index 5f07f602f..8e15f7881 100644 --- a/frontend/src/i18n/locales/zh-Hant/accounts.json +++ b/frontend/src/i18n/locales/zh-Hant/accounts.json @@ -240,9 +240,9 @@ "cleanupRemove": "移除", "cleanupSelected": "移除 {count} 項" }, - "notes": { - "viewAccountNotes": "查看賬號備註", - "title": "賬號備註" + "identity": { + "notes": "賬號備註", + "email": "賬號信箱" }, "overview": { "totalAccounts": "總賬號", diff --git a/frontend/src/views/accounts/components/AccountIdentityCell.vue b/frontend/src/views/accounts/components/AccountIdentityCell.vue index fc2f034f8..f1706d3df 100644 --- a/frontend/src/views/accounts/components/AccountIdentityCell.vue +++ b/frontend/src/views/accounts/components/AccountIdentityCell.vue @@ -2,11 +2,12 @@ import type { Account } from '@/api' import { computed } from 'vue' +import { useI18n } from 'vue-i18n' import AccountPlanBadge from '@/components/account-plan-badge/index.vue' import { stablePresetVisualToneClass } from '@/utils/color' import { accountIdentityLabel } from '../utils/accountIdentity' -import AccountNotesPopover from './AccountNotesPopover.vue' +import AccountSecondaryText from './AccountSecondaryText.vue' type AccountIdentity = Pick & Partial> @@ -29,6 +30,7 @@ const props = withDefaults( }, ) +const { t } = useI18n({ useScope: 'global' }) const emailText = computed(() => props.account.email?.trim()) const displayTitle = computed(() => { const label = accountIdentityLabel(props.account) @@ -46,13 +48,17 @@ const identityTitle = computed(() => { : displayTitle.value }) -const secondaryText = computed(() => props.account.authenticationKind !== 'api_key' && emailText.value !== displayTitle.value - ? emailText.value - : undefined) +const secondaryText = computed(() => { + if (visibleNotes.value) + return visibleNotes.value + if (props.account.authenticationKind !== 'api_key' && emailText.value !== displayTitle.value) + return emailText.value + return undefined +}) -const secondaryClass = computed(() => props.size === 'lg' +const secondaryClass = computed(() => props.size === 'lg' && !visibleNotes.value ? 'mt-1 text-z-sm text-z-text-secondary' - : 'mt-0.5 font-mono text-z-xs text-z-text-quaternary') + : 'mt-0.5 font-mono text-z-xs leading-4 text-z-text-quaternary') const initial = computed(() => displayTitle.value.slice(0, 1).toUpperCase()) @@ -102,10 +108,12 @@ const avatarToneClass = computed(() => { - -
- {{ secondaryText }} -
+ diff --git a/frontend/src/views/accounts/components/AccountNotesPopover.vue b/frontend/src/views/accounts/components/AccountSecondaryText.vue similarity index 71% rename from frontend/src/views/accounts/components/AccountNotesPopover.vue rename to frontend/src/views/accounts/components/AccountSecondaryText.vue index b56907286..eca021f3b 100644 --- a/frontend/src/views/accounts/components/AccountNotesPopover.vue +++ b/frontend/src/views/accounts/components/AccountSecondaryText.vue @@ -4,21 +4,19 @@ import { ZPopover, ZScrollbar } from '@codex-proxy/ui' import { useEventListener } from '@vueuse/core' import { computed, shallowRef, useId, useTemplateRef, watch } from 'vue' -import { useI18n } from 'vue-i18n' const props = defineProps<{ - notes: string + text: string + label: string }>() -const { t } = useI18n({ useScope: 'global' }) - -const detailId = `account-notes-${useId()}` -const notesTextRef = useTemplateRef('notesText') +const detailId = `account-secondary-${useId()}` +const textRef = useTemplateRef('textElement') const open = shallowRef(false) const viewportTarget = computed(() => open.value ? window : null) function updateOpen(nextOpen: boolean) { - const text = notesTextRef.value + const text = textRef.value // 在实际打开前按需测量,悬停、点击和键盘入口共用同一道溢出检查。 open.value = nextOpen && Boolean(text && text.scrollWidth > text.clientWidth) } @@ -29,7 +27,7 @@ function recheckOpen() { } useEventListener(viewportTarget, 'resize', recheckOpen) -watch(() => props.notes, recheckOpen, { flush: 'post' }) +watch(() => props.text, recheckOpen, { flush: 'post' })