xieb
2023-09-18 2900f50c28b5e2a1cb0f72e4556fb761f61c408e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import EventBus from '/@/event-bus/'
import { onMounted, onBeforeUnmount } from 'vue'
import { DeviceCmdExecuteInfo, DeviceCmdExecuteStatus } from '/@/types/device-cmd'
 
export function useDeviceUpgradeEvent (onDeviceUpgradeWs: (payload: DeviceCmdExecuteInfo) => void): void {
  function handleDeviceUpgrade (payload: any) {
    onDeviceUpgradeWs(payload.data)
    // eslint-disable-next-line no-unused-expressions
    // console.log('payload', payload.data)
  }
 
  onMounted(() => {
    EventBus.on('deviceUpgrade', handleDeviceUpgrade)
  })
 
  onBeforeUnmount(() => {
    EventBus.off('deviceUpgrade', handleDeviceUpgrade)
  })
}