From 2a66bdbbba1b4ed0df88be3999362ccb1410609b Mon Sep 17 00:00:00 2001 From: zenggaofeng Date: Fri, 12 Apr 2024 10:28:56 +0800 Subject: [PATCH] =?UTF-8?q?LogUtil=E6=97=A5=E5=BF=97=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=85=B3=E9=97=ADOFF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zenggaofeng --- README.md | 1 + entry/src/main/ets/entryability/EntryAbility.ets | 4 ++-- entry/src/main/module.json5 | 2 ++ entry/src/main/resources/base/element/string.json | 8 ++++++++ entry/src/main/resources/en_US/element/string.json | 8 ++++++++ entry/src/main/resources/zh_CN/element/string.json | 8 ++++++++ library/index.ets | 1 + library/src/main/ets/utils/LogUtil.ets | 2 +- 8 files changed, 31 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4e37f6c..0aa52b9 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ - 支持生命周期已销毁的图片,不再发起请求 待实现特性 +- svg图片显示 - gif/webp动图显示与控制 - 内存降采样优化,节约内存的占用 - 支持自定义图片加载 diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 3066439..675efde 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -17,7 +17,7 @@ import hilog from '@ohos.hilog'; import UIAbility from '@ohos.app.ability.UIAbility'; import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; -import { ImageKnife } from '@ohos/imageknife'; +import { ImageKnife,LogUtil } from '@ohos/imageknife'; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { @@ -34,7 +34,7 @@ export default class EntryAbility extends UIAbility { // 初始化ImageKnife的文件缓存 await ImageKnife.getInstance().initFileCache(this.context, 256, 256 * 1024 * 1024) - + LogUtil.mLogLevel = LogUtil.ALL windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 54cf03a..e5aff0d 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -46,6 +46,7 @@ }, { "name": "ohos.permission.MEDIA_LOCATION", + "reason":"$string:app_permission_MEDIA_LOCATION", "usedScene": { "abilities": [ "EntryAbility" @@ -55,6 +56,7 @@ }, { "name": "ohos.permission.READ_MEDIA", + "reason": "$string:app_permission_MEDIA_LOCATION", "usedScene": { "abilities": [ "EntryAbility" diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index f945955..9d7e8dd 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -11,6 +11,14 @@ { "name": "EntryAbility_label", "value": "label" + }, + { + "name": "app_permission_MEDIA_LOCATION", + "value": "获取媒体图片" + }, + { + "name": "app_permission_READ_MEDIA", + "value": "读媒体图片" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json index f945955..9d7e8dd 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -11,6 +11,14 @@ { "name": "EntryAbility_label", "value": "label" + }, + { + "name": "app_permission_MEDIA_LOCATION", + "value": "获取媒体图片" + }, + { + "name": "app_permission_READ_MEDIA", + "value": "读媒体图片" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index 597ecf9..bb49ac2 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -11,6 +11,14 @@ { "name": "EntryAbility_label", "value": "label" + }, + { + "name": "app_permission_MEDIA_LOCATION", + "value": "获取媒体图片" + }, + { + "name": "app_permission_READ_MEDIA", + "value": "读媒体图片" } ] } \ No newline at end of file diff --git a/library/index.ets b/library/index.ets index 7a3fa16..b6c20fd 100644 --- a/library/index.ets +++ b/library/index.ets @@ -8,4 +8,5 @@ export { ImageKnifeRequest } from './src/main/ets/ImageKnifeRequest' export { FileUtils } from './src/main/ets/utils/FileUtils' +export { LogUtil } from './src/main/ets/utils/LogUtil' diff --git a/library/src/main/ets/utils/LogUtil.ets b/library/src/main/ets/utils/LogUtil.ets index 11a3645..02c2d39 100644 --- a/library/src/main/ets/utils/LogUtil.ets +++ b/library/src/main/ets/utils/LogUtil.ets @@ -20,7 +20,7 @@ export class LogUtil { public static WARN: number = 5 public static ERROR: number = 6 public static ALL: number = 7 - public static mLogLevel: number = LogUtil.ALL; + public static mLogLevel: number = LogUtil.OFF; public static TAG: string = "ImageKnife:: "; public static debug(message: string, ...args: Object[]) {