From 6dcf2840b36c0926e3e36a06118b3023c20c7ab9 Mon Sep 17 00:00:00 2001 From: zgf Date: Fri, 27 Sep 2024 09:58:27 +0800 Subject: [PATCH] =?UTF-8?q?FileUtil.readFile=E6=8E=A5=E5=8F=A3=E5=92=8Cfil?= =?UTF-8?q?e=E6=A0=BC=E5=BC=8F=E5=9B=BE=E7=89=87=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E5=85=B3=E9=97=ADfd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zgf --- CHANGELOG.md | 9 ++++++ library/src/main/ets/ImageKnifeDispatcher.ets | 32 +++++++++++-------- .../ImageKnifeAnimatorComponent.ets | 23 +++---------- library/src/main/ets/utils/FileUtils.ets | 1 + 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c5d7cc..2fd51a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 3.0.2-rc.0 +- FileUtil.readFile接口和file格式图片同步关闭fd + +## 3.0.1 +- 修复animatorOption属性设置初始化值失效 +- 网络请求code为206、204时返回arraybuffer +- ImageKnifeComponent显示非必要文件缓存初始化 +- 修复webp静态图无法设置图形变换 + ## 3.0.1-rc.2 - 修复自定义下载失败无失败回调 - 增加全局配置自定义下载接口 diff --git a/library/src/main/ets/ImageKnifeDispatcher.ets b/library/src/main/ets/ImageKnifeDispatcher.ets index 795d709..3c2f4fb 100644 --- a/library/src/main/ets/ImageKnifeDispatcher.ets +++ b/library/src/main/ets/ImageKnifeDispatcher.ets @@ -175,7 +175,7 @@ export class ImageKnifeDispatcher { requestSource: requestSource, isWatchProgress: isWatchProgress, memoryKey: memoryKey, - fileCacheFolder: ImageKnife.getInstance().getFileCache().getCacheFolder(), + fileCacheFolder: ImageKnife.getInstance().getFileCache()?.getCacheFolder(), isAnimator:isAnimator } @@ -467,7 +467,7 @@ async function requestJob(request: RequestJobRequest, requestList?: List { - if (data == 200) { + if (data == 200 || data == 204 || data == 201 || data == 206) { resBuf = combineArrayBuffers(arrayBuffers) } else { loadError = "HttpDownloadClient has error, http code =" + JSON.stringify(data) @@ -496,7 +496,7 @@ async function requestJob(request: RequestJobRequest, requestList?: List { resBuf = buf; - fs.close(file.fd); + fs.closeSync(file.fd); }).catch((err:BusinessError) => { loadError = 'LoadDataShareFileClient fs.read err happened uri=' + request.src + " err.msg=" + err?.message + " err.code=" + err?.code; }) @@ -608,19 +608,23 @@ async function requestJob(request: RequestJobRequest, requestList?: List | undefined = undefined - @State state: AnimationStatus = AnimationStatus.Running - @State iterations: number = -1 - @State reverse: boolean = false @State adaptiveWidth: Length = '100%' @State adaptiveHeight: Length = '100%' @State objectFit: ImageFit = ImageFit.Contain @@ -64,9 +61,9 @@ export struct ImageKnifeAnimatorComponent { .width(this.adaptiveWidth) .height(this.adaptiveHeight) .border(this.imageKnifeOption.border) - .state(this.state) - .iterations(this.iterations) - .reverse(this.reverse) + .state(this.animatorOption.state == undefined ? AnimationStatus.Running : this.animatorOption.state) + .iterations(this.animatorOption.iterations == undefined ? -1 : this.animatorOption.iterations) + .reverse(this.animatorOption.reverse == undefined ? false : this.animatorOption.reverse) .onSizeChange((oldValue:SizeOptions, newValue:SizeOptions) => { this.currentWidth = newValue.width as number this.currentHeight = newValue.height as number @@ -84,18 +81,6 @@ export struct ImageKnifeAnimatorComponent { }) } - watchAnimatorOption(){ - if(this.animatorOption.state != undefined) { - this.state = this.animatorOption.state - } - if(this.animatorOption.iterations != undefined) { - this.iterations = this.animatorOption.iterations - } - if(this.animatorOption.reverse != undefined) { - this.reverse = this.animatorOption.reverse - } - } - watchImageKnifeOption() { if (this.request !== undefined) { this.request.requestState = ImageKnifeRequestState.DESTROY diff --git a/library/src/main/ets/utils/FileUtils.ets b/library/src/main/ets/utils/FileUtils.ets index 5f41dd1..9c5722c 100644 --- a/library/src/main/ets/utils/FileUtils.ets +++ b/library/src/main/ets/utils/FileUtils.ets @@ -176,6 +176,7 @@ export class FileUtils { let length = stat.size; let buf = new ArrayBuffer(length); await fs.read(fd, buf); + await fs.close(fd) return buf } catch (error) { let err: BusinessError = error as BusinessError;