From 733a0b47469b2cee0511d6c7ba16c2456f74c3e4 Mon Sep 17 00:00:00 2001 From: zhengzhou Date: Tue, 2 Mar 2021 14:47:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20=E9=80=80=E7=99=BB?= =?UTF-8?q?=E5=90=8E=20=E5=85=A8=E5=B1=80=E6=95=B0=E6=8D=AE=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E5=AE=9E=E6=97=B6=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/index.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 40101de7..108648e7 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -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(); },