fix: 修复创建项目后进入新项目页面跳回到系统设置的问题

This commit is contained in:
CaptainB 2022-10-20 16:44:46 +08:00
parent 8e881a8f49
commit 79edd18fa0
5 changed files with 28 additions and 12 deletions

View File

@ -2,7 +2,6 @@ package io.metersphere.gateway.controller;
import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule; import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.SessionConstants;
import io.metersphere.commons.utils.CodingUtil; import io.metersphere.commons.utils.CodingUtil;
import io.metersphere.gateway.service.SSOService; import io.metersphere.gateway.service.SSOService;
import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.log.annotation.MsAuditLog;
@ -49,15 +48,19 @@ public class SSOController {
* oidc 登出 callback * oidc 登出 callback
*/ */
@PostMapping("/callback/logout") @PostMapping("/callback/logout")
public void logoutCallback(@RequestParam("logout_token") String logoutToken) { public Rendering logoutCallback(@RequestParam("logout_token") String logoutToken) {
ssoService.kickOutUser(logoutToken); ssoService.kickOutUser(logoutToken);
return Rendering.redirectTo("/#/login")
.build();
} }
/** /**
* cas 登出 callback * cas 登出 callback
*/ */
@PostMapping("/callback/cas/logout") @PostMapping("/callback/cas/logout")
public void logoutCasCallback(@RequestParam("logoutRequest") String logoutRequest) { public Rendering logoutCasCallback(@RequestParam("logoutRequest") String logoutRequest) {
ssoService.kickOutCasUser(logoutRequest); ssoService.kickOutCasUser(logoutRequest);
return Rendering.redirectTo("/#/login")
.build();
} }
} }

View File

@ -49,7 +49,7 @@ import MsView from "../../components/layout/View";
import MxLicenseMessage from "../../components/MxLicenseMessage"; import MxLicenseMessage from "../../components/MxLicenseMessage";
import MxTheme from "../../components/MxTheme"; import MxTheme from "../../components/MxTheme";
import {hasLicense} from "../../utils/permission"; 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 {ORIGIN_COLOR} from "../../utils/constants";
import {getDisplayInfo, getSystemTheme, isLogin} from "../../api/user"; import {getDisplayInfo, getSystemTheme, isLogin} from "../../api/user";
import {useUserStore} from "@/store"; import {useUserStore} from "@/store";
@ -101,11 +101,12 @@ export default {
this.isCollapse = this.isFixed === true ? false : true; this.isCollapse = this.isFixed === true ? false : true;
}, },
beforeCreate() { beforeCreate() {
const userStore = useUserStore() if (checkMicroMode()) {
return;
}
const userStore = useUserStore();
userStore.getIsLogin() userStore.getIsLogin()
.then(response => { .then(response => {
this.$setLang(response.data.language);
if (window.location.href.endsWith('/#/login')) { if (window.location.href.endsWith('/#/login')) {
window.location.replace("/#/setting/personsetting"); window.location.replace("/#/setting/personsetting");
} }

View File

@ -70,8 +70,11 @@ router.beforeEach(async (to, from, next) => {
if (to.path.split('/')[1] !== from.path.split('/')[1]) { if (to.path.split('/')[1] !== from.path.split('/')[1]) {
try { try {
user = await store.getIsLogin(); user = await store.getIsLogin();
if (window.location.href.endsWith('/#/login')) {
window.location.replace("/#/setting/personsetting");
}
} catch (e) { } catch (e) {
// console.error(e); // console.error(e)
} }
} }
if (user && user.id) { if (user && user.id) {

View File

@ -79,6 +79,7 @@ export default {
isLogin() isLogin()
.then((res) => { .then((res) => {
this.$patch(res.data) this.$patch(res.data)
setLanguage(res.data.language)
saveSessionStorage(res) saveSessionStorage(res)
resolve(res) resolve(res)
}) })

View File

@ -207,6 +207,9 @@ import {getProjectMemberGroup, getUserGroupList} from "../../../api/user-group";
import {operationConfirm} from "metersphere-frontend/src/utils"; import {operationConfirm} from "metersphere-frontend/src/utils";
import EditProject from "./EditProject"; import EditProject from "./EditProject";
import ApiEnvironmentConfig from "metersphere-frontend/src/components/environment/ApiEnvironmentConfig"; 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 { export default {
name: "MsProject", name: "MsProject",
@ -309,10 +312,15 @@ export default {
this.$warning(this.$t("commons.project_permission")); this.$warning(this.$t("commons.project_permission"));
return; return;
} }
window.sessionStorage.setItem(PROJECT_ID, row.id); // last_project_id
this.$router.push('/track/home').then(() => { sessionStorage.setItem(PROJECT_ID, row.id);
this.reloadTopMenus(); const loading = fullScreenLoading(this);
}); switchProject({id: getCurrentUserId(), lastProjectId: row.id}).then(() => {
this.$router.push('/track/home').then(() => {
location.reload();
stopFullScreenLoading(loading);
});
})
}); });
}, },
getMaintainerOptions() { getMaintainerOptions() {