공지사항 리스트 추가

This commit is contained in:
kimdaae328 2025-01-17 15:38:41 +09:00
parent d2f7aed762
commit 80f7aff731

View File

@ -26,7 +26,11 @@
</div> </div>
</div> </div>
<!-- 게시물 리스트 --> <!-- 공지사항 게시물 리스트 -->
<div class="row g-3">
<board-card :posts="filteredList2" @click="goDetail" />
</div>
<!-- 일반 게시물 리스트 -->
<div class="row g-3"> <div class="row g-3">
<board-card :posts="paginatedList" @click="goDetail" /> <board-card :posts="paginatedList" @click="goDetail" />
</div> </div>
@ -56,6 +60,7 @@ import axios from '@api';
// //
const list = ref([]); const list = ref([]);
const list2 = ref([]);
const searchText = ref(''); const searchText = ref('');
// //
@ -68,16 +73,23 @@ const search = (e) => {
searchText.value = e.trim(); searchText.value = e.trim();
}; };
// // ()
const filteredList = computed(() => const filteredList = computed(() =>
list.value.filter((item) => list.value.filter((item) =>
item.title.toLowerCase().includes(searchText.value.toLowerCase()) 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 currentPage = ref(1); //
const itemsPerPage = 5; // const itemsPerPage = 10; //
// //
const paginatedList = computed(() => { const paginatedList = computed(() => {
@ -98,7 +110,7 @@ const changePage = (page) => {
} }
}; };
// // ()
const fetchPosts = async () => { const fetchPosts = async () => {
const response = await axios.get("board/general"); 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(() => { onMounted(() => {
fetchPosts(); fetchPosts();
fetchPosts2();
}); });
</script> </script>