fix: 修复OIDC登陆的问题

This commit is contained in:
Captain.B 2021-09-13 16:02:38 +08:00 committed by 刘瑞斌
parent 3e3014c7ff
commit 25c2e08209
1 changed files with 19 additions and 9 deletions

View File

@ -38,6 +38,7 @@ import {registerRequestHeaders} from "@/common/js/ajax";
import {ORIGIN_COLOR} from "@/common/js/constants";
import MsTaskCenter from "@/business/components/task/TaskCenter";
import MsNotification from "@/business/components/notice/Notification";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const header = requireComponent.keys().length > 0 ? requireComponent("./license/LicenseMessage.vue") : {};
const display = requireComponent.keys().length > 0 ? requireComponent("./display/Display.vue") : {};
@ -60,7 +61,6 @@ export default {
};
},
created() {
registerRequestHeaders();
this.initSessionTimer();
if (!hasLicense()) {
setDefaultTheme();
@ -73,14 +73,12 @@ export default {
this.$store.commit('setTheme', res.data);
});
}
if (localStorage.getItem("store")) {
this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(localStorage.getItem("store"))));
this.$get("/project/listAll", response => {
let projectIds = response.data;
if (projectIds && projectIds.length <= 0) {
this.$store.commit('setProjectId', undefined);
}
});
// OIDC redirect
if (window.location.href.endsWith('/#/') || window.location.href.endsWith('/#')) {
window.location.replace("/#/setting/personsetting");
setTimeout(() => {
window.location.reload();
}, 500);
}
window.addEventListener("beforeunload", () => {
localStorage.setItem("store", JSON.stringify(this.$store.state));
@ -91,6 +89,7 @@ export default {
if (response.data.success) {
this.$setLang(response.data.data.language);
saveLocalStorage(response.data);
registerRequestHeaders();
this.auth = true;
//
if (header.default !== undefined) {
@ -100,6 +99,17 @@ export default {
if (display.default !== undefined) {
display.default.showHome(this);
}
//
if (localStorage.getItem("store")) {
this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(localStorage.getItem("store"))));
this.$get("/project/listAll", response => {
let projectIds = response.data;
if (projectIds && projectIds.length <= 0) {
this.$store.commit('setProjectId', undefined);
}
});
}
} else {
window.location.href = "/login";
}