From fe8abc7f7c846e544dcbb1428e952bf289c96f28 Mon Sep 17 00:00:00 2001 From: khj0414 Date: Fri, 14 Mar 2025 13:16:47 +0900 Subject: [PATCH 1/9] =?UTF-8?q?=EC=9A=A9=EC=96=B4=EC=A7=91=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wordDict/DictAlphabetFilter.vue | 64 +++++++++---- src/components/wordDict/DictCard.vue | 4 +- src/components/wordDict/DictWrite.vue | 5 +- src/views/wordDict/wordDict.vue | 96 +++++++++++-------- 4 files changed, 101 insertions(+), 68 deletions(-) diff --git a/src/components/wordDict/DictAlphabetFilter.vue b/src/components/wordDict/DictAlphabetFilter.vue index e18f954..8479312 100644 --- a/src/components/wordDict/DictAlphabetFilter.vue +++ b/src/components/wordDict/DictAlphabetFilter.vue @@ -1,29 +1,18 @@ diff --git a/src/views/error/Error400.vue b/src/views/error/Error400.vue new file mode 100644 index 0000000..9f1c61b --- /dev/null +++ b/src/views/error/Error400.vue @@ -0,0 +1,12 @@ + + + diff --git a/src/views/error/Error404.vue b/src/views/error/Error404.vue new file mode 100644 index 0000000..1ee5a81 --- /dev/null +++ b/src/views/error/Error404.vue @@ -0,0 +1,13 @@ + + + diff --git a/src/views/error/Error500.vue b/src/views/error/Error500.vue new file mode 100644 index 0000000..4e0730a --- /dev/null +++ b/src/views/error/Error500.vue @@ -0,0 +1,16 @@ + + + + + From 74be397b5d42c78b6234a90ef2cf06819c3c8420 Mon Sep 17 00:00:00 2001 From: nevermoregb Date: Fri, 14 Mar 2025 16:16:37 +0900 Subject: [PATCH 5/9] 123 --- src/stores/useBoardAccessStore.js | 27 +++++++++++++++++++++++++++ src/views/board/BoardEdit.vue | 15 +++++++++++++-- src/views/board/BoardView.vue | 9 +++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 src/stores/useBoardAccessStore.js diff --git a/src/stores/useBoardAccessStore.js b/src/stores/useBoardAccessStore.js new file mode 100644 index 0000000..ab9db4b --- /dev/null +++ b/src/stores/useBoardAccessStore.js @@ -0,0 +1,27 @@ +/* + 작성자 : 박성용 + 작성일 : 2025-03-14 + 수정자 : + 수정일 : + 설명 : 게시글 수정 시 비밀번호 적재용. +*/ +import { ref, computed } from 'vue'; +import { defineStore } from 'pinia'; + +export const useBoardAccessStore = defineStore('access', () => { + const password = ref(null); + + function setBoardPassword(input) { + password.value = input; + } + + function $reset() { + password.value = null; + } + + return { + password, + setBoardPassword, + $reset, + }; +}); diff --git a/src/views/board/BoardEdit.vue b/src/views/board/BoardEdit.vue index 4b19c15..14b38f0 100644 --- a/src/views/board/BoardEdit.vue +++ b/src/views/board/BoardEdit.vue @@ -85,11 +85,13 @@ import { ref, onMounted, computed, watch, inject } from 'vue'; import { useRoute, useRouter } from 'vue-router'; import { useToastStore } from '@s/toastStore'; + import { useBoardAccessStore } from '@s/useBoardAccessStore'; import axios from '@api'; // 공통 const $common = inject('common'); const toastStore = useToastStore(); + const accessStore = useBoardAccessStore(); // 상태 변수 const title = ref(''); @@ -118,9 +120,18 @@ // 게시물 데이터 로드 const fetchBoardDetails = async () => { try { - const response = await axios.get(`board/${currentBoardId.value}`); - const data = response.data.data; + // 수정 데이터 전송 + const params = { + password: accessStore.password?.value || '', + }; + //const response = await axios.get(`board/${currentBoardId.value}`); + const response = await axios.post(`board/${currentBoardId.value}`, params); + if (response.data.code !== 200) { + toastStore.onToast(response.data.message, 'e'); + router.go(-1); + } + const data = response.data.data; // 기존 첨부파일 추가 if (data.hasAttachment && data.attachments.length > 0) { attachFiles.value = addDisplayFileName([...data.attachments]); diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 6caf0f3..29780ca 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -137,7 +137,9 @@ import { useRoute, useRouter } from 'vue-router'; import { useUserInfoStore } from '@/stores/useUserInfoStore'; import { useToastStore } from '@s/toastStore'; + import { useBoardAccessStore } from '@s/useBoardAccessStore'; import axios from '@api'; + // 게시물 데이터 상태 const profileName = ref(''); const boardTitle = ref('제목 없음'); @@ -157,6 +159,8 @@ const router = useRouter(); const userStore = useUserInfoStore(); const toastStore = useToastStore(); + const accessStore = useBoardAccessStore(); + const currentBoardId = ref(Number(route.params.id)); const unknown = computed(() => profileName.value === '익명'); const currentUserId = computed(() => userStore?.user?.id); // 현재 로그인한 사용자 id @@ -598,14 +602,19 @@ }); if (response.data.code === 200 && response.data.data === true) { + accessStore.setBoardPassword(password); + console.log('password: ', password.value); + console.log('accessStore.password: ', accessStore.password.value); boardPasswordAlert.value = ''; isPassword.value = false; if (lastClickedButton.value === 'edit') { router.push({ name: 'BoardEdit', params: { id: currentBoardId.value } }); + return; } else if (lastClickedButton.value === 'delete') { await deletePost(); } + accessStore.$reset(); lastClickedButton.value = null; } else { boardPasswordAlert.value = '비밀번호가 일치하지 않습니다.'; From 277524c0c3a532301ded207d2386d0a1271e7102 Mon Sep 17 00:00:00 2001 From: nevermoregb Date: Mon, 17 Mar 2025 09:13:25 +0900 Subject: [PATCH 6/9] =?UTF-8?q?=EC=88=98=EC=A0=95=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8=20=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/useBoardAccessStore.js | 47 +++++++++++++++++++++---------- src/views/board/BoardEdit.vue | 47 +++++++++++++++---------------- src/views/board/BoardView.vue | 34 ++++++++++++---------- 3 files changed, 74 insertions(+), 54 deletions(-) diff --git a/src/stores/useBoardAccessStore.js b/src/stores/useBoardAccessStore.js index ab9db4b..3960cfe 100644 --- a/src/stores/useBoardAccessStore.js +++ b/src/stores/useBoardAccessStore.js @@ -5,23 +5,40 @@ 수정일 : 설명 : 게시글 수정 시 비밀번호 적재용. */ -import { ref, computed } from 'vue'; +import { ref, computed, watch } from 'vue'; import { defineStore } from 'pinia'; -export const useBoardAccessStore = defineStore('access', () => { - const password = ref(null); +export const useBoardAccessStore = defineStore( + 'access', + () => { + const password = ref(''); - function setBoardPassword(input) { - password.value = input; - } + if (localStorage.getItem('tempPassword')) { + // 저장된 값을 불러와 상태에 할당 + const storedState = JSON.parse(localStorage.getItem('tempPassword')); + password.value = storedState; + } - function $reset() { - password.value = null; - } + watch(password, newValue => { + localStorage.setItem('tempPassword', JSON.stringify(newValue.value)); + }); - return { - password, - setBoardPassword, - $reset, - }; -}); + function setBoardPassword(input) { + password.value = input; + } + + function $reset() { + password.value = ''; + localStorage.removeItem('tempPassword', newValue); + } + + return { + password, + setBoardPassword, + $reset, + }; + }, + { + persist: true, + }, +); diff --git a/src/views/board/BoardEdit.vue b/src/views/board/BoardEdit.vue index 14b38f0..f043e27 100644 --- a/src/views/board/BoardEdit.vue +++ b/src/views/board/BoardEdit.vue @@ -119,31 +119,30 @@ // 게시물 데이터 로드 const fetchBoardDetails = async () => { - try { - // 수정 데이터 전송 - const params = { - password: accessStore.password?.value || '', - }; - //const response = await axios.get(`board/${currentBoardId.value}`); - const response = await axios.post(`board/${currentBoardId.value}`, params); + // 수정 데이터 전송 + const password = accessStore.password.value; + const params = { + password: password || '', + }; + console.log('params: ', params); + //const response = await axios.get(`board/${currentBoardId.value}`); + const { data } = await axios.post(`board/${currentBoardId.value}`, params); - if (response.data.code !== 200) { - toastStore.onToast(response.data.message, 'e'); - router.go(-1); - } - const data = response.data.data; - // 기존 첨부파일 추가 - if (data.hasAttachment && data.attachments.length > 0) { - attachFiles.value = addDisplayFileName([...data.attachments]); - } - - // 데이터 설정 - title.value = data.title || '제목 없음'; - content.value = data.content || '내용 없음'; - contentLoaded.value = true; - } catch (error) { - console.error('게시물 가져오기 오류:', error.response || error.message); + if (data.code !== 200) { + toastStore.onToast(data.message, 'e'); + router.go(-1); + return; } + const boardData = data.data; + // 기존 첨부파일 추가 + if (boardData.hasAttachment && boardData.attachments.length > 0) { + attachFiles.value = addDisplayFileName([...boardData.attachments]); + } + + // 데이터 설정 + title.value = boardData.title || '제목 없음'; + content.value = boardData.content || '내용 없음'; + contentLoaded.value = true; }; // 기존 첨부파일명을 노출 @@ -265,7 +264,7 @@ }; // 컴포넌트 마운트 시 데이터 로드 - onMounted(() => { + onMounted(async () => { if (currentBoardId.value) { fetchBoardDetails(); } else { diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 29780ca..c3a6ce6 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -240,21 +240,25 @@ }; // 게시물 상세 데이터 불러오기 const fetchBoardDetails = async () => { - const response = await axios.get(`board/${currentBoardId.value}`); - const data = response.data.data; - - profileName.value = data.author || '익명'; - authorId.value = data.authorId; - boardTitle.value = data.title || '제목 없음'; - boardContent.value = data.content || ''; - profileImg.value = data.profileImg || ''; - date.value = data.date || ''; - views.value = data.cnt || 0; - likes.value = data.likeCount || 0; - dislikes.value = data.dislikeCount || 0; - attachment.value = data.hasAttachment || null; - commentNum.value = data.commentCount || 0; - attachments.value = data.attachments || []; + const { data } = await axios.get(`board/${currentBoardId.value}`); + if (data?.data) { + const boardData = data.data; + profileName.value = boardData.author || '익명'; + authorId.value = boardData.authorId; + boardTitle.value = boardData.title || '제목 없음'; + boardContent.value = boardData.content || ''; + profileImg.value = boardData.profileImg || ''; + date.value = boardData.date || ''; + views.value = boardData.cnt || 0; + likes.value = boardData.likeCount || 0; + dislikes.value = boardData.dislikeCount || 0; + attachment.value = boardData.hasAttachment || null; + commentNum.value = boardData.commentCount || 0; + attachments.value = boardData.attachments || []; + } else { + toastStore.onToast(data.message, 'e'); + router.back(); + } }; // 좋아요, 싫어요 From 4258881d4b3d3e60182a9b20f6d874df81251bbc Mon Sep 17 00:00:00 2001 From: khj0414 Date: Mon, 17 Mar 2025 10:24:41 +0900 Subject: [PATCH 7/9] =?UTF-8?q?=EC=9A=A9=EC=96=B4=EC=A7=91=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/input/FormInput.vue | 3 - src/components/input/FormSelect.vue | 8 ++ src/components/wordDict/DictWrite.vue | 123 +++++++++++++------------- src/views/wordDict/wordDict.vue | 4 +- 4 files changed, 70 insertions(+), 68 deletions(-) diff --git a/src/components/input/FormInput.vue b/src/components/input/FormInput.vue index 7c1da23..931ff2e 100644 --- a/src/components/input/FormInput.vue +++ b/src/components/input/FormInput.vue @@ -19,9 +19,6 @@ @focusout="$emit('focusout', modelValue)" @input="handleInput" /> -
- -
{{ title }}을 확인해주세요.
카테고리 중복입니다.
diff --git a/src/components/input/FormSelect.vue b/src/components/input/FormSelect.vue index bc7e9f4..915deaf 100644 --- a/src/components/input/FormSelect.vue +++ b/src/components/input/FormSelect.vue @@ -10,6 +10,9 @@ {{ isCommon ? item.label : item }} +
+ +
-
-
- -
-
- -
-
- -
-
- -
+ +
+
-
- + +
+ -
-
- -
- +
+ +
+ +
-