diff --git a/src/views/home/modules/header-banner.vue b/src/views/home/modules/header-banner.vue index d1e4644..5ea0437 100644 --- a/src/views/home/modules/header-banner.vue +++ b/src/views/home/modules/header-banner.vue @@ -291,7 +291,11 @@ async function mockDataUpdate() { max: Math.max(numBalance, 100), displayValue: formatBalance(response.balance), unit: t('page.headerbanner.money'), - subTitle: t('page.headerbanner.deviceCount') + `: ${response.clientNumEnable ? (response.clientNum || 0) + t('page.headerbanner.device') : t('page.headerbanner.nolimit')}` + subTitle: t('page.headerbanner.deviceCount') + `: ${ + !response.clientNumEnable + ? t('page.headerbanner.nolimit') + : (response.clientNum || 0) + t('page.headerbanner.device') + }` }; // 更新流量数据 @@ -326,8 +330,12 @@ async function mockDataUpdate() { // 更新速率限制显示 if (response.rateLimitEnable) { speedLimits.value = { - upLimit: response.upLimitEnable ? formatSpeedLimit(response.upLimit) : t('page.headerbanner.nolimit'), - downLimit: response.downLimitEnable ? formatSpeedLimit(response.downLimit) : t('page.headerbanner.nolimit') + upLimit: !response.upLimitEnable + ? t('page.headerbanner.nolimit') + : formatSpeedLimit(response.upLimit), + downLimit: !response.downLimitEnable + ? t('page.headerbanner.nolimit') + : formatSpeedLimit(response.downLimit) }; } else { speedLimits.value = { @@ -395,16 +403,17 @@ defineExpose({ // 修改流量获取函数 const getTrafficTotal = (description?: string, trafficEnable?: boolean): string => { - if (!trafficEnable) return t('page.headerbanner.nolimit'); - if (!description) return '0B'; + // 如果描述中包含"无限制",说明是无限制套餐 + if (!description || description.includes(t('page.headerbanner.nolimit'))) { + return t('page.headerbanner.nolimit'); + } const matches = description.match(/\((.*?)\)/); return matches ? matches[1] : '0B'; }; // 修改设备数量获取函数 const getDeviceCount = (subTitle?: string, clientNumEnable?: boolean): string => { - if (!clientNumEnable) return t('page.headerbanner.nolimit'); - if (!subTitle) return '0'; + if (!subTitle) return t('page.headerbanner.nolimit'); const parts = subTitle.split(': '); return parts.length > 1 ? parts[1] : '0'; }; @@ -440,11 +449,11 @@ const getDeviceCount = (subTitle?: string, clientNumEnable?: boolean): string =>
{{ t('page.headerbanner.monthflowr') }} - {{ getTrafficTotal(baseData[1].description, baseData[1].speedLimits?.upLimit !== t('page.headerbanner.nolimit')) }} + {{ getTrafficTotal(baseData[1].description) }}
{{ t('page.headerbanner.Used') }} - {{ getTrafficTotal(baseData[1].description, baseData[1].speedLimits?.downLimit !== t('page.headerbanner.nolimit')) }} + {{ getTrafficTotal(baseData[1].subTitle) }}
{{ t('page.headerbanner.uplimit') }}