优化打包下载

This commit is contained in:
aixianling
2022-06-10 12:00:22 +08:00
parent 95663704d1
commit bc79fa48be

View File

@@ -9,12 +9,12 @@ module.exports = {
dbUtils.query(sql).then(res => {
let info = res?.[0]
if (info?.id) {
let path = `${info.target}`, zipPath = `./zips/${info.id}.zip`
let path = `${info.target}`, zipPath = `../zips/${info.id}.zip`
fse.removeSync(zipPath)
fse.pathExists(path, (err, exists) => {
console.log(`${path}=========>${exists}`)
if (exists) {
execute(`zip -r ${zipPath} ${path}`).then(() => {
execute(`cd ../zips`).then(() => execute(`zip -r ${info.id}.zip ${path}`)).then(() => {
console.log('压缩完成!')
setTimeout(() => {
response.download(zipPath)