From 0915287381ebff7c162b95cb2976d4fac0724e11 Mon Sep 17 00:00:00 2001 From: zhongzm Date: Fri, 27 Dec 2024 10:42:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=A8=A1=E6=8B=9F=E4=B8=8A=E7=BD=91?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/home/modules/header-banner.vue | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/views/home/modules/header-banner.vue b/src/views/home/modules/header-banner.vue index 6327c18..234024e 100644 --- a/src/views/home/modules/header-banner.vue +++ b/src/views/home/modules/header-banner.vue @@ -5,7 +5,7 @@ import { useAppStore } from '@/store/modules/app'; import type { ECOption } from '@/hooks/common/echarts'; import { useI18n } from 'vue-i18n'; import { useAuthStore } from '@/store/modules/auth'; - +import { clientAuth } from '@/service/ue/client' const { t } = useI18n(); const authStore = useAuthStore(); defineOptions({ @@ -230,8 +230,29 @@ const updateGaugeData = (opts: ECOption, data: GaugeDisplayData) => { // 添加峰值速率的 ref const peakTrafficRate = ref(0); +//增加模拟上网 +function checkAndTriggerAuth(dashboardData: any) { + // 检查是否有余额 + const hasBalance = dashboardData.balance > 0; -// 修改 mockDataUpdate 函数 + // 检查是否不限制流量 + const noTrafficLimit = !dashboardData.trafficEnable; + + // 检查是否有剩余流量 + const hasRemainingTraffic = dashboardData.trafficEnable && + (dashboardData.traffic - dashboardData.trafficUsed) > 0; + + // 如果满足任一条件,触发上网 + if (hasBalance || noTrafficLimit || hasRemainingTraffic) { + clientAuth().then((res) => { + console.log('Auto auth triggered:', res); + }).catch(err => { + console.error('Auto auth failed:', err); + }); + } +} + +// mockDataUpdate 函数 async function mockDataUpdate() { try { const response = await authStore.getDashboardData(); @@ -268,7 +289,8 @@ async function mockDataUpdate() { description: `${t('page.headerbanner.monthflowr')} (${formattedTotal.value}${formattedTotal.unit})`, // 显示总流量 subTitle: t('page.headerbanner.Used') + `: ${formattedUsed.value}${formattedUsed.unit}` // 显示已用流量 }; - + // 在数据处理完成后,添加自动上网检查 + checkAndTriggerAuth(response); // 更新仪表盘的进度比例 updateGauge2(opts => { if (opts.series && Array.isArray(opts.series)) {