From f9b486888d3210bf76857fd04f75679d21a896be Mon Sep 17 00:00:00 2001 From: zhongzm Date: Fri, 24 Jan 2025 19:34:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E5=A4=8D=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84enable=E5=88=A4=E6=96=AD=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/home/modules/header-banner.vue | 27 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) 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') }}