fix:修改错误提示
This commit is contained in:
19
src/typings/api.d.ts
vendored
19
src/typings/api.d.ts
vendored
@@ -446,20 +446,15 @@ declare namespace Api {
|
||||
* Backend api module: "dashboard"
|
||||
*/
|
||||
namespace Dashboard {
|
||||
/** Dashboard gauge data */
|
||||
/** Gauge data */
|
||||
interface GaugeData {
|
||||
/** Balance amount */
|
||||
balance: number;
|
||||
/** Total traffic amount (bytes) */
|
||||
traffic: number;
|
||||
/** Used traffic amount (bytes) */
|
||||
trafficUsed: number;
|
||||
/** Current traffic rate (B/s) */
|
||||
activity: number;
|
||||
/** Peak traffic rate (B/s) */
|
||||
peakTrafficRate: number;
|
||||
/** Number of connected devices */
|
||||
balance: string | number;
|
||||
clientNum: number;
|
||||
traffic: number;
|
||||
trafficUsed: number;
|
||||
trafficEnable: boolean;
|
||||
activity: number;
|
||||
error?: any; // 添加可选的 error 属性
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -279,8 +279,8 @@ function checkAndTriggerAuth(dashboardData: any) {
|
||||
async function mockDataUpdate() {
|
||||
try {
|
||||
const response = await authStore.getDashboardData();
|
||||
// 检查响应是否有效
|
||||
if (response && typeof response === 'object') {
|
||||
// 检查响应是否有效且不是错误响应
|
||||
if (response && typeof response === 'object' && !response.error) {
|
||||
// 检查必要的字段是否存在
|
||||
if (response.balance !== undefined) {
|
||||
// 更新余额和设备数据
|
||||
@@ -365,14 +365,16 @@ async function mockDataUpdate() {
|
||||
});
|
||||
updateGauge3(opts => updateGaugeData(opts, baseData.value[2]));
|
||||
} else {
|
||||
// 静默处理无效数据
|
||||
console.warn('Invalid dashboard data structure:', response);
|
||||
}
|
||||
} else {
|
||||
// 静默处理无效响应
|
||||
console.warn('Invalid response:', response);
|
||||
}
|
||||
} catch (error) {
|
||||
// 只记录真正的错误
|
||||
if (error instanceof Error) {
|
||||
console.warn('Dashboard data update failed:', error.message);
|
||||
}
|
||||
// 静默处理所有错误
|
||||
console.warn('Dashboard update failed:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user