From fe852441a14a8ec9742ab47b7757db426b33a209 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Mon, 1 Apr 2024 20:06:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=80=9A=E7=94=A8=E5=8A=9F=E8=83=BD):?= =?UTF-8?q?=20=E8=B0=83=E6=95=B4=E8=B7=B3=E8=BD=AC=E6=97=B6=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=80=BC=E7=9A=84=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/store/modules/user/index.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/store/modules/user/index.ts b/frontend/src/store/modules/user/index.ts index 4fe90f85fd..05c60030e7 100644 --- a/frontend/src/store/modules/user/index.ts +++ b/frontend/src/store/modules/user/index.ts @@ -155,8 +155,18 @@ const useUserStore = defineStore('user', { setToken(res.sessionId, res.csrfToken); this.setInfo(res); const { orgId, pId } = getHashParameters(); - appStore.setCurrentOrgId(forceSet ? res.lastOrganizationId || '' : orgId || ''); - appStore.setCurrentProjectId(forceSet ? res.lastProjectId || '' : pId || ''); + // 1. forceSet是强制设置,需要设置res的,2.非force且地址栏有,则也设置 3.地址栏参数为空就不设置 + // 如果访问页面的时候携带了组织 ID和项目 ID,则不设置 + if (!forceSet && orgId) { + appStore.setCurrentOrgId(orgId); + } + if (!forceSet && pId) { + appStore.setCurrentProjectId(pId); + } + if (forceSet) { + appStore.setCurrentOrgId(res.lastOrganizationId || ''); + appStore.setCurrentProjectId(res.lastProjectId || ''); + } return true; } catch (err) { // eslint-disable-next-line no-console