mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-18 21:27:35 +08:00
refactor: Update FileBrowser.vue and FileBrowserView.vue to support multiple storage configurations
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
import type { Axios } from 'axios'
|
||||
import FileList from './filebrowser/FileList.vue'
|
||||
import FileToolbar from './filebrowser/FileToolbar.vue'
|
||||
import type { EndPoints, FileItem } from '@/api/types'
|
||||
import type { EndPoints, FileItem, StorageConf } from '@/api/types'
|
||||
|
||||
// 输入参数
|
||||
const props = defineProps({
|
||||
storages: String,
|
||||
storages: Array as PropType<StorageConf[]>,
|
||||
tree: Boolean,
|
||||
endpoints: Object as PropType<EndPoints>,
|
||||
axios: {
|
||||
@@ -83,7 +83,7 @@ const sort = ref('name')
|
||||
|
||||
// 计算属性
|
||||
const storagesArray = computed(() => {
|
||||
const storageCodes = props.storages?.split(',')
|
||||
const storageCodes = props.storages?.map(item => item.type)
|
||||
return availableStorages.filter(item => storageCodes?.includes(item.code))
|
||||
})
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import api from '@/api'
|
||||
import { FileItem, TransferDirectoryConf } from '@/api/types'
|
||||
import { FileItem, StorageConf, TransferDirectoryConf } from '@/api/types'
|
||||
import FileBrowser from '@/components/FileBrowser.vue'
|
||||
import store from '@/store'
|
||||
|
||||
const endpoints = {
|
||||
list: {
|
||||
@@ -31,10 +30,19 @@ const endpoints = {
|
||||
},
|
||||
}
|
||||
|
||||
const user_level = store.state.auth.level
|
||||
// 所有存储
|
||||
const storages = ref<StorageConf[]>([])
|
||||
|
||||
// 用户存储
|
||||
const userStorage = user_level > 1 ? 'local,alipan,u115' : 'local'
|
||||
// 查询存储
|
||||
async function loadStorages() {
|
||||
try {
|
||||
const result: { [key: string]: any } = await api.get('system/setting/Storages')
|
||||
|
||||
storages.value = result.data?.value ?? []
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
// 当前文件项
|
||||
const operItem = ref<FileItem>({
|
||||
@@ -149,12 +157,16 @@ function pathChanged(item: FileItem) {
|
||||
|
||||
// 加载初始目录
|
||||
onBeforeMount(loadDownloadDirectories)
|
||||
|
||||
onMounted(() => {
|
||||
loadStorages()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<FileBrowser
|
||||
:storages="userStorage"
|
||||
:storages="storages"
|
||||
:tree="false"
|
||||
:itemstack="itemstack"
|
||||
:endpoints="endpoints"
|
||||
|
||||
Reference in New Issue
Block a user