修改文件预览逻辑.

This commit is contained in:
lijiahang
2025-02-05 10:45:16 +08:00
parent cec11ce8c3
commit 2d5835b150
9 changed files with 36 additions and 30 deletions

View File

@@ -68,7 +68,7 @@
</a-button>
</a-tooltip>
<!-- 编辑内容 -->
<a-tooltip v-if="canEditable(record.size, record.attr)"
<a-tooltip v-if="record.canPreview"
position="top"
:mini="true"
:overlay-inverse="true"
@@ -144,15 +144,13 @@
<script lang="ts" setup>
import type { TableData } from '@arco-design/web-vue/es/table/interface';
import type { SftpFile, ISftpSession } from '../../types/define';
import type { SftpSetting } from '@/api/system/setting';
import { ref, computed, watch, inject, onMounted } from 'vue';
import { ref, computed, watch, inject } from 'vue';
import { useRowSelection } from '@/hooks/table';
import { dateFormat } from '@/utils';
import { setAutoFocus } from '@/utils/dom';
import { copy } from '@/hooks/copy';
import columns from './types/table.columns';
import { FILE_TYPE, openSftpChmodModalKey, openSftpMoveModalKey } from '../../types/const';
import { useCacheStore } from '@/store';
const props = defineProps<{
session?: ISftpSession;
@@ -169,8 +167,6 @@
const rowSelection = useRowSelection({ width: 40 });
const previewSize = ref(0);
// 切换页面自动清空过滤
watch(() => props.list, () => {
tableRef.value?.clearFilters();
@@ -205,13 +201,6 @@
record.hover = false;
};
// 是否可编辑
const canEditable = (size: number, attr: string) => {
// 是普通文件 && 文件小于 配置大小(MB) 可以编辑
return FILE_TYPE.NORMAL_FILE.value == formatFileType(attr).value
&& size <= (previewSize.value || 0) * 1024 * 1024;
};
// 点击文件名称
const clickFilename = (record: TableData) => {
if (record.isDir) {
@@ -279,12 +268,6 @@
}) || FILE_TYPE.NORMAL_FILE;
};
// 加载配置
onMounted(async () => {
const { sftp } = await useCacheStore().loadSystemSetting();
previewSize.value = sftp?.previewSize;
});
</script>
<style lang="less" scoped>

View File

@@ -369,6 +369,7 @@ export interface SftpFile {
uid: number;
gid: number;
modifyTime: number;
canPreview: boolean;
}
// sftp 传输管理器定义