From 08d518324a3e5e9a75b61c73ac615cae4a8e61fb Mon Sep 17 00:00:00 2001 From: Zyy Date: Wed, 2 Sep 2026 12:14:03 +0800 Subject: [PATCH] fix(frontend): refine account quota layout Co-authored-by: Codex --- .../components/AccountQuotaPanel/index.vue | 2 +- .../AccountQuotaSummaryCell/Entry.vue | 17 +++- .../AccountQuotaSummaryCell/WindowGroup.vue | 37 ++++++-- .../AccountQuotaSummaryCell/index.vue | 85 +++++++++++++++---- .../accounts/components/AccountUsagePanel.vue | 14 +-- frontend/src/views/accounts/index.vue | 2 +- 6 files changed, 121 insertions(+), 36 deletions(-) diff --git a/frontend/src/views/accounts/components/AccountQuotaPanel/index.vue b/frontend/src/views/accounts/components/AccountQuotaPanel/index.vue index cfc831639..cb21a1f7a 100644 --- a/frontend/src/views/accounts/components/AccountQuotaPanel/index.vue +++ b/frontend/src/views/accounts/components/AccountQuotaPanel/index.vue @@ -77,7 +77,7 @@ const profileOpen = shallowRef(false) -
+
() + showPercentage?: boolean +}>(), { + showPercentage: true, +}) const now = useUiClock() -const grouped = computed(() => props.windows.length > 1 && Boolean(props.label)) const detailHeading = computed(() => props.label) const detailTitle = computed(() => detailHeading.value ?? props.windows[0]?.labelDisplay ?? '额度详情') +const summaryLabel = computed(() => props.label ?? props.windows[0]?.labelDisplay ?? '额度') +const hasQuotaWindow = computed(() => props.windows.some(window => typeof window.usedPercent === 'number')) const detailItems = computed(() => props.windows.map((window) => { const view = resolveAccountUsageWindowPresentation({ @@ -82,7 +86,12 @@ function quotaWindowCode(windowSeconds: number | null, role: AccountQuotaWindow[ :aria-expanded="open" aria-haspopup="dialog" > - + () + showPercentage?: boolean +}>(), { + showPercentage: true, +}) const windowItems = computed(() => props.windows.map(window => ({ key: window.key, @@ -16,6 +19,17 @@ const windowItems = computed(() => props.windows.map(window => ({ usedPercentDisplay: window.usedPercentDisplay, presentation: quotaWindowPresentation(window, '2px'), }))) +const highestUsageWindow = computed(() => props.windows.reduce((highest, window) => { + if (typeof window.usedPercent !== 'number') + return highest + if (!highest || typeof highest.usedPercent !== 'number' || window.usedPercent > highest.usedPercent) + return window + return highest +}, undefined as AccountQuotaWindow | undefined)) +const highestUsageDisplay = computed(() => highestUsageWindow.value?.usedPercentDisplay ?? '—') +const highestUsageTextClass = computed(() => highestUsageWindow.value + ? quotaWindowPresentation(highestUsageWindow.value, '2px').percentTextClass + : 'text-cp-text-quaternary') const trackGridStyle = computed(() => ({ gridTemplateColumns: `repeat(${Math.max(windowItems.value.length, 1)}, minmax(0, 1fr))`, @@ -23,16 +37,25 @@ const trackGridStyle = computed(() => ({