From aaf5e7f49d7ff56895e5fbb28500d54a5882f51f Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 20 Jun 2024 13:16:05 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E9=98=BF=E9=87=8C=E4=BA=91?= =?UTF-8?q?=E7=9B=98=E6=94=AF=E6=8C=81=E5=A4=87=E4=BB=BD=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/types.ts | 2 ++ src/components/FileBrowser.vue | 4 ++-- src/components/filebrowser/FileToolbar.vue | 24 ++++++++-------------- src/views/reorganize/FileBrowserView.vue | 22 ++++++++++++-------- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/api/types.ts b/src/api/types.ts index 71f26839..33a6507c 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -765,6 +765,8 @@ export interface FileItem { thumbnail?: string // pickcode pickcode?: string + // drive_id + drive_id?: string } // 媒体服务器播放条目 diff --git a/src/components/FileBrowser.vue b/src/components/FileBrowser.vue index 0766e438..69af7667 100644 --- a/src/components/FileBrowser.vue +++ b/src/components/FileBrowser.vue @@ -22,7 +22,7 @@ const props = defineProps({ type: Object as PropType, required: true, }, - fileidstack: Array as PropType, + itemstack: Array as PropType, }) // 对外事件 @@ -169,7 +169,7 @@ function u115AuthDone() {
, required: true, }, - fileidstack: { - type: Array as PropType, - default: () => [], + itemstack: { + type: Array as PropType, + required: true, }, endpoints: Object as PropType, axios: { @@ -50,14 +50,12 @@ const pathSegments = computed(() => { let path_str = '' const isFolder = inProps.item.path?.endsWith('/') const segments = inProps.item.path?.split('/').filter(item => item) - const fileids = inProps.fileidstack ?? [] return ( segments?.map((item, index) => { path_str += item + (index < segments.length - 1 || isFolder ? '/' : '') return { name: item, path: path_str, - fileid: fileids[index], } }) ?? [] ) @@ -76,19 +74,15 @@ function changeStorage(code: string) { } // 路径变化 -function changePath(_path: string, _fileid: string) { - emit('pathchanged', { - path: _path, - fileid: _fileid, - }) +function changePath(item: FileItem) { + emit('pathchanged', item) } // 返回上一级 function goUp() { const segments = pathSegments.value ?? [] - const path = segments?.length === 1 ? '/' : segments[segments.length - 2].path - const fileid = segments?.length === 1 ? 'root' : segments[segments.length - 1].fileid - changePath(path, fileid) + const fileitem = inProps.itemstack[segments.length - 1] + changePath(fileitem) } // 创建目录 @@ -145,7 +139,7 @@ const sortIcon = computed(() => { - + {{ storageObject?.name }} @@ -155,7 +149,7 @@ const sortIcon = computed(() => { variant="text" :input-value="index === pathSegments.length - 1" class="px-1" - @click="changePath(segment.path, inProps.fileidstack[index + 1])" + @click="changePath(inProps.itemstack[index + 1])" > {{ segment.name }} diff --git a/src/views/reorganize/FileBrowserView.vue b/src/views/reorganize/FileBrowserView.vue index d1cd6c00..40ec8938 100644 --- a/src/views/reorganize/FileBrowserView.vue +++ b/src/views/reorganize/FileBrowserView.vue @@ -45,7 +45,14 @@ const operItem = ref({ }) // fileid的堆栈 -const fileidstack = ref(['root']) +const itemstack = ref([ + { + type: 'dir', + name: '/', + path: '/', + fileid: 'root', + }, +]) // 下载目录列表 const downloadDirectories = ref([]) @@ -106,12 +113,11 @@ async function loadDownloadDirectories() { // 目录变化 function pathChanged(item: FileItem) { operItem.value = item - if (item.fileid) { - if (fileidstack.value.includes(item.fileid)) { - fileidstack.value = fileidstack.value.slice(0, fileidstack.value.indexOf(item.fileid) + 1) - } else { - fileidstack.value.push(item.fileid) - } + const index = itemstack.value.findIndex(i => i.path === item.path) + if (index >= 0) { + itemstack.value = itemstack.value.slice(0, index + 1) + } else { + itemstack.value.push(item) } } @@ -124,7 +130,7 @@ onBeforeMount(loadDownloadDirectories)