From c0fc17cf05ece8bfdc4a8a2227d9605acb2f745d Mon Sep 17 00:00:00 2001 From: mediabot-pt <295750538+mediabot-pt@users.noreply.github.com> Date: Thu, 2 Jul 2026 13:40:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=BC=E5=87=BA=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E7=94=A8api.raw=E7=BB=95=E8=BF=87=E5=B0=81=E8=A3=85=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1+=E6=9A=B4=E9=9C=B2=E5=8E=9F=E5=A7=8Baxios=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/api/index.js | 4 +++- web/src/views/AccessResults.vue | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/src/api/index.js b/web/src/api/index.js index 3bc35d3..35d4023 100644 --- a/web/src/api/index.js +++ b/web/src/api/index.js @@ -93,5 +93,7 @@ export default { parse: (configId, accessResultId) => api.post('/admin/adapter/parse', { configId, accessResultId }), parseBatch: (configId, siteId) => api.post('/admin/adapter/parse-batch', { configId, siteId }), }, - health: () => api.get('/health', { baseURL: '' }) + health: () => api.get('/health', { baseURL: '' }), + // 原始 axios 实例,供需要直接调用(如 blob 下载)的场景使用 + raw: { get: (url, cfg) => api.get(url, cfg), post: (url, data, cfg) => api.post(url, data, cfg) } } diff --git a/web/src/views/AccessResults.vue b/web/src/views/AccessResults.vue index e1dac3f..f6ae403 100644 --- a/web/src/views/AccessResults.vue +++ b/web/src/views/AccessResults.vue @@ -77,7 +77,7 @@ const exportScripts = async () => { exporting.value = true try { // api 响应拦截器返回 response.data,所以 r 直接就是 blob - const r = await api.get('/admin/scripts/export', { responseType: 'blob' }) + const r = await api.raw.get('/admin/scripts/export', { responseType: 'blob' }) const a = document.createElement('a') a.href = URL.createObjectURL(new Blob([r])) a.download = 'scripts.zip'; a.click(); URL.revokeObjectURL(a.href) @@ -89,7 +89,7 @@ const importScripts = async (file) => { importing.value = true try { const fd = new FormData(); fd.append('file', file.raw) - const r = await api.post('/admin/scripts/import', fd) + const r = await api.raw.post('/admin/scripts/import', fd) ElMessage.success('导入完成: ' + ((r.ok || 0) + ' 成功, ' + (r.fail || 0) + ' 失败')) fetchAll() } catch { ElMessage.error('导入失败') }