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,7 @@ import { wxLogin } from "../request/api/LoginApi";
import { loginAuth, bindPhone, checkPhone } from "@/manager/LoginManager";
import { clientId } from "@/constant/base";
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
import { getStorageSyncToken, setStorageSyncToken } from "../constant/token";
// 跳转登录
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
@@ -47,7 +48,7 @@ export const onLogin = async (e) => {
// 检测token
export const checkToken = () => {
const token = uni.getStorageSync("token");
const token = getStorageSyncToken();
return new Promise((resolve) => {
if (!token) {
@@ -61,7 +62,7 @@ export const checkToken = () => {
// 刷新token
export const refreshToken = () => {
const token = uni.getStorageSync("token");
const token = getStorageSyncToken();
if (!token) {
return;
@@ -81,7 +82,7 @@ export const refreshToken = () => {
const response = await wxLogin(params);
if (response.access_token) {
uni.setStorageSync("token", response.access_token);
setStorageSyncToken(response.access_token);
// 登录成功后,触发登录成功事件
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
}