mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-28 08:00:38 +00:00
fix(accounts): show truncated emails and notes consistently
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -240,9 +240,9 @@
|
||||
"cleanupRemove": "移除",
|
||||
"cleanupSelected": "移除 {count} 项"
|
||||
},
|
||||
"notes": {
|
||||
"viewAccountNotes": "查看账号备注",
|
||||
"title": "账号备注"
|
||||
"identity": {
|
||||
"notes": "账号备注",
|
||||
"email": "账号邮箱"
|
||||
},
|
||||
"overview": {
|
||||
"totalAccounts": "总账号",
|
||||
|
||||
@@ -240,9 +240,9 @@
|
||||
"cleanupRemove": "移除",
|
||||
"cleanupSelected": "移除 {count} 項"
|
||||
},
|
||||
"notes": {
|
||||
"viewAccountNotes": "查看賬號備註",
|
||||
"title": "賬號備註"
|
||||
"identity": {
|
||||
"notes": "賬號備註",
|
||||
"email": "賬號信箱"
|
||||
},
|
||||
"overview": {
|
||||
"totalAccounts": "總賬號",
|
||||
|
||||
@@ -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<Account, 'id' | 'email' | 'planType' | 'planTypeDisplay'>
|
||||
& Partial<Pick<Account, 'accountId' | 'notes' | 'name' | 'authenticationKind' | 'upstream'>>
|
||||
@@ -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(() => {
|
||||
<slot name="meta" />
|
||||
<AccountPlanBadge v-if="showPlan" :upstream="account.upstream" :authentication-kind="account.authenticationKind" :plan-type="account.planType" :plan-type-display="account.planTypeDisplay" :size="metaSize" />
|
||||
</div>
|
||||
<AccountNotesPopover v-else-if="visibleNotes" :notes="visibleNotes" class="mt-0.5" />
|
||||
<div v-else-if="secondaryText" class="truncate font-emphasis" :class="secondaryClass">
|
||||
{{ secondaryText }}
|
||||
</div>
|
||||
<AccountSecondaryText
|
||||
v-else-if="secondaryText"
|
||||
:text="secondaryText"
|
||||
:label="visibleNotes ? t('accounts.identity.notes') : t('accounts.identity.email')"
|
||||
:class="secondaryClass"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
+11
-13
@@ -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<HTMLSpanElement>('notesText')
|
||||
const detailId = `account-secondary-${useId()}`
|
||||
const textRef = useTemplateRef<HTMLSpanElement>('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' })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -45,20 +43,20 @@ watch(() => props.notes, recheckOpen, { flush: 'post' })
|
||||
<template #reference>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex min-w-0 max-w-full cursor-default touch-manipulation items-center rounded-z-sm border-0 bg-transparent p-0 text-left font-mono text-z-xs leading-4 font-emphasis text-z-text-quaternary outline-none focus-visible:ring-2 focus-visible:ring-z-control-outline"
|
||||
:aria-label="t('accounts.notes.viewAccountNotes')"
|
||||
class="inline-flex min-w-0 max-w-full cursor-default touch-manipulation items-center rounded-z-sm border-0 bg-transparent p-0 text-left font-emphasis outline-none focus-visible:ring-2 focus-visible:ring-z-control-outline"
|
||||
:aria-label="label"
|
||||
aria-haspopup="dialog"
|
||||
:aria-expanded="open"
|
||||
:aria-controls="open ? detailId : undefined"
|
||||
>
|
||||
<span ref="notesText" class="min-w-0 truncate">{{ notes }}</span>
|
||||
<span ref="textElement" class="min-w-0 truncate">{{ text }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<section :id="detailId" class="w-max max-w-[min(20rem,calc(100vw-1rem))] overflow-hidden rounded-z-lg" role="dialog" :aria-label="t('accounts.notes.title')">
|
||||
<section :id="detailId" class="w-max max-w-[min(20rem,calc(100vw-1rem))] overflow-hidden rounded-z-lg" role="dialog" :aria-label="label">
|
||||
<ZScrollbar max-height="min(240px, calc(100dvh - 2rem))">
|
||||
<div class="px-3 py-2.5 text-z-sm leading-5 whitespace-pre-wrap text-z-text select-text wrap-anywhere">
|
||||
{{ notes }}
|
||||
{{ text }}
|
||||
</div>
|
||||
</ZScrollbar>
|
||||
</section>
|
||||
Reference in New Issue
Block a user