2025-12-18 13:50:39 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<span
|
|
|
|
|
|
:class="[
|
2025-12-25 08:40:12 -08:00
|
|
|
|
'inline-flex items-center gap-1.5 rounded-md px-2 py-0.5 text-xs font-medium transition-colors',
|
2025-12-23 10:01:58 +08:00
|
|
|
|
badgeClass
|
2025-12-18 13:50:39 +08:00
|
|
|
|
]"
|
|
|
|
|
|
>
|
2025-12-23 10:01:58 +08:00
|
|
|
|
<!-- Platform logo -->
|
|
|
|
|
|
<PlatformIcon v-if="platform" :platform="platform" size="sm" />
|
|
|
|
|
|
<!-- Group name -->
|
2025-12-18 13:50:39 +08:00
|
|
|
|
<span class="truncate">{{ name }}</span>
|
2025-12-23 11:03:10 +08:00
|
|
|
|
<!-- Right side label -->
|
2025-12-25 08:40:12 -08:00
|
|
|
|
<span v-if="showLabel" :class="labelClass">
|
2025-12-23 10:01:58 +08:00
|
|
|
|
{{ labelText }}
|
2025-12-18 13:50:39 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { computed } from 'vue'
|
2025-12-23 10:01:58 +08:00
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
|
import type { SubscriptionType, GroupPlatform } from '@/types'
|
|
|
|
|
|
import PlatformIcon from './PlatformIcon.vue'
|
2025-12-18 13:50:39 +08:00
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
|
name: string
|
2025-12-23 10:01:58 +08:00
|
|
|
|
platform?: GroupPlatform
|
2025-12-18 13:50:39 +08:00
|
|
|
|
subscriptionType?: SubscriptionType
|
|
|
|
|
|
rateMultiplier?: number
|
|
|
|
|
|
showRate?: boolean
|
2025-12-25 08:40:12 -08:00
|
|
|
|
daysRemaining?: number | null // 剩余天数(订阅类型时使用)
|
2025-12-18 13:50:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
|
|
|
|
subscriptionType: 'standard',
|
2025-12-23 11:03:10 +08:00
|
|
|
|
showRate: true,
|
|
|
|
|
|
daysRemaining: null
|
2025-12-18 13:50:39 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-23 10:01:58 +08:00
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
2025-12-18 13:50:39 +08:00
|
|
|
|
const isSubscription = computed(() => props.subscriptionType === 'subscription')
|
2025-12-23 10:01:58 +08:00
|
|
|
|
|
2025-12-23 11:03:10 +08:00
|
|
|
|
// 是否显示右侧标签
|
|
|
|
|
|
const showLabel = computed(() => {
|
|
|
|
|
|
if (!props.showRate) return false
|
|
|
|
|
|
// 订阅类型:显示天数或"订阅"
|
|
|
|
|
|
if (isSubscription.value) return true
|
|
|
|
|
|
// 标准类型:显示倍率
|
|
|
|
|
|
return props.rateMultiplier !== undefined
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Label text
|
2025-12-23 10:01:58 +08:00
|
|
|
|
const labelText = computed(() => {
|
|
|
|
|
|
if (isSubscription.value) {
|
2025-12-23 11:03:10 +08:00
|
|
|
|
// 如果有剩余天数,显示天数
|
|
|
|
|
|
if (props.daysRemaining !== null && props.daysRemaining !== undefined) {
|
|
|
|
|
|
if (props.daysRemaining <= 0) {
|
|
|
|
|
|
return t('admin.users.expired')
|
|
|
|
|
|
}
|
|
|
|
|
|
return t('admin.users.daysRemaining', { days: props.daysRemaining })
|
|
|
|
|
|
}
|
|
|
|
|
|
// 否则显示"订阅"
|
2025-12-23 10:01:58 +08:00
|
|
|
|
return t('groups.subscription')
|
|
|
|
|
|
}
|
|
|
|
|
|
return props.rateMultiplier !== undefined ? `${props.rateMultiplier}x` : ''
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-23 11:03:10 +08:00
|
|
|
|
// Label style based on type and days remaining
|
2025-12-23 10:01:58 +08:00
|
|
|
|
const labelClass = computed(() => {
|
|
|
|
|
|
const base = 'px-1.5 py-0.5 rounded text-[10px] font-semibold'
|
2025-12-23 11:03:10 +08:00
|
|
|
|
|
|
|
|
|
|
if (!isSubscription.value) {
|
|
|
|
|
|
// Standard: subtle background
|
|
|
|
|
|
return `${base} bg-black/10 dark:bg-white/10`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 订阅类型:根据剩余天数显示不同颜色
|
|
|
|
|
|
if (props.daysRemaining !== null && props.daysRemaining !== undefined) {
|
|
|
|
|
|
if (props.daysRemaining <= 0 || props.daysRemaining <= 3) {
|
|
|
|
|
|
// 已过期或紧急(<=3天):红色
|
|
|
|
|
|
return `${base} bg-red-200/80 text-red-800 dark:bg-red-800/50 dark:text-red-300`
|
|
|
|
|
|
}
|
|
|
|
|
|
if (props.daysRemaining <= 7) {
|
|
|
|
|
|
// 警告(<=7天):橙色
|
|
|
|
|
|
return `${base} bg-amber-200/80 text-amber-800 dark:bg-amber-800/50 dark:text-amber-300`
|
2025-12-23 10:01:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-23 11:03:10 +08:00
|
|
|
|
|
|
|
|
|
|
// 正常状态或无天数:根据平台显示主题色
|
|
|
|
|
|
if (props.platform === 'anthropic') {
|
|
|
|
|
|
return `${base} bg-orange-200/60 text-orange-800 dark:bg-orange-800/40 dark:text-orange-300`
|
|
|
|
|
|
}
|
|
|
|
|
|
if (props.platform === 'openai') {
|
|
|
|
|
|
return `${base} bg-emerald-200/60 text-emerald-800 dark:bg-emerald-800/40 dark:text-emerald-300`
|
|
|
|
|
|
}
|
2025-12-25 08:40:12 -08:00
|
|
|
|
if (props.platform === 'gemini') {
|
|
|
|
|
|
return `${base} bg-blue-200/60 text-blue-800 dark:bg-blue-800/40 dark:text-blue-300`
|
|
|
|
|
|
}
|
2025-12-23 11:03:10 +08:00
|
|
|
|
return `${base} bg-violet-200/60 text-violet-800 dark:bg-violet-800/40 dark:text-violet-300`
|
2025-12-23 10:01:58 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Badge color based on platform and subscription type
|
|
|
|
|
|
const badgeClass = computed(() => {
|
|
|
|
|
|
if (props.platform === 'anthropic') {
|
|
|
|
|
|
// Claude: orange theme
|
|
|
|
|
|
return isSubscription.value
|
|
|
|
|
|
? 'bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400'
|
|
|
|
|
|
: 'bg-amber-50 text-amber-700 dark:bg-amber-900/20 dark:text-amber-400'
|
|
|
|
|
|
} else if (props.platform === 'openai') {
|
|
|
|
|
|
// OpenAI: green theme
|
|
|
|
|
|
return isSubscription.value
|
|
|
|
|
|
? 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400'
|
|
|
|
|
|
: 'bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-400'
|
|
|
|
|
|
}
|
2025-12-25 08:40:12 -08:00
|
|
|
|
if (props.platform === 'gemini') {
|
|
|
|
|
|
return isSubscription.value
|
|
|
|
|
|
? 'bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400'
|
|
|
|
|
|
: 'bg-sky-50 text-sky-700 dark:bg-sky-900/20 dark:text-sky-400'
|
|
|
|
|
|
}
|
2025-12-23 10:01:58 +08:00
|
|
|
|
// Fallback: original colors
|
|
|
|
|
|
return isSubscription.value
|
|
|
|
|
|
? 'bg-violet-100 text-violet-700 dark:bg-violet-900/30 dark:text-violet-400'
|
|
|
|
|
|
: 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400'
|
|
|
|
|
|
})
|
2025-12-18 13:50:39 +08:00
|
|
|
|
</script>
|