diff --git a/src/components/board/BoardCommentArea.vue b/src/components/board/BoardCommentArea.vue index 3fa251d..283ce8b 100644 --- a/src/components/board/BoardCommentArea.vue +++ b/src/components/board/BoardCommentArea.vue @@ -51,65 +51,78 @@ + diff --git a/src/components/board/BoardProfile.vue b/src/components/board/BoardProfile.vue index 71c1c2e..25ae89d 100644 --- a/src/components/board/BoardProfile.vue +++ b/src/components/board/BoardProfile.vue @@ -2,9 +2,9 @@
- Avatar + Avatar
- +
{{ profileName }}
@@ -23,8 +23,7 @@
- - - - diff --git a/src/views/board/BoardView.vue b/src/views/board/BoardView.vue index 3719d7b..d268bb6 100644 --- a/src/views/board/BoardView.vue +++ b/src/views/board/BoardView.vue @@ -39,8 +39,8 @@
  • {{ attachment.originalName }}.{{ attachment.extension }} @@ -157,8 +157,26 @@ const commentsWithAuthStatus = computed(() => { const attachments = ref([]); // 첨부파일 다운로드 URL 생성 -const getFileDownloadUrl = (attachment) => { - return `board/files/download?path=${encodeURIComponent(attachment.path)}`; +const downloadFile = async (attachment) => { + try { + const response = await axios.get(`board/download`, { + params: { path: attachment.path }, + responseType: 'blob' + }); + + // Blob에서 파일 다운로드 링크 생성 + const url = window.URL.createObjectURL(new Blob([response.data])); + const link = document.createElement('a'); + link.href = url; + link.setAttribute('download', attachment.originalName + '.' + attachment.extension); + document.body.appendChild(link); + link.click(); + link.remove(); + window.URL.revokeObjectURL(url); + } catch (error) { + console.error('파일 다운로드 오류:', error); + alert('파일 다운로드 중 오류가 발생했습니다.'); + } }; @@ -200,14 +218,11 @@ const fetchBoardDetails = async () => { try { 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 || '익명'; - authorId.value = data.authorId; //게시글 작성자 id + authorId.value = data.authorId; boardTitle.value = data.title || '제목 없음'; boardContent.value = data.content || ''; date.value = data.date || ''; @@ -277,7 +292,6 @@ const fetchComments = async (page = 1) => { page } }); - const commentsList = response.data.data.list.map(comment => ({ commentId: comment.LOCCMTSEQ, // 댓글 ID boardId: comment.LOCBRDSEQ, @@ -292,6 +306,7 @@ const fetchComments = async (page = 1) => { createdAtRaw: new Date(comment.LOCCMTRDT), // 정렬용 createdAt: formattedDate(comment.LOCCMTRDT), // 표시용 children: [], // 대댓글을 담을 배열 + updateAtRaw: new Date(comment.LOCCMTUDT), })); commentsList.sort((a, b) => b.createdAtRaw - a.createdAtRaw);