新版打包监控,不再用前端轮询
This commit is contained in:
@@ -23,8 +23,8 @@ const app = new Vue({
|
||||
render: h => h(App)
|
||||
});
|
||||
let theme = null
|
||||
store.dispatch('getSystem').then(({colorScheme}) => {
|
||||
theme = JSON.parse(colorScheme || null)
|
||||
store.dispatch('getSystem').then(res => {
|
||||
theme = JSON.parse(res?.colorScheme || null)
|
||||
Vue.prototype.$theme = theme?.web || "blue"
|
||||
return import(`dui/lib/styles/theme.${theme?.web}.scss`).catch(() => 0)
|
||||
}).finally(() => {
|
||||
|
||||
@@ -57,7 +57,7 @@ export default {
|
||||
{prop: "dist", label: "更新路径"},
|
||||
{slot: 'process'},
|
||||
],
|
||||
timer: {}
|
||||
ws: {}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -107,34 +107,32 @@ export default {
|
||||
})
|
||||
},
|
||||
handleUpdate(row) {
|
||||
let {id} = row, {timer} = this
|
||||
this.instance.post("/node/custom/getZip", null, {
|
||||
params: {id}
|
||||
}).then(res => {
|
||||
if (res?.code == 0) {
|
||||
row.count = 1
|
||||
timer[id] = setInterval(() => {
|
||||
if (row.count >= 100) {
|
||||
clearInterval(timer[id])
|
||||
let {id} = row
|
||||
if (!this.ws[id]) {
|
||||
this.ws[id] = new WebSocket(`ws://192.168.1.87:12525/custom/getZip?id=${id}`)
|
||||
this.ws[id].onmessage = res => {
|
||||
if (res?.data) {
|
||||
const data = JSON.parse(res.data)
|
||||
if (data.code == '0') {
|
||||
row.count = data.progress
|
||||
if (row.count == 100) {
|
||||
row.count = 0
|
||||
this.$message.success("打包成功!")
|
||||
this.refreshRow(row, data.remark)
|
||||
}
|
||||
} else if (data.code == 1) {
|
||||
row.count = 0
|
||||
this.$message.error("打包失败!")
|
||||
} else if (row.count % 2 == 0 && row.target) {
|
||||
row.count++
|
||||
} else this.getRowById(row.id).then(v => {
|
||||
if (v.error) {
|
||||
clearInterval(timer[id])
|
||||
this.$message.error("打包失败!")
|
||||
this.refreshRow(row, v)
|
||||
row.count = 0
|
||||
} else if (v.download) {
|
||||
clearInterval(timer[id])
|
||||
this.refreshRow(row, v)
|
||||
row.count = 0
|
||||
} else row.count++
|
||||
})
|
||||
}, 6000)
|
||||
this.refreshRow(row, data.row)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
this.ws[id].onclose = () => {
|
||||
row.count = 0
|
||||
this.ws[id].close()
|
||||
delete this.ws[id]
|
||||
}
|
||||
} else this.ws[id]?.send(JSON.stringify({id}))
|
||||
},
|
||||
refreshRow(row, v) {
|
||||
row.error = v.error
|
||||
@@ -148,15 +146,9 @@ export default {
|
||||
},
|
||||
handleCancelUpdate(row) {
|
||||
let {id} = row
|
||||
return this.instance.post("/node/custom/cancelZip", null, {
|
||||
params: {id}
|
||||
}).then(res => {
|
||||
if (res?.code == 0) {
|
||||
clearInterval(this.timer[id])
|
||||
row.count = 0
|
||||
this.getRowById(row.id).then(v => this.refreshRow(row, v))
|
||||
}
|
||||
})
|
||||
this.ws[id].send(JSON.stringify({
|
||||
cid: id
|
||||
}))
|
||||
},
|
||||
getRowById(id) {
|
||||
return this.instance.post("/node/custom/detail", null, {
|
||||
@@ -179,7 +171,7 @@ export default {
|
||||
this.getTableData()
|
||||
},
|
||||
beforeDestroy() {
|
||||
Object.values(this.timer).map(t => clearInterval(t))
|
||||
Object.values(this.ws).map(t => t.close())
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -97,7 +97,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
'/lns': {
|
||||
target: 'http://dvcp.sinocare.net',
|
||||
target: 'http://localhost:12525',
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
//地址重写
|
||||
|
||||
Reference in New Issue
Block a user