| 
				
				
				
				 | 
			
			 | 
			@@ -1,5 +1,4 @@ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import router from "@/router"; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import { useUserStoreHook } from "@/store/modules/user"; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import { usePermissionStoreHook } from "@/store/modules/permission"; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import NProgress from "nprogress"; | 
		
		
	
	
		
			
				| 
				
				
				
					
				
				 | 
			
			 | 
			@@ -11,51 +10,28 @@ const permissionStore = usePermissionStoreHook(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			// 白名单路由 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			const whiteList = ["/login", "/signSucceed"]; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			// router.beforeEach(async (to, from, next) => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   NProgress.start(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   // const hasToken = localStorage.getItem("accessToken"); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   // if (hasToken) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //   if (to.path === "/login") { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //     // 如果已登录,跳转首页 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //     next({ path: "/" }); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //     NProgress.done(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //   } else { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //     const userStore = useUserStoreHook(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //     const hasRoles = userStore.roles && userStore.roles.length > 0; | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //     if (hasRoles) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //       // 未匹配到任何路由,跳转404 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //       if (to.matched.length === 0) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //         from.name ? next({ name: from.name }) : next("/404"); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //       } else { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //         next(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //       } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //     } else { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //       try { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //         const { roles } = await userStore.getInfo(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //         const accessRoutes = await permissionStore.generateRoutes(roles); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //         accessRoutes.forEach((route) => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //           router.addRoute(route); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //         }); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //         next({ ...to, replace: true }); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //       } catch (error) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //         // 移除 token 并跳转登录页 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //         await userStore.resetToken(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //         next(`/login?redirect=${to.path}`); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //         NProgress.done(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //       } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //     } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //   } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   // } else { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //   // 未登录可以访问白名单页面 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //   if (whiteList.indexOf(to.path) !== -1) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //     next(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //   } else { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //     next(`/login?redirect=${to.path}`); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //     NProgress.done(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   //   } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   // } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			// }); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			router.beforeEach(async (to, from, next) => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  NProgress.start(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  const AccessToken = localStorage.getItem("AccessToken"); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  // 已登录 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  if (AccessToken) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    if (to.path === "/login") { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      next({ path: "/" }); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    } else { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      next(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    // 未登录 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  } else { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    // 未登录可以访问白名单页面 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    if (whiteList.indexOf(to.path) !== -1) { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      next(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    } else { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      // 不在白名单内,跳转登录页 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			      next({ path: "/login" }); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  } | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			}); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			// router.afterEach(() => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			//   NProgress.done(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			// }); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			router.afterEach(() => { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			  NProgress.done(); | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			}); |