diff --git a/zh-cn/application-dev/application-models/inputmethodextentionability.md b/zh-cn/application-dev/application-models/inputmethodextentionability.md index 9fa4a2b97e96b9d43d0d9d271663c3e5c9fdd07d..329bbf970b9e3c755c108598347e7352e2ab8e1e 100644 --- a/zh-cn/application-dev/application-models/inputmethodextentionability.md +++ b/zh-cn/application-dev/application-models/inputmethodextentionability.md @@ -347,10 +347,10 @@ InputMethodExtensionAbility通过[InputMethodExtensionContext](../reference/apis // ... "extensionAbilities": [ { - "description": "输入法Demo", + "description": "inputMethod", "icon": "$media:icon", - "name": "InputDemoService", - "srcEntrance": "./ets/InputMethodExtAbility/InputMethodService.ts", + "name": "InputMethodExtAbility", + "srcEntrance": "./ets/inputmethodextability/InputMethodService.ts", "type": "inputMethod", "visible": true, } diff --git a/zh-cn/application-dev/application-test/arkxtest-guidelines.md b/zh-cn/application-dev/application-test/arkxtest-guidelines.md index f79e8b5cce3c66e0c16b140c64c16326d76aade3..b427ea7e285f44ef6df9f338d7b10d288e449828 100644 --- a/zh-cn/application-dev/application-test/arkxtest-guidelines.md +++ b/zh-cn/application-dev/application-test/arkxtest-guidelines.md @@ -108,7 +108,7 @@ UI测试脚本是在单元测试框架的基础上编写,主要就是增加了 下面的示例代码是在上面的测试脚本基础上增量编写,首先需要增加依赖导包,如下示例代码所示: ```js -import {UiDriver,BY,UiComponent,MatchPattern} from '@ohos.uitest' +import {Driver,ON,Component,MatchPattern} from '@ohos.uitest' ``` 然后是具体测试代码编写,场景较为简单,就是在启动的应用页面上进行点击操作,然后增加检查点检查用例。 @@ -131,16 +131,16 @@ export default function abilityTest() { expect(Ability.context.abilityInfo.name).assertEqual('EntryAbility'); }) //ui test code - //init uidriver - var driver = await UiDriver.create(); + //init driver + var driver = await Driver.create(); await driver.delayMs(1000); - //find button by text 'Next' - var button = await driver.findComponent(BY.text('Next')); + //find button on text 'Next' + var button = await driver.findComponent(ON.text('Next')); //click button await button.click(); await driver.delayMs(1000); //check text - await driver.assertComponentExist(BY.text('after click')); + await driver.assertComponentExist(ON.text('after click')); await driver.pressBack(); done(); }) diff --git a/zh-cn/application-dev/application-test/figures/Execute.PNG b/zh-cn/application-dev/application-test/figures/Execute.PNG index 7c9d9be0d39c8b07c32f351622423085a4086584..5d4d1b3c79e423e7e2f758c77dd1474f2bcc47d9 100644 Binary files a/zh-cn/application-dev/application-test/figures/Execute.PNG and b/zh-cn/application-dev/application-test/figures/Execute.PNG differ diff --git a/zh-cn/application-dev/database/database-distributedobject-guidelines.md b/zh-cn/application-dev/database/database-distributedobject-guidelines.md index d17f68d9f8e04e6984eafd04577f397e42a79c99..0a441dc09b9d6c29b5d3e663e1fb0f5132c09833 100644 --- a/zh-cn/application-dev/database/database-distributedobject-guidelines.md +++ b/zh-cn/application-dev/database/database-distributedobject-guidelines.md @@ -111,18 +111,43 @@ 这个权限还需要在应用首次启动的时候弹窗获取用户授权。 ```js + // FA模型 import featureAbility from '@ohos.ability.featureAbility'; - + function grantPermission() { console.info('grantPermission'); let context = featureAbility.getContext(); context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) { - console.info(`result.requestCode=${result.requestCode}`) - + console.info(`requestPermissionsFromUser CallBack`); + }) console.info('end grantPermission'); } - + + grantPermission(); + ``` + + ```ts + // Stage模型 + import UIAbility from '@ohos.app.ability.UIAbility'; + + let context = null; + + class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage) { + context = this.context; + } + } + + function grantPermission() { + let permissions = ['ohos.permission.DISTRIBUTED_DATASYNC']; + context.requestPermissionsFromUser(permissions).then((data) => { + console.log('success: ${data}'); + }).catch((error) => { + console.error('failed: ${error}'); + }); + } + grantPermission(); ``` diff --git a/zh-cn/application-dev/quick-start/app-configuration-file.md b/zh-cn/application-dev/quick-start/app-configuration-file.md index bb49a4387e9ceea462d394a1280cac5467b47d3f..a890fd96269336f5bd3e8b52fa3c1f2e9640bf14 100644 --- a/zh-cn/application-dev/quick-start/app-configuration-file.md +++ b/zh-cn/application-dev/quick-start/app-configuration-file.md @@ -45,6 +45,7 @@ app.json5配置文件包含以下标签。 | targetAPIVersion | 标识应用运行需要的API目标版本。 | 数值 | 由build-profile.json5中的compileSdkVersion生成。 | | apiReleaseType | 标识应用运行需要的API目标版本的类型,采用字符串类型表示。取值为“CanaryN”、“BetaN”或者“Release”,其中,N代表大于零的整数。
- Canary:受限发布的版本。
- Beta:公开发布的Beta版本。
- Release:公开发布的正式版本。
该字段由DevEco Studio读取当前使用的SDK的Stage来生成。 | 字符串 | 该标签可缺省,由IDE生成并覆盖。 | | multiProjects | 标识当前工程是否支持多个工程的联合开发。
- true:当前工程支持多个工程的联合开发。
- false:当前工程不支持多个工程的联合开发。多工程开发可以参考文档:[多工程构建](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/ohos-building-overview-0000001263360495-V3#section71471033104216) | 布尔值 | 可缺省,缺省值为false。 | +| assanEnabled | 标识应用程序是否开启asan检测,用于辅助定位buffer越界造成的crash问题。
- true:当前工程开启asan检测。
- false:当前工程不开启asan检测。Release版本不支持开启asan检测。 | 布尔值 | 可缺省,缺省值为false。 | | tablet | 标识对tablet设备做的特殊配置,可以配置的属性字段有上文提到的:minAPIVersion、distributedNotificationEnabled。
如果使用该属性对tablet设备做了特殊配置,则应用在tablet设备中会采用此处配置的属性值,并忽略在app.json5公共区域配置的属性值。 | 对象 | 该标签可缺省,缺省时tablet设备使用app.json5公共区域配置的属性值。 | | tv | 标识对tv设备做的特殊配置,可以配置的属性字段有上文提到的:minAPIVersion、distributedNotificationEnabled。
如果使用该属性对tv设备做了特殊配置,则应用在tv设备中会采用此处配置的属性值,并忽略在app.json5公共区域配置的属性值。 | 对象 | 该标签可缺省,缺省时tv设备使用app.json5公共区域配置的属性值。 | | wearable | 标识对wearable设备做的特殊配置,可以配置的属性字段有上文提到的:minAPIVersion、distributedNotificationEnabled。
如果使用该属性对wearable设备做了特殊配置,则应用在wearable设备中会采用此处配置的属性值,并忽略在app.json5公共区域配置的属性值。 | 对象 | 该标签可缺省,缺省时wearable设备使用app.json5公共区域配置的属性值。 | diff --git a/zh-cn/application-dev/quick-start/app-structure.md b/zh-cn/application-dev/quick-start/app-structure.md index 3cfc6a9f1560db75f13cb32e847e578669afaafb..14a44e4f29a4d124ee11cf2752498bab35b99702 100644 --- a/zh-cn/application-dev/quick-start/app-structure.md +++ b/zh-cn/application-dev/quick-start/app-structure.md @@ -13,6 +13,7 @@ app对象包含应用全局配置信息,内部结构如下: | apiVersion | 标识应用程序所依赖的OpenHarmony API版本。 | 对象 | 可缺省,缺省值为空。 | | smartWindowSize | 标识应用在模拟器中运行时使用的屏幕尺寸。 | 字符串 | 可缺省,缺省值为空。 | | smartWindowDeviceType | 标识应用在模拟器中运行时可以模拟的设备。 | 字符串数组 | 可缺省,缺省值为空。 | +| assanEnabled | 标识应用程序是否开启asan检测,用于辅助定位buffer越界造成的crash问题。
- true:当前工程开启asan检测。
- false:当前工程不开启asan检测。Release版本不支持开启asan检测。 | 布尔值 | 可缺省,缺省值false。 | ## version对象内部结构 diff --git a/zh-cn/application-dev/quick-start/module-configuration-file.md b/zh-cn/application-dev/quick-start/module-configuration-file.md index 851eef300841ba827184a02a9f81fffa51f7dec4..d9f377179fbc7058bd4c393d14784dd6e9be695c 100644 --- a/zh-cn/application-dev/quick-start/module-configuration-file.md +++ b/zh-cn/application-dev/quick-start/module-configuration-file.md @@ -231,6 +231,7 @@ ablities标签描述UIAbility组件的配置信息,标签值为数组类型, | maxWindowHeight | 标识当前UIAbility组件支持的最大的窗口高度, 高度单位为vp。该标签最小取值为0。 | 数值 | 该标签可缺省,缺省值为平台支持的最大的窗口高度。 | | minWindowHeight | 标识当前UIAbility组件支持的最小的窗口高度, 高度单位为vp。该标签最小取值为0。 | 数值 | 该标签可缺省,缺省值为平台支持的最小的窗口高度。 | | excludeFromMissions | 标识当前UIAbility组件是否在最近任务列表中显示。
- true:表示不在任务列表中显示。
- false:表示在任务列表中显示。
**说明:**
- 仅支持系统应用配置,三方应用配置不生效。 | 布尔值 | 该标签可缺省,缺省值为false。 | +| recoverable | 标识当前是否支持在检测到应用故障后,恢复到应用原界面。
- true:支持检测到出现故障后,恢复到原界面。
- false:不支持检测到出现故障后,恢复到原界面。 | 布尔值 | 该标签可缺省,缺省值为false。 | abilities示例: @@ -348,7 +349,7 @@ skills示例: | description | 标识当前ExtensionAbility组件的描述,标签值最大长度为255字节,标签也可以是描述内容的资源索引,用于支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | | icon | 标识当前ExtensionAbility组件的图标,标签值为资源文件的索引。如果ExtensionAbility组件被配置为MainElement,该标签必须配置。 | 字符串 | 该标签可缺省,缺省值为空。 | | label | 标识当前ExtensionAbility组件对用户显示的名称,标签值配置为该名称的资源索引以支持多语言。
**说明:**
- 如果ExtensionAbility被配置当前Module的mainElement时,该标签必须配置,且应用内唯一。 | 字符串 | 该标签不可缺省。 | -| type | 标识当前ExtensionAbility组件的类型,取值为:
- form:卡片的ExtensionAbility。
- workScheduler:延时任务的ExtensionAbility。
- inputMethod:输入法的ExtensionAbility。
- service:后台运行的service组件。
- accessibility:辅助能力的ExtensionAbility。
- dataShare:数据共享的ExtensionAbility。
- fileShare:文件共享的ExtensionAbility。
- staticSubscriber:静态广播的ExtensionAbility。
- wallpaper:壁纸的ExtensionAbility。
- backup:数据备份的ExtensionAbility。
- window:该ExtensionAbility会在启动过程中创建一个window,为开发者提供界面开发。开发者开发出来的界面将通过abilityComponent控件组合到其他应用的窗口中。
- thumbnail:获取文件缩略图的ExtensionAbility,开发者可以对自定义文件类型的文件提供缩略。
- preview:该ExtensionAbility会将文件解析后在一个窗口中显示,开发者可以通过将此窗口组合到其他应用窗口中。
**说明:**
- 其中service和dataShare类型,仅支持系统应用配置,三方应用配置不生效。 | 字符串 | 该标签不可缺省。 | +| type | 标识当前ExtensionAbility组件的类型,取值为:
- form:卡片的ExtensionAbility。
- workScheduler:延时任务的ExtensionAbility。
- inputMethod:输入法的ExtensionAbility。
- service:后台运行的service组件。
- accessibility:辅助能力的ExtensionAbility。
- dataShare:数据共享的ExtensionAbility。
- fileShare:文件共享的ExtensionAbility。
- staticSubscriber:静态广播的ExtensionAbility。
- wallpaper:壁纸的ExtensionAbility。
- backup:数据备份的ExtensionAbility。
- window:该ExtensionAbility会在启动过程中创建一个window,为开发者提供界面开发。开发者开发出来的界面将通过abilityComponent控件组合到其他应用的窗口中。
- thumbnail:获取文件缩略图的ExtensionAbility,开发者可以对自定义文件类型的文件提供缩略。
- preview:该ExtensionAbility会将文件解析后在一个窗口中显示,开发者可以通过将此窗口组合到其他应用窗口中。
- print:打印框架的ExtensionAbility。
**说明:**
- 其中service和dataShare类型,仅支持系统应用配置,三方应用配置不生效。 | 字符串 | 该标签不可缺省。 | | permissions | 标识当前ExtensionAbility组件自定义的权限信息。当其他应用访问该ExtensionAbility时,需要申请相应的权限信息。
一个数组元素为一个权限名称。通常采用反向域名格式(最大255字节),可以是系统预定义的权限,也可以是该应用自定义的权限。如果是后者,需与defPermissions标签中定义的某个权限的name标签值一致。 | 字符串数组 | 该标签可缺省,缺省值为空。 | | uri | 标识当前ExtensionAbility组件提供的数据URI,为字符数组类型(最大长度255),用反向域名的格式表示。
**说明:**
- 该标签在type为dataShare类型的ExtensionAbility时,不可缺省。 | 字符串 | 该标签可缺省,缺省值为空。 | |skills | 标识当前ExtensionAbility组件能够接收的[Want](../application-models/want-overview.md)的特征集,为数组格式。
配置规则:entry包可以配置多个具有入口能力的skills标签(配置了ohos.want.action.home和entity.system.home)的ExtensionAbility,其中第一个配置了skills标签的ExtensionAbility中的label和icon作为OpenHarmony服务或应用的label和icon。
**说明:**
- OpenHarmony服务的Feature包不能配置具有入口能力的skills标签。
- OpenHarmony应用的Feature包可以配置具有入口能力的skills标签。 | 数组 | 该标签可缺省,缺省值为空。 | diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 7df578b35ba6e1b0f712a5d0ef1bb7448c70be6d..2b2c63e1820fbac6368d56a35cefc6f28b5a1d2d 100755 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -1,4 +1,4 @@ -# 接口 +# 接口 - [开发说明](development-intro.md) @@ -157,6 +157,7 @@ - [@ohos.curves (插值计算)](js-apis-curve.md) - [@ohos.matrix4 (矩阵变换)](js-apis-matrix4.md) - [@ohos.mediaquery (媒体查询)](js-apis-mediaquery.md) + - [@ohos.pluginComponent(PluginComponentManager)](js-apis-plugincomponent.md) - [@ohos.promptAction (弹窗)](js-apis-promptAction.md) - [@ohos.router (页面路由)](js-apis-router.md) @@ -228,8 +229,8 @@ - [@ohos.file.statvfs (文件系统空间统计)](js-apis-file-statvfs.md) - [@ohos.filemanagement.userFileManager (用户数据管理)](js-apis-userFileManager.md) - [@ohos.multimedia.medialibrary (媒体库管理)](js-apis-medialibrary.md) - - [@ohos.storageStatistics (应用空间统计)](js-apis-storage-statistics.md) - - [@ohos.volumeManager (卷管理)](js-apis-volumemanager.md) + - [@ohos.storageStatistics (应用空间统计)](js-apis-file-storage-statistics.md) + - [@ohos.volumeManager (卷管理)](js-apis-file-volumemanager.md) - 电话服务 - [@ohos.contact (联系人)](js-apis-contact.md) @@ -336,6 +337,7 @@ - [@ohos.enterprise.adminManager (企业设备管理)](js-apis-enterprise-adminManager.md) - [@ohos.enterprise.dateTimeManager (系统时间管理)](js-apis-enterprise-dateTimeManager.md) - [@ohos.enterprise.deviceControl (设备控制管理)](js-apis-enterprise-deviceControl.md) + - [@ohos.enterprise.wifiManager (WiFi管理)](js-apis-enterprise-wifiManager.md) - 语言基础类库 - [@ohos.buffer (Buffer)](js-apis-buffer.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-enterprise-wifiManager.md b/zh-cn/application-dev/reference/apis/js-apis-enterprise-wifiManager.md new file mode 100644 index 0000000000000000000000000000000000000000..81dbd16db9c033e8ce5dffa52fcc2db355336b7c --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-enterprise-wifiManager.md @@ -0,0 +1,104 @@ +# @ohos.enterprise.wifiManager(WiFi管理) + +本模块提供企业设备WiFi管理能力,包括查询WiFi开启状态等。仅企业设备管理员应用才能调用。 + +> **说明:** +> +> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```js +import wifiManager from '@ohos.enterprise.wifiManager'; +``` + +## wifiManager.isWifiActive + +isWifiActive(admin: Want, callback: AsyncCallback<boolean>): void + +查询wifi开启状态,使用callback形式返回wifi开启状态。 + +**需要权限:** ohos.permission.ENTERPRISE_SET_WIFI + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | +| callback | AsyncCallback<boolean> | 是 | callback方式返回wifi开启状态 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) + +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | the application is not an administrator of the device. | +| 9200002 | the administrator application does not have permission to manage the device. | + +**示例:** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +wifiManager.isWifiActive(wantTemp, (error, result) => { + if (error != null) { + console.log("error code:" + error.code + " error message:" + error.message); + return; + } + console.log(result); +}); +``` + +## wifiManager.isWifiActive + +isWifiActive(admin: Want): Promise<boolean> + +获取wifi开启状态,使用callback形式返回wifi开启状态。 + +**需要权限:** ohos.permission.ENTERPRISE_SET_WIFI + +**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager + +**系统API**: 此接口为系统接口。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ----------------------------------- | ---- | ------- | +| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | ------------------------- | +| Promise<boolean> | Promise方式返回wifi开启状态 | + +**错误码**: + +以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md) + +| 错误码ID | 错误信息 | +| ------- | ---------------------------------------------------------------------------- | +| 9200001 | the application is not an administrator of the device. | +| 9200002 | the administrator application does not have permission to manage the device. | + +**示例:** + +```js +let wantTemp = { + bundleName: "com.example.myapplication", + abilityName: "EntryAbility", +}; +wifiManager.isWifiActive(wantTemp).then((result) => { + console.log(result); +}).catch(error => { + console.log("error code:" + error.code + " error message:" + error.message); +}); +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md b/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md index a05eaa950e88168109014c8b39bac11f1a4ad908..2f66868a47a28345d007b1320abbd349800f41d8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md +++ b/zh-cn/application-dev/reference/apis/js-apis-fileAccess.md @@ -17,7 +17,7 @@ import fileAccess from '@ohos.file.fileAccess'; getFileAccessAbilityInfo( ) : Promise<Array<Want>> -以异步方法获取系统内extension配置为fileAcesss类型的所有Want信息。使用Promise异步回调。 +以异步方法获取系统内extension配置为fileAccess类型的所有Want信息。使用Promise异步回调。 **系统能力**:SystemCapability.FileManagement.UserFileService @@ -47,7 +47,7 @@ getFileAccessAbilityInfo( ) : Promise<Array<Want>> getFileAccessAbilityInfo(callback: AsyncCallback<Array<Want>>): void; -以异步方法获取系统内extension配置为fileAcesss类型的所有Want信息。使用callback异步回调。 +以异步方法获取系统内extension配置为fileAccess类型的所有Want信息。使用callback异步回调。 **系统能力**:SystemCapability.FileManagement.UserFileService @@ -150,12 +150,12 @@ createFileAccessHelper(context: Context) : FileAccessHelper ```js createFileAccessHelper() { - let fileAccesssHelperAllServer = null; + let fileAccessHelperAllServer = null; // 创建连接系统内所有配置fileAccess的文件管理类服务的helper对象 try { // this.context 是EntryAbility 传过来的context - fileAccesssHelperAllServer = fileAccess.createFileAccessHelper(this.context); - if (!fileAccesssHelperAllServer) + fileAccessHelperAllServer = fileAccess.createFileAccessHelper(this.context); + if (!fileAccessHelperAllServer) console.error("createFileAccessHelper interface returns an undefined object"); } catch (error) { console.error("createFileAccessHelper failed, errCode:" + error.code + ", errMessage:" + error.message); diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index bae88f7b46887eec29700970fa3f71c89bc94326..35538b60d4defdbe0b9de62195ff4740c0581c83 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -3793,7 +3793,7 @@ audioPlayer.on('error', (error) => { //设置'error'事件回调 console.info(`audio error called, error: ${error}`); }); -// 用户选择视频设置fd(本地播放) +// 用户选择音频设置fd(本地播放) let fdPath = 'fd://'; // path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" 命令,将其推送到设备上 let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md index 955a1c086f9f76512b5280c668f9baed1a1570f6..3df21e05a765610e5c22aab750c7c66679a699f8 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md +++ b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md @@ -110,6 +110,36 @@ connection.getDefaultNet().then(function (data) { }) ``` +## connection.getDefaultNetSync9+ + +getDefaultNetSync(): NetHandle + +使用同步方法获取默认激活的数据网络。可以使用[getNetCapabilities](#connectiongetnetcapabilities)去获取网络的类型、拥有的能力等信息。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**返回值:** + +| 类型 | 说明 | +| --------- | ---------------------------------- | +| NetHandle | 以同步方式返回默认激活的数据网络。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**示例:** + +```js +let netHandle = connection.getDefaultNetSync(); +``` + ## connection.getGlobalHttpProxy10+ getGlobalHttpProxy(callback: AsyncCallback\): void @@ -406,36 +436,6 @@ connection.getDefaultNet().then(function (netHandle) { }) ``` -## connection.getDefaultNetSync9+ - -getDefaultNetSync(): NetHandle; - -使用同步方法获取默认激活的数据网络。可以使用[getNetCapabilities](#connectiongetnetcapabilities)去获取网络的类型、拥有的能力等信息。 - -**需要权限**:ohos.permission.GET_NETWORK_INFO - -**系统能力**:SystemCapability.Communication.NetManager.Core - -**返回值:** - -| 类型 | 说明 | -| --------- | ---------------------------------- | -| NetHandle | 以同步方式返回默认激活的数据网络。 | - -**错误码:** - -| 错误码ID | 错误信息 | -| ------- | ----------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**示例:** - -```js -let netHandle = connection.getDefaultNetSync(); -``` - ## connection.getAllNets getAllNets(callback: AsyncCallback<Array<NetHandle>>): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-plugincomponent.md b/zh-cn/application-dev/reference/apis/js-apis-plugincomponent.md new file mode 100644 index 0000000000000000000000000000000000000000..4c7b81609c6de384d947f905b162dc9c1e16c540 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-plugincomponent.md @@ -0,0 +1,398 @@ +# @ohos.pluginComponent (PluginComponentManager) + +用于给插件组件的使用者请求组件与数据,使用者发送组件模板和数据。如需实现插件模板的显示,请参考[PluginComponent](../arkui-ts/ts-basic-components-plugincomponent.md)。 + +> **说明:** +> +> - 本模块首批接口从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +## 导入模块 + +```js +import pluginComponentManager from '@ohos.pluginComponent' +``` + +## PluginComponentTemplate + +Plugin组件模板参数。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 参数 | 类型 | 必填 | 描述 | +| ---------- | ------ | ---- | --------------------------- | +| source | string | 是 | 组件模板名。 | +| bundleName | string | 是 | 提供者Ability的bundleName。 | + + +## PluginComponentManager + +### KVObject + +以键值对形式存储信息,符合json格式。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + + +| 取值范围 | 说明 | +| --------------------- | ---------------------------------------- | +| [key: string] | 关键字,数据类型为字符串,可取空字符串。 | +| number | 键值,表示值类型为数字。 | +| string | 键值,表示值类型为字符串,可取空字符串。 | +| boolean | 键值,表示值类型为布尔值。 | +| [] | 键值,可取值为[]。 | +| [KVObject](#kvobject) | 键值,表示值类型为KVObject。 | + + +### PushParameters + +用于设置FA模型下使用PluginManager.Push方法时候的需要传递的参数。 + +**模型约束:** 此接口仅适用于FA模型。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ----------------------------------- | ---- | -------------------------------------------------------------- | +| want | [Want](js-apis-application-want.md) | 是 | 组件使用者Ability信息。 | +| name | string | 是 | 组件名称。 | +| data | [KVObject](#kvobject) | 否 | 组件数据值。 | +| extraData | [KVObject](#kvobject) | 否 | 附加数据值。 | +| jsonPath | string | 否 | 存放模板路径的[external.json](#externaljson文件说明)件的路径。 | + +### PushParameterForStage + +用于设置Stage模型下使用PluginManager.Push方法时候的需要传递的参数。 + +**模型约束:** 此接口仅适用于Stage模型。 + +**系统接口:** 此接口为系统接口。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ----------------------------------- | ---- | ---------------------------------------------------------------- | +| owner | [Want](js-apis-application-want.md) | 是 | 组件提供方Ability信息。 | +| target | [Want](js-apis-application-want.md) | 是 | 组件使用者Ability信息。 | +| name | string | 是 | 组件名称。 | +| data | [KVObject](#kvobject) | 否 | 组件数据值。 | +| extraData | [KVObject](#kvobject) | 否 | 附加数据值。 | +| jsonPath | string | 否 | 存放模板路径的[external.json](#externaljson文件说明)文件的路径。 | + +### RequestParameters + +用于设置FA模型下使用PluginManager.Request方法时候的需要传递的参数。 + +**模型约束:** 此接口仅适用于FA模型。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------- | ---- | --------------------------------------------------------------------------------------------------------------------- | +| want | [Want](js-apis-application-want.md) | 是 | 组件提供者Ability信息。 | +| name | string | 是 | 请求组件名称。 | +| data | [KVObject](#kvobject) | 是 | 附加数据。 | +| jsonPath | string | 否 | 存放模板路径的[external.json](#externaljson文件说明)文件的路径。jsonPath字段不为空或者未设置的时候不触发Request通信。 | + +### RequestParameterForStage + +用于设置Stage模型下使用PluginManager.Request方法时候的需要传递的参数。 + +**系统接口:** 此接口为系统接口。 + +**模型约束:** 此接口仅适用于Stage模型。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------- | ---- | --------------------------------------------------------------------------------------------------------------------- | +| owner | [Want](js-apis-application-want.md) | 是 | 组件使用者Ability信息。 | +| target | [Want](js-apis-application-want.md) | 是 | 组件提供者Ability信息。 | +| name | string | 是 | 请求组件名称。 | +| data | [KVObject](#kvobject) | 是 | 附加数据。 | +| jsonPath | string | 否 | 存放模板路径的[external.json](#externaljson文件说明)文件的路径。jsonPath字段不为空或者未设置的时候不触发Request通信。 | + +### RequestCallbackParameters + +PluginManager.Request方法时候接收到的回调结果。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| ----------------- | ---------------------------------------------------- | ---- | ---------- | +| componentTemplate | [PluginComponentTemplate](#plugincomponenttemplate)] | 是 | 组件模板。 | +| data | [KVObject](#kvobject) | 是 | 组件数据。 | +| extraData | [KVObject](#kvobject) | 是 | 附加数据。 | + +### RequestEventResult + +注册Request监听方法后,接受到的请求事件时候回应请求的数据类型。 + +**系统能力:** SystemCapability.ArkUI.ArkUI.Full + +| 名称 | 类型 | 必填 | 说明 | +| --------- | --------------------- | ---- | ---------- | +| template | string | 否 | 组件模板。 | +| data | [KVObject](#kvobject) | 否 | 组件数据。 | +| extraData | [KVObject](#kvobject) | 否 | 附加数据。 | + +### OnPushEventCallback + +OnPushEventCallback = (source: Want, template: PluginComponentTemplate, data: KVObject, + extraData: KVObject) => void + +对应Push事件的监听回调函数。 + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| --------- | --------------------------------------------------- | ---- | ---------------------------------------- | +| source | [Want](js-apis-application-want.md) | 是 | Push请求发送方相关信息。 | +| template | [PluginComponentTemplate](#plugincomponenttemplate) | 是 | Push请求发送方相关信息请求组件模板名称。 | +| data | [KVObject](#kvobject) | 是 | 数据。 | +| extraData | [KVObject](#kvobject) | 是 | 附加数据。 | + +**示例:** + +```js +function onPushListener(source, template, data, extraData) { + console.log("onPushListener template.source=" + template.source) + console.log("onPushListener source=" + JSON.stringify(source)) + console.log("onPushListener template=" + JSON.stringify(template)) + console.log("onPushListener data=" + JSON.stringify(data)) + console.log("onPushListener extraData=" + JSON.stringify(extraData)) +} +``` + + +### OnRequestEventCallback + +OnRequestEventCallback = (source: Want, name: string, data: KVObject) => RequestEventResult + +对应request事件的监听回调函数。 + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| --------- | ----------------------------------- | ---- | --------------------------- | +| source | [Want](js-apis-application-want.md) | 是 | request请求发送方相关信息。 | +| data | [KVObject](#kvobject) | 是 | 数据。 | +| extraData | [KVObject](#kvobject) | 是 | 附加数据。 | + +**示例:** + +```js +function onRequestListener(source, name, data) +{ + console.error("onRequestListener"); + console.log("onRequestListener source=" + JSON.stringify(source)); + console.log("onRequestListener name=" + name); + console.log("onRequestListener data=" + JSON.stringify(data)); + + return {template:"ets/pages/plugin.js", data:data}; +} +``` + +### push + +push(param: PushParameters , callback: AsyncCallback<void>): void + +组件提供者向组件使用者主动发送组件与数据。 + +**模型约束:** 此接口仅适用于FA模型。 + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------- | ---- | ------------------------ | +| param | [PushParameters](#pushparameters) | 是 | 组件使用者的详细信息。 | +| callback | AsyncCallback<void> | 是 | 此次接口调用的异步回调。 | + +**示例:** + +```js +pluginComponentManager.push( +{ + want: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", + }, + name: "plugintemplate", + data: { + "key_1": "plugin component test", + "key_2": 34234 + }, + extraData: { + "extra_str": "this is push event" + }, + jsonPath: "", + }, + (err, data) => { + console.log("push_callback: push ok!"); + } +) +``` + +### push + +push(param: PushParameterForStage, callback: AsyncCallback<void>): void + +组件提供者向组件使用者主动发送组件与数据。 + +**系统接口:** 此接口为系统接口。 + +**模型约束:** 此接口仅适用于Stage模型。 + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | ------------------------ | +| param | [PushParameterForStage](#pushparameterforstage) | 是 | 组件使用者的详细信息。 | +| callback | AsyncCallback<void> | 是 | 此次接口调用的异步回调。 | + +**示例:** + +```js +pluginComponentManager.push( + { + owner:{ + bundleName:"com.example.provider", + abilityName:"com.example.provider.MainAbility" + }, + target: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", + }, + name: "ets/pages/plugin2.js", + data: { + "js": "ets/pages/plugin.js", + "key_1": 1111, , + }, + extraData: { + "extra_str": "this is push event" + }, + jsonPath: "", + }, + (err, data) => { + console.log("push_callback:err: " ,JSON.stringify(err)); + console.log("push_callback:data: " , JSON.stringify(data)); + console.log("push_callback: push ok!"); + } +) +``` + + +### request + +request(param: RequestParameters, callback: AsyncCallback<RequestCallbackParameters>): void + +组件使用者向组件提供者主动请求组件。 + +**模型约束:** 此接口仅适用于FA模型。 + + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------------------------------------------------- | ---- | ---------------------------------------------------------------- | +| param | [RequestParameters](#requestparameters) | 是 | 组件模板的详细请求信息。 | +| callback | AsyncCallback<[RequestCallbackParameters](#requestcallbackparameters) \| void> | 是 | 此次请求的异步回调, 通过回调接口的参数返回接受请求的数据。 | + +**示例:** + +```js +pluginComponentManager.request( + { + want: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", + }, + name: "plugintemplate", + data: { + "key_1": "plugin component test", + "key_2": 1111111 + }, + jsonPath: "", + }, + (err, data) => { + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + console.log("request_callback: data=" + JSON.stringify(data.data)) + console.log("request_callback: extraData=" + JSON.stringify(data.extraData)) + } +) +``` + + +### request + +request(param: RequestParameterForStage, callback: AsyncCallback<RequestCallbackParameters>): void + +组件使用者向组件提供者主动请求组件。 + +**系统接口:** 此接口为系统接口。 + +**模型约束:** 此接口仅适用于Stage模型。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------------------------------------------------- | ---- | ---------------------------------------------------------------- | +| param | [RequestParameterForStage](#requestparameterforstage) | 是 | 组件模板的详细请求信息。 | +| callback | AsyncCallback<[RequestCallbackParameters](#requestcallbackparameters) \| void> | 是 | 此次请求的异步回调, 通过回调接口的参数返回接受请求的数据。 | + +**示例:** + +```js +pluginComponentManager.request( + { + owner:{ + bundleName:"com.example.provider", + abilityName:"com.example.provider.MainAbility" + }, + target: { + bundleName: "com.example.provider", + abilityName: "ets/pages/plugin2.js", + }, + name: "plugintemplate", + data: { + "key_1": " myapplication plugin component test", + }, + jsonPath: "", + }, + (err, data) => { + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + } +) +``` + +### on + +on(eventType: string, callback: OnPushEventCallback | OnRequestEventCallback ): void + +提供者监听"request"类型的事件,给使用者返回通过request接口主动请求的数据;使用者监听"push"类型的事件,接收提供者通过push接口主动推送的数据。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ---------------------------------------------------------------------------------------------------------- | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| eventType | string | 是 | 监听的事件类型, 可选值为:"push" 、"request"。
"push”:指组件提供者向使用者主动推送数据。
"request”:指组件使用者向提供者主动请求数据。 | +| callback | [OnPushEventCallback](#onpusheventcallback) \| [OnRequestEventCallback](#onrequesteventcallback) | 是 | 对应监听回调,push事件对应回调类型为[OnPushEventCallback](#onpusheventcallback),request事件对应回调类型为[OnRequestEventCallback](#onrequesteventcallback) 。 | + + +**示例:** + +```js + pluginComponentManager.on("push", onPushListener) + pluginComponentManager.on("request", onRequestListener) +``` + +## external.json文件说明 + +external.json文件由开发者创建。external.json中以键值对形式存放组件名称以及对应模板路径。以组件名称name作为关键字,对应模板路径作为值。 + +**示例** + +```json +{ + "PluginProviderExample": "ets/pages/PluginProviderExample.js", + "plugintemplate2": "ets/pages/plugintemplate2.js" +} diff --git a/zh-cn/application-dev/reference/apis/js-apis-system-time.md b/zh-cn/application-dev/reference/apis/js-apis-system-time.md index bb21d6f388879054e23fd445a8a0c5510b7bbe97..04383c4b5596704dffda9318f89a357ac69cd565 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-system-time.md +++ b/zh-cn/application-dev/reference/apis/js-apis-system-time.md @@ -4,7 +4,8 @@ > **说明:** > -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> - 从API Version 9 开始,该模块接口不再维护,推荐使用新模块接口[@ohos.systemDateTime (系统时间、时区)](js-apis-system-date-time.md) +> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -107,10 +108,6 @@ getCurrentTime(isNano: boolean, callback: AsyncCallback<number>): void 获取自Unix纪元以来经过的时间,使用callback异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getCurrentTime](./js-apis-system-date-time.md#systemdatetimegetcurrenttime)替代。 - **系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -150,10 +147,6 @@ getCurrentTime(callback: AsyncCallback<number>): void 获取自Unix纪元以来经过的时间,使用callback异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getCurrentTime](./js-apis-system-date-time.md#systemdatetimegetcurrenttime-1)替代。 - **系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -192,10 +185,6 @@ getCurrentTime(isNano?: boolean): Promise<number> 获取自Unix纪元以来经过的时间,使用Promise异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getCurrentTime](./js-apis-system-date-time.md#systemdatetimegetcurrenttime-2)替代。 - **系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -238,10 +227,6 @@ getRealActiveTime(isNano: boolean, callback: AsyncCallback<number>): void 获取自系统启动以来经过的时间,不包括深度睡眠时间,使用callback异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getRealActiveTime](./js-apis-system-date-time.md#systemdatetimegetrealactivetime)替代。 - **系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -281,10 +266,6 @@ getRealActiveTime(callback: AsyncCallback<number>): void 获取自系统启动以来经过的时间,不包括深度睡眠时间,使用callback异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getRealActiveTime](./js-apis-system-date-time.md#systemdatetimegetrealactivetime-1)替代。 - **系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -323,10 +304,6 @@ getRealActiveTime(isNano?: boolean): Promise<number> 获取自系统启动以来经过的时间,不包括深度睡眠时间,使用Promise异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getRealActiveTime](./js-apis-system-date-time.md#systemdatetimegetrealactivetime-2)替代。 - **系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -369,10 +346,6 @@ getRealTime(isNano: boolean, callback: AsyncCallback<number>): void 获取自系统启动以来经过的时间,包括深度睡眠时间,使用callback异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getRealTime](./js-apis-system-date-time.md#systemdatetimegetrealtime)替代。 - **系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -412,10 +385,6 @@ getRealTime(callback: AsyncCallback<number>): void 获取自系统启动以来经过的时间,包括深度睡眠时间,使用callback异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getRealTime](./js-apis-system-date-time.md#systemdatetimegetrealtime-1)替代。 - **系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -454,10 +423,6 @@ getRealTime(isNano?: boolean): Promise<number> 获取自系统启动以来经过的时间,包括深度睡眠时间,使用Promise异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getRealTime](./js-apis-system-date-time.md#systemdatetimegetrealtime-2)替代。 - **系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -587,10 +552,6 @@ getDate(callback: AsyncCallback<Date>): void 获取当前系统日期,使用callback异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getDate](./js-apis-system-date-time.md#systemdatetimegetdate)替代。 - **系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -629,10 +590,6 @@ getDate(): Promise<Date> 获取当前系统日期,使用Promise异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getDate](./js-apis-system-date-time.md#systemdatetimegetdate-1)替代。 - **系统能力:** SystemCapability.MiscServices.Time **返回值:** @@ -754,10 +711,6 @@ getTimezone(callback: AsyncCallback<string>): void 获取系统时区,使用callback异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getTimezone](./js-apis-system-date-time.md#systemdatetimegettimezone)替代。 - **系统能力:** SystemCapability.MiscServices.Time **参数:** @@ -796,10 +749,6 @@ getTimezone(): Promise<string> 获取系统时区,使用Promise异步回调。 -> **说明:** -> -> 从 API Version 7 开始支持,从 API Version 9 开始废弃,建议使用[systemDateTime.getTimezone](./js-apis-system-date-time.md#systemdatetimegettimezone-1)替代。 - **系统能力:** SystemCapability.MiscServices.Time **返回值:** diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index 0029bbf9a4ecafdc4e11a482d3a681210a93fc84..14cfe634bc197af6fa0b272442e1722d2ca7d45d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -66,6 +66,9 @@ - [ImageAnimator](ts-basic-components-imageanimator.md) - [LoadingProgress](ts-basic-components-loadingprogress.md) - [Marquee](ts-basic-components-marquee.md) + - [Menu](ts-basic-components-menu.md) + - [MenuItem](ts-basic-components-menuitem.md) + - [MenuItemGroup](ts-basic-components-menuitemgroup.md) - [Navigation](ts-basic-components-navigation.md) - [NavRouter](ts-basic-components-navrouter.md) - [NavDestination](ts-basic-components-navdestination.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/borderImage.gif b/zh-cn/application-dev/reference/arkui-ts/figures/borderImage.gif new file mode 100644 index 0000000000000000000000000000000000000000..dd8d0f1a9f9a786de94abf348130c526ecb09641 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/borderImage.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/figures/menu1.png b/zh-cn/application-dev/reference/arkui-ts/figures/menu1.png new file mode 100644 index 0000000000000000000000000000000000000000..e4e90982652f27353f43ce7e596a512d31141f6c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-ts/figures/menu1.png differ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menu.md new file mode 100644 index 0000000000000000000000000000000000000000..3bcdbdb380cffb2e6fa4f3c0f554600270e4d671 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menu.md @@ -0,0 +1,95 @@ +# Menu + +以垂直列表形式显示的菜单,优先用于PC端的菜单开发。 + +> **说明:** +> +> 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +## 子组件 + +包含[MenuItem](ts-basic-components-menuitem.md)、[MenuItemGroup](ts-basic-components-menuitemgroup.md)子组件。 + +## 接口 + +Menu() + +作为菜单的固定容器,无参数。 + +## 属性 + +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + +| 名称 | 参数类型 | 描述 | +| -------- | ------------------------- | ---------------------------------------------------------------- | +| fontSize | [Length](ts-types.md#length) | 统一设置Menu中所有文本的尺寸,Length为number类型时,使用fp单位。 | + +## 示例 + +```ts +@Entry +@Component +struct Index { + @State select: boolean = true + private iconStr: ResourceStr = $r("app.media.view_list_filled") + private iconStr2: ResourceStr = $r("app.media.view_list_filled") + + @Builder + SubMenu() { + Menu() { + MenuItem({ content: "复制", labelInfo: "Ctrl+C" }) + MenuItem({ content: "粘贴", labelInfo: "Ctrl+V" }) + } + } + + @Builder + MyMenu(){ + Menu() { + MenuItem({ startIcon: $r("app.media.icon"), content: "菜单选项" }) + MenuItem({ startIcon: $r("app.media.icon"), content: "菜单选项" }) + .enabled(false) + MenuItem({ + startIcon: this.iconStr, + content: "菜单选项", + endIcon: $r("app.media.arrow_right_filled"), + builder: this.SubMenu.bind(this) + }) + MenuItemGroup({ header: '小标题' }) { + MenuItem({ content: "菜单选项" }) + .selectIcon(true) + .selected(this.select) + .onChange((selected) => { + console.info("menuItem select" + selected); + this.iconStr2 = $r("app.media.icon"); + }) + MenuItem({ + startIcon: $r("app.media.view_list_filled"), + content: "菜单选项", + endIcon: $r("app.media.arrow_right_filled"), + builder: this.SubMenu.bind(this) + }) + } + MenuItem({ + startIcon: this.iconStr2, + content: "菜单选项", + endIcon: $r("app.media.arrow_right_filled") + }) + } + } + + build() { + Row() { + Column() { + Text('click to show menu') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .bindMenu(this.MyMenu) + .width('100%') + } + .height('100%') + } +} +``` + +![menu1](figures/menu1.png) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menuitem.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menuitem.md new file mode 100644 index 0000000000000000000000000000000000000000..038af44a42a7ffbdc5fd9688be54b1fc0782c78d --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menuitem.md @@ -0,0 +1,50 @@ +# MenuItem + +用来展示菜单Menu中具体的item菜单项。 + +> **说明:** +> +> 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +## 子组件 + +无 + +## 接口 + +MenuItem(value?: MenuItemOptions| CustomBuilder) + +**参数:** + +| 参数 | 类型 | 必填 | 参数描述 | +| ----- | ----------------------------------------------------------------------------------------------------------------------------- | ---- | ---------------------------- | +| value | [MenuItemOptions](ts-basic-components-menuitem.md#menuitemoptions类型说明) \| [CustomBuilder](ts-types.md#custombuilder8) | 否 | 包含设置MenuItem的各项信息。 | + +## MenuItemOptions类型说明 + +| 名称 | 类型 | 必填 | 描述 | +| --------- | ---------------------------------------- | ---- | -------------------------------------- | +| startIcon | [ResourceStr](ts-types.md#resourcestr) | 否 | item中显示在左侧的图标信息路径。 | +| content | [ResourceStr](ts-types.md#resourcestr) | 是 | item的内容信息。 | +| endIcon | [ResourceStr](ts-types.md#resourcestr) | 否 | item中显示在右侧的图标信息路径。 | +| labelInfo | [ResourceStr](ts-types.md#resourcestr) | 否 | 定义结束标签信息,如快捷方式Ctrl+C等。 | +| builder | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 用于构建二级菜单。 | + +## 属性 + +除支持[通用属性](ts-universal-attributes-size.md)外,还支持以下属性: + +| 名称 | 参数类型 | 描述 | +| ---------- | -------- | ---------------------------------------- | +| selected | boolean | 设置菜单项是否选中。
默认值:false | +| selectIcon | boolean | 当菜单项被选中时,是否显示被选中的图标。 | + +## 事件 + +| 名称 | 参数类型 | 描述 | +| -------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| onChange | (selected: boolean) => void | 当选中状态发生变化时,触发该回调。只有手动触发且MenuItem状态改变时才会触发onChange回调。
- value为true时,表示已选中。
- value为false时,表示未选中。 | + +## 示例 + +详见[Menu组件示例](ts-basic-components-menu.md#示例)。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menuitemgroup.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menuitemgroup.md new file mode 100644 index 0000000000000000000000000000000000000000..2e864b99d78bf349a946310d8e7c3e0714e12086 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-menuitemgroup.md @@ -0,0 +1,32 @@ +# MenuItemGroup + +该组件用来展示菜单MenuItem的分组。 + +> **说明:** +> +> 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +## 子组件 + +包含[MenuItem](ts-basic-components-menuitem.md)子组件。 + +## 接口 + +MenuItemGroup(value?: MenuItemGroupOptions) + +**参数:** + +| 参数 | 类型 | 必填 | 参数描述 | +| ----- | -------------------------------------------------------------------------------------- | ---- | ------------------------------------------- | +| value | [MenuItemGroupOptions](ts-basic-components-menuitemgroup.md#menuitemgroupoptions类型说明) | 否 | 包含设置MenuItemGroup的标题和尾部显示信息。 | + +## MenuItemGroupOptions类型说明 + +| 名称 | 类型 | 必填 | 描述 | +| ------ | ----------------------------------------------------------------------------------------- | ---- | ----------------------------- | +| header | [ResourceStr](ts-types.md#resourcestr) \| [CustomBuilder](ts-types.md#custombuilder8) | 否 | 设置对应group的标题显示信息。 | +| footer | [ResourceStr](ts-types.md#resourcestr) \| [CustomBuilder](ts-types.md#custombuilder8) | 否 | 设置对应group的尾部显示信息。 | + +## 示例 + +详见[Menu组件示例](ts-basic-components-menu.md#示例)。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md index 6e28c15b09dd53348449554f9ed8352621b1ea1d..0bad69d7c539028e0e165cc3e16a27ca93575876 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md @@ -1,14 +1,11 @@ # PluginComponent -提供外部应用组件嵌入式显示功能,即外部应用提供的UI可在本应用内显示。 +提供外部应用组件嵌入式显示功能,即外部应用提供的UI可在本应用内显示。如需通过跨进程通信实现更新,请参考[@ohos.pluginComponent](../apis/js-apis-plugincomponent.md)。 > **说明:** > > - 该组件从API Version 9开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -> -> - 本组件为系统接口。 - ## 子组件 @@ -23,155 +20,30 @@ PluginComponent(value: { template: PluginComponentTemplate, data: KVObject}) **参数:** -| 参数名 | 参数类型 | 必填 | 参数描述 | -| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| value | {
template: PluginComponentTemplate,
data: KVObject
} | 是 | template:  组件模板,用于跟提供者定义的组件绑定。
data: 传给插件组件提供者使用的数据。 | +| 参数名 | 参数类型 | 必填 | 参数描述 | +| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- | --------------------------------------------------------------------------------------------------------- | +| value | {
template:  [PluginComponentTemplate](#plugincomponenttemplate类型说明),
data: [KVObject](../apis/js-apis-plugincomponent.md#kvobject)
} | 是 | template:  组件模板,用于跟提供者定义的组件绑定。
data: 传给插件组件提供者使用的数据。 | ## PluginComponentTemplate类型说明 -| 参数 | 类型 | 描述 | -| ------- | ------ | ----------------------- | -| source | string | 组件模板名。 | -| ability | string | 提供者Ability的abilityname。 | +| 参数 | 类型 | 描述 | +| ---------- | ------ | --------------------------- | +| source | string | 组件模板名。 | +| bundleName | string | 提供者Ability的bundleName。 | ## 事件 -| 名称 | 功能描述 | -| ---------------------------------------- | ---------------------------------------- | -| onComplete(callback: () => void) | 组件加载完成回调。 | +| 名称 | 功能描述 | +| ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| onComplete(callback: () => void) | 组件加载完成回调。 | | onError(callback: (info: { errcode: number, msg: string }) => void) | 组件加载错误回调。
errcode: 错误码。
msg: 错误信息。 | - -## PluginComponentManager - -提供配套插件组件使用的相关接口,用于给插件组件的使用者请求组件与数据,使用者发送组件模板和数据。 - - -## 导入模块 - - -``` -import pluginComponentManager from '@ohos.plugincomponent' -``` - - -## push - -push(param: PushParameters, callback: AsyncCallback<void>): void - -组件提供者向组件使用者主动发送组件与数据。 - -**参数** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------- | ---- | -------------------------------- | -| param | PushParameters | 是 | 组件使用者的详细信息,详见PushParameters参数说明。 | -| callback | AsyncCallback<void> | 是 | 此次接口调用的异步回调。 | - -**PushParameters参数说明** - -| 参数名 | 类型 | 必填 | 说明 | -| --------- | -------- | ---- | --------------- | -| want | Want | 是 | 组件使用者Ability信息。 | -| name | string | 是 | 组件名称。 | -| data | KVObject | 否 | 组件数据值。 | -| extraData | KVObject | 否 | 附加数据值。 | -| jsonPath | string | 否 | 存放模板路径的external.json文件的路径。 | - -**示例** - -见[Plugin组件提供方](#组件提供方)示例。 - - -## request - -request(param: RequestParameters, callback: AsyncCallback<RequestCallbackParameters>): void - -组件使用者向组件提供者主动请求组件。 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ------------------------------------ | -| param | RequestParameters | 是 | 组件模板的详细请求信息,详见RequestParameters参数说明。 | -| callback | AsyncCallback"push”:指组件提供者向使用者主动推送数据。
"request”:指组件使用者向提供者主动请求数据。 | -| callback | OnPushEventCallback \| OnRequestEventCallback | 是 | 见callback事件说明。 | - -**callback事件说明** - -| 参数名 | 类型 | 说明 | -| ---------------------- | ---------------------------------------- | ---------------------------------------- | -| OnRequestEventCallback | (source: Want,
name: string,
data: KVObject ) =>RequestEventResult | 数据请求事件的回调。
source: 组件请求方Ability信息。
name: 请求组件名称。
data: 附加数据。
返回值: 请求数据结果。 | -| OnPushEventCallback | (source: Want,
template: PluginComponentTemplate,
data: KVObject,
extraData: KVObject
) => void | 接收提供者主动推送的数据。
source: 组件提供者Ability信息。
template: 组件模板。
data: 组件更新数据。
extraData: 附加数据。 | - -**RequestEventResult类型说明** - -| 参数 | 类型 | 说明 | -| --------- | -------- | ---------- | -| template | string | 组件名称。 | -| data | KVObject | 组件数据。 | -| extraData | KVObject | 附加数据。 | - -**示例** - -见[Plugin组件工具](#plugin组件工具)示例。 - -**KVObject类型说明** - -| 参数 | 类型 | 说明 | -| ---- | ---------------------------------------- | ---------------------------------------- | -| key | number \| string \| boolean \| Array \| KVObject | KVObject用[key,value]来存储数据,key是string类型的,value可以是number,string,boolean,数组或者另外的一个KVObject。 | - - -**external.json文件说明** - -external.json文件由开发者创建。external.json中以键值对形式存放组件名称以及对应模板路径。以组件名称name作为关键字,对应模板路径作为值。 - -**示例** - -见[external.json](#externaljson)示例。 - ## 示例 ### 组件使用方 - ```ts //PluginUserExample.ets import plugin from "plugin_component.js" @@ -180,9 +52,9 @@ import plugin from "plugin_component.js" @Component struct PluginUserExample { @StorageLink("plugincount") plugincount: Object[] = [ - { source: 'plugincomponent1', ability: 'com.example.plugin' }, - { source: 'plugintemplate', ability: 'com.example.myapplication' }, - { source: 'plugintemplate', ability: 'com.example.myapplication' }] + { source: 'plugincomponent1', bundleName: 'com.example.plugin' }, + { source: 'plugintemplate', bundleName: 'com.example.myapplication' }, + { source: 'plugintemplate', bundleName: 'com.example.myapplication' }] build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { @@ -209,7 +81,7 @@ struct PluginUserExample { }) ForEach(this.plugincount, item => { PluginComponent({ - template: { source: 'plugincomponent1', ability: 'com.example.plugin' }, + template: { source: 'PluginProviderExample', bundleName: 'com.example.plugin' }, data: { 'countDownStartValue': 'new countDownStartValue' } }).size({ width: 500, height: 100 }) .onComplete(() => { @@ -270,7 +142,7 @@ struct PluginProviderExample { ### Plugin组件工具 - +#### FA模型 ```js //plugin_component.js import pluginComponentManager from '@ohos.pluginComponent' @@ -308,10 +180,10 @@ export default { pluginComponentManager.push( { want: { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", + bundleName: "com.example.plugin", + abilityName: "com.example.myapplication.PluginProviderExample", }, - name: "plugintemplate", + name: "PluginProviderExample", data: { "key_1": "plugin component test", "key_2": 34234 @@ -330,10 +202,10 @@ export default { // 组件使用方主动发送事件 pluginComponentManager.request({ want: { - bundleName: "com.example.myapplication", - abilityName: "com.example.myapplication.MainAbility", + bundleName: "com.example.plugin", + abilityName: "com.example.myapplication.PluginProviderExample", }, - name: "plugintemplate", + name: "PluginProviderExample", data: { "key_1": "plugin component test", "key_2": 34234 @@ -358,10 +230,98 @@ export default { } ``` +#### Stage模型 +```js +//plugin_component.js +import pluginComponentManager from '@ohos.pluginComponent' + +function onPushListener(source, template, data, extraData) { + console.log("onPushListener template.source=" + template.source) + var jsonObject = JSON.parse(data.componentTemplate.source) + console.log("request_callback1:source json object" + jsonObject) + var jsonArry = jsonObject.ExternalComponent + for (var i in jsonArry) { + console.log(jsonArry[i]) + } + console.log("onPushListener:source json object" + jsonObject) + console.log("onPushListener:source json string" + JSON.stringify(jsonObject)) + console.log("onPushListener template.ability=" + template.ability) + console.log("onPushListener data=" + JSON.stringify(data)) + console.log("onPushListener extraData=" + JSON.stringify(extraData)) +} -### external.json -```json +function onRequestListener(source, name, data) { - "plugintemplate": "ets/pages/plugintemplate.js", - "plugintemplate2": "ets/pages/plugintemplate2.js" + console.log("onRequestListener name=" + name); + console.log("onRequestListener data=" + JSON.stringify(data)); + return {template:"plugintemplate", data:data}; +} + +export default { + //register listener + onListener() { + pluginComponentManager.on("push", onPushListener) + pluginComponentManager.on("request", onRequestListener) + }, + Push() { + // 组件提供方主动发送事件 + pluginComponentManager.push( + { + owner: { + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility", + }, + target: { + bundleName: "com.example.plugin", + abilityName: "com.example.myapplication.PluginProviderExample", + }, + name: "PluginProviderExample", + data: { + "key_1": "plugin component test", + "key_2": 34234 + }, + extraData: { + "extra_str": "this is push event" + }, + jsonPath: "", + }, + (err, data) => { + console.log("push_callback: push ok!"); + } + ) + }, + Request() { + // 组件使用方主动发送事件 + pluginComponentManager.request({ + owner: { + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility", + }, + target: { + bundleName: "com.example.plugin", + abilityName: "com.example.myapplication.PluginProviderExample", + }, + name: "PluginProviderExample", + data: { + "key_1": "plugin component test", + "key_2": 34234 + }, + jsonPath: "", + }, + (err, data) => { + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + var jsonObject = JSON.parse(data.componentTemplate.source) + console.log("request_callback:source json object" + jsonObject) + var jsonArry = jsonObject.ExternalComponent + for (var i in jsonArry) { + console.log(jsonArry[i]) + } + console.log("request_callback:source json string" + JSON.stringify(jsonObject)) + console.log("request_callback: data=" + JSON.stringify(data.data)) + console.log("request_callback: extraData=" + JSON.stringify(data.extraData)) + } + ) + } } +``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md index 825da4ef822e132555972061b29a983a3e8d58f4..ab4d9d7023f1df2500ceaeaadfd592127967c68f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md @@ -25,7 +25,7 @@ Select(options: Array\<[SelectOption](#selectoption对象说明)\>) | 名称 | 参数类型 | 描述 | | ----------------------- | ------------------------------------- | --------------------------------------------- | -| selected | number | 设置下拉菜单初始选项的索引,第一项的索引为0。 | +| selected | number | 设置下拉菜单初始选项的索引,第一项的索引为0。
当不设置selected属性时,默认选择值为-1,菜单项不选中。 | | value | string | 设置下拉按钮本身的文本内容。 | | font | [Font](ts-types.md#font) | 设置下拉按钮本身的文本样式。 | | fontColor | [ResourceColor](ts-types.md#resourcecolor) | 设置下拉按钮本身的文本颜色。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md b/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md index 26d9859e7d7c42952f58f5857d52bff459f64648..5787e7fe8af42b5d5875d8dd59466cc40d602c78 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-components-summary.md @@ -284,4 +284,13 @@ 远程控制窗口组件,可以通过此组件控制应用窗口,提供启动退出过程中控件动画和应用窗口联动动画的能力。 - [Formcomponent](ts-basic-components-formcomponent.md) - 提供卡片组件,实现卡片的显示功能。 \ No newline at end of file + 提供卡片组件,实现卡片的显示功能。 +- [Menu](ts-basic-components-menu.md) + + 以垂直列表形式显示的菜单,优先用于PC端的菜单开发。 +- [MenuItem](ts-basic-components-menuitem.md) + + 用来展示菜单Menu中具体的item菜单项。 +- [MenuItemGroup](ts-basic-components-menuitemgroup.md) + + 用来展示菜单MenuItem的分组。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index c9550fbd7355c8f35bd790f7619793f73b1f1388..4b07b23b9d2ad75935b4be658d06933374a11722 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -11,7 +11,7 @@ ## 接口 -CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, autoCancel?: boolean, alignment?: DialogAlignment, offset?: Offset, customStyle?: boolean, gridCount?: number}) +CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, autoCancel?: boolean, alignment?: DialogAlignment, offset?: Offset, customStyle?: boolean, gridCount?: number, maskColor?: ResourceColor, openAnimation?: AnimateParam, closeAniamtion?: AnimateParam}) **参数:** @@ -25,7 +25,9 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, aut | offset | [Offset](ts-types.md#offset) | 否 | 弹窗相对alignment所在位置的偏移量。 | | customStyle | boolean | 否 | 弹窗容器样式是否自定义。
默认值:false,弹窗容器的宽度根据栅格系统自适应,不跟随子节点;高度自适应子节点,最大为窗口高度的90%;圆角为24vp。 | | gridCount8+ | number | 否 | 弹窗宽度占[栅格宽度](../../ui/ui-ts-layout-grid-container-new.md)的个数。
默认值为4,异常值按默认值处理,最大栅格数为系统最大栅格数。 | - +| maskColor10+ | [ResourceColor](ts-types.md#resourcecolor) | 否 | 自定义蒙层颜色。
默认值: 0x33000000 | +| openAnimation10+ | [AnimateParam](ts-explicit-animation.md#animateparam对象说明) | 否 | 自定义设置弹窗弹出的动画效果相关参数。 | +| closeAniamtion10+| [AnimateParam](ts-explicit-animation.md#animateparam对象说明) | 否 | 自定义设置弹窗关闭的动画效果相关参数。 | ## CustomDialogController diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md index 2ce59a0349c7729a2e8c86b4913906f0ab5adb4f..b41a408db85dccf042901b5dedcee65367dc18cd 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md @@ -1,6 +1,6 @@ # 图片边框设置 -设置组件图片边框样式。 +设置容器组件的图片边框样式。 > **说明:** > @@ -16,7 +16,7 @@ | 名称 | 类型 | 描述 | | ---------- | ---------------------------------------- | --------------------------------------- | -| source | string \| [Resource](ts-types.md#resource) \| [linearGradient](ts-universal-attributes-gradient-color.md) | 边框图源或者渐变色设置。 | +| source | string \| [Resource](ts-types.md#resource) \| [linearGradient](ts-universal-attributes-gradient-color.md) | 边框图源或者渐变色设置。
**说明:** 边框图源仅适用于容器组件,如Row、Column、Flex,在非容器组件上使用会失效。 | | slice | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | 设置图片边框切割宽度。
默认值:0 | | width | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | 设置图片边框宽度。
默认值:0 | | outset | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | 设置边框图片向外延伸距离。
默认值:0 | @@ -33,9 +33,10 @@ | Round | 被切割图片以整数次平铺在图片边框上,无法以整数次平铺时压缩被切割图片。 | | Space | 被切割图片以整数次平铺在图片边框上,无法以整数次平铺时以空白填充。 | - ## 示例 +### 示例1 + ```ts // xxx.ets @@ -66,3 +67,48 @@ struct Index { ``` ![zh-cn_image_borderImageGradient](figures/borderImageGradient.png) + +### 示例2 + +```ts +// xxx.ets +@Entry +@Component +struct Index { + @State outSetValue: number = 40 + + build() { + Row() { + Column() { + Row() { + Text('This is borderImage.').textAlign(TextAlign.Center).fontSize(50) + } + .borderImage({ + source: $r('app.media.icon'), + slice: `${this.outSetValue}%`, + width: `${this.outSetValue}px`, + outset: '5px', + repeat: RepeatMode.Repeat, + fill: false + }) + + Slider({ + value: this.outSetValue, + min: 0, + max: 100, + style: SliderStyle.OutSet + }) + .margin({ top: 30 }) + .onChange((value: number, mode: SliderChangeMode) => { + this.outSetValue = value + console.info('value:' + value + 'mode:' + mode.toString()) + }) + } + .width('100%') + } + .height('100%') + } +} +``` + +![zh-cn_image_borderImage](figures/borderImage.gif) \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md index 1883fcc9579703540203e7034d6d8005fe9df258..e0fa17c2e61bab1acc534cb900ab81883deaba8b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md @@ -12,7 +12,7 @@ | 名称 | 参数类型 | 描述 | | ------- | ---------------------------------------- | ---------------------------------------- | -| opacity | number \| [Resource](ts-types.md#resource) | 元素的不透明度,取值范围为0到1,1表示不透明,0表示完全透明, 达到隐藏组件效果,但是在布局中占位。
**说明:**
子组件可以继承父组件的此属性。默认值:1 | +| opacity | number \| [Resource](ts-types.md#resource) | 元素的不透明度,取值范围为0到1,1表示不透明,0表示完全透明, 达到隐藏组件效果,但是在布局中占位。 默认值:1
**说明:**
子组件会继承父组件的透明度,并与自身的透明度属性叠加。如:父组件透明度为0.1,子组件设置透明度为0.8,则子组件实际透明度为0.1*0.8=0.08。| ## 示例 diff --git a/zh-cn/application-dev/security/permission-list.md b/zh-cn/application-dev/security/permission-list.md index b5d547e02bc45bdbbdc33c159cbd5b91328399d8..3e2247ad01f9f9ca35d6a58e21014a612c8eab99 100644 --- a/zh-cn/application-dev/security/permission-list.md +++ b/zh-cn/application-dev/security/permission-list.md @@ -1498,6 +1498,26 @@ **ACL使能**:TRUE +## ohos.permission.READ_APP_PUSH_DATA + +允许推送服务读取应用中推送服务存储的数据。 + +**权限级别**:system_basic + +**授权方式**:system_grant + +**ACL使能**:FALSE + +## ohos.permission.WRITE_APP_PUSH_DATA + +允许推送服务往应用中写入数据。 + +**权限级别**:system_basic + +**授权方式**:system_grant + +**ACL使能**:FALSE + ## ohos.permission.RECEIVER_STARTUP_COMPLETED 允许应用订阅开机广播。 @@ -1666,4 +1686,24 @@ **授权方式**:system_grant -**ACL使能**:FALSE \ No newline at end of file +**ACL使能**:FALSE + +## ohos.permission.PRINT + +允许应用获取打印框架的能力。 + +**权限级别**:normal + +**授权方式**:system_grant + +**ACL使能**:TRUE + +## ohos.permission.MANAGE_PRINT_JOB + +允许应用获取管理打印任务的能力。 + +**权限级别**:system_basic + +**授权方式**:system_grant + +**ACL使能**:TRUE \ No newline at end of file diff --git a/zh-cn/device-dev/subsystems/subsys-security-huks-guide.md b/zh-cn/device-dev/subsystems/subsys-security-huks-guide.md index 009a4989cccc4f494f5f4a51cec730b07abb8d22..e019d626238f9516e78fc512228e79b7facdd9ff 100644 --- a/zh-cn/device-dev/subsystems/subsys-security-huks-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-security-huks-guide.md @@ -83,6 +83,7 @@ HUKS Core作为向应用提供密钥库能力的基础,包括密钥管理及 | [HuksHdiAbort()](#hukshdiabort) | 终止三段式。 |无 | abort(handle: number, options: HuksOptions) | | [HuksHdiGetKeyProperties()](#hukshdigetkeyproperties) | 获取密钥属性。 |无 | getKeyProperties(keyAlias: string, options: HuksOptions)| | [HuksHdiAttestKey()](#hukshdiattestkey) | 获取密钥证书。 |出参要遵循certChain格式 | attestKey(keyAlias: string, options: HuksOptions)| +| [HuksHdiExportChipsetPlatformPublicKey()](#hukshdiexportchipsetplatformpublickey) | 导出芯片平台级密钥对的公钥。 | 出参为ECC P256的x y轴值裸数据,各32字节 | 无 | - - - @@ -558,6 +559,49 @@ HUKS Core的初始化,包括锁,加密算法库,authtoken key和根密钥 - - - +#### HuksHdiExportChipsetPlatformPublicKey + +**接口描述** + +导出芯片平台级密钥对的公钥。 + +**接口原型** +
int32_t (*HuksHdiExportChipsetPlatformPublicKey)(const struct HksBlob *salt, enum HksChipsetPlatformDecryptScene scene, struct HksBlob *publicKey);
+ +
+ 参数说明 +
+  const struct HksBlob *salt
+  用来派生芯片平台密钥对时的派生因子
+  

+ enum HksChipsetPlatformDecryptScene scene + 业务预期进行芯片平台解密的场景 +

+ struct HksBlob *publicKey + 出参为ECC P256的x y轴值裸数据,各32字节 +
+
+

+ +
+ 约束与限制 + + 1. 入参`salt`长度必须为16字节,且最后一个字节的内容会被忽略,将由huks内部根据入参`scene`进行修改填充。
+ 当前huks的芯片平台级密钥对为软实现,硬编码了一对ECC-P256密钥对到代码中,`salt`值被忽略,即无论传入什么`salt`,派生出的密钥都是一样的。在真正基于硬件的芯片平台级密钥实现中,`salt`为用来派生密钥的派生因子,传入不同的`salt`会得到不同的密钥对。 + +
+

+ +
+ 返回值 + + - HKS_SUCCESS:成功 + + - 其他:失败 +
+ +- - - + ### 开发步骤 HDI接口到HUKS Core的适配在以下目录中: diff --git a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-arkui.md b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-arkui.md index 1dbe17d99b7290362d3982cc6834c753c9281e9a..2b4e4e962d2c7a877c35db4ff04dad7f9b3f2ccc 100644 --- a/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-arkui.md +++ b/zh-cn/release-notes/changelogs/OpenHarmony_3.2.10.7/changelogs-arkui.md @@ -1,39 +1,306 @@ -# arkui子系统ChangeLog - -## cl.arkui.1 getInspectorTree接口返回值从string修改为Object。 - -**变更影响** - -3.2.10.7之前使用getInspectorTree接口的代码需要适配 - -**关键的接口/组件变更** - -getInspectorTree接口返回值从string修改为Object - -**适配指导** - -将getInspectorTree返回值作为string使用的代码需要修改,比如以下示例代码: - -```typescript -console.info(getInspectorTree()) -``` - -需要修改成 - -```typescript -console.info(JSON.stringify(getInspectorTree())) -``` - -## cl.arkui.2 废弃GridItem的forceRebuild属性 - -**变更影响** - -无,该属性无作用 - -**关键的接口/组件变更** - -GridItem的forceRebuild属性废弃 - -**适配指导** - -如有使用可以直接删除,不影响GridItem功能 +# arkui子系统ChangeLog + +## cl.arkui.1 getInspectorTree接口返回值从string修改为Object。 + +**变更影响** + +3.2.10.7之前使用getInspectorTree接口的代码需要适配 + +**关键的接口/组件变更** + +getInspectorTree接口返回值从string修改为Object + +**适配指导** + +将getInspectorTree返回值作为string使用的代码需要修改,比如以下示例代码: + +```typescript +console.info(getInspectorTree()) +``` + +需要修改成 + +```typescript +console.info(JSON.stringify(getInspectorTree())) +``` + +## cl.arkui.2 废弃GridItem的forceRebuild属性 + +**变更影响** + +无,该属性无作用 + +**关键的接口/组件变更** + +GridItem的forceRebuild属性废弃 + +**适配指导** + +如有使用可以直接删除,不影响GridItem功能 + +## cl.arkui.3 Plugin模块接口变更 + + +### 1. arkui子系统Plugin模块 `PluginComponentTemplate` 接口存在变更: + +ability命名无法准确表达对应参数的语义,修改为bundleName。 + +开发者需要根据以下说明对应用进行适配。 + + + +**变更影响** + +基于此前版本开发的应用,需适配变更接口,变更前的接口已经不能正常使用,会在编译过程中报错。 + + + +**关键的接口/组件变更** + +- 涉及接口 + + interface PluginComponentTemplate { + source: string; + bundleName: string; + } + + interface PluginComponentInterface { + (value: { template: PluginComponentTemplate; data: any }): PluginComponentAttribute; +} + +- 变更前: + +```js + interface PluginComponentTemplate { source: string; ability: string; } + interface PluginComponentInterface { + (value: { template: PluginComponentTemplate; data: any }): PluginComponentAttribute; + } +``` + +- 变更后: + +```js + interface PluginComponentTemplate { source: string; bundleName: string; } + interface PluginComponentInterface { + (value: { template: PluginComponentTemplate; data: any }): PluginComponentAttribute; + } +``` + +**适配指导** + +使用变更后的接口,示例代码如下: + +- 变更前: +```js +PluginComponent({ + template: { source: 'plugincomponent1', ability: 'com.example.plugin' }, + data: { 'countDownStartValue': 'new countDownStartValue' } +}).size({ width: 500, height: 100 }) +``` + +- 变更后: +```js +PluginComponent({ + template: { source: 'plugincomponent1', bundleName: 'com.example.plugin' }, + data: { 'countDownStartValue': 'new countDownStartValue' } +}).size({ width: 500, height: 100 }) +``` + +### 2. arkui子系统Plugin模块 `pluginComponentManager` 接口存在变更: + +want命名无法准确表达对应参数的语义,修改为target。 + +开发者需要根据以下说明对应用进行适配。 + + + +**变更影响** + +基于此前版本开发的应用,需适配变更接口。变更前的接口会出现告警,虽然可以通过编译,但是已经不能正常使用其功能。 + + + +**关键的接口/组件变更** + +- 涉及接口 + + interface PushParameterForStage { + owner: Want; + target: Want; + name: string; + data: KVObject; + extraData: KVObject; + jsonPath?: string; + } + + function push(param: PushParameterForStage, callback: AsyncCallback): void; + + interface RequestParameterForStage { + owner: Want; + target: Want; + name: string; + data: KVObject; + jsonPath?: string; + } + + function request(param: RequestParameterForStage, callback: AsyncCallback): void; + +- 变更前: + +```js + interface PushParameterForStage { + owner: Want; + want: Want; + name: string; + data: KVObject; + extraData: KVObject; + jsonPath?: string; + } + + function push(param: PushParameterForStage, callback: AsyncCallback): void; + + interface RequestParameterForStage { + owner: Want; + want: Want; + name: string; + data: KVObject; + jsonPath?: string; + } + + function request(param: RequestParameterForStage, callback: AsyncCallback): void; +``` + +- 变更后: + +```js + interface PushParameterForStage { + owner: Want; + target: Want; + name: string; + data: KVObject; + extraData: KVObject; + jsonPath?: string; + } + + function push(param: PushParameterForStage, callback: AsyncCallback): void; + + interface RequestParameterForStage { + owner: Want; + target: Want; + name: string; + data: KVObject; + jsonPath?: string; + } + + function request(param: RequestParameterForStage, callback: AsyncCallback): void; +``` + +**适配指导** + +使用变更后的接口,示例代码如下: + +- 变更前: +```js +import pluginComponentManager from '@ohos.pluginComponent' + +pluginComponentManager.push({ + owner:{ + bundleName:"com.example.provider", + abilityName:"com.example.provider.MainAbility" + }, + want: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", + }, + name: "ets/pages/plugin2.js", + data: { + "js": "ets/pages/plugin.js", + "key_1": 1111, + }, + extraData: { + "extra_str": "this is push event" + }, + jsonPath: "", + }, + (err, data) => { + console.log("push_callback:err: " ,JSON.stringify(err)); + console.log("push_callback:data: " , JSON.stringify(data)); + console.log("push_callback: push ok!"); + } +) + +pluginComponentManager.request({ + owner:{ + bundleName:"com.example.provider", + abilityName:"com.example.provider.MainAbility" + }, + want: { + bundleName: "com.example.provider", + abilityName: "ets/pages/plugin2.js", + }, + name: "plugintemplate", + data: { + "key_1": " myapplication plugin component test", + "key_2": 123456 + }, + jsonPath: "", +}, + (err, data) => { + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + } +) +``` + +- 变更后: +```js +import pluginComponentManager from '@ohos.pluginComponent' + +pluginComponentManager.push({ + owner:{ + bundleName:"com.example.provider", + abilityName:"com.example.provider.MainAbility" + }, + target: { + bundleName: "com.example.provider", + abilityName: "com.example.provider.MainAbility", + }, + name: "ets/pages/plugin2.js", + data: { + "js": "ets/pages/plugin.js", + "key_1": 1111, + }, + extraData: { + "extra_str": "this is push event" + }, + jsonPath: "", + }, + (err, data) => { + console.log("push_callback:err: " ,JSON.stringify(err)); + console.log("push_callback:data: " , JSON.stringify(data)); + console.log("push_callback: push ok!"); + } +) + +pluginComponentManager.request({ + owner:{ + bundleName:"com.example.provider", + abilityName:"com.example.provider.MainAbility" + }, + target: { + bundleName: "com.example.provider", + abilityName: "ets/pages/plugin2.js", + }, + name: "plugintemplate", + data: { + "key_1": " myapplication plugin component test", + "key_2": 123456 + }, + jsonPath: "", +}, + (err, data) => { + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + } +) +```