2
0

feat:修复其他信息的enable判断逻辑

This commit is contained in:
zhongzm
2025-01-24 19:34:11 +08:00
parent 09a31c46b6
commit f9b486888d

View File

@@ -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 =>
</div>
<div class="info-item">
<span class="info-label">{{ t('page.headerbanner.monthflowr') }}</span>
<span class="info-value">{{ getTrafficTotal(baseData[1].description, baseData[1].speedLimits?.upLimit !== t('page.headerbanner.nolimit')) }}</span>
<span class="info-value">{{ getTrafficTotal(baseData[1].description) }}</span>
</div>
<div class="info-item">
<span class="info-label">{{ t('page.headerbanner.Used') }}</span>
<span class="info-value">{{ getTrafficTotal(baseData[1].description, baseData[1].speedLimits?.downLimit !== t('page.headerbanner.nolimit')) }}</span>
<span class="info-value">{{ getTrafficTotal(baseData[1].subTitle) }}</span>
</div>
<div class="info-item">
<span class="info-label">{{ t('page.headerbanner.uplimit') }}</span>