授权失败跳转

This commit is contained in:
lccsw
2025-11-21 10:43:26 +08:00
parent 0a8fc16800
commit 9f7b99b5fa
+5 -1
View File
@@ -174,9 +174,9 @@ service.interceptors.response.use(
// 直接返回响应数据(根据后端接口规范调整)
// console.log(response.data.code);
if (response.data.code === 403) {
localStorage.removeItem("token");
// 如果在微信浏览器中,自动重新授权
if (WechatAuth.isWechatBrowser() && !isAuthing) {
localStorage.removeItem("token");
const urlParams = new URLSearchParams(window.location.search);
const friend_account_id = urlParams.get('friend_account_id');
const accountId = urlParams.get('accountId');
@@ -185,6 +185,10 @@ service.interceptors.response.use(
window.location.reload();
}
// return Promise.reject(new Error('正在重新授权,请稍候...'));
}else{
//跳转h5登录
window.location.href = '/login?redirect='+encodeURIComponent(window.location.href);
return Promise.reject(new Error('正在重新授权,请稍候...'));
}
}
return response.data;