From 56a310c6674873837689c13e15c99c1bb62fc688 Mon Sep 17 00:00:00 2001 From: LH_R Date: Fri, 15 Aug 2025 16:09:41 +0800 Subject: [PATCH] feat(ui): record the page path when logout --- cmdb-ui/src/store/global/user.js | 11 ++++++++++- cmdb-ui/src/views/user/Logout.vue | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cmdb-ui/src/store/global/user.js b/cmdb-ui/src/store/global/user.js index 914682b..0285660 100644 --- a/cmdb-ui/src/store/global/user.js +++ b/cmdb-ui/src/store/global/user.js @@ -184,7 +184,16 @@ const user = { }).catch(() => { resolve() }).finally(() => { - window.location.href = '/user/logout' + let logoutURL = '/user/logout' + const fullPath = window.location.pathname + window.location.search + if ( + fullPath && + fullPath !== '/' + ) { + logoutURL += `?redirect=${fullPath}` + } + + window.location.href = logoutURL }) }) }, diff --git a/cmdb-ui/src/views/user/Logout.vue b/cmdb-ui/src/views/user/Logout.vue index 2fff238..d2a75cb 100644 --- a/cmdb-ui/src/views/user/Logout.vue +++ b/cmdb-ui/src/views/user/Logout.vue @@ -64,7 +64,13 @@ export default { await this.GetAuthDataEnable() this.loading = false if (!this._enable_list.length || this._enable_list.length > 1) { - this.$router.push('/user/login') + let loginURL = '/user/login' + const redirect = this.$route?.query?.redirect + if (redirect) { + loginURL += `?redirect=${redirect}` + } + + this.$router.push(loginURL) } if (this.auth_auto_redirect) { this.time = 0