完整流程加节流 + 高频重试

This commit is contained in:
yml2213
2026-05-03 00:37:50 +08:00
parent 4cc91bf194
commit d7c61ed20f
10 changed files with 313 additions and 7 deletions
+11 -1
View File
@@ -37,8 +37,9 @@ http.interceptors.response.use(
if (error?.config?.url && String(error.config.url).startsWith('/api/v1/admin')) {
const status = Number(error?.response?.status || 0)
const errorCode = String(error?.response?.data?.errorCode || '').trim()
if (status === 401) {
if (status === 401 && shouldClearAdminSession(errorCode)) {
clearAdminSession()
if (window.location.hash.startsWith('#/admin') && !window.location.hash.startsWith('#/admin/login')) {
@@ -81,6 +82,15 @@ function resolveFallbackHttpMessage(error: unknown) {
return '接口请求失败'
}
function shouldClearAdminSession(errorCode: string) {
return [
'admin_auth_required',
'admin_auth_invalid',
'admin_auth_expired',
'admin_auth_user_invalid',
].includes(errorCode)
}
export function apiGet<T>(url: string, params?: Record<string, unknown>) {
return http.get<ApiEnvelope<T>>(url, { params }) as unknown as Promise<ApiEnvelope<T>>
}