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) } }