You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
595 B
20 lines
595 B
2 years ago
|
import EventBus from '/@/event-bus/'
|
||
|
import { onMounted, onBeforeUnmount } from 'vue'
|
||
|
import { TaskProgressInfo } from '/@/types/task'
|
||
|
|
||
|
export function useTaskProgressEvent (onTaskProgressWs: (data: TaskProgressInfo) => void): void {
|
||
|
function handleTaskProgress (payload: any) {
|
||
|
onTaskProgressWs(payload.data)
|
||
|
// eslint-disable-next-line no-unused-expressions
|
||
|
// console.log('payload', payload.data)
|
||
|
}
|
||
|
|
||
|
onMounted(() => {
|
||
|
EventBus.on('deviceTaskProgress', handleTaskProgress)
|
||
|
})
|
||
|
|
||
|
onBeforeUnmount(() => {
|
||
|
EventBus.off('deviceTaskProgress', handleTaskProgress)
|
||
|
})
|
||
|
}
|