yangfeng
2024-02-06 8f1e5d92579da34c21a83f74b924dfd4908889c6
注掉获取PLC运行数据
1个文件已修改
46 ■■■■ 已修改文件
src/stores/plc.ts 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stores/plc.ts
@@ -13,29 +13,27 @@
export const usePLCStore = defineStore('plc', () => {
  const taskStore = useTasksStore()
  const plcInfo = computed(() => {
    return plcRes?.value?.data as PLCResponse
  })
  const plcInfo = ref()
  /**
   * 如果任务状态是进行中, 则轮询 plc 取进度
   */
  const {
    data: plcRes,
    run: startPLCPolling,
    cancel: cancelPLCPolling
  } = useRequest(
    () =>
      getProductProgress({
        channel: taskStore.activeChannel ?? 0,
        procedureId: taskStore.activeTask?.Procedure.ID ?? undefined
      } as ProductProgressParams),
    {
      manual: true,
      pollingInterval: PLC_POLLING_DURATION,
      pollingWhenHidden: false
    }
  )
  // const {
  //   data: plcRes,
  //   run: startPLCPolling,
  //   cancel: cancelPLCPolling
  // } = useRequest(
  //   () =>
  //     getProductProgress({
  //       channel: taskStore.activeChannel ?? 0,
  //       procedureId: taskStore.activeTask?.Procedure.ID ?? undefined
  //     } as ProductProgressParams),
  //   {
  //     manual: true,
  //     pollingInterval: PLC_POLLING_DURATION,
  //     pollingWhenHidden: false
  //   }
  // )
  if (!unwatch.value) {
    /**
@@ -44,19 +42,19 @@
    unwatch.value = watch(
      () => taskStore.activeChannel,
      () => {
        cancelPLCPolling()
        startPLCPolling()
        // cancelPLCPolling()
        // startPLCPolling()
      }
    )
  }
  function startPollingPLC() {
    cancelPLCPolling()
    startPLCPolling()
    // cancelPLCPolling()
    // startPLCPolling()
  }
  onUnmounted(() => {
    cancelPLCPolling()
    // cancelPLCPolling()
  })
  return { plcInfo, startPollingPLC }