mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-12 21:38:43 +08:00
parent
7f823ecd7c
commit
4074b94800
2 changed files with 101 additions and 37 deletions
|
|
@ -253,7 +253,7 @@
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<el-dropdown class="mr-2.5" style="border-left: 1px solid #ccc">
|
<el-dropdown class="mr-2.5">
|
||||||
<el-button class="btn">
|
<el-button class="btn">
|
||||||
{{ hostMount[0]?.path }} ({{ $t('file.root') }})
|
{{ hostMount[0]?.path }} ({{ $t('file.root') }})
|
||||||
{{ formatFileSize(hostMount[0]?.free) }}
|
{{ formatFileSize(hostMount[0]?.free) }}
|
||||||
|
|
@ -314,7 +314,7 @@
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-dropdown v-if="moreButtons.length" style="border-left: 1px solid #ccc">
|
<el-dropdown v-if="moreButtons.length">
|
||||||
<el-button>
|
<el-button>
|
||||||
{{ $t('tabs.more') }}
|
{{ $t('tabs.more') }}
|
||||||
<i class="el-icon-arrow-down el-icon--right" />
|
<i class="el-icon-arrow-down el-icon--right" />
|
||||||
|
|
@ -614,7 +614,7 @@ const fileCreate = reactive({ path: '/', isDir: false, mode: 0o755 });
|
||||||
const fileCompress = reactive({ files: [''], name: '', dst: '', operate: 'compress' });
|
const fileCompress = reactive({ files: [''], name: '', dst: '', operate: 'compress' });
|
||||||
const fileDeCompress = reactive({ path: '', name: '', dst: '', mimeType: '' });
|
const fileDeCompress = reactive({ path: '', name: '', dst: '', mimeType: '' });
|
||||||
const fileEdit = reactive({ content: '', path: '', name: '', language: 'plaintext', extension: '' });
|
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 codeReq = reactive({ path: '', expand: false, page: 1, pageSize: 100, isDetail: false });
|
||||||
const fileUpload = reactive({ path: '' });
|
const fileUpload = reactive({ path: '' });
|
||||||
const fileRename = reactive({ path: '', oldName: '' });
|
const fileRename = reactive({ path: '', oldName: '' });
|
||||||
|
|
@ -653,6 +653,7 @@ const disableBtn = ref(false);
|
||||||
const calculateBtn = ref(false);
|
const calculateBtn = ref(false);
|
||||||
const dirNum = ref(0);
|
const dirNum = ref(0);
|
||||||
const fileNum = ref(0);
|
const fileNum = ref(0);
|
||||||
|
const imageFiles = ref([]);
|
||||||
|
|
||||||
const { searchableStatus, searchablePath, searchableInputRef, searchableInputBlur } = useSearchable(paths);
|
const { searchableStatus, searchablePath, searchableInputRef, searchableInputBlur } = useSearchable(paths);
|
||||||
|
|
||||||
|
|
@ -1034,6 +1035,12 @@ const openDeCompress = (item: File.File) => {
|
||||||
|
|
||||||
const openView = (item: File.File) => {
|
const openView = (item: File.File) => {
|
||||||
const fileType = getFileType(item.extension);
|
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'];
|
const previewTypes = ['image', 'video', 'audio', 'word', 'excel'];
|
||||||
if (previewTypes.includes(fileType)) {
|
if (previewTypes.includes(fileType)) {
|
||||||
|
|
@ -1058,6 +1065,7 @@ const openPreview = (item: File.File, fileType: string) => {
|
||||||
filePreview.name = item.name;
|
filePreview.name = item.name;
|
||||||
filePreview.extension = item.extension;
|
filePreview.extension = item.extension;
|
||||||
filePreview.fileType = fileType;
|
filePreview.fileType = fileType;
|
||||||
|
filePreview.imageFiles = imageFiles.value;
|
||||||
|
|
||||||
previewRef.value.acceptParams(filePreview);
|
previewRef.value.acceptParams(filePreview);
|
||||||
};
|
};
|
||||||
|
|
@ -1482,4 +1490,7 @@ onBeforeUnmount(() => {
|
||||||
.search-button {
|
.search-button {
|
||||||
width: 20vw;
|
width: 20vw;
|
||||||
}
|
}
|
||||||
|
.el-button-group > .el-dropdown > .el-button {
|
||||||
|
border-left-color: var(--el-border-color);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -15,22 +15,47 @@
|
||||||
<span>{{ $t('commons.button.preview') + ' - ' + filePath }}</span>
|
<span>{{ $t('commons.button.preview') + ' - ' + filePath }}</span>
|
||||||
<el-space alignment="center" :size="10" class="dialog-header-icon">
|
<el-space alignment="center" :size="10" class="dialog-header-icon">
|
||||||
<el-tooltip :content="loadTooltip()" placement="top" v-if="fileType !== 'excel'">
|
<el-tooltip :content="loadTooltip()" placement="top" v-if="fileType !== 'excel'">
|
||||||
<el-icon @click="toggleFullscreen"><FullScreen /></el-icon>
|
<el-icon @click="toggleFullscreen" class="cursor-pointer hover:scale-110">
|
||||||
|
<FullScreen />
|
||||||
|
</el-icon>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-icon @click="handleClose" size="20"><Close /></el-icon>
|
<el-icon @click="handleClose" size="20" class="cursor-pointer hover:scale-110"><Close /></el-icon>
|
||||||
</el-space>
|
</el-space>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div v-loading="loading" :style="isFullscreen ? 'height: 90vh' : 'height: 80vh'">
|
<div
|
||||||
<div class="flex items-center justify-center h-full">
|
v-loading="loading"
|
||||||
<el-image
|
|
||||||
v-if="fileType === 'image'"
|
|
||||||
:src="fileUrl"
|
|
||||||
:style="isFullscreen ? 'height: 90vh' : 'height: 80vh'"
|
:style="isFullscreen ? 'height: 90vh' : 'height: 80vh'"
|
||||||
|
:class="fileType === 'image' ? 'overflow-y-auto' : 'flex justify-center items-center'"
|
||||||
|
>
|
||||||
|
<template v-if="fileType === 'image'">
|
||||||
|
<div class="flex h-full">
|
||||||
|
<aside class="w-[200px] overflow-y-auto p-2 sm:block hidden left-aside rounded">
|
||||||
|
<template v-for="(item, index) in imageFiles" :key="index">
|
||||||
|
<el-tooltip :content="item.path" placement="right">
|
||||||
|
<div
|
||||||
|
class="text-sm truncate mb-1 rounded p-1 left-item"
|
||||||
|
@click="changeImg(item.path)"
|
||||||
|
:class="item.path === filePath ? 'left-item-default' : ''"
|
||||||
|
>
|
||||||
|
{{ item.path }}
|
||||||
|
</div>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
</aside>
|
||||||
|
<main class="flex-1 overflow-hidden">
|
||||||
|
<el-tooltip :content="filePath" placement="bottom">
|
||||||
|
<el-image
|
||||||
|
loading="lazy"
|
||||||
|
:src="fileUrl"
|
||||||
|
:alt="filePath"
|
||||||
fit="contain"
|
fit="contain"
|
||||||
:preview-src-list="[fileUrl]"
|
class="w-full h-full"
|
||||||
/>
|
/>
|
||||||
|
</el-tooltip>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<video v-else-if="fileType === 'video'" :src="fileUrl" controls autoplay class="size-3/4"></video>
|
<video v-else-if="fileType === 'video'" :src="fileUrl" controls autoplay class="size-3/4"></video>
|
||||||
|
|
||||||
<audio v-else-if="fileType === 'audio'" :src="fileUrl" controls></audio>
|
<audio v-else-if="fileType === 'audio'" :src="fileUrl" controls></audio>
|
||||||
|
|
@ -53,7 +78,6 @@
|
||||||
@error="errorHandler"
|
@error="errorHandler"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -73,6 +97,7 @@ interface EditProps {
|
||||||
path: string;
|
path: string;
|
||||||
name: string;
|
name: string;
|
||||||
extension: string;
|
extension: string;
|
||||||
|
imageFiles: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const open = ref(false);
|
const open = ref(false);
|
||||||
|
|
@ -81,6 +106,7 @@ const filePath = ref('');
|
||||||
const fileName = ref('');
|
const fileName = ref('');
|
||||||
const fileType = ref('');
|
const fileType = ref('');
|
||||||
const fileUrl = ref('');
|
const fileUrl = ref('');
|
||||||
|
const imageFiles = ref([]);
|
||||||
|
|
||||||
const fileExtension = ref('');
|
const fileExtension = ref('');
|
||||||
const isFullscreen = ref(false);
|
const isFullscreen = ref(false);
|
||||||
|
|
@ -107,7 +133,15 @@ const toggleFullscreen = () => {
|
||||||
isFullscreen.value = !isFullscreen.value;
|
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) => {
|
const acceptParams = (props: EditProps) => {
|
||||||
|
imageFiles.value = [];
|
||||||
fileExtension.value = props.extension;
|
fileExtension.value = props.extension;
|
||||||
fileName.value = props.name;
|
fileName.value = props.name;
|
||||||
filePath.value = props.path;
|
filePath.value = props.path;
|
||||||
|
|
@ -115,15 +149,22 @@ const acceptParams = (props: EditProps) => {
|
||||||
isFullscreen.value = fileType.value === 'excel';
|
isFullscreen.value = fileType.value === 'excel';
|
||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
fileUrl.value = `${import.meta.env.VITE_API_URL as string}/files/download?path=${encodeURIComponent(
|
fileUrl.value = getDownloadUrl(props.path);
|
||||||
props.path,
|
imageFiles.value = props.imageFiles.map((item) => ({
|
||||||
)}×tamp=${new Date().getTime()}`;
|
path: item,
|
||||||
|
url: getDownloadUrl(item),
|
||||||
|
}));
|
||||||
open.value = true;
|
open.value = true;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onOpen = () => {};
|
const onOpen = () => {};
|
||||||
|
|
||||||
|
const changeImg = (path: string) => {
|
||||||
|
filePath.value = path;
|
||||||
|
fileUrl.value = getDownloadUrl(path);
|
||||||
|
};
|
||||||
|
|
||||||
defineExpose({ acceptParams });
|
defineExpose({ acceptParams });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -135,4 +176,16 @@ defineExpose({ acceptParams });
|
||||||
.dialog-header-icon {
|
.dialog-header-icon {
|
||||||
color: var(--el-color-info);
|
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;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue