Files
dvcp-node-service/src/rest/wechat/download.js

27 lines
950 B
JavaScript
Raw Normal View History

2022-05-19 11:09:22 +08:00
const fse = require("fs-extra");
2022-06-10 12:14:33 +08:00
const execute = require("../../tools/exec");
2022-05-19 11:09:22 +08:00
module.exports = {
2022-05-19 11:14:58 +08:00
action: "/node/wxmp/download",
2022-05-19 11:09:22 +08:00
method: "post",
execute: (request, response) => {
let appid = request.query?.appid
if (appid) {
2022-06-17 15:22:21 +08:00
let path = `/home/deploy/wxmpZips/${appid}/`, zipPath = `/home/deploy/wxmpZips/${appid}.zip`
2022-05-19 11:09:22 +08:00
fse.removeSync(zipPath)
fse.pathExists(path, (err, exists) => {
console.log(`${path}=========>${exists}`)
if (exists) {
2022-06-10 15:17:07 +08:00
execute(`cd ${path}&&zip -r ${appid}.zip .`)
2022-06-17 15:22:21 +08:00
.then(() => execute(`cd ${path}&&mv ${appid}.zip /home/deploy/wxmpZips`))
2022-06-10 15:17:07 +08:00
.then(() => {
2022-05-19 11:09:22 +08:00
console.log('压缩完成!')
setTimeout(() => {
response.download(zipPath)
}, 1000)
})
} else response.send({code: 1, err: "没有打包文件!"})
})
} else response.send({code: 1, err: "无法找到小程序信息"})
}
}