|
@@ -16,6 +16,7 @@ import {
|
|
|
} from '/@/enums/cacheEnum';
|
|
|
import { DEFAULT_CACHE_TIME } from '/@/settings/encryptionSetting';
|
|
|
import { toRaw } from 'vue';
|
|
|
+import { pick } from 'lodash-es';
|
|
|
|
|
|
interface BasicStore {
|
|
|
[TOKEN_KEY]: string | number | null | undefined;
|
|
@@ -96,8 +97,15 @@ export class Persistent {
|
|
|
}
|
|
|
|
|
|
window.addEventListener('beforeunload', function () {
|
|
|
- ls.set(APP_LOCAL_CACHE_KEY, localMemory.getCache);
|
|
|
- ss.set(APP_SESSION_CACHE_KEY, sessionMemory.getCache);
|
|
|
+ // TOKEN_KEY 在登录或注销时已经写入到storage了,此处为了解决同时打开多个窗口时token不同步的问题
|
|
|
+ ls.set(APP_LOCAL_CACHE_KEY, {
|
|
|
+ ...localMemory.getCache,
|
|
|
+ ...pick(ls.get(APP_LOCAL_CACHE_KEY), [TOKEN_KEY, USER_INFO_KEY]),
|
|
|
+ });
|
|
|
+ ss.set(APP_SESSION_CACHE_KEY, {
|
|
|
+ ...sessionMemory.getCache,
|
|
|
+ ...pick(sessionMemory.getCache, [TOKEN_KEY, USER_INFO_KEY]),
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
function storageChange(e: any) {
|