优化打包流程
This commit is contained in:
@@ -6,24 +6,27 @@ module.exports = {
|
||||
action: "/node/wxmp/getZip",
|
||||
method: "post",
|
||||
execute: (request, response) => {
|
||||
let id = request.query?.appid, sql = `select * from node_dvcp_config where appid='${id}'`
|
||||
let id = request.query?.appid, sql = `select * from node_dvcp_config where miniapp_appid='${id}'`
|
||||
db.query(sql).then(res => {
|
||||
let info = res?.[0]
|
||||
let info = res?.[0], sql
|
||||
if (info?.appid) {
|
||||
db.query(`update node_wxmp_config set error=null where appid='${info.appid}'`).then(() => setTimeout(() => {
|
||||
response.send({code: 0})
|
||||
}, 2000))
|
||||
execute(`cd /root/node-service/dvcp_v2_wechat&&node bin/pages.js ${id}&&npm run build`)
|
||||
.then(() => fse.emptyDir(`../wxmpZips/${id}/`))
|
||||
.then(() => fse.copy('../dvcp_v2_wechat/dist/build/mp-weixin/', `../wxmpZips/${id}/`))
|
||||
.then(() => fse.emptyDir('../dvcp_v2_wechat/dist/build'))
|
||||
.then(() => {
|
||||
db.query(`update node_wxmp_config set error='打包时间:${dayjs().format("YYYY-MM-DD HH:mm:ss")}' where appid='${info.appid}'`)
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
db.query(`update node_wxmp_config set error='${err}' where appid='${info.appid}'`)
|
||||
})
|
||||
} else response.send({code: 1, err: "无法找到小程序信息"})
|
||||
sql = `update node_wxmp_config set error=null where appid='${info.appid}'`
|
||||
} else if (info?.miniapp_appid) {
|
||||
sql = `insert into node_wxmp_config ('appid') values('${info?.miniapp_appid}')`
|
||||
} else return response.send({code: 1, err: "无法找到小程序信息"})
|
||||
db.query(sql).then(() => setTimeout(() => {
|
||||
response.send({code: 0})
|
||||
}, 2000))
|
||||
execute(`cd /root/node-service/dvcp_v2_wechat&&node bin/pages.js ${id}&&npm run build`)
|
||||
.then(() => fse.emptyDir(`../wxmpZips/${id}/`))
|
||||
.then(() => fse.copy('../dvcp_v2_wechat/dist/build/mp-weixin/', `../wxmpZips/${id}/`))
|
||||
.then(() => fse.emptyDir('../dvcp_v2_wechat/dist/build'))
|
||||
.then(() => {
|
||||
db.query(`update node_wxmp_config set error='打包时间:${dayjs().format("YYYY-MM-DD HH:mm:ss")}' where appid='${info.appid}'`)
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
db.query(`update node_wxmp_config set error='${err}' where appid='${info.appid}'`)
|
||||
})
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
response.send({code: 1, err: err.sqlMessage})
|
||||
|
||||
Reference in New Issue
Block a user