mirror of
https://github.com/MCSManager/MCSManager.git
synced 2024-11-21 03:12:10 +08:00
解压文件测试通过
This commit is contained in:
parent
aaf8df7e86
commit
dd8f6f3803
@ -6,6 +6,7 @@ const {
|
||||
} = require("./base_fsoperate");
|
||||
const fsex = require('fs-extra');
|
||||
const AdmZip = require('adm-zip');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
|
||||
|
||||
@ -150,6 +151,13 @@ class FileOperate extends BaseFileOperate {
|
||||
try {
|
||||
const zip = new AdmZip(absPath);
|
||||
const zipExtractDir = absPath.split('.')[0];
|
||||
// zip.extractAllTo(zipExtractDir, true);
|
||||
// 解决目录中中文乱码问题
|
||||
const zipEntries = zip.getEntries();
|
||||
for (let i = 0; i < zipEntries.length; i++) {
|
||||
const entry = zipEntries[i];
|
||||
entry.entryName = iconv.decode(entry.rawEntryName, 'gbk');
|
||||
}
|
||||
zip.extractAllTo(zipExtractDir, true);
|
||||
return true;
|
||||
} catch (err) {
|
||||
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -13,6 +13,19 @@
|
||||
"negotiator": "0.6.1"
|
||||
}
|
||||
},
|
||||
"adm-zip": {
|
||||
"version": "0.4.13",
|
||||
"resolved": "https://registry.npm.taobao.org/adm-zip/download/adm-zip-0.4.13.tgz",
|
||||
"integrity": "sha1-WX4vjMNnIVHhMH0+lc3bx1ZyMUo="
|
||||
},
|
||||
"adm-zip-iconv": {
|
||||
"version": "0.4.9",
|
||||
"resolved": "https://registry.npm.taobao.org/adm-zip-iconv/download/adm-zip-iconv-0.4.9.tgz",
|
||||
"integrity": "sha1-SUGLPuUrbJ4G+Vcg7zdYVv48qf8=",
|
||||
"requires": {
|
||||
"iconv-lite": "^0.4.18"
|
||||
}
|
||||
},
|
||||
"array-flatten": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "http://registry.npm.taobao.org/array-flatten/download/array-flatten-1.1.1.tgz",
|
||||
|
@ -17,6 +17,8 @@
|
||||
"paji"
|
||||
],
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.4.13",
|
||||
"adm-zip-iconv": "^0.4.9",
|
||||
"body-parser": "^1.17.2",
|
||||
"colors": "^1.1.2",
|
||||
"compression": "^1.7.2",
|
||||
|
Loading…
Reference in New Issue
Block a user