fix: 网元切换时命令操作信息过滤

This commit is contained in:
TsMask
2024-11-14 11:33:17 +08:00
parent 021f9f28f6
commit 348b11e201
2 changed files with 33 additions and 14 deletions

View File

@@ -80,6 +80,14 @@ async function fnIPerf() {
}); });
return; return;
} }
// 网元切换时重置
if (neType !== state.params.neType || neId !== state.params.neId) {
state.initialized = false;
state.params.neType = neType;
state.params.neId = neId;
}
// 软件版本检查 // 软件版本检查
state.params.neType = neType; state.params.neType = neType;
state.params.neId = neId; state.params.neId = neId;
@@ -88,7 +96,6 @@ async function fnIPerf() {
neId, neId,
version: state.data.version, version: state.data.version,
}); });
if (resVersion.code !== RESULT_CODE_SUCCESS) { if (resVersion.code !== RESULT_CODE_SUCCESS) {
Modal.confirm({ Modal.confirm({
title: t('common.tipTitle'), title: t('common.tipTitle'),
@@ -99,6 +106,7 @@ async function fnIPerf() {
} else { } else {
state.versionInfo = resVersion.data; state.versionInfo = resVersion.data;
} }
// 初始化的直接重发 // 初始化的直接重发
if (state.initialized) { if (state.initialized) {
fnResend(); fnResend();
@@ -145,8 +153,8 @@ function fnResend() {
if (!toolTerminal.value) return; if (!toolTerminal.value) return;
state.running = true; state.running = true;
toolTerminal.value.ctrlC(); toolTerminal.value.ctrlC();
toolTerminal.value.clear();
setTimeout(() => { setTimeout(() => {
toolTerminal.value.clear();
const data = JSON.parse(JSON.stringify(state.data)); const data = JSON.parse(JSON.stringify(state.data));
if (state.dataType === 'options') data.command = ''; if (state.dataType === 'options') data.command = '';
toolTerminal.value.send('iperf', data); toolTerminal.value.send('iperf', data);
@@ -180,9 +188,12 @@ function fnProcessMessage(data: string): string {
if (lestIndex !== -1) { if (lestIndex !== -1) {
text = text.substring(0, lestIndex); text = text.substring(0, lestIndex);
} }
if (text.endsWith('# ')) {
text = text.substring(0, text.lastIndexOf('\r\n') + 2);
}
// console.log({ parts, text }); // console.log({ parts, text });
if (parts[0].startsWith('iperf')) { if (parts.length > 1 && parts[0].startsWith('iperf')) {
return parts[0] + '\r\n' + text; return parts[0] + '\r\n' + text;
} }
return text; return text;

View File

@@ -72,13 +72,15 @@ async function fnPing() {
}); });
return; return;
} }
if (state.initialized) {
fnResend();
return;
}
// 网元切换时重置
if (neType !== state.params.neType || neId !== state.params.neId) {
state.initialized = false;
state.params.neType = neType; state.params.neType = neType;
state.params.neId = neId; state.params.neId = neId;
}
// 软件版本检查
const resVersion = await pingV({ neType, neId }); const resVersion = await pingV({ neType, neId });
if (resVersion.code !== RESULT_CODE_SUCCESS) { if (resVersion.code !== RESULT_CODE_SUCCESS) {
message.warning({ message.warning({
@@ -89,6 +91,12 @@ async function fnPing() {
} else { } else {
state.versionInfo = resVersion.data; state.versionInfo = resVersion.data;
} }
// 初始化的直接重发
if (state.initialized) {
fnResend();
return;
}
state.initialized = true; state.initialized = true;
} }
@@ -108,8 +116,8 @@ function fnResend() {
if (!toolTerminal.value) return; if (!toolTerminal.value) return;
state.running = true; state.running = true;
toolTerminal.value.ctrlC(); toolTerminal.value.ctrlC();
toolTerminal.value.clear();
setTimeout(() => { setTimeout(() => {
toolTerminal.value.clear();
const data = JSON.parse(JSON.stringify(state.data)); const data = JSON.parse(JSON.stringify(state.data));
if (state.dataType === 'options') data.command = ''; if (state.dataType === 'options') data.command = '';
toolTerminal.value.send('ping', data); toolTerminal.value.send('ping', data);
@@ -143,9 +151,12 @@ function fnProcessMessage(data: string): string {
if (lestIndex !== -1) { if (lestIndex !== -1) {
text = text.substring(0, lestIndex); text = text.substring(0, lestIndex);
} }
if (text.endsWith('# ')) {
text = text.substring(0, text.lastIndexOf('\r\n') + 2);
}
// console.log({ parts, text }); // console.log({ parts, text });
if (parts[0].startsWith('ping')) { if (parts.length > 1 && parts[0].startsWith('ping')) {
return parts[0] + '\r\n' + text; return parts[0] + '\r\n' + text;
} }
return text; return text;
@@ -377,10 +388,7 @@ onBeforeUnmount(() => {});
<a-auto-complete <a-auto-complete
v-model:value="state.data.command" v-model:value="state.data.command"
:disabled="state.running" :disabled="state.running"
:options="[ :options="[{ value: '-help' }, { value: '-i 1 -c 4 8.8.8.8' }]"
{ value: '-help' },
{ value: '-i 1 -c 4 8.8.8.8' },
]"
:dropdown-match-select-width="500" :dropdown-match-select-width="500"
style="width: 100%" style="width: 100%"
> >