web/src/utils/request.js: Fix Server 返回非 JSON 响应数据时导致错误弹窗 (#2049)

This commit is contained in:
Joy
2025-06-28 22:29:02 +08:00
committed by GitHub
parent 44751357b4
commit a5e1170af0

View File

@@ -77,6 +77,9 @@ service.interceptors.response.use(
if (response.headers['new-token']) { if (response.headers['new-token']) {
userStore.setToken(response.headers['new-token']) userStore.setToken(response.headers['new-token'])
} }
if (typeof response.data.code === 'undefined') {
return response
}
if (response.data.code === 0 || response.headers.success === 'true') { if (response.data.code === 0 || response.headers.success === 'true') {
if (response.headers.msg) { if (response.headers.msg) {
response.data.msg = decodeURI(response.headers.msg) response.data.msg = decodeURI(response.headers.msg)