From 5f509f0533b089b4d06d32cb29f0a9ce4630c788 Mon Sep 17 00:00:00 2001 From: shanghuanni Date: Wed, 6 Sep 2023 09:36:44 +0800 Subject: [PATCH] =?UTF-8?q?js-apis-hichecker=E5=91=8A=E8=AD=A6=E6=B8=85?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shanghuanni --- .../reference/apis/js-apis-hichecker.md | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-hichecker.md b/zh-cn/application-dev/reference/apis/js-apis-hichecker.md index 74cd7a0da3..9117de7631 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hichecker.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hichecker.md @@ -9,7 +9,7 @@ HiChecker可以作为应用开发阶段使用的检测工具,用于检测代 ## 导入模块 -```js +```ts import hichecker from '@ohos.hichecker'; ``` @@ -43,7 +43,9 @@ addCheckRule(rule: bigint): void **示例:** -```js +```ts +import { BusinessError } from '@ohos.base'; + try { // 添加一条规则 hichecker.addCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); @@ -51,7 +53,7 @@ try { // hichecker.addCheckRule( // hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); } catch (err) { - console.error(`code: ${err.code}, message: ${err.message}`); + console.error(`code: ${(err as BusinessError).code}, message: ${(err as BusinessError).message}`); } ``` @@ -71,7 +73,9 @@ removeCheckRule(rule: bigint): void **示例:** -```js +```ts +import { BusinessError } from '@ohos.base' + try { // 删除一条规则 hichecker.removeCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); @@ -79,7 +83,7 @@ try { // hichecker.removeCheckRule( // hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); } catch (err) { - console.error(`code: ${err.code}, message: ${err.message}`); + console.error(`code: ${(err as BusinessError).code}, message: ${(err as BusinessError).message}`); } ``` @@ -105,7 +109,9 @@ containsCheckRule(rule: bigint): boolean **示例:** -```js +```ts +import { BusinessError } from '@ohos.base' + try { // 添加一条规则 hichecker.addCheckRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); @@ -114,7 +120,7 @@ try { hichecker.containsCheckRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // return true; hichecker.containsCheckRule(hichecker.RULE_CAUTION_PRINT_LOG); // return false; } catch (err) { - console.error(`code: ${err.code}, message: ${err.message}`); + console.error(`code: ${(err as BusinessError).code}, message: ${(err as BusinessError).message}`); } ``` @@ -138,7 +144,7 @@ addRule(rule: bigint): void **示例:** -```js +```ts // 添加一条规则 hichecker.addRule(hichecker.RULE_CAUTION_PRINT_LOG); @@ -167,7 +173,7 @@ removeRule(rule: bigint): void **示例:** -```js +```ts // 删除一条规则 hichecker.removeRule(hichecker.RULE_CAUTION_PRINT_LOG); @@ -192,7 +198,7 @@ getRule(): bigint **示例:** -```js +```ts // 添加一条规则 hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); @@ -226,7 +232,7 @@ contains(rule: bigint): boolean **示例:** -```js +```ts // 添加一条规则 hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); -- GitLab