refactor(通用功能): 调整跳转时参数值的设置

This commit is contained in:
guoyuqi 2024-04-01 20:06:51 +08:00 committed by Craftsman
parent 3518c37ffb
commit fe852441a1
1 changed files with 12 additions and 2 deletions

View File

@ -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