diff --git a/src/layout/components/NavHeader/AccountDropdown.vue b/src/layout/components/NavHeader/AccountDropdown.vue index 9f924d714..bbe3fb256 100644 --- a/src/layout/components/NavHeader/AccountDropdown.vue +++ b/src/layout/components/NavHeader/AccountDropdown.vue @@ -71,7 +71,7 @@ export default { }, async logout() { const currentOrg = this.$store.getters.currentOrg - if (currentOrg.autoEnter) { + if (currentOrg.autoEnter || currentOrg.is_system) { await this.$store.dispatch('users/setCurrentOrg', this.$store.getters.preOrg) } window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${this.$route.fullPath}` diff --git a/src/store/modules/users.js b/src/store/modules/users.js index e97edad74..33a60b1b5 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -71,10 +71,11 @@ const mutations = { state.consoleOrgs = state.consoleOrgs.filter(i => i.id !== org.id) }, SET_CURRENT_ORG(state, org) { - // 系统组织和全局组织不设置成 Pre org - if (!state.currentOrg?.autoEnter) { - state.preOrg = state.currentOrg - setPreOrgLocal(state.username, state.currentOrg) + // 系统组织不设置成 Pre org + const currentOrg = state.currentOrg + if (!currentOrg?.autoEnter && !currentOrg.is_system) { + state.preOrg = currentOrg + setPreOrgLocal(state.username, currentOrg) } state.currentOrg = org saveCurrentOrgLocal(state.username, org) @@ -144,6 +145,7 @@ const actions = { const systemOrg = { id: orgUtil.SYSTEM_ORG_ID, name: 'SystemSetting', + is_system: true, autoEnter: new Date().getTime() } commit('SET_CURRENT_ORG', systemOrg) diff --git a/src/utils/org.js b/src/utils/org.js index dff2932e7..8c8766ffb 100644 --- a/src/utils/org.js +++ b/src/utils/org.js @@ -17,7 +17,7 @@ function getPropOrg() { if (defaultOrg) { return defaultOrg } - return orgs.filter(item => !item['is_root'] && item.id !== SYSTEM_ORG_ID)[0] + return orgs.filter(item => !item['is_root'] && !item['is_system'])[0] } async function change2PropOrg() { diff --git a/src/utils/startup.js b/src/utils/startup.js index a5e368a02..70971cdc6 100644 --- a/src/utils/startup.js +++ b/src/utils/startup.js @@ -8,7 +8,10 @@ import orgs from '@/api/orgs' import { getPropView, isViewHasOrgs } from '@/utils/jms' const whiteList = ['/login', process.env.VUE_APP_LOGIN_PATH] // no redirect whitelist -const autoEnterOrgs = ['00000000-0000-0000-0000-000000000001', '00000000-0000-0000-0000-000000000000'] +const autoEnterOrgs = [ + '00000000-0000-0000-0000-000000000001', + '00000000-0000-0000-0000-000000000000' +] function reject(msg) { return new Promise((resolve, reject) => reject(msg))