From b67076a3ca08946166f19aed39a0c2420d66ea05 Mon Sep 17 00:00:00 2001 From: dyhj625 Date: Thu, 20 Mar 2025 13:00:55 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=8C=EC=8B=9C=ED=8C=90=20=EC=9D=B5?= =?UTF-8?q?=EB=AA=85=20=EB=8B=89=EB=84=A4=EC=9E=84,=20=EA=B2=BD=EA=B3=A0?= =?UTF-8?q?=EB=AC=B8=EA=B5=ACcss=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/board/BoardComment.vue | 2 +- src/components/board/BoardCommentArea.vue | 108 +++++++++++++--------- src/views/board/BoardView.vue | 4 + 3 files changed, 70 insertions(+), 44 deletions(-) diff --git a/src/components/board/BoardComment.vue b/src/components/board/BoardComment.vue index 906d5cf..cff6256 100644 --- a/src/components/board/BoardComment.vue +++ b/src/components/board/BoardComment.vue @@ -4,7 +4,7 @@ :unknown="comment.author === '익명'" :isCommentAuthor="isCommentAuthor" :boardId="comment.boardId" - :profileName="comment.author" + :profileName="comment.nickname ? comment.nickname : comment.author" :date="comment.createdAt" :comment="comment" :profileImg="comment.profileImg" diff --git a/src/components/board/BoardCommentArea.vue b/src/components/board/BoardCommentArea.vue index f8da317..1add6aa 100644 --- a/src/components/board/BoardCommentArea.vue +++ b/src/components/board/BoardCommentArea.vue @@ -3,35 +3,29 @@
- - -
{{ commentAlert }} - {{ textAlert }} + {{ textAlert }}
-
-
- -
+
+ +
+ +
익명
- - -
-
-
-
- {{ passwordAlert }} - {{ passwordAlert2 }}
@@ -108,37 +109,54 @@ const password = ref(''); const isCheck = ref(false); const textAlert = ref(''); + const nicknameAlert = ref(''); const passwordAlert2 = ref(''); + const nickname = ref(''); const emit = defineEmits(['submitComment']); - const alertTextHandler = () => { - textAlert.value = ''; - }; - - const passwordAlertTextHandler = event => { - event.target.value = event.target.value.replace(/\s/g, ''); - passwordAlert2.value = ''; + // 입력 필드별 경고 메시지 초기화 + const clearAlert = field => { + if (field === 'comment') textAlert.value = ''; + if (field === 'nickname') nicknameAlert.value = ''; + if (field === 'password') passwordAlert2.value = ''; }; const handleCommentSubmit = () => { + let isValid = true; + + // 댓글 공백 체크 if (!$common.isNotEmpty(comment.value)) { textAlert.value = '댓글을 입력하세요'; - return false; + isValid = false; } else { textAlert.value = ''; } - if (isCheck.value && !$common.isNotEmpty(password.value)) { - passwordAlert2.value = '비밀번호를 입력하세요'; - return false; - } else { - passwordAlert2.value = ''; + // 익명 선택 시 닉네임 & 비밀번호 체크 + if (isCheck.value) { + if (!$common.isNotEmpty(nickname.value)) { + nicknameAlert.value = '닉네임을 입력하세요'; + isValid = false; + } else { + nicknameAlert.value = ''; + } + + if (!$common.isNotEmpty(password.value)) { + passwordAlert2.value = '비밀번호를 입력하세요'; + isValid = false; + } else { + passwordAlert2.value = ''; + } } + // 모든 입력값이 유효할 경우만 제출 + if (!isValid) return; + // 댓글 제출 emit('submitComment', { comment: comment.value, + nickname: isCheck.value ? nickname.value : '', password: isCheck.value ? password.value : '', isCheck: isCheck.value, LOCBRDTYP: isCheck.value ? '300102' : null, // 익명일 경우 '300102' 설정 @@ -148,15 +166,19 @@ resetCommentForm(); }; - // 비밀번호 경고 초기화 + // 비밀번호 & 닉네임 경고 초기화 const pwd2AlertHandler = () => { - if (isCheck.value === false) passwordAlert2.value = ''; + if (!isCheck.value) { + passwordAlert2.value = ''; + nicknameAlert.value = ''; + } }; // 입력 필드 리셋 함수 추가 const resetCommentForm = () => { comment.value = ''; password.value = ''; + nickname.value = ''; isCheck.value = false; }; diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index b3cdfe2..4d45f11 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -322,6 +322,7 @@ likeCount: comment.likeCount || 0, dislikeCount: comment.dislikeCount || 0, profileImg: comment.profileImg || '', + nickname: comment.LOCCMTNIC, likeClicked: comment.likeClicked || false, dislikeClicked: comment.dislikeClicked || false, createdAtRaw: comment.LOCCMTRDT, // 작성일 @@ -351,6 +352,7 @@ parentId: reply.LOCCMTPNT, // 부모 댓글 ID content: reply.LOCCMTRPY || '내용 없음', createdAtRaw: reply.LOCCMTRDT, + nickname: reply.LOCCMTNIC, // createdAt: formattedDate(reply.LOCCMTRDT), //createdAtRaw: new Date(reply.LOCCMTUDT), createdAt: formattedDate(reply.LOCCMTUDT) + (reply.LOCCMTUDT !== reply.LOCCMTRDT ? ' (수정됨)' : ''), @@ -413,6 +415,7 @@ LOCCMTRPY: comment, LOCCMTPWD: isCheck ? password : '', LOCCMTPNT: 1, + LOCCMTNIC: data.isCheck ? data.nickname : null, LOCBRDTYP: isCheck ? '300102' : null, }); @@ -432,6 +435,7 @@ LOCCMTRPY: reply.comment, LOCCMTPWD: reply.password || null, LOCCMTPNT: reply.parentId, + LOCCMTNIC: data.isCheck ? data.nickname : null, LOCBRDTYP: reply.isCheck ? '300102' : null, });