mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
fix filemanager
This commit is contained in:
@@ -908,4 +908,5 @@ export interface FileItem {
|
|||||||
extension: string
|
extension: string
|
||||||
size: number
|
size: number
|
||||||
children: FileItem[]
|
children: FileItem[]
|
||||||
|
modify_time: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ const loading = ref(0)
|
|||||||
const activeStorage = ref('local')
|
const activeStorage = ref('local')
|
||||||
// 刷新
|
// 刷新
|
||||||
const refreshPending = ref(false)
|
const refreshPending = ref(false)
|
||||||
|
// 排序
|
||||||
|
const sort = ref('name')
|
||||||
// axios实例
|
// axios实例
|
||||||
const axiosInstance = ref<Axios>()
|
const axiosInstance = ref<Axios>()
|
||||||
|
|
||||||
@@ -83,6 +85,12 @@ function pathChanged(_path: string) {
|
|||||||
emit('pathchanged', _path)
|
emit('pathchanged', _path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 排序变化
|
||||||
|
function sortChanged(s: string) {
|
||||||
|
sort.value = s
|
||||||
|
refreshPending.value = true
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
activeStorage.value = props.storage ?? 'local'
|
activeStorage.value = props.storage ?? 'local'
|
||||||
@@ -101,6 +109,7 @@ onBeforeMount(() => {
|
|||||||
@storagechanged="storageChanged"
|
@storagechanged="storageChanged"
|
||||||
@pathchanged="pathChanged"
|
@pathchanged="pathChanged"
|
||||||
@foldercreated="refreshPending = true"
|
@foldercreated="refreshPending = true"
|
||||||
|
@sortchanged="sortChanged"
|
||||||
/>
|
/>
|
||||||
<VRow no-gutters>
|
<VRow no-gutters>
|
||||||
<VCol v-if="tree" sm="auto" class="d-none d-md-block">
|
<VCol v-if="tree" sm="auto" class="d-none d-md-block">
|
||||||
@@ -125,6 +134,7 @@ onBeforeMount(() => {
|
|||||||
:endpoints="endpoints"
|
:endpoints="endpoints"
|
||||||
:axios="axiosInstance"
|
:axios="axiosInstance"
|
||||||
:refreshpending="refreshPending"
|
:refreshpending="refreshPending"
|
||||||
|
:sort="sort"
|
||||||
@pathchanged="pathChanged"
|
@pathchanged="pathChanged"
|
||||||
@loading="loadingChanged"
|
@loading="loadingChanged"
|
||||||
@refreshed="refreshPending = false"
|
@refreshed="refreshPending = false"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const inProps = defineProps({
|
|||||||
endpoints: Object as PropType<EndPoints>,
|
endpoints: Object as PropType<EndPoints>,
|
||||||
axios: Object as PropType<Axios>,
|
axios: Object as PropType<Axios>,
|
||||||
refreshpending: Boolean,
|
refreshpending: Boolean,
|
||||||
|
sort: String,
|
||||||
})
|
})
|
||||||
|
|
||||||
// 对外事件
|
// 对外事件
|
||||||
@@ -125,18 +126,18 @@ const isImage = computed(() => {
|
|||||||
async function load() {
|
async function load() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
emit('loading', true)
|
emit('loading', true)
|
||||||
if (isDir.value) {
|
// 参数
|
||||||
const url = inProps.endpoints?.list.url
|
const url = inProps.endpoints?.list.url
|
||||||
.replace(/{storage}/g, storage.value)
|
.replace(/{storage}/g, storage.value)
|
||||||
.replace(/{path}/g, encodeURIComponent(inProps.path || ''))
|
.replace(/{path}/g, encodeURIComponent(inProps.path || ''))
|
||||||
|
.replace(/{sort}/g, inProps.sort || 'name')
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
url,
|
url,
|
||||||
method: inProps.endpoints?.list.method || 'get',
|
method: inProps.endpoints?.list.method || 'get',
|
||||||
}
|
|
||||||
// 加载数据
|
|
||||||
items.value = await axiosInstance.value.request(config) ?? []
|
|
||||||
}
|
}
|
||||||
|
// 加载数据
|
||||||
|
items.value = await axiosInstance.value.request(config) ?? []
|
||||||
emit('loading', false)
|
emit('loading', false)
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@@ -275,6 +276,11 @@ async function transfer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 将文件修改时间(timestape)转换为本地时间
|
||||||
|
function formatTime(timestape: number) {
|
||||||
|
return new Date(timestape * 1000).toLocaleString()
|
||||||
|
}
|
||||||
|
|
||||||
// 监听path变化
|
// 监听path变化
|
||||||
watch(
|
watch(
|
||||||
() => inProps.path,
|
() => inProps.path,
|
||||||
@@ -408,7 +414,9 @@ onMounted(() => {
|
|||||||
v-else-if="isFile && !isImage"
|
v-else-if="isFile && !isImage"
|
||||||
class="text-center break-all"
|
class="text-center break-all"
|
||||||
>
|
>
|
||||||
文件: {{ path }}
|
<strong>{{ items[0]?.name }}</strong><br>
|
||||||
|
大小:{{ formatBytes(items[0]?.size || 0) }}<br>
|
||||||
|
修改时间:{{ formatTime(items[0]?.modify_time || 0) }}
|
||||||
</VCardText>
|
</VCardText>
|
||||||
<VCardText
|
<VCardText
|
||||||
v-else-if="isFile && isImage"
|
v-else-if="isFile && isImage"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const inProps = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 对外事件
|
// 对外事件
|
||||||
const emit = defineEmits(['storagechanged', 'pathchanged', 'loading', 'foldercreated'])
|
const emit = defineEmits(['storagechanged', 'pathchanged', 'loading', 'foldercreated', 'sortchanged'])
|
||||||
|
|
||||||
// 新建文件夹名称
|
// 新建文件夹名称
|
||||||
const newFolderPopper = ref(false)
|
const newFolderPopper = ref(false)
|
||||||
@@ -20,6 +20,19 @@ const newFolderPopper = ref(false)
|
|||||||
// 新建文件名称
|
// 新建文件名称
|
||||||
const newFolderName = ref('')
|
const newFolderName = ref('')
|
||||||
|
|
||||||
|
// 排序方式
|
||||||
|
const sort = ref('name')
|
||||||
|
|
||||||
|
// 调整排序方式
|
||||||
|
function changeSort() {
|
||||||
|
if (sort.value === 'name')
|
||||||
|
sort.value = 'time'
|
||||||
|
else
|
||||||
|
sort.value = 'name'
|
||||||
|
|
||||||
|
emit('sortchanged', sort.value)
|
||||||
|
}
|
||||||
|
|
||||||
// 计算PATH面包屑
|
// 计算PATH面包屑
|
||||||
const pathSegments = computed(() => {
|
const pathSegments = computed(() => {
|
||||||
let path_str = ''
|
let path_str = ''
|
||||||
@@ -81,6 +94,14 @@ async function mkdir() {
|
|||||||
// 通知重新加载
|
// 通知重新加载
|
||||||
emit('foldercreated')
|
emit('foldercreated')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 计算排序图标
|
||||||
|
const sortIcon = computed(() => {
|
||||||
|
if (sort.value === 'time')
|
||||||
|
return 'mdi-sort-clock-ascending-outline'
|
||||||
|
else
|
||||||
|
return 'mdi-sort-alphabetical-ascending'
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -123,6 +144,9 @@ async function mkdir() {
|
|||||||
</template>
|
</template>
|
||||||
</VToolbarItems>
|
</VToolbarItems>
|
||||||
<div class="flex-grow-1" />
|
<div class="flex-grow-1" />
|
||||||
|
<IconBtn @click="changeSort">
|
||||||
|
<VIcon :icon="sortIcon" />
|
||||||
|
</IconBtn>
|
||||||
<IconBtn v-if="pathSegments.length > 0" @click="goUp">
|
<IconBtn v-if="pathSegments.length > 0" @click="goUp">
|
||||||
<VIcon icon="mdi-arrow-up-bold-outline" />
|
<VIcon icon="mdi-arrow-up-bold-outline" />
|
||||||
</IconBtn>
|
</IconBtn>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import api from '@/api'
|
|||||||
import FileBrowser from '@/components/FileBrowser.vue'
|
import FileBrowser from '@/components/FileBrowser.vue'
|
||||||
|
|
||||||
const endpoints = {
|
const endpoints = {
|
||||||
list: { url: '/filebrowser/list?path={path}', method: 'get' },
|
list: { url: '/filebrowser/list?path={path}&sort={sort}', method: 'get' },
|
||||||
mkdir: { url: '/filebrowser/mkdir?path={path}', method: 'get' },
|
mkdir: { url: '/filebrowser/mkdir?path={path}', method: 'get' },
|
||||||
delete: { url: '/filebrowser/delete?path={path}', method: 'get' },
|
delete: { url: '/filebrowser/delete?path={path}', method: 'get' },
|
||||||
download: { url: '/filebrowser/download?path={path}', method: 'get' },
|
download: { url: '/filebrowser/download?path={path}', method: 'get' },
|
||||||
|
|||||||
Reference in New Issue
Block a user