| 
					
				 | 
			
			
				@@ -1,32 +1,46 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 <script setup lang="ts"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // This starter template is using Vue 3 <script setup> SFCs 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  import { ref, watch, computed, nextTick } from 'vue'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   import { RouterView, useRouter, useRoute } from 'vue-router'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  import { AppRoute, NotFoundRoute } from '@/router/base'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  import { AppRoute, NotFoundRoute, EnumPage } from '@/router/base'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   import { authRoutes } from '@/router/auth'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   import { filterAuthHandle } from '@/router/utils' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   import { AppStore } from '@/store/modules/app'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  import { useLocalStorage } from '@vueuse/core' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   const router = useRouter() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   const route = useRoute() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   const store = AppStore() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // TODO: 增加无需权限时的判断 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // 此处模拟接口请求获取权限列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  setTimeout(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    const authFilterRoutes = filterAuthHandle([1], authRoutes) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    console.log(authFilterRoutes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    const childrenRoutes = [...authFilterRoutes, ...AppRoute.children as []] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    router.removeRoute(AppRoute.name as string) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    router.addRoute({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      ...AppRoute, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      children: childrenRoutes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    router.addRoute(NotFoundRoute) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    store.updateLoading(false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    store.updateAuthRoutes(authFilterRoutes) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    router.replace(route.fullPath) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  }, 2e3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  const isLogin = computed(() => store.isLogin) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  watch(isLogin, (val) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (![EnumPage.Login as string, EnumPage.Error as string].includes(route.path)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      if (!val) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        router.push(EnumPage.Login) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        store.updateLoading(false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 此处模拟接口请求获取权限列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        store.updateLoading(true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        setTimeout(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          const authFilterRoutes = filterAuthHandle([1], authRoutes) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          console.log(authFilterRoutes); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          const childrenRoutes = [...authFilterRoutes, ...AppRoute.children as []] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          router.removeRoute(AppRoute.name as string) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          router.addRoute({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ...AppRoute, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            children: childrenRoutes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          router.addRoute(NotFoundRoute) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          store.updateLoading(false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          store.updateAuthRoutes(authFilterRoutes) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          router.replace(route.fullPath) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 2e3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }, { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    immediate: true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 </script> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 <template> 
			 |