fix(frontend): BUG-001慢API超时兜底+BUG-002清理views残留.bak (产品打磨批次1 2026-09-03)

- api/index.ts: axios网络层错误(超时ECONNABORTED/断连)3s节流ElMessage提示,页面不再静默加载失败
- views: 删除6个.bak历史备份(BudgetManagement/CMAKnowledge/DeviationDashboard/KPIList/MapCanvas/MapReview),均已git跟踪可回溯
- nginx缓存策略另改(不进git): /assets/ immutable长缓存+index.html etag条件请求
This commit is contained in:
Hermes CI Fix
2026-09-03 18:32:24 +08:00
parent 9a823e80a6
commit 45cacedfdd
7 changed files with 11 additions and 3684 deletions
+11
View File
@@ -1,10 +1,14 @@
import axios from 'axios'
import { ElMessage } from 'element-plus'
const api = axios.create({
baseURL: '/api/cma',
timeout: 15000,
})
// 网络层错误提示节流标记(3 秒内只弹一次)
let lastNetErrToast = 0
api.interceptors.request.use((config) => {
const token = localStorage.getItem('cma_token')
if (token) config.headers.Authorization = `Bearer ${token}`
@@ -19,6 +23,13 @@ api.interceptors.response.use(
localStorage.removeItem('cma_token')
localStorage.removeItem('cma_user')
window.location.href = '/login'
} else if (error.code === 'ECONNABORTED' || !error.response) {
// BUG-001 兜底(2026-09-03):网络层失败(超时/断连)节流提示,避免并行请求重复弹窗
const now = Date.now()
if (now - lastNetErrToast > 3000) {
lastNetErrToast = now
ElMessage.warning(error.code === 'ECONNABORTED' ? '请求超时,请稍后重试' : '网络异常,请检查连接后重试')
}
}
return Promise.reject(error)
}