Pārlūkot izejas kodu

修正 退登后 全局数据不会实时更新的问题

dev
zhengzhou pirms 4 gadiem
vecāks
revīzija
733a0b4746
1 mainītis faili ar 11 papildinājumiem un 8 dzēšanām
  1. +11
    -8
      src/store/index.js

+ 11
- 8
src/store/index.js Parādīt failu

@@ -3,9 +3,14 @@ import { platform, PLATFORM_TYPE, AccessCode } from '@/utils/access';
import { firstCharToLowerCase } from '@/utils/tool';
import system from '@/services/system';

const initialState = () => ({
isLogin: false,
const systemInitState = () => ({
gatewayState: false,
isMaxWindowSize: false,
client: system.isClient ? '桌面端' : 'WEB端',
});

const loginInitState = () => ({
isLogin: false,
accountId: undefined,
accountName: undefined,
userName: undefined,
@@ -14,12 +19,10 @@ const initialState = () => ({
currentCompanyId: undefined,
avator: undefined,
userInfo: {},
isMaxWindowSize: false,
client: system.isClient ? '桌面端' : 'WEB端',
});
})

const getBootstrapState = () => {
let state = initialState();
let state = Object.assign(systemInitState(), loginInitState());
try {
const sessionState = JSON.parse(sessionStorage.getItem('user'));
const currentCompanyId = sessionStorage.getItem('companyId');
@@ -33,7 +36,7 @@ const getBootstrapState = () => {
}
} catch (e) {
console.log('加载session数据失败');
state = initialState();
state = Object.assign(systemInitState(), loginInitState());
}
return state;
};
@@ -153,7 +156,7 @@ export default {
Source: sessionStorage.client,
};
fetchApi('operation/record', params);
this.state = initialState();
this.state = Object.assign(this.state, loginInitState());
fetchApi('authentication/loginOut');
sessionStorage.clear();
},


Notiek ielāde…
Atcelt
Saglabāt