教学点名强化
This commit is contained in:
+7
-1
@@ -25,6 +25,7 @@ http.interceptors.response.use(
|
||||
|
||||
export function apiErrorMessage(error: unknown) {
|
||||
if (!axios.isAxiosError(error)) return '操作失败,请稍后重试。'
|
||||
const status = error.response?.status
|
||||
const data = error.response?.data
|
||||
if (data?.errors && typeof data.errors === 'object') {
|
||||
const validationMessage = Object.values(data.errors)
|
||||
@@ -37,7 +38,12 @@ export function apiErrorMessage(error: unknown) {
|
||||
const detail = typeof data?.detail === 'string' ? data.detail.trim() : ''
|
||||
if (detail) return detail
|
||||
const title = typeof data?.title === 'string' ? data.title.trim() : ''
|
||||
return title || '操作失败,请检查网络连接。'
|
||||
if (title) return title
|
||||
if (status === 403) return '您没有权限执行此操作,请联系管理员。'
|
||||
if (status === 404) return '请求的资源不存在。'
|
||||
if (status === 401) return '登录已过期,请重新登录。'
|
||||
if (status && status >= 500) return '服务器繁忙,请稍后重试。'
|
||||
return '操作失败,请检查网络连接。'
|
||||
}
|
||||
|
||||
export default http
|
||||
|
||||
Reference in New Issue
Block a user