🐛 批量执行历史显示错误.

This commit is contained in:
lijiahang
2024-07-17 13:38:51 +08:00
parent f75d097d8a
commit 48d308b1a8
8 changed files with 80 additions and 29 deletions

View File

@@ -47,7 +47,7 @@
import type { ExecCommandRequest } from '@/api/exec/exec-command';
import { onMounted, ref } from 'vue';
import { getExecCommandLogHistory } from '@/api/exec/exec-command-log';
import { historyCount } from '../types/const';
import { historyCount, descOmit, omit } from '../types/const';
import useLoading from '@/hooks/loading';
const emits = defineEmits(['selected']);
@@ -58,12 +58,20 @@
// 添加
const add = (record: ExecCommandRequest) => {
const command = record.command as string;
if (!record.description) {
if (command.length < descOmit + omit.length) {
record.description = command;
} else {
record.description = command.substring(0, descOmit) + omit;
}
}
const index = historyLogs.value.findIndex(s => s.description === record.description);
if (index === -1) {
// 不存在
historyLogs.value.unshift({
description: record.description,
command: record.command,
command: command,
parameterSchema: record.parameterSchema,
timeout: record.timeout,
hostIdList: record.hostIdList
@@ -74,7 +82,7 @@
historyLogs.value.splice(index, 1);
historyLogs.value.unshift({
...his,
command: record.command,
command: command,
parameterSchema: record.parameterSchema,
timeout: record.timeout,
hostIdList: record.hostIdList

View File

@@ -1,2 +1,8 @@
// 历史数量
export const historyCount = 15;
// 描述最大大小
export const descOmit = 60;
// 省略
export const omit = '...';