src/main.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/utils/request.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/utils/storage.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main.ts
@@ -14,7 +14,7 @@ import { getAllData } from './stores/chatRoom'; import { setTheme } from '/@/utils/theme'; setTheme(); // setTheme(); const app = createApp(App); for (const [key, component] of Object.entries(ElementPlusIconsVue)) { app.component(key, component); src/utils/request.ts
@@ -212,7 +212,7 @@ * @description 域名前缀 * 防止类似于 http://sqi.beng35.com/airp 和 http://sqi.beng35.com/test 公用同一个 token 或 userInfo */ export const getDomainPrefix = (win: Window) => { export const getDomainPrefix = (win: Window = window) => { const subDomainName = win.location.pathname .split('/') .filter((item) => !!item) @@ -221,15 +221,17 @@ return domainPrefix; }; export const domainPrefix = getDomainPrefix(window); // token 键定义 export const sessionName = 'access-session'; export const userName = 'userName'; export const getSessionKey = (win: Window) => { return getDomainPrefix(win) + sessionName; return sessionName; }; export const getUserNameKey = (win: Window) => { return getDomainPrefix(win) + userName; return userName; }; export const accessSessionKey = getSessionKey(window); @@ -238,7 +240,7 @@ export const refreshAccessTokenKey = `x-${accessSessionKey}`; // userInfo键定义 export const userInfoKey = getDomainPrefix(window) + 'userInfo'; export const userInfoKey ='userInfo'; // 获取 token export const getSession = () => { return Local.get(accessSessionKey); src/utils/storage.ts
@@ -1,4 +1,4 @@ import { accessSessionKey, getSessionKey, getUserNameKey, userNameKey } from './request'; import { accessSessionKey, getSessionKey, getUserNameKey, userNameKey,domainPrefix } from './request'; /** * window.localStorage 浏览器永久缓存 @@ -11,7 +11,7 @@ // 查看 v2.4.3版本更新日志 setKey(key: string) { // @ts-ignore return `${__NEXT_NAME__}:${key}`; return `${__NEXT_NAME__}:${domainPrefix}${key}`; }, // 设置永久缓存 set<T>(key: string, val: T, win = window) {