mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 14:47:28 +08:00
chore: miscellaneous modifications
This commit is contained in:
@@ -7,8 +7,8 @@ const ls = createStorage(localStorage);
|
||||
const ss = createStorage();
|
||||
|
||||
interface CacheStore {
|
||||
local?: any;
|
||||
session?: any;
|
||||
local: Record<string, any>;
|
||||
session: Record<string, any>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,14 +25,14 @@ function initCache() {
|
||||
cacheStore.local = ls.get(BASE_LOCAL_CACHE_KEY) || {};
|
||||
cacheStore.session = ss.get(BASE_SESSION_CACHE_KEY) || {};
|
||||
}
|
||||
|
||||
initCache();
|
||||
|
||||
export function setLocal(key: string, value: any, immediate = false) {
|
||||
cacheStore.local[BASE_LOCAL_CACHE_KEY] = cacheStore.local[BASE_LOCAL_CACHE_KEY] || {};
|
||||
cacheStore.local[BASE_LOCAL_CACHE_KEY][key] = value;
|
||||
if (immediate) {
|
||||
const localCache = cacheStore.local;
|
||||
ls.set(BASE_LOCAL_CACHE_KEY, localCache);
|
||||
ls.set(BASE_LOCAL_CACHE_KEY, cacheStore.local);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ export function getLocal<T>(key: string): T | null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function removeLocal(key: string) {
|
||||
if (cacheStore.local[BASE_LOCAL_CACHE_KEY]) {
|
||||
Reflect.deleteProperty(cacheStore.local[BASE_LOCAL_CACHE_KEY], key);
|
||||
@@ -91,8 +92,6 @@ export function clearAll() {
|
||||
const localCache = cacheStore.local;
|
||||
const sessionCache = cacheStore.session;
|
||||
|
||||
// const ss = createStorage();
|
||||
|
||||
ls.set(BASE_LOCAL_CACHE_KEY, localCache);
|
||||
ss.set(BASE_SESSION_CACHE_KEY, sessionCache);
|
||||
});
|
||||
@@ -114,6 +113,7 @@ export function clearAll() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isIeFn() && (document as any).attachEvent) {
|
||||
(document as any).attachEvent('onstorage', storageChange);
|
||||
} else {
|
||||
|
@@ -158,6 +158,7 @@ export function forEach<T = any>(
|
||||
export function treeMap(treeData: any[], opt: { children?: string; conversion: Fn }) {
|
||||
return treeData.map((item) => treeMapEach(item, opt));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 提取tree指定结构
|
||||
*/
|
||||
|
Reference in New Issue
Block a user