diff --git a/package.json b/package.json index cf429d2..bfea5fd 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ }, "author": "kubbo", "dependencies": { - "archiver": "^5.3.0", "dayjs": "^1.11.0", "express": "^4.17.3", "fs-extra": "^10.0.1", diff --git a/src/rest/wechat/download.js b/src/rest/wechat/download.js index dfd3684..e94fa2c 100644 --- a/src/rest/wechat/download.js +++ b/src/rest/wechat/download.js @@ -1,25 +1,17 @@ -const archiver = require("archiver") const fse = require("fs-extra"); -const fs = require("fs"); +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 = `../wxmpZips/${appid}/`, zipPath = `../wxmpZips/${appid}.zip` + 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) { - let output = fs.createWriteStream(zipPath), - arc = archiver('zip') - arc.on('error', err => { - response.send({code: 1, err}) - }) - arc.pipe(output) - arc.directory(path, false) - arc.finalize().then(() => { + execute(`cd /root/node-service/wxmpZips&&zip -r ${appid}.zip ${path}`).then(() => { console.log('压缩完成!') setTimeout(() => { response.download(zipPath)