From 7c4e06037a2964c52772a344ee8240a19c708539 Mon Sep 17 00:00:00 2001 From: KUN1007 Date: Fri, 16 Jun 2023 20:15:29 +0800 Subject: [PATCH] rebuild technique fetch --- server/src/routes/topic.js | 5 +- src/components/WangEditor.vue | 1 - src/views/technique/Technique.vue | 56 ++++++++++++++----- .../technique/components/SingleTopic.vue | 45 ++++++--------- 4 files changed, 62 insertions(+), 45 deletions(-) diff --git a/server/src/routes/topic.js b/server/src/routes/topic.js index 4ed38f42..f22a7cfd 100644 --- a/server/src/routes/topic.js +++ b/server/src/routes/topic.js @@ -8,7 +8,8 @@ const topics = [ // 帖子的数组 { topicId: 1, - topicTitle: '啊这可海星啊这可海星啊这可海星啊这可海星啊这可海星', + topicTitle: + '啊这可海星啊这可海星啊这可海星啊这可海星啊这可海星啊这可海星啊这可海星啊这可海星', topicFloorCount: 1, topicContent: '

啊这可海星

', topicPublishTime: Date.now(), @@ -111,7 +112,7 @@ const topics = [ }, { topicId: 2, - topicTitle: '啊这可海星啊这可海星啊这可海星啊这可海星啊这可海星', + topicTitle: '啊这可海星', topicFloorCount: 1, topicContent: '

啊这可海星

', topicPublishTime: Date.now(), diff --git a/src/components/WangEditor.vue b/src/components/WangEditor.vue index 92da3630..b42a870f 100644 --- a/src/components/WangEditor.vue +++ b/src/components/WangEditor.vue @@ -60,7 +60,6 @@ const editorConfig = { const handleCreated = (editor: IDomEditor) => { editorRef.value = editor - console.log(editor.getConfig()) } onMounted(() => { diff --git a/src/views/technique/Technique.vue b/src/views/technique/Technique.vue index 47e7ff43..a3eb95b2 100644 --- a/src/views/technique/Technique.vue +++ b/src/views/technique/Technique.vue @@ -3,6 +3,28 @@ import KUNGalgameTopBar from '@/components/KUNGalgameTopBar.vue' import SingleTopic from './components/SingleTopic.vue' import Pagination from './components/Pagination.vue' import Aside from './components/Aside.vue' + +import { ref, onMounted } from 'vue' +import { getTopicRangeApi } from '@/api/topic/index' +import { KUNGalgameTopic } from '@/api/topic/types/topic' + +// 在组件中定义响应式的帖子数据 +const topics = ref([]) + +// 在组件挂载时调用 fetchTopics 获取帖子数据 +onMounted(async () => { + try { + const start = 0 // 起始位置 + const count = 17 // 获取的帖子数量 + + // TODO: 这里接口获取到的数据太多了,其实获取 title,like,view,comment,text 这几个字段就足够了 + const fetchedTopics = await getTopicRangeApi(start, count) + + topics.value = fetchedTopics + } catch (error) { + console.error('Error fetching topics:', error) + } +})