From d1c91b30df144b11908e8671db45e8bff186a568 Mon Sep 17 00:00:00 2001 From: kimdaae328 Date: Fri, 28 Feb 2025 10:01:53 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/board/BoardComment.vue | 1 - src/components/board/BoardProfile.vue | 7 ++- src/views/board/BoardList.vue | 5 +- src/views/board/BoardView.vue | 86 +++------------------------ 4 files changed, 15 insertions(+), 84 deletions(-) diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 965f6d7..82b54ea 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -165,7 +165,6 @@ const handleEditClick = () => { } const handleReplyEditClick = (event) => { - console.log("πŸ“Œ editClick 이벀트 싀행됨! μ „λ‹¬λœ 데이터:", event); emit('editClick', event); } diff --git a/src/components/board/BoardProfile.vue b/src/components/board/BoardProfile.vue index c3c4f91..cf43b87 100644 --- a/src/components/board/BoardProfile.vue +++ b/src/components/board/BoardProfile.vue @@ -4,6 +4,7 @@
Avatar
+
{{ profileName }}
@@ -94,7 +95,7 @@ const props = defineProps({ isLike: { type: Boolean, default: false, - } + }, }); const emit = defineEmits(['updateReaction', 'editClick', 'deleteClick']); @@ -117,6 +118,10 @@ const handleUpdateReaction = (reactionData) => { }); }; +const getProfileImage = (profilePath) => { + return profilePath && profilePath.trim() ? `${baseUrl}upload/img/profile/${profilePath}` : defaultProfile; +}; + diff --git a/src/views/board/BoardList.vue b/src/views/board/BoardList.vue index 095e5e3..3ac8ef0 100644 --- a/src/views/board/BoardList.vue +++ b/src/views/board/BoardList.vue @@ -195,10 +195,7 @@ const fetchGeneralPosts = async (page = 1) => { }); if (data?.data) { - // console.log(data) - const totalPosts = data.data.total; // 전체 κ²Œμ‹œλ¬Ό 개수 λ°›μ•„μ˜€κΈ° - - // console.log('πŸ“Œ API 응닡 데이터:', data.data); + const totalPosts = data.data.total; generalList.value = data.data.list.map((post, index) => ({ realId: post.id, diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 725dd2a..30d7921 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -76,13 +76,7 @@ @updateReaction="handleUpdateReaction" />
- - - - - +
@@ -173,7 +166,6 @@ const commentsWithAuthStatus = computed(() => { isCommentAuthor: reply.authorId === currentUserId.value, })) })); - // console.log("βœ… commentsWithAuthStatus μ—…λ°μ΄νŠΈλ¨:", updatedComments); return updatedComments; }); @@ -210,20 +202,12 @@ const fetchBoardDetails = async () => { const response = await axios.get(`board/${currentBoardId.value}`); const data = response.data.data; - // console.log(data) // API 응닡 데이터 반영 // const boardDetail = data.boardDetail || {}; profileName.value = data.author || '읡λͺ…'; - // 읡λͺ…ν™•μΈν•˜κ³  μ‹Άμ„λ•Œ - // profileName.value = '읡λͺ…'; - - // console.log("πŸ“Œ κ²Œμ‹œκΈ€ μž‘μ„±μž:", profileName.value); // μž‘μ„±μž 이름 좜λ ₯ - // console.log("πŸ” 읡λͺ… μ—¬λΆ€ (unknown.value):", unknown.value); // 읡λͺ… μ—¬λΆ€ 확인 - - authorId.value = data.authorId; //κ²Œμ‹œκΈ€ μž‘μ„±μž id boardTitle.value = data.title || '제λͺ© μ—†μŒ'; boardContent.value = data.content || ''; @@ -245,7 +229,6 @@ const handleUpdateReaction = async ({ boardId, commentId, isLike, isDislike }) = await axios.post(`/board/${boardId}/${commentId}/reaction`, { LOCBRDSEQ: boardId, // κ²Œμ‹œκΈ€ id LOCCMTSEQ: commentId, //λŒ“κΈ€ id - // MEMBERSEQ: 1, // 멀버아이디 μ§€κΈˆμ€ 1 λ‚˜μ€‘μ— μˆ˜μ •ν•΄μ•Όν•¨ LOCGOBGOD: isLike ? 'T' : 'F', LOCGOBBAD: isDislike ? 'T' : 'F' }); @@ -258,13 +241,9 @@ const handleUpdateReaction = async ({ boardId, commentId, isLike, isDislike }) = likeClicked.value = isLike; dislikeClicked.value = isDislike; - // console.log(updatedData) - - // console.log("κ°±μ‹ λœ 데이터:", updatedData); } catch (error) { alert('였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.'); - // console.log('λ°˜μ‘μ„ μ—…λ°μ΄νŠΈν•˜λŠ” 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.'); } }; @@ -281,13 +260,10 @@ const handleCommentReaction = async ({ boardId, commentId, isLike, isDislike }) LOCGOBBAD: isDislike ? 'T' : 'F' }); - // console.log("λŒ“κΈ€ μ’‹μ•„μš” API 응닡 데이터:", response.data); - await fetchComments(); } catch (error) { alert('였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.'); - // console.log('λŒ“κΈ€ λ°˜μ‘μ„ μ—…λ°μ΄νŠΈν•˜λŠ” 쀑 였λ₯˜ λ°œμƒ'); } }; @@ -302,8 +278,6 @@ const fetchComments = async (page = 1) => { } }); - // console.log(response.data.data) - const commentsList = response.data.data.list.map(comment => ({ commentId: comment.LOCCMTSEQ, // λŒ“κΈ€ ID boardId: comment.LOCBRDSEQ, @@ -329,8 +303,6 @@ const fetchComments = async (page = 1) => { params: { LOCCMTPNT: comment.commentId } }); - // console.log(`λŒ€λŒ“κΈ€ 데이터 (${comment.commentId}의 λŒ€λŒ“κΈ€):`, replyResponse.data); - if (replyResponse.data.data) { comment.children = replyResponse.data.data.map(reply => ({ author: reply.author || '읡λͺ…', @@ -370,18 +342,15 @@ const fetchComments = async (page = 1) => { navigateLastPage: response.data.data.navigateLastPage // νŽ˜μ΄μ§€λ„€μ΄μ…˜μ—μ„œ λ§ˆμ§€λ§‰ νŽ˜μ΄μ§€ 번호 }; - // console.log("πŸ“Œ λŒ“κΈ€ λͺ©λ‘:", comments.value); } catch (error) { alert('였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.'); - // alert('λŒ“κΈ€ λͺ©λ‘ 뢈러였기 였λ₯˜:', error); } }; // λŒ“κΈ€ μž‘μ„± const handleCommentSubmit = async (data) => { if (!data) { - console.error("handleCommentSubmit: dataκ°€ undefinedμž…λ‹ˆλ‹€."); return; } @@ -432,8 +401,8 @@ const handleCommentReply = async (reply) => { }); if (response.status === 200) { - if (response.data.code === 200) { // μ„œλ²„ 응닡 μ½”λ“œλ„ 확인 - await fetchComments(); // λŒ“κΈ€ λͺ©λ‘ μƒˆλ‘œκ³ μΉ¨ + if (response.data.code === 200) { + await fetchComments(); } else { alert('λŒ€λŒ“κΈ€ μž‘μ„±μ„ μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.'); } @@ -443,7 +412,6 @@ const handleCommentReply = async (reply) => { alert("였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."); } alert("였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."); - } } @@ -482,41 +450,33 @@ const findCommentById = (commentId, commentsList) => { // λŒ“κΈ€ μˆ˜μ • λ²„νŠΌ 클릭 const editComment = (comment) => { - // λΆ€λͺ¨ λ˜λŠ” λŒ€λŒ“κΈ€μ„ μ°Ύμ•„μ„œ κ°€μ Έμ˜€κΈ° const targetComment = findCommentById(comment.commentId, comments.value); if (!targetComment) { return; } - // λŒ“κΈ€ μž‘μ„±μžκ°€ ν˜„μž¬ λ‘œκ·ΈμΈν•œ μ‚¬μš©μžμ™€ λ™μΌν•œμ§€ 확인 const isMyComment = comment.authorId === currentUserId.value; const isAnonymous = comment.author === "읡λͺ…"; if (isMyComment) { - // 본인 λŒ“κΈ€μ΄λ©΄ λ°”λ‘œ μˆ˜μ • λͺ¨λ“œ ν™œμ„±ν™” targetComment.isEditTextarea = !targetComment.isEditTextarea; } else if (isAnonymous) { - // 읡λͺ… λŒ“κΈ€μ΄λ©΄ λΉ„λ°€λ²ˆν˜Έ μž…λ ₯μ°½ λ„μš°κΈ° toggleCommentPassword(comment, "edit"); } else { - // console.log("λ‹€λ₯Έ μ‚¬μš©μž λŒ“κΈ€ - μˆ˜μ • λΆˆκ°€"); alert("μˆ˜μ •μ΄ λΆˆκ°€λŠ₯ν•©λ‹ˆλ‹€"); } } // λŒ“κΈ€ μ‚­μ œ λ²„νŠΌ 클릭 const deleteComment = async (comment) => { - // 읡λͺ… μ‚¬μš©μžμΈ 경우 const isMyComment = comment.authorId === currentUserId.value; if (unknown.value && !isMyComment) { if (comment.isEditTextarea) { - // ν˜„μž¬ μˆ˜μ • 쀑이라면 μˆ˜μ • λͺ¨λ“œλ₯Ό 끄고, μ‚­μ œ λΉ„λ°€λ²ˆν˜Έ μž…λ ₯창을 띄움 comment.isEditTextarea = false; comment.isCommentPassword = true; } else { - // μˆ˜μ • 쀑이 μ•„λ‹ˆλ©΄ 기쑴의 μ‚­μ œ λΉ„λ°€λ²ˆν˜Έ μž…λ ₯창을 λ„μš°λŠ” 둜직 μ‹€ν–‰ toggleCommentPassword(comment, "delete"); } } else { @@ -554,7 +514,7 @@ const submitPassword = async () => { try { const response = await axios.post(`board/${currentBoardId.value}/password`, { LOCBRDPWD: password.value, - LOCBRDSEQ: 288, // λ‚˜μ€‘μ— ν˜„μž¬ κ²Œμ‹œκΈ€ ID μ‚¬μš©ν•΄μ•Όν•¨ + LOCBRDSEQ: 288, }); if (response.data.code === 200 && response.data.data === true) { @@ -571,8 +531,6 @@ const submitPassword = async () => { passwordAlert.value = "λΉ„λ°€λ²ˆν˜Έκ°€ μΌμΉ˜ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."; } } catch (error) { - // console.log("πŸ“Œ 전체 였λ₯˜:", error); - if (error.response) { if (error.response.status === 401) { passwordAlert.value = "λΉ„λ°€λ²ˆν˜Έκ°€ μΌμΉ˜ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."; @@ -589,11 +547,6 @@ const submitPassword = async () => { // λŒ“κΈ€ μ‚­μ œ (λΉ„λ°€λ²ˆν˜Έ 확인 ν›„) const submitCommentPassword = async (comment, password) => { - console.log('μ•Όμ•Όμ•Ό') - - console.log("λΉ„λ°€λ²ˆν˜Έ :", password); - console.log("λŒ“κΈ€ ID:", comment.commentId); - if (!password) { passwordCommentAlert.value = "λΉ„λ°€λ²ˆν˜Έλ₯Ό μž…λ ₯ν•΄μ£Όμ„Έμš”."; return; @@ -602,12 +555,10 @@ const submitCommentPassword = async (comment, password) => { const targetComment = findCommentById(comment.commentId, comments.value); try { - // console.log('μ„œλ²„λ‘œ λΉ„λ°€λ²ˆν˜Έ 확인 μš”μ²­') const response = await axios.post(`board/comment/${comment.commentId}/password`, { LOCCMTPWD: password, LOCCMTSEQ: comment.commentId, }); - console.log("βœ… μ„œλ²„ 응닡 데이터:", response.data); if (response.data.code === 200 && response.data.data === true) { passwordCommentAlert.value = ""; @@ -622,9 +573,6 @@ const submitCommentPassword = async (comment, password) => { } else { alert("μˆ˜μ • μ·¨μ†Œλ₯Ό μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€."); } - - // 여기뢀뢄이 읡λͺ… μˆ˜μ • λΉ„λ°€λ²ˆν˜Έ λΆ€λΆ„μž„!!!!! - } else if (lastCommentClickedButton.value === "delete") { passwordCommentAlert.value = ""; @@ -632,14 +580,12 @@ const submitCommentPassword = async (comment, password) => { } lastCommentClickedButton.value = null; } else { - // console.log("❌ λΉ„λ°€λ²ˆν˜Έκ°€ ν‹€λ¦Ό"); passwordCommentAlert.value = "λΉ„λ°€λ²ˆν˜Έκ°€ μΌμΉ˜ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."; } } catch (error) { - // console.log("🚨 μ„œλ²„ μš”μ²­ 쀑 였λ₯˜ λ°œμƒ:", error.response?.data || error); - // if (error.response?.status === 401) { - // console.log("❌ 401 였λ₯˜: 인증 μ‹€νŒ¨ (λΉ„λ°€λ²ˆν˜Έ 뢈일치)"); - // } + if (error.response?.status === 401) { + passwordCommentAlert.value = "λΉ„λ°€λ²ˆν˜Έκ°€ μΌμΉ˜ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€"; + } passwordCommentAlert.value = "λΉ„λ°€λ²ˆν˜Έκ°€ μΌμΉ˜ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€"; } }; @@ -677,17 +623,12 @@ const deleteReplyComment = async (comment) => { data: { LOCCMTSEQ: comment.commentId } }); - // console.log("μ„œλ²„ 응닡:", response.data); - if (response.data.code === 200) { - // console.log("λŒ“κΈ€ μ‚­μ œ 성곡!"); await fetchComments(); } else { - // console.log("λŒ“κΈ€ μ‚­μ œ μ‹€νŒ¨:", response.data.message); alert("λŒ“κΈ€ μ‚­μ œμ— μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€."); } } catch (error) { - // console.log("λŒ“κΈ€ μ‚­μ œ 쀑 였λ₯˜ λ°œμƒ:", error); alert("λŒ“κΈ€ μ‚­μ œ 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."); } }; @@ -700,9 +641,6 @@ const handleSubmitEdit = async (comment, editedContent) => { LOCCMTRPY: editedContent }); - // μˆ˜μ • 성곡 μ‹œ μ—…λ°μ΄νŠΈ - // comment.content = editedContent; - // comment.isEditTextarea = false; f if (response.status === 200) { const targetComment = findCommentById(comment.commentId, comments.value); @@ -710,15 +648,12 @@ const handleSubmitEdit = async (comment, editedContent) => { targetComment.content = editedContent; // λŒ“κΈ€ λ‚΄μš© μ—…λ°μ΄νŠΈ targetComment.isEditTextarea = false; // μˆ˜μ • λͺ¨λ“œ λ‹«κΈ° } else { - // console.warn("❌ μˆ˜μ •ν•  λŒ“κΈ€μ„ 찾을 수 μ—†μŒ"); alert("μˆ˜μ •ν•  λŒ“κΈ€μ„ 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."); } } else { - // console.log("❌ λŒ“κΈ€ μˆ˜μ • μ‹€νŒ¨:", response.data); alert("λŒ“κΈ€ μˆ˜μ • μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€."); } } catch (error) { - // console.error("λŒ“κΈ€ μˆ˜μ • 쀑 였λ₯˜ λ°œμƒ:", error); alert("λŒ“κΈ€ μˆ˜μ • 쀑 였λ₯˜ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."); } }; @@ -728,10 +663,8 @@ const handleCancelEdit = (comment) => { const targetComment = findCommentById(comment.commentId, comments.value); if (targetComment) { - // console.log("βœ… 원본 데이터 찾음, μˆ˜μ • μ·¨μ†Œ 처리 κ°€λŠ₯:", targetComment); targetComment.isEditTextarea = false; } else { - // console.error("❌ 원본 데이터 찾을 수 μ—†μŒ, μˆ˜μ • μ·¨μ†Œ μ‹€νŒ¨"); alert("μˆ˜μ • μ·¨μ†Œλ₯Ό μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€."); } }; @@ -754,7 +687,7 @@ const handleCommentDeleted = (deletedCommentId) => { return; } - // 2λŒ€λŒ“κΈ€ μ‚­μ œ + // λŒ€λŒ“κΈ€ μ‚­μ œ for (let parent of comments.value) { const childIndex = parent.children.findIndex(child => child.commentId === deletedCommentId); if (childIndex !== -1) { @@ -762,11 +695,8 @@ const handleCommentDeleted = (deletedCommentId) => { return; } } - - // console.error("❌ μ‚­μ œν•  λŒ“κΈ€μ„ 찾을 수 μ—†μŒ:", deletedCommentId); }; - // λ‚ μ§œ const formattedDate = (dateString) => { if (!dateString) return "λ‚ μ§œ μ—†μŒ";