99 <PlatformIcon v-if =" platform " :platform =" platform " size="sm" />
1010 <!-- Group name -->
1111 <span class =" truncate" >{{ name }}</span >
12- <!-- Right side label: subscription shows "订阅", standard shows rate multiplier -->
12+ <!-- Right side label -->
1313 <span
14- v-if =" showRate "
14+ v-if =" showLabel "
1515 :class =" labelClass"
1616 >
1717 {{ labelText }}
@@ -31,39 +31,73 @@ interface Props {
3131 subscriptionType? : SubscriptionType
3232 rateMultiplier? : number
3333 showRate? : boolean
34+ daysRemaining? : number | null // 剩余天数(订阅类型时使用)
3435}
3536
3637const props = withDefaults (defineProps <Props >(), {
3738 subscriptionType: ' standard' ,
38- showRate: true
39+ showRate: true ,
40+ daysRemaining: null
3941})
4042
4143const { t } = useI18n ()
4244
4345const isSubscription = computed (() => props .subscriptionType === ' subscription' )
4446
45- // Label text: subscription shows localized text, standard shows rate
47+ // 是否显示右侧标签
48+ const showLabel = computed (() => {
49+ if (! props .showRate ) return false
50+ // 订阅类型:显示天数或"订阅"
51+ if (isSubscription .value ) return true
52+ // 标准类型:显示倍率
53+ return props .rateMultiplier !== undefined
54+ })
55+
56+ // Label text
4657const labelText = computed (() => {
4758 if (isSubscription .value ) {
59+ // 如果有剩余天数,显示天数
60+ if (props .daysRemaining !== null && props .daysRemaining !== undefined ) {
61+ if (props .daysRemaining <= 0 ) {
62+ return t (' admin.users.expired' )
63+ }
64+ return t (' admin.users.daysRemaining' , { days: props .daysRemaining })
65+ }
66+ // 否则显示"订阅"
4867 return t (' groups.subscription' )
4968 }
5069 return props .rateMultiplier !== undefined ? ` ${props .rateMultiplier }x ` : ' '
5170})
5271
53- // Label style based on type
72+ // Label style based on type and days remaining
5473const labelClass = computed (() => {
5574 const base = ' px-1.5 py-0.5 rounded text-[10px] font-semibold'
56- if (isSubscription .value ) {
57- // Subscription: more prominent style with border
58- if (props .platform === ' anthropic' ) {
59- return ` ${base } bg-orange-200/60 text-orange-800 dark:bg-orange-800/40 dark:text-orange-300 `
60- } else if (props .platform === ' openai' ) {
61- return ` ${base } bg-emerald-200/60 text-emerald-800 dark:bg-emerald-800/40 dark:text-emerald-300 `
75+
76+ if (! isSubscription .value ) {
77+ // Standard: subtle background
78+ return ` ${base } bg-black/10 dark:bg-white/10 `
79+ }
80+
81+ // 订阅类型:根据剩余天数显示不同颜色
82+ if (props .daysRemaining !== null && props .daysRemaining !== undefined ) {
83+ if (props .daysRemaining <= 0 || props .daysRemaining <= 3 ) {
84+ // 已过期或紧急(<=3天):红色
85+ return ` ${base } bg-red-200/80 text-red-800 dark:bg-red-800/50 dark:text-red-300 `
86+ }
87+ if (props .daysRemaining <= 7 ) {
88+ // 警告(<=7天):橙色
89+ return ` ${base } bg-amber-200/80 text-amber-800 dark:bg-amber-800/50 dark:text-amber-300 `
6290 }
63- return ` ${base } bg-violet-200/60 text-violet-800 dark:bg-violet-800/40 dark:text-violet-300 `
6491 }
65- // Standard: subtle background
66- return ` ${base } bg-black/10 dark:bg-white/10 `
92+
93+ // 正常状态或无天数:根据平台显示主题色
94+ if (props .platform === ' anthropic' ) {
95+ return ` ${base } bg-orange-200/60 text-orange-800 dark:bg-orange-800/40 dark:text-orange-300 `
96+ }
97+ if (props .platform === ' openai' ) {
98+ return ` ${base } bg-emerald-200/60 text-emerald-800 dark:bg-emerald-800/40 dark:text-emerald-300 `
99+ }
100+ return ` ${base } bg-violet-200/60 text-violet-800 dark:bg-violet-800/40 dark:text-violet-300 `
67101})
68102
69103// Badge color based on platform and subscription type
0 commit comments