diff --git a/src/utils/cache/persistent.ts b/src/utils/cache/persistent.ts index 65f7c805..cd68a366 100644 --- a/src/utils/cache/persistent.ts +++ b/src/utils/cache/persistent.ts @@ -16,7 +16,7 @@ import { } from '/@/enums/cacheEnum'; import { DEFAULT_CACHE_TIME } from '/@/settings/encryptionSetting'; import { toRaw } from 'vue'; -import { pick } from 'lodash-es'; +import { pick, omit } from 'lodash-es'; interface BasicStore { [TOKEN_KEY]: string | number | null | undefined; @@ -98,13 +98,14 @@ export class Persistent { window.addEventListener('beforeunload', function () { // TOKEN_KEY 在登录或注销时已经写入到storage了,此处为了解决同时打开多个窗口时token不同步的问题 + // LOCK_INFO_KEY 在锁屏和解锁时写入,此处也不应修改 ls.set(APP_LOCAL_CACHE_KEY, { - ...localMemory.getCache, - ...pick(ls.get(APP_LOCAL_CACHE_KEY), [TOKEN_KEY, USER_INFO_KEY]), + ...omit(localMemory.getCache, LOCK_INFO_KEY), + ...pick(ls.get(APP_LOCAL_CACHE_KEY), [TOKEN_KEY, USER_INFO_KEY, LOCK_INFO_KEY]), }); ss.set(APP_SESSION_CACHE_KEY, { - ...sessionMemory.getCache, - ...pick(sessionMemory.getCache, [TOKEN_KEY, USER_INFO_KEY]), + ...omit(sessionMemory.getCache, LOCK_INFO_KEY), + ...pick(ss.get(APP_SESSION_CACHE_KEY), [TOKEN_KEY, USER_INFO_KEY, LOCK_INFO_KEY]), }); });