fix:优化文件管理性能

This commit is contained in:
jxxghp
2024-04-06 09:25:46 +08:00
parent 0e161b1735
commit 1e1117b187
3 changed files with 115 additions and 110 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ $layout-horizontal-nav-layout-navbar-z-index: 11 !default;
$layout-boxed-content-width: 90rem !default; $layout-boxed-content-width: 90rem !default;
// 👉Footer // 👉Footer
$layout-vertical-nav-footer-height: 3.5rem !default; $layout-vertical-nav-footer-height: 0rem !default;
// 👉 Layout overlay // 👉 Layout overlay
$layout-overlay-z-index: 11 !default; $layout-overlay-z-index: 11 !default;
+9 -8
View File
@@ -10,7 +10,6 @@ import type { Context, EndPoints, FileItem } from '@/api/types'
import store from '@/store' import store from '@/store'
import api from '@/api' import api from '@/api'
import MediaInfoCard from '@/components/cards/MediaInfoCard.vue' import MediaInfoCard from '@/components/cards/MediaInfoCard.vue'
import { useDefer } from '@/@core/utils/dom'
// 输入参数 // 输入参数
const inProps = defineProps({ const inProps = defineProps({
@@ -75,7 +74,7 @@ const nameTestResult = ref<Context>()
const nameTestDialog = ref(false) const nameTestDialog = ref(false)
// 延迟加载 // 延迟加载
let defer = (_: number) => true const defer = (_: number) => true
// 目录过滤 // 目录过滤
const dirs = computed(() => const dirs = computed(() =>
@@ -115,7 +114,6 @@ async function load() {
} }
// 加载数据 // 加载数据
items.value = await axiosInstance.value.request(config) ?? [] items.value = await axiosInstance.value.request(config) ?? []
defer = useDefer(items.value.length)
emit('loading', false) emit('loading', false)
loading.value = false loading.value = false
} }
@@ -410,13 +408,11 @@ onMounted(() => {
</VCardText> </VCardText>
<VCardText v-else-if="dirs.length || files.length" class="p-0"> <VCardText v-else-if="dirs.length || files.length" class="p-0">
<VList subheader> <VList subheader>
<VHover <VVirtualScroll class="virtual-scroll-div" :items="[...dirs, ...files]">
v-for="(item, index) in [...dirs, ...files]" <template #default="{ item }">
:key="index" <VHover>
>
<template #default="hover"> <template #default="hover">
<VListItem <VListItem
v-if="defer(index)"
v-bind="hover.props" v-bind="hover.props"
class="px-3 pe-1" class="px-3 pe-1"
@click="changePath(item.path)" @click="changePath(item.path)"
@@ -495,6 +491,8 @@ onMounted(() => {
</VListItem> </VListItem>
</template> </template>
</VHover> </VHover>
</template>
</VVirtualScroll>
</VList> </VList>
</VCardText> </VCardText>
<VCardText <VCardText
@@ -583,4 +581,7 @@ onMounted(() => {
.v-toolbar{ .v-toolbar{
background: rgb(var(--v-table-header-background)); background: rgb(var(--v-table-header-background));
} }
.virtual-scroll-div {
height: calc(100vh - 230px);
}
</style> </style>
+29 -25
View File
@@ -311,31 +311,6 @@ fixArrayAt()
</script> </script>
<template> <template>
<!-- 底部操作按钮 -->
<span>
<VFab
v-if="selected.length > 0"
icon="mdi-trash-can-outline"
color="error"
location="bottom end"
size="x-large"
fixed
app
appear
@click="removeHistoryBatch"
/>
<VFab
v-if="selected.length > 0"
class="mb-2"
icon="mdi-redo-variant"
location="bottom end"
size="x-large"
fixed
app
appear
@click="retransferBatch"
/>
</span>
<VCard class="pb-5"> <VCard class="pb-5">
<VCardItem> <VCardItem>
<VCardTitle> <VCardTitle>
@@ -379,6 +354,7 @@ fixArrayAt()
items-per-page-text="每页条数" items-per-page-text="每页条数"
page-text="{0}-{1} {2} " page-text="{0}-{1} {2} "
loading-text="加载中..." loading-text="加载中..."
class="data-table-div"
@update:options="fetchData" @update:options="fetchData"
> >
<template #item.title="{ item }"> <template #item.title="{ item }">
@@ -486,10 +462,38 @@ fixArrayAt()
" "
@close="redoDialog = false" @close="redoDialog = false"
/> />
<!-- 底部操作按钮 -->
<span>
<VFab
v-if="selected.length > 0"
icon="mdi-trash-can-outline"
color="error"
location="bottom end"
size="x-large"
fixed
app
appear
@click="removeHistoryBatch"
/>
<VFab
v-if="selected.length > 0"
class="mb-2"
icon="mdi-redo-variant"
location="bottom end"
size="x-large"
fixed
app
appear
@click="retransferBatch"
/>
</span>
</template> </template>
<style lang="scss"> <style lang="scss">
.v-table th { .v-table th {
white-space: nowrap; white-space: nowrap;
} }
.data-table-div {
height: calc(100vh - 200px);
}
</style> </style>