Skip to content

Commit

Permalink
feat: 面包屑展示加上子元素判断
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntian001 committed Jun 21, 2023
1 parent 7abc316 commit c236f8c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ const setBreadcrumbList = (route: RouteLocationNormalized) => {
let temp = { children: routes.value } as unknown as RouteRecordRaw;
route.meta.menuIndex!.forEach((item) => {
temp = temp.children![item];
if (temp.meta && temp.meta.title && temp.meta.breadcrumb !== false) {
if (
temp.meta?.title &&
temp.meta.breadcrumb !== false &&
(temp.meta.breadcrumb || temp.children?.filter((v) => v.meta?.breadcrumb !== false).length !== 1)
) {
list.push({
name: temp.name,
path: temp.path,
Expand Down
1 change: 1 addition & 0 deletions types/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
const ElLoading: typeof import('element-plus/es')['ElLoading']
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
const asyncComputed: typeof import('@vueuse/core')['asyncComputed']
const autoResetRef: typeof import('@vueuse/core')['autoResetRef']
Expand Down
2 changes: 1 addition & 1 deletion types/vue-router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare module 'vue-router' {
// 若你想不管路由下面的 children 声明的个数都显示你的根路由
// 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
alwaysShow?: boolean;
// 是否需要面包屑false不需要 ture或undefined为需要
// 是否需要面包屑 false不展示在面包屑,ture一直展示在面包屑,undefined当只有一个子元素面包屑时跳过展示
breadcrumb?: boolean;
//路由在菜单的index deep映射(会动态计算不要设置默认值)
menuIndex?: number[];
Expand Down

0 comments on commit c236f8c

Please sign in to comment.