|
@@ -4,8 +4,9 @@
|
|
|
<div v-if="detail">
|
|
|
<div class="breadcrumb my-[30px] pb-[20px] bb-1px_#EBEBEB" role="navigation">
|
|
|
<n-breadcrumb separator=">" v-if="breadcrumb">
|
|
|
+ <n-breadcrumb-item @click="$router.push('/')">{{ $t('home') }}</n-breadcrumb-item>
|
|
|
<template v-for="(bread, index) in breadcrumb" :key="index">
|
|
|
- <n-breadcrumb-item :clickable="false"> {{ bread.title }}</n-breadcrumb-item>
|
|
|
+ <n-breadcrumb-item @click="handleBreadcrumb(bread)"> {{ bread.title }}</n-breadcrumb-item>
|
|
|
</template>
|
|
|
</n-breadcrumb>
|
|
|
</div>
|
|
@@ -73,7 +74,7 @@
|
|
|
<n-empty :description="$t('no_article')">
|
|
|
<template #extra>
|
|
|
{{ $t('no_data_article') }},
|
|
|
- <n-button link size="small" quaternary type="primary" @click="router.push('/')">
|
|
|
+ <n-button link size="small" quaternary type="primary" @click="router.push('/')">
|
|
|
{{ $t('go_home') }}
|
|
|
</n-button>
|
|
|
</template>
|
|
@@ -141,7 +142,7 @@ onMounted(async () => {
|
|
|
}
|
|
|
}, 1000)
|
|
|
if (params.id) {
|
|
|
- if(!isNaN(+params.id)){
|
|
|
+ if (!isNaN(+params.id)) {
|
|
|
await getArticleCount(+params.id)
|
|
|
}
|
|
|
}
|
|
@@ -149,36 +150,36 @@ onMounted(async () => {
|
|
|
|
|
|
watchEffect(() => {
|
|
|
if (params.id) {
|
|
|
- if(!isNaN(+params.id)){
|
|
|
+ if (!isNaN(+params.id)) {
|
|
|
getArticleDetail(+params.id).then(async (data) => {
|
|
|
- if (data.data) {
|
|
|
- detail.value = data.data
|
|
|
- document.title = detail.value.title
|
|
|
- mainContents.value = htmlToTree(detail.value.content)
|
|
|
- if (detail.value.categoryId) {
|
|
|
-
|
|
|
- const res = await getCategoryTree(detail.value.categoryId)
|
|
|
- if (res.data) {
|
|
|
- mainCategories.value = res.data as CategoryItem[]
|
|
|
- if (mainCategories.value) {
|
|
|
- currentCate.value = findNodeById(
|
|
|
- [mainCategories.value] as unknown as TreeNode[],
|
|
|
- detail.value.categoryId,
|
|
|
- ) as unknown as CategoryItem
|
|
|
-
|
|
|
- defaultExpandedKeys.value = [currentCate.value.parentId]
|
|
|
- breadcrumb.value = findBreadcrumbPath([mainCategories.value] as unknown as TreeNode[], detail.value.categoryId)
|
|
|
- console.log('breadcrumb', [mainCategories.value], breadcrumb.value)
|
|
|
+ if (data.data) {
|
|
|
+ detail.value = data.data
|
|
|
+ document.title = detail.value.title
|
|
|
+ mainContents.value = htmlToTree(detail.value.content)
|
|
|
+ if (detail.value.categoryId) {
|
|
|
+
|
|
|
+ const res = await getCategoryTree(detail.value.categoryId)
|
|
|
+ if (res.data) {
|
|
|
+ mainCategories.value = res.data as CategoryItem[]
|
|
|
+ if (mainCategories.value) {
|
|
|
+ currentCate.value = findNodeById(
|
|
|
+ [mainCategories.value] as unknown as TreeNode[],
|
|
|
+ detail.value.categoryId,
|
|
|
+ ) as unknown as CategoryItem
|
|
|
+
|
|
|
+ defaultExpandedKeys.value = [currentCate.value.parentId]
|
|
|
+ breadcrumb.value = findBreadcrumbPath([mainCategories.value] as unknown as TreeNode[], detail.value.categoryId)
|
|
|
+ console.log('breadcrumb', [mainCategories.value], breadcrumb.value)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- getNearArticles(+params.id).then(res => {
|
|
|
- if (res.data) {
|
|
|
- articleNear.value = res.data
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ getNearArticles(+params.id).then(res => {
|
|
|
+ if (res.data) {
|
|
|
+ articleNear.value = res.data
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -188,7 +189,13 @@ const handleToArticle = (article: ArticleDetailType) => {
|
|
|
router.replace(`/showdoc/${article.id}`)
|
|
|
setTimeout(() => {
|
|
|
location.reload()
|
|
|
- }, 500)
|
|
|
+ }, 100)
|
|
|
+}
|
|
|
+const handleBreadcrumb = (bread: TreeNode) => {
|
|
|
+ router.replace(`/showcate/${bread.id}`)
|
|
|
+ setTimeout(() => {
|
|
|
+ location.reload()
|
|
|
+ }, 100)
|
|
|
}
|
|
|
|
|
|
</script>
|