프로필 부분 정리
This commit is contained in:
parent
af36b11b6e
commit
cf4e56472a
@ -1,6 +1,12 @@
|
||||
<template>
|
||||
<div>
|
||||
<BoardProfile :profileName="comment.author" :date="comment.createdAt" :showDetail="false" :author="true" :isChild="isChild" />
|
||||
<BoardProfile
|
||||
:profileName="comment.author"
|
||||
:date="comment.createdAt"
|
||||
:showDetail="false"
|
||||
:author="true"
|
||||
:isLike="!isLike"
|
||||
/>
|
||||
<div class="mt-6">
|
||||
<p class="m-0">{{ comment.content }}</p>
|
||||
</div>
|
||||
@ -17,7 +23,7 @@
|
||||
<BoardComment
|
||||
:comment="child"
|
||||
:isPlusButton="false"
|
||||
:isChild="true"
|
||||
:isLike="true"
|
||||
@submitComment="submitComment"
|
||||
/>
|
||||
</li>
|
||||
@ -51,7 +57,7 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
isChild: {
|
||||
isLike: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="d-flex align-items-center flex-wrap">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="avatar me-2" v-if="!unknown">
|
||||
<div v-if="!unknown" class="avatar me-2">
|
||||
<img src="/img/avatars/2.png" alt="Avatar" class="rounded-circle" />
|
||||
</div>
|
||||
<div class="me-2">
|
||||
@ -19,40 +19,30 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 버튼 영역 -->
|
||||
<div class="ms-auto btn-area">
|
||||
<template v-if="showDetail">
|
||||
<div class="text-end">
|
||||
<EditButton @click="handleEdit" />
|
||||
<DeleteButton @click="handleDelete" />
|
||||
<!-- 수정, 삭제 버튼 -->
|
||||
<template v-if="author || showDetail">
|
||||
<EditButton @click="handleEdit" />
|
||||
<DeleteButton @click="handleDelete" />
|
||||
</template>
|
||||
|
||||
<div class="mt-3" v-if="isPassword && !unknown">
|
||||
<div class="input-group">
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
v-model="password"
|
||||
placeholder="비밀번호 입력"
|
||||
/>
|
||||
<button class="btn btn-primary" type="button" @click="handleSubmit">확인</button>
|
||||
</div>
|
||||
<span v-if="passwordAlert" class="invalid-feedback d-block text-start">{{ passwordAlert }}</span>
|
||||
</div>
|
||||
<!-- 비밀번호 입력창 (익명일 경우) -->
|
||||
<div v-if="isPassword && unknown" class="mt-3">
|
||||
<div class="input-group">
|
||||
<input
|
||||
type="password"
|
||||
class="form-control"
|
||||
v-model="password"
|
||||
placeholder="비밀번호 입력"
|
||||
/>
|
||||
<button class="btn btn-primary" @click="handleSubmit">확인</button>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<!-- 게시글의 작성자 여부를 확인 : 현재 로그인한 사용자가 이 게시글의 작성자인지 여부 -->
|
||||
<template v-if="author">
|
||||
<EditButton />
|
||||
<DeleteButton />
|
||||
<!-- <button class="btn author btn-label-primary btn-icon" @click="handleEdit">
|
||||
<i class='bx bx-edit-alt'></i>
|
||||
</button>
|
||||
<button class="btn author btn-label-primary btn-icon" @click="handleDelete">
|
||||
<i class='bx bx-trash'></i>
|
||||
</button> -->
|
||||
</template>
|
||||
<BoardRecommendBtn v-if="!isChild" :isRecommend="false" />
|
||||
</template>
|
||||
<span v-if="passwordAlert" class="invalid-feedback d-block text-start">{{ passwordAlert }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 좋아요, 싫어요 버튼 (댓글에서만 표시) -->
|
||||
<BoardRecommendBtn v-if="isLike" :isRecommend="false" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -107,7 +97,7 @@ const props = defineProps({
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
isChild: {
|
||||
isLike: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
}
|
||||
@ -158,21 +148,15 @@ const handleSubmit = async () => {
|
||||
|
||||
const postResponse = await axios.post(`board/${props.boardId}/password`, requestData);
|
||||
|
||||
if (postResponse.data.code === 200) {
|
||||
if (postResponse.data.data === true) {
|
||||
isPassword.value = false;
|
||||
|
||||
if (postResponse.data.code === 200 && postResponse.data.data) {
|
||||
isPassword.value = false;
|
||||
|
||||
if (lastClickedButton.value === 'edit') {
|
||||
router.push({ name: 'BoardEdit', params: { id: props.boardId } });
|
||||
} else if (lastClickedButton.value === 'delete') {
|
||||
await deletePost();
|
||||
}
|
||||
|
||||
lastClickedButton.value = null;
|
||||
} else {
|
||||
passwordAlert.value = '비밀번호가 일치하지 않습니다.';
|
||||
if (lastClickedButton.value === 'edit') {
|
||||
router.push({ name: 'BoardEdit', params: { id: props.boardId } });
|
||||
} else if (lastClickedButton.value === 'delete') {
|
||||
await deletePost();
|
||||
}
|
||||
lastClickedButton.value = null;
|
||||
} else {
|
||||
passwordAlert.value = '비밀번호가 일치하지 않습니다.';
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
:views="views"
|
||||
:commentNum="commentNum"
|
||||
:date="formattedBoardDate"
|
||||
:isLike="false"
|
||||
class="pb-6 border-bottom"
|
||||
/>
|
||||
</div>
|
||||
@ -196,15 +197,13 @@ const fetchComments = async () => {
|
||||
let rootComments = [];
|
||||
|
||||
allComments.forEach(comment => {
|
||||
commentMap[comment.id] = comment; // 모든 댓글을 객체 형태로 저장
|
||||
commentMap[comment.id] = comment;
|
||||
});
|
||||
|
||||
allComments.forEach(comment => {
|
||||
if (comment.parentId && commentMap[comment.parentId]) {
|
||||
// 부모 댓글이 존재하면, 부모의 children에 추가
|
||||
commentMap[comment.parentId].children.push(comment);
|
||||
} else {
|
||||
// 부모 ID가 없으면 최상위 댓글
|
||||
rootComments.push(comment);
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user