diff --git a/packages/client/src/components/drive.vue b/packages/client/src/components/drive.vue index 02d46f185..10f0be183 100644 --- a/packages/client/src/components/drive.vue +++ b/packages/client/src/components/drive.vue @@ -35,27 +35,35 @@ @drop.prevent.stop="onDrop" @contextmenu.stop="onContextmenu" > -
- - + + - +
@@ -145,13 +116,7 @@ const emit = defineEmits<{ (ev: 'open-folder', v: foundkey.entities.DriveFolder): void; }>(); -let foldersPaginationElem = $ref>(); -let filesPaginationElem = $ref>(); - -let foldersLoading = $ref(true); -let filesLoading = $ref(true); -const empty = $computed(() => !foldersLoading && !filesLoading - && foldersPaginationElem?.items.length === 0 && filesPaginationElem?.items.length === 0); +let paginationElem = $ref>(); let fileInput = $ref(); @@ -434,10 +399,6 @@ function chooseFolder(folderToChoose: foundkey.entities.DriveFolder) { } function move(target?: string | foundkey.entities.DriveFolder) { - // reset loading state - foldersLoading = true; - filesLoading = true; - if (!target) { goRoot(); return; @@ -466,13 +427,13 @@ function addFolder(folderToAdd: foundkey.entities.DriveFolder, unshift = false) const current = folder?.id ?? null; if (current !== folderToAdd.parentId) return; - const exist = foldersPaginationElem.items.some(f => f.id === folderToAdd.id); + const exist = paginationElem.items.some(f => f.id === folderToAdd.id); if (exist) { - foldersPaginationElem.updateItem(folderToAdd.id, () => folderToAdd); + paginationElem.updateItem(folderToAdd.id, () => folderToAdd); } else if (unshift) { - foldersPaginationElem.prepend(folderToAdd); + paginationElem.prepend(folderToAdd); } else { - foldersPaginationElem.append(folderToAdd); + paginationElem.append(folderToAdd); } } @@ -480,24 +441,24 @@ function addFile(fileToAdd: foundkey.entities.DriveFile, unshift = false) { const current = folder?.id ?? null; if (current !== fileToAdd.folderId) return; - const exist = filesPaginationElem.items.some(f => f.id === fileToAdd.id); + const exist = paginationElem.items.some(f => f.id === fileToAdd.id); if (exist) { - filesPaginationElem.updateItem(fileToAdd.id, () => fileToAdd); + paginationElem.updateItem(fileToAdd.id, () => fileToAdd); } else if (unshift) { - filesPaginationElem.prepend(fileToAdd); + paginationElem.prepend(fileToAdd); } else { - filesPaginationElem.append(fileToAdd); + paginationElem.append(fileToAdd); } } function removeFolder(folderToRemove: foundkey.entities.DriveFolder | string): void { const folderIdToRemove = typeof folderToRemove === 'object' ? folderToRemove.id : folderToRemove; - foldersPaginationElem.removeItem(item => item.id === folderIdToRemove); + paginationElem.removeItem(item => item.id === folderIdToRemove); } function removeFile(fileToRemove: foundkey.entities.DriveFile | string): void { const fileIdToRemove = typeof fileToRemove === 'object' ? fileToRemove.id : fileToRemove; - filesPaginationElem.removeItem(item => item.id === fileIdToRemove); + paginationElem.removeItem(item => item.id === fileIdToRemove); } function goRoot() { @@ -509,23 +470,14 @@ function goRoot() { emit('move-root'); } -const foldersPagination = { - endpoint: 'drive/folders' as const, +const pagination = { + endpoint: 'drive/show' as const, limit: 30, params: computed(() => ({ folderId: folder?.id ?? null, })), }; -const filesPagination = { - endpoint: 'drive/files' as const, - limit: 30, - params: computed(() => ({ - folderId: folder?.id ?? null, - type: props.type, - })), -}; - function getMenu() { return [{ type: 'switch', @@ -669,37 +621,23 @@ onBeforeUnmount(() => { } > .contents { + display: flex; + flex-wrap: wrap; - > .folders, - > .files { - display: flex; - flex-wrap: wrap; - - > .folder, - > .file { - flex-grow: 1; - width: 128px; - margin: 4px; - box-sizing: border-box; - } - - > .padding { - flex-grow: 1; - pointer-events: none; - width: 128px + 8px; - } + > .item { + flex-grow: 1; + width: 128px; + margin: 4px; + box-sizing: border-box; } + } - > .empty { - padding: 16px; - text-align: center; - pointer-events: none; - opacity: 0.5; - - > p { - margin: 0; - } - } + > .empty { + padding: 16px; + text-align: center; + pointer-events: none; + opacity: 0.5; + margin: 0; } }