forked from floraachy/ImageKnife
1.更新版本号至2.0.6
2.更新CHANGELOG.md文件 3.更新README.md文件 Signed-off-by: zhoulisheng1 <zhoulisheng1@huawei.com>
This commit is contained in:
parent
bd887825e7
commit
51fff045d8
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,3 +1,15 @@
|
|||
## 2.0.6
|
||||
|
||||
- ArkTs语法整改:
|
||||
|
||||
globalThis.ImageKnife方式已经不可使用
|
||||
|
||||
提供了ImageKnifeGlobal对象单例全局可访问
|
||||
|
||||
访问ImageKnife对象需要使用ImageKnifeGlobal.getInstance().getImageKnife()
|
||||
|
||||
- 适配DevEco Studio 版本:4.0(4.0.3.512), SDK: API10 (4.0.10.9)
|
||||
|
||||
## 2.0.5
|
||||
|
||||
- 修复若干问题:
|
||||
|
|
46
README.md
46
README.md
|
@ -37,7 +37,7 @@ ohpm install @ohos/imageknife
|
|||
"author": "",
|
||||
"license": "",
|
||||
"dependencies": {
|
||||
"@ohos/imageknife": "^2.0.2"
|
||||
"@ohos/imageknife": "^2.0.6"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -53,8 +53,9 @@ export default class EntryAbility extends UIAbility {
|
|||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
windowStage.loadContent('pages/Index', (err, data) => {
|
||||
});
|
||||
//初始化全局ImageKnife
|
||||
globalThis.ImageKnife = ImageKnife.with(this.context);
|
||||
// 初始化全局ImageKnife
|
||||
ImageKnife.with(this.context);
|
||||
// 后续访问ImageKnife请通过:ImageKnifeGlobal.getInstance().getImageKnife()方式
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -109,13 +110,13 @@ GIF图片即可。
|
|||
```extendtypescript
|
||||
import router from '@ohos.router'
|
||||
|
||||
import { ImageKnifeComponent, ImageKnifeOption, } from '@ohos/imageknife'
|
||||
import { ImageKnifeComponent, ImageKnifeOption,ImageKnife } from '@ohos/imageknife'
|
||||
import worker from '@ohos.worker';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct IndexFunctionDemo {
|
||||
private globalGifWorker: any = undefined
|
||||
private globalGifWorker?:worker.ThreadWorker = undefined;
|
||||
@State imageKnifeOption1: ImageKnifeOption = {
|
||||
loadSrc: $r('app.media.icon'),
|
||||
placeholderSrc: $r('app.media.icon_loading'),
|
||||
|
@ -174,9 +175,15 @@ struct IndexFunctionDemo {
|
|||
}
|
||||
|
||||
aboutToAppear() {
|
||||
this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts')
|
||||
this.globalGifWorker = new worker.ThreadWorker('entry/ets/workers/GifLoadWorker.ts', {
|
||||
type: 'classic',
|
||||
name: 'ImageKnifeParseGIF'
|
||||
})
|
||||
// gif解析在子线程,请在页面构建后创建worker,注入imageknife
|
||||
globalThis.ImageKnife.setGifWorker(this.globalGifWorker)
|
||||
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife()
|
||||
if(imageKnife != undefined) {
|
||||
imageKnife.setGifWorker(this.globalGifWorker)
|
||||
}
|
||||
}
|
||||
|
||||
aboutToDisappear() {
|
||||
|
@ -322,17 +329,20 @@ svg返回的都是PixelMap,gif返回GIFFrame数组),我们返回了true。
|
|||
当进行加载网络图片时,可能需要展示网络下载百分比动画。但是默认的动画又不能满足需求,这个时候我们就需要自定义网络下载百分比效果。代码如下:
|
||||
|
||||
```typescript
|
||||
import AbilityStage from '@ohos.application.AbilityStage'
|
||||
import { ImageKnife, ImageKnifeDrawFactory } from '@ohos/imageknife'
|
||||
|
||||
import ArkWorker from '@ohos.worker'
|
||||
|
||||
export default class MyAbilityStage extends AbilityStage {
|
||||
onCreate() {
|
||||
globalThis.ImageKnife = ImageKnife.with(this.context);
|
||||
// 全局配置网络加载进度条
|
||||
globalThis.ImageKnife.setDefaultLifeCycle(ImageKnifeDrawFactory.createProgressLifeCycle("#10a5ff", 0.5))
|
||||
}
|
||||
import UIAbility from '@ohos.app.ability.UIAbility';
|
||||
import window from '@ohos.window';
|
||||
import { ImageKnifeGlobal,ImageKnife,ImageKnifeDrawFactory,LogUtil } from '@ohos/imageknife'
|
||||
import abilityAccessCtrl,{Permissions} from '@ohos.abilityAccessCtrl';
|
||||
export default class EntryAbility extends UIAbility {
|
||||
onWindowStageCreate(windowStage: window.WindowStage) {
|
||||
//.. 删除不必要代码
|
||||
windowStage.loadContent('pages/index', (err, data) => {
|
||||
});
|
||||
// 初始化ImageKnifeGlobal和ImageKnife
|
||||
ImageKnife.with(this.context);
|
||||
// 全局配置网络加载进度条 使用ImageKnifeGlobal.getInstance().getImageKnife()访问ImageKnife
|
||||
ImageKnifeGlobal.getInstance().getImageKnife().setDefaultLifeCycle(ImageKnifeDrawFactory.createProgressLifeCycle("#10a5ff", 0.5))
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"main": "index.ets",
|
||||
"repository": "https://gitee.com/openharmony-tpc/ImageKnife",
|
||||
"type": "module",
|
||||
"version": "2.0.5-rc.0",
|
||||
"version": "2.0.6",
|
||||
"dependencies": {
|
||||
"@ohos/disklrucache": "^2.0.0",
|
||||
"@ohos/svg": "^2.0.0",
|
||||
|
|
Loading…
Reference in New Issue