提交 456dd3db 编写于 作者: W WOSHIMAHAIFENG

修改压缩示例

上级 fd7141b5
...@@ -786,36 +786,32 @@ ...@@ -786,36 +786,32 @@
} }
}, },
unzipFileTest: function (_ : any) { unzipFileTest: function (_ : any) {
uni.downloadFile({ const fileManager = uni.getFileSystemManager()
url: 'https://b2c-store.oss-ap-southeast-1.aliyuncs.com/ceshi/FRT.zip', try {
success: (res) => { fileManager.mkdirSync(`${this.basePath}${this.targetZip}`, true)
console.log(res) } catch (e) {
const fileManager = uni.getFileSystemManager() console.error(e)
fileManager.unzip({ }
zipFilePath: res.tempFilePath, fileManager.unzip({
targetPath: `${this.basePath}${this.targetZip}`, zipFilePath: '/static/filemanager/to.zip',
success: (res : FileManagerSuccessResult) => { targetPath: `${this.basePath}${this.targetZip}`,
if (this.logAble) { success: (res : FileManagerSuccessResult) => {
this.log += 'unzipFileTest success:' + JSON.stringify(res) + '\n\n' if (this.logAble) {
} this.log += 'unzipFileTest success:' + JSON.stringify(res) + '\n\n'
console.log('success', res) }
}, console.log('success', res)
fail: (res : UniError) => { },
if (this.logAble) { fail: (res : UniError) => {
this.log += 'unzipFileTest fail:' + JSON.stringify(res) + '\n\n' if (this.logAble) {
} this.log += 'unzipFileTest fail:' + JSON.stringify(res) + '\n\n'
console.log('fail', res) }
this.lastFailError = res console.log('fail', res)
}, this.lastFailError = res
complete: (_) => {
this.done = true
}
} as UnzipFileOptions)
}, },
fail: (e) => { complete: (_) => {
console.log(e) this.done = true
} }
}) } as UnzipFileOptions)
}, },
getSavedFileListTest: function () { getSavedFileListTest: function () {
...@@ -1233,33 +1229,24 @@ ...@@ -1233,33 +1229,24 @@
} }
}, },
readZipEntry() { readZipEntry() {
uni.downloadFile({ const fileManager = uni.getFileSystemManager()
url: 'https://b2c-store.oss-ap-southeast-1.aliyuncs.com/ceshi/FRT.zip', fileManager.readZipEntry({
success: (res) => { filePath: '/static/filemanager/to.zip',
console.log(res) encoding: 'utf-8',
const fileManager = uni.getFileSystemManager() success: (res : EntriesResult) => {
fileManager.readZipEntry({ if (this.logAble) {
filePath: res.tempFilePath, this.log += 'readZipEntry success:size=' + res.result.size + '\n\n'
encoding: 'utf-8', }
success: (res : EntriesResult) => { console.log("success", res)
if (this.logAble) {
this.log += 'readZipEntry success:size=' + res.result.size + '\n\n'
}
console.log("success", res)
},
fail: (res : UniError) => {
if (this.logAble) {
this.log += 'readZipEntry fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
}
} as ReadZipEntryOptions)
}, },
fail: (e) => { fail: (res : UniError) => {
console.log(e) if (this.logAble) {
this.log += 'readZipEntry fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
} }
}) } as ReadZipEntryOptions)
}, },
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册