diff --git a/frontend/src/components/account/UsageProgressBar.vue b/frontend/src/components/account/UsageProgressBar.vue
index bf08127185..90b8b4ea17 100644
--- a/frontend/src/components/account/UsageProgressBar.vue
+++ b/frontend/src/components/account/UsageProgressBar.vue
@@ -35,7 +35,7 @@
-
+
{{ label }}
@@ -78,7 +78,7 @@ const props = withDefaults(
estimatedTotalCost?: number | null
showNowWhenIdle?: boolean
remainingCapacity?: boolean
- /** fixed: 定宽居中徽章(账号页纵向对齐);auto: 限宽截断左对齐(监控页组合标签) */
+ /** fixed: 最小宽度居中徽章;auto: 限宽截断左对齐(监控页组合标签) */
labelWidth?: 'fixed' | 'auto'
}>(),
{ labelWidth: 'fixed' }
@@ -125,12 +125,11 @@ const labelClass = computed(() => {
return colors[props.color]
})
-// Label badge width mode: fixed 定宽保证账号页纵向对齐;auto 限宽截断适配
-// 监控页「Pro/7 天」类组合标签。百分比列在两种模式下保持不变。
+// Keep short labels aligned, but let longer labels reserve space before the bar.
const labelSizeClass = computed(() =>
props.labelWidth === 'auto'
? 'max-w-[72px] shrink-0 truncate rounded px-1 text-left text-[10px] font-medium'
- : 'w-[32px] shrink-0 rounded px-1 text-center text-[10px] font-medium'
+ : 'min-w-[32px] shrink-0 whitespace-nowrap rounded px-1 text-center text-[10px] font-medium'
)
// Progress bar color based on utilization
diff --git a/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts b/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts
index 2b954c748f..5c00a58f62 100644
--- a/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts
+++ b/frontend/src/components/account/__tests__/UsageProgressBar.spec.ts
@@ -186,13 +186,14 @@ describe('UsageProgressBar', () => {
expect(mountAt(90).get('.h-1\\.5 + span').classes()).toContain('text-red-600')
})
- it('labelWidth 默认 fixed:标签保持定宽居中,百分比列不变', () => {
+ it('labelWidth 默认 fixed:标签保持最小宽度且不换行,百分比列不变', () => {
const wrapper = mount(UsageProgressBar, {
props: { label: '5h', utilization: 30, color: 'indigo' }
})
const label = wrapper.get('.gap-1 > span')
- expect(label.classes()).toContain('w-[32px]')
+ expect(label.classes()).toContain('min-w-[32px]')
+ expect(label.classes()).toContain('whitespace-nowrap')
expect(label.classes()).toContain('text-center')
expect(label.classes()).not.toContain('max-w-[72px]')