feat: 区别不同的小程序的缓存问题

This commit is contained in:
2025-12-15 16:26:45 +08:00
parent 09452bf600
commit a3c363cbc9
8 changed files with 43 additions and 16 deletions

View File

@@ -2,6 +2,8 @@ import { goLogin } from "../../hooks/useGoLogin";
import { getCurrentConfig } from "@/constant/base";
import { useAppStore } from "@/store";
import { NOTICE_EVENT_LOGOUT } from "@/constant/constant";
import { getStorageSyncToken } from "@/constant/token";
import { removeStorageSyncToken } from "@/constant/token";
const clientId = getCurrentConfig().clientId;
const defaultConfig = {
@@ -19,7 +21,7 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
url = appStore.serverConfig?.baseUrl + url;
}
// 动态获取 token
const token = uni.getStorageSync("token");
const token = getStorageSyncToken();
let header = {
...defaultConfig.header,
@@ -58,7 +60,7 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
resolve(res.data);
if (res.statusCode && res.statusCode === 424) {
console.log("424错误重新登录");
uni.setStorageSync("token", "");
removeStorageSyncToken();
uni.$emit(NOTICE_EVENT_LOGOUT);
goLogin();
}