From b83426e94c5abb458a388e29b4404510478e9d1c Mon Sep 17 00:00:00 2001 From: jhynsoo Date: Tue, 21 May 2024 15:56:30 +0900 Subject: [PATCH] Feat: Use api in article detail page --- src/components/article/ArticleDetail.vue | 34 ++++------------ src/components/article/ArticleList.vue | 51 ++++++++++++++---------- src/components/article/CommentArea.vue | 4 +- src/components/article/CommentForm.vue | 2 + 4 files changed, 42 insertions(+), 49 deletions(-) diff --git a/src/components/article/ArticleDetail.vue b/src/components/article/ArticleDetail.vue index 225fc3b..70394b4 100644 --- a/src/components/article/ArticleDetail.vue +++ b/src/components/article/ArticleDetail.vue @@ -4,6 +4,7 @@ import { useRoute } from 'vue-router'; import BoardHeader from './BoardHeader.vue'; import { getArticle } from '@/api/article'; import CommentArea from './CommentArea.vue'; +import { getComment } from '@/api/comment'; const route = useRoute(); @@ -14,30 +15,9 @@ const comments = ref([]); getArticle(id, ({ data }) => { article.value = data; }); - -// FIXME: remove mock data -setTimeout(() => { - article.value = { - title: '제목', - text: '내용', - author: '작성자', - date: '2024-04-11 13:12:14', - }; - comments.value = [ - { - id: 1, - nickname: '닉네임', - date: '2024-04-11 13:12:14', - text: '댓글 내용', - }, - { - id: 2, - nickname: '닉네임', - date: '2024-04-11 13:12:14', - text: '댓글 내용', - }, - ]; -}, 100); +getComment(id, ({ data }) => { + comments.value = data; +}); @@ -56,9 +36,9 @@ setTimeout(() => { diff --git a/src/components/article/ArticleList.vue b/src/components/article/ArticleList.vue index 6e69890..3d1bb3b 100644 --- a/src/components/article/ArticleList.vue +++ b/src/components/article/ArticleList.vue @@ -1,43 +1,52 @@