提交 f57eb944 作者: Vben

perf: improve persistent logic

上级 11d3f395
...@@ -5,4 +5,4 @@ VITE_PORT = 3100 ...@@ -5,4 +5,4 @@ VITE_PORT = 3100
VITE_GLOB_APP_TITLE = Vben Admin VITE_GLOB_APP_TITLE = Vben Admin
# spa shortname # spa shortname
VITE_GLOB_APP_SHORT_NAME = vue_vben_admin_2x VITE_GLOB_APP_SHORT_NAME = vue_vben_admin
...@@ -17,7 +17,7 @@ jobs: ...@@ -17,7 +17,7 @@ jobs:
id: release_tag id: release_tag
uses: yyx990803/release-tag@master uses: yyx990803/release-tag@master
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.OPER_TOKEN }}
with: with:
tag_name: ${{ github.ref }} tag_name: ${{ github.ref }}
body: | body: |
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"stylelint.vscode-stylelint", "stylelint.vscode-stylelint",
"esbenp.prettier-vscode", "esbenp.prettier-vscode",
"mrmlnc.vscode-less", "mrmlnc.vscode-less",
"antfu.i18n-ally", "lokalise.i18n-ally",
"antfu.iconify", "antfu.iconify",
"mikestead.dotenv", "mikestead.dotenv",
"heybourn.headwind" "heybourn.headwind"
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
}, },
"dependencies": { "dependencies": {
"@iconify/iconify": "^2.0.0-rc.6", "@iconify/iconify": "^2.0.0-rc.6",
"@vueuse/core": "^4.2.2", "@vueuse/core": "^4.3.0",
"@zxcvbn-ts/core": "^0.2.0", "@zxcvbn-ts/core": "^0.2.0",
"ant-design-vue": "2.0.0", "ant-design-vue": "2.0.0",
"apexcharts": "^3.25.0", "apexcharts": "^3.25.0",
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
"sortablejs": "^1.13.0", "sortablejs": "^1.13.0",
"vditor": "^3.8.1", "vditor": "^3.8.1",
"vue": "3.0.5", "vue": "3.0.5",
"vue-i18n": "9.0.0-rc.8", "vue-i18n": "^9.0.0",
"vue-router": "^4.0.4", "vue-router": "^4.0.4",
"vue-types": "^3.0.2", "vue-types": "^3.0.2",
"vuex": "^4.0.0", "vuex": "^4.0.0",
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
"@typescript-eslint/eslint-plugin": "^4.15.2", "@typescript-eslint/eslint-plugin": "^4.15.2",
"@typescript-eslint/parser": "^4.15.2", "@typescript-eslint/parser": "^4.15.2",
"@vitejs/plugin-legacy": "^1.3.1", "@vitejs/plugin-legacy": "^1.3.1",
"@vitejs/plugin-vue": "^1.1.4", "@vitejs/plugin-vue": "^1.1.5",
"@vitejs/plugin-vue-jsx": "^1.1.2", "@vitejs/plugin-vue-jsx": "^1.1.2",
"@vue/compiler-sfc": "3.0.5", "@vue/compiler-sfc": "3.0.5",
"autoprefixer": "^10.2.4", "autoprefixer": "^10.2.4",
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
"stylelint-order": "^4.1.0", "stylelint-order": "^4.1.0",
"ts-node": "^9.1.1", "ts-node": "^9.1.1",
"typescript": "4.1.5", "typescript": "4.1.5",
"vite": "2.0.3", "vite": "2.0.4",
"vite-plugin-compression": "^0.2.2", "vite-plugin-compression": "^0.2.2",
"vite-plugin-html": "^2.0.2", "vite-plugin-html": "^2.0.2",
"vite-plugin-imagemin": "^0.2.8", "vite-plugin-imagemin": "^0.2.8",
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
"vite-plugin-pwa": "^0.5.5", "vite-plugin-pwa": "^0.5.5",
"vite-plugin-style-import": "^0.7.5", "vite-plugin-style-import": "^0.7.5",
"vite-plugin-theme": "^0.4.8", "vite-plugin-theme": "^0.4.8",
"vite-plugin-windicss": "0.5.3", "vite-plugin-windicss": "0.5.4",
"vue-eslint-parser": "^7.5.0", "vue-eslint-parser": "^7.5.0",
"yargs": "^16.2.0" "yargs": "^16.2.0"
}, },
......
// token key // token key
export const TOKEN_KEY = 'TOKEN'; export const TOKEN_KEY = 'TOKEN__';
// user info key // user info key
export const USER_INFO_KEY = 'USER__INFO__'; export const USER_INFO_KEY = 'USER__INFO__';
...@@ -19,6 +19,12 @@ export const BASE_LOCAL_CACHE_KEY = 'LOCAL__CACHE__KEY__'; ...@@ -19,6 +19,12 @@ export const BASE_LOCAL_CACHE_KEY = 'LOCAL__CACHE__KEY__';
// base global session key // base global session key
export const BASE_SESSION_CACHE_KEY = 'SESSION__CACHE__KEY__'; export const BASE_SESSION_CACHE_KEY = 'SESSION__CACHE__KEY__';
// base global local key
export const APP_LOCAL_CACHE_KEY = 'LOCAL__CACHE__KEY__';
// base global session key
export const APP_SESSION_CACHE_KEY = 'SESSION__CACHE__KEY__';
export enum CacheTypeEnum { export enum CacheTypeEnum {
SESSION, SESSION,
LOCAL, LOCAL,
......
...@@ -7,7 +7,7 @@ import type { ProjectConfig } from '/#/config'; ...@@ -7,7 +7,7 @@ import type { ProjectConfig } from '/#/config';
import { PROJ_CFG_KEY } from '/@/enums/cacheEnum'; import { PROJ_CFG_KEY } from '/@/enums/cacheEnum';
import projectSetting from '/@/settings/projectSetting'; import projectSetting from '/@/settings/projectSetting';
import { getLocal } from '/@/utils/cache/persistent'; import { Persistent } from '/@/utils/cache/persistent';
import { updateHeaderBgColor, updateSidebarBgColor } from '/@/logics/theme/updateBackground'; import { updateHeaderBgColor, updateSidebarBgColor } from '/@/logics/theme/updateBackground';
import { updateColorWeak } from '/@/logics/theme/updateColorWeak'; import { updateColorWeak } from '/@/logics/theme/updateColorWeak';
import { updateGrayMode } from '/@/logics/theme/updateGrayMode'; import { updateGrayMode } from '/@/logics/theme/updateGrayMode';
...@@ -19,7 +19,7 @@ import { primaryColor } from '../../build/config/themeConfig'; ...@@ -19,7 +19,7 @@ import { primaryColor } from '../../build/config/themeConfig';
// Initial project configuration // Initial project configuration
export function initAppConfigStore() { export function initAppConfigStore() {
let projCfg: ProjectConfig = getLocal(PROJ_CFG_KEY) as ProjectConfig; let projCfg: ProjectConfig = Persistent.getLocal(PROJ_CFG_KEY) as ProjectConfig;
projCfg = deepMerge(projectSetting, projCfg || {}); projCfg = deepMerge(projectSetting, projCfg || {});
try { try {
const { const {
......
...@@ -4,6 +4,7 @@ export default { ...@@ -4,6 +4,7 @@ export default {
// app theme preset color // app theme preset color
export const APP_PRESET_COLOR_LIST: string[] = [ export const APP_PRESET_COLOR_LIST: string[] = [
'#0960bd',
'#0084f4', '#0084f4',
'#009688', '#009688',
'#536dfe', '#536dfe',
......
...@@ -6,7 +6,7 @@ import store from '/@/store'; ...@@ -6,7 +6,7 @@ import store from '/@/store';
import { PROJ_CFG_KEY } from '/@/enums/cacheEnum'; import { PROJ_CFG_KEY } from '/@/enums/cacheEnum';
import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper'; import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper';
import { setLocal, getLocal, clearSession, clearLocal } from '/@/utils/cache/persistent'; import { Persistent } from '/@/utils/cache/persistent';
import { deepMerge } from '/@/utils'; import { deepMerge } from '/@/utils';
import { resetRouter } from '/@/router'; import { resetRouter } from '/@/router';
...@@ -29,7 +29,7 @@ export default class App extends VuexModule { ...@@ -29,7 +29,7 @@ export default class App extends VuexModule {
private pageLoadingState = false; private pageLoadingState = false;
// project config // project config
private projectConfigState: ProjectConfig | null = getLocal(PROJ_CFG_KEY); private projectConfigState: ProjectConfig | null = Persistent.getLocal(PROJ_CFG_KEY);
// set main overflow hidden // set main overflow hidden
private lockMainScrollState = false; private lockMainScrollState = false;
...@@ -59,14 +59,13 @@ export default class App extends VuexModule { ...@@ -59,14 +59,13 @@ export default class App extends VuexModule {
@Mutation @Mutation
commitProjectConfigState(proCfg: DeepPartial<ProjectConfig>): void { commitProjectConfigState(proCfg: DeepPartial<ProjectConfig>): void {
this.projectConfigState = deepMerge(this.projectConfigState || {}, proCfg); this.projectConfigState = deepMerge(this.projectConfigState || {}, proCfg);
setLocal(PROJ_CFG_KEY, this.projectConfigState); Persistent.setLocal(PROJ_CFG_KEY, this.projectConfigState);
} }
@Action @Action
async resumeAllState() { async resumeAllState() {
resetRouter(); resetRouter();
clearSession(); Persistent.clearAll();
clearLocal();
permissionStore.commitResetState(); permissionStore.commitResetState();
tabStore.commitResetState(); tabStore.commitResetState();
......
...@@ -4,7 +4,7 @@ import store from '/@/store'; ...@@ -4,7 +4,7 @@ import store from '/@/store';
import { LOCK_INFO_KEY } from '/@/enums/cacheEnum'; import { LOCK_INFO_KEY } from '/@/enums/cacheEnum';
import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper'; import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper';
import { setLocal, getLocal, removeLocal } from '/@/utils/cache/persistent'; import { Persistent } from '/@/utils/cache/persistent';
import { userStore } from './user'; import { userStore } from './user';
...@@ -18,7 +18,7 @@ hotModuleUnregisterModule(NAME); ...@@ -18,7 +18,7 @@ hotModuleUnregisterModule(NAME);
@Module({ dynamic: true, namespaced: true, store, name: NAME }) @Module({ dynamic: true, namespaced: true, store, name: NAME })
class Lock extends VuexModule { class Lock extends VuexModule {
// lock info // lock info
private lockInfoState: LockInfo | null = getLocal(LOCK_INFO_KEY); private lockInfoState: LockInfo | null = Persistent.getLocal(LOCK_INFO_KEY);
get getLockInfo(): LockInfo { get getLockInfo(): LockInfo {
return this.lockInfoState || ({} as LockInfo); return this.lockInfoState || ({} as LockInfo);
...@@ -27,12 +27,12 @@ class Lock extends VuexModule { ...@@ -27,12 +27,12 @@ class Lock extends VuexModule {
@Mutation @Mutation
commitLockInfoState(info: LockInfo): void { commitLockInfoState(info: LockInfo): void {
this.lockInfoState = Object.assign({}, this.lockInfoState, info); this.lockInfoState = Object.assign({}, this.lockInfoState, info);
setLocal(LOCK_INFO_KEY, this.lockInfoState); Persistent.setLocal(LOCK_INFO_KEY, this.lockInfoState);
} }
@Mutation @Mutation
resetLockInfo(): void { resetLockInfo(): void {
removeLocal(LOCK_INFO_KEY); Persistent.removeLocal(LOCK_INFO_KEY);
this.lockInfoState = null; this.lockInfoState = null;
} }
......
...@@ -18,30 +18,23 @@ import router from '/@/router'; ...@@ -18,30 +18,23 @@ import router from '/@/router';
import { loginApi, getUserInfoById } from '/@/api/sys/user'; import { loginApi, getUserInfoById } from '/@/api/sys/user';
import { setLocal, getLocal, getSession, setSession } from '/@/utils/cache/persistent'; import { Persistent, BasicKeys } from '/@/utils/cache/persistent';
import { useProjectSetting } from '/@/hooks/setting';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { ErrorMessageMode } from '/@/utils/http/axios/types'; import { ErrorMessageMode } from '/@/utils/http/axios/types';
import projectSetting from '/@/settings/projectSetting';
export type UserInfo = Omit<GetUserInfoByUserIdModel, 'roles'>; export type UserInfo = Omit<GetUserInfoByUserIdModel, 'roles'>;
const NAME = 'user'; const NAME = 'user';
hotModuleUnregisterModule(NAME); hotModuleUnregisterModule(NAME);
const { permissionCacheType } = useProjectSetting(); function getCache<T>(key: BasicKeys) {
const { permissionCacheType } = projectSetting;
function getCache<T>(key: string) { const fn =
const fn = permissionCacheType === CacheTypeEnum.LOCAL ? getLocal : getSession; permissionCacheType === CacheTypeEnum.LOCAL ? Persistent.getLocal : Persistent.getSession;
return fn(key) as T; return fn(key) as T;
} }
function setCache(USER_INFO_KEY: string, info: any) {
if (!info) return;
setLocal(USER_INFO_KEY, info, true);
// TODO
setSession(USER_INFO_KEY, info, true);
}
@Module({ namespaced: true, name: NAME, dynamic: true, store }) @Module({ namespaced: true, name: NAME, dynamic: true, store })
class User extends VuexModule { class User extends VuexModule {
// user info // user info
...@@ -75,19 +68,19 @@ class User extends VuexModule { ...@@ -75,19 +68,19 @@ class User extends VuexModule {
@Mutation @Mutation
commitUserInfoState(info: UserInfo): void { commitUserInfoState(info: UserInfo): void {
this.userInfoState = info; this.userInfoState = info;
setCache(USER_INFO_KEY, info); Persistent.setLocal(USER_INFO_KEY, info);
} }
@Mutation @Mutation
commitRoleListState(roleList: RoleEnum[]): void { commitRoleListState(roleList: RoleEnum[]): void {
this.roleListState = roleList; this.roleListState = roleList;
setCache(ROLES_KEY, roleList); Persistent.setLocal(ROLES_KEY, roleList);
} }
@Mutation @Mutation
commitTokenState(info: string): void { commitTokenState(info: string): void {
this.tokenState = info; this.tokenState = info;
setCache(TOKEN_KEY, info); Persistent.setLocal(TOKEN_KEY, info);
} }
/** /**
......
import { getStorageShortName } from '/@/utils/env'; import { getStorageShortName } from '/@/utils/env';
import { createStorage as create } from './storageCache'; import { createStorage as create, CreateStorageParams } from './storageCache';
import { enableStorageEncryption } from '/@/settings/encryptionSetting'; import { enableStorageEncryption } from '/@/settings/encryptionSetting';
import { DEFAULT_CACHE_TIME } from '/@/settings/encryptionSetting'; import { DEFAULT_CACHE_TIME } from '/@/settings/encryptionSetting';
const createOptions = (storage = sessionStorage) => { export type Options = Partial<CreateStorageParams>;
const createOptions = (storage: Storage, options: Options = {}): Options => {
return { return {
// No encryption in debug mode // No encryption in debug mode
hasEncrypt: enableStorageEncryption, hasEncrypt: enableStorageEncryption,
storage, storage,
prefixKey: getStorageShortName(), prefixKey: getStorageShortName(),
timeout: DEFAULT_CACHE_TIME,
...options,
}; };
}; };
export const WebStorage = create(createOptions()); export const WebStorage = create(createOptions(sessionStorage));
export const createStorage = (storage: Storage = sessionStorage, options: Options = {}) => {
return create(createOptions(storage, options));
};
export const createStorage = (storage: Storage = sessionStorage) => { export const createPersistentStorage = (
return create(createOptions(storage))!; storage: Storage = sessionStorage,
options: Options = {}
) => {
return createStorage(storage, { ...options, timeout: DEFAULT_CACHE_TIME });
}; };
export default WebStorage; export default WebStorage;
export interface Cache<V = any> {
value?: V;
timeoutId?: ReturnType<typeof setTimeout>;
time?: number;
alive?: number;
}
const NOT_ALIVE = 0;
export class Memory<T = any, V = any> {
private cache: { [key in keyof T]?: Cache<V> } = {};
private alive: number;
constructor(alive = NOT_ALIVE) {
// Unit second
this.alive = alive * 1000;
}
get getCache() {
return this.cache;
}
setCache(cache) {
this.cache = cache;
}
// get<K extends keyof T>(key: K) {
// const item = this.getItem(key);
// const time = item?.time;
// if (!isNullOrUnDef(time) && time < new Date().getTime()) {
// this.remove(key);
// }
// return item?.value ?? undefined;
// }
get<K extends keyof T>(key: K) {
return this.cache[key];
}
set<K extends keyof T>(key: K, value: V, expires?: number) {
let item = this.get(key);
if (!expires || (expires as number) <= 0) {
expires = this.alive;
}
if (item) {
if (item.timeoutId) {
clearTimeout(item.timeoutId);
item.timeoutId = undefined;
}
item.value = value;
} else {
item = { value, alive: expires };
this.cache[key] = item;
}
if (!expires) {
return value;
}
item.time = new Date().getTime() + this.alive * 1000;
item.timeoutId = setTimeout(() => {
this.remove(key);
}, expires);
return value;
}
remove<K extends keyof T>(key: K) {
const item = this.get(key);
Reflect.deleteProperty(this.cache, key);
if (item) {
clearTimeout(item.timeoutId!);
return item.value;
}
}
resetCache(cache: { [K in keyof T]: Cache }) {
Object.keys(cache).forEach((key) => {
const k = (key as any) as keyof T;
const item = cache[k];
if (item && item.time) {
const now = new Date().getTime();
const expire = now + item.time * 1000;
if (expire > now) {
this.set(k, item.value, expire);
}
}
});
}
clear() {
Object.keys(this.cache).forEach((key) => {
const item = this.cache[key];
item.timeoutId && clearTimeout(item.timeoutId);
});
this.cache = {};
}
}
import { createStorage } from '/@/utils/cache'; import { createPersistentStorage } from '/@/utils/cache';
import { Memory } from './memory';
import { BASE_LOCAL_CACHE_KEY, BASE_SESSION_CACHE_KEY } from '/@/enums/cacheEnum'; import {
TOKEN_KEY,
const ls = createStorage(localStorage); USER_INFO_KEY,
const ss = createStorage(); ROLES_KEY,
LOCK_INFO_KEY,
interface CacheStore { PROJ_CFG_KEY,
local: Recordable; APP_LOCAL_CACHE_KEY,
session: Recordable; APP_SESSION_CACHE_KEY,
} from '/@/enums/cacheEnum';
import { DEFAULT_CACHE_TIME } from '/@/settings/encryptionSetting';
import { toRaw } from 'vue';
interface BasicStore {
[TOKEN_KEY]: string | number | null | undefined;
[USER_INFO_KEY]: Recordable;
[ROLES_KEY]: Recordable;
[LOCK_INFO_KEY]: Recordable;
[PROJ_CFG_KEY]: Recordable;
} }
/** type LocalStore = BasicStore;
* @description: Persistent cache
*/
const cacheStore: CacheStore = {
// localstorage cache
local: {},
// sessionstorage cache
session: {},
};
function initCache() {
cacheStore.local = ls.get(BASE_LOCAL_CACHE_KEY) || {};
cacheStore.session = ss.get(BASE_SESSION_CACHE_KEY) || {};
}
initCache(); type SessionStore = BasicStore;
export function setLocal(key: string, value: any, immediate = false) { export type BasicKeys = keyof BasicStore;
const local = ls.get(BASE_LOCAL_CACHE_KEY)?.[BASE_LOCAL_CACHE_KEY] || {}; type LocalKeys = keyof LocalStore;
type SessionKeys = keyof SessionStore;
cacheStore.local[BASE_LOCAL_CACHE_KEY] = const ls = createPersistentStorage(localStorage);
{ ...local, ...cacheStore.local[BASE_LOCAL_CACHE_KEY] } || {}; const ss = createPersistentStorage(sessionStorage);
cacheStore.local[BASE_LOCAL_CACHE_KEY][key] = value;
if (immediate) { const localMemory = new Memory(DEFAULT_CACHE_TIME);
ls.set(BASE_LOCAL_CACHE_KEY, cacheStore.local); const sessionMemory = new Memory(DEFAULT_CACHE_TIME);
}
}
export function getLocal<T>(key: string): T | null { function initMemory() {
try { const localCache = ls.get(APP_LOCAL_CACHE_KEY);
return cacheStore.local[BASE_LOCAL_CACHE_KEY][key]; const sessionCache = ls.get(APP_SESSION_CACHE_KEY);
} catch (error) { localCache && localMemory.resetCache(localCache);
return null; sessionCache && sessionMemory.resetCache(sessionCache);
}
} }
initMemory();
export function removeLocal(key: string) { export class Persistent {
if (cacheStore.local[BASE_LOCAL_CACHE_KEY]) { static getLocal<T>(key: LocalKeys) {
Reflect.deleteProperty(cacheStore.local[BASE_LOCAL_CACHE_KEY], key); return localMemory.get(key)?.value as Nullable<T>;
} }
}
export function clearLocal(immediate = false) {
cacheStore.local = {};
immediate && ls.remove(BASE_LOCAL_CACHE_KEY);
}
export function setSession(key: string, value: any, immediate = false) {
const session = ss.get(BASE_SESSION_CACHE_KEY)?.[BASE_SESSION_CACHE_KEY] || {};
cacheStore.session[BASE_SESSION_CACHE_KEY] =
{ ...session, ...cacheStore.session[BASE_SESSION_CACHE_KEY] } || {};
cacheStore.session[BASE_SESSION_CACHE_KEY][key] = value; static setLocal(key: LocalKeys, value: LocalStore[LocalKeys], immediate = false): void {
localMemory.set(key, toRaw(value));
immediate && ls.set(APP_LOCAL_CACHE_KEY, localMemory.getCache);
}
if (immediate) { static removeLocal(key: LocalKeys): void {
ss.set(BASE_SESSION_CACHE_KEY, cacheStore.session); localMemory.remove(key);
} }
}
export function removeSession(key: string) { static clearLocal(): void {
if (cacheStore.session[BASE_SESSION_CACHE_KEY]) { localMemory.clear();
Reflect.deleteProperty(cacheStore.session[BASE_SESSION_CACHE_KEY], key);
} }
}
export function getSession<T>(key: string): T | null { static getSession<T>(key: SessionKeys) {
try { return sessionMemory.get(key)?.value as Nullable<T>;
return cacheStore.session[BASE_SESSION_CACHE_KEY][key];
} catch (error) {
return null;
} }
}
export function clearSession(immediate = false) { static setSession(key: SessionKeys, value: SessionStore[SessionKeys], immediate = false): void {
cacheStore.session = {}; sessionMemory.set(key, toRaw(value));
immediate && ss.remove(BASE_SESSION_CACHE_KEY); immediate && ss.set(APP_SESSION_CACHE_KEY, localMemory);
} }
export function clearAll() { static removeSession(key: SessionKeys): void {
clearLocal(); sessionMemory.remove(key);
clearSession(); }
} static clearSession(): void {
sessionMemory.clear();
}
export function persistentCache() { static clearAll() {
const localCache = cacheStore.local; sessionMemory.clear();
const sessionCache = cacheStore.session; localMemory.clear();
ls.set(BASE_LOCAL_CACHE_KEY, localCache); }
ss.set(BASE_SESSION_CACHE_KEY, sessionCache);
} }
(() => { window.addEventListener('beforeunload', function () {
// /** Write to local before closing window */ ls.set(APP_LOCAL_CACHE_KEY, localMemory.getCache);
window.addEventListener('beforeunload', () => { ss.set(APP_SESSION_CACHE_KEY, sessionMemory.getCache);
persistentCache(); });
});
function storageChange(e: any) { function storageChange(e: any) {
const { key, newValue, oldValue } = e; const { key, newValue, oldValue } = e;
if (!key) { if (!key) {
clearAll(); Persistent.clearAll();
return; return;
} }
if (!!newValue && !!oldValue) { if (!!newValue && !!oldValue) {
if (BASE_LOCAL_CACHE_KEY === key) { if (APP_LOCAL_CACHE_KEY === key) {
clearLocal(); Persistent.clearLocal();
}
if (BASE_SESSION_CACHE_KEY === key) {
clearSession();
} }
if (APP_SESSION_CACHE_KEY === key) {
Persistent.clearSession();
} }
} }
}
window.addEventListener('storage', storageChange);
window.addEventListener('storage', storageChange); export default {};
})();
...@@ -1123,43 +1123,43 @@ ...@@ -1123,43 +1123,43 @@
resolved "https://registry.npmjs.org/@iconify/json/-/json-1.1.308.tgz#162210182c14af4eb217f19e1a1707b787aca2aa" resolved "https://registry.npmjs.org/@iconify/json/-/json-1.1.308.tgz#162210182c14af4eb217f19e1a1707b787aca2aa"
integrity sha512-zoVnvr5A1tpuTCzuw5EvRcWYV5rcmWLGLhEzg9+SuRAXWyT2st0ShF8hYbeHzm+MJHhJWodHVfsTu2DkshMX2g== integrity sha512-zoVnvr5A1tpuTCzuw5EvRcWYV5rcmWLGLhEzg9+SuRAXWyT2st0ShF8hYbeHzm+MJHhJWodHVfsTu2DkshMX2g==
"@intlify/core-base@9.0.0-rc.8": "@intlify/core-base@9.0.0":
version "9.0.0-rc.8" version "9.0.0"
resolved "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.0.0-rc.8.tgz#674b88c313cbe471bb66f52dd0907106b01e1c38" resolved "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.0.0.tgz#3de223b8532c535d022e5be58f7d56a26d2fb12f"
integrity sha512-Nwj2GTZN7gOiN7uGgAeaaJAho/UamkXTheMrdjLrj7FPjE3d1oiSeB3fBgobJxzpyBRjhmjUmpPCEs1afokSxQ== integrity sha512-dxqakT94EV2bFshG3LENQUPWX9yJFCga1BOwJ6mz7J8LnAYVB9Kxw7NRyE2ybN31USW2IUTQH6WWR1yDbCiefQ==
dependencies: dependencies:
"@intlify/message-compiler" "9.0.0-rc.8" "@intlify/message-compiler" "9.0.0"
"@intlify/message-resolver" "9.0.0-rc.8" "@intlify/message-resolver" "9.0.0"
"@intlify/runtime" "9.0.0-rc.8" "@intlify/runtime" "9.0.0"
"@intlify/shared" "9.0.0-rc.8" "@intlify/shared" "9.0.0"
"@intlify/message-compiler@9.0.0-rc.8": "@intlify/message-compiler@9.0.0":
version "9.0.0-rc.8" version "9.0.0"
resolved "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.0.0-rc.8.tgz#b2c291b728858aa6fa57b6329a806c1accc8450b" resolved "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.0.0.tgz#8a1079f8aebcde33057ce769817691ce27ad3e0d"
integrity sha512-vtKk5z7ovenLUXMGHVUyS+snEYrTpHT4o6bQyjPeEL3BoXcVyHlLKIHXNJ6QzlHVQN8aN1bWyj3rMf9ZKEZF3A== integrity sha512-3oiLj+8z6koRYJwknazjilBsrqnJEAJywr/t39MYVy2yPmwOI1+NDfdDwM9U3ioA2RvsQEUICqW8gmjq1YIElw==
dependencies: dependencies:
"@intlify/message-resolver" "9.0.0-rc.8" "@intlify/message-resolver" "9.0.0"
"@intlify/shared" "9.0.0-rc.8" "@intlify/shared" "9.0.0"
source-map "0.6.1" source-map "0.6.1"
"@intlify/message-resolver@9.0.0-rc.8": "@intlify/message-resolver@9.0.0":
version "9.0.0-rc.8" version "9.0.0"
resolved "https://registry.npmjs.org/@intlify/message-resolver/-/message-resolver-9.0.0-rc.8.tgz#09382e6390298d6786cc53c483d4240e4654ec17" resolved "https://registry.npmjs.org/@intlify/message-resolver/-/message-resolver-9.0.0.tgz#0077ec24606b6486d238bdef9044e27729f4782c"
integrity sha512-8Qqh23yN3sM/hIZKIgJ1S6a9mNm1LVeUxkjhHdfyGV84P6G3Q9bgwCSenX1BKuUrVUJfK45FUkg87BZnUd2Qpg== integrity sha512-LVK4cwu1l33yvBy0UQkEdXm6pZUcbbiparobruJXz+U8jRTmYHBprN59j59YKXEKcV43cHfzNveaQIm84bgxvQ==
"@intlify/runtime@9.0.0-rc.8": "@intlify/runtime@9.0.0":
version "9.0.0-rc.8" version "9.0.0"
resolved "https://registry.npmjs.org/@intlify/runtime/-/runtime-9.0.0-rc.8.tgz#be5d1c776bba2678b51c3c0492d4676a910921ca" resolved "https://registry.npmjs.org/@intlify/runtime/-/runtime-9.0.0.tgz#bf9415ff90c746a9be38a5c32f71cbbe9848eee8"
integrity sha512-ZK0eZwZQ6wb3nxUPc+WYSebnswSSt/lRJotmaVdcmS+tT9/FFz6PJ9pO0nNFV/cGn0uEGW92buldCiNVKA5aHg== integrity sha512-UqCKduZezb5/qA+XPRfHVvXoLmhnQ8iKMyCh0Lg3ZwjW2vOMep/AgZU3T9cgESe67r4buPYHs7nOBSHbTdjNxg==
dependencies: dependencies:
"@intlify/message-compiler" "9.0.0-rc.8" "@intlify/message-compiler" "9.0.0"
"@intlify/message-resolver" "9.0.0-rc.8" "@intlify/message-resolver" "9.0.0"
"@intlify/shared" "9.0.0-rc.8" "@intlify/shared" "9.0.0"
"@intlify/shared@9.0.0-rc.8": "@intlify/shared@9.0.0":
version "9.0.0-rc.8" version "9.0.0"
resolved "https://registry.npmjs.org/@intlify/shared/-/shared-9.0.0-rc.8.tgz#0b1b387a3237d4ae95496e8ae60cec267625f55d" resolved "https://registry.npmjs.org/@intlify/shared/-/shared-9.0.0.tgz#d85b3b5f9033f377c5cf2202cf2459aa49948f36"
integrity sha512-HH05+lD4A9q6F0VLbGY5eZmmCbfaBMuCSSQXmrGgegtsRVu7WFiUMQLNsouN1UtHabOJC9PQarxKwfTzdHyN6Q== integrity sha512-0r4v7dnY8g/Jfx2swUWy2GyfH/WvIpWvkU4OIupvxDTWiE8RhcpbOCVvqpVh/xGi0proHQ/r2Dhc0QSItUsfDQ==
"@ls-lint/ls-lint@^1.9.2": "@ls-lint/ls-lint@^1.9.2":
version "1.9.2" version "1.9.2"
...@@ -1595,10 +1595,10 @@ ...@@ -1595,10 +1595,10 @@
"@vue/babel-plugin-jsx" "^1.0.3" "@vue/babel-plugin-jsx" "^1.0.3"
hash-sum "^2.0.0" hash-sum "^2.0.0"
"@vitejs/plugin-vue@^1.1.4": "@vitejs/plugin-vue@^1.1.5":
version "1.1.4" version "1.1.5"
resolved "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-1.1.4.tgz#1dd388519b75439b7733601b55238ca691864796" resolved "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-1.1.5.tgz#fa1e8e5e049c35e213672e33f73fe81706ad5dbe"
integrity sha512-cUDILd++9jdhdjpuhgJofQqOabOKe+kTWTE2HQY2PBHEUO2fgwTurLE0cJg9UcIo1x4lHfsp+59S9TBCHgTZkw== integrity sha512-4DV8VPYo8/OR1YsnK39QN16xhKENt2XvcmJxqfRtyz75kvbjBYh1zTSHLp7XsXqv4R2I+fOZlbEBvxosMYLcPA==
"@vue/babel-helper-vue-transform-on@^1.0.2": "@vue/babel-helper-vue-transform-on@^1.0.2":
version "1.0.2" version "1.0.2"
...@@ -1703,25 +1703,25 @@ ...@@ -1703,25 +1703,25 @@
resolved "https://registry.npmjs.org/@vue/shared/-/shared-3.0.5.tgz#c131d88bd6713cc4d93b3bb1372edb1983225ff0" resolved "https://registry.npmjs.org/@vue/shared/-/shared-3.0.5.tgz#c131d88bd6713cc4d93b3bb1372edb1983225ff0"
integrity sha512-gYsNoGkWejBxNO6SNRjOh/xKeZ0H0V+TFzaPzODfBjkAIb0aQgBuixC1brandC/CDJy1wYPwSoYrXpvul7m6yw== integrity sha512-gYsNoGkWejBxNO6SNRjOh/xKeZ0H0V+TFzaPzODfBjkAIb0aQgBuixC1brandC/CDJy1wYPwSoYrXpvul7m6yw==
"@vueuse/core@^4.2.2": "@vueuse/core@^4.3.0":
version "4.2.2" version "4.3.0"
resolved "https://registry.npmjs.org/@vueuse/core/-/core-4.2.2.tgz#ecbba4ba05e0360e9c9079b32e149fac803a1020" resolved "https://registry.npmjs.org/@vueuse/core/-/core-4.3.0.tgz#409d1c8fc0b7fffcf5b5388dfc487762bb936b0c"
integrity sha512-NMU3Vr4eBiNrPzCoUH5ptNj+DETg85Vtww0OJjaQEXobDTH28gzbLJseqCh4m3NYR92C5qlXRnzhSvWOoR/uLg== integrity sha512-PQ3r6wZDCN3pY+UBB5NLQdRfwiasd8MmWppuzpvNE2Sr8T48gmWXDWw3GG4EHMXnuz5EBfQG+U+1TjSaGaK6/w==
dependencies: dependencies:
"@vueuse/shared" "4.2.2" "@vueuse/shared" "4.3.0"
vue-demi latest vue-demi latest
"@vueuse/shared@4.2.2": "@vueuse/shared@4.3.0":
version "4.2.2" version "4.3.0"
resolved "https://registry.npmjs.org/@vueuse/shared/-/shared-4.2.2.tgz#e52ee278b929f028117c0ca1792b24df462bff80" resolved "https://registry.npmjs.org/@vueuse/shared/-/shared-4.3.0.tgz#82e05dc2941642814ac6fcbb5f9076c38c052968"
integrity sha512-yudh4jt0SxaW0i3j2iumI8GTloA8aUpLwGaBw9Xv2rQCdZvOZpXpvpGEz8EsMK793ySs+d5S4/opItlxuzjtSg== integrity sha512-udc1ADIYwizTK/iSfjZQj6+QDFM099oHuX0Sj/yv0NgE9eSODcesV4zO7PtvmJanzw43hCdvtdGBz8miyRkHCQ==
dependencies: dependencies:
vue-demi latest vue-demi latest
"@windicss/plugin-utils@0.5.3": "@windicss/plugin-utils@0.5.4":
version "0.5.3" version "0.5.4"
resolved "https://registry.npmjs.org/@windicss/plugin-utils/-/plugin-utils-0.5.3.tgz#5302864cb2f94dd3d71bb5af958dab6ce3f74dab" resolved "https://registry.npmjs.org/@windicss/plugin-utils/-/plugin-utils-0.5.4.tgz#69476a9d1fee92046695766bf7fbfe48e48809a7"
integrity sha512-BXNvMSRmi1TyM8j3EnF/li9HViJPN4EPeGKTiIDWemxrfkRNlgN+Gmv31CFtZwnjiAlXRO58B6LIqVTSVYaTfQ== integrity sha512-zxpHdTsVZl7TF8A3uAymJCqMRlG83dMRAXf//fXonluoLDSJCuGBJyxN3NdkAyNZZR1L1DvoUUtkZLYOba+ElQ==
dependencies: dependencies:
esbuild "^0.8.52" esbuild "^0.8.52"
esbuild-register "^2.0.0" esbuild-register "^2.0.0"
...@@ -3601,11 +3601,6 @@ esbuild-register@^2.0.0: ...@@ -3601,11 +3601,6 @@ esbuild-register@^2.0.0:
source-map-support "^0.5.19" source-map-support "^0.5.19"
strip-json-comments "^3.1.1" strip-json-comments "^3.1.1"
esbuild@^0.8.47:
version "0.8.51"
resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.8.51.tgz#1a59f1fee34892f143b7009081f9b4901a564b93"
integrity sha512-MVIom8fgL1+B6iGqWtrG7QJ1gqd64BycxounlsX1kR/IcIITaSlTo7gghKpg4a+bnxkpo0dwcikuvk4MVSA9ww==
esbuild@^0.8.48: esbuild@^0.8.48:
version "0.8.48" version "0.8.48"
resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.8.48.tgz#a57e4dde84ec56da1c6ecaefee97e9da6c5b00b5" resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.8.48.tgz#a57e4dde84ec56da1c6ecaefee97e9da6c5b00b5"
...@@ -8973,20 +8968,20 @@ vite-plugin-theme@^0.4.8: ...@@ -8973,20 +8968,20 @@ vite-plugin-theme@^0.4.8:
es-module-lexer "^0.3.26" es-module-lexer "^0.3.26"
tinycolor2 "^1.4.2" tinycolor2 "^1.4.2"
vite-plugin-windicss@0.5.3: vite-plugin-windicss@0.5.4:
version "0.5.3" version "0.5.4"
resolved "https://registry.npmjs.org/vite-plugin-windicss/-/vite-plugin-windicss-0.5.3.tgz#7929b5fbaed7f0530cbe79947e7bc9e4f471b683" resolved "https://registry.npmjs.org/vite-plugin-windicss/-/vite-plugin-windicss-0.5.4.tgz#35764e91536d596ac2c9266c3e16c546915d8b3e"
integrity sha512-hVfj0QjgxBch4j5M6BfMj9Dsm7iKioP9uQUvs00RGkuUdG+Gc0PQcT9SuLrcZJjUE/2Tp9+J44BEbOYxjesqlA== integrity sha512-iPLoqfpZdnRIY1AzweumpdE8ILQQnyhywZwJDqFpj8SZ3h43e5tfQFnJb5nS6FLccOsBcCV9JFugD2w6pGyfqg==
dependencies: dependencies:
"@windicss/plugin-utils" "0.5.3" "@windicss/plugin-utils" "0.5.4"
windicss "^2.2.0" windicss "^2.2.0"
vite@2.0.3: vite@2.0.4:
version "2.0.3" version "2.0.4"
resolved "https://registry.npmjs.org/vite/-/vite-2.0.3.tgz#ea0329295d4da9341e670036e5e7f0bfa30ae2cf" resolved "https://registry.npmjs.org/vite/-/vite-2.0.4.tgz#063532a4139b59a067297d8ebb5960d450907a09"
integrity sha512-4CUm3FVUHyTSSSK6vHWkj3SVkP+GGNNzwYcFsHOjjc8xQ3BPjJa1JDDmFlYxpxR29ANa+7RWptYPoyHyJ29Nhw== integrity sha512-+PP89D7AKXFE4gps8c5+4eP5yXTh5qCogjdYX7iSsIxbLZAa26JoGSq6OLk0qdb/fqDh7gtJqGiLbG2V6NvkKQ==
dependencies: dependencies:
esbuild "^0.8.47" esbuild "^0.8.52"
postcss "^8.2.1" postcss "^8.2.1"
resolve "^1.19.0" resolve "^1.19.0"
rollup "^2.38.5" rollup "^2.38.5"
...@@ -9010,13 +9005,13 @@ vue-eslint-parser@^7.5.0: ...@@ -9010,13 +9005,13 @@ vue-eslint-parser@^7.5.0:
esquery "^1.4.0" esquery "^1.4.0"
lodash "^4.17.15" lodash "^4.17.15"
vue-i18n@9.0.0-rc.8: vue-i18n@^9.0.0:
version "9.0.0-rc.8" version "9.0.0"
resolved "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.0.0-rc.8.tgz#36d022516cf2527ce02eecf9de116b978e163da3" resolved "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.0.0.tgz#a04c41d5ed3d5a068e923517bfaa0abcbc84e174"
integrity sha512-WQC9q0UG1lbk+naBBoVTrJjHPZfHP6Pid35Ek9AkCxUcXolW1pXUCQg1gIMF8I0obxLd/fSx9GuOWrB/aaU3aQ== integrity sha512-iks0eJDv/4cK/7tl/ooMUroNVVIGOK4kKS1PIHmPQk7QjT/sDfFM84vjPKgpARbw0GjJsOiADL43jufNfs9e9A==
dependencies: dependencies:
"@intlify/core-base" "9.0.0-rc.8" "@intlify/core-base" "9.0.0"
"@intlify/shared" "9.0.0-rc.8" "@intlify/shared" "9.0.0"
"@vue/devtools-api" "^6.0.0-beta.5" "@vue/devtools-api" "^6.0.0-beta.5"
vue-router@^4.0.4: vue-router@^4.0.4:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论