feat:阿里云盘支持备份盘

This commit is contained in:
jxxghp
2024-06-20 13:16:05 +08:00
parent 6a5958409a
commit aaf5e7f49d
4 changed files with 27 additions and 25 deletions

View File

@@ -765,6 +765,8 @@ export interface FileItem {
thumbnail?: string
// pickcode
pickcode?: string
// drive_id
drive_id?: string
}
// 媒体服务器播放条目

View File

@@ -22,7 +22,7 @@ const props = defineProps({
type: Object as PropType<FileItem>,
required: true,
},
fileidstack: Array as PropType<string[]>,
itemstack: Array as PropType<FileItem[]>,
})
// 对外事件
@@ -169,7 +169,7 @@ function u115AuthDone() {
<div v-if="activeStorage && item">
<FileToolbar
:item="item"
:fileidstack="fileidstack"
:itemstack="itemstack"
:storages="storagesArray"
:storage="activeStorage"
:endpoints="endpoints"

View File

@@ -14,9 +14,9 @@ const inProps = defineProps({
type: Object as PropType<FileItem>,
required: true,
},
fileidstack: {
type: Array as PropType<string[]>,
default: () => [],
itemstack: {
type: Array as PropType<FileItem[]>,
required: true,
},
endpoints: Object as PropType<EndPoints>,
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(() => {
</VListItem>
</VList>
</VMenu>
<VBtn variant="text" :input-value="item.path === '/'" class="px-1" @click="changePath('/', 'root')">
<VBtn variant="text" :input-value="item.path === '/'" class="px-1" @click="changePath(inProps.itemstack[0])">
<VIcon :icon="storageObject?.icon" class="mr-2" />
{{ storageObject?.name }}
</VBtn>
@@ -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])"
>
<VIcon icon=" mdi-chevron-right" />
{{ segment.name }}

View File

@@ -45,7 +45,14 @@ const operItem = ref<FileItem>({
})
// fileid的堆栈
const fileidstack = ref<string[]>(['root'])
const itemstack = ref<FileItem[]>([
{
type: 'dir',
name: '/',
path: '/',
fileid: 'root',
},
])
// 下载目录列表
const downloadDirectories = ref<MediaDirectory[]>([])
@@ -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)
<FileBrowser
:storages="userStorage"
:tree="false"
:fileidstack="fileidstack"
:itemstack="itemstack"
:endpoints="endpoints"
:axios="api"
:item="operItem"