|
@@ -3,7 +3,7 @@
|
|
|
<div v-if="detail">
|
|
|
<div class="breadcrumb my-[30px] pb-[20px] bb-1px_#EBEBEB" role="navigation">
|
|
|
<n-breadcrumb separator=">" v-if="breadcrumb">
|
|
|
- <!-- {{ breadcrumb }}-->
|
|
|
+ <!-- {{ breadcrumb }} -->
|
|
|
<template v-for="(bread, index) in breadcrumb" :key="index">
|
|
|
<n-breadcrumb-item :clickable="false"> {{ bread.title }}</n-breadcrumb-item>
|
|
|
</template>
|
|
@@ -92,7 +92,7 @@ import {
|
|
|
getCategoryTree,
|
|
|
getArticlesByCateId,
|
|
|
} from '@/api'
|
|
|
-import { htmlToTree, createAnchorNames, dayjs, findNodeById, findBreadcrumbPath } from '@/utils'
|
|
|
+import { htmlToTree, createAnchorNames, dayjs, findNodeById, findBreadcrumbPath, type TreeNode } from '@/utils'
|
|
|
import { NH1, NH2, NH4, NBreadcrumb, NBreadcrumbItem, NTree, NAnchor, NAnchorLink } from 'naive-ui'
|
|
|
import type { TreeOption } from 'naive-ui'
|
|
|
|
|
@@ -155,13 +155,14 @@ watchEffect(() => {
|
|
|
if (res.data) {
|
|
|
mainCategories.value = res.data as CategoryItem[]
|
|
|
if (mainCategories.value) {
|
|
|
+ debugger
|
|
|
currentCate.value = findNodeById(
|
|
|
- [mainCategories.value],
|
|
|
- detail.value.categoryId,
|
|
|
+ mainCategories.value as unknown as TreeNode[] ||[],
|
|
|
+ String(detail.value.categoryId),
|
|
|
) as unknown as CategoryItem
|
|
|
defaultExpandedKeys.value = [currentCate.value.parentId]
|
|
|
- breadcrumb.value = findBreadcrumbPath([mainCategories.value], detail.value.categoryId)
|
|
|
- // console.log('breadcrumb', breadcrumb.value)
|
|
|
+ breadcrumb.value = findBreadcrumbPath(mainCategories.value as unknown as TreeNode[] ||[], String(detail.value.categoryId))
|
|
|
+ console.log('breadcrumb', breadcrumb.value)
|
|
|
}
|
|
|
}
|
|
|
}
|