diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f17062..843383b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 3.0.0-rc.8 +- svg解码单位改为px +- 修复预加载接口preLoadCache传ImageKnifeOption失效 +- 文件缓存初始化接口新增目录参数 + ## 3.0.0-rc.7 - 修复成功回调获取不到宽高 - 新增svg图片解码 diff --git a/entry/src/main/ets/pages/TestPrefetchToFileCache.ets b/entry/src/main/ets/pages/TestPrefetchToFileCache.ets index d6b9e23..eb735a7 100644 --- a/entry/src/main/ets/pages/TestPrefetchToFileCache.ets +++ b/entry/src/main/ets/pages/TestPrefetchToFileCache.ets @@ -26,11 +26,18 @@ struct TestPrefetchToFileCachePage { let fileCachePath = await ImageKnife.getInstance().preLoadCache(url) console.log("preload-fileCachePath=="+ fileCachePath) } + async preload1(url:string) { + let fileCachePath = await ImageKnife.getInstance().preLoadCache({ loadSrc: url }) + console.log("preload-fileCachePath1=="+ fileCachePath) + } build() { Column() { - Button("预加载图片到文件缓存").margin({top:10}).onClick(async ()=>{ + Button("url预加载图片到文件缓存").margin({top:10}).onClick(async ()=>{ await this.preload("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658") }) + Button("option预加载图片到文件缓存").margin({top:10}).onClick(async ()=>{ + await this.preload1("https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658") + }) Button("加载图片(预加载后可断网加载)").margin({top:10}).onClick(()=>{ this.imageKnifeOption.loadSrc = "https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658" }) diff --git a/library/oh-package.json5 b/library/oh-package.json5 index a584ba0..c206a0f 100644 --- a/library/oh-package.json5 +++ b/library/oh-package.json5 @@ -14,7 +14,7 @@ "main": "index.ets", "repository": "https://gitee.com/openharmony-tpc/ImageKnife", "type": "module", - "version": "3.0.0-rc.7", + "version": "3.0.0-rc.8", "dependencies": { "@ohos/gpu_transform": "^1.0.2" }, diff --git a/library/src/main/ets/ImageKnife.ets b/library/src/main/ets/ImageKnife.ets index 19b4d08..e58fadd 100644 --- a/library/src/main/ets/ImageKnife.ets +++ b/library/src/main/ets/ImageKnife.ets @@ -65,9 +65,13 @@ export class ImageKnife { * @param size 缓存数量 * @param memory 内存大小 */ - async initFileCache(context: Context, size: number = 256, memory: number = 256 * 1024 * 1024) { + async initFileCache(context: Context, size: number = 256, memory: number = 256 * 1024 * 1024,path?: string) { this.fileCache = new FileCache(context, size, memory) - await this.fileCache.initFileCache() + if ( path != undefined ) { + await this.fileCache.initFileCache(path) + } else { + await this.fileCache.initFileCache() + } } /** @@ -166,10 +170,10 @@ export class ImageKnife { preLoadCache(loadSrc: string | ImageKnifeOption): Promise { return new Promise((resolve, reject) => { let imageKnifeOption = new ImageKnifeOption() - if (loadSrc instanceof ImageKnifeOption) { - imageKnifeOption = loadSrc + if (typeof loadSrc == "string") { + imageKnifeOption.loadSrc = loadSrc } else { - imageKnifeOption.loadSrc = loadSrc; + imageKnifeOption = loadSrc; } LogUtil.log("ImageKnife_DataTime_preLoadCache-imageKnifeOption:"+loadSrc) let fileKey = this.getEngineKeyImpl().generateFileKey(imageKnifeOption.loadSrc, imageKnifeOption.signature) diff --git a/library/src/main/ets/ImageKnifeDispatcher.ets b/library/src/main/ets/ImageKnifeDispatcher.ets index 56b81c3..03d7a70 100644 --- a/library/src/main/ets/ImageKnifeDispatcher.ets +++ b/library/src/main/ets/ImageKnifeDispatcher.ets @@ -171,7 +171,8 @@ export class ImageKnifeDispatcher { signature: currentRequest.imageKnifeOption.signature, requestSource: requestSource, isWatchProgress: isWatchProgress, - memoryKey: memoryKey + memoryKey: memoryKey, + fileCacheFolder: ImageKnife.getInstance().getFileCache().getCacheFolder() } @@ -373,7 +374,7 @@ async function requestJob(request: RequestJobRequest, requestList?: List