mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	perf: 面包屑去首页化,根据选择的菜单对应显示,首页不在固定到面包屑里,并优化面包屑页面的路由监听
This commit is contained in:
		
							parent
							
								
									4bc888b273
								
							
						
					
					
						commit
						d4de5fc6f6
					
				@ -1,6 +1,5 @@
 | 
				
			|||||||
<script setup lang="ts">
 | 
					<script setup lang="ts">
 | 
				
			||||||
import { isEqual } from "@pureadmin/utils";
 | 
					import { isEqual } from "@pureadmin/utils";
 | 
				
			||||||
import { routerArrays } from "@/layout/types";
 | 
					 | 
				
			||||||
import { transformI18n } from "@/plugins/i18n";
 | 
					import { transformI18n } from "@/plugins/i18n";
 | 
				
			||||||
import { ref, watch, onMounted, toRaw } from "vue";
 | 
					import { ref, watch, onMounted, toRaw } from "vue";
 | 
				
			||||||
import { getParentPaths, findRouteByPath } from "@/router/utils";
 | 
					import { getParentPaths, findRouteByPath } from "@/router/utils";
 | 
				
			||||||
@ -11,7 +10,6 @@ const route = useRoute();
 | 
				
			|||||||
const levelList = ref([]);
 | 
					const levelList = ref([]);
 | 
				
			||||||
const router = useRouter();
 | 
					const router = useRouter();
 | 
				
			||||||
const routes: any = router.options.routes;
 | 
					const routes: any = router.options.routes;
 | 
				
			||||||
const { VITE_HIDE_HOME } = import.meta.env;
 | 
					 | 
				
			||||||
const multiTags: any = useMultiTagsStoreHook().multiTags;
 | 
					const multiTags: any = useMultiTagsStoreHook().multiTags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const getBreadcrumb = (): void => {
 | 
					const getBreadcrumb = (): void => {
 | 
				
			||||||
@ -33,6 +31,7 @@ const getBreadcrumb = (): void => {
 | 
				
			|||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    currentRoute = findRouteByPath(router.currentRoute.value.path, routes);
 | 
					    currentRoute = findRouteByPath(router.currentRoute.value.path, routes);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // 当前路由的父级路径组成的数组
 | 
					  // 当前路由的父级路径组成的数组
 | 
				
			||||||
  const parentRoutes = getParentPaths(
 | 
					  const parentRoutes = getParentPaths(
 | 
				
			||||||
    router.currentRoute.value.name as string,
 | 
					    router.currentRoute.value.name as string,
 | 
				
			||||||
@ -40,16 +39,14 @@ const getBreadcrumb = (): void => {
 | 
				
			|||||||
    "name"
 | 
					    "name"
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
  // 存放组成面包屑的数组
 | 
					  // 存放组成面包屑的数组
 | 
				
			||||||
  let matched = [];
 | 
					  const matched = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // 获取每个父级路径对应的路由信息
 | 
					  // 获取每个父级路径对应的路由信息
 | 
				
			||||||
  parentRoutes.forEach(path => {
 | 
					  parentRoutes.forEach(path => {
 | 
				
			||||||
    if (path !== "/") matched.push(findRouteByPath(path, routes));
 | 
					    if (path !== "/") matched.push(findRouteByPath(path, routes));
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (currentRoute?.path !== "/welcome") matched.push(currentRoute);
 | 
					  matched.push(currentRoute);
 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (VITE_HIDE_HOME === "false") matched = routerArrays.concat(matched);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  matched.forEach((item, index) => {
 | 
					  matched.forEach((item, index) => {
 | 
				
			||||||
    if (currentRoute?.query || currentRoute?.params) return;
 | 
					    if (currentRoute?.query || currentRoute?.params) return;
 | 
				
			||||||
@ -84,6 +81,9 @@ watch(
 | 
				
			|||||||
  () => route.path,
 | 
					  () => route.path,
 | 
				
			||||||
  () => {
 | 
					  () => {
 | 
				
			||||||
    getBreadcrumb();
 | 
					    getBreadcrumb();
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    deep: true
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user