57334bfb by renchao@pashanhoo.com

style:权限

1 parent bcb8e998
......@@ -13,7 +13,7 @@ import "nprogress/nprogress.css"; // progress bar style
import getPageTitle from "@/utils/get-page-title";
import getTheme from "@/utils/theme";
import Cookies from "js-cookie";
import {getToken, getUrlParam, setToken} from "@/utils/util";
import { getToken, getUrlParam, setToken } from "@/utils/util";
NProgress.configure({ showSpinner: false });
......@@ -27,7 +27,7 @@ router.beforeEach(async (to, from, next) => {
// cas操作
const token = getToken()
let locationUrl = window.location.origin + window.location.pathname;
function casValidate (ticket){
function casValidate (ticket) {
axios.get(window._config.services.management + "/management/cas/validate", {
params: {
ticket: ticket,
......@@ -35,10 +35,10 @@ router.beforeEach(async (to, from, next) => {
},
}).then(async (res) => {
if (res.data.status === 1) {
setToken(res.data.content.accessToken)
window.location.href = localStorage.getItem('sjsb-location') + '#' + localStorage.getItem('hash')
setToken(res.data.content.accessToken)
window.location.href = localStorage.getItem('sjsb-location') + '#' + localStorage.getItem('hash')
} else {
alert(res.data.message)
alert(res.data.message)
}
}).catch((e) => {
console.log(e);
......@@ -65,12 +65,7 @@ router.beforeEach(async (to, from, next) => {
...accessRoutes,
{ path: "*", redirect: "/404", hidden: true }
]);
const routeTo = Cookies.get("routerTo");
if (routeTo && routeTo !== "/") {
next({ ...to, replace: true });
} else {
next(path)
}
next(path)
}
}
if (window._config.casEnable === true) {
......@@ -92,35 +87,35 @@ router.beforeEach(async (to, from, next) => {
if (ticket) {
casValidate(ticket)
} else {
if (to.path === '/login') {
if (getUrlParam('_flag') === '1') {
next();
return
} else {
//todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写
localStorage.setItem('sjsb-location',locationUrl)
localStorage.setItem('hash',to.fullPath)
window.location.href = window._config.services.management + `/management/cas/status?loginUrl=${window._config.baseUrl}/sjsb/&hash=/login&`
return
}
if (to.path === '/login') {
if (getUrlParam('_flag') === '1') {
next();
return
} else {
//todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写
localStorage.setItem('sjsb-location', locationUrl)
localStorage.setItem('hash', to.fullPath)
window.location.href = window._config.services.management + `/management/cas/status?loginUrl=${window._config.baseUrl}/sjsb/&hash=/login&`
return
}
localStorage.setItem('sjsb-location',locationUrl)
localStorage.setItem('hash',to.fullPath)
//todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写
window.location.href = window._config.services.management + `/management/cas/status?loginUrl=${window._config.baseUrl}/sjsb/&hash=/login`
}
localStorage.setItem('sjsb-location', locationUrl)
localStorage.setItem('hash', to.fullPath)
//todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写
window.location.href = window._config.services.management + `/management/cas/status?loginUrl=${window._config.baseUrl}/sjsb/&hash=/login`
}
}else{
} else {
permission()
if (to.path === '/login') {
const redirectUrl = getUrlParam('redirectUrl');
if (redirectUrl && redirectUrl !== '') {
window.location.href = redirectUrl
return
window.location.href = redirectUrl
return
} else {
next('/');
return
next('/');
return
}
}
permission()
}
}
NProgress.done()
......