From 80f7aff7312b47387c22c1ba3211fd2ea2c23620 Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Fri, 17 Jan 2025 15:38:41 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B3=B5=EC=A7=80=EC=82=AC=ED=95=AD=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/board/BoardList.vue | 43 +++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/views/board/BoardList.vue b/src/views/board/BoardList.vue index d30734d..eda8118 100644 --- a/src/views/board/BoardList.vue +++ b/src/views/board/BoardList.vue @@ -26,7 +26,11 @@ - + +
+ +
+
@@ -56,6 +60,7 @@ import axios from '@api'; // 데이터 초기화 const list = ref([]); +const list2 = ref([]); const searchText = ref(''); // 상세 페이지 이동 @@ -68,16 +73,23 @@ const search = (e) => { searchText.value = e.trim(); }; -// 검색 결과 필터링 +// 검색 결과 필터링(일반게시물) const filteredList = computed(() => list.value.filter((item) => item.title.toLowerCase().includes(searchText.value.toLowerCase()) ) ); +// 검색 결과 필터링(공지사항) +const filteredList2 = computed(() => + list2.value.filter((item) => + item.title.toLowerCase().includes(searchText.value.toLowerCase()) + ) +); + // 페이지네이션 상태 const currentPage = ref(1); // 현재 페이지 번호 -const itemsPerPage = 5; // 한 페이지에 표시할 아이템 수 +const itemsPerPage = 10; // 한 페이지에 표시할 아이템 수 // 현재 페이지 데이터 계산 const paginatedList = computed(() => { @@ -98,7 +110,7 @@ const changePage = (page) => { } }; -// 게시물 데이터 로드 +// 게시물 데이터 로드(일반) const fetchPosts = async () => { const response = await axios.get("board/general"); @@ -115,9 +127,32 @@ const fetchPosts = async () => { } }; +const fetchPosts2 = async () => { + try { + console.log('ㅁㄴㅇㅁㅇㅁ') + const response = await axios.get("board/notices"); + console.log(response) + + if (response.data && response.data.data && Array.isArray(response.data.data)) { + list2.value = response.data.data.map((post, index) => ({ + ...post, + id: post.id || index, + img: post.img || null, + likes: post.likes || 0, + comments: post.comments || 0, + })); + } else { + console.error("데이터 오류:", response.data); + } + } catch (error) { + console.error("공지사항 데이터 로드 실패:", error); + } +}; + // 데이터 로드 onMounted(() => { fetchPosts(); + fetchPosts2(); });