Pre Merge pull request !264 from zgf/3.x

This commit is contained in:
zgf 2024-05-18 01:45:49 +00:00 committed by Gitee
commit 66de3e3ebd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 28 additions and 16 deletions

View File

@ -1,6 +1,7 @@
## 3.0.0-rc.5
- 图片加载事件增加请求开始的回调,以及修复有缓存时没有回调的bug
- 修复对已销毁组件不再下发请求的逻辑
- Watch监听imageKnifeOption属性改为@State,对imageKnifeOption对象里面内容进行监听
## 3.0.0-rc.4
- 支持hsp多包图片资源

View File

@ -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",
}
],

View File

@ -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<HeaderOptions>;
@Track
// 自定义缓存关键字
signature?: string;
@Track
// 主图填充效果
objectFit?: ImageFit
@Track
// 占位图填充效果
placeholderObjectFit?: ImageFit
@Track
// 错误图填充效果
errorholderObjectFit?: ImageFit
@Track
customGetImage?: (context: Context, src: string | PixelMap | Resource) => Promise<ArrayBuffer | undefined>
@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() {

View File

@ -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))
}