wujingjing
2025-01-07 f93ffdd6a106c4aec20019da5f20f0dc2456e25f
getDomainPrefix
已修改2个文件
8 ■■■■ 文件已修改
src/utils/request.ts 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/storage.ts 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.ts
@@ -206,6 +206,7 @@
    const domainPrefix = subDomainName ? `${subDomainName}-` : '';
    return domainPrefix;
};
export const domainPrefix = getDomainPrefix(window);
// token 键定义
const sessionName = 'access-session';
@@ -215,7 +216,7 @@
    phoneNumber?: string;
};
const getDomainKey = (suffix: string) => getDomainPrefix() + suffix;
const getDomainKey = (suffix: string) => suffix;
export const accessSessionKey = getDomainKey(sessionName);
export const userInfoKey = getDomainKey(userInfoName);
src/utils/storage.ts
@@ -1,5 +1,5 @@
import { domainPrefix } from './request';
/**
 * window.localStorage 浏览器永久缓存
 * @method set 设置永久缓存
@@ -11,8 +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) {
        window.localStorage.setItem(Local.setKey(key), JSON.stringify(val));