From 14a6ee7090f2226c9bd4f07ef7c6573c2bfbfb9a Mon Sep 17 00:00:00 2001 From: linhaojun Date: Tue, 27 Sep 2022 22:29:43 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E8=A7=84=E8=8C=83About.vue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aurora-vue/aurora-blog/src/views/About.vue | 68 ++++++++++++---------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/aurora-vue/aurora-blog/src/views/About.vue b/aurora-vue/aurora-blog/src/views/About.vue index 5cfb2f5..cf723b5 100644 --- a/aurora-vue/aurora-blog/src/views/About.vue +++ b/aurora-vue/aurora-blog/src/views/About.vue @@ -85,6 +85,42 @@ export default defineComponent({ size: 7 }) + const fetchData = async () => { + fetchComments() + fetchAbout() + } + + onMounted(fetchData) + + onBeforeUnmount(() => { + commonStore.resetHeaderImage() + tocbot.destroy() + }) + + provide( + 'comments', + computed(() => reactiveData.comments) + ) + provide( + 'haveMore', + computed(() => reactiveData.haveMore) + ) + emitter.on('aboutFetchComment', () => { + pageInfo.current = 1 + reactiveData.isReload = true + fetchComments() + }) + emitter.on('aboutFetchReplies', (index) => { + fetchReplies(index) + }) + emitter.on('aboutLoadMore', () => { + fetchComments() + }) + + const handlePreview = (index: any) => { + v3ImgPreviewFn({ images: reactiveData.images, index: reactiveData.images.indexOf(index) }) + } + const initTocbot = () => { let nodes = postRef.value.children if (nodes.length) { @@ -113,12 +149,7 @@ export default defineComponent({ } } - const handlePreview = (index: any) => { - v3ImgPreviewFn({ images: reactiveData.images, index: reactiveData.images.indexOf(index) }) - } - - const fetchData = async () => { - fetchComments() + const fetchAbout = () => { api.getAbout().then(({ data }) => { data.data.content = markdownToHtml(data.data.content) reactiveData.about = data.data.content @@ -158,31 +189,6 @@ export default defineComponent({ }) } - onMounted(fetchData) - provide( - 'comments', - computed(() => reactiveData.comments) - ) - provide( - 'haveMore', - computed(() => reactiveData.haveMore) - ) - emitter.on('aboutFetchComment', () => { - pageInfo.current = 1 - reactiveData.isReload = true - fetchComments() - }) - emitter.on('aboutFetchReplies', (index) => { - fetchReplies(index) - }) - emitter.on('aboutLoadMore', () => { - fetchComments() - }) - onBeforeUnmount(() => { - commonStore.resetHeaderImage() - tocbot.destroy() - }) - return { postRef, ...toRefs(reactiveData),