feat: PCAP历史目录下载为zip
This commit is contained in:
@@ -1200,6 +1200,7 @@ export default {
|
|||||||
size: "Size",
|
size: "Size",
|
||||||
modifiedTime: "Modified Time",
|
modifiedTime: "Modified Time",
|
||||||
fileName: "File Name",
|
fileName: "File Name",
|
||||||
|
downTipZip: "Confirm downloading the directory [{fileName}] as a ZIP file?",
|
||||||
downTip: "Confirm the download file name is [{fileName}] File?",
|
downTip: "Confirm the download file name is [{fileName}] File?",
|
||||||
downTipErr: "Failed to get file",
|
downTipErr: "Failed to get file",
|
||||||
dirCd: "Enter Dir",
|
dirCd: "Enter Dir",
|
||||||
|
|||||||
@@ -1200,6 +1200,7 @@ export default {
|
|||||||
size: "文件大小",
|
size: "文件大小",
|
||||||
modifiedTime: "修改时间",
|
modifiedTime: "修改时间",
|
||||||
fileName: "文件名称",
|
fileName: "文件名称",
|
||||||
|
downTipZip: "确认将目录 【{fileName}】 下载为ZIP文件?",
|
||||||
downTip: "确认下载文件名为 【{fileName}】 文件?",
|
downTip: "确认下载文件名为 【{fileName}】 文件?",
|
||||||
downTipErr: "文件获取失败",
|
downTipErr: "文件获取失败",
|
||||||
dirCd: "进入目录",
|
dirCd: "进入目录",
|
||||||
|
|||||||
@@ -192,17 +192,31 @@ export function parseSizeFromBits(bits: number | string): string {
|
|||||||
/**
|
/**
|
||||||
* 字节数转换单位
|
* 字节数转换单位
|
||||||
* @param byte 字节Byte大小 64009540 = 512.08 MB
|
* @param byte 字节Byte大小 64009540 = 512.08 MB
|
||||||
|
* @param unit 指定单位 B / KB / MB / GB / TB / PB / EB / ZB / YB
|
||||||
* @returns xx B / KB / MB / GB / TB / PB / EB / ZB / YB
|
* @returns xx B / KB / MB / GB / TB / PB / EB / ZB / YB
|
||||||
*/
|
*/
|
||||||
export function parseSizeFromByte(byte: number | string): string {
|
export function parseSizeFromByte(
|
||||||
|
byte: number | string,
|
||||||
|
unit?: string
|
||||||
|
): string {
|
||||||
byte = Number(byte) || 0;
|
byte = Number(byte) || 0;
|
||||||
if (byte <= 0) return '0 B';
|
if (byte <= 0) return '0 B';
|
||||||
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||||
const unitIndex = Math.floor(Math.log2(byte) / 10);
|
let unitIndex = 0;
|
||||||
const unti = units[unitIndex];
|
let unitStr = 'B';
|
||||||
|
if (unit) {
|
||||||
|
const index = units.indexOf(unit);
|
||||||
|
if (index > -1) {
|
||||||
|
unitIndex = index;
|
||||||
|
unitStr = unit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unitIndex = Math.floor(Math.log2(byte) / 10);
|
||||||
|
unitStr = units[unitIndex];
|
||||||
|
}
|
||||||
const value = byte / Math.pow(1000, unitIndex);
|
const value = byte / Math.pow(1000, unitIndex);
|
||||||
if (unitIndex > 0) {
|
if (unitIndex > 0) {
|
||||||
return `${value.toFixed(2)} ${unti}`;
|
return `${value.toFixed(2)} ${unitStr}`;
|
||||||
}
|
}
|
||||||
return `${value} ${unti}`;
|
return `${value} ${unitStr}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { SizeType } from 'ant-design-vue/es/config-provider';
|
|||||||
import { ColumnsType } from 'ant-design-vue/es/table';
|
import { ColumnsType } from 'ant-design-vue/es/table';
|
||||||
import { Modal, message } from 'ant-design-vue/es';
|
import { Modal, message } from 'ant-design-vue/es';
|
||||||
import { parseDateToStr } from '@/utils/date-utils';
|
import { parseDateToStr } from '@/utils/date-utils';
|
||||||
import { getNeFile, listNeFiles } from '@/api/tool/neFile';
|
import { getNeDirZip, getNeFile, listNeFiles } from '@/api/tool/neFile';
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||||
import ViewDrawer from '@/views/logManage/neFile/components/ViewDrawer.vue';
|
import ViewDrawer from '@/views/logManage/neFile/components/ViewDrawer.vue';
|
||||||
import useNeInfoStore from '@/store/modules/neinfo';
|
import useNeInfoStore from '@/store/modules/neinfo';
|
||||||
@@ -79,7 +79,7 @@ let tableColumns: ColumnsType = reactive([
|
|||||||
if (!opt.value) return '';
|
if (!opt.value) return '';
|
||||||
return parseDateToStr(opt.value * 1000);
|
return parseDateToStr(opt.value * 1000);
|
||||||
},
|
},
|
||||||
width: 150,
|
width: 200,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t('views.logManage.neFile.fileName'),
|
title: t('views.logManage.neFile.fileName'),
|
||||||
@@ -168,6 +168,45 @@ function fnDownloadFile(row: Record<string, any>) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**信息文件下载 */
|
||||||
|
function fnDownloadFileZIP(row: Record<string, any>) {
|
||||||
|
if (downLoading.value) return;
|
||||||
|
Modal.confirm({
|
||||||
|
title: t('common.tipTitle'),
|
||||||
|
content: t('views.logManage.neFile.downTipZip', { fileName: row.fileName }),
|
||||||
|
onOk() {
|
||||||
|
downLoading.value = true;
|
||||||
|
const hide = message.loading(t('common.loading'), 0);
|
||||||
|
getNeDirZip({
|
||||||
|
neType: queryParams.neType,
|
||||||
|
neId: queryParams.neId,
|
||||||
|
path: `${queryParams.path}/${row.fileName}`,
|
||||||
|
delTemp: true,
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (res.code === RESULT_CODE_SUCCESS) {
|
||||||
|
message.success({
|
||||||
|
content: t('common.msgSuccess', {
|
||||||
|
msg: t('common.downloadText'),
|
||||||
|
}),
|
||||||
|
duration: 2,
|
||||||
|
});
|
||||||
|
saveAs(res.data, `${row.fileName}.zip`);
|
||||||
|
} else {
|
||||||
|
message.error({
|
||||||
|
content: t('views.logManage.neFile.downTipErr'),
|
||||||
|
duration: 2,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hide();
|
||||||
|
downLoading.value = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**tmp目录下,UPF标准版内部输出目录 */
|
/**tmp目录下,UPF标准版内部输出目录 */
|
||||||
let tmp = ref<boolean>(false);
|
let tmp = ref<boolean>(false);
|
||||||
|
|
||||||
@@ -386,16 +425,6 @@ onMounted(() => {
|
|||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
<template v-if="column.key === 'fileName'">
|
<template v-if="column.key === 'fileName'">
|
||||||
<a-space :size="8" align="center">
|
<a-space :size="8" align="center">
|
||||||
<a-tooltip
|
|
||||||
v-if="
|
|
||||||
record.fileType === 'file' && record.fileName.endsWith('.log')
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<template #title>{{ t('common.viewText') }}</template>
|
|
||||||
<a-button type="link" @click.prevent="fnDrawerOpen(record)">
|
|
||||||
<template #icon><ProfileOutlined /></template>
|
|
||||||
</a-button>
|
|
||||||
</a-tooltip>
|
|
||||||
<a-button
|
<a-button
|
||||||
type="link"
|
type="link"
|
||||||
:loading="downLoading"
|
:loading="downLoading"
|
||||||
@@ -405,15 +434,36 @@ onMounted(() => {
|
|||||||
<template #icon><DownloadOutlined /></template>
|
<template #icon><DownloadOutlined /></template>
|
||||||
{{ t('common.downloadText') }}
|
{{ t('common.downloadText') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
|
|
||||||
|
<a-button
|
||||||
|
type="link"
|
||||||
|
@click.prevent="fnDrawerOpen(record)"
|
||||||
|
v-if="
|
||||||
|
record.fileType === 'file' && record.fileName.endsWith('.log')
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<template #icon><ProfileOutlined /></template>
|
||||||
|
{{ t('common.viewText') }}
|
||||||
|
</a-button>
|
||||||
|
|
||||||
|
<template v-if="record.fileType === 'dir'">
|
||||||
|
<a-button
|
||||||
|
type="link"
|
||||||
|
:loading="downLoading"
|
||||||
|
@click.prevent="fnDownloadFileZIP(record)"
|
||||||
|
>
|
||||||
|
<template #icon><DownloadOutlined /></template>
|
||||||
|
{{ t('common.downloadText') }}
|
||||||
|
</a-button>
|
||||||
<a-button
|
<a-button
|
||||||
type="link"
|
type="link"
|
||||||
:loading="downLoading"
|
:loading="downLoading"
|
||||||
@click.prevent="fnDirCD(record.fileName)"
|
@click.prevent="fnDirCD(record.fileName)"
|
||||||
v-if="record.fileType === 'dir'"
|
|
||||||
>
|
>
|
||||||
<template #icon><FolderOutlined /></template>
|
<template #icon><FolderOutlined /></template>
|
||||||
{{ t('views.logManage.neFile.dirCd') }}
|
{{ t('views.logManage.neFile.dirCd') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
|
</template>
|
||||||
</a-space>
|
</a-space>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user