修复动图控制组件初始值失效、网络请求成功code以及文件缓存可选初始化

Signed-off-by: zgf <zenggaofeng2@h-partners.com>
This commit is contained in:
zgf 2024-08-02 16:25:41 +08:00
parent f497f32c48
commit 69f951b290
3 changed files with 11 additions and 21 deletions

View File

@ -1,3 +1,8 @@
## 3.0.1
- 修复animatorOption属性设置初始化值失效
- 网络请求code为206、204时返回arraybuffer
- ImageKnifeComponent显示非必要文件缓存初始化
## 3.0.1-rc.2
- 修复自定义下载失败无失败回调
- 增加全局配置自定义下载接口

View File

@ -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<ImageKn
});
await promise.then((data: number) => {
if (data == 200) {
if (data == 200 || data == 206 || data == 204) {
resBuf = combineArrayBuffers(arrayBuffers)
} else {
loadError = "HttpDownloadClient has error, http code =" + JSON.stringify(data)

View File

@ -22,12 +22,9 @@ import { ImageKnifeRequestSource } from '../model/ImageKnifeData';
@Component
export struct ImageKnifeAnimatorComponent {
@Watch('watchImageKnifeOption') @ObjectLink imageKnifeOption: ImageKnifeOption;
@Watch('watchAnimatorOption') @State animatorOption: AnimatorOption = new AnimatorOption();
@State animatorOption: AnimatorOption = new AnimatorOption();
@State pixelMap: PixelMap | string | undefined = undefined
@State imageAnimator: Array<ImageFrameInfo> | 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