“43ba24e051f3166d35d3860c4669ba0d0560cc61”上不存在“...client/git@gitcode.net:s920243400/PaddleDetection.git”
未验证 提交 90885f6f 编写于 作者: 1 189******51 提交者: Gitee

IssueNo: #I7WVE9:[新需求]: Rectify the arkts syntax on monthly

Description: Rectify the arkts syntax2 on monthly
Sig: SIG_ApplicaitonFramework
Feature or Bugfix: Feature
Binary Source: No
Signed-off-by: N189******51 <lipeicheng5@huawei.com>
上级 fb8a824a
...@@ -51,9 +51,11 @@ getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallba ...@@ -51,9 +51,11 @@ getLauncherAbilityInfo(bundleName: string, userId: number, callback: AsyncCallba
```ts ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getLauncherAbilityInfo('com.example.demo', 100, (errData, data) => { launcherBundleManager.getLauncherAbilityInfo('com.example.demo', 100,
(errData: BusinessError, data: launcherBundleManager.LauncherAbilityInfo[]) => {
if (errData !== null) { if (errData !== null) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
} else { } else {
...@@ -61,7 +63,9 @@ try { ...@@ -61,7 +63,9 @@ try {
} }
}) })
} catch (errData) { } catch (errData) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); let code = (errData as BusinessError).code;
let message = (errData as BusinessError).message;
console.error(`errData is errCode:${code} message:${message}`);
} }
``` ```
...@@ -101,17 +105,21 @@ getLauncherAbilityInfo(bundleName: string, userId: number) : Promise<Array\<[Lau ...@@ -101,17 +105,21 @@ getLauncherAbilityInfo(bundleName: string, userId: number) : Promise<Array\<[Lau
**示例:** **示例:**
```typescript ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getLauncherAbilityInfo("com.example.demo", 100).then(data => { launcherBundleManager.getLauncherAbilityInfo("com.example.demo", 100)
.then((data: launcherBundleManager.LauncherAbilityInfo[]) => {
console.log("data is " + JSON.stringify(data)); console.log("data is " + JSON.stringify(data));
}).catch (errData => { }).catch ((errData: BusinessError) => {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
}) })
} catch (errData) { } catch (errData) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); let code = (errData as BusinessError).code;
let message = (errData as BusinessError).message;
console.error(`errData is errCode:${code} message:${message}`);
} }
``` ```
...@@ -151,9 +159,11 @@ getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback<Array\<[Launch ...@@ -151,9 +159,11 @@ getAllLauncherAbilityInfo(userId: number, callback: AsyncCallback<Array\<[Launch
```ts ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getAllLauncherAbilityInfo(100, (errData, data) => { launcherBundleManager.getAllLauncherAbilityInfo(100,
(errData: BusinessError, data: launcherBundleManager.LauncherAbilityInfo[]) => {
if (errData !== null) { if (errData !== null) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
} else { } else {
...@@ -161,7 +171,9 @@ try { ...@@ -161,7 +171,9 @@ try {
} }
}); });
} catch (errData) { } catch (errData) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); let code = (errData as BusinessError).code;
let message = (errData as BusinessError).message;
console.error(`errData is errCode:${code} message:${message}`);
} }
``` ```
## launcherBundlemanager.getAllLauncherAbilityInfo<sup>9+</sup> ## launcherBundlemanager.getAllLauncherAbilityInfo<sup>9+</sup>
...@@ -200,15 +212,19 @@ getAllLauncherAbilityInfo(userId: number) : Promise<Array\<[LauncherAbilityInfo] ...@@ -200,15 +212,19 @@ getAllLauncherAbilityInfo(userId: number) : Promise<Array\<[LauncherAbilityInfo]
```ts ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getAllLauncherAbilityInfo(100).then(data => { launcherBundleManager.getAllLauncherAbilityInfo(100)
.then((data: launcherBundleManager.LauncherAbilityInfo[]) => {
console.log("data is " + JSON.stringify(data)); console.log("data is " + JSON.stringify(data));
}).catch (errData => { }).catch ((errData: BusinessError) => {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
}); });
} catch (errData) { } catch (errData) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); let code = (errData as BusinessError).code;
let message = (errData as BusinessError).message;
console.error(`errData is errCode:${code} message:${message}`);
} }
``` ```
...@@ -246,9 +262,11 @@ getShortcutInfo(bundleName :string, callback: AsyncCallback<Array\<[ShortcutInfo ...@@ -246,9 +262,11 @@ getShortcutInfo(bundleName :string, callback: AsyncCallback<Array\<[ShortcutInfo
```ts ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getShortcutInfo("com.example.demo", (errData, data) => { launcherBundleManager.getShortcutInfo("com.example.demo",
(errData: BusinessError, data: launcherBundleManager.ShortcutInfo[]) => {
if (errData !== null) { if (errData !== null) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
} else { } else {
...@@ -256,7 +274,9 @@ try { ...@@ -256,7 +274,9 @@ try {
} }
}); });
} catch (errData) { } catch (errData) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); let code = (errData as BusinessError).code;
let message = (errData as BusinessError).message;
console.error(`errData is errCode:${code} message:${message}`);
} }
``` ```
...@@ -294,14 +314,18 @@ getShortcutInfo(bundleName : string) : Promise<Array\<[ShortcutInfo](js-apis-bun ...@@ -294,14 +314,18 @@ getShortcutInfo(bundleName : string) : Promise<Array\<[ShortcutInfo](js-apis-bun
```ts ```ts
import launcherBundleManager from '@ohos.bundle.launcherBundleManager'; import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
import { BusinessError } from '@ohos.base';
try { try {
launcherBundleManager.getShortcutInfo("com.example.demo").then(data => { launcherBundleManager.getShortcutInfo("com.example.demo")
.then((data: launcherBundleManager.ShortcutInfo[]) => {
console.log("data is " + JSON.stringify(data)); console.log("data is " + JSON.stringify(data));
}).catch (errData => { }).catch ((errData: BusinessError) => {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); console.error(`errData is errCode:${errData.code} message:${errData.message}`);
}); });
} catch (errData) { } catch (errData) {
console.error(`errData is errCode:${errData.code} message:${errData.message}`); let code = (errData as BusinessError).code;
let message = (errData as BusinessError).message;
console.error(`errData is errCode:${code} message:${message}`);
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册