diff --git a/framework/gateway/src/main/java/io/metersphere/gateway/controller/SSOController.java b/framework/gateway/src/main/java/io/metersphere/gateway/controller/SSOController.java index 69fb386566..cb8738deec 100644 --- a/framework/gateway/src/main/java/io/metersphere/gateway/controller/SSOController.java +++ b/framework/gateway/src/main/java/io/metersphere/gateway/controller/SSOController.java @@ -2,7 +2,6 @@ package io.metersphere.gateway.controller; import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogModule; -import io.metersphere.commons.constants.SessionConstants; import io.metersphere.commons.utils.CodingUtil; import io.metersphere.gateway.service.SSOService; import io.metersphere.log.annotation.MsAuditLog; @@ -49,15 +48,19 @@ public class SSOController { * oidc 登出 callback */ @PostMapping("/callback/logout") - public void logoutCallback(@RequestParam("logout_token") String logoutToken) { + public Rendering logoutCallback(@RequestParam("logout_token") String logoutToken) { ssoService.kickOutUser(logoutToken); + return Rendering.redirectTo("/#/login") + .build(); } /** * cas 登出 callback */ @PostMapping("/callback/cas/logout") - public void logoutCasCallback(@RequestParam("logoutRequest") String logoutRequest) { + public Rendering logoutCasCallback(@RequestParam("logoutRequest") String logoutRequest) { ssoService.kickOutCasUser(logoutRequest); + return Rendering.redirectTo("/#/login") + .build(); } } diff --git a/framework/sdk-parent/frontend/src/business/app-layout/index.vue b/framework/sdk-parent/frontend/src/business/app-layout/index.vue index 03b4b61b3c..4ec1cff6a8 100644 --- a/framework/sdk-parent/frontend/src/business/app-layout/index.vue +++ b/framework/sdk-parent/frontend/src/business/app-layout/index.vue @@ -49,7 +49,7 @@ import MsView from "../../components/layout/View"; import MxLicenseMessage from "../../components/MxLicenseMessage"; import MxTheme from "../../components/MxTheme"; import {hasLicense} from "../../utils/permission"; -import {setAsideColor, setColor, setCustomizeColor, setDefaultTheme, setLightColor} from "../../utils"; +import {checkMicroMode, setAsideColor, setColor, setCustomizeColor, setDefaultTheme, setLightColor} from "../../utils"; import {ORIGIN_COLOR} from "../../utils/constants"; import {getDisplayInfo, getSystemTheme, isLogin} from "../../api/user"; import {useUserStore} from "@/store"; @@ -101,11 +101,12 @@ export default { this.isCollapse = this.isFixed === true ? false : true; }, beforeCreate() { - const userStore = useUserStore() + if (checkMicroMode()) { + return; + } + const userStore = useUserStore(); userStore.getIsLogin() .then(response => { - this.$setLang(response.data.language); - if (window.location.href.endsWith('/#/login')) { window.location.replace("/#/setting/personsetting"); } diff --git a/framework/sdk-parent/frontend/src/router/index.js b/framework/sdk-parent/frontend/src/router/index.js index 71c1de66ec..718666e9af 100644 --- a/framework/sdk-parent/frontend/src/router/index.js +++ b/framework/sdk-parent/frontend/src/router/index.js @@ -70,8 +70,11 @@ router.beforeEach(async (to, from, next) => { if (to.path.split('/')[1] !== from.path.split('/')[1]) { try { user = await store.getIsLogin(); + if (window.location.href.endsWith('/#/login')) { + window.location.replace("/#/setting/personsetting"); + } } catch (e) { - // console.error(e); + // console.error(e) } } if (user && user.id) { diff --git a/framework/sdk-parent/frontend/src/store/modules/user.js b/framework/sdk-parent/frontend/src/store/modules/user.js index a41b0d9ad6..700b2e97cb 100644 --- a/framework/sdk-parent/frontend/src/store/modules/user.js +++ b/framework/sdk-parent/frontend/src/store/modules/user.js @@ -79,6 +79,7 @@ export default { isLogin() .then((res) => { this.$patch(res.data) + setLanguage(res.data.language) saveSessionStorage(res) resolve(res) }) diff --git a/system-setting/frontend/src/business/workspace/project/MsProject.vue b/system-setting/frontend/src/business/workspace/project/MsProject.vue index c408dc5f7c..394da54c03 100644 --- a/system-setting/frontend/src/business/workspace/project/MsProject.vue +++ b/system-setting/frontend/src/business/workspace/project/MsProject.vue @@ -207,6 +207,9 @@ import {getProjectMemberGroup, getUserGroupList} from "../../../api/user-group"; import {operationConfirm} from "metersphere-frontend/src/utils"; import EditProject from "./EditProject"; import ApiEnvironmentConfig from "metersphere-frontend/src/components/environment/ApiEnvironmentConfig"; +import {switchProject} from "metersphere-frontend/src/api/project"; +import {fullScreenLoading, stopFullScreenLoading} from "metersphere-frontend/src/utils"; + export default { name: "MsProject", @@ -309,10 +312,15 @@ export default { this.$warning(this.$t("commons.project_permission")); return; } - window.sessionStorage.setItem(PROJECT_ID, row.id); - this.$router.push('/track/home').then(() => { - this.reloadTopMenus(); - }); + // 跳转的时候更新用户的last_project_id + sessionStorage.setItem(PROJECT_ID, row.id); + const loading = fullScreenLoading(this); + switchProject({id: getCurrentUserId(), lastProjectId: row.id}).then(() => { + this.$router.push('/track/home').then(() => { + location.reload(); + stopFullScreenLoading(loading); + }); + }) }); }, getMaintainerOptions() {