From 3b68163246ae4c7c1aeef438e3cbe09c9f5add3a Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Mon, 20 Jul 2026 08:49:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=81=9C=E6=A3=80=EF=BC=8C=E6=B5=8B?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E4=BA=8C=E6=AC=A1=E7=A1=AE=E8=AE=A4=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E7=AD=89=E5=BE=85=E5=B0=8F=E9=A1=B9=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/socket/socket.ts | 16 ++-- frontend/src/views/home/components/test.vue | 27 +++++- .../src/views/home/components/testPopup.vue | 96 +++++++++++++++++-- 3 files changed, 120 insertions(+), 19 deletions(-) diff --git a/frontend/src/api/socket/socket.ts b/frontend/src/api/socket/socket.ts index d89ceef..7aa7bc8 100644 --- a/frontend/src/api/socket/socket.ts +++ b/frontend/src/api/socket/socket.ts @@ -3,15 +3,19 @@ import { useDetectionLockStore } from '@/stores/modules/detectionLock' import type { CheckData } from '@/api/check/interface' -export const startPreTest = async (params) => { +export const startPreTest = async (params: any) => { const result = await http.post(`/prepare/startPreTest`, params, {loading: false}) // 抢锁成功 → 标记本地为持锁者 useDetectionLockStore().setAsHolder() return result } -export const closePreTest = (params) => { - return http.post(`/prepare/closePreTest`, params,{ loading: false }) +export interface ClosePreTestParam { + waitCurrentItem: boolean +} + +export const closePreTest = (params: ClosePreTestParam) => { + return http.post(`/prepare/closePreTest`, params, { loading: false }) } /** @@ -26,15 +30,15 @@ export const closePreTest = (params) => { * 暂停正式检测 * @param params */ -export const pauseTest = () => { - return http.get(`/prepare/closePreTest`, {loading: false}) +export const pauseTest = (waitCurrentItem = true) => { + return closePreTest({ waitCurrentItem }) } /** * 继续正式检测 * @param params */ -export const resumeTest = (params) => { +export const resumeTest = (params: any) => { return http.post(`/prepare/restartTemTest/`, params, {loading: false}) } diff --git a/frontend/src/views/home/components/test.vue b/frontend/src/views/home/components/test.vue index 0ac447e..726fa6b 100644 --- a/frontend/src/views/home/components/test.vue +++ b/frontend/src/views/home/components/test.vue @@ -198,6 +198,15 @@ let errorCheckItem: Array<{ scriptType: string, type: CheckData.ChnCheckResultEn // 检测日志列表 const testLogList = reactive([{ type: 'info', log: '暂无数据,等待检测开始' }]) +interface FormalCurrentItem { + type?: string + typeName?: string + index?: number + desc?: string +} + +const currentFormalItem = ref(null) + // ========== 响应式引用 ========== // 将props转为ref,便于watch监听 const testStatus = toRef(props, 'testStatus') @@ -472,6 +481,11 @@ watch(webMsgSend, function(newValue, oldValue) { count++ } break + case 'formal_current_item': + currentFormalItem.value = typeof newValue.data === 'string' + ? JSON.parse(newValue.data || '{}') + : (newValue.data || null) + break // 正式测试相关消息 case 'formal_real': switch (newValue.operateCode) { @@ -1200,13 +1214,17 @@ const handleClick = (item: any, chnNum: number, scriptType: string) => { // ========== 暂停/继续相关函数 ========== // 处理暂停请求 -const handlePause = () => { +const handlePause = (waitCurrentItem = true) => { testLogList.push({ - type: 'error', - log: `${new Date().toLocaleString()}:当前测试小项正在执行中,将在该小项执行结束后暂停...`, + type: waitCurrentItem ? 'error' : 'warning', + log: waitCurrentItem + ? `${new Date().toLocaleString()}:当前测试小项正在执行中,将在该小项执行结束后暂停...` + : `${new Date().toLocaleString()}:已请求立即暂停,不等待当前小项检测结束`, }) } +const getCurrentFormalItem = () => currentFormalItem.value + // 暂停成功回调 const pauseSuccessCallback = () => { // 记录暂停时的时间 @@ -1371,7 +1389,8 @@ defineExpose({ handlePause, // 暂停方法 getElapsedSeconds, applyFormalProgress, - startFormalTimer + startFormalTimer, + getCurrentFormalItem }) diff --git a/frontend/src/views/home/components/testPopup.vue b/frontend/src/views/home/components/testPopup.vue index 134f0d2..2b4fa51 100644 --- a/frontend/src/views/home/components/testPopup.vue +++ b/frontend/src/views/home/components/testPopup.vue @@ -119,7 +119,7 @@ - 停止检测 + 暂停检测 @@ -168,11 +168,37 @@ + + +
+

当前正在进行:{{ pauseCurrentItemText }}...

+

是否等待该小项检测完成

+
+ +