fix:模拟上网判断
This commit is contained in:
@@ -5,7 +5,7 @@ import { useAppStore } from '@/store/modules/app';
|
|||||||
import type { ECOption } from '@/hooks/common/echarts';
|
import type { ECOption } from '@/hooks/common/echarts';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useAuthStore } from '@/store/modules/auth';
|
import { useAuthStore } from '@/store/modules/auth';
|
||||||
|
import { clientAuth } from '@/service/ue/client'
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -230,8 +230,29 @@ const updateGaugeData = (opts: ECOption, data: GaugeDisplayData) => {
|
|||||||
|
|
||||||
// 添加峰值速率的 ref
|
// 添加峰值速率的 ref
|
||||||
const peakTrafficRate = ref(0);
|
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() {
|
async function mockDataUpdate() {
|
||||||
try {
|
try {
|
||||||
const response = await authStore.getDashboardData();
|
const response = await authStore.getDashboardData();
|
||||||
@@ -268,7 +289,8 @@ async function mockDataUpdate() {
|
|||||||
description: `${t('page.headerbanner.monthflowr')} (${formattedTotal.value}${formattedTotal.unit})`, // 显示总流量
|
description: `${t('page.headerbanner.monthflowr')} (${formattedTotal.value}${formattedTotal.unit})`, // 显示总流量
|
||||||
subTitle: t('page.headerbanner.Used') + `: ${formattedUsed.value}${formattedUsed.unit}` // 显示已用流量
|
subTitle: t('page.headerbanner.Used') + `: ${formattedUsed.value}${formattedUsed.unit}` // 显示已用流量
|
||||||
};
|
};
|
||||||
|
// 在数据处理完成后,添加自动上网检查
|
||||||
|
checkAndTriggerAuth(response);
|
||||||
// 更新仪表盘的进度比例
|
// 更新仪表盘的进度比例
|
||||||
updateGauge2(opts => {
|
updateGauge2(opts => {
|
||||||
if (opts.series && Array.isArray(opts.series)) {
|
if (opts.series && Array.isArray(opts.series)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user