未验证 提交 98a99c7d 编写于 作者: O openharmony_ci 提交者: Gitee

!22785 ArkTs语法整改

Merge pull request !22785 from 廖康康/master
......@@ -40,14 +40,14 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>):
**示例**
```ts
let timer = {
let timer:reminderAgent.ReminderRequestTimer = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10
}
}
reminderAgent.publishReminder(timer, (err, reminderId) => {
reminderAgent.publishReminder(timer, (err: BusinessError, reminderId: number) => {
console.log("callback, reminderId = " + reminderId);
});
});
```
......@@ -76,14 +76,14 @@ publishReminder(reminderReq: ReminderRequest): Promise\<number>
**示例**
```ts
let timer = {
let timer:reminderAgent.ReminderRequestTimer = {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10
}
}
reminderAgent.publishReminder(timer).then((reminderId) => {
reminderAgent.publishReminder(timer).then((reminderId: number) => {
console.log("promise, reminderId = " + reminderId);
});
});
```
......@@ -108,7 +108,7 @@ cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void
**示例**
```ts
reminderAgent.cancelReminder(1, (err, data) => {
reminderAgent.cancelReminder(1, (err: BusinessError, data: void) => {
console.log("cancelReminder callback");
});
```
......@@ -165,7 +165,7 @@ getValidReminders(callback: AsyncCallback\<Array\<ReminderRequest>>): void
**示例**
```ts
reminderAgent.getValidReminders((err, reminders) => {
reminderAgent.getValidReminders((err: BusinessError, reminders: Array<reminderAgent.ReminderRequest>) => {
console.log("callback, getValidReminders length = " + reminders.length);
for (let i = 0; i < reminders.length; i++) {
console.log("getValidReminders = " + reminders[i]);
......@@ -212,7 +212,7 @@ getValidReminders(): Promise\<Array\<ReminderRequest>>
**示例**
```ts
reminderAgent.getValidReminders().then((reminders) => {
reminderAgent.getValidReminders().then((reminders: Array<reminderAgent.ReminderRequest>) => {
console.log("promise, getValidReminders length = " + reminders.length);
for (let i = 0; i < reminders.length; i++) {
console.log("getValidReminders = " + reminders[i]);
......@@ -236,6 +236,7 @@ reminderAgent.getValidReminders().then((reminders) => {
console.log("getValidReminders, slotType = " + reminders[i].slotType);
}
})
```
......@@ -259,7 +260,7 @@ cancelAllReminders(callback: AsyncCallback\<void>): void
**示例**
```ts
reminderAgent.cancelAllReminders((err, data) =>{
reminderAgent.cancelAllReminders((err: BusinessError, data: void) =>{
console.log("cancelAllReminders callback")
})
```
......@@ -311,12 +312,12 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): voi
**示例**
```ts
import notification from '@ohos.notification'
import notification from '@ohos.notificationManager'
let mySlot = {
let mySlot:notification.NotificationSlot = {
type: notification.SlotType.SOCIAL_COMMUNICATION
}
reminderAgent.addNotificationSlot(mySlot, (err, data) => {
reminderAgent.addNotificationSlot(mySlot, (err: BusinessError, data: void) => {
console.log("addNotificationSlot callback");
});
```
......@@ -348,9 +349,9 @@ addNotificationSlot(slot: NotificationSlot): Promise\<void>
**示例**
```ts
import notification from '@ohos.notification'
import notification from '@ohos.notificationManager'
let mySlot = {
let mySlot:notification.NotificationSlot = {
type: notification.SlotType.SOCIAL_COMMUNICATION
}
reminderAgent.addNotificationSlot(mySlot).then(() => {
......@@ -382,7 +383,7 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\
```ts
import notification from '@ohos.notification'
reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) => {
reminderAgent.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err: BusinessError, data: void) => {
console.log("removeNotificationSlot callback");
});
```
......
......@@ -45,22 +45,18 @@ publishReminder(reminderReq: ReminderRequest, callback: AsyncCallback\<number>):
**示例**
```ts
let timer = {
let timer: reminderAgentManager.ReminderRequestTimer = {
reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10
}
try {
reminderAgentManager.publishReminder(timer, (err, reminderId) => {
reminderAgentManager.publishReminder(timer, (err: BusinessError, reminderId: number) => {
if (err) {
console.log("callback err code:" + err.code + " message:" + err.message);
} else {
console.log("callback, reminderId = " + reminderId);
}
});
} catch (error) {
console.log("publishReminder code:" + error.code + " message:" + error.message);
};
});
```
## reminderAgentManager.publishReminder
......@@ -98,20 +94,16 @@ publishReminder(reminderReq: ReminderRequest): Promise\<number>
**示例**
```ts
let timer = {
let timer: reminderAgentManager.ReminderRequestTimer = {
reminderType: reminderAgentManager.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 10
}
try {
reminderAgentManager.publishReminder(timer).then((reminderId) => {
reminderAgentManager.publishReminder(timer).then((reminderId: number) => {
console.log("promise, reminderId = " + reminderId);
}).catch(err => {
}).catch((err: BusinessError) => {
console.log("promise err code:" + err.code + " message:" + err.message);
});
} catch (error) {
console.log("publishReminder code:" + error.code + " message:" + error.message);
};
});
```
......@@ -142,17 +134,14 @@ cancelReminder(reminderId: number, callback: AsyncCallback\<void>): void
**示例**
```ts
try {
reminderAgentManager.cancelReminder(1, (err, data) => {
let reminderId: number = 1;
reminderAgentManager.cancelReminder(reminderId, (err: BusinessError, data: void) => {
if (err) {
console.log("callback err code:" + err.code + " message:" + err.message);
} else {
console.log("cancelReminder callback");
}
});
} catch (error) {
console.log("cancelReminder code:" + error.code + " message:" + error.message);
};
});
```
## reminderAgentManager.cancelReminder
......@@ -187,15 +176,12 @@ cancelReminder(reminderId: number): Promise\<void>
**示例**
```ts
try {
reminderAgentManager.cancelReminder(1).then(() => {
let reminderId: number = 1;
reminderAgentManager.cancelReminder(reminderId).then(() => {
console.log("cancelReminder promise");
}).catch(err => {
}).catch((err: BusinessError) => {
console.log("promise err code:" + err.code + " message:" + err.message);
});
} catch (error) {
console.log("cancelReminder code:" + error.code + " message:" + error.message);
};
});
```
## reminderAgentManager.getValidReminders
......@@ -223,8 +209,7 @@ getValidReminders(callback: AsyncCallback<Array\<ReminderRequest>>): void
**示例**
```ts
try {
reminderAgentManager.getValidReminders((err, reminders) => {
reminderAgentManager.getValidReminders((err: BusinessError, reminders: Array<reminderAgentManager.ReminderRequest>) => {
if (err) {
console.log("callback err code:" + err.code + " message:" + err.message);
} else {
......@@ -251,10 +236,7 @@ try {
console.log("getValidReminders, slotType = " + reminders[i].slotType);
}
}
})
} catch (error) {
console.log("getValidReminders code:" + error.code + " message:" + error.message);
};
});
```
## reminderAgentManager.getValidReminders
......@@ -282,8 +264,7 @@ getValidReminders(): Promise\<Array\<ReminderRequest>>
**示例**
```ts
try {
reminderAgentManager.getValidReminders().then((reminders) => {
reminderAgentManager.getValidReminders().then((reminders: Array<reminderAgentManager.ReminderRequest>) => {
console.log("promise, getValidReminders length = " + reminders.length);
for (let i = 0; i < reminders.length; i++) {
console.log("getValidReminders = " + reminders[i]);
......@@ -306,12 +287,9 @@ try {
console.log("getValidReminders, notificationId = " + reminders[i].notificationId);
console.log("getValidReminders, slotType = " + reminders[i].slotType);
}
}).catch(err => {
}).catch((err: BusinessError) => {
console.log("promise err code:" + err.code + " message:" + err.message);
});
} catch (error) {
console.log("getValidReminders code:" + error.code + " message:" + error.message);
};
});
```
## reminderAgentManager.cancelAllReminders
......@@ -339,17 +317,13 @@ cancelAllReminders(callback: AsyncCallback\<void>): void
**示例**
```ts
try {
reminderAgentManager.cancelAllReminders((err, data) =>{
reminderAgentManager.cancelAllReminders((err: BusinessError, data: void) =>{
if (err) {
console.log("callback err code:" + err.code + " message:" + err.message);
} else {
console.log("cancelAllReminders callback")
}
})
} catch (error) {
console.log("cancelAllReminders code:" + error.code + " message:" + error.message);
};
});
```
## reminderAgentManager.cancelAllReminders
......@@ -377,15 +351,11 @@ cancelAllReminders(): Promise\<void>
**示例**
```ts
try {
reminderAgentManager.cancelAllReminders().then(() => {
reminderAgentManager.cancelAllReminders().then(() => {
console.log("cancelAllReminders promise")
}).catch(err => {
}).catch((err: BusinessError) => {
console.log("promise err code:" + err.code + " message:" + err.message);
});
} catch (error) {
console.log("cancelAllReminders code:" + error.code + " message:" + error.message);
};
});
```
......@@ -407,22 +377,19 @@ addNotificationSlot(slot: NotificationSlot, callback: AsyncCallback\<void>): voi
**示例**
```ts
import notification from '@ohos.notification'
import notification from '@ohos.notificationManager'
let mySlot = {
let mySlot: notification.NotificationSlot = {
type: notification.SlotType.SOCIAL_COMMUNICATION
}
try {
reminderAgentManager.addNotificationSlot(mySlot, (err, data) => {
reminderAgentManager.addNotificationSlot(mySlot, (err: BusinessError, data: void) => {
if (err) {
console.log("callback err code:" + err.code + " message:" + err.message);
} else {
console.log("addNotificationSlot callback");
}
});
} catch (error) {
console.log("addNotificationSlot code:" + error.code + " message:" + error.message);
};
});
```
......@@ -449,20 +416,16 @@ addNotificationSlot(slot: NotificationSlot): Promise\<void>
**示例**
```ts
import notification from '@ohos.notification'
import notification from '@ohos.notificationManager'
let mySlot = {
let mySlot: notification.NotificationSlot = {
type: notification.SlotType.SOCIAL_COMMUNICATION
}
try {
reminderAgentManager.addNotificationSlot(mySlot).then(() => {
reminderAgentManager.addNotificationSlot(mySlot).then(() => {
console.log("addNotificationSlot promise");
}).catch(err => {
}).catch((err: BusinessError) => {
console.log("promise err code:" + err.code + " message:" + err.message);
});
} catch (error) {
console.log("addNotificationSlot code:" + error.code + " message:" + error.message);
};
});
```
......@@ -484,19 +447,16 @@ removeNotificationSlot(slotType: notification.SlotType, callback: AsyncCallback\
**示例**
```ts
import notification from '@ohos.notification'
import notification from '@ohos.notificationManager'
try {
reminderAgentManager.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION, (err, data) => {
reminderAgentManager.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION,
(err: BusinessError, data: void) => {
if (err) {
console.log("callback err code:" + err.code + " message:" + err.message);
} else {
console.log("removeNotificationSlot callback");
}
});
} catch (error) {
console.log("removeNotificationSlot code:" + error.code + " message:" + error.message);
};
});
```
......@@ -523,17 +483,13 @@ removeNotificationSlot(slotType: notification.SlotType): Promise\<void>
**示例**
```ts
import notification from '@ohos.notification'
import notification from '@ohos.notificationManager'
try {
reminderAgentManager.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).then(() => {
reminderAgentManager.removeNotificationSlot(notification.SlotType.CONTENT_INFORMATION).then(() => {
console.log("removeNotificationSlot promise");
}).catch(err => {
}).catch((err: BusinessError) => {
console.log("promise err code:" + err.code + " message:" + err.message);
});
} catch (error) {
console.log("removeNotificationSlot code:" + error.code + " message:" + error.message);
};
});
```
## ActionButtonType
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册