|
@@ -1,8 +1,8 @@
|
|
|
<template>
|
|
|
- <div class="max-w-screen-xl content my-0 mx-auto text-size-base">
|
|
|
+ <div class="max-w-screen-xl content my-0 mx-auto text-size-base overflow-hidden">
|
|
|
<div v-if="detail" class="mt-[100px]">
|
|
|
- <div class="flex flex-row flex-nowrap">
|
|
|
- <div class="flex-1 flex-basis-[240px] flex-grow-0">
|
|
|
+ <div class="w-full flex flex-row flex-nowrap">
|
|
|
+ <div class="flex-basis-[240px] flex-grow-0 flex-shrink-0">
|
|
|
<n-collapse accordion class="br-1px_#EBEBEB py-[10px]">
|
|
|
<template v-for="(cate, index) in mainCategories.children" :key="index">
|
|
|
<n-collapse-item :title="cate.title" :name="cate.title">
|
|
@@ -11,7 +11,7 @@
|
|
|
</template>
|
|
|
</n-collapse>
|
|
|
</div>
|
|
|
- <div class="flex-1 px-[40px] mb-[120px]">
|
|
|
+ <div class="flex-1 w-[calc(100%-80px)] px-[40px] mb-[120px] overflow-hidden">
|
|
|
<div class="bb-1px_#EBEBEB color-[#999999]">
|
|
|
<n-h1 class="font-700"> {{ detail.title }}</n-h1>
|
|
|
<span class="flex flex-row gap-col-6 pb-[15px]">
|
|
@@ -23,7 +23,7 @@
|
|
|
<div class="w-full content-html" v-html="detail.content"></div>
|
|
|
</div>
|
|
|
|
|
|
- <div class="flex-1 flex-basis-[240px] flex-grow-0">
|
|
|
+ <div class="flex-basis-[240px] flex-grow-0 flex-shrink-0">
|
|
|
<div class="min-h-[200px] bg-[#F5F9FF] b-r-[8px] p-[20px]">
|
|
|
<n-h4 class="font-600 ext-size-base">主要内容</n-h4>
|
|
|
<n-anchor :show-rail="false">
|
|
@@ -67,7 +67,10 @@ import { htmlToTree, createAnchorNames, dayjs } from '@/utils'
|
|
|
import { NH1, NH4, NCollapse, NCollapseItem, NAnchor, NAnchorLink } from 'naive-ui'
|
|
|
|
|
|
const route = useRoute()
|
|
|
-const id = route.params?.id
|
|
|
+
|
|
|
+const params = route.params as {
|
|
|
+ id?: number
|
|
|
+}
|
|
|
|
|
|
console.log('route', route)
|
|
|
const detail = ref<ArticleDetailType | undefined>()
|
|
@@ -81,23 +84,33 @@ onMounted(async () => {
|
|
|
createAnchorNames(html)
|
|
|
}
|
|
|
}, 1000)
|
|
|
- await getArticleCount(+id)
|
|
|
+ if (params.id) {
|
|
|
+ await getArticleCount(+params.id)
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
watchEffect(() => {
|
|
|
- if (id) {
|
|
|
- getArticleDetail(+id).then(async (data) => {
|
|
|
+ if (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)
|
|
|
- const res = await getCategoryTree(+detail.value.categoryId)
|
|
|
- // console.log('data', res.data)
|
|
|
- mainCategories.value = res.data
|
|
|
+ if (detail.value.categoryId) {
|
|
|
+ const res = await getCategoryTree(detail.value.categoryId)
|
|
|
+ if (res.data) {
|
|
|
+ mainCategories.value = res.data as CategoryItem[]
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss" scoped></style>
|
|
|
+<style lang="scss" scoped>
|
|
|
+:deep(.content-html img) {
|
|
|
+ width: 100% !important;
|
|
|
+ height: auto;
|
|
|
+}
|
|
|
+</style>
|