Browse Source

注释main.js中的getcurrentUser

guo00guo 5 years ago
parent
commit
cedb5e74f2
1 changed files with 62 additions and 62 deletions
  1. 62 62
      src/main.js

+ 62 - 62
src/main.js

@@ -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)