未验证 提交 90773e5a 编写于 作者: O openharmony_ci 提交者: Gitee

!24086 元能力及事件通知ArkTs整改

Merge pull request !24086 from xuzhihao/master
......@@ -53,27 +53,48 @@
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
function FunACall(data) {
// 获取call事件中传递的所有参数
console.info('FunACall param:' + JSON.stringify(data.readString()));
return null;
}
function FunBCall(data) {
console.info('FunBCall param:' + JSON.stringify(data.readString()));
return null;
import Base from '@ohos.base'
import rpc from '@ohos.rpc';
import Want from '@ohos.app.ability.Want';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
class MyParcelable implements rpc.Parcelable {
num: number;
str: string;
constructor(num: number, str: string) {
this.num = num;
this.str = str;
}
marshalling(messageSequence: rpc.MessageSequence): boolean {
messageSequence.writeInt(this.num);
messageSequence.writeString(this.str);
return true;
}
unmarshalling(messageSequence: rpc.MessageSequence): boolean {
this.num = messageSequence.readInt();
this.str = messageSequence.readString();
return true;
}
}
export default class CameraAbility extends UIAbility {
// 如果UIAbility第一次启动,在收到call事件后会触发onCreate生命周期回调
onCreate(want, launchParam) {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
try {
// 监听call事件所需的方法
this.callee.on('funA', FunACall);
this.callee.on('funB', FunBCall);
this.callee.on('funA', (data: rpc.MessageSequence) => {
// 获取call事件中传递的所有参数
console.info('FunACall param:' + JSON.stringify(data.readString()));
return new MyParcelable(1, 'aaa');
});
this.callee.on('funB', (data: rpc.MessageSequence) => {
// 获取call事件中传递的所有参数
console.info('FunACall param:' + JSON.stringify(data.readString()));
return new MyParcelable(2, 'bbb');
});
} catch (err) {
console.error(`Failed to register callee on. Cause: ${JSON.stringify(err)}`);
console.error(`Failed to register callee on. Cause: ${JSON.stringify(err as Base.BusinessError)}`);
}
}
......@@ -85,7 +106,7 @@
this.callee.off('funA');
this.callee.off('funB');
} catch (err) {
console.error(`Failed to register callee off. Cause: ${JSON.stringify(err)}`);
console.error(`Failed to register callee off. Cause: ${JSON.stringify(err as Base.BusinessError)}`);
}
}
};
......
......@@ -52,10 +52,10 @@
let formData = new Map<Object, string>();
formData.set('title', 'Title Update.'); // 和卡片布局中对应
formData.set('detail', 'Description update success.'); // 和卡片布局中对应
let formInfo = formBindingData.createFormBindingData(formData)
formProvider.updateForm(formId, formInfo).then((data) => {
console.info('FormAbility updateForm success.' + JSON.stringify(data));
})
let formInfo: formBindingData.FormBindingData = formBindingData.createFormBindingData(formData);
formProvider.updateForm(formId, formInfo).then(() => {
console.info('FormAbility updateForm success.');
});
}
...
......
......@@ -54,26 +54,29 @@
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
import Want from '@ohos.app.ability.Want';
import Base from '@ohos.base';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
let selectPage = "";
let currentWindowStage = null;
let selectPage: string = "";
let currentWindowStage: window.WindowStage | null = null;
export default class EntryAbility extends UIAbility {
// 如果UIAbility第一次启动,在收到Router事件后会触发onCreate生命周期回调
onCreate(want, launchParam) {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
// 获取router事件中传递的targetPage参数
console.info("onCreate want:" + JSON.stringify(want));
if (want.parameters.params !== undefined) {
let params = JSON.parse(want.parameters.params);
if (want.parameters?.params !== undefined) {
let params: Record<string, string> = JSON.parse(JSON.stringify(want.parameters?.params));
console.info("onCreate router targetPage:" + params.targetPage);
selectPage = params.targetPage;
}
}
// 如果UIAbility已在后台运行,在收到Router事件后会触发onNewWant生命周期回调
onNewWant(want, launchParam) {
onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam) {
console.info("onNewWant want:" + JSON.stringify(want));
if (want.parameters.params !== undefined) {
let params = JSON.parse(want.parameters.params);
if (want.parameters?.params !== undefined) {
let params: Record<string, string> = JSON.parse(JSON.stringify(want.parameters?.params));
console.info("onNewWant router targetPage:" + params.targetPage);
selectPage = params.targetPage;
}
......@@ -81,9 +84,9 @@
this.onWindowStageCreate(currentWindowStage);
}
}
onWindowStageCreate(windowStage: window.WindowStage) {
let targetPage;
let targetPage: string;
// 根据传递的targetPage不同,选择拉起不同的页面
switch (selectPage) {
case 'funA':
......@@ -98,7 +101,7 @@
if (currentWindowStage === null) {
currentWindowStage = windowStage;
}
windowStage.loadContent(targetPage, (err, data) => {
windowStage.loadContent(targetPage, (err: Base.BusinessError) => {
if (err && err.code) {
console.info('Failed to load the content. Cause: %{public}s', JSON.stringify(err));
return;
......
......@@ -44,30 +44,33 @@
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
import formInfo from '@ohos.app.form.formInfo';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
import Want from '@ohos.app.ability.Want';
import Base from '@ohos.base'
export default class EntryAbility extends UIAbility {
// 如果UIAbility第一次启动,在收到Router事件后会触发onCreate生命周期回调
onCreate(want, launchParam) {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
this.handleFormRouterEvent(want);
}
// 如果UIAbility已在后台运行,在收到Router事件后会触发onNewWant生命周期回调
onNewWant(want, launchParam) {
onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam) {
this.handleFormRouterEvent(want);
}
handleFormRouterEvent(want) {
handleFormRouterEvent(want: Want) {
console.info('Want:' + JSON.stringify(want));
if (want.parameters[formInfo.FormParam.IDENTITY_KEY] !== undefined) {
let curFormId = want.parameters[formInfo.FormParam.IDENTITY_KEY];
let message = JSON.parse(want.parameters.params).detail;
if (want.parameters && want.parameters[formInfo.FormParam.IDENTITY_KEY] !== undefined) {
let curFormId = JSON.stringify(want.parameters[formInfo.FormParam.IDENTITY_KEY]);
let message: string = JSON.parse(JSON.stringify(want.parameters.params)).detail;
console.info(`UpdateForm formId: ${curFormId}, message: ${message}`);
let formData = {
let formData: Record<string, string> = {
"detail": message + ': UIAbility.', // 和卡片布局中对应
};
let formMsg = formBindingData.createFormBindingData(formData)
formProvider.updateForm(curFormId, formMsg).then((data) => {
console.info('updateForm success.' + JSON.stringify(data));
}).catch((error) => {
}).catch((error: Base.BusinessError) => {
console.error('updateForm failed:' + JSON.stringify(error));
})
}
......@@ -83,18 +86,21 @@
```ts
import formBindingData from '@ohos.app.form.formBindingData';
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import Want from '@ohos.app.ability.Want';
export default class EntryFormAbility extends FormExtensionAbility {
onAddForm(want) {
let formId = want.parameters["ohos.extra.param.key.form_identity"];
let dataObj1 = {
"formId": formId
};
onAddForm(want: Want) {
let dataObj1: Record<string, string> | undefined;
if (want.parameters && want.parameters["ohos.extra.param.key.form_identity"] != undefined) {
let formId: string = JSON.parse(JSON.stringify(want.parameters["ohos.extra.param.key.form_identity"]));
dataObj1 = {
"formId": formId
};
}
let obj1 = formBindingData.createFormBindingData(dataObj1);
return obj1;
}
...
...
};
```
......@@ -138,40 +144,63 @@
import UIAbility from '@ohos.app.ability.UIAbility';
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
import Want from '@ohos.app.ability.Want';
import Base from '@ohos.base'
import rpc from '@ohos.rpc';
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
const MSG_SEND_METHOD: string = 'funA';
class MyParcelable implements rpc.Parcelable {
num: number;
str: string;
constructor(num: number, str: string) {
this.num = num;
this.str = str;
}
marshalling(messageSequence: rpc.MessageSequence): boolean {
messageSequence.writeInt(this.num);
messageSequence.writeString(this.str);
return true;
}
unmarshalling(messageSequence: rpc.MessageSequence): boolean {
this.num = messageSequence.readInt();
this.str = messageSequence.readString();
return true;
}
}
// 在收到call事件后会触发callee监听的方法
function FunACall(data) {
let FunACall = (data: rpc.MessageSequence) => {
// 获取call事件中传递的所有参数
let params = JSON.parse(data.readString())
let params: Record<string, string> = JSON.parse(data.readString())
if (params.formId !== undefined) {
let curFormId = params.formId;
let message = params.detail;
let curFormId: string = params.formId;
let message: string = params.detail;
console.info(`UpdateForm formId: ${curFormId}, message: ${message}`);
let formData = {
let formData: Record<string, string> = {
"detail": message
};
let formMsg = formBindingData.createFormBindingData(formData)
let formMsg: formBindingData.FormBindingData = formBindingData.createFormBindingData(formData);
formProvider.updateForm(curFormId, formMsg).then((data) => {
console.info('updateForm success.' + JSON.stringify(data));
}).catch((error) => {
}).catch((error: Base.BusinessError) => {
console.error('updateForm failed:' + JSON.stringify(error));
})
}
return null;
return new MyParcelable(1, 'aaa');
}
export default class EntryAbility extends UIAbility {
// 如果UIAbility第一次启动,call事件后会触发onCreate生命周期回调
onCreate(want, launchParam) {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
console.info('Want:' + JSON.stringify(want));
try {
// 监听call事件所需的方法
// 监听call事件所需的方法
this.callee.on(MSG_SEND_METHOD, FunACall);
} catch (error) {
console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`)
console.info(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error as Base.BusinessError)}`)
}
}
...
}
```
\ No newline at end of file
......@@ -14,31 +14,34 @@
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import request from '@ohos.request';
import fs from '@ohos.file.fs';
import Want from '@ohos.app.ability.Want';
import Base from '@ohos.base';
import fileFs from '@ohos.file.fs';
export default class EntryFormAbility extends FormExtensionAbility {
...
// 在添加卡片时,打开一个本地图片并将图片内容传递给卡片页面显示
onAddForm(want) {
// 假设在当前卡片应用的tmp目录下有一个本地图片:head.PNG
let tempDir = this.context.getApplicationContext().tempDir;
// 打开本地图片并获取其打开后的fd
let file;
try {
file = fs.openSync(tempDir + '/' + 'head.PNG');
} catch (e) {
console.error(`openSync failed: ${JSON.stringify(e)}`);
}
let formData = {
'text': 'Image: Bear',
'imgName': 'imgBear',
'formImages': {
'imgBear': file.fd
},
'loaded': true
}
// 将fd封装在formData中并返回至卡片页面
return formBindingData.createFormBindingData(formData);
}
onAddForm(want: Want) {
// 假设在当前卡片应用的tmp目录下有一个本地图片:head.PNG
let tempDir = this.context.getApplicationContext().tempDir;
// 打开本地图片并获取其打开后的fd
let file: fileFs.File;
let formData = new Map<string, Object>();
formData.set('text', 'Image: Bear');
formData.set('imgName', 'imgBear');
formData.set('loaded', true);
try {
file = fs.openSync(tempDir + '/' + 'head.PNG');
let imgBear: Record<string, number> = {
'imgBear': file.fd
}
formData.set('formImages', imgBear);
} catch (e) {
console.error(`openSync failed: ${JSON.stringify(e as Base.BusinessError)}`);
}
// 将fd封装在formData中并返回至卡片页面
return formBindingData.createFormBindingData(formData);
}
...
}
......@@ -46,67 +49,67 @@
3. 在EntryFormAbility中的onFormEvent生命周期回调中实现网络文件的刷新
```ts
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import request from '@ohos.request';
import fs from '@ohos.file.fs';
```ts
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import request from '@ohos.request';
import fs from '@ohos.file.fs';
import Base from '@ohos.base';
import fileFs from '@ohos.file.fs';
export default class EntryFormAbility extends FormExtensionAbility {
// 在卡片页面触发message事件时,下载一个网络图片,并将网络图片内容传递给卡片页面显示
onFormEvent(formId, message) {
let formInfo = formBindingData.createFormBindingData({
'text': '刷新中...'
})
formProvider.updateForm(formId, formInfo)
// 注意:FormExtensionAbility在触发生命周期回调时被拉起,仅能在后台存在5秒
// 建议下载能快速下载完成的小文件,如在5秒内未下载完成,则此次网络图片无法刷新至卡片页面上
let netFile = 'https://xxxx/xxxx.png'; // 需要在此处使用真实的网络图片下载链接
let tempDir = this.context.getApplicationContext().tempDir;
let fileName = 'file' + Date.now();
let tmpFile = tempDir + '/' + fileName;
request.downloadFile(this.context, {
url: netFile, filePath: tmpFile, enableMetered: true, enableRoaming: true
}).then((task) => {
task.on('complete', function callback() {
console.info('ArkTSCard download complete:' + tmpFile);
let file;
try {
file = fs.openSync(tmpFile);
} catch (e) {
console.error(`openSync failed: ${JSON.stringify(e)}`);
}
let fileInfo = {};
fileInfo[fileName] = file.fd;
let formData = {
'text': 'Image:' + fileName,
'imgName': fileName,
'formImages': fileInfo,
'loaded': true
};
let formInfo = formBindingData.createFormBindingData(formData)
formProvider.updateForm(formId, formInfo).then((data) => {
console.info('FormAbility updateForm success.' + JSON.stringify(data));
}).catch((error) => {
console.error('FormAbility updateForm failed: ' + JSON.stringify(error));
})
})
task.on('fail', function callBack(err) {
console.info('ArkTSCard download task failed. Cause:' + err);
let formInfo = formBindingData.createFormBindingData({
'text': '刷新失败'
})
formProvider.updateForm(formId, formInfo)
});
}).catch((err) => {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
});
}
...
};
```
export default class EntryFormAbility extends FormExtensionAbility {
// 在卡片页面触发message事件时,下载一个网络图片,并将网络图片内容传递给卡片页面显示
onFormEvent(formId: string, message: string) {
let formInfo = formBindingData.createFormBindingData({
'text': '刷新中...'
})
formProvider.updateForm(formId, formInfo)
// 注意:FormExtensionAbility在触发生命周期回调时被拉起,仅能在后台存在5秒
// 建议下载能快速下载完成的小文件,如在5秒内未下载完成,则此次网络图片无法刷新至卡片页面上
let netFile = 'https://xxxx/xxxx.png'; // 需要在此处使用真实的网络图片下载链接
let tempDir = this.context.getApplicationContext().tempDir;
let fileName = 'file' + Date.now();
let tmpFile = tempDir + '/' + fileName;
request.downloadFile(this.context, {
url: netFile, filePath: tmpFile, enableMetered: true, enableRoaming: true
}).then((task) => {
task.on('complete', () => {
console.info('ArkTSCard download complete:' + tmpFile);
let file: fileFs.File;
let formData = new Map<string, Object>();
try {
file = fs.openSync(tmpFile);
formData.set('text', 'Image: Bear' + fileName);
formData.set('imgName', 'imgBear' + fileName);
formData.set('loaded', true);
let imgBear: Record<string, number> = {
'imgBear': file.fd
};
formData.set('formImages', imgBear);
} catch (e) {
console.error(`openSync failed: ${JSON.stringify(e as Base.BusinessError)}`);
}
let formInfo = formBindingData.createFormBindingData(formData);
formProvider.updateForm(formId, formInfo).then(() => {
console.info('FormAbility updateForm success.');
}).catch((error: Base.BusinessError) => {
console.error('FormAbility updateForm failed: ' + JSON.stringify(error));
});
})
task.on('fail', (err: number) => {
console.info('ArkTSCard download task failed. Cause:' + err);
let formInfo = formBindingData.createFormBindingData({
'text': '刷新失败'
})
formProvider.updateForm(formId, formInfo)
});
}).catch((err: Base.BusinessError) => {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
});
}
};
```
4. 在卡片页面通过Image组件展示EntryFormAbility传递过来的卡片内容。
......
......@@ -20,74 +20,72 @@
import formBindingData from '@ohos.app.form.formBindingData';
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formProvider from '@ohos.app.form.formProvider';
import { Configuration } from '@ohos.app.ability.Configuration';
import Want from '@ohos.app.ability.Want';
import formInfo from '@ohos.app.form.formInfo';
import Base from '@ohos.base';
export default class EntryFormAbility extends FormExtensionAbility {
onAddForm(want) {
console.info('[EntryFormAbility] onAddForm');
// 在入参want中可以取出卡片的唯一标识:formId
let formId: string = want.parameters[formInfo.FormParam.IDENTITY_KEY];
// 使用方创建卡片时触发,提供方需要返回卡片数据绑定类
let obj = {
'title': 'titleOnAddForm',
'detail': 'detailOnAddForm'
};
let formData = formBindingData.createFormBindingData(obj);
return formData;
}
onCastToNormalForm(formId) {
// Called when the form provider is notified that a temporary form is successfully
// converted to a normal form.
// 使用方将临时卡片转换为常态卡片触发,提供方需要做相应的处理
console.info(`[EntryFormAbility] onCastToNormalForm, formId: ${formId}`);
}
onUpdateForm(formId) {
// 若卡片支持定时更新/定点更新/卡片使用方主动请求更新功能,则提供方需要重写该方法以支持数据更新
console.info('[EntryFormAbility] onUpdateForm');
let obj = {
'title': 'titleOnUpdateForm',
'detail': 'detailOnUpdateForm'
};
let formData = formBindingData.createFormBindingData(obj);
formProvider.updateForm(formId, formData).catch((err) => {
if (err) {
// 异常分支打印
console.error(`[EntryFormAbility] Failed to updateForm. Code: ${err.code}, message: ${err.message}`);
return;
}
});
}
onChangeFormVisibility(newStatus) {
// Called when the form provider receives form events from the system.
// 需要配置formVisibleNotify为true,且为系统应用才会回调
console.info('[EntryFormAbility] onChangeFormVisibility');
}
onFormEvent(formId, message) {
// Called when a specified message event defined by the form provider is triggered.
// 若卡片支持触发事件,则需要重写该方法并实现对事件的触发
console.info('[EntryFormAbility] onFormEvent');
}
onRemoveForm(formId) {
// Called to notify the form provider that a specified form has been destroyed.
// 当对应的卡片删除时触发的回调,入参是被删除的卡片ID
console.info('[EntryFormAbility] onRemoveForm');
}
onConfigurationUpdate(config) {
// 当系统配置信息置更新时触发的回调
console.info('[EntryFormAbility] configurationUpdate:' + JSON.stringify(config));
}
onAcquireFormState(want) {
// Called to return a {@link FormState} object.
// 卡片提供方接收查询卡片状态通知接口,默认返回卡片初始状态。
return formInfo.FormState.READY;
}
}
onAddForm(want: Want) {
console.info('[EntryFormAbility] onAddForm');
// 使用方创建卡片时触发,提供方需要返回卡片数据绑定类
let obj: Record<string, string> = {
'title': 'titleOnAddForm',
'detail': 'detailOnAddForm'
};
let formData = formBindingData.createFormBindingData(obj);
return formData;
}
onCastToNormalForm(formId: string) {
// Called when the form provider is notified that a temporary form is successfully
// converted to a normal form.
// 使用方将临时卡片转换为常态卡片触发,提供方需要做相应的处理
console.info(`[EntryFormAbility] onCastToNormalForm, formId: ${formId}`);
}
onUpdateForm(formId: string) {
// 若卡片支持定时更新/定点更新/卡片使用方主动请求更新功能,则提供方需要重写该方法以支持数据更新
console.info('[EntryFormAbility] onUpdateForm');
let obj: Record<string, string> = {
'title': 'titleOnUpdateForm',
'detail': 'detailOnUpdateForm'
};
let formData = formBindingData.createFormBindingData(obj);
formProvider.updateForm(formId, formData).catch((err: Base.BusinessError) => {
console.error(`[EntryFormAbility] Failed to updateForm. Code: ${err.code}, message: ${err.message}`);
});
}
onChangeFormVisibility(newStatus: Record<string, number>) {
// Called when the form provider receives form events from the system.
// 需要配置formVisibleNotify为true,且为系统应用才会回调
console.info('[EntryFormAbility] onChangeFormVisibility');
}
onFormEvent(formId: string, message: string) {
// Called when a specified message event defined by the form provider is triggered.
// 若卡片支持触发事件,则需要重写该方法并实现对事件的触发
console.info('[EntryFormAbility] onFormEvent');
}
onRemoveForm(formId: string) {
// Called to notify the form provider that a specified form has been destroyed.
// 当对应的卡片删除时触发的回调,入参是被删除的卡片ID
console.info('[EntryFormAbility] onRemoveForm');
}
onConfigurationUpdate(config: Configuration) {
// 当系统配置信息置更新时触发的回调
console.info('[EntryFormAbility] configurationUpdate:' + JSON.stringify(config));
}
onAcquireFormState(want: Want) {
// Called to return a {@link FormState} object.
// 卡片提供方接收查询卡片状态通知接口,默认返回卡片初始状态。
return formInfo.FormState.READY;
}
}
```
......
......@@ -76,19 +76,22 @@
> key可以是uri也可以是简单字符串,subscriberId默认值为当前formId,实际取值都依赖于数据发布方的定义。
```ts
import formBindingData from '@ohos.app.form.formBindingData';
import Want from '@ohos.app.ability.Want';
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
let dataShareHelper;
onAddForm(want) {
let formData = {};
let proxies = [
{
"key": "detail",
"subscriberId": "11"
}
]
let formBinding = formBindingData.createFormBindingData(formData);
formBinding["proxies"] = proxies;
return formBinding;
export default class EntryFormAbility extends FormExtensionAbility {
onAddForm(want: Want) {
let formData: Record<string, Object> = {};
let proxies: formBindingData.ProxyData[] = [
{
"key": "detail",
"subscriberId": "11"
}
]
let formBinding = formBindingData.createFormBindingData(formData);
formBinding["proxies"] = proxies;
return formBinding;
}
}
```
......@@ -151,33 +154,38 @@
```ts
import formBindingData from '@ohos.app.form.formBindingData';
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import dataShare from '@ohos.data.dataShare'
let dataShareHelper;
onAddForm(want) {
let template = {
predicates : {
"list" : "select type from TBL00 limit 0,1"
},
scheduler: ""
}
let subscriberId = "111";
dataShare.createDataShareHelper(this.context, "datashareproxy://com.example.myapplication", {isProxy : true}).then((data) => {
dataShareHelper = data;
dataShareHelper.addTemplate("datashareproxy://com.example.myapplication/test", subscriberId, template);
})
let formData = {};
let proxies = [
{
"key": "datashareproxy://com.example.myapplication/test",
"subscriberId": subscriberId
import dataShare from '@ohos.data.dataShare';
import Want from '@ohos.app.ability.Want';
let dataShareHelper: dataShare.DataShareHelper;
export default class EntryFormAbility extends FormExtensionAbility {
onAddForm(want: Want) {
let template: dataShare.Template = {
predicates: {
"list": "select type from TBL00 limit 0,1"
},
scheduler: ""
}
]
let formBinding = formBindingData.createFormBindingData(formData);
formBinding["proxies"] = proxies;
let subscriberId: string = "111";
dataShare.createDataShareHelper(this.context, "datashareproxy://com.example.myapplication", {
isProxy: true
}).then((data: dataShare.DataShareHelper) => {
dataShareHelper = data;
dataShareHelper.addTemplate("datashareproxy://com.example.myapplication/test", subscriberId, template);
})
return formBinding;
let formData: Record<string, Object> = {};
let proxies: formBindingData.ProxyData[] = [
{
"key": "datashareproxy://com.example.myapplication/test",
"subscriberId": subscriberId
}
]
let formBinding = formBindingData.createFormBindingData(formData);
formBinding["proxies"] = proxies;
return formBinding;
}
}
```
......
......@@ -96,56 +96,62 @@
import formBindingData from '@ohos.app.form.formBindingData';
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import dataPreferences from '@ohos.data.preferences';
import Want from '@ohos.app.ability.Want';
import Base from '@ohos.base';
export default class EntryFormAbility extends FormExtensionAbility {
onAddForm(want) {
let formId = want.parameters[formInfo.FormParam.IDENTITY_KEY];
let isTempCard: boolean = want.parameters[formInfo.FormParam.TEMPORARY_KEY];
if (isTempCard === false) { // 如果为常态卡片,直接进行信息持久化
console.info('Not temp card, init db for:' + formId);
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB) => {
console.info("Succeeded to get preferences.");
await storeDB.put('A' + formId, 'false');
await storeDB.put('B' + formId, 'false');
await storeDB.flush();
}).catch((err) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
onAddForm(want: Want) {
let formId: string = '';
let isTempCard: boolean;
if (want.parameters) {
formId = JSON.stringify(want.parameters[formInfo.FormParam.IDENTITY_KEY]);
isTempCard = want.parameters[formInfo.FormParam.TEMPORARY_KEY] as boolean;
if (isTempCard === false) { // 如果为常态卡片,直接进行信息持久化
console.info('Not temp card, init db for:' + formId);
let promise: Promise<dataPreferences.Preferences> = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB: dataPreferences.Preferences) => {
console.info("Succeeded to get preferences.");
await storeDB.put('A' + formId, 'false');
await storeDB.put('B' + formId, 'false');
await storeDB.flush();
}).catch((err: Base.BusinessError) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
}
let formData = {};
let formData: Record<string, Object | string> = {};
return formBindingData.createFormBindingData(formData);
}
onRemoveForm(formId) {
onRemoveForm(formId: string) {
console.info('onRemoveForm, formId:' + formId);
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB) => {
console.info("Succeeded to get preferences.");
await storeDB.delete('A' + formId);
await storeDB.delete('B' + formId);
}).catch((err) => {
}).catch((err: Base.BusinessError) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
// 如果在添加时为临时卡片,则建议转为常态卡片时进行信息持久化
onCastToNormalForm(formId) {
onCastToNormalForm(formId: string) {
console.info('onCastToNormalForm, formId:' + formId);
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB) => {
let promise: Promise<dataPreferences.Preferences> = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB: dataPreferences.Preferences) => {
console.info("Succeeded to get preferences.");
await storeDB.put('A' + formId, 'false');
await storeDB.put('B' + formId, 'false');
await storeDB.flush();
}).catch((err) => {
}).catch((err: Base.BusinessError) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
onUpdateForm(formId) {
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB) => {
onUpdateForm(formId: string) {
let promise: Promise<dataPreferences.Preferences> = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB: dataPreferences.Preferences) => {
console.info("Succeeded to get preferences.");
let stateA = await storeDB.get('A' + formId, 'false');
let stateB = await storeDB.get('B' + formId, 'false');
......@@ -160,18 +166,18 @@
await formProvider.updateForm(formId, formInfo);
}
console.info(`Update form success stateA:${stateA} stateB:${stateB}.`);
}).catch((err) => {
}).catch((err: Base.BusinessError) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
onFormEvent(formId, message) {
onFormEvent(formId: string, message: string) {
// 存放卡片状态
console.info('onFormEvent formId:' + formId + 'msg:' + message);
let promise = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB) => {
let promise: Promise<dataPreferences.Preferences> = dataPreferences.getPreferences(this.context, 'myStore');
promise.then(async (storeDB: dataPreferences.Preferences) => {
console.info("Succeeded to get preferences.");
let msg = JSON.parse(message);
let msg: Record<string, string> = JSON.parse(message);
if (msg.selectA != undefined) {
console.info('onFormEvent selectA info:' + msg.selectA);
await storeDB.put('A' + formId, msg.selectA);
......@@ -181,7 +187,7 @@
await storeDB.put('B' + formId, msg.selectB);
}
await storeDB.flush();
}).catch((err) => {
}).catch((err: Base.BusinessError) => {
console.info(`Failed to get preferences. ${JSON.stringify(err)}`);
})
}
......
......@@ -69,11 +69,12 @@
```ts
import formProvider from '@ohos.app.form.formProvider';
import Base from '@ohos.base';
let formId = '123456789'; // 实际业务场景需要使用正确的formId
let formId: string = '123456789'; // 实际业务场景需要使用正确的formId
try {
// 设置过5分钟后更新卡片内容
formProvider.setFormNextRefreshTime(formId, 5, (err, data) => {
formProvider.setFormNextRefreshTime(formId, 5, (err: Base.BusinessError) => {
if (err) {
console.error(`Failed to setFormNextRefreshTime. Code: ${err.code}, message: ${err.message}`);
return;
......@@ -82,7 +83,7 @@
}
});
} catch (err) {
console.error(`Failed to setFormNextRefreshTime. Code: ${err.code}, message: ${err.message}`);
console.error(`Failed to setFormNextRefreshTime. Code: ${(err as Base.BusinessError).code}, message: ${(err as Base.BusinessError).message}`);
}
```
......
......@@ -27,19 +27,20 @@
```ts
import commonEventManager from '@ohos.commonEventManager';
import Base from '@ohos.base';
```
2. 传入需要发布的事件名称和回调函数,发布事件。
```ts
// 发布公共事件
commonEventManager.publish("usual.event.SCREEN_OFF", (err) => {
commonEventManager.publish("usual.event.SCREEN_OFF", (err: Base.BusinessError) => {
if (err) {
console.error(`[CommonEvent] PublishCallBack err=${JSON.stringify(err)}`);
} else {
console.info(`[CommonEvent] Publish success`);
}
})
});
```
......@@ -51,13 +52,14 @@
```ts
import commonEventManager from '@ohos.commonEventManager';
import Base from '@ohos.base';
```
2. 传入需要发布的事件名称和回调函数,发布事件。
```ts
// 公共事件相关信息
let options = {
let options: commonEventManager.CommonEventPublishData = {
code: 1, // 公共事件的初始代码
data: "initial data", // 公共事件的初始数据
}
......@@ -67,11 +69,11 @@
```ts
// 发布公共事件
commonEventManager.publish("usual.event.SCREEN_OFF", options, (err) => {
commonEventManager.publish("usual.event.SCREEN_OFF", options, (err: Base.BusinessError) => {
if (err) {
console.error('[CommonEvent] PublishCallBack err=' + JSON.stringify(err));
} else {
console.info('[CommonEvent] Publish success')
}
})
});
```
......@@ -22,6 +22,7 @@
```ts
import commonEventManager from '@ohos.commonEventManager';
import Base from '@ohos.base';
```
3. 调用[`removeStickyCommonEvent()`](../reference/apis/js-apis-commonEventManager.md#commoneventmanagerremovestickycommonevent10)方法移除对应的粘性公共事件。
......@@ -31,7 +32,7 @@
> 移除的粘性公共事件,必须是本应用之前已发布的粘性公共事件,发布粘性公共事件参考[公共事件发布](common-event-publish.md)章节。
```ts
commonEventManager.removeStickyCommonEvent("sticky_event", (err) => { // sticky_event粘性公共事件名
commonEventManager.removeStickyCommonEvent("sticky_event", (err: Base.BusinessError) => { // sticky_event粘性公共事件名
if (err) {
console.error(`Failed to remove sticky common event. Code is ${err.code}, message is ${err.message}`);
return;
......
......@@ -21,10 +21,11 @@
开发者可以在[`onReceiveEvent()`](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md#staticsubscriberextensionabilityonreceiveevent)回调中实现业务逻辑。
```ts
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility';
import commonEventManager from '@ohos.commonEventManager';
export default class StaticSubscriber extends StaticSubscriberExtensionAbility {
onReceiveEvent(event) {
onReceiveEvent(event: commonEventManager.CommonEventData) {
console.info('onReceiveEvent, event: ' + event.event);
}
}
......
......@@ -23,15 +23,16 @@
```ts
import commonEventManager from '@ohos.commonEventManager';
import Base from '@ohos.base';
```
2. 创建订阅者信息,详细的订阅者信息数据类型及包含的参数请见[CommonEventSubscribeInfo](../reference/apis/js-apis-commonEventManager.md#commoneventsubscribeinfo)文档介绍。
```ts
// 用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
let subscriber = null;
let subscriber: commonEventManager.CommonEventSubscriber | null = null;
// 订阅者信息
let subscribeInfo = {
let subscribeInfo: commonEventManager.CommonEventSubscribeInfo = {
events: ["usual.event.SCREEN_OFF"], // 订阅灭屏公共事件
}
```
......@@ -40,7 +41,7 @@
```ts
// 创建订阅者回调
commonEventManager.createSubscriber(subscribeInfo, (err, data) => {
commonEventManager.createSubscriber(subscribeInfo, (err: Base.BusinessError, data: commonEventManager.CommonEventSubscriber) => {
if (err) {
console.error(`Failed to create subscriber. Code is ${err.code}, message is ${err.message}`);
return;
......@@ -56,7 +57,7 @@
```ts
// 订阅公共事件回调
if (subscriber !== null) {
commonEventManager.subscribe(subscriber, (err, data) => {
commonEventManager.subscribe(subscriber, (err: Base.BusinessError, data: commonEventManager.CommonEventData) => {
if (err) {
console.error(`Failed to subscribe common event. Code is ${err.code}, message is ${err.message}`);
return;
......
......@@ -19,6 +19,7 @@
```ts
import commonEventManager from '@ohos.commonEventManager';
import Base from '@ohos.base';
```
2. 根据[动态订阅公共事件](common-event-subscription.md)章节的步骤来订阅某个事件。
......@@ -28,7 +29,7 @@
```ts
// subscriber为订阅事件时创建的订阅者对象
if (subscriber !== null) {
commonEventManager.unsubscribe(subscriber, (err) => {
commonEventManager.unsubscribe(subscriber, (err: Base.BusinessError) => {
if (err) {
console.error(`[CommonEvent] UnsubscribeCallBack err=${JSON.stringify(err)}`);
} else {
......
......@@ -63,15 +63,16 @@ createFormBindingData(obj?: Object | string): FormBindingData
```ts
import formBindingData from '@ohos.app.form.formBindingData';
import fs from '@ohos.file.fs';
import Base from '@ohos.base';
try {
let fd = fs.openSync('/path/to/form.png');
let createFormBindingDataParam = new Map<Object, string | object>()
let formImagesParam = new Map<Object, object>()
formImagesParam.set('image', fd)
createFormBindingDataParam.set("name", '21°')
createFormBindingDataParam.set('formImages', formImagesParam)
let createFormBindingDataParam = new Map<string, string | Object>();
let formImagesParam = new Map<string, Object>();
formImagesParam.set('image', fd);
createFormBindingDataParam.set("name", '21°');
createFormBindingDataParam.set('formImages', formImagesParam);
formBindingData.createFormBindingData(createFormBindingDataParam);
} catch (error) {
......
......@@ -51,7 +51,7 @@ import Want from '@ohos.app.ability.Want';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAddForm(want: Want) {
console.log(`FormExtensionAbility onAddForm, want: ${want.abilityName}`);
let dataObj1 = new Map<Object, string>();
let dataObj1 = new Map<string, string>();
dataObj1.set('temperature', '11c');
dataObj1.set('time', '11:00');
......@@ -107,20 +107,19 @@ onUpdateForm(formId: string): void
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
import Base from '@ohos.base';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onUpdateForm(formId: string) {
console.log(`FormExtensionAbility onUpdateForm, formId: ${formId}`);
class createFormBindingDataParam {
temperature: string
time: string
}
let obj2 = formBindingData.createFormBindingData({
temperature: '22c',
time: '22:00'
} as createFormBindingDataParam);
});
formProvider.updateForm(formId, obj2).then((data) => {
console.log(`FormExtensionAbility context updateForm, data: ${data}`);
}).catch((error: Base.BusinessError) => {
console.error(`FormExtensionAbility context updateForm failed, data: ${error}`);
});
}
};
......@@ -146,6 +145,7 @@ onChangeFormVisibility(newStatus: { [key: string]: number }): void
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData';
import formProvider from '@ohos.app.form.formProvider';
import Base from '@ohos.base';
// 由于arkTs中无Object.keys,且无法使用for..in...
// 若报arkTs问题,请将此方法单独抽离至一个ts文件中并暴露,在需要用到的ets文件中引入使用
......@@ -155,23 +155,21 @@ function getObjKeys(obj: Object): string[] {
}
export default class MyFormExtensionAbility extends FormExtensionAbility {
onChangeFormVisibility(newStatus) {
onChangeFormVisibility(newStatus: Record<string, number>) {
console.log(`FormExtensionAbility onChangeFormVisibility, newStatus: ${newStatus}`);
class createFormBindingDataParam {
temperature: string
time: string
}
let obj2 = formBindingData.createFormBindingData({
temperature: '22c',
time: '22:00'
} as createFormBindingDataParam);
for (let key in newStatus) {
console.log(`FormExtensionAbility onChangeFormVisibility, key: ${key}, value= ${newStatus[key]}`);
formProvider.updateForm(key, obj2).then((data) => {
console.log(`FormExtensionAbility context updateForm, data: ${data}`);
}).catch((error) => {
console.error(`Operation updateForm failed. Cause: ${error}`);
});
let keys: string[] = getObjKeys(newStatus);
for (let i: number = 0; i < keys.length; i++) {
console.log(`FormExtensionAbility onChangeFormVisibility, key: ${keys[i]}, value= ${newStatus[keys[i]]}`);
formProvider.updateForm(keys[i], obj2).then(() => {
console.log(`FormExtensionAbility context updateForm`);
}).catch((error: Base.BusinessError) => {
console.error(`Operation updateForm failed. Cause: ${JSON.stringify(error)}`);
});
}
}
......@@ -317,9 +315,9 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onShareForm(formId: string) {
console.log(`FormExtensionAbility onShareForm, formId: ${formId}`);
let wantParams = {
let wantParams: Record<string, Object> = {
'temperature': '20',
'time': '2022-8-8 09:59',s
'time': '2022-8-8 09:59',
};
return wantParams;
}
......@@ -355,8 +353,8 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
export default class MyFormExtensionAbility extends FormExtensionAbility {
onAcquireFormData(formId: string) {
console.log('FormExtensionAbility onAcquireFormData, formId: ${formId}');
let wantParams = {
console.log(`FormExtensionAbility onAcquireFormData, formId: ${formId}`);
let wantParams: Record<string, Object> = {
'temperature': '20',
'time': '2022-8-8 09:59',
};
......
......@@ -61,7 +61,7 @@ try {
}
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -114,10 +114,10 @@ try {
formHost.deleteForm(formId).then(() => {
console.log('formHost deleteForm success');
}).catch((error: Base.BusinessError) => {
console.error('formHost deleteForm, error: ${JSON.stringify(error)}');
console.error(`formHost deleteForm, error: ${JSON.stringify(error)}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -167,7 +167,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -218,7 +218,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -274,7 +274,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -324,7 +324,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -379,7 +379,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -430,7 +430,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -485,7 +485,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -533,7 +533,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -586,7 +586,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -634,7 +634,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -687,7 +687,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -736,7 +736,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -790,7 +790,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -840,7 +840,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -895,7 +895,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -935,7 +935,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -974,7 +974,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1023,7 +1023,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1069,7 +1069,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1120,7 +1120,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1172,7 +1172,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1227,7 +1227,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1277,7 +1277,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1330,7 +1330,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1392,7 +1392,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1457,7 +1457,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1575,7 +1575,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1630,7 +1630,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1680,7 +1680,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1735,7 +1735,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
## shareForm
......@@ -1785,7 +1785,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1841,7 +1841,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1890,7 +1890,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1942,7 +1942,7 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -1990,7 +1990,7 @@ try {
}
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -2041,6 +2041,6 @@ try {
console.error(`error, code: ${error.code}, message: ${error.message}`);
});
} catch(error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message}`);
}
```
......@@ -57,7 +57,7 @@ try {
console.log(`formProvider setFormNextRefreshTime success`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
......@@ -110,7 +110,7 @@ try {
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
......@@ -152,15 +152,10 @@ import Base from '@ohos.base';
let formId: string = '12400633174999288';
try {
class createFormBindingDataParamType {
temperature: string
time: string
}
let createFormBindingDataParam: createFormBindingDataParamType = {
temperature:'22c',
time:'22:00'
};
let obj = formBindingData.createFormBindingData(createFormBindingDataParam);
let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData({
temperature: '22c',
time: '22:00'
});
formProvider.updateForm(formId, obj, (error: Base.BusinessError) => {
if (error) {
console.error(`callback error, code: ${error.code}, message: ${error.message})`);
......@@ -169,7 +164,7 @@ try {
console.log(`formProvider updateForm success`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
......@@ -215,23 +210,18 @@ import formBindingData from '@ohos.app.form.formBindingData';
import Base from '@ohos.base';
let formId: string = '12400633174999288';
class createFormBindingDataParamType {
temperature: string
time: string
}
let createFormBindingDataParam: createFormBindingDataParamType = {
temperature:'22c',
time:'22:00'
};
let obj = formBindingData.createFormBindingData(createFormBindingDataParam);
let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData({
temperature: '22c',
time: '22:00'
});
try {
formProvider.updateForm(formId, obj).then(() => {
console.log(`formProvider updateForm success`);
}).catch((error: Base.BusinessError) => {
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
console.error(`promise error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
......@@ -272,7 +262,7 @@ try {
console.log(`formProvider getFormsInfo, data: ${JSON.stringify(data)}`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
## getFormsInfo
......@@ -319,7 +309,7 @@ try {
console.log(`formProvider getFormsInfo, data: ${JSON.stringify(data)}`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
......@@ -371,7 +361,7 @@ try {
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
......@@ -421,24 +411,19 @@ let want: Want = {
}
};
try {
class createFormBindingDataParamType {
temperature: string
time: string
}
let createFormBindingDataParam: createFormBindingDataParamType = {
temperature:'22c',
time:'22:00'
};
let obj = formBindingData.createFormBindingData(createFormBindingDataParam);
let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData({
temperature: '22c',
time: '22:00'
});
formProvider.requestPublishForm(want, obj, (error: Base.BusinessError, data: string) => {
if (error) {
console.error(`callback error, code: ${error.code}, message: ${error.message})`);
console.error(`callback error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
return;
}
console.log('formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}');
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
......@@ -494,7 +479,7 @@ try {
console.log(`formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
......@@ -554,7 +539,7 @@ try {
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
......@@ -614,13 +599,13 @@ try {
console.log(`formProvider requestPublishForm, form ID is: ${JSON.stringify(data)}`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
}
}
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
......@@ -674,13 +659,13 @@ try {
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
}
}).catch((error: Base.BusinessError) => {
console.error(`promise error, code: ${error.code}, message: ${error.message})`);
});
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message})`);
console.error(`catch error, code: ${(error as Base.BusinessError).code}, message: ${(error as Base.BusinessError).message})`);
}
```
\ No newline at end of file
......@@ -50,6 +50,7 @@ createFormBindingData(obj?: Object | string): FormBindingData
```ts
import formBindingData from '@ohos.application.formBindingData';
import fs from '@ohos.file.fs';
import Base from '@ohos.base';
try {
let fd = fs.openSync('/path/to/form.png');
......@@ -61,6 +62,6 @@ try {
formBindingData.createFormBindingData(createFormBindingDataParam);
} catch (error) {
console.error('catch error, error: ${JSON.stringify(error)}');
console.error(`catch error, error: ${JSON.stringify(error as Base.BusinessError)}`);
}
```
......@@ -37,9 +37,9 @@ deleteForm(formId: string, callback: AsyncCallback&lt;void&gt;): void
import formHost from '@ohos.application.formHost';
let formId: string = '12400633174999288';
formHost.deleteForm(formId, (error, data) => {
formHost.deleteForm(formId, (error: Base.BusinessError) => {
if (error.code) {
console.error('formHost deleteForm, error: ${JSON.stringify(error)}');
console.error(`formHost deleteForm, error: ${JSON.stringify(error)}`);
}
});
```
......@@ -344,7 +344,7 @@ import Base from '@ohos.base';
let formId: string[] = ['12400633174999288'];
formHost.notifyVisibleForms(formId, (error: Base.BusinessError) => {
if (error.code) {
console.error('formHost notifyVisibleForms, error: ${JSON.stringify(error)}');
console.error(`formHost notifyVisibleForms, error: ${JSON.stringify(error)}`);
}
});
```
......
......@@ -97,16 +97,11 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
import formBindingData from '@ohos.app.form.formBindingData';
import Base from '@ohos.base'
let formId = '12400633174999288';
class createBindingDataType {
temperature: string
time: string
};
let createBindingDataParam: createBindingDataType = {
temperature:'22c',
time:'22:00'
};
let obj = formBindingData.createFormBindingData(createBindingDataParam);
let formId: string = '12400633174999288';
let obj = formBindingData.createFormBindingData({
temperature: '22c',
time: '22:00'
});
formProvider.updateForm(formId, obj, (error: Base.BusinessError) => {
if (error.code) {
console.error(`formProvider updateForm, error: ${JSON.stringify(error)}`);
......@@ -142,15 +137,10 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
import Base from '@ohos.base'
let formId: string = '12400633174999288';
class createBindingDataType {
temperature: string
time: string
};
let createBindingDataParam: createBindingDataType = {
temperature:'22c',
time:'22:00'
};
let obj = formBindingData.createFormBindingData(createBindingDataParam);
let obj = formBindingData.createFormBindingData({
temperature: '22c',
time: '22:00'
});
formProvider.updateForm(formId, obj).then(() => {
console.log('formProvider updateForm success');
}).catch((error: Base.BusinessError) => {
......
......@@ -11,8 +11,6 @@
```ts
import CommonEvent from '@ohos.commonEvent';
import CommonEventManager from '@ohos.commonEventManager';
import Base from '@ohos.base';
```
## Support
......@@ -42,6 +40,8 @@ publish(event: string, callback: AsyncCallback\<void>): void
**示例:**
```ts
import Base from '@ohos.base';
//发布公共事件回调
function publishCB(err:Base.BusinessError) {
if (err.code) {
......@@ -78,6 +78,9 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\
```ts
import Base from '@ohos.base';
import CommonEventManager from '@ohos.commonEventManager';
//公共事件相关信息
let options:CommonEventManager.CommonEventPublishData = {
code: 0, //公共事件的初始代码
......@@ -122,6 +125,8 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): vo
**示例:**
```ts
import Base from '@ohos.base';
// 发布公共事件回调
function publishCB(err:Base.BusinessError) {
if (err.code) {
......@@ -164,6 +169,9 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca
```ts
import Base from '@ohos.base';
import CommonEventManager from '@ohos.commonEventManager';
// 公共事件相关信息
let options:CommonEventManager.CommonEventPublishData = {
code: 0, // 公共事件的初始代码
......@@ -208,6 +216,9 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac
```ts
import Base from '@ohos.base';
import CommonEventManager from '@ohos.commonEventManager';
let subscriber:CommonEventManager.CommonEventSubscriber; // 用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
// 订阅者信息
......@@ -254,6 +265,9 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventS
**示例:**
```ts
import Base from '@ohos.base';
import CommonEventManager from '@ohos.commonEventManager';
let subscriber:CommonEventManager.CommonEventSubscriber; // 用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
// 订阅者信息
......@@ -291,6 +305,9 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEven
**示例:**
```ts
import Base from '@ohos.base';
import CommonEventManager from '@ohos.commonEventManager';
let subscriber:CommonEventManager.CommonEventSubscriber;// 用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
// 订阅者信息
......@@ -344,6 +361,9 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>):
**示例:**
```ts
import Base from '@ohos.base';
import CommonEventManager from '@ohos.commonEventManager';
let subscriber:CommonEventManager.CommonEventSubscriber; // 用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
// 订阅者信息
......
......@@ -10,7 +10,6 @@
```ts
import CommonEventManager from '@ohos.commonEventManager';
import Base from '@ohos.base';
```
## Support
......@@ -48,6 +47,8 @@ publish(event: string, callback: AsyncCallback\<void>): void
**示例:**
```ts
import Base from '@ohos.base';
//发布公共事件回调
function publishCB(err:Base.BusinessError) {
if (err) {
......@@ -96,6 +97,8 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\
**示例:**
```ts
import Base from '@ohos.base';
//公共事件相关信息
let options:CommonEventManager.CommonEventPublishData = {
code: 0, //公共事件的初始代码
......@@ -153,6 +156,8 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\<void>): vo
**示例:**
```ts
import Base from '@ohos.base';
//发布公共事件回调
function publishCB(err:Base.BusinessError) {
if (err) {
......@@ -208,6 +213,8 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca
```ts
import Base from '@ohos.base';
//公共事件相关信息
let options:CommonEventManager.CommonEventPublishData = {
code: 0, //公共事件的初始代码
......@@ -253,6 +260,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac
**示例:**
```ts
import Base from '@ohos.base';
let subscriber:CommonEventManager.CommonEventSubscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
//订阅者信息
......@@ -301,6 +310,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventS
**示例:**
```ts
import Base from '@ohos.base';
let subscriber:CommonEventManager.CommonEventSubscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
//订阅者信息
......@@ -340,6 +351,8 @@ createSubscriber的同步接口。
**示例:**
```ts
import Base from '@ohos.base';
let subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
//订阅者信息
......@@ -385,6 +398,8 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEven
**示例:**
```ts
import Base from '@ohos.base';
//订阅者信息
let subscriber:CommonEventManager.CommonEventSubscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
......@@ -456,6 +471,8 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>):
**示例:**
```ts
import Base from '@ohos.base';
let subscriber:CommonEventManager.CommonEventSubscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作
//订阅者信息
let subscribeInfo:CommonEventManager.CommonEventSubscribeInfo = {
......@@ -543,6 +560,8 @@ removeStickyCommonEvent(event: string, callback: AsyncCallback\<void>): void
```ts
import Base from '@ohos.base';
CommonEventManager.removeStickyCommonEvent("sticky_event", (err:Base.BusinessError) => {
if (err) {
console.info(`Remove sticky event AsyncCallback failed, errCode: ${err.code}, errMes: ${err.message}`);
......@@ -590,6 +609,8 @@ removeStickyCommonEvent(event: string): Promise\<void>
```ts
import Base from '@ohos.base';
CommonEventManager.removeStickyCommonEvent("sticky_event").then(() => {
console.info(`Remove sticky event AsyncCallback success`);
}).catch ((err:Base.BusinessError) => {
......@@ -627,6 +648,8 @@ setStaticSubscriberState(enable: boolean, callback: AsyncCallback\<void>): void;
```ts
import Base from '@ohos.base';
CommonEventManager.setStaticSubscriberState(true, (err:Base.BusinessError) => {
if (!err) {
console.info(`Set static subscriber state callback failed, err is null.`);
......@@ -675,6 +698,8 @@ setStaticSubscriberState(enable: boolean): Promise\<void>;
```ts
import Base from '@ohos.base';
CommonEventManager.setStaticSubscriberState(false).then(() => {
console.info(`Set static subscriber state promise success`);
}).catch ((err:Base.BusinessError) => {
......
......@@ -10,8 +10,8 @@
## 导入模块
```javascript
import emitter from '@ohos.events.emitter'
```ts
import emitter from '@ohos.events.emitter';
```
## 权限列表
......@@ -35,16 +35,15 @@ on(event: [InnerEvent](#innerevent), callback: Callback\<[EventData](#eventdata)
**示例:**
```javascript
let innerEvent = {
eventId: 1
```ts
let innerEvent: emitter.InnerEvent = {
eventId: 1
};
// 收到eventId为1的事件后执行该回调函数
function emitterCallback() {
console.info('callback');
}
emitter.on(innerEvent, emitterCallback);
// 收到eventId为1的事件后执行回调函数
emitter.on(innerEvent, () => {
console.info('callback');
});
```
## emitter.once
......@@ -64,16 +63,15 @@ once(event: [InnerEvent](#innerevent), callback: Callback\<[EventData](#eventdat
**示例:**
```javascript
let innerEvent = {
```ts
let innerEvent: emitter.InnerEvent = {
eventId: 1
};
// 收到eventId为1的事件后执行该回调函数
function emitterCallback() {
emitter.once(innerEvent, () => {
console.info('once callback');
};
emitter.once(innerEvent, emitterCallback);
});
```
## emitter.off
......@@ -92,7 +90,7 @@ off(eventId: number): void
**示例:**
```javascript
```ts
// 取消eventID为1的所有事件回调处理函数
emitter.off(1);
```
......@@ -114,13 +112,12 @@ off(eventId: number, callback: Callback\<[EventData](#eventdata)\>): void
**示例:**
```javascript
```ts
// 取消eventID为1的事件回调处理函数 emitterCallback
// 如果该回调处理函数没有被订阅,则不做任何处理
function emitterCallback() {
console.info('callback');
}
emitter.off(1, emitterCallback);
emitter.off(1, () => {
console.info('callback');
});
```
## emitter.emit
......@@ -140,15 +137,15 @@ emit(event: [InnerEvent](#innerevent), data?: [EventData](#eventdata)): void
**示例:**
```javascript
let eventData = {
```ts
let eventData: emitter.EventData = {
data: {
"content": "c",
"id": 1,
}
};
let innerEvent = {
let innerEvent: emitter.InnerEvent = {
eventId: 1,
priority: emitter.EventPriority.HIGH
};
......
......@@ -66,7 +66,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
};
this.context.startAbility(want, (error: Base.BusinessError) => {
if (error) {
console.error('FormExtensionContext startAbility, error:${JSON.stringify(error)}');
console.error(`FormExtensionContext startAbility, error:${JSON.stringify(error)}`);
} else {
console.log('FormExtensionContext startAbility success');
}
......@@ -213,7 +213,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
connection = this.context.connectServiceExtensionAbility(want, options);
} catch (paramError) {
// 处理入参错误异常
console.error(`error.code: ${paramError.code}, error.message: ${paramError.message}`);
console.error(`error.code: ${(paramError as Base.BusinessError).code}, error.message: ${(paramError as Base.BusinessError).message}`);
}
}
};
......@@ -275,7 +275,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
} catch (paramError) {
commRemote = null;
// 处理入参错误异常
console.error(`error.code: ${paramError.code}, error.message: ${paramError.message}`);
console.error(`error.code: ${(paramError as Base.BusinessError).code}, error.message: ${(paramError as Base.BusinessError).message}`);
}
}
};
......@@ -343,7 +343,7 @@ export default class MyFormExtensionAbility extends FormExtensionAbility {
} catch (paramError) {
commRemote = null;
// 处理入参错误异常
console.error(`error.code: ${paramError.code}, error.message: ${paramError.message}`);
console.error(`error.code: ${(paramError as Base.BusinessError).code}, error.message: ${(paramError as Base.BusinessError).message}`);
}
}
};
......
......@@ -8,6 +8,8 @@
**系统能力**:以下各项对应的系统能力均为SystemCapability.Notification.Notification
## 属性
| 名称 | 类型 | 必填 | 说明 |
| ---------------- | ---------------------- | ---- | --------------------------------- |
| soundEnabled | [NotificationFlagStatus](#notificationflagstatus) | 否 | 是否启用声音提示。 |
......
......@@ -32,23 +32,25 @@ onConsume?: (data: [SubscribeCallbackData](js-apis-notification.md#subscribecall
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
```ts
import Base from '@ohos.base';
let subscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConsumeCallback(data) {
console.info('===> onConsume in test');
let req = data.request;
console.info('===> onConsume callback req.id:' + req.id);
let onConsumeCallback = (data: notificationSubscribe.SubscribeCallbackData) => {
console.info('===> onConsume in test');
let req = data.request;
console.info('===> onConsume callback req.id:' + req.id);
};
let subscriber = {
onConsume: onConsumeCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onConsume: onConsumeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
......@@ -72,23 +74,25 @@ onCancel?:(data: [SubscribeCallbackData](js-apis-notification.md#subscribecallba
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
```ts
import Base from '@ohos.base';
let subscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onCancelCallback(data) {
console.info('===> onCancel in test');
let req = data.request;
console.info('===> onCancel callback req.id:' + req.id);
function onCancelCallback(data: notificationSubscribe.SubscribeCallbackData) {
console.info('===> onCancel in test');
let req = data.request;
console.info('===> onCancel callback req.id:' + req.id);
}
let subscriber = {
onCancel: onCancelCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onCancel: onCancelCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
......@@ -112,21 +116,21 @@ onUpdate?:(data: [NotificationSortingMap](js-apis-notification.md#notificationso
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
```ts
import Base from '@ohos.base';
let subscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onUpdateCallback(map) {
let subscriber: notificationSubscribe.NotificationSubscriber = {
onUpdate: (map) => {
console.info('===> onUpdateCallback map:' + JSON.stringify(map));
}
let subscriber = {
onUpdate: onUpdateCallback
}
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
......@@ -144,21 +148,23 @@ onConnect?:() => void
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
```ts
import Base from '@ohos.base';
let subscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
let onConnectCallback = () => {
console.info('===> onConnect in test');
}
let subscriber = {
onConnect: onConnectCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onConnect: onConnectCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
......@@ -176,32 +182,34 @@ onDisconnect?:() => void
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
```ts
import Base from '@ohos.base';
let subscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function unsubscribeCallback(err) {
if (err.code) {
console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("unsubscribeCallback");
}
let unsubscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("unsubscribeCallback");
}
};
function onConnectCallback() {
console.info('===> onConnect in test');
let onConnectCallback = () => {
console.info('===> onConnect in test');
}
function onDisconnectCallback() {
console.info('===> onDisconnect in test');
let onDisconnectCallback = () => {
console.info('===> onDisconnect in test');
}
let subscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback
};
// 订阅通知后会收到onConnect回调
......@@ -222,21 +230,23 @@ onDestroy?:() => void
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
```ts
import Base from '@ohos.base';
let subscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDestroyCallback() {
console.info('===> onDestroy in test');
let onDestroyCallback = () => {
console.info('===> onDestroy in test');
}
let subscriber = {
onDestroy: onDestroyCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onDestroy: onDestroyCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
......@@ -260,21 +270,23 @@ onDoNotDisturbDateChange?:(mode: notification.[DoNotDisturbDate](js-apis-notific
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
```ts
import Base from '@ohos.base';
let subscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onDoNotDisturbDateChangeCallback(mode) {
console.info('===> onDoNotDisturbDateChange:' + mode);
let onDoNotDisturbDateChangeCallback = (mode: NotificationManager.DoNotDisturbDate) => {
console.info('===> onDoNotDisturbDateChange:' + mode);
}
let subscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onDoNotDisturbDateChange: onDoNotDisturbDateChangeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
......@@ -299,23 +311,25 @@ onEnabledNotificationChanged?:(callbackData: [EnabledNotificationCallbackData](j
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
```ts
import Base from '@ohos.base';
let subscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onEnabledNotificationChangedCallback(callbackData) {
console.info("bundle: ", callbackData.bundle);
console.info("uid: ", callbackData.uid);
console.info("enable: ", callbackData.enable);
let onEnabledNotificationChangedCallback = (callbackData: notificationSubscribe.EnabledNotificationCallbackData) => {
console.info("bundle: ", callbackData.bundle);
console.info("uid: ", callbackData.uid);
console.info("enable: ", callbackData.enable);
};
let subscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onEnabledNotificationChanged: onEnabledNotificationChangedCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
......@@ -339,23 +353,23 @@ notificationSubscribe.subscribe(subscriber, subscribeCallback);
**示例:**
```javascript
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
```ts
import Base from '@ohos.base';
let subscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribeCallback");
}
};
function onBadgeChangedCallback(data) {
let subscriber: notificationSubscribe.NotificationSubscriber = {
onBadgeChanged: (data) => {
console.info("bundle: ", data.bundle);
console.info("uid: ", data.uid);
console.info("badgeNumber: ", data.badgeNumber);
};
let subscriber = {
onBadgeChanged: onBadgeChangedCallback
}
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
......
......@@ -8,7 +8,7 @@
## 导入模块
```js
```ts
import notificationSubscribe from '@ohos.notificationSubscribe';
```
......@@ -45,23 +45,25 @@ subscribe(subscriber: NotificationSubscriber, info: NotificationSubscribeInfo, c
**示例:**
```js
```ts
import Base from '@ohos.base';
//subscribe回调
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribe success");
}
let subscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribe success");
}
}
function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data));
let onConsumeCallback = (data: notificationSubscribe.SubscribeCallbackData) => {
console.info("Consume callback: " + JSON.stringify(data));
}
let subscriber = {
onConsume: onConsumeCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onConsume: onConsumeCallback
};
let info = {
bundleNames: ["bundleName1","bundleName2"]
let info: notificationSubscribe.NotificationSubscribeInfo = {
bundleNames: ["bundleName1","bundleName2"]
};
notificationSubscribe.subscribe(subscriber, info, subscribeCallback);
```
......@@ -98,19 +100,21 @@ subscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>):
**示例:**
```js
function subscribeCallback(err) {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribe success");
}
```ts
import Base from '@ohos.base';
let subscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`subscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("subscribe success");
}
}
function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data));
let onConsumeCallback = (data: notificationSubscribe.SubscribeCallbackData) => {
console.info("Consume callback: " + JSON.stringify(data));
}
let subscriber = {
onConsume: onConsumeCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onConsume: onConsumeCallback
};
notificationSubscribe.subscribe(subscriber, subscribeCallback);
```
......@@ -149,15 +153,19 @@ subscribe(subscriber: NotificationSubscriber, info?: NotificationSubscribeInfo):
**示例:**
```js
function onConsumeCallback(data) {
console.info("Consume callback: " + JSON.stringify(data));
```ts
import Base from '@ohos.base';
let onConsumeCallback = (data: notificationSubscribe.SubscribeCallbackData) => {
console.info("Consume callback: " + JSON.stringify(data));
}
let subscriber = {
onConsume: onConsumeCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onConsume: onConsumeCallback
};
notificationSubscribe.subscribe(subscriber).then(() => {
console.info("subscribe success");
console.info("subscribe success");
}).catch((err: Base.BusinessError) => {
console.error("subscribe fail: " + JSON.stringify(err));
});
```
......@@ -194,19 +202,21 @@ unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback\<void\>)
**示例:**
```js
function unsubscribeCallback(err) {
if (err) {
console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("unsubscribe success");
}
```ts
import Base from '@ohos.base';
let unsubscribeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`unsubscribe failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("unsubscribe success");
}
}
function onDisconnectCallback() {
console.info("subscribe disconnect");
let onDisconnectCallback = () => {
console.info("subscribe disconnect");
}
let subscriber = {
onDisconnect: onDisconnectCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onDisconnect: onDisconnectCallback
};
notificationSubscribe.unsubscribe(subscriber, unsubscribeCallback);
```
......@@ -241,15 +251,19 @@ unsubscribe(subscriber: NotificationSubscriber): Promise\<void\>
**示例:**
```js
function onDisconnectCallback() {
console.info("subscribe disconnect");
```ts
import Base from '@ohos.base';
let onDisconnectCallback = () => {
console.info("subscribe disconnect");
}
let subscriber = {
onDisconnect: onDisconnectCallback
let subscriber: notificationSubscribe.NotificationSubscriber = {
onDisconnect: onDisconnectCallback
};
notificationSubscribe.unsubscribe(subscriber).then(() => {
console.info("unsubscribe success");
console.info("unsubscribe success");
}).catch((err: Base.BusinessError) => {
console.error("unsubscribe fail: " + JSON.stringify(err));
});
```
......@@ -288,22 +302,25 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
**示例:**
```js
function removeCallback(err) {
if (err) {
console.error(`remove failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("remove success");
}
```ts
import Base from '@ohos.base';
import NotificationManager from '@ohos.notificationManager';
let removeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`remove failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("remove success");
}
}
let bundle = {
bundle: "bundleName1",
let bundle: NotificationManager.BundleOption = {
bundle: "bundleName1",
};
let notificationKey = {
id: 0,
label: "label",
let notificationKey: notificationSubscribe.NotificationKey = {
id: 0,
label: "label",
};
let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
let reason: notificationSubscribe.RemoveReason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
notificationSubscribe.remove(bundle, notificationKey, reason, removeCallback);
```
......@@ -343,17 +360,22 @@ remove(bundle: BundleOption, notificationKey: NotificationKey, reason: RemoveRea
**示例:**
```js
let bundle = {
bundle: "bundleName1",
```ts
import Base from '@ohos.base';
import NotificationManager from '@ohos.notificationManager';
let bundle: NotificationManager.BundleOption = {
bundle: "bundleName1",
};
let notificationKey = {
id: 0,
label: "label",
let notificationKey: notificationSubscribe.NotificationKey = {
id: 0,
label: "label",
};
let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
let reason: notificationSubscribe.RemoveReason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
notificationSubscribe.remove(bundle, notificationKey, reason).then(() => {
console.info("remove success");
console.info("remove success");
}).catch((err: Base.BusinessError) => {
console.error("remove fail: " + JSON.stringify(err));
});
```
......@@ -390,17 +412,19 @@ remove(hashCode: string, reason: RemoveReason, callback: AsyncCallback\<void\>):
**示例:**
```js
let hashCode = 'hashCode';
```ts
import Base from '@ohos.base';
function removeCallback(err) {
if (err) {
console.error(`remove failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("remove success");
}
let hashCode: string = 'hashCode';
let removeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`remove failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("remove success");
}
}
let reason = notificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
let reason: notificationSubscribe.RemoveReason = notificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
notificationSubscribe.remove(hashCode, reason, removeCallback);
```
......@@ -436,11 +460,15 @@ remove(hashCode: string, reason: RemoveReason): Promise\<void\>
**示例:**
```js
let hashCode = 'hashCode';
let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
```ts
import Base from '@ohos.base';
let hashCode: string = 'hashCode';
let reason: notificationSubscribe.RemoveReason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
notificationSubscribe.remove(hashCode, reason).then(() => {
console.info("remove success");
}).catch((err: Base.BusinessError) => {
console.error("remove fail: " + JSON.stringify(err));
});
```
## NotificationSubscribe.remove<sup>10+<sup>
......@@ -475,17 +503,19 @@ remove(hashCodes: Array\<String\>, reason: RemoveReason, callback: AsyncCallback
**示例:**
```js
let hashCodes = ['hashCode1', 'hashCode2'];
```ts
import Base from '@ohos.base';
function removeCallback(err) {
if (err) {
console.error(`remove failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("remove success");
}
let hashCodes: string[] = ['hashCode1', 'hashCode2'];
let removeCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`remove failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("remove success");
}
}
let reason = notificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
let reason: notificationSubscribe.RemoveReason = notificationSubscribe.RemoveReason.CANCEL_REASON_REMOVE;
notificationSubscribe.remove(hashCodes, reason, removeCallback);
```
......@@ -520,11 +550,15 @@ remove(hashCodes: Array\<String\>, reason: RemoveReason): Promise\<void\>
**示例:**
```js
let hashCodes = ['hashCode1','hashCode2'];
let reason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
```ts
import Base from '@ohos.base';
let hashCodes: string[] = ['hashCode1','hashCode2'];
let reason: notificationSubscribe.RemoveReason = notificationSubscribe.RemoveReason.CLICK_REASON_REMOVE;
notificationSubscribe.remove(hashCodes, reason).then(() => {
console.info("remove success");
console.info("remove success");
}).catch((err: Base.BusinessError) => {
console.error("remove fail: " + JSON.stringify(err));
});
```
......@@ -560,16 +594,18 @@ removeAll(bundle: BundleOption, callback: AsyncCallback\<void\>): void
**示例:**
```js
function removeAllCallback(err) {
if (err) {
console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("removeAll success");
}
```ts
import Base from '@ohos.base';
let removeAllCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("removeAll success");
}
}
let bundle = {
bundle: "bundleName1",
let bundle: notificationSubscribe.BundleOption = {
bundle: "bundleName1",
};
notificationSubscribe.removeAll(bundle, removeAllCallback);
```
......@@ -604,8 +640,10 @@ removeAll(callback: AsyncCallback\<void\>): void
**示例:**
```js
function removeAllCallback(err) {
```ts
import Base from '@ohos.base';
let removeAllCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else {
......@@ -647,10 +685,14 @@ removeAll(bundle?: BundleOption): Promise\<void\>
**示例:**
```js
```ts
import Base from '@ohos.base';
// 不指定应用时,删除所有通知
notificationSubscribe.removeAll().then(() => {
console.info("removeAll success");
}).catch((err: Base.BusinessError) => {
console.error("removeAll fail: " + JSON.stringify(err));
});
```
......@@ -686,16 +728,18 @@ removeAll(userId: number, callback: AsyncCallback\<void>): void
**示例:**
```js
function removeAllCallback(err) {
if (err) {
console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("removeAll success");
}
```ts
import Base from '@ohos.base';
let removeAllCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("removeAll success");
}
}
let userId = 1;
let userId: number = 1;
notificationSubscribe.removeAll(userId, removeAllCallback);
```
......@@ -731,16 +775,18 @@ removeAll(userId: number): Promise\<void>
**示例:**
```js
function removeAllCallback(err) {
if (err) {
console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("removeAll success");
}
```ts
import Base from '@ohos.base';
let removeAllCallback = (err: Base.BusinessError) => {
if (err) {
console.error(`removeAll failed, code is ${err.code}, message is ${err.message}`);
} else {
console.info("removeAll success");
}
}
let userId = 1;
let userId: number = 1;
notificationSubscribe.removeAll(userId, removeAllCallback);
```
......
......@@ -51,11 +51,7 @@ show(options?: ShowNotificationOptions): void
**示例:**
```ts
class NotificationClass {
show: Function
}
let notificationObj: NotificationClass = {
let notificationObj: notification = {
show() {
notification.show({
contentTitle: 'title info',
......@@ -69,5 +65,5 @@ let notificationObj: NotificationClass = {
}
}
export default notificationObj
export default notificationObj
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册