diff --git a/frontend/src/views/host/file-management/index.vue b/frontend/src/views/host/file-management/index.vue index 8d2ab12f7..266693bf7 100644 --- a/frontend/src/views/host/file-management/index.vue +++ b/frontend/src/views/host/file-management/index.vue @@ -253,7 +253,7 @@ - + {{ $t('tabs.more') }} @@ -614,7 +614,7 @@ const fileCreate = reactive({ path: '/', isDir: false, mode: 0o755 }); const fileCompress = reactive({ files: [''], name: '', dst: '', operate: 'compress' }); const fileDeCompress = reactive({ path: '', name: '', dst: '', mimeType: '' }); const fileEdit = reactive({ content: '', path: '', name: '', language: 'plaintext', extension: '' }); -const filePreview = reactive({ path: '', name: '', extension: '', fileType: '' }); +const filePreview = reactive({ path: '', name: '', extension: '', fileType: '', imageFiles: [] }); const codeReq = reactive({ path: '', expand: false, page: 1, pageSize: 100, isDetail: false }); const fileUpload = reactive({ path: '' }); const fileRename = reactive({ path: '', oldName: '' }); @@ -653,6 +653,7 @@ const disableBtn = ref(false); const calculateBtn = ref(false); const dirNum = ref(0); const fileNum = ref(0); +const imageFiles = ref([]); const { searchableStatus, searchablePath, searchableInputRef, searchableInputBlur } = useSearchable(paths); @@ -1034,6 +1035,12 @@ const openDeCompress = (item: File.File) => { const openView = (item: File.File) => { const fileType = getFileType(item.extension); + if (fileType === 'image') { + imageFiles.value = data.value + .filter((item) => !item.isDir) + .filter((item) => getFileType(item.extension) == 'image') + .map((item) => (item.isSymlink ? item.linkPath : item.path)); + } const previewTypes = ['image', 'video', 'audio', 'word', 'excel']; if (previewTypes.includes(fileType)) { @@ -1058,6 +1065,7 @@ const openPreview = (item: File.File, fileType: string) => { filePreview.name = item.name; filePreview.extension = item.extension; filePreview.fileType = fileType; + filePreview.imageFiles = imageFiles.value; previewRef.value.acceptParams(filePreview); }; @@ -1482,4 +1490,7 @@ onBeforeUnmount(() => { .search-button { width: 20vw; } +.el-button-group > .el-dropdown > .el-button { + border-left-color: var(--el-border-color); +} diff --git a/frontend/src/views/host/file-management/preview/index.vue b/frontend/src/views/host/file-management/preview/index.vue index f5d4e83c6..67e809e7b 100644 --- a/frontend/src/views/host/file-management/preview/index.vue +++ b/frontend/src/views/host/file-management/preview/index.vue @@ -15,44 +15,68 @@ {{ $t('commons.button.preview') + ' - ' + filePath }} - + + + - + -
-
- +
+ + - + - + - - - -
+
@@ -73,6 +97,7 @@ interface EditProps { path: string; name: string; extension: string; + imageFiles: []; } const open = ref(false); @@ -81,6 +106,7 @@ const filePath = ref(''); const fileName = ref(''); const fileType = ref(''); const fileUrl = ref(''); +const imageFiles = ref([]); const fileExtension = ref(''); const isFullscreen = ref(false); @@ -107,7 +133,15 @@ const toggleFullscreen = () => { isFullscreen.value = !isFullscreen.value; }; +const getDownloadUrl = (path: string) => { + const baseUrl = `${import.meta.env.VITE_API_URL as string}/files/download`; + const encodedPath = encodeURIComponent(path); + const timestamp = new Date().getTime(); + return `${baseUrl}?path=${encodedPath}×tamp=${timestamp}`; +}; + const acceptParams = (props: EditProps) => { + imageFiles.value = []; fileExtension.value = props.extension; fileName.value = props.name; filePath.value = props.path; @@ -115,15 +149,22 @@ const acceptParams = (props: EditProps) => { isFullscreen.value = fileType.value === 'excel'; loading.value = true; - fileUrl.value = `${import.meta.env.VITE_API_URL as string}/files/download?path=${encodeURIComponent( - props.path, - )}×tamp=${new Date().getTime()}`; + fileUrl.value = getDownloadUrl(props.path); + imageFiles.value = props.imageFiles.map((item) => ({ + path: item, + url: getDownloadUrl(item), + })); open.value = true; loading.value = false; }; const onOpen = () => {}; +const changeImg = (path: string) => { + filePath.value = path; + fileUrl.value = getDownloadUrl(path); +}; + defineExpose({ acceptParams }); @@ -135,4 +176,16 @@ defineExpose({ acceptParams }); .dialog-header-icon { color: var(--el-color-info); } +.left-aside { + background-color: var(--panel-menu-bg-color); + opacity: 85%; +} +.left-item { + &:hover { + background: var(--el-menu-item-bg-color-active) !important; + } +} +.left-item-default { + background: var(--el-menu-item-bg-color-active) !important; +}