提交 6909d900 authored 作者: JaxBBLL's avatar JaxBBLL
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
}, },
{ {
"userId": "5", "userId": "5",
"user": "admin", "user": "管理员",
"avatar": "", "avatar": "",
"passWord": "123456", "passWord": "Gly@124",
"roleName": "超级管理员", "roleName": "超级管理员",
"isAdmin": 1, "isAdmin": 1,
"unitName": "运维", "unitName": "运维",
......
...@@ -249,9 +249,8 @@ ...@@ -249,9 +249,8 @@
zipCompress(`${SYNCHRONIZE_DATA_PAD}/发送数据`, zipCompress(`${SYNCHRONIZE_DATA_PAD}/发送数据`,
`${SYNCHRONIZE_DATA_PAD}/fssj/${userName}_JFXJ_${timeStr}.zip` `${SYNCHRONIZE_DATA_PAD}/fssj/${userName}_JFXJ_${timeStr}.zip`
); );
debugger
// zip // zip
// await inspectApi.updateSyncData(ids); await inspectApi.updateSyncData(ids);
this.close(); this.close();
this.loading = false; this.loading = false;
......
...@@ -473,48 +473,15 @@ export function getUserList() { ...@@ -473,48 +473,15 @@ export function getUserList() {
export function zipCompress(sourceDir, zipPath) { export function zipCompress(sourceDir, zipPath) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// 递归函数,用于收集目录中的所有文件路径 plus.zip.compress(
function collectFiles(dirEntry, filePaths = []) { plus.io.convertLocalFileSystemURL(sourceDir),
return new Promise((resolveCollect, rejectCollect) => { plus.io.convertLocalFileSystemURL(zipPath),
var directoryReader = dirEntry.createReader(); {
directoryReader.readEntries(function(entries) { recursive: true,
var promises = []; overwrite: true,
entries.forEach(function(entry) { },
if (entry.isFile) { () => resolve(zipPath),
filePaths.push(entry.toLocalURL()); (error) => reject(`压缩失败: ${error.message}`)
} else if (entry.isDirectory) { );
promises.push(collectFiles(entry, filePaths));
}
});
Promise.all(promises).then(() => resolveCollect(filePaths)).catch(rejectCollect);
}, function(e) {
rejectCollect(e);
});
});
}
// 开始收集文件
plus.io.resolveLocalFileSystemURL(sourceDir, function(dirEntry) {
if (dirEntry.isDirectory) {
collectFiles(dirEntry).then(function(allFilePaths) {
debugger
// 使用收集到的文件路径进行压缩
plus.zip.compress(
allFilePaths,
plus.io.convertLocalFileSystemURL(zipPath),
function() {
resolve(zipPath);
},
function(error) {
reject(`压缩失败: ${error.message}`);
}
);
}).catch(reject);
} else {
reject('提供的路径不是一个目录');
}
}, function(e) {
reject(`解析文件系统URL失败: ${e.message}`);
});
}); });
} }
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论