From b0e212f25b298f782fdf640fd9a07517f43f0b02 Mon Sep 17 00:00:00 2001 From: xiaosi <2652281683@qq.com> Date: Tue, 1 Sep 2026 18:20:07 +0800 Subject: [PATCH] fix: quiet pool 404 toast and localize purchase status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow skipErrorToast for expected missing pool and map inactive to 失效. --- src/utils/http.js | 8 ++++++-- src/views/TrafficOpsView/TrafficOpsView.vue | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/utils/http.js b/src/utils/http.js index 358ef18..31dacb5 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -25,7 +25,9 @@ request.interceptors.response.use( if (res && res.code === 200) { return res.data } - useUiStore().toast(res?.msg || '请求失败') + if (!response.config.skipErrorToast) { + useUiStore().toast(res?.msg || '请求失败') + } return Promise.reject(new Error(res?.msg || '请求失败')) }, (error) => { @@ -40,7 +42,9 @@ request.interceptors.response.use( useUiStore().toast(data?.msg || '无权限访问') } else { const message = data?.msg || error.message || '网络错误' - useUiStore().toast(message) + if (!error.config?.skipErrorToast) { + useUiStore().toast(message) + } const err = new Error(message) err.status = status err.response = error.response diff --git a/src/views/TrafficOpsView/TrafficOpsView.vue b/src/views/TrafficOpsView/TrafficOpsView.vue index c931a06..3a9d390 100644 --- a/src/views/TrafficOpsView/TrafficOpsView.vue +++ b/src/views/TrafficOpsView/TrafficOpsView.vue @@ -86,8 +86,8 @@
池状态 - {{ pool.status === 'active' ? '有效' : (pool.status || '—') }} - {{ pool.status || '—' }} + {{ pool.status === 'active' ? '有效' : (pool.status === 'inactive' ? '失效' : (pool.status || '—')) }} + {{ pool.status === 'active' ? '有效' : (pool.status === 'inactive' ? '失效' : (pool.status || '—')) }}
@@ -518,7 +518,7 @@ const purchaseColumns = [ async function loadPool() { poolMissing.value = false try { - pool.value = await request.get(urls.ADMIN_TRAFFIC_POOL) + pool.value = await request.get(urls.ADMIN_TRAFFIC_POOL, { skipErrorToast: true }) } catch (e) { if (e.status === 404 || /资源不存在|not found/i.test(e.message || '')) { pool.value = null @@ -543,7 +543,7 @@ async function loadPurchases() { totalText: bytesToGbText(p.totalBytes), costText: `¥${Number(p.totalCost || 0).toFixed(2)}`, expiresAt: fmtTime(p.expiresAt), - statusName: p.status === 'active' ? '有效' : (p.status || '—'), + statusName: p.status === 'active' ? '有效' : (p.status === 'inactive' ? '失效' : (p.status || '—')), remark: p.remark || '', createdAt: fmtTime(p.createdAt), raw: p