自动排课
This commit is contained in:
+11
-3
@@ -26,10 +26,18 @@ http.interceptors.response.use(
|
||||
export function apiErrorMessage(error: unknown) {
|
||||
if (!axios.isAxiosError(error)) return '操作失败,请稍后重试。'
|
||||
const data = error.response?.data
|
||||
if (data?.errors) {
|
||||
return Object.values(data.errors).flat().join(';')
|
||||
if (data?.errors && typeof data.errors === 'object') {
|
||||
const validationMessage = Object.values(data.errors)
|
||||
.flat()
|
||||
.map((item) => String(item).trim())
|
||||
.filter(Boolean)
|
||||
.join(';')
|
||||
if (validationMessage) return validationMessage
|
||||
}
|
||||
return data?.detail ?? data?.title ?? '操作失败,请检查网络连接。'
|
||||
const detail = typeof data?.detail === 'string' ? data.detail.trim() : ''
|
||||
if (detail) return detail
|
||||
const title = typeof data?.title === 'string' ? data.title.trim() : ''
|
||||
return title || '操作失败,请检查网络连接。'
|
||||
}
|
||||
|
||||
export default http
|
||||
|
||||
Reference in New Issue
Block a user