|
|
@@ -95,6 +95,7 @@ const router = new Router({
|
|
|
|
|
|
]
|
|
|
})
|
|
|
+
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
// 登录界面登录成功之后,会把用户信息保存在会话
|
|
|
// 存在时间为会话生命周期,页面关闭即失效。
|
|
|
@@ -110,28 +111,26 @@ router.beforeEach((to, from, next) => {
|
|
|
return
|
|
|
// next({ path: '/Signature' })
|
|
|
}
|
|
|
- console.log(to.path);
|
|
|
- console.log(from.path);
|
|
|
- console.log(window.location.href);
|
|
|
if (to.path === '/letter/KhgxLetter' && window.location.href.includes('token')) {
|
|
|
- const urlToken = decodeURIComponent(window.location.href.split("=")[1]);
|
|
|
- const decryptedBytes = CryptoJS.AES.decrypt(urlToken,
|
|
|
- 'token')
|
|
|
- console.log(urlToken)
|
|
|
- console.log(decryptedBytes)
|
|
|
- const tokens = decryptedBytes.toString(CryptoJS.enc.Utf8);
|
|
|
- console.log(tokens)
|
|
|
- const usgMsg = JSON.parse(tokens);
|
|
|
- console.log(usgMsg)
|
|
|
- Cookies.set("custId", usgMsg.custId);
|
|
|
- Cookies.set("licenseNo", usgMsg.licenseNo);
|
|
|
- router.addRoutes(router.options.routes)
|
|
|
- Cookies.set("token", usgMsg.token);
|
|
|
- getUser();
|
|
|
- next(false);
|
|
|
+ const urlToken = decodeURIComponent(window.location.href.split("=")[1]);
|
|
|
+ const decryptedBytes = CryptoJS.AES.decrypt(urlToken,
|
|
|
+ 'token')
|
|
|
+ console.log(urlToken)
|
|
|
+ console.log(decryptedBytes)
|
|
|
+ const tokens = decryptedBytes.toString(CryptoJS.enc.Utf8);
|
|
|
+ console.log(tokens)
|
|
|
+ const usgMsg = JSON.parse(tokens);
|
|
|
+ console.log(usgMsg)
|
|
|
+ Cookies.set("custId", usgMsg.custId);
|
|
|
+ Cookies.set("licenseNo", usgMsg.licenseNo);
|
|
|
+ router.addRoutes(router.options.routes)
|
|
|
+ Cookies.set("token", usgMsg.token);
|
|
|
+ getUser();
|
|
|
+ next(false);
|
|
|
// next({ path: '/Signature' })
|
|
|
}
|
|
|
if (to.path === '/login') {
|
|
|
+ store.commit('clearMenuTree')//跳转登录页 清空菜单
|
|
|
// console.log(window.location.href.includes('token'))
|
|
|
if (window.location.href.includes('token')) {
|
|
|
const decryptedBytes = CryptoJS.AES.decrypt(window.location.href.split("=")[1],
|
|
|
@@ -139,7 +138,6 @@ router.beforeEach((to, from, next) => {
|
|
|
const token = decryptedBytes.toString(CryptoJS.enc.Utf8);
|
|
|
getUser()
|
|
|
let userName = Cookies.get('user')
|
|
|
-
|
|
|
if (token) {
|
|
|
//let userInfo = JSON.parse(localStorage.getItem("user_data"))
|
|
|
Cookies.set("token", token);
|
|
|
@@ -194,7 +192,6 @@ router.beforeEach((to, from, next) => {
|
|
|
//获取用户信息
|
|
|
function getUser() {
|
|
|
api.user.getLoginUser().then((response) => {
|
|
|
- console.log(response)
|
|
|
if (response.code == 200) {
|
|
|
//头像地址拼接
|
|
|
if (
|
|
|
@@ -227,6 +224,7 @@ function getUser() {
|
|
|
* 加载动态菜单和路由
|
|
|
*/
|
|
|
function addDynamicMenuAndRoutes(userName, to, from) {
|
|
|
+
|
|
|
// 处理IFrame嵌套页面
|
|
|
handleIFrameUrl(to.path)
|
|
|
if (store.state.app.menuRouteLoaded) {
|
|
|
@@ -234,16 +232,23 @@ function addDynamicMenuAndRoutes(userName, to, from) {
|
|
|
return
|
|
|
}
|
|
|
api.menu.findNavTree({ 'userName': userName }).then(res => {
|
|
|
- // 添加动态路由
|
|
|
- let dynamicRoutes = addDynamicRoutes(res.data)
|
|
|
+ if (res.data.length) {
|
|
|
+ // 添加动态路由
|
|
|
+ let dynamicRoutes = addDynamicRoutes(res.data)
|
|
|
+ // 处理静态组件绑定路由
|
|
|
+ handleStaticComponent(router, dynamicRoutes)
|
|
|
+ router.addRoutes(router.options.routes)
|
|
|
+ // 保存加载状态
|
|
|
+ store.commit('menuRouteLoaded', true)
|
|
|
+ // 保存菜单树
|
|
|
+ store.commit('setNavTree', res.data)
|
|
|
+ } else {
|
|
|
+ store.commit('setNavTree', []) // 清空导航树
|
|
|
+ store.commit('changeLeftTree', null) // 清空左侧菜单
|
|
|
+ router.addRoutes(router.options.routes)
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- // 处理静态组件绑定路由
|
|
|
- handleStaticComponent(router, dynamicRoutes)
|
|
|
- router.addRoutes(router.options.routes)
|
|
|
- // 保存加载状态
|
|
|
- store.commit('menuRouteLoaded', true)
|
|
|
- // 保存菜单树
|
|
|
- store.commit('setNavTree', res.data)
|
|
|
}).then(res => {
|
|
|
api.user.findPermissions({ 'name': userName }).then(res => {
|
|
|
// 保存用户权限标识集合
|