From 456dd3db60ac38d0722c97bd5b57d2c0354b8466 Mon Sep 17 00:00:00 2001 From: WOSHIMAHAIFENG Date: Mon, 22 Apr 2024 18:16:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8E=8B=E7=BC=A9=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../get-file-system-manager.uvue | 93 ++++++++---------- static/filemanager/to.zip | Bin 0 -> 1380 bytes 2 files changed, 40 insertions(+), 53 deletions(-) create mode 100644 static/filemanager/to.zip diff --git a/pages/API/get-file-system-manager/get-file-system-manager.uvue b/pages/API/get-file-system-manager/get-file-system-manager.uvue index d80c34a8..22367a84 100644 --- a/pages/API/get-file-system-manager/get-file-system-manager.uvue +++ b/pages/API/get-file-system-manager/get-file-system-manager.uvue @@ -786,36 +786,32 @@ } }, unzipFileTest: function (_ : any) { - uni.downloadFile({ - url: 'https://b2c-store.oss-ap-southeast-1.aliyuncs.com/ceshi/FRT.zip', - success: (res) => { - console.log(res) - const fileManager = uni.getFileSystemManager() - fileManager.unzip({ - zipFilePath: res.tempFilePath, - targetPath: `${this.basePath}${this.targetZip}`, - success: (res : FileManagerSuccessResult) => { - if (this.logAble) { - this.log += 'unzipFileTest success:' + JSON.stringify(res) + '\n\n' - } - console.log('success', res) - }, - fail: (res : UniError) => { - if (this.logAble) { - this.log += 'unzipFileTest fail:' + JSON.stringify(res) + '\n\n' - } - console.log('fail', res) - this.lastFailError = res - }, - complete: (_) => { - this.done = true - } - } as UnzipFileOptions) + const fileManager = uni.getFileSystemManager() + try { + fileManager.mkdirSync(`${this.basePath}${this.targetZip}`, true) + } catch (e) { + console.error(e) + } + fileManager.unzip({ + zipFilePath: '/static/filemanager/to.zip', + targetPath: `${this.basePath}${this.targetZip}`, + success: (res : FileManagerSuccessResult) => { + if (this.logAble) { + this.log += 'unzipFileTest success:' + JSON.stringify(res) + '\n\n' + } + console.log('success', res) + }, + fail: (res : UniError) => { + if (this.logAble) { + this.log += 'unzipFileTest fail:' + JSON.stringify(res) + '\n\n' + } + console.log('fail', res) + this.lastFailError = res }, - fail: (e) => { - console.log(e) + complete: (_) => { + this.done = true } - }) + } as UnzipFileOptions) }, getSavedFileListTest: function () { @@ -1233,33 +1229,24 @@ } }, readZipEntry() { - uni.downloadFile({ - url: 'https://b2c-store.oss-ap-southeast-1.aliyuncs.com/ceshi/FRT.zip', - success: (res) => { - console.log(res) - const fileManager = uni.getFileSystemManager() - fileManager.readZipEntry({ - filePath: res.tempFilePath, - encoding: 'utf-8', - success: (res : EntriesResult) => { - 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) + const fileManager = uni.getFileSystemManager() + fileManager.readZipEntry({ + filePath: '/static/filemanager/to.zip', + encoding: 'utf-8', + success: (res : EntriesResult) => { + if (this.logAble) { + this.log += 'readZipEntry success:size=' + res.result.size + '\n\n' + } + console.log("success", res) }, - fail: (e) => { - console.log(e) + fail: (res : UniError) => { + if (this.logAble) { + this.log += 'readZipEntry fail:' + JSON.stringify(res) + '\n\n' + } + console.log('fail', res) + this.lastFailError = res } - }) + } as ReadZipEntryOptions) }, }, diff --git a/static/filemanager/to.zip b/static/filemanager/to.zip new file mode 100644 index 0000000000000000000000000000000000000000..c7417b4844e387b583781d85dfc23a37ddb9e827 GIT binary patch literal 1380 zcmWIWW@Zs#-~hse>c$8LC}0QDtPBbahI%CxC7~g_4D3e}xzgsEsHOD+acKoN10%~< zMg|6;Rt5%dZ%scRZ%sCa0B?2<~Wa+R(rtj44xLexWII-~mGw6^=tpFB7gX z7|pskWrM@fpOO+sCVwveD#XoI6!g_8NZTvs^Q6zgMxQS!{yN*(!ob`t;^ga>ROp#m znC0b_x?C4Snh=`*I!ITa8!X<2q+ZbnX0N=9C0 z;-&0G)7UPhWF6CDSY#i2%5vLnoeb;$i`L#upKp9NX2Y-QcfrZ4FS~!8a%Y*9X06S+ zGp5T|^*1kmA<6Fj^^mdpYkt?(9nl-o)~|n+ct1|}%G~;l&(Cr^KR&t=|FbRiIrGxZ zb@tYk(K}1-Rl2dYwQXikopWuw4-+_MUdU!%wgHAcDEzU<3@p}-Fk&4P^Hh&@OlwAC zoyM`w$Rxsy$nD5^6_ndyU`Zp0g_$X_>xoAd}QAk8V0{2Y&-5 pYRvS6CE21IiQB