style:权限
Showing
1 changed file
with
27 additions
and
32 deletions
| ... | @@ -13,7 +13,7 @@ import "nprogress/nprogress.css"; // progress bar style | ... | @@ -13,7 +13,7 @@ import "nprogress/nprogress.css"; // progress bar style |
| 13 | import getPageTitle from "@/utils/get-page-title"; | 13 | import getPageTitle from "@/utils/get-page-title"; |
| 14 | import getTheme from "@/utils/theme"; | 14 | import getTheme from "@/utils/theme"; |
| 15 | import Cookies from "js-cookie"; | 15 | import Cookies from "js-cookie"; |
| 16 | import {getToken, getUrlParam, setToken} from "@/utils/util"; | 16 | import { getToken, getUrlParam, setToken } from "@/utils/util"; |
| 17 | 17 | ||
| 18 | NProgress.configure({ showSpinner: false }); | 18 | NProgress.configure({ showSpinner: false }); |
| 19 | 19 | ||
| ... | @@ -27,7 +27,7 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -27,7 +27,7 @@ router.beforeEach(async (to, from, next) => { |
| 27 | // cas操作 | 27 | // cas操作 |
| 28 | const token = getToken() | 28 | const token = getToken() |
| 29 | let locationUrl = window.location.origin + window.location.pathname; | 29 | let locationUrl = window.location.origin + window.location.pathname; |
| 30 | function casValidate (ticket){ | 30 | function casValidate (ticket) { |
| 31 | axios.get(window._config.services.management + "/management/cas/validate", { | 31 | axios.get(window._config.services.management + "/management/cas/validate", { |
| 32 | params: { | 32 | params: { |
| 33 | ticket: ticket, | 33 | ticket: ticket, |
| ... | @@ -35,10 +35,10 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -35,10 +35,10 @@ router.beforeEach(async (to, from, next) => { |
| 35 | }, | 35 | }, |
| 36 | }).then(async (res) => { | 36 | }).then(async (res) => { |
| 37 | if (res.data.status === 1) { | 37 | if (res.data.status === 1) { |
| 38 | setToken(res.data.content.accessToken) | 38 | setToken(res.data.content.accessToken) |
| 39 | window.location.href = localStorage.getItem('sjsb-location') + '#' + localStorage.getItem('hash') | 39 | window.location.href = localStorage.getItem('sjsb-location') + '#' + localStorage.getItem('hash') |
| 40 | } else { | 40 | } else { |
| 41 | alert(res.data.message) | 41 | alert(res.data.message) |
| 42 | } | 42 | } |
| 43 | }).catch((e) => { | 43 | }).catch((e) => { |
| 44 | console.log(e); | 44 | console.log(e); |
| ... | @@ -65,12 +65,7 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -65,12 +65,7 @@ router.beforeEach(async (to, from, next) => { |
| 65 | ...accessRoutes, | 65 | ...accessRoutes, |
| 66 | { path: "*", redirect: "/404", hidden: true } | 66 | { path: "*", redirect: "/404", hidden: true } |
| 67 | ]); | 67 | ]); |
| 68 | const routeTo = Cookies.get("routerTo"); | 68 | next(path) |
| 69 | if (routeTo && routeTo !== "/") { | ||
| 70 | next({ ...to, replace: true }); | ||
| 71 | } else { | ||
| 72 | next(path) | ||
| 73 | } | ||
| 74 | } | 69 | } |
| 75 | } | 70 | } |
| 76 | if (window._config.casEnable === true) { | 71 | if (window._config.casEnable === true) { |
| ... | @@ -92,35 +87,35 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -92,35 +87,35 @@ router.beforeEach(async (to, from, next) => { |
| 92 | if (ticket) { | 87 | if (ticket) { |
| 93 | casValidate(ticket) | 88 | casValidate(ticket) |
| 94 | } else { | 89 | } else { |
| 95 | if (to.path === '/login') { | 90 | if (to.path === '/login') { |
| 96 | if (getUrlParam('_flag') === '1') { | 91 | if (getUrlParam('_flag') === '1') { |
| 97 | next(); | 92 | next(); |
| 98 | return | 93 | return |
| 99 | } else { | 94 | } else { |
| 100 | //todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写 | 95 | //todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写 |
| 101 | localStorage.setItem('sjsb-location',locationUrl) | 96 | localStorage.setItem('sjsb-location', locationUrl) |
| 102 | localStorage.setItem('hash',to.fullPath) | 97 | localStorage.setItem('hash', to.fullPath) |
| 103 | window.location.href = window._config.services.management + `/management/cas/status?loginUrl=${window._config.baseUrl}/sjsb/&hash=/login&` | 98 | window.location.href = window._config.services.management + `/management/cas/status?loginUrl=${window._config.baseUrl}/sjsb/&hash=/login&` |
| 104 | return | 99 | return |
| 105 | } | ||
| 106 | } | 100 | } |
| 107 | localStorage.setItem('sjsb-location',locationUrl) | 101 | } |
| 108 | localStorage.setItem('hash',to.fullPath) | 102 | localStorage.setItem('sjsb-location', locationUrl) |
| 109 | //todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写 | 103 | localStorage.setItem('hash', to.fullPath) |
| 110 | window.location.href = window._config.services.management + `/management/cas/status?loginUrl=${window._config.baseUrl}/sjsb/&hash=/login` | 104 | //todo: loginUrl 需要业务系统根据登录页面路由地址获取,这里只是简写 |
| 105 | window.location.href = window._config.services.management + `/management/cas/status?loginUrl=${window._config.baseUrl}/sjsb/&hash=/login` | ||
| 111 | } | 106 | } |
| 112 | }else{ | 107 | } else { |
| 108 | permission() | ||
| 113 | if (to.path === '/login') { | 109 | if (to.path === '/login') { |
| 114 | const redirectUrl = getUrlParam('redirectUrl'); | 110 | const redirectUrl = getUrlParam('redirectUrl'); |
| 115 | if (redirectUrl && redirectUrl !== '') { | 111 | if (redirectUrl && redirectUrl !== '') { |
| 116 | window.location.href = redirectUrl | 112 | window.location.href = redirectUrl |
| 117 | return | 113 | return |
| 118 | } else { | 114 | } else { |
| 119 | next('/'); | 115 | next('/'); |
| 120 | return | 116 | return |
| 121 | } | 117 | } |
| 122 | } | 118 | } |
| 123 | permission() | ||
| 124 | } | 119 | } |
| 125 | } | 120 | } |
| 126 | NProgress.done() | 121 | NProgress.done() | ... | ... |
-
Please register or sign in to post a comment