调整ws返回格式

This commit is contained in:
2023-02-17 11:38:30 +08:00
parent 2e5a162292
commit 768982f6e3

View File

@@ -17,23 +17,23 @@ const handleZip = (id, ws) => {
}, 6000)
}
set(progress, remark) {
set(progress, id) {
if (this.timer) clearInterval(this.timer)
this.count = progress
sendMessage({code: 0, progress: this.count, remark})
sendMessage({code: 0, progress: this.count, id})
this.timer = setInterval(() => {
sendMessage({code: 0, progress: ++this.count, remark})
sendMessage({code: 0, progress: ++this.count, id})
}, 4000)
}
stop(row) {
if (this.timer) clearInterval(this.timer)
sendMessage({code: 1, row})
sendMessage({code: 1, row, id: row.id})
}
finish(row) {
if (this.timer) clearInterval(this.timer)
sendMessage({code: 0, progress: 100, row})
sendMessage({code: 0, progress: 100, row, id: row.id})
}
}
@@ -47,12 +47,12 @@ const handleZip = (id, ws) => {
let path = `../${buildPath}`, {dist} = info
dist = dist || `../zips/${info.name}v${info.version || "1.0.0"}`
Promise.all([db.query(`update node_custom_config set download=null,error=null,zipTime='${dayjs().format("YYYY-MM-DD HH:mm:ss")}' where ${uniCon}`), execute(`./shell/update.sh ${info.name} ${path}`, signal)])
.then(cmd => progress.set(30, cmd))
.then(cmd => progress.set(30, info?.id))
.then(() => execute(`cd ${path}&&npm run apps&&node bin/pages.js ${id}&&npm run build`, signal))
.then(cmd => progress.set(70, cmd))
.then(cmd => progress.set(70, info?.id))
.then(() => fse.emptyDir(dist))
.then(() => execute(`./shell/move.sh ${info.type} ${path} ${dist}`, signal))
.then(cmd => progress.set(90, cmd))
.then(cmd => progress.set(90, info?.id))
.then(() => db.query(`update node_custom_config set download='${dayjs().format("YYYY-MM-DD HH:mm:ss")}',error='' where ${uniCon}`))
.then(() => db.detail({table: "node_custom_config", id}))
.then(row => progress.finish(row))