feat: 登录逻辑调整

This commit is contained in:
duanshuwen
2025-12-27 22:49:14 +08:00
parent ea56695099
commit 56ad450731
10 changed files with 93 additions and 75 deletions

View File

@@ -2,7 +2,7 @@ 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 { getAccessToken } from "@/constant/token";
const clientId = getCurrentConfig().clientId;
const defaultConfig = {
@@ -20,7 +20,7 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
url = appStore.serverConfig?.baseUrl + url;
}
// 动态获取 token
const token = getStorageSyncToken();
const token = getAccessToken();
let header = {
...defaultConfig.header,
@@ -31,8 +31,8 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
if (customConfig.noToken) {
delete header.Authorization;
} else {
if (token) {
header.Authorization = `Bearer ${token}`;
if (token || customConfig.token) {
header.Authorization = `Bearer ${token || customConfig.token}`;
}
}
@@ -59,7 +59,7 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
resolve(res.data);
if (res.statusCode && res.statusCode === 424) {
console.log("424错误重新登录");
// removeStorageSyncToken();
// removeAccessToken();
uni.$emit(NOTICE_EVENT_LOGOUT);
// goLogin();
}