mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-28 20:40:47 +08:00
feat: lint & format
This commit is contained in:
@@ -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);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user