const fse = require("fs-extra"); const execute = require("../../tools/exec"); module.exports = { action: "/node/wxmp/download", method: "post", execute: (request, response) => { let appid = request.query?.appid if (appid) { let path = `/root/node-service/wxmpZips/${appid}/`, zipPath = `../wxmpZips/${appid}.zip` fse.removeSync(zipPath) fse.pathExists(path, (err, exists) => { console.log(`${path}=========>${exists}`) if (exists) { execute(`cd /root/node-service/wxmpZips&&zip -r ${appid}.zip ${path}`).then(() => { console.log('压缩完成!') setTimeout(() => { response.download(zipPath) }, 1000) }) } else response.send({code: 1, err: "没有打包文件!"}) }) } else response.send({code: 1, err: "无法找到小程序信息"}) } }