zy1125 преди 1 година
родител
ревизия
f0672c97ed
променени са 1 файла, в които са добавени 10 реда и са изтрити 0 реда
  1. 10 0
      src/router/index.js

+ 10 - 0
src/router/index.js

@@ -20,4 +20,14 @@ const router = createRouter({
20 20
   routes
21 21
 })
22 22
 
23
+
24
+router.beforeEach(function(to, from, next) {
25
+  if (!localStorage.getItem("myAdminToken")) {
26
+      if (to.path !== '/login') {
27
+          return next('/login')
28
+      }
29
+  }
30
+  next()
31
+})
32
+
23 33
 export default router