feat: 登录逻辑调整
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user