diff --git a/CHANGELOG.md b/CHANGELOG.md index 3715d2f..69bf3b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 3.0.0-rc.5 - 图片加载事件增加请求开始的回调,以及修复有缓存时,没有回调的bug - 修复对已销毁组件不再下发请求的逻辑 +- Watch监听imageKnifeOption属性改为@State,对imageKnifeOption对象里面内容进行监听 ## 3.0.0-rc.4 - 支持hsp多包图片资源 diff --git a/build-profile.json5 b/build-profile.json5 index d2d4041..1d9a371 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -7,8 +7,8 @@ { "name": "default", "signingConfig": "default", - "compileSdkVersion": "4.1.0(11)", - "compatibleSdkVersion": "4.1.0(11)", + "compileSdkVersion": "5.0.0(12)", + "compatibleSdkVersion": "5.0.0(12)", "runtimeOS": "HarmonyOS", } ], diff --git a/library/src/main/ets/ImageKnifeOption.ets b/library/src/main/ets/ImageKnifeOption.ets index 1531896..7cd5366 100644 --- a/library/src/main/ets/ImageKnifeOption.ets +++ b/library/src/main/ets/ImageKnifeOption.ets @@ -23,42 +23,46 @@ export interface HeaderOptions { } @Observed export class ImageKnifeOption { + @Track // 主图资源 loadSrc: string | PixelMap | Resource = ""; // 占位图 placeholderSrc?: string | PixelMap | Resource; // 失败占位图 errorholderSrc?: string | PixelMap | Resource; - + @Track headerOption?: Array; - + @Track // 自定义缓存关键字 signature?: string; - + @Track // 主图填充效果 objectFit?: ImageFit - + @Track // 占位图填充效果 placeholderObjectFit?: ImageFit - + @Track // 错误图填充效果 errorholderObjectFit?: ImageFit - + @Track customGetImage?: (context: Context, src: string | PixelMap | Resource) => Promise - + @Track border?: BorderOptions // 缓存策略 + @Track writeCacheStrategy?: CacheStrategy // 仅使用缓存加载数据 + @Track onlyRetrieveFromCache?: boolean = false; - + @Track priority? : taskpool.Priority = taskpool.Priority.LOW - + @Track context?: common.UIAbilityContext; - + @Track progressListener?: (progress: number)=>void; - + @Track transformation?: PixelMapTransformation + @Track onLoadListener?: OnLoadCallBack | undefined; constructor() { diff --git a/library/src/main/ets/components/ImageKnifeComponent.ets b/library/src/main/ets/components/ImageKnifeComponent.ets index 2d8c3bd..7fee453 100644 --- a/library/src/main/ets/components/ImageKnifeComponent.ets +++ b/library/src/main/ets/components/ImageKnifeComponent.ets @@ -21,7 +21,7 @@ import { ImageKnifeRequestSource } from '../model/ImageKnifeData'; @Component export struct ImageKnifeComponent { - @Watch('watchImageKnifeOption') @ObjectLink imageKnifeOption: ImageKnifeOption; + @Watch('watchImageKnifeOption') @State imageKnifeOption: ImageKnifeOption = new ImageKnifeOption(); @State pixelMap: PixelMap | string | undefined = undefined @State adaptiveWidth: Length = '100%' @State adaptiveHeight: Length = '100%' @@ -53,7 +53,15 @@ export struct ImageKnifeComponent { this.request = undefined } } - + aboutToReuse(params: ESObject): void { + this.imageKnifeOption = params.imageKnifeOption + if (this.request !== undefined) { + this.request.requestState = ImageKnifeRequestState.DESTROY + } + this.request = undefined + this.componentVersion++ + ImageKnife.getInstance().execute(this.getRequest(this.currentWidth, this.currentHeight)) + } aboutToRecycle() { if (this.request !== undefined) { this.request.requestState = ImageKnifeRequestState.DESTROY @@ -90,7 +98,6 @@ export struct ImageKnifeComponent { this.request.requestState = ImageKnifeRequestState.DESTROY } this.request = undefined - this.componentVersion++ ImageKnife.getInstance().execute(this.getRequest(this.currentWidth, this.currentHeight)) }