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

25 lines
877 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-10 12:14:33 +08:00
let path = `/root/node-service/wxmpZips/${appid}/`, zipPath = `../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 12:14:33 +08:00
execute(`cd /root/node-service/wxmpZips&&zip -r ${appid}.zip ${path}`).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: "无法找到小程序信息"})
}
}