mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-07 00:36:41 +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 type { Axios } from 'axios'
|
||||||
import FileList from './filebrowser/FileList.vue'
|
import FileList from './filebrowser/FileList.vue'
|
||||||
import FileToolbar from './filebrowser/FileToolbar.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({
|
const props = defineProps({
|
||||||
storages: String,
|
storages: Array as PropType<StorageConf[]>,
|
||||||
tree: Boolean,
|
tree: Boolean,
|
||||||
endpoints: Object as PropType<EndPoints>,
|
endpoints: Object as PropType<EndPoints>,
|
||||||
axios: {
|
axios: {
|
||||||
@@ -83,7 +83,7 @@ const sort = ref('name')
|
|||||||
|
|
||||||
// 计算属性
|
// 计算属性
|
||||||
const storagesArray = computed(() => {
|
const storagesArray = computed(() => {
|
||||||
const storageCodes = props.storages?.split(',')
|
const storageCodes = props.storages?.map(item => item.type)
|
||||||
return availableStorages.filter(item => storageCodes?.includes(item.code))
|
return availableStorages.filter(item => storageCodes?.includes(item.code))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import { FileItem, TransferDirectoryConf } from '@/api/types'
|
import { FileItem, StorageConf, TransferDirectoryConf } from '@/api/types'
|
||||||
import FileBrowser from '@/components/FileBrowser.vue'
|
import FileBrowser from '@/components/FileBrowser.vue'
|
||||||
import store from '@/store'
|
|
||||||
|
|
||||||
const endpoints = {
|
const endpoints = {
|
||||||
list: {
|
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>({
|
const operItem = ref<FileItem>({
|
||||||
@@ -149,12 +157,16 @@ function pathChanged(item: FileItem) {
|
|||||||
|
|
||||||
// 加载初始目录
|
// 加载初始目录
|
||||||
onBeforeMount(loadDownloadDirectories)
|
onBeforeMount(loadDownloadDirectories)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadStorages()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<FileBrowser
|
<FileBrowser
|
||||||
:storages="userStorage"
|
:storages="storages"
|
||||||
:tree="false"
|
:tree="false"
|
||||||
:itemstack="itemstack"
|
:itemstack="itemstack"
|
||||||
:endpoints="endpoints"
|
:endpoints="endpoints"
|
||||||
|
|||||||
Reference in New Issue
Block a user