From fedd9caefbffd8689c94ca5c6a3a6c7bd90de197 Mon Sep 17 00:00:00 2001 From: Vben Date: Tue, 23 Mar 2021 00:21:09 +0800 Subject: [PATCH] wip: cache miss --- src/main.ts | 5 ++++- src/settings/projectSetting.ts | 2 +- src/utils/auth/index.ts | 2 +- src/utils/cache/memory.ts | 2 +- src/utils/cache/persistent.ts | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 51bfb9c2c..5284ccad0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -32,6 +32,9 @@ import { isDevMode } from '/@/utils/env'; // Register global components registerGlobComp(app); + // Multilingual configuration + await setupI18n(app); + // Configure routing setupRouter(app); @@ -45,7 +48,7 @@ import { isDevMode } from '/@/utils/env'; setupErrorHandle(app); // Mount when the route is ready - await Promise.all([setupI18n(app), router.isReady()]); + await router.isReady(); app.mount('#app', true); diff --git a/src/settings/projectSetting.ts b/src/settings/projectSetting.ts index 11287dada..eca9e05fa 100644 --- a/src/settings/projectSetting.ts +++ b/src/settings/projectSetting.ts @@ -23,7 +23,7 @@ const setting: ProjectConfig = { permissionMode: PermissionModeEnum.ROLE, // Permission-related cache is stored in sessionStorage or localStorage - permissionCacheType: CacheTypeEnum.SESSION, + permissionCacheType: CacheTypeEnum.LOCAL, // color themeColor: primaryColor, diff --git a/src/utils/auth/index.ts b/src/utils/auth/index.ts index 078ed3faf..b8612d3fb 100644 --- a/src/utils/auth/index.ts +++ b/src/utils/auth/index.ts @@ -17,5 +17,5 @@ export function getAuthCache(key: BasicKeys) { export function setAuthCache(key: BasicKeys, value) { const fn = isLocal ? Persistent.setLocal : Persistent.setSession; - return fn(key, value); + return fn(key, value, true); } diff --git a/src/utils/cache/memory.ts b/src/utils/cache/memory.ts index eb7cf0641..d373dcfbb 100644 --- a/src/utils/cache/memory.ts +++ b/src/utils/cache/memory.ts @@ -59,7 +59,7 @@ export class Memory { } item.time = new Date().getTime() + this.alive; item.timeoutId = setTimeout(() => { - this.remove(key); + // this.remove(key); }, expires); return value; diff --git a/src/utils/cache/persistent.ts b/src/utils/cache/persistent.ts index 2c6036915..ced28f76e 100644 --- a/src/utils/cache/persistent.ts +++ b/src/utils/cache/persistent.ts @@ -69,7 +69,7 @@ export class Persistent { static setSession(key: SessionKeys, value: SessionStore[SessionKeys], immediate = false): void { sessionMemory.set(key, toRaw(value)); - immediate && ss.set(APP_SESSION_CACHE_KEY, sessionMemory); + immediate && ss.set(APP_SESSION_CACHE_KEY, sessionMemory.getCache); } static removeSession(key: SessionKeys): void {