优化打包下载
This commit is contained in:
@@ -9,12 +9,12 @@ module.exports = {
|
|||||||
dbUtils.query(sql).then(res => {
|
dbUtils.query(sql).then(res => {
|
||||||
let info = res?.[0]
|
let info = res?.[0]
|
||||||
if (info?.id) {
|
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.removeSync(zipPath)
|
||||||
fse.pathExists(path, (err, exists) => {
|
fse.pathExists(path, (err, exists) => {
|
||||||
console.log(`${path}=========>${exists}`)
|
console.log(`${path}=========>${exists}`)
|
||||||
if (exists) {
|
if (exists) {
|
||||||
execute(`zip -r ${zipPath} ${path}`).then(() => {
|
execute(`cd ../zips`).then(() => execute(`zip -r ${info.id}.zip ${path}`)).then(() => {
|
||||||
console.log('压缩完成!')
|
console.log('压缩完成!')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
response.download(zipPath)
|
response.download(zipPath)
|
||||||
|
|||||||
Reference in New Issue
Block a user