Commit f57eb944edfd967f5f45566ec5bedbf12f147492

Authored by Vben
1 parent 11d3f395

perf: improve persistent logic

... ... @@ -5,4 +5,4 @@ VITE_PORT = 3100
5 5 VITE_GLOB_APP_TITLE = Vben Admin
6 6  
7 7 # spa shortname
8   -VITE_GLOB_APP_SHORT_NAME = vue_vben_admin_2x
  8 +VITE_GLOB_APP_SHORT_NAME = vue_vben_admin
... ...
.github/workflows/release.yml
... ... @@ -17,7 +17,7 @@ jobs:
17 17 id: release_tag
18 18 uses: yyx990803/release-tag@master
19 19 env:
20   - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  20 + GITHUB_TOKEN: ${{ secrets.OPER_TOKEN }}
21 21 with:
22 22 tag_name: ${{ github.ref }}
23 23 body: |
... ...
.vscode/extensions.json
... ... @@ -5,7 +5,7 @@
5 5 "stylelint.vscode-stylelint",
6 6 "esbenp.prettier-vscode",
7 7 "mrmlnc.vscode-less",
8   - "antfu.i18n-ally",
  8 + "lokalise.i18n-ally",
9 9 "antfu.iconify",
10 10 "mikestead.dotenv",
11 11 "heybourn.headwind"
... ...
package.json
... ... @@ -26,7 +26,7 @@
26 26 },
27 27 "dependencies": {
28 28 "@iconify/iconify": "^2.0.0-rc.6",
29   - "@vueuse/core": "^4.2.2",
  29 + "@vueuse/core": "^4.3.0",
30 30 "@zxcvbn-ts/core": "^0.2.0",
31 31 "ant-design-vue": "2.0.0",
32 32 "apexcharts": "^3.25.0",
... ... @@ -41,7 +41,7 @@
41 41 "sortablejs": "^1.13.0",
42 42 "vditor": "^3.8.1",
43 43 "vue": "3.0.5",
44   - "vue-i18n": "9.0.0-rc.8",
  44 + "vue-i18n": "^9.0.0",
45 45 "vue-router": "^4.0.4",
46 46 "vue-types": "^3.0.2",
47 47 "vuex": "^4.0.0",
... ... @@ -68,7 +68,7 @@
68 68 "@typescript-eslint/eslint-plugin": "^4.15.2",
69 69 "@typescript-eslint/parser": "^4.15.2",
70 70 "@vitejs/plugin-legacy": "^1.3.1",
71   - "@vitejs/plugin-vue": "^1.1.4",
  71 + "@vitejs/plugin-vue": "^1.1.5",
72 72 "@vitejs/plugin-vue-jsx": "^1.1.2",
73 73 "@vue/compiler-sfc": "3.0.5",
74 74 "autoprefixer": "^10.2.4",
... ... @@ -97,7 +97,7 @@
97 97 "stylelint-order": "^4.1.0",
98 98 "ts-node": "^9.1.1",
99 99 "typescript": "4.1.5",
100   - "vite": "2.0.3",
  100 + "vite": "2.0.4",
101 101 "vite-plugin-compression": "^0.2.2",
102 102 "vite-plugin-html": "^2.0.2",
103 103 "vite-plugin-imagemin": "^0.2.8",
... ... @@ -106,7 +106,7 @@
106 106 "vite-plugin-pwa": "^0.5.5",
107 107 "vite-plugin-style-import": "^0.7.5",
108 108 "vite-plugin-theme": "^0.4.8",
109   - "vite-plugin-windicss": "0.5.3",
  109 + "vite-plugin-windicss": "0.5.4",
110 110 "vue-eslint-parser": "^7.5.0",
111 111 "yargs": "^16.2.0"
112 112 },
... ...
src/enums/cacheEnum.ts
1 1 // token key
2   -export const TOKEN_KEY = 'TOKEN';
  2 +export const TOKEN_KEY = 'TOKEN__';
3 3  
4 4 // user info key
5 5 export const USER_INFO_KEY = 'USER__INFO__';
... ... @@ -19,6 +19,12 @@ export const BASE_LOCAL_CACHE_KEY = 'LOCAL__CACHE__KEY__';
19 19 // base global session key
20 20 export const BASE_SESSION_CACHE_KEY = 'SESSION__CACHE__KEY__';
21 21  
  22 +// base global local key
  23 +export const APP_LOCAL_CACHE_KEY = 'LOCAL__CACHE__KEY__';
  24 +
  25 +// base global session key
  26 +export const APP_SESSION_CACHE_KEY = 'SESSION__CACHE__KEY__';
  27 +
22 28 export enum CacheTypeEnum {
23 29 SESSION,
24 30 LOCAL,
... ...
src/logics/initAppConfig.ts
... ... @@ -7,7 +7,7 @@ import type { ProjectConfig } from '/#/config';
7 7 import { PROJ_CFG_KEY } from '/@/enums/cacheEnum';
8 8  
9 9 import projectSetting from '/@/settings/projectSetting';
10   -import { getLocal } from '/@/utils/cache/persistent';
  10 +import { Persistent } from '/@/utils/cache/persistent';
11 11 import { updateHeaderBgColor, updateSidebarBgColor } from '/@/logics/theme/updateBackground';
12 12 import { updateColorWeak } from '/@/logics/theme/updateColorWeak';
13 13 import { updateGrayMode } from '/@/logics/theme/updateGrayMode';
... ... @@ -19,7 +19,7 @@ import { primaryColor } from '../../build/config/themeConfig';
19 19  
20 20 // Initial project configuration
21 21 export function initAppConfigStore() {
22   - let projCfg: ProjectConfig = getLocal(PROJ_CFG_KEY) as ProjectConfig;
  22 + let projCfg: ProjectConfig = Persistent.getLocal(PROJ_CFG_KEY) as ProjectConfig;
23 23 projCfg = deepMerge(projectSetting, projCfg || {});
24 24 try {
25 25 const {
... ...
src/settings/designSetting.ts
... ... @@ -4,6 +4,7 @@ export default {
4 4  
5 5 // app theme preset color
6 6 export const APP_PRESET_COLOR_LIST: string[] = [
  7 + '#0960bd',
7 8 '#0084f4',
8 9 '#009688',
9 10 '#536dfe',
... ...
src/store/modules/app.ts
... ... @@ -6,7 +6,7 @@ import store from '/@/store';
6 6 import { PROJ_CFG_KEY } from '/@/enums/cacheEnum';
7 7  
8 8 import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper';
9   -import { setLocal, getLocal, clearSession, clearLocal } from '/@/utils/cache/persistent';
  9 +import { Persistent } from '/@/utils/cache/persistent';
10 10 import { deepMerge } from '/@/utils';
11 11  
12 12 import { resetRouter } from '/@/router';
... ... @@ -29,7 +29,7 @@ export default class App extends VuexModule {
29 29 private pageLoadingState = false;
30 30  
31 31 // project config
32   - private projectConfigState: ProjectConfig | null = getLocal(PROJ_CFG_KEY);
  32 + private projectConfigState: ProjectConfig | null = Persistent.getLocal(PROJ_CFG_KEY);
33 33  
34 34 // set main overflow hidden
35 35 private lockMainScrollState = false;
... ... @@ -59,14 +59,13 @@ export default class App extends VuexModule {
59 59 @Mutation
60 60 commitProjectConfigState(proCfg: DeepPartial<ProjectConfig>): void {
61 61 this.projectConfigState = deepMerge(this.projectConfigState || {}, proCfg);
62   - setLocal(PROJ_CFG_KEY, this.projectConfigState);
  62 + Persistent.setLocal(PROJ_CFG_KEY, this.projectConfigState);
63 63 }
64 64  
65 65 @Action
66 66 async resumeAllState() {
67 67 resetRouter();
68   - clearSession();
69   - clearLocal();
  68 + Persistent.clearAll();
70 69  
71 70 permissionStore.commitResetState();
72 71 tabStore.commitResetState();
... ...
src/store/modules/lock.ts
... ... @@ -4,7 +4,7 @@ import store from &#39;/@/store&#39;;
4 4 import { LOCK_INFO_KEY } from '/@/enums/cacheEnum';
5 5  
6 6 import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper';
7   -import { setLocal, getLocal, removeLocal } from '/@/utils/cache/persistent';
  7 +import { Persistent } from '/@/utils/cache/persistent';
8 8  
9 9 import { userStore } from './user';
10 10  
... ... @@ -18,7 +18,7 @@ hotModuleUnregisterModule(NAME);
18 18 @Module({ dynamic: true, namespaced: true, store, name: NAME })
19 19 class Lock extends VuexModule {
20 20 // lock info
21   - private lockInfoState: LockInfo | null = getLocal(LOCK_INFO_KEY);
  21 + private lockInfoState: LockInfo | null = Persistent.getLocal(LOCK_INFO_KEY);
22 22  
23 23 get getLockInfo(): LockInfo {
24 24 return this.lockInfoState || ({} as LockInfo);
... ... @@ -27,12 +27,12 @@ class Lock extends VuexModule {
27 27 @Mutation
28 28 commitLockInfoState(info: LockInfo): void {
29 29 this.lockInfoState = Object.assign({}, this.lockInfoState, info);
30   - setLocal(LOCK_INFO_KEY, this.lockInfoState);
  30 + Persistent.setLocal(LOCK_INFO_KEY, this.lockInfoState);
31 31 }
32 32  
33 33 @Mutation
34 34 resetLockInfo(): void {
35   - removeLocal(LOCK_INFO_KEY);
  35 + Persistent.removeLocal(LOCK_INFO_KEY);
36 36 this.lockInfoState = null;
37 37 }
38 38  
... ...
src/store/modules/user.ts
... ... @@ -18,30 +18,23 @@ import router from &#39;/@/router&#39;;
18 18  
19 19 import { loginApi, getUserInfoById } from '/@/api/sys/user';
20 20  
21   -import { setLocal, getLocal, getSession, setSession } from '/@/utils/cache/persistent';
22   -import { useProjectSetting } from '/@/hooks/setting';
  21 +import { Persistent, BasicKeys } from '/@/utils/cache/persistent';
23 22 import { useI18n } from '/@/hooks/web/useI18n';
24 23 import { ErrorMessageMode } from '/@/utils/http/axios/types';
  24 +import projectSetting from '/@/settings/projectSetting';
25 25  
26 26 export type UserInfo = Omit<GetUserInfoByUserIdModel, 'roles'>;
27 27  
28 28 const NAME = 'user';
29 29 hotModuleUnregisterModule(NAME);
30 30  
31   -const { permissionCacheType } = useProjectSetting();
32   -
33   -function getCache<T>(key: string) {
34   - const fn = permissionCacheType === CacheTypeEnum.LOCAL ? getLocal : getSession;
  31 +function getCache<T>(key: BasicKeys) {
  32 + const { permissionCacheType } = projectSetting;
  33 + const fn =
  34 + permissionCacheType === CacheTypeEnum.LOCAL ? Persistent.getLocal : Persistent.getSession;
35 35 return fn(key) as T;
36 36 }
37 37  
38   -function setCache(USER_INFO_KEY: string, info: any) {
39   - if (!info) return;
40   - setLocal(USER_INFO_KEY, info, true);
41   - // TODO
42   - setSession(USER_INFO_KEY, info, true);
43   -}
44   -
45 38 @Module({ namespaced: true, name: NAME, dynamic: true, store })
46 39 class User extends VuexModule {
47 40 // user info
... ... @@ -75,19 +68,19 @@ class User extends VuexModule {
75 68 @Mutation
76 69 commitUserInfoState(info: UserInfo): void {
77 70 this.userInfoState = info;
78   - setCache(USER_INFO_KEY, info);
  71 + Persistent.setLocal(USER_INFO_KEY, info);
79 72 }
80 73  
81 74 @Mutation
82 75 commitRoleListState(roleList: RoleEnum[]): void {
83 76 this.roleListState = roleList;
84   - setCache(ROLES_KEY, roleList);
  77 + Persistent.setLocal(ROLES_KEY, roleList);
85 78 }
86 79  
87 80 @Mutation
88 81 commitTokenState(info: string): void {
89 82 this.tokenState = info;
90   - setCache(TOKEN_KEY, info);
  83 + Persistent.setLocal(TOKEN_KEY, info);
91 84 }
92 85  
93 86 /**
... ...
src/utils/cache/index.ts
1 1 import { getStorageShortName } from '/@/utils/env';
2   -import { createStorage as create } from './storageCache';
  2 +import { createStorage as create, CreateStorageParams } from './storageCache';
3 3 import { enableStorageEncryption } from '/@/settings/encryptionSetting';
4 4 import { DEFAULT_CACHE_TIME } from '/@/settings/encryptionSetting';
5 5  
6   -const createOptions = (storage = sessionStorage) => {
  6 +export type Options = Partial<CreateStorageParams>;
  7 +
  8 +const createOptions = (storage: Storage, options: Options = {}): Options => {
7 9 return {
8 10 // No encryption in debug mode
9 11 hasEncrypt: enableStorageEncryption,
10 12 storage,
11 13 prefixKey: getStorageShortName(),
12   - timeout: DEFAULT_CACHE_TIME,
  14 +
  15 + ...options,
13 16 };
14 17 };
15 18  
16   -export const WebStorage = create(createOptions());
  19 +export const WebStorage = create(createOptions(sessionStorage));
  20 +
  21 +export const createStorage = (storage: Storage = sessionStorage, options: Options = {}) => {
  22 + return create(createOptions(storage, options));
  23 +};
17 24  
18   -export const createStorage = (storage: Storage = sessionStorage) => {
19   - return create(createOptions(storage))!;
  25 +export const createPersistentStorage = (
  26 + storage: Storage = sessionStorage,
  27 + options: Options = {}
  28 +) => {
  29 + return createStorage(storage, { ...options, timeout: DEFAULT_CACHE_TIME });
20 30 };
21 31  
22 32 export default WebStorage;
... ...
src/utils/cache/memory.ts 0 โ†’ 100644
  1 +export interface Cache<V = any> {
  2 + value?: V;
  3 + timeoutId?: ReturnType<typeof setTimeout>;
  4 + time?: number;
  5 + alive?: number;
  6 +}
  7 +
  8 +const NOT_ALIVE = 0;
  9 +
  10 +export class Memory<T = any, V = any> {
  11 + private cache: { [key in keyof T]?: Cache<V> } = {};
  12 + private alive: number;
  13 +
  14 + constructor(alive = NOT_ALIVE) {
  15 + // Unit second
  16 + this.alive = alive * 1000;
  17 + }
  18 +
  19 + get getCache() {
  20 + return this.cache;
  21 + }
  22 +
  23 + setCache(cache) {
  24 + this.cache = cache;
  25 + }
  26 +
  27 + // get<K extends keyof T>(key: K) {
  28 + // const item = this.getItem(key);
  29 + // const time = item?.time;
  30 + // if (!isNullOrUnDef(time) && time < new Date().getTime()) {
  31 + // this.remove(key);
  32 + // }
  33 + // return item?.value ?? undefined;
  34 + // }
  35 +
  36 + get<K extends keyof T>(key: K) {
  37 + return this.cache[key];
  38 + }
  39 +
  40 + set<K extends keyof T>(key: K, value: V, expires?: number) {
  41 + let item = this.get(key);
  42 +
  43 + if (!expires || (expires as number) <= 0) {
  44 + expires = this.alive;
  45 + }
  46 + if (item) {
  47 + if (item.timeoutId) {
  48 + clearTimeout(item.timeoutId);
  49 + item.timeoutId = undefined;
  50 + }
  51 + item.value = value;
  52 + } else {
  53 + item = { value, alive: expires };
  54 + this.cache[key] = item;
  55 + }
  56 +
  57 + if (!expires) {
  58 + return value;
  59 + }
  60 + item.time = new Date().getTime() + this.alive * 1000;
  61 + item.timeoutId = setTimeout(() => {
  62 + this.remove(key);
  63 + }, expires);
  64 +
  65 + return value;
  66 + }
  67 +
  68 + remove<K extends keyof T>(key: K) {
  69 + const item = this.get(key);
  70 + Reflect.deleteProperty(this.cache, key);
  71 + if (item) {
  72 + clearTimeout(item.timeoutId!);
  73 + return item.value;
  74 + }
  75 + }
  76 +
  77 + resetCache(cache: { [K in keyof T]: Cache }) {
  78 + Object.keys(cache).forEach((key) => {
  79 + const k = (key as any) as keyof T;
  80 + const item = cache[k];
  81 + if (item && item.time) {
  82 + const now = new Date().getTime();
  83 + const expire = now + item.time * 1000;
  84 + if (expire > now) {
  85 + this.set(k, item.value, expire);
  86 + }
  87 + }
  88 + });
  89 + }
  90 +
  91 + clear() {
  92 + Object.keys(this.cache).forEach((key) => {
  93 + const item = this.cache[key];
  94 + item.timeoutId && clearTimeout(item.timeoutId);
  95 + });
  96 + this.cache = {};
  97 + }
  98 +}
... ...
src/utils/cache/persistent.ts
1   -import { createStorage } from '/@/utils/cache';
2   -
3   -import { BASE_LOCAL_CACHE_KEY, BASE_SESSION_CACHE_KEY } from '/@/enums/cacheEnum';
4   -
5   -const ls = createStorage(localStorage);
6   -const ss = createStorage();
7   -
8   -interface CacheStore {
9   - local: Recordable;
10   - session: Recordable;
  1 +import { createPersistentStorage } from '/@/utils/cache';
  2 +import { Memory } from './memory';
  3 +import {
  4 + TOKEN_KEY,
  5 + USER_INFO_KEY,
  6 + ROLES_KEY,
  7 + LOCK_INFO_KEY,
  8 + PROJ_CFG_KEY,
  9 + APP_LOCAL_CACHE_KEY,
  10 + APP_SESSION_CACHE_KEY,
  11 +} from '/@/enums/cacheEnum';
  12 +import { DEFAULT_CACHE_TIME } from '/@/settings/encryptionSetting';
  13 +import { toRaw } from 'vue';
  14 +
  15 +interface BasicStore {
  16 + [TOKEN_KEY]: string | number | null | undefined;
  17 + [USER_INFO_KEY]: Recordable;
  18 + [ROLES_KEY]: Recordable;
  19 + [LOCK_INFO_KEY]: Recordable;
  20 + [PROJ_CFG_KEY]: Recordable;
11 21 }
12 22  
13   -/**
14   - * @description: Persistent cache
15   - */
16   -const cacheStore: CacheStore = {
17   - // localstorage cache
18   - local: {},
19   - // sessionstorage cache
20   - session: {},
21   -};
22   -
23   -function initCache() {
24   - cacheStore.local = ls.get(BASE_LOCAL_CACHE_KEY) || {};
25   - cacheStore.session = ss.get(BASE_SESSION_CACHE_KEY) || {};
26   -}
  23 +type LocalStore = BasicStore;
27 24  
28   -initCache();
  25 +type SessionStore = BasicStore;
29 26  
30   -export function setLocal(key: string, value: any, immediate = false) {
31   - const local = ls.get(BASE_LOCAL_CACHE_KEY)?.[BASE_LOCAL_CACHE_KEY] || {};
  27 +export type BasicKeys = keyof BasicStore;
  28 +type LocalKeys = keyof LocalStore;
  29 +type SessionKeys = keyof SessionStore;
32 30  
33   - cacheStore.local[BASE_LOCAL_CACHE_KEY] =
34   - { ...local, ...cacheStore.local[BASE_LOCAL_CACHE_KEY] } || {};
35   - cacheStore.local[BASE_LOCAL_CACHE_KEY][key] = value;
  31 +const ls = createPersistentStorage(localStorage);
  32 +const ss = createPersistentStorage(sessionStorage);
36 33  
37   - if (immediate) {
38   - ls.set(BASE_LOCAL_CACHE_KEY, cacheStore.local);
39   - }
40   -}
  34 +const localMemory = new Memory(DEFAULT_CACHE_TIME);
  35 +const sessionMemory = new Memory(DEFAULT_CACHE_TIME);
41 36  
42   -export function getLocal<T>(key: string): T | null {
43   - try {
44   - return cacheStore.local[BASE_LOCAL_CACHE_KEY][key];
45   - } catch (error) {
46   - return null;
47   - }
  37 +function initMemory() {
  38 + const localCache = ls.get(APP_LOCAL_CACHE_KEY);
  39 + const sessionCache = ls.get(APP_SESSION_CACHE_KEY);
  40 + localCache && localMemory.resetCache(localCache);
  41 + sessionCache && sessionMemory.resetCache(sessionCache);
48 42 }
49   -
50   -export function removeLocal(key: string) {
51   - if (cacheStore.local[BASE_LOCAL_CACHE_KEY]) {
52   - Reflect.deleteProperty(cacheStore.local[BASE_LOCAL_CACHE_KEY], key);
  43 +initMemory();
  44 +export class Persistent {
  45 + static getLocal<T>(key: LocalKeys) {
  46 + return localMemory.get(key)?.value as Nullable<T>;
53 47 }
54   -}
55   -
56   -export function clearLocal(immediate = false) {
57   - cacheStore.local = {};
58   - immediate && ls.remove(BASE_LOCAL_CACHE_KEY);
59   -}
60   -
61   -export function setSession(key: string, value: any, immediate = false) {
62   - const session = ss.get(BASE_SESSION_CACHE_KEY)?.[BASE_SESSION_CACHE_KEY] || {};
63 48  
64   - cacheStore.session[BASE_SESSION_CACHE_KEY] =
65   - { ...session, ...cacheStore.session[BASE_SESSION_CACHE_KEY] } || {};
  49 + static setLocal(key: LocalKeys, value: LocalStore[LocalKeys], immediate = false): void {
  50 + localMemory.set(key, toRaw(value));
  51 + immediate && ls.set(APP_LOCAL_CACHE_KEY, localMemory.getCache);
  52 + }
66 53  
67   - cacheStore.session[BASE_SESSION_CACHE_KEY][key] = value;
  54 + static removeLocal(key: LocalKeys): void {
  55 + localMemory.remove(key);
  56 + }
68 57  
69   - if (immediate) {
70   - ss.set(BASE_SESSION_CACHE_KEY, cacheStore.session);
  58 + static clearLocal(): void {
  59 + localMemory.clear();
71 60 }
72   -}
73 61  
74   -export function removeSession(key: string) {
75   - if (cacheStore.session[BASE_SESSION_CACHE_KEY]) {
76   - Reflect.deleteProperty(cacheStore.session[BASE_SESSION_CACHE_KEY], key);
  62 + static getSession<T>(key: SessionKeys) {
  63 + return sessionMemory.get(key)?.value as Nullable<T>;
77 64 }
78   -}
79 65  
80   -export function getSession<T>(key: string): T | null {
81   - try {
82   - return cacheStore.session[BASE_SESSION_CACHE_KEY][key];
83   - } catch (error) {
84   - return null;
  66 + static setSession(key: SessionKeys, value: SessionStore[SessionKeys], immediate = false): void {
  67 + sessionMemory.set(key, toRaw(value));
  68 + immediate && ss.set(APP_SESSION_CACHE_KEY, localMemory);
85 69 }
86   -}
87 70  
88   -export function clearSession(immediate = false) {
89   - cacheStore.session = {};
90   - immediate && ss.remove(BASE_SESSION_CACHE_KEY);
91   -}
  71 + static removeSession(key: SessionKeys): void {
  72 + sessionMemory.remove(key);
  73 + }
  74 + static clearSession(): void {
  75 + sessionMemory.clear();
  76 + }
92 77  
93   -export function clearAll() {
94   - clearLocal();
95   - clearSession();
  78 + static clearAll() {
  79 + sessionMemory.clear();
  80 + localMemory.clear();
  81 + }
96 82 }
97 83  
98   -export function persistentCache() {
99   - const localCache = cacheStore.local;
100   - const sessionCache = cacheStore.session;
101   - ls.set(BASE_LOCAL_CACHE_KEY, localCache);
102   - ss.set(BASE_SESSION_CACHE_KEY, sessionCache);
103   -}
  84 +window.addEventListener('beforeunload', function () {
  85 + ls.set(APP_LOCAL_CACHE_KEY, localMemory.getCache);
  86 + ss.set(APP_SESSION_CACHE_KEY, sessionMemory.getCache);
  87 +});
104 88  
105   -(() => {
106   - // /** Write to local before closing window */
107   - window.addEventListener('beforeunload', () => {
108   - persistentCache();
109   - });
  89 +function storageChange(e: any) {
  90 + const { key, newValue, oldValue } = e;
110 91  
111   - function storageChange(e: any) {
112   - const { key, newValue, oldValue } = e;
  92 + if (!key) {
  93 + Persistent.clearAll();
  94 + return;
  95 + }
113 96  
114   - if (!key) {
115   - clearAll();
116   - return;
  97 + if (!!newValue && !!oldValue) {
  98 + if (APP_LOCAL_CACHE_KEY === key) {
  99 + Persistent.clearLocal();
117 100 }
118   -
119   - if (!!newValue && !!oldValue) {
120   - if (BASE_LOCAL_CACHE_KEY === key) {
121   - clearLocal();
122   - }
123   - if (BASE_SESSION_CACHE_KEY === key) {
124   - clearSession();
125   - }
  101 + if (APP_SESSION_CACHE_KEY === key) {
  102 + Persistent.clearSession();
126 103 }
127 104 }
  105 +}
  106 +
  107 +window.addEventListener('storage', storageChange);
128 108  
129   - window.addEventListener('storage', storageChange);
130   -})();
  109 +export default {};
... ...
yarn.lock
... ... @@ -1123,43 +1123,43 @@
1123 1123 resolved "https://registry.npmjs.org/@iconify/json/-/json-1.1.308.tgz#162210182c14af4eb217f19e1a1707b787aca2aa"
1124 1124 integrity sha512-zoVnvr5A1tpuTCzuw5EvRcWYV5rcmWLGLhEzg9+SuRAXWyT2st0ShF8hYbeHzm+MJHhJWodHVfsTu2DkshMX2g==
1125 1125  
1126   -"@intlify/core-base@9.0.0-rc.8":
1127   - version "9.0.0-rc.8"
1128   - resolved "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.0.0-rc.8.tgz#674b88c313cbe471bb66f52dd0907106b01e1c38"
1129   - integrity sha512-Nwj2GTZN7gOiN7uGgAeaaJAho/UamkXTheMrdjLrj7FPjE3d1oiSeB3fBgobJxzpyBRjhmjUmpPCEs1afokSxQ==
1130   - dependencies:
1131   - "@intlify/message-compiler" "9.0.0-rc.8"
1132   - "@intlify/message-resolver" "9.0.0-rc.8"
1133   - "@intlify/runtime" "9.0.0-rc.8"
1134   - "@intlify/shared" "9.0.0-rc.8"
1135   -
1136   -"@intlify/message-compiler@9.0.0-rc.8":
1137   - version "9.0.0-rc.8"
1138   - resolved "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.0.0-rc.8.tgz#b2c291b728858aa6fa57b6329a806c1accc8450b"
1139   - integrity sha512-vtKk5z7ovenLUXMGHVUyS+snEYrTpHT4o6bQyjPeEL3BoXcVyHlLKIHXNJ6QzlHVQN8aN1bWyj3rMf9ZKEZF3A==
1140   - dependencies:
1141   - "@intlify/message-resolver" "9.0.0-rc.8"
1142   - "@intlify/shared" "9.0.0-rc.8"
  1126 +"@intlify/core-base@9.0.0":
  1127 + version "9.0.0"
  1128 + resolved "https://registry.npmjs.org/@intlify/core-base/-/core-base-9.0.0.tgz#3de223b8532c535d022e5be58f7d56a26d2fb12f"
  1129 + integrity sha512-dxqakT94EV2bFshG3LENQUPWX9yJFCga1BOwJ6mz7J8LnAYVB9Kxw7NRyE2ybN31USW2IUTQH6WWR1yDbCiefQ==
  1130 + dependencies:
  1131 + "@intlify/message-compiler" "9.0.0"
  1132 + "@intlify/message-resolver" "9.0.0"
  1133 + "@intlify/runtime" "9.0.0"
  1134 + "@intlify/shared" "9.0.0"
  1135 +
  1136 +"@intlify/message-compiler@9.0.0":
  1137 + version "9.0.0"
  1138 + resolved "https://registry.npmjs.org/@intlify/message-compiler/-/message-compiler-9.0.0.tgz#8a1079f8aebcde33057ce769817691ce27ad3e0d"
  1139 + integrity sha512-3oiLj+8z6koRYJwknazjilBsrqnJEAJywr/t39MYVy2yPmwOI1+NDfdDwM9U3ioA2RvsQEUICqW8gmjq1YIElw==
  1140 + dependencies:
  1141 + "@intlify/message-resolver" "9.0.0"
  1142 + "@intlify/shared" "9.0.0"
1143 1143 source-map "0.6.1"
1144 1144  
1145   -"@intlify/message-resolver@9.0.0-rc.8":
1146   - version "9.0.0-rc.8"
1147   - resolved "https://registry.npmjs.org/@intlify/message-resolver/-/message-resolver-9.0.0-rc.8.tgz#09382e6390298d6786cc53c483d4240e4654ec17"
1148   - integrity sha512-8Qqh23yN3sM/hIZKIgJ1S6a9mNm1LVeUxkjhHdfyGV84P6G3Q9bgwCSenX1BKuUrVUJfK45FUkg87BZnUd2Qpg==
  1145 +"@intlify/message-resolver@9.0.0":
  1146 + version "9.0.0"
  1147 + resolved "https://registry.npmjs.org/@intlify/message-resolver/-/message-resolver-9.0.0.tgz#0077ec24606b6486d238bdef9044e27729f4782c"
  1148 + integrity sha512-LVK4cwu1l33yvBy0UQkEdXm6pZUcbbiparobruJXz+U8jRTmYHBprN59j59YKXEKcV43cHfzNveaQIm84bgxvQ==
1149 1149  
1150   -"@intlify/runtime@9.0.0-rc.8":
1151   - version "9.0.0-rc.8"
1152   - resolved "https://registry.npmjs.org/@intlify/runtime/-/runtime-9.0.0-rc.8.tgz#be5d1c776bba2678b51c3c0492d4676a910921ca"
1153   - integrity sha512-ZK0eZwZQ6wb3nxUPc+WYSebnswSSt/lRJotmaVdcmS+tT9/FFz6PJ9pO0nNFV/cGn0uEGW92buldCiNVKA5aHg==
  1150 +"@intlify/runtime@9.0.0":
  1151 + version "9.0.0"
  1152 + resolved "https://registry.npmjs.org/@intlify/runtime/-/runtime-9.0.0.tgz#bf9415ff90c746a9be38a5c32f71cbbe9848eee8"
  1153 + integrity sha512-UqCKduZezb5/qA+XPRfHVvXoLmhnQ8iKMyCh0Lg3ZwjW2vOMep/AgZU3T9cgESe67r4buPYHs7nOBSHbTdjNxg==
1154 1154 dependencies:
1155   - "@intlify/message-compiler" "9.0.0-rc.8"
1156   - "@intlify/message-resolver" "9.0.0-rc.8"
1157   - "@intlify/shared" "9.0.0-rc.8"
  1155 + "@intlify/message-compiler" "9.0.0"
  1156 + "@intlify/message-resolver" "9.0.0"
  1157 + "@intlify/shared" "9.0.0"
1158 1158  
1159   -"@intlify/shared@9.0.0-rc.8":
1160   - version "9.0.0-rc.8"
1161   - resolved "https://registry.npmjs.org/@intlify/shared/-/shared-9.0.0-rc.8.tgz#0b1b387a3237d4ae95496e8ae60cec267625f55d"
1162   - integrity sha512-HH05+lD4A9q6F0VLbGY5eZmmCbfaBMuCSSQXmrGgegtsRVu7WFiUMQLNsouN1UtHabOJC9PQarxKwfTzdHyN6Q==
  1159 +"@intlify/shared@9.0.0":
  1160 + version "9.0.0"
  1161 + resolved "https://registry.npmjs.org/@intlify/shared/-/shared-9.0.0.tgz#d85b3b5f9033f377c5cf2202cf2459aa49948f36"
  1162 + integrity sha512-0r4v7dnY8g/Jfx2swUWy2GyfH/WvIpWvkU4OIupvxDTWiE8RhcpbOCVvqpVh/xGi0proHQ/r2Dhc0QSItUsfDQ==
1163 1163  
1164 1164 "@ls-lint/ls-lint@^1.9.2":
1165 1165 version "1.9.2"
... ... @@ -1595,10 +1595,10 @@
1595 1595 "@vue/babel-plugin-jsx" "^1.0.3"
1596 1596 hash-sum "^2.0.0"
1597 1597  
1598   -"@vitejs/plugin-vue@^1.1.4":
1599   - version "1.1.4"
1600   - resolved "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-1.1.4.tgz#1dd388519b75439b7733601b55238ca691864796"
1601   - integrity sha512-cUDILd++9jdhdjpuhgJofQqOabOKe+kTWTE2HQY2PBHEUO2fgwTurLE0cJg9UcIo1x4lHfsp+59S9TBCHgTZkw==
  1598 +"@vitejs/plugin-vue@^1.1.5":
  1599 + version "1.1.5"
  1600 + resolved "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-1.1.5.tgz#fa1e8e5e049c35e213672e33f73fe81706ad5dbe"
  1601 + integrity sha512-4DV8VPYo8/OR1YsnK39QN16xhKENt2XvcmJxqfRtyz75kvbjBYh1zTSHLp7XsXqv4R2I+fOZlbEBvxosMYLcPA==
1602 1602  
1603 1603 "@vue/babel-helper-vue-transform-on@^1.0.2":
1604 1604 version "1.0.2"
... ... @@ -1703,25 +1703,25 @@
1703 1703 resolved "https://registry.npmjs.org/@vue/shared/-/shared-3.0.5.tgz#c131d88bd6713cc4d93b3bb1372edb1983225ff0"
1704 1704 integrity sha512-gYsNoGkWejBxNO6SNRjOh/xKeZ0H0V+TFzaPzODfBjkAIb0aQgBuixC1brandC/CDJy1wYPwSoYrXpvul7m6yw==
1705 1705  
1706   -"@vueuse/core@^4.2.2":
1707   - version "4.2.2"
1708   - resolved "https://registry.npmjs.org/@vueuse/core/-/core-4.2.2.tgz#ecbba4ba05e0360e9c9079b32e149fac803a1020"
1709   - integrity sha512-NMU3Vr4eBiNrPzCoUH5ptNj+DETg85Vtww0OJjaQEXobDTH28gzbLJseqCh4m3NYR92C5qlXRnzhSvWOoR/uLg==
  1706 +"@vueuse/core@^4.3.0":
  1707 + version "4.3.0"
  1708 + resolved "https://registry.npmjs.org/@vueuse/core/-/core-4.3.0.tgz#409d1c8fc0b7fffcf5b5388dfc487762bb936b0c"
  1709 + integrity sha512-PQ3r6wZDCN3pY+UBB5NLQdRfwiasd8MmWppuzpvNE2Sr8T48gmWXDWw3GG4EHMXnuz5EBfQG+U+1TjSaGaK6/w==
1710 1710 dependencies:
1711   - "@vueuse/shared" "4.2.2"
  1711 + "@vueuse/shared" "4.3.0"
1712 1712 vue-demi latest
1713 1713  
1714   -"@vueuse/shared@4.2.2":
1715   - version "4.2.2"
1716   - resolved "https://registry.npmjs.org/@vueuse/shared/-/shared-4.2.2.tgz#e52ee278b929f028117c0ca1792b24df462bff80"
1717   - integrity sha512-yudh4jt0SxaW0i3j2iumI8GTloA8aUpLwGaBw9Xv2rQCdZvOZpXpvpGEz8EsMK793ySs+d5S4/opItlxuzjtSg==
  1714 +"@vueuse/shared@4.3.0":
  1715 + version "4.3.0"
  1716 + resolved "https://registry.npmjs.org/@vueuse/shared/-/shared-4.3.0.tgz#82e05dc2941642814ac6fcbb5f9076c38c052968"
  1717 + integrity sha512-udc1ADIYwizTK/iSfjZQj6+QDFM099oHuX0Sj/yv0NgE9eSODcesV4zO7PtvmJanzw43hCdvtdGBz8miyRkHCQ==
1718 1718 dependencies:
1719 1719 vue-demi latest
1720 1720  
1721   -"@windicss/plugin-utils@0.5.3":
1722   - version "0.5.3"
1723   - resolved "https://registry.npmjs.org/@windicss/plugin-utils/-/plugin-utils-0.5.3.tgz#5302864cb2f94dd3d71bb5af958dab6ce3f74dab"
1724   - integrity sha512-BXNvMSRmi1TyM8j3EnF/li9HViJPN4EPeGKTiIDWemxrfkRNlgN+Gmv31CFtZwnjiAlXRO58B6LIqVTSVYaTfQ==
  1721 +"@windicss/plugin-utils@0.5.4":
  1722 + version "0.5.4"
  1723 + resolved "https://registry.npmjs.org/@windicss/plugin-utils/-/plugin-utils-0.5.4.tgz#69476a9d1fee92046695766bf7fbfe48e48809a7"
  1724 + integrity sha512-zxpHdTsVZl7TF8A3uAymJCqMRlG83dMRAXf//fXonluoLDSJCuGBJyxN3NdkAyNZZR1L1DvoUUtkZLYOba+ElQ==
1725 1725 dependencies:
1726 1726 esbuild "^0.8.52"
1727 1727 esbuild-register "^2.0.0"
... ... @@ -3601,11 +3601,6 @@ esbuild-register@^2.0.0:
3601 3601 source-map-support "^0.5.19"
3602 3602 strip-json-comments "^3.1.1"
3603 3603  
3604   -esbuild@^0.8.47:
3605   - version "0.8.51"
3606   - resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.8.51.tgz#1a59f1fee34892f143b7009081f9b4901a564b93"
3607   - integrity sha512-MVIom8fgL1+B6iGqWtrG7QJ1gqd64BycxounlsX1kR/IcIITaSlTo7gghKpg4a+bnxkpo0dwcikuvk4MVSA9ww==
3608   -
3609 3604 esbuild@^0.8.48:
3610 3605 version "0.8.48"
3611 3606 resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.8.48.tgz#a57e4dde84ec56da1c6ecaefee97e9da6c5b00b5"
... ... @@ -8973,20 +8968,20 @@ vite-plugin-theme@^0.4.8:
8973 8968 es-module-lexer "^0.3.26"
8974 8969 tinycolor2 "^1.4.2"
8975 8970  
8976   -vite-plugin-windicss@0.5.3:
8977   - version "0.5.3"
8978   - resolved "https://registry.npmjs.org/vite-plugin-windicss/-/vite-plugin-windicss-0.5.3.tgz#7929b5fbaed7f0530cbe79947e7bc9e4f471b683"
8979   - integrity sha512-hVfj0QjgxBch4j5M6BfMj9Dsm7iKioP9uQUvs00RGkuUdG+Gc0PQcT9SuLrcZJjUE/2Tp9+J44BEbOYxjesqlA==
  8971 +vite-plugin-windicss@0.5.4:
  8972 + version "0.5.4"
  8973 + resolved "https://registry.npmjs.org/vite-plugin-windicss/-/vite-plugin-windicss-0.5.4.tgz#35764e91536d596ac2c9266c3e16c546915d8b3e"
  8974 + integrity sha512-iPLoqfpZdnRIY1AzweumpdE8ILQQnyhywZwJDqFpj8SZ3h43e5tfQFnJb5nS6FLccOsBcCV9JFugD2w6pGyfqg==
8980 8975 dependencies:
8981   - "@windicss/plugin-utils" "0.5.3"
  8976 + "@windicss/plugin-utils" "0.5.4"
8982 8977 windicss "^2.2.0"
8983 8978  
8984   -vite@2.0.3:
8985   - version "2.0.3"
8986   - resolved "https://registry.npmjs.org/vite/-/vite-2.0.3.tgz#ea0329295d4da9341e670036e5e7f0bfa30ae2cf"
8987   - integrity sha512-4CUm3FVUHyTSSSK6vHWkj3SVkP+GGNNzwYcFsHOjjc8xQ3BPjJa1JDDmFlYxpxR29ANa+7RWptYPoyHyJ29Nhw==
  8979 +vite@2.0.4:
  8980 + version "2.0.4"
  8981 + resolved "https://registry.npmjs.org/vite/-/vite-2.0.4.tgz#063532a4139b59a067297d8ebb5960d450907a09"
  8982 + integrity sha512-+PP89D7AKXFE4gps8c5+4eP5yXTh5qCogjdYX7iSsIxbLZAa26JoGSq6OLk0qdb/fqDh7gtJqGiLbG2V6NvkKQ==
8988 8983 dependencies:
8989   - esbuild "^0.8.47"
  8984 + esbuild "^0.8.52"
8990 8985 postcss "^8.2.1"
8991 8986 resolve "^1.19.0"
8992 8987 rollup "^2.38.5"
... ... @@ -9010,13 +9005,13 @@ vue-eslint-parser@^7.5.0:
9010 9005 esquery "^1.4.0"
9011 9006 lodash "^4.17.15"
9012 9007  
9013   -vue-i18n@9.0.0-rc.8:
9014   - version "9.0.0-rc.8"
9015   - resolved "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.0.0-rc.8.tgz#36d022516cf2527ce02eecf9de116b978e163da3"
9016   - integrity sha512-WQC9q0UG1lbk+naBBoVTrJjHPZfHP6Pid35Ek9AkCxUcXolW1pXUCQg1gIMF8I0obxLd/fSx9GuOWrB/aaU3aQ==
  9008 +vue-i18n@^9.0.0:
  9009 + version "9.0.0"
  9010 + resolved "https://registry.npmjs.org/vue-i18n/-/vue-i18n-9.0.0.tgz#a04c41d5ed3d5a068e923517bfaa0abcbc84e174"
  9011 + integrity sha512-iks0eJDv/4cK/7tl/ooMUroNVVIGOK4kKS1PIHmPQk7QjT/sDfFM84vjPKgpARbw0GjJsOiADL43jufNfs9e9A==
9017 9012 dependencies:
9018   - "@intlify/core-base" "9.0.0-rc.8"
9019   - "@intlify/shared" "9.0.0-rc.8"
  9013 + "@intlify/core-base" "9.0.0"
  9014 + "@intlify/shared" "9.0.0"
9020 9015 "@vue/devtools-api" "^6.0.0-beta.5"
9021 9016  
9022 9017 vue-router@^4.0.4:
... ...