|
@@ -78,68 +78,68 @@ function getCurrentUserSuccess(res){
|
|
|
// var s = document.getElementsByTagName("script")[0];
|
|
|
// s.parentNode.insertBefore(hm, s);
|
|
|
// })();
|
|
|
-// router.beforeEach((to, from, next) => {
|
|
|
-// // if (_hmt) {
|
|
|
-// // if (to.path) {
|
|
|
-// // _hmt.push(['_trackPageview', '/#' + to.fullPath]);
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// const urls = getAuthUrls()
|
|
|
-// if (storageGet('user') == null) {
|
|
|
-// getCurrentUser().then((res) => {
|
|
|
-// storageSave('user', res)
|
|
|
-// storageSave('rolesPermissions', getRolesPermissions(res.roleList))
|
|
|
-// if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
|
|
|
-// if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
|
|
|
-// next()
|
|
|
-// } else {
|
|
|
-// next({
|
|
|
-// path: '/',
|
|
|
-// query: {
|
|
|
-// redirect: to.fullPath
|
|
|
-// } // 将跳转的路由path作为参数,登录成功后跳转到该路由
|
|
|
-// })
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// next()
|
|
|
-// }
|
|
|
-// }).catch((error) => {
|
|
|
-// // notify('warning', '请登录')
|
|
|
-// if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
|
|
|
-// if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
|
|
|
-// next()
|
|
|
-// } else {
|
|
|
-// next({
|
|
|
-// path: '/',
|
|
|
-// query: {
|
|
|
-// redirect: to.fullPath
|
|
|
-// } // 将跳转的路由path作为参数,登录成功后跳转到该路由
|
|
|
-// })
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// next()
|
|
|
-// }
|
|
|
-// })
|
|
|
-// } else {
|
|
|
-// if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
|
|
|
-// if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
|
|
|
-// next()
|
|
|
-// } else {
|
|
|
-// next({
|
|
|
-// path: '/',
|
|
|
-// query: {
|
|
|
-// redirect: to.fullPath
|
|
|
-// } // 将跳转的路由path作为参数,登录成功后跳转到该路由
|
|
|
-// })
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// next()
|
|
|
-// }
|
|
|
-// }
|
|
|
-// //console.log(to.matched[0].path)
|
|
|
-// //console.log(urls.includes(to.matched[0].path))
|
|
|
-//
|
|
|
-// })
|
|
|
+router.beforeEach((to, from, next) => {
|
|
|
+ // if (_hmt) {
|
|
|
+ // if (to.path) {
|
|
|
+ // _hmt.push(['_trackPageview', '/#' + to.fullPath]);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ const urls = getAuthUrls()
|
|
|
+ if (storageGet('user') == null) {
|
|
|
+ getCurrentUser().then((res) => {
|
|
|
+ storageSave('user', res)
|
|
|
+ storageSave('rolesPermissions', getRolesPermissions(res.roleList))
|
|
|
+ if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
|
|
|
+ if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
|
|
|
+ next()
|
|
|
+ } else {
|
|
|
+ next({
|
|
|
+ path: '/',
|
|
|
+ query: {
|
|
|
+ redirect: to.fullPath
|
|
|
+ } // 将跳转的路由path作为参数,登录成功后跳转到该路由
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ next()
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ // notify('warning', '请登录')
|
|
|
+ if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
|
|
|
+ if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
|
|
|
+ next()
|
|
|
+ } else {
|
|
|
+ next({
|
|
|
+ path: '/',
|
|
|
+ query: {
|
|
|
+ redirect: to.fullPath
|
|
|
+ } // 将跳转的路由path作为参数,登录成功后跳转到该路由
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ next()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限
|
|
|
+ if (sessionStorage.userName === '2' && urls.includes(to.matched[0].path)) { // 判断缓存里面是否有 userName //在登录的时候设置它的值
|
|
|
+ next()
|
|
|
+ } else {
|
|
|
+ next({
|
|
|
+ path: '/',
|
|
|
+ query: {
|
|
|
+ redirect: to.fullPath
|
|
|
+ } // 将跳转的路由path作为参数,登录成功后跳转到该路由
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ next()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //console.log(to.matched[0].path)
|
|
|
+ //console.log(urls.includes(to.matched[0].path))
|
|
|
+
|
|
|
+})
|
|
|
|
|
|
// require('./mock.js')
|
|
|
Vue.use(Carousel)
|