feat: 支持用户专属分组倍率配置

This commit is contained in:
shaw
2026-02-05 16:00:34 +08:00
parent 6d0152c8e2
commit 2b192f7dca
27 changed files with 705 additions and 89 deletions

View File

@@ -11,7 +11,14 @@
<span class="truncate">{{ name }}</span>
<!-- Right side label -->
<span v-if="showLabel" :class="labelClass">
{{ labelText }}
<template v-if="hasCustomRate">
<!-- 原倍率删除线 + 专属倍率高亮 -->
<span class="line-through opacity-50 mr-0.5">{{ rateMultiplier }}x</span>
<span class="font-bold">{{ userRateMultiplier }}x</span>
</template>
<template v-else>
{{ labelText }}
</template>
</span>
</span>
</template>
@@ -27,6 +34,7 @@ interface Props {
platform?: GroupPlatform
subscriptionType?: SubscriptionType
rateMultiplier?: number
userRateMultiplier?: number | null // 用户专属倍率
showRate?: boolean
daysRemaining?: number | null // 剩余天数(订阅类型时使用)
}
@@ -34,20 +42,31 @@ interface Props {
const props = withDefaults(defineProps<Props>(), {
subscriptionType: 'standard',
showRate: true,
daysRemaining: null
daysRemaining: null,
userRateMultiplier: null
})
const { t } = useI18n()
const isSubscription = computed(() => props.subscriptionType === 'subscription')
// 是否有专属倍率(且与默认倍率不同)
const hasCustomRate = computed(() => {
return (
props.userRateMultiplier !== null &&
props.userRateMultiplier !== undefined &&
props.rateMultiplier !== undefined &&
props.userRateMultiplier !== props.rateMultiplier
)
})
// 是否显示右侧标签
const showLabel = computed(() => {
if (!props.showRate) return false
// 订阅类型:显示天数或"订阅"
if (isSubscription.value) return true
// 标准类型:显示倍率
return props.rateMultiplier !== undefined
// 标准类型:显示倍率(包括专属倍率)
return props.rateMultiplier !== undefined || hasCustomRate.value
})
// Label text
@@ -71,7 +90,7 @@ const labelClass = computed(() => {
const base = 'px-1.5 py-0.5 rounded text-[10px] font-semibold'
if (!isSubscription.value) {
// Standard: subtle background
// Standard: subtle background (不再为专属倍率使用不同的背景色)
return `${base} bg-black/10 dark:bg-white/10`
}

View File

@@ -9,6 +9,7 @@
:platform="platform"
:subscription-type="subscriptionType"
:rate-multiplier="rateMultiplier"
:user-rate-multiplier="userRateMultiplier"
/>
<span
v-if="description"
@@ -39,6 +40,7 @@ interface Props {
platform: GroupPlatform
subscriptionType?: SubscriptionType
rateMultiplier?: number
userRateMultiplier?: number | null
description?: string | null
selected?: boolean
showCheckmark?: boolean
@@ -47,6 +49,7 @@ interface Props {
withDefaults(defineProps<Props>(), {
subscriptionType: 'standard',
selected: false,
showCheckmark: true
showCheckmark: true,
userRateMultiplier: null
})
</script>