diff --git a/src/components/drive/FolderComponent.vue b/src/components/drive/FolderComponent.vue
index aa62b92..2fc004a 100644
--- a/src/components/drive/FolderComponent.vue
+++ b/src/components/drive/FolderComponent.vue
@@ -2,20 +2,24 @@
-
+
+
+ 루트
+
+
+ /
+
{{ folder.folderName }}
- /
+ /
-
+
@@ -66,7 +70,8 @@ export default {
folderList: [], // 현재 폴더 내 폴더 목록
fileList: [], // 현재 폴더 내 파일 목록
currentFolderId: null, // 현재 탐색 중인 폴더 ID
- backButtonHistory: [], // 이전 폴더 기록
+ rootFolderId: null, // 루트 폴더 ID 저장
+ // backButtonHistory: [], // 이전 폴더 기록
files: [], // 업로드할 파일 배열
uploadProgress: [], // 파일 업로드 진행 상황
breadcrumb: [], // 폴더 경로를 저장하는 배열
@@ -81,6 +86,7 @@ export default {
try {
const response = await axios.get(`${process.env.VUE_APP_API_BASE_URL}/channel/${channelId}/drive`);
const data = response.data.result;
+ this.rootFolderId = data.nowFolderId; // 루트 폴더 설정
this.currentFolderId = data.nowFolderId;
this.folderList = data.folderListDto || [];
this.fileList = data.fileListDto || [];
@@ -99,27 +105,40 @@ export default {
// 드롭 시 호출
async onDrop(event, targetFolderId) {
- if (!targetFolderId && this.draggedType === 'folder') {
+ if (targetFolderId === null || targetFolderId === undefined) {
+ alert('유효한 폴더 ID를 입력하세요.');
+ return;
+ }
+ // 폴더가 파일 안에 이동하지 않도록 처리
+ if (this.draggedType === 'folder' && !targetFolderId) {
alert('폴더는 파일 안에 이동할 수 없습니다.');
return;
}
- if (this.draggedType === 'file') {
- try {
- await this.moveFile(this.draggedItem, targetFolderId || this.currentFolderId);
+ // 자기 자신에게 드롭하지 못하도록 하기 (폴더와 파일 구분)
+ if (this.draggedType === 'folder' && this.draggedItem === targetFolderId) {
+ alert('같은 폴더로 이동할 수 없습니다.');
+ return;
+ }
+
+ if (this.draggedType === 'file' && this.currentFolderId === targetFolderId) {
+ alert('같은 위치로 파일을 이동할 수 없습니다.');
+ return;
+ }
+
+ try {
+ if (this.draggedType === 'file') {
+ // 파일을 targetFolderId로 이동
+ await this.moveFile(this.draggedItem, targetFolderId);
alert('파일이 성공적으로 이동되었습니다.');
- } catch (error) {
- console.error('파일 이동 실패:', error);
- alert('파일 이동 중 오류가 발생했습니다.');
- }
- } else if (this.draggedType === 'folder') {
- try {
+ } else if (this.draggedType === 'folder') {
+ // 폴더를 targetFolderId로 이동
await this.moveFolder(this.draggedItem, targetFolderId);
alert('폴더가 성공적으로 이동되었습니다.');
- } catch (error) {
- console.error('폴더 이동 실패:', error);
- alert('폴더 이동 중 오류가 발생했습니다.');
}
+ } catch (error) {
+ console.error(`${this.draggedType} 이동 실패:`, error);
+ alert(`${this.draggedType} 이동 중 오류가 발생했습니다.`);
}
// 드래그 상태 초기화
@@ -130,7 +149,8 @@ export default {
this.refreshFolderList();
},
- // 폴더 생성
+
+// 폴더 생성
async createFolder() {
try {
const response = await axios.post(`${process.env.VUE_APP_API_BASE_URL}/drive/folder/create`, {
@@ -145,15 +165,16 @@ export default {
}
},
- // 뒤로 가기 기능
- goBack() {
- if (this.backButtonHistory.length) {
- console.log('뒤로 가기:', this.backButtonHistory);
- const previousFolderId = this.backButtonHistory.pop(); // 마지막 폴더 ID를 제거하고 이동
- this.breadcrumb.pop(); // 경로에서 마지막 폴더 제거
- this.navigateToFolder(previousFolderId, false); // false는 뒤로가기 이동 시 기록하지 않기 위함
- }
- },
+
+ // // 뒤로 가기 기능
+ // goBack() {
+ // if (this.backButtonHistory.length && this.currentFolderId !== this.rootFolderId) {
+ // console.log('뒤로 가기:', this.backButtonHistory);
+ // const previousFolderId = this.backButtonHistory.pop(); // 마지막 폴더 ID를 제거하고 이동
+ // this.breadcrumb.pop(); // 경로에서 마지막 폴더 제거
+ // this.navigateToFolder(previousFolderId, false); // false는 뒤로가기 이동 시 기록하지 않기 위함
+ // }
+ // },
// 폴더 탐색
// async refreshFolderList() {
@@ -171,7 +192,7 @@ export default {
// 폴더/파일 목록 갱신
async refreshFolderList() {
try {
- const response = await axios.get(`${process.env.VUE_APP_API_BASE_URL}/drive/folder/${this.currentFolderId || 1}`);
+ const response = await axios.get(`${process.env.VUE_APP_API_BASE_URL}/drive/folder/${this.currentFolderId}`);
this.folderList = response.data.result.folderListDto || [];
this.fileList = response.data.result.fileListDto || [];
} catch (error) {
@@ -371,10 +392,17 @@ export default {
}
},
// 폴더 탐색
- async navigateToFolder(folderId, recordHistory = true) {
- if (recordHistory && this.currentFolderId !== folderId) {
- this.backButtonHistory.push(this.currentFolderId);
-
+ // async navigateToFolder(folderId, recordHistory = true) {
+ async navigateToFolder(folderId) {
+ // if (recordHistory && this.currentFolderId !== folderId) {
+ // this.backButtonHistory.push(this.currentFolderId);
+
+ if (folderId === this.rootFolderId) {
+ console.log('루트 폴더로 이동');
+ console.log('rootFolderId:', this.rootFolderId);
+ // 루트 폴더일 경우, breadcrumb를 초기화
+ this.breadcrumb = [];
+ } else {
const selectedFolder = this.folderList.find(folder => folder.folderId === folderId);
// 선택한 폴더가 이미 breadcrumb에 있다면, 해당 폴더까지만 남기고 나머지 경로는 삭제
@@ -382,13 +410,13 @@ export default {
if (folderIndex !== -1) {
this.breadcrumb = this.breadcrumb.slice(0, folderIndex + 1);
} else if (selectedFolder) {
- // 새로운 폴더를 탐색하는 경우
this.breadcrumb.push({
folderId: selectedFolder.folderId,
folderName: selectedFolder.folderName,
});
}
}
+ // }
this.currentFolderId = folderId;
await this.refreshFolderList();
@@ -397,7 +425,7 @@ export default {
},
created() {
// this.currentFolderId = this.currentFolderId || 1;
- this.refreshFolderList();
+ this.loadChannelDrive();
},
};