- HTTP拦截器仅在曾持有token(过期/失效)时才reLaunch回首页,未登录时不跳转 - refresh()未登录时API失败静默处理,不弹错误modal Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@@ -516,6 +516,10 @@ const refresh = () => {
console.log(err);
uni.hideLoading();
loading.value = false;
+ if (!token.value) {
+ ready.value = true;
+ return;
+ }
uni.showModal({
content: `${err.errMsg},请重试`,
});
@@ -75,12 +75,15 @@ class Http {
// });
// }
if ([21005, 21000, 10001].includes(Number(res.code))) {
+ const hasToken = getApp<any>().globalData.token;
clearToken();
- setTimeout(() => {
- uni.reLaunch({
- url: "/pages/map/map",
- });
- }, 1500);
+ if (hasToken) {
+ setTimeout(() => {
+ uni.reLaunch({
+ url: "/pages/map/map",
+ });
+ }, 1500);
throw {
errMsg: "请重新登录",
};