mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-23 18:11:37 +08:00
fix: login failed message.
This commit is contained in:
@@ -48,8 +48,8 @@ export const useAuth = createSharedComposable(() => {
|
||||
|
||||
if (error.status === 404) {
|
||||
message.error('请更新AutoBangumi!');
|
||||
} else {
|
||||
message.error(error.msg_zh);
|
||||
} else if (error.status === 401){
|
||||
message.error(err.msg_zh);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -38,9 +38,5 @@ definePage({
|
||||
</div>
|
||||
</div>
|
||||
</ab-container>
|
||||
|
||||
<!-- <div bg="#C7C4AB" text-white rounded-4px py-4px px-2em text-main> -->
|
||||
<!-- <div>{{ $t('login.default') }}: admin adminadmin</div> -->
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -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 = '';
|
||||
/** 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);
|
||||
}
|
||||
|
||||
/** 执行失败 */
|
||||
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