From 6b93a6563daa07d3a99f6421051a773c92272c34 Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 23 Aug 2024 11:36:17 +0800 Subject: [PATCH] perf: revert pre org if logout --- src/layout/components/NavHeader/AccountDropdown.vue | 8 ++++++-- src/utils/startup.js | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/layout/components/NavHeader/AccountDropdown.vue b/src/layout/components/NavHeader/AccountDropdown.vue index 61be74e33..b897031db 100644 --- a/src/layout/components/NavHeader/AccountDropdown.vue +++ b/src/layout/components/NavHeader/AccountDropdown.vue @@ -61,7 +61,6 @@ export default { break case 'logout': this.logout() - window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${this.$route.fullPath}` break case 'apiKey': this.$router.push('/profile/api-keys') @@ -73,7 +72,12 @@ export default { this.$router.push('/profile/user/setting') } }, - logout() { + async logout() { + const currentOrg = this.$store.getters.currentOrg + if (currentOrg.autoEnter) { + 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/utils/startup.js b/src/utils/startup.js index 9806ddedc..8af450bde 100644 --- a/src/utils/startup.js +++ b/src/utils/startup.js @@ -24,6 +24,9 @@ async function checkLogin({ to, from, next }) { } catch (e) { Vue.$log.error(e) const status = e.response.status + if (store.getters.currentOrg.autoEnter) { + await store.dispatch('users/setCurrentOrg', store.getters.preOrg) + } if (status === 401 || status === 403) { setTimeout(() => { window.location = process.env.VUE_APP_LOGIN_PATH