diff --git a/src/views/tool/iperf/index.vue b/src/views/tool/iperf/index.vue index 3119a83a..f9b0ee0d 100644 --- a/src/views/tool/iperf/index.vue +++ b/src/views/tool/iperf/index.vue @@ -80,6 +80,14 @@ async function fnIPerf() { }); 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.neId = neId; @@ -88,7 +96,6 @@ async function fnIPerf() { neId, version: state.data.version, }); - if (resVersion.code !== RESULT_CODE_SUCCESS) { Modal.confirm({ title: t('common.tipTitle'), @@ -99,6 +106,7 @@ async function fnIPerf() { } else { state.versionInfo = resVersion.data; } + // 初始化的直接重发 if (state.initialized) { fnResend(); @@ -145,8 +153,8 @@ function fnResend() { if (!toolTerminal.value) return; state.running = true; toolTerminal.value.ctrlC(); - toolTerminal.value.clear(); setTimeout(() => { + toolTerminal.value.clear(); const data = JSON.parse(JSON.stringify(state.data)); if (state.dataType === 'options') data.command = ''; toolTerminal.value.send('iperf', data); @@ -180,9 +188,12 @@ function fnProcessMessage(data: string): string { if (lestIndex !== -1) { text = text.substring(0, lestIndex); } + if (text.endsWith('# ')) { + text = text.substring(0, text.lastIndexOf('\r\n') + 2); + } // console.log({ parts, text }); - if (parts[0].startsWith('iperf')) { + if (parts.length > 1 && parts[0].startsWith('iperf')) { return parts[0] + '\r\n' + text; } return text; diff --git a/src/views/tool/ping/index.vue b/src/views/tool/ping/index.vue index 0e909def..260ee5ec 100644 --- a/src/views/tool/ping/index.vue +++ b/src/views/tool/ping/index.vue @@ -72,13 +72,15 @@ async function fnPing() { }); return; } - if (state.initialized) { - fnResend(); - 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.neId = neId; + // 软件版本检查 const resVersion = await pingV({ neType, neId }); if (resVersion.code !== RESULT_CODE_SUCCESS) { message.warning({ @@ -89,6 +91,12 @@ async function fnPing() { } else { state.versionInfo = resVersion.data; } + + // 初始化的直接重发 + if (state.initialized) { + fnResend(); + return; + } state.initialized = true; } @@ -108,8 +116,8 @@ function fnResend() { if (!toolTerminal.value) return; state.running = true; toolTerminal.value.ctrlC(); - toolTerminal.value.clear(); setTimeout(() => { + toolTerminal.value.clear(); const data = JSON.parse(JSON.stringify(state.data)); if (state.dataType === 'options') data.command = ''; toolTerminal.value.send('ping', data); @@ -143,9 +151,12 @@ function fnProcessMessage(data: string): string { if (lestIndex !== -1) { text = text.substring(0, lestIndex); } + if (text.endsWith('# ')) { + text = text.substring(0, text.lastIndexOf('\r\n') + 2); + } // console.log({ parts, text }); - if (parts[0].startsWith('ping')) { + if (parts.length > 1 && parts[0].startsWith('ping')) { return parts[0] + '\r\n' + text; } return text; @@ -377,10 +388,7 @@ onBeforeUnmount(() => {});