From b7e9bc2e1f4d02b1a5cb0180fce4a0c9f093d84e Mon Sep 17 00:00:00 2001 From: guoapeng Date: Mon, 7 Jul 2025 15:30:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=BC=80=E5=A7=8B=E6=B6=88=E6=AF=92?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E7=9B=91=E5=90=AC=E6=B6=88=E6=AF=92=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/home/HomeOperation.vue | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/home/HomeOperation.vue b/src/components/home/HomeOperation.vue index 03ffd68..abd201f 100644 --- a/src/components/home/HomeOperation.vue +++ b/src/components/home/HomeOperation.vue @@ -4,7 +4,7 @@ import homeFinish from 'assets/images/home/home-finish.svg' import homeStart from 'assets/images/home/home-start.svg' import { startTimer, stopTimer } from 'libs/countdownTimer' import { deviceStateMap } from 'libs/utils' -import { computed, onMounted, ref, watchEffect } from 'vue' +import { computed, ref, watchEffect } from 'vue' import { getDeviceStatus } from '@/libs/deviceComm' import { FtMessage } from '@/libs/message' @@ -54,11 +54,6 @@ watchEffect(() => { }) /** - * @hook 生命周期钩子 - 组件挂载完成时执行 - */ -onMounted(async () => {}) - -/** * @function 开始消毒操作 * @desc 校验设备状态并发起消毒请求 */ @@ -74,8 +69,6 @@ const onStartDisinfect = () => { }) } -let poll = null - const doStartDisinfect = async () => { // 校验设备状态 const statusName = getDeviceStatus() @@ -89,6 +82,12 @@ const doStartDisinfect = async () => { // 使用选中配方或默认配置启动消毒 if (formulaStore.selectedFormulaInfo && formulaStore.selectedFormulaInfo.formula_id) { await formulaStore.startDisinfectFormula(formulaStore.selectedFormulaInfo) + const poll = setInterval(() => { + if (!operationState.value) { + systemStore.updateLoading(false) + clearInterval(poll) + } + }, 100) } else { const startParams = { @@ -97,12 +96,16 @@ const doStartDisinfect = async () => { params: { loglevel: formulaStore.loglevel }, } await sendCmd(startParams) + const poll = setInterval(() => { + if (!operationState.value) { + systemStore.updateLoading(false) + clearInterval(poll) + } + }, 100) } - // 开启定时器, 30秒保存一次数据 - poll = setInterval(async () => {}, 1000 * 30) - console.log(poll) } - finally { + catch (e) { + console.log(e) systemStore.updateLoading(false) } }