diff --git a/src/api/http.ts b/src/api/http.ts index b50a4fd..fc31959 100644 --- a/src/api/http.ts +++ b/src/api/http.ts @@ -65,9 +65,12 @@ export class HttpClient { return Promise.reject(new ApiError(body.code, body.message)) }, async (error: AxiosError) => { - const config = error.config - // 401 自动刷新并重放一次 - if (error.response?.status === 401 && config) { + const config = error.config as (AxiosRequestConfig & { _retry?: boolean }) | undefined + const url = config?.url ?? '' + const isAuthEndpoint = url.includes('/auth/login') || url.includes('/auth/refresh') + // 401 自动刷新并重放一次(登录/刷新接口自身 401 不重放,_retry 防死循环) + if (error.response?.status === 401 && config && !config._retry && !isAuthEndpoint) { + config._retry = true try { const token = await this.refresh() config.headers = config.headers ?? {} diff --git a/src/pages/system/role/assign-resources-form.vue b/src/pages/system/role/assign-resources-form.vue index c058a7d..212dd32 100644 --- a/src/pages/system/role/assign-resources-form.vue +++ b/src/pages/system/role/assign-resources-form.vue @@ -7,13 +7,12 @@ node-key="code" show-checkbox :props="{ label: 'name', children: 'children' }" - :default-checked-keys="assigned ?? []" default-expand-all />