feat: lint & format

This commit is contained in:
Rewrite0
2023-10-06 04:32:33 +00:00
committed by GitHub
parent 664a121092
commit edf697e68a
36 changed files with 821 additions and 833 deletions

View File

@@ -1,5 +1,5 @@
import Axios from 'axios';
import type {ApiError} from "#/api";
import type { ApiError } from '#/api';
export const axios = Axios.create();
@@ -17,38 +17,38 @@ export const axios = Axios.create();
axios.defaults.withCredentials = true;
axios.interceptors.response.use(
(res) => {
return res;
},
(err) => {
const status = err.response.status as ApiError['status'];
const msg_en = (err.response.data.msg_en ?? '') as ApiError['msg_en'];
const msg_zh = (err.response.data.msg_zh ?? '') as ApiError['msg_zh'];
(res) => {
return res;
},
(err) => {
const status = err.response.status as ApiError['status'];
const msg_en = (err.response.data.msg_en ?? '') as ApiError['msg_en'];
const msg_zh = (err.response.data.msg_zh ?? '') as ApiError['msg_zh'];
const error = {
status,
msg_en,
msg_zh,
};
const error = {
status,
msg_en,
msg_zh,
};
const message = useMessage();
const message = useMessage();
/** token 过期 */
if (error.status === 401) {
const {auth} = useAuth();
auth.value = '';
}
/** 执行失败 */
if (error.status === 406) {
message.error(error.msg_zh);
}
if (error.status === 500) {
const msg = (err.response.data.msg_en ?? '') as ApiError['msg_en']
message.error(msg);
}
return Promise.reject(error);
/** token 过期 */
if (error.status === 401) {
const { auth } = useAuth();
auth.value = '';
}
/** 执行失败 */
if (error.status === 406) {
message.error(error.msg_zh);
}
if (error.status === 500) {
const msg = (err.response.data.msg_en ?? '') as ApiError['msg_en'];
message.error(msg);
}
return Promise.reject(error);
}
);