fix bug 用户中心接口调整

This commit is contained in:
yuping
2023-07-13 14:44:50 +08:00
parent 692eabb474
commit 9d2760c3cf
3 changed files with 30 additions and 9 deletions

View File

@@ -1,8 +1,9 @@
import {isRef, reactive, ref, toRefs, unref, watch, watchEffect} from "vue";
import {getCookieForName, throttle} from "@/api/method";
import {getCookieForName, setCookie, throttle} from "@/api/method";
import JSONBigInt from "json-bigint";
import router from "@/router";
import {message} from "ant-design-vue";
import {REFRESH_TOKEN, VALIDATE_TOKEN} from "@/api/apis";
const JSONBigIntStr = JSONBigInt({ storeAsString: true });
@@ -405,13 +406,21 @@ export async function request(_url, params) {
if (res.code === 0 || res.code === 200) {
return res;
}
if (res.code === 1000) {
if (res.code === 1000 || res.code === 1002) {
(process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'alpine') ?
router.push({path: 'login', query: { returnUrl: router.currentRoute.value.fullPath }}) :
(window.location.href = process.env.VUE_APP_LOGIN_URL + encodeURIComponent(window.location.protocol + process.env.VUE_APP_BOE_API_URL + process.env.VUE_APP_BASE + router.currentRoute.value.fullPath))
localStorage.removeItem('refreshPage')
return Promise.reject(res);
}else if(res.code=== 1001){
request(REFRESH_TOKEN).then((res)=>{
if(res.code===0 || res.code === 200){
setCookie('token',res.data)
return request(_url, params)
}
})
}
//刷新token
res.show ? message.error(res.msg):message.error('系统接口数据异常,请联系管理员');
return Promise.reject(res);
});