This commit is contained in:
2023-03-10 11:26:39 +08:00
parent 363130ddd0
commit 0428a1b155
10 changed files with 270 additions and 20 deletions

View File

@@ -328,6 +328,31 @@ const TaskSubmit = async () => {
})
}
// 如果列表里有待执行的任务, 使用WS连接检查任务状态
const TaskManagement = () => {
console.log('构建WS连接')
let ws = new WebSocket('ws://'+window.location.host+'/api/sendmessage')
ws.onopen = () => {
console.log('ws open')
ws.send('hello')
}
ws.onmessage = (e) => {
console.log('ws message')
let data = JSON.parse(e.data)
console.log(data.id, data.status, data.progress)
}
ws.onerror = () => {
console.log('ws error')
}
ws.onclose = () => {
console.log('ws close')
}
}
onMounted(() => {
TaskManagement()
})
</script>
<style>