|
@@ -97,22 +97,25 @@ const nodeProps = ({ option }: { option: TreeOption }) => {
|
|
|
|
|
|
watchEffect(async () => {
|
|
|
if (params.id) {
|
|
|
- const res = await getArticlesByCateId(params.id);
|
|
|
- if (res) {
|
|
|
- articleList.value = res.data as ArticleDetailType[]
|
|
|
- }
|
|
|
- const res1 = await getCategoryTree(params.id)
|
|
|
- if (res1 && res1.data) {
|
|
|
- mainCategories.value = res1.data as CategoryItem
|
|
|
-
|
|
|
- currentCate.value = findNodeById(
|
|
|
- [mainCategories.value] as unknown as TreeNode[],
|
|
|
- Number(params.id),
|
|
|
- ) as unknown as CategoryItem
|
|
|
- defaultExpandedKeys.value = [currentCate.value.parentId]
|
|
|
- breadcrumb.value = findBreadcrumbPath([mainCategories.value] as unknown as TreeNode[], Number(params.id))
|
|
|
- console.log('breadcrumb', [mainCategories.value], breadcrumb.value)
|
|
|
+ if (!isNaN(+params.id)) {
|
|
|
+ const res = await getArticlesByCateId(params.id);
|
|
|
+ if (res) {
|
|
|
+ articleList.value = res.data as ArticleDetailType[]
|
|
|
+ }
|
|
|
+ const res1 = await getCategoryTree(params.id)
|
|
|
+ if (res1 && res1.data) {
|
|
|
+ mainCategories.value = res1.data as CategoryItem
|
|
|
+
|
|
|
+ currentCate.value = findNodeById(
|
|
|
+ [mainCategories.value] as unknown as TreeNode[],
|
|
|
+ Number(params.id),
|
|
|
+ ) as unknown as CategoryItem
|
|
|
+ defaultExpandedKeys.value = [currentCate.value.parentId]
|
|
|
+ breadcrumb.value = findBreadcrumbPath([mainCategories.value] as unknown as TreeNode[], Number(params.id))
|
|
|
+ console.log('breadcrumb', [mainCategories.value], breadcrumb.value)
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
})
|
|
|
|