diff --git a/ui/components.d.ts b/ui/components.d.ts index 690a594e..0f60f39e 100644 --- a/ui/components.d.ts +++ b/ui/components.d.ts @@ -42,6 +42,7 @@ declare module 'vue' { NNotificationProvider: typeof import('naive-ui')['NNotificationProvider'] NPopconfirm: typeof import('naive-ui')['NPopconfirm'] NPopover: typeof import('naive-ui')['NPopover'] + NPopselect: typeof import('naive-ui')['NPopselect'] NScrollbar: typeof import('naive-ui')['NScrollbar'] NSelect: typeof import('naive-ui')['NSelect'] NSpin: typeof import('naive-ui')['NSpin'] diff --git a/ui/src/components/Drawer/components/FileManagement/index.vue b/ui/src/components/Drawer/components/FileManagement/index.vue index 42373a04..43335d09 100644 --- a/ui/src/components/Drawer/components/FileManagement/index.vue +++ b/ui/src/components/Drawer/components/FileManagement/index.vue @@ -1,14 +1,14 @@ @@ -189,13 +187,6 @@ const columns = createColumns(); - - diff --git a/ui/src/components/Drawer/components/FileManagement/widget/index.vue b/ui/src/components/Drawer/components/FileManagement/widget/index.vue index f4e4f53b..4a6bde7f 100644 --- a/ui/src/components/Drawer/components/FileManagement/widget/index.vue +++ b/ui/src/components/Drawer/components/FileManagement/widget/index.vue @@ -3,8 +3,7 @@ import type { DataTableColumns, DropdownOption, UploadCustomRequestOptions, Uplo import { useI18n } from 'vue-i18n'; import { NText, useMessage } from 'naive-ui'; -import { useWindowSize } from '@vueuse/core'; -import { computed, h, nextTick, onActivated, onBeforeUnmount, onMounted, provide, ref, watch } from 'vue'; +import { computed, h, nextTick, onActivated, onBeforeUnmount, onMounted, provide, ref, watch, watchEffect } from 'vue'; import { ChevronLeft, ChevronRight, @@ -36,11 +35,13 @@ export interface IFilePath { showArrow: boolean; } -withDefaults( +const props = withDefaults( defineProps<{ + fileList: FileManageSftpFileItem[]; columns?: DataTableColumns; }>(), { + fileList: () => [], columns: () => [], } ); @@ -48,7 +49,6 @@ withDefaults( const { t } = useI18n(); const message = useMessage(); const fileManageStore = useFileManageStore(); -const { height: _windowHeight } = useWindowSize(); const options: DropdownOption[] = [ { @@ -81,7 +81,6 @@ const newFileName = ref(''); const searchValue = ref(''); const modalContent = ref(''); const loading = ref(true); -const showInner = ref(false); const showModal = ref(false); const showDropdown = ref(false); const isShowUploadList = ref(false); @@ -89,7 +88,6 @@ const disabledBack = ref(true); const disabledForward = ref(true); const scrollRef = ref(null); -const dataList = ref([]); const filePathList = ref([]); const currentRowData = ref>({}); @@ -97,108 +95,107 @@ const persistedUploadFiles = ref([]); const uploadFileList = ref([]); const stopUploadFile = ref(); -const _tableHeight = computed(() => { - if (!uploadFileList.value || uploadFileList.value.length === 0) { - return 240; +watchEffect(() => { + if (props.fileList.length > 0) { + loading.value = false; } - return 300; }); -watch( - () => fileManageStore.currentPath, - newPath => { - if (newPath) { - // 重置现有路径列表 - filePathList.value = []; - - if (newPath === '/') { - disabledBack.value = true; - return; - } - - if (fileManageStore.currentPath === forwardPath.value) { - disabledForward.value = true; - } - - // 分割路径 - const pathSegments = newPath.split('/').filter(segment => segment); - - // 根据路径段构建完整的路径列表 - let currentPath = ''; - pathSegments.forEach((segment, index) => { - // 更新当前路径 - currentPath += `/${segment}`; - - // 添加到路径列表 - filePathList.value.push({ - id: currentPath, // 使用完整路径作为ID - path: segment, // 显示路径段名称 - active: index === pathSegments.length - 1, - showArrow: index !== pathSegments.length - 1, - }); - }); - - // 滚动到最后一个路径段 - nextTick(() => { - const contentRef = document.getElementsByClassName('n-scrollbar-content')[2]; - if (scrollRef.value && contentRef) { - // @ts-expect-error 目标对象滚动 - scrollRef.value.scrollTo({ - left: contentRef.scrollWidth, - behavior: 'smooth', - }); - } - }); - } - }, - { - immediate: true, - } -); - -watch( - () => forwardPath.value, - (newPath, oldPath) => { - if (oldPath && (oldPath === newPath || oldPath.startsWith(`${newPath}/`))) { - // 如果 oldPath 包含 newPath,则重置 forwardPath 为 oldPath - forwardPath.value = oldPath; - } - } -); - -watch( - () => fileManageStore.fileList, - newFileList => { - if (newFileList) { - loading.value = false; - dataList.value = newFileList; - } - }, - { - immediate: true, - } -); - -watch( - () => uploadFileList.value, - newValue => { - if (newValue && newValue.length > 0) { - persistedUploadFiles.value = [...newValue]; - } - }, - { deep: true } -); - -watch( - () => searchValue.value, - (newVal: string) => { - if (newVal) { - dataList.value = fileManageStore.fileList!.filter(item => item.name.toLowerCase().includes(newVal.toLowerCase())); - } else { - dataList.value = fileManageStore.fileList!; - } - } -); +// watch( +// () => fileManageStore.currentPath, +// newPath => { +// if (newPath) { +// // 重置现有路径列表 +// filePathList.value = []; + +// if (newPath === '/') { +// disabledBack.value = true; +// return; +// } + +// if (fileManageStore.currentPath === forwardPath.value) { +// disabledForward.value = true; +// } + +// // 分割路径 +// const pathSegments = newPath.split('/').filter(segment => segment); + +// // 根据路径段构建完整的路径列表 +// let currentPath = ''; +// pathSegments.forEach((segment, index) => { +// // 更新当前路径 +// currentPath += `/${segment}`; + +// // 添加到路径列表 +// filePathList.value.push({ +// id: currentPath, // 使用完整路径作为ID +// path: segment, // 显示路径段名称 +// active: index === pathSegments.length - 1, +// showArrow: index !== pathSegments.length - 1, +// }); +// }); + +// // 滚动到最后一个路径段 +// nextTick(() => { +// const contentRef = document.getElementsByClassName('n-scrollbar-content')[2]; +// if (scrollRef.value && contentRef) { +// // @ts-expect-error 目标对象滚动 +// scrollRef.value.scrollTo({ +// left: contentRef.scrollWidth, +// behavior: 'smooth', +// }); +// } +// }); +// } +// }, +// { +// immediate: true, +// } +// ); + +// watch( +// () => forwardPath.value, +// (newPath, oldPath) => { +// if (oldPath && (oldPath === newPath || oldPath.startsWith(`${newPath}/`))) { +// // 如果 oldPath 包含 newPath,则重置 forwardPath 为 oldPath +// forwardPath.value = oldPath; +// } +// } +// ); + +// watch( +// () => fileManageStore.fileList, +// newFileList => { +// if (newFileList) { +// loading.value = false; +// dataList.value = newFileList; +// } +// }, +// { +// immediate: true, +// } +// ); + +// watch( +// () => uploadFileList.value, +// newValue => { +// if (newValue && newValue.length > 0) { +// persistedUploadFiles.value = [...newValue]; +// } +// }, +// { deep: true } +// ); + +// watch( +// () => searchValue.value, +// (newVal: string) => { +// if (newVal) { +// dataList.value = fileManageStore.fileList!.filter(item => item.name.toLowerCase().includes(newVal.toLowerCase())); +// } else { +// dataList.value = fileManageStore.fileList!; +// } +// } +// ); const onClickOutside = () => { showDropdown.value = false; @@ -216,7 +213,7 @@ const handleRemoveItem = (data: { file: UploadFileInfo; fileList: UploadFileInfo // 对于上传失败、已完成或其他状态的文件,允许直接移除 uploadFileList.value = fileList.filter(item => item.id !== file.id); - fileManageStore.setUploadFileList(uploadFileList.value); + // fileManageStore.setUploadFileList(uploadFileList.value); return true; }; @@ -244,11 +241,11 @@ const handleSelect = (key: string) => { break; } case 'download': { - mittBus.emit('download-file', { - path: `${fileManageStore.currentPath}/${currentRowData?.value?.name as string}`, - is_dir: currentRowData.value.is_dir!, - size: currentRowData.value.size!, - }); + // mittBus.emit('download-file', { + // path: `${fileManageStore.currentPath}/${currentRowData?.value?.name as string}`, + // is_dir: currentRowData.value.is_dir!, + // size: currentRowData.value.size!, + // }); break; } @@ -439,11 +436,6 @@ const handleUploadFileChange = (options: { fileList: Array }) => if (options.fileList.length > 0) { uploadFileList.value = options.fileList; fileManageStore.setUploadFileList(options.fileList); - - // 使用 nextTick 确保数据更新后再打开抽屉 - nextTick(() => { - showInner.value = true; - }); } }; @@ -474,18 +466,6 @@ const customRequest = ({ file, onFinish, onError, onProgress }: UploadCustomRequ }); }; -/** - * @description 打开传输历史列表 - */ -// const handleOpenTransferList = () => { -// 从 store 中恢复文件列表 -// uploadFileList.value = [...fileManageStore.uploadFileList]; - -// nextTick(() => { -// showInner.value = true; -// }); -// }; - const modalNegativeClick = () => { newFileName.value = ''; }; @@ -673,50 +653,8 @@ provide('persistedUploadFiles', persistedUploadFiles); - - - -