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('导入失败') }