refactor: CAS登录方式变更
This commit is contained in:
parent
4a4856663d
commit
5811079fd5
|
@ -45,7 +45,15 @@ import MsAsideMenus from "./components/layout/AsideMenus";
|
|||
import MsAsideHeader from "./components/layout/AsideHeader";
|
||||
import MsAsideFooter from "./components/layout/AsideFooter";
|
||||
import MsView from "./components/common/router/View";
|
||||
import {hasLicense, saveLocalStorage, setAsideColor, setColor, setCustomizeColor, setDefaultTheme, setLightColor} from "@/common/js/utils";
|
||||
import {
|
||||
hasLicense,
|
||||
saveLocalStorage,
|
||||
setAsideColor,
|
||||
setColor,
|
||||
setCustomizeColor,
|
||||
setDefaultTheme,
|
||||
setLightColor
|
||||
} from "@/common/js/utils";
|
||||
import {registerRequestHeaders} from "@/common/js/ajax";
|
||||
import {ORIGIN_COLOR} from "@/common/js/constants";
|
||||
|
||||
|
@ -96,13 +104,7 @@ export default {
|
|||
});
|
||||
this.getDisplayInfo();
|
||||
}
|
||||
// OIDC redirect 之后不跳转
|
||||
if (window.location.href.endsWith('#/refresh')) {
|
||||
window.location.replace("/#/setting/personsetting");
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 200);
|
||||
}
|
||||
|
||||
window.addEventListener("beforeunload", () => {
|
||||
localStorage.setItem("store", JSON.stringify(this.$store.state));
|
||||
});
|
||||
|
@ -124,6 +126,11 @@ export default {
|
|||
if (display.default !== undefined) {
|
||||
display.default.showHome(this);
|
||||
}
|
||||
|
||||
if (window.location.href.endsWith('/#/login')) {
|
||||
window.location.replace("/#/setting/personsetting");
|
||||
}
|
||||
|
||||
if (localStorage.getItem("store")) {
|
||||
this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(localStorage.getItem("store"))));
|
||||
this.$get("/project/listAll", response => {
|
||||
|
@ -158,7 +165,7 @@ export default {
|
|||
this.sideTheme = response.data[7].paramValue;
|
||||
}
|
||||
this.setAsideTheme(theme);
|
||||
})
|
||||
});
|
||||
},
|
||||
setAsideTheme(theme) {
|
||||
switch (this.sideTheme) {
|
||||
|
|
|
@ -7,13 +7,13 @@ import Performance from "@/business/components/performance/router";
|
|||
import Track from "@/business/components/track/router";
|
||||
import ReportStatistics from "@/business/components/reportstatistics/router";
|
||||
import Project from "@/business/components/project/router";
|
||||
import {getCurrentUserId, hasPermissions} from "@/common/js/utils";
|
||||
import {getCurrentUser, getCurrentUserId, hasPermissions} from "@/common/js/utils";
|
||||
|
||||
Vue.use(VueRouter);
|
||||
const requireContext = require.context('@/business/components/xpack/', true, /router\.js$/);
|
||||
const router = new VueRouter({
|
||||
routes: [
|
||||
{path: "/", redirect: '/setting'},
|
||||
{path: "/", redirect: '/setting/personsetting'},
|
||||
{
|
||||
path: "/sidebar",
|
||||
components: {
|
||||
|
@ -32,14 +32,8 @@ const router = new VueRouter({
|
|||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
|
||||
redirectLoginPath(to.fullPath);
|
||||
|
||||
//解决localStorage清空,cookie没失效导致的卡死问题
|
||||
if (!localStorage.getItem('Admin-Token')) {
|
||||
localStorage.setItem('Admin-Token', "{}");
|
||||
window.location.href = "/login";
|
||||
next();
|
||||
if (getCurrentUser() && getCurrentUser().id) {
|
||||
redirectLoginPath(to.fullPath, next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
@ -53,7 +47,7 @@ VueRouter.prototype.push = function push(location) {
|
|||
|
||||
|
||||
// 登入后跳转至原路径
|
||||
function redirectLoginPath(originPath) {
|
||||
function redirectLoginPath(originPath, next) {
|
||||
let redirectUrl = sessionStorage.getItem('redirectUrl');
|
||||
let loginSuccess = sessionStorage.getItem('loginSuccess');
|
||||
|
||||
|
@ -69,13 +63,17 @@ function redirectLoginPath(originPath) {
|
|||
}
|
||||
}
|
||||
|
||||
if (redirectUrl && loginSuccess) {
|
||||
sessionStorage.removeItem('loginSuccess');
|
||||
router.push(redirectUrl);
|
||||
}
|
||||
sessionStorage.setItem('lastUser', getCurrentUserId());
|
||||
sessionStorage.setItem('redirectUrl', originPath);
|
||||
sessionStorage.removeItem('loginSuccess');
|
||||
|
||||
if (redirectUrl && loginSuccess) {
|
||||
sessionStorage.removeItem('loginSuccess');
|
||||
// router.push(redirectUrl);
|
||||
next({path: redirectUrl});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue