🐛 修复 windows 文件备份失败.

This commit is contained in:
lijiahangmax
2024-07-14 21:24:53 +08:00
parent 849e010bc3
commit c20c83245f
12 changed files with 68 additions and 20 deletions

View File

@@ -107,10 +107,14 @@
{{ getDictValue(sftpOperatorTypeKey, record.type) }}
</a-tag>
</template>
<!-- 文件数量 -->
<template #fileCount="{ record }">
<b class="span-blue">{{ record.paths.length }}</b> 个
</template>
<!-- 操作文件 -->
<template #paths="{ record }">
<div class="paths-wrapper">
<span v-for="path in record.paths"
<span v-for="path in record.paths.slice(0, record.extra.maxCount)"
class="path-wrapper text-ellipsis text-copy"
:title="path"
@click="copy(path)">
@@ -125,6 +129,13 @@
提权 {{ record.extra?.mod }} {{ permission10toString(record.extra?.mod as number) }}
</span>
</div>
<!-- 查看更多-->
<div v-if="record.paths.length > record.extra.maxCount"
class="paths-wrapper span-blue pointer"
title="查看更多"
@click="() => record.extra.maxCount = record.paths.length">
查看更多
</div>
</template>
<!-- 执行结果 -->
<template #result="{ record }">
@@ -175,7 +186,7 @@
import type { HostSftpLogQueryRequest, HostSftpLogQueryResponse } from '@/api/asset/host-sftp';
import { reactive, ref, onMounted } from 'vue';
import { getHostSftpLogPage, deleteHostSftpLog } from '@/api/asset/host-sftp';
import { sftpOperatorTypeKey, sftpOperatorResultKey, SftpOperatorType } from '../types/const';
import { sftpOperatorTypeKey, sftpOperatorResultKey, SftpOperatorType, showPathMaxCount } from '../types/const';
import { usePagination, useRowSelection } from '@/types/table';
import { useDictStore } from '@/store';
import { Message } from '@arco-design/web-vue';
@@ -186,14 +197,13 @@
import UserSelector from '@/components/user/user/selector/index.vue';
import HostSelector from '@/components/asset/host/selector/index.vue';
const tableRenderData = ref<HostSftpLogQueryResponse[]>([]);
const selectedKeys = ref<number[]>([]);
const pagination = usePagination();
const rowSelection = useRowSelection();
const { loading, setLoading } = useLoading();
const { toOptions, getDictValue } = useDictStore();
const tableRenderData = ref<Array<HostSftpLogQueryResponse>>([]);
const selectedKeys = ref<Array<number>>([]);
const formModel = reactive<HostSftpLogQueryRequest>({
userId: undefined,
hostId: undefined,
@@ -206,7 +216,12 @@
const doFetchTableData = async (request: HostSftpLogQueryRequest) => {
try {
setLoading(true);
// 查询
const { data } = await getHostSftpLogPage(request);
// 设置最大数量
data.rows.forEach(s => {
s.extra.maxCount = showPathMaxCount;
});
tableRenderData.value = data.rows;
pagination.total = data.total;
pagination.current = request.page;
@@ -240,13 +255,11 @@
};
// 删除当前行
const deleteRow = async ({ id }: {
id: number
}) => {
const deleteRow = async (record: HostSftpLogQueryResponse) => {
try {
setLoading(true);
// 调用删除接口
await deleteHostSftpLog([id]);
await deleteHostSftpLog([record.id]);
Message.success('删除成功');
selectedKeys.value = [];
// 重新加载数据

View File

@@ -4,6 +4,9 @@ export const SftpOperatorType = {
SFTP_CHMOD: 'host-terminal:sftp-chmod',
};
// 最大展示数量
export const showPathMaxCount = 5;
// sftp 操作类型 字典项
export const sftpOperatorTypeKey = 'sftpOperatorType';

View File

@@ -29,6 +29,12 @@ const columns = [
slotName: 'type',
width: 116,
align: 'left',
}, {
title: '文件数量',
dataIndex: 'fileCount',
slotName: 'fileCount',
align: 'left',
width: 100,
}, {
title: '操作文件',
dataIndex: 'paths',

View File

@@ -50,7 +50,11 @@
// 打开新增
const open = (session: string, path: string, isTouch: boolean) => {
sessionId.value = session;
formModel.value.path = path;
if (path === '/') {
formModel.value.path = path;
} else {
formModel.value.path = path + '/';
}
touch.value = isTouch;
setVisible(true);
// 自动聚焦

View File

@@ -285,12 +285,12 @@
// 创建文件
const createFile = () => {
openSftpCreateModal(props.session?.sessionId as string, props.currentPath + '/', true);
openSftpCreateModal(props.session?.sessionId as string, props.currentPath, true);
};
// 创建文件夹
const createDir = () => {
openSftpCreateModal(props.session?.sessionId as string, props.currentPath + '/', false);
openSftpCreateModal(props.session?.sessionId as string, props.currentPath, false);
};
// 删除选中文件

View File

@@ -106,7 +106,8 @@
return false;
}
if (!fileList.value.length) {
return true;
Message.error('请选择文件');
return false;
}
// 添加到上传列表
const files = fileList.value.map(s => s.file as File);
@@ -168,6 +169,10 @@
margin-right: 0 !important;
}
:deep(.arco-upload-list-item-name-link) {
width: 100%;
}
:deep(.arco-upload-list-item-name-text) {
width: 100%;
}

View File

@@ -3,7 +3,7 @@ import { TransferOperatorType, TransferStatus } from '../types/terminal.const';
import { getFileName, getPath } from '@/utils/file';
import { saveAs } from 'file-saver';
// sftp 上传器实现
// sftp 下载器实现
export default class SftpTransferDownloader implements ISftpTransferDownloader {
public abort: boolean;