Skip to content

Commit 1815327

Browse files
committed
🐛 抽取面包屑组件
1 parent b56ee55 commit 1815327

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/composables/header/useHeaderBreadcrumb.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ let storageConfigStore = useStorageConfigStore();
77
import useRouterData from "~/composables/useRouterData";
88
let { fullpath, storageKey } = useRouterData();
99

10+
import useCommon from "~/composables/useCommon";
11+
const { encodeAllIgnoreSlashes } = useCommon();
12+
1013
// 面包屑数据
1114
let breadcrumbData = ref([]);
1215
let initialized = false;
@@ -16,7 +19,13 @@ export default function useBreadcrumb() {
1619

1720
// 构建面包屑
1821
let buildBreadcrumbData = () => {
19-
breadcrumbData.value = [];
22+
breadcrumbData.value = [
23+
{
24+
name: storageConfigStore.globalConfig.siteHomeName || '首页',
25+
href: rootPath.value,
26+
disable: false
27+
}
28+
];
2029

2130
// 如果为包含根目录模式,则面包屑显示驱动器
2231
if (rootShowStorage) {
@@ -25,7 +34,7 @@ export default function useBreadcrumb() {
2534
if (storageByKey) {
2635
breadcrumbData.value.push({
2736
name: storageByKey.name,
28-
fullPath: '/' + storageByKey.key
37+
href: encodeAllIgnoreSlashes('/' + storageByKey.key)
2938
})
3039
}
3140
}
@@ -34,10 +43,10 @@ export default function useBreadcrumb() {
3443
fullpath.value.forEach((item, index, arr) => {
3544
let breadcrumbItem = {
3645
name: item,
37-
fullPath: removeDuplicateSlashes('/' + storageKey.value + '/' + arr.slice(0, index + 1).join('/'))
46+
href: encodeAllIgnoreSlashes(removeDuplicateSlashes('/' + storageKey.value + '/' + arr.slice(0, index + 1).join('/'))),
47+
disable: index === arr.length - 1
3848
}
3949
breadcrumbData.value.push(breadcrumbItem);
40-
4150
})
4251
}
4352
};

0 commit comments

Comments
 (0)