mirror of
https://github.com/vbenjs/gf-vben-admin.git
synced 2025-02-03 03:32:59 +08:00
fix(lock-screen): ensure lock info is saved
确保打开多个窗口锁屏时,其它窗口不会误覆盖锁屏状态
This commit is contained in:
parent
e5f37885ff
commit
d38ff6670a
11
src/utils/cache/persistent.ts
vendored
11
src/utils/cache/persistent.ts
vendored
@ -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]),
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user