提交 5ce561f3 编写于 作者: Z zengyawen

update docs

Signed-off-by: Nzengyawen <zengyawen1@huawei.com>
上级 5ee9491c
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
- [应用开发导读](application-dev-guide.md) - [应用开发导读](application-dev-guide.md)
- 了解OpenHarmony - 了解OpenHarmony
- [了解OpenHarmony开源项目](../OpenHarmony-Overview_zh.md) - [了解OpenHarmony开源项目](../OpenHarmony-Overview_zh.md)
- [了解OpenHarmony系统](../readme)
- [术语](../device-dev/glossary/glossary.md) - [术语](../device-dev/glossary/glossary.md)
- [版本说明](../release-notes/Readme.md) - [版本说明](../release-notes/Readme.md)
- 快速开始 - 快速开始
......
...@@ -40,7 +40,7 @@ Ability assistant(Ability助手,简称为aa)是实现应用、原子化服 ...@@ -40,7 +40,7 @@ Ability assistant(Ability助手,简称为aa)是实现应用、原子化服
当成功启动Ability时,返回“start ability successfully.”;当启动失败时,返回“error: failed to start ability.”。 当成功启动Ability时,返回“start ability successfully.”;当启动失败时,返回“error: failed to start ability.”。
使用方法: **使用方法:**
``` ```
aa start [-d <device-id>] -a <ability-name> -b <bundle-name> [-D] aa start [-d <device-id>] -a <ability-name> -b <bundle-name> [-D]
...@@ -61,7 +61,7 @@ Ability assistant(Ability助手,简称为aa)是实现应用、原子化服 ...@@ -61,7 +61,7 @@ Ability assistant(Ability助手,简称为aa)是实现应用、原子化服
当成功停止Service Ability时,返回“stop service ability successfully.”;当停止失败时,返回“error: failed to stop service ability.”。 当成功停止Service Ability时,返回“stop service ability successfully.”;当停止失败时,返回“error: failed to stop service ability.”。
使用方法: **使用方法:**
``` ```
aa stop-service [-d <device-id>] -a <ability-name> -b <bundle-name> aa stop-service [-d <device-id>] -a <ability-name> -b <bundle-name>
...@@ -71,16 +71,17 @@ Ability assistant(Ability助手,简称为aa)是实现应用、原子化服 ...@@ -71,16 +71,17 @@ Ability assistant(Ability助手,简称为aa)是实现应用、原子化服
用于打印Ability的相关信息。 用于打印Ability的相关信息。
| 参数 | 参数说明 | | 参数 | 二级参数 | 参数说明 |
| ---------------------- | -------------------------------------- | | ----------------- | -------------------- | ------------------------------------------------------------ |
| -h/--help | 帮助信息。 | | -h/--help | - | 帮助信息。 |
| -a/--all | 打印所有mission内的Ability。 | | -a/--all | - | 打印所有mission内的Ability。 |
| -s/--stack \<number> | 打印指定mission stack内的Ability。 | | -l/--mission-list | type(缺省打印全部) | 打印任务栈信息。<br />type:<br />NORMAL <br />DEFAULT_STANDARD<br />DEFAULT_SINGLE<br />LAUNCHER |
| -m/--mission \<number> | 打印指定mission内的Ability。 | | -e/--extension | elementName | 打印扩展组件信息。 |
| -l/--stack-list | 打印每个mission stack内的mission列表。 | | -u/--userId | UserId | 打印指定UserId的栈信息,需要和其他参数组合使用,例如 aa dump -a -u 100、aa dump -d -u 100、 |
| -u/--ui | 打印system ui Ability。 | | -d/--data | | 打印Data Ability。 |
| -e/--serv | 打印Service Ability。 | | -i/--ability | AbilityRecord ID | 打印指定Ability详细信息 |
| -d/--data | 打印Data Ability。 | | -c/--client | | 打印Ability详细信息,需要和其他参数组合使用,例如 aa dump -a -c、aa dump -i 21 -c、 |
**使用方法:** **使用方法:**
......
# FA模型综述 # FA模型综述
\ No newline at end of file
## 整体架构
鸿蒙用户程序的开发本质上就是开发Ability,OpenHarmony系统也是通过调度Ability,通过系统提供的一致性调度契约对Ability进行生命周期管理,从而实现对用户程序的调度。FA模型中Ability分为PageAbility、ServiceAbility和DataAbility三种类型。其中PageAbility具备ArkUI的Ability,是用户具体可见并可以交互的Ability实例;ServiceAbility也是Ability一种,但是没有UI,提供其他Ability调用自定义的服务,在后台运行;DataAbility也是没有UI,提供其他Ability进行数据的增删查服务,在后台运行。
## 应用包结构
**应用包结构如下图所示:**
![fa-package-info](figures/fa-package-info.png)
## 生命周期
**pageAbility生命周期回调如下图所示:**
![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png)
开发者可以在 app.js/app.ets 中重写生命周期函数,在对应的生命周期函数内处理应用相应逻辑。
## 进程线程模型
应用独享独立进程,Ability独享独立线程,应用进程在Ability第一次启动时创建,并为启动的Ability创建线程,应用启动后再启动应用内其他Ability,会为每一个Ability创建相应的线程。每个Ability绑定一个独立的JSRuntime实例,因此Ability之间是隔离的。
![fa-threading-nodel](figures/fa-threading-model.png)
\ No newline at end of file
...@@ -27,19 +27,19 @@ Page模板(以下简称“Page”)是FA唯一支持的模板,用于提供 ...@@ -27,19 +27,19 @@ Page模板(以下简称“Page”)是FA唯一支持的模板,用于提供
**PageAbility类型Ability生命周期回调如下图所示:** **PageAbility类型Ability生命周期回调如下图所示:**
![PageAbility-Lifecycel-Callbacks](figures/page-ability-lifecycle-callbacks.png) ![fa-pageAbility-lifecycle](figures/fa-pageAbility-lifecycle.png)
## 启动本地PageAbility ## 启动本地PageAbility
导入模块 * 导入模块
``` ```
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
``` ```
``` ```
FeatureAbility.startAbility(parameter: StartAbilityParameter, callback: AsyncCallback<number>) featureAbility.startAbility(parameter: StartAbilityParameter, callback: AsyncCallback<number>)
``` ```
* 接口说明 * 接口说明
...@@ -50,61 +50,75 @@ import featureAbility from '@ohos.ability.featureAbility' ...@@ -50,61 +50,75 @@ import featureAbility from '@ohos.ability.featureAbility'
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
featureAbility.startAbility( featureAbility.startAbility({
{ want:
want: {
{ action: "",
action: "", entities: [""],
entities: [""], type: "",
type: "", options: {
options: { // indicates the grant to perform read operations on the URI
// indicates the grant to perform read operations on the URI authReadUriPermission: true,
authReadUriPermission: true, // indicates the grant to perform write operations on the URI
// indicates the grant to perform write operations on the URI authWriteUriPermission: true,
authWriteUriPermission: true, // support forward intent result to origin ability
// support forward intent result to origin ability abilityForwardResult: true,
abilityForwardResult: true, // used for marking the ability start-up is triggered by continuation
// used for marking the ability start-up is triggered by continuation abilityContinuation: true,
abilityContinuation: true, // specifies whether a component does not belong to ohos
// specifies whether a component does not belong to ohos notOhosComponent: true,
notOhosComponent: true, // specifies whether an ability is started
// specifies whether an ability is started abilityFormEnabled: true,
abilityFormEnabled: true, // indicates the grant for possible persisting on the URI.
// indicates the grant for possible persisting on the URI. authPersistableUriPermission: true,
authPersistableUriPermission: true, // indicates the grant for possible persisting on the URI.
// indicates the grant for possible persisting on the URI. authPrefixUriPermission: true,
authPrefixUriPermission: true, // support distributed scheduling system start up multiple devices
// support distributed scheduling system start up multiple devices abilitySliceMultiDevice: true,
abilitySliceMultiDevice: true, // indicates that an ability using the service template is started regardless of whether the
// indicates that an ability using the service template is started regardless of whether the // host application has been started.
// host application has been started. startForegroundAbility: true,
startForegroundAbility: true, // install the specified ability if it's not installed.
// install the specified ability if it's not installed. installOnDemand: true,
installOnDemand: true, // return result to origin ability slice
// return result to origin ability slice abilitySliceForwardResult: true,
abilitySliceForwardResult: true, // install the specified ability with background mode if it's not installed.
// install the specified ability with background mode if it's not installed. installWithBackgroundMode: true
installWithBackgroundMode: true
},
deviceId: "",
bundleName: "com.example.startability",
abilityName: "com.example.startability.MainAbility",
uri: ""
},
}, },
); deviceId: "",
) bundleName: "com.example.startability",
abilityName: "com.example.startability.MainAbility",
uri: ""
},
},
);
```
want参数也可以使用parameters参数,使用key-value的方式输入。
* 示例
```javascript
import featureAbility from '@ohos.ability.featureAbility'
featureAbility.startAbility({
want:
{
bundleName: "com.example.startability",
uri: "",
parameters: {
abilityName: "com.example.startability.MainAbility"
}
},
},
);
``` ```
## 启动远程PageAbility ## 启动远程PageAbility
导入模块 * 导入模块
``` ```
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
``` ```
``` ```
FeatureAbility.startAbility(parameter: StartAbilityParameter) featureAbility.startAbility(parameter: StartAbilityParameter)
``` ```
* 接口说明 * 接口说明
...@@ -114,14 +128,13 @@ FeatureAbility.startAbility(parameter: StartAbilityParameter) ...@@ -114,14 +128,13 @@ FeatureAbility.startAbility(parameter: StartAbilityParameter)
* 示例 * 示例
```javascript ```javascript
var promise = await ability.startAbility( var promise = await featureAbility.startAbility({
{ want:
want: {
{ deviceId: this.deviceId,
deviceId: this.deviceId, bundleName: "com.example.test",
bundleName: "com.example.test", abilityName: "com.example.test.MainAbility",
abilityName: "com.example.test.MainAbility", },
}, }
} );
);
``` ```
\ No newline at end of file
...@@ -25,8 +25,7 @@ ...@@ -25,8 +25,7 @@
- [访问控制](js-apis-abilityAccessCtrl.md) - [访问控制](js-apis-abilityAccessCtrl.md)
- [通用密钥库系统](js-apis-huks.md) - [通用密钥库系统](js-apis-huks.md)
- 数据管理 - 数据管理
- [轻量级存储<sup>9+</sup>](js-apis-data-preferences.md) - [轻量级存储](js-apis-data-preferences.md)
- [轻量级存储](js-apis-data-storage.md)
- [分布式数据管理](js-apis-distributed-data.md) - [分布式数据管理](js-apis-distributed-data.md)
- [关系型数据库](js-apis-data-rdb.md) - [关系型数据库](js-apis-data-rdb.md)
- [结果集](js-apis-data-resultset.md) - [结果集](js-apis-data-resultset.md)
...@@ -77,15 +76,17 @@ ...@@ -77,15 +76,17 @@
- [USB管理](js-apis-usb.md) - [USB管理](js-apis-usb.md)
- [位置服务](js-apis-geolocation.md) - [位置服务](js-apis-geolocation.md)
- 基本功能 - 基本功能
- [应用上下文](js-apis-basic-features-app-context.md)
- [日志打印](js-apis-basic-features-logs.md)
- [页面路由](js-apis-basic-features-routes.md) - [页面路由](js-apis-basic-features-routes.md)
- [弹窗](js-apis-basic-features-pop-up.md) - [弹窗](js-apis-basic-features-pop-up.md)
- [应用配置](js-apis-basic-features-configuration.md)
- [定时器](js-apis-basic-features-timer.md) - [定时器](js-apis-basic-features-timer.md)
- [锁屏管理](js-apis-screen-lock.md) - [锁屏管理](js-apis-screen-lock.md)
- [设置系统时间](js-apis-system-time.md) - [设置系统时间](js-apis-system-time.md)
- [壁纸](js-apis-wallpaper.md) - [壁纸](js-apis-wallpaper.md)
- [剪贴板](js-apis-pasteboard.md) - [剪贴板](js-apis-pasteboard.md)
- [动画](js-apis-basic-features-animator.md) - [动画](js-apis-basic-features-animator.md)
- [媒体查询](js-apis-mediaquery.md)
- [WebGL](js-apis-webgl.md) - [WebGL](js-apis-webgl.md)
- [WebGL2](js-apis-webgl2.md) - [WebGL2](js-apis-webgl2.md)
- [屏幕截图](js-apis-screenshot.md) - [屏幕截图](js-apis-screenshot.md)
......
...@@ -10,10 +10,10 @@ Ability的上下文环境,继承自Context。 ...@@ -10,10 +10,10 @@ Ability的上下文环境,继承自Context。
## 使用说明 ## 使用说明
在使用AbilityContext的功能前,需要通过Ability子类实例获取。 ​在使用AbilityContext的功能前,需要通过Ability子类实例获取。
```js ```js
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
class MainAbility extends Ability { class MainAbility extends Ability {
...@@ -42,10 +42,10 @@ startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void ...@@ -42,10 +42,10 @@ startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果 |
**示例:** **示例:**
...@@ -71,11 +71,11 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void& ...@@ -71,11 +71,11 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 |
| options | StartOptions | 是 | 启动Ability所携带的参数。 | | options | StartOptions | 是 | 启动Ability所携带的参数。 |
| callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果。 | | callback | AsyncCallback&lt;void&gt; | 是 | callback形式返回启动结果。 |
**示例:** **示例:**
...@@ -96,7 +96,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void& ...@@ -96,7 +96,7 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&
## AbilityContext.startAbility ## AbilityContext.startAbility
startAbility(want: Want, options: StartOptions): Promise&lt;void> startAbility(want: Want, options: StartOptions): Promise&lt;void&gt;;
启动Ability。通过Promise返回结果。 启动Ability。通过Promise返回结果。
...@@ -104,10 +104,10 @@ startAbility(want: Want, options: StartOptions): Promise&lt;void> ...@@ -104,10 +104,10 @@ startAbility(want: Want, options: StartOptions): Promise&lt;void>
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 |
| options | StartOptions | 是 | 启动Ability所携带的参数。 | | options | StartOptions | 是 | 启动Ability所携带的参数。 |
**返回值:** **返回值:**
...@@ -145,10 +145,10 @@ startAbilityForResult(want: Want, callback: AsyncCallback&lt;AbilityResult&gt;): ...@@ -145,10 +145,10 @@ startAbilityForResult(want: Want, callback: AsyncCallback&lt;AbilityResult&gt;):
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want |[Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | | want |[Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 |
| callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | 是 | 执行结果回调函数。 | | callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | 是 | 执行结果回调函数。 |
**示例:** **示例:**
...@@ -173,11 +173,11 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback ...@@ -173,11 +173,11 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want |[Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | | want |[Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 |
| options | StartOptions | 是 | 启动Ability所携带的参数。 | | options | StartOptions | 是 | 启动Ability所携带的参数。 |
| callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | 是 | 执行结果回调函数。 | | callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | 是 | 执行结果回调函数。 |
**示例:** **示例:**
...@@ -206,10 +206,10 @@ startAbilityForResult(want: Want, options: StartOptions): Promise&lt;AbilityResu ...@@ -206,10 +206,10 @@ startAbilityForResult(want: Want, options: StartOptions): Promise&lt;AbilityResu
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#want) | 是 | 启动Ability的want信息。 | | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 启动Ability的want信息。 |
| options | StartOptions | 是 | 启动Ability所携带的参数。 | | options | StartOptions | 是 | 启动Ability所携带的参数。 |
**返回值:** **返回值:**
...@@ -353,9 +353,9 @@ startAbilityByCall(want: Want): Promise&lt;Caller&gt;; ...@@ -353,9 +353,9 @@ startAbilityByCall(want: Want): Promise&lt;Caller&gt;;
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#want) | 是 | 传入需要启动的ability的信息,包含ability名称、包名、设备ID,设备ID缺省或为空表示启动本地ability。 | | want | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 传入需要启动的ability的信息,包含ability名称、包名、设备ID,设备ID缺省或为空表示启动本地ability。 |
**返回值:** **返回值:**
......
# 应用上下文
## 导入模块
```
import app from '@system.app';
```
## 权限列表
## app.getInfo
getInfo(): &lt;AppResponse&gt;
获取当前应用配置文件中声明的信息。
- 返回值
**表1** AppResponse
| | | |
| -------- | -------- | -------- |
| 参数名 | 类型 | 说明 |
| appID<sup>6+</sup> | string | 表示应用的包名,用于标识应用的唯一性。 |
| appName | string | 表示应用的名称。 |
| versionName | string | 表示应用的版本名称。 |
| versionCode | number | 表示应用的版本号。 |
- 示例
```
export default {
getInfo(){
var info = app.getInfo();
console.log(JSON.stringify(info));
}
}
```
## app.terminate
terminate(): void
退出当前Ability
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 从API Version 7 开始,推荐使用新接口['@ohos.ability.featureAbility'](js-apis-featureAbility.md)。
- 示例
```
export default {
terminate(){
app.terminate();
}}
```
## app.requestFullWindow
requestFullWindow(duration: number): void
请求应用以全窗口运行,FA在某些场景下(如半模态FA)会以非全窗口运行,调用该接口会从非全窗口切换为全窗口运行,如果已经以全窗口运行则该接口调用无效。
- 参数
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| duration | number | 否 | 请求全屏时,设定非全屏到全屏的过渡时间,单位为毫秒,默认时间与非全屏到全屏的距离成正比。 |
- 示例
```
export default {
requestFullWindow(){
app.requestFullWindow({
duration: 200});
}
}
```
# 应用配置
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.i18n'](js-apis-i18n.md)和['@ohos.intl'](js-apis-intl.md)。
>
## 导入模块
```
import configuration from '@system.configuration';
```
## 权限列表
## configuration.getLocale
getLocale(): &lt;LocaleResponse&gt;
获取应用当前的语言和地区。默认与系统的语言和地区同步。
- 返回值
**表1** LocaleResponse
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| language | string | 语言。例如:zh。 |
| countryOrRegion | string | 国家或地区。例如:CN。 |
| dir | string | 文字布局方向。取值范围:<br/>-&nbsp;ltr:从左到右;<br/>-&nbsp;rtl:从右到左。 |
| $unicodeSetting^{5+}$ | string | 语言环境定义的Unicode语言环境键集,如果此语言环境没有特定键集,则返回空集。<br/>例如:{"nu":"arab"},表示当前环境下的数字采用阿拉伯语的数字。 |
- 示例
```
export default {
getLocale() {
const localeInfo = configuration.getLocale();
console.info(localeInfo.language);
}
}
```
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
无需导入。 无需导入。
## 权限列表
## console.debug ## console.debug
......
...@@ -1432,7 +1432,7 @@ lstat(path:string, callback:AsyncCallback&lt;Stat&gt;): void ...@@ -1432,7 +1432,7 @@ lstat(path:string, callback:AsyncCallback&lt;Stat&gt;): void
```js ```js
fileio.lstat(path, function (err, stat) { fileio.lstat(path, function (err, stat) {
// do something // do something
)); });
``` ```
...@@ -1827,7 +1827,7 @@ chown(path: string, uid: number, gid: number): Promise&lt;void&gt; ...@@ -1827,7 +1827,7 @@ chown(path: string, uid: number, gid: number): Promise&lt;void&gt;
- 示例: - 示例:
```js ```js
let stat = fileio.statSync(path); let stat = fileio.statSync(path);
fileio.chown(path, stat.uid, stat.gid)).then(function(){ fileio.chown(path, stat.uid, stat.gid).then(function(){
console.info("chown successfully"); console.info("chown successfully");
}).catch(function(err){ }).catch(function(err){
console.info("chown failed with error:"+ err); console.info("chown failed with error:"+ err);
...@@ -2127,7 +2127,7 @@ fdopenStream(fd: number, mode: string): Promise&lt;Stream&gt; ...@@ -2127,7 +2127,7 @@ fdopenStream(fd: number, mode: string): Promise&lt;Stream&gt;
- 示例: - 示例:
```js ```js
fileio.fdopenStream(fd, mode).then(function(stream){ fileio.fdopenStream(fd, mode).then(function(stream){
console.info("openStream successfully"+); console.info("openStream successfully");
}).catch(function(err){ }).catch(function(err){
console.info("openStream failed with error:"+ err); console.info("openStream failed with error:"+ err);
}); });
......
# FormProvider
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
卡片提供方相关接口。
## 导入模块
```
import formProvider from '@ohos.application.formProvider';
```
## 权限
## setFormNextRefreshTime
setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void;
设置指定卡片的下一次更新时间。
**系统能力:**
SystemCapability.Ability.Form
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------- |
| formId | string | 是 | 卡片标识 |
| minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5 |
**示例:**
```js
var formId = "12400633174999288";
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error) {
console.log('formProvider setFormNextRefreshTime, error:' + error.code);
}
});
```
## setFormNextRefreshTime
setFormNextRefreshTime(formId: string, minute: number): Promise<void>;
设置指定卡片的下一次更新时间,以promise方式返回。
**系统能力:**
SystemCapability.Ability.Form
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------- |
| formId | string | 是 | 卡片标识 |
| minute | number | 是 | 指定多久之后更新,单位分钟,大于等于5 |
**示例:**
```js
var formId = "12400633174999288";
formProvider.setFormNextRefreshTime(formId, 5).catch((error) => {
console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
});
```
## updateForm
updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback<void>): void;
更新指定的卡片。
**系统能力:**
SystemCapability.Ability.Form
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | 是 | 请求更新的卡片标识 |
| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于更新的数据 |
**示例:**
```js
import formBindingData from '@ohos.application.formBindingData';
var formId = "12400633174999288";
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
formProvider.updateForm(formId, obj, (error, data) => {
if (error) {
console.log('formProvider updateForm, error:' + error.code);
}
});
```
## updateForm
updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void>;
更新指定的卡片,以promise方式返回。
**系统能力:**
SystemCapability.Ability.Form
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | 是 | 请求更新的卡片标识 |
| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于更新的数据 |
**示例:**
```js
import formBindingData from '@ohos.application.formBindingData';
var formId = "12400633174999288";
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
formProvider.updateForm(formId, obj).catch((error) => {
console.log('formProvider updateForm, error:' + JSON.stringify(error));
});
```
\ No newline at end of file
# 上传下载 # 上传下载(新)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
......
# 应用配置 # 应用配置
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.i18n'](js-apis-i18n.md)和['@ohos.intl'](js-apis-intl.md)。 > - 从API Version 7 开始,该接口不再维护,推荐使用新接口['@ohos.i18n'](https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-i18n-0000001155058572)和['@ohos.intl'](https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-intl-0000001200978209)。
> >
> >
> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
## 导入模块 ## 导入模块
``` ```
import systemTime from '@ohos.systemTime'; import systemTime from '@ohos.systemTime';
``` ```
...@@ -29,7 +29,7 @@ setTime(time : number, callback : AsyncCallback&lt;void&gt;) : void ...@@ -29,7 +29,7 @@ setTime(time : number, callback : AsyncCallback&lt;void&gt;) : void
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
- 示例: - 示例:
``` ```
// time对应的时间为2021-01-20 02:36:25 // time对应的时间为2021-01-20 02:36:25
var time = 1611081385000; var time = 1611081385000;
...@@ -64,7 +64,7 @@ setTime(time : number) : Promise&lt;void&gt; ...@@ -64,7 +64,7 @@ setTime(time : number) : Promise&lt;void&gt;
| Promise&lt;void&gt; | 返回的异步回调函数。 | | Promise&lt;void&gt; | 返回的异步回调函数。 |
- 示例: - 示例:
``` ```
// time对应的时间为2021-01-20 02:36:25 // time对应的时间为2021-01-20 02:36:25
var time = 1611081385000; var time = 1611081385000;
...@@ -91,7 +91,7 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void ...@@ -91,7 +91,7 @@ getCurrentTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 |
- 示例: - 示例:
``` ```
systemTime.getCurrentTime(true, (error, data) => { systemTime.getCurrentTime(true, (error, data) => {
if (error) { if (error) {
...@@ -122,7 +122,7 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -122,7 +122,7 @@ getCurrentTime(isNano?: boolean): Promise&lt;number&gt;
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 | | Promise&lt;number&gt; | 以Promise形式返回结果,返回自&nbsp;Unix&nbsp;纪元以来经过的时间。 |
- 示例: - 示例:
``` ```
systemTime.getCurrentTime().then((data) => { systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
...@@ -147,7 +147,7 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void ...@@ -147,7 +147,7 @@ getRealActiveTime(isNano?: boolean, callback: AsyncCallback&lt;number&gt;): void
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来但不包括度睡眠时间经过的时间。 |
- 示例: - 示例:
``` ```
systemTime.getRealActiveTime(true, (error, data) => { systemTime.getRealActiveTime(true, (error, data) => {
if (error) { if (error) {
...@@ -178,7 +178,7 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt; ...@@ -178,7 +178,7 @@ getRealActiveTime(isNano?: boolean): Promise&lt;number&gt;
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 | | Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来但不包括度睡眠时间经过的时间。 |
- 示例: - 示例:
``` ```
systemTime.getCurrentTime().then((data) => { systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
...@@ -203,7 +203,7 @@ getRealTime(callback: AsyncCallback&lt;number&gt;): void ...@@ -203,7 +203,7 @@ getRealTime(callback: AsyncCallback&lt;number&gt;): void
| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 | | callback | AsyncCallback&lt;number&gt; | 是 | 回调函数,返回自系统启动以来包括深度睡眠时间经过的毫秒数。 |
- 示例: - 示例:
``` ```
systemTime.getRealTime(true, (error, data) => { systemTime.getRealTime(true, (error, data) => {
if (error) { if (error) {
...@@ -234,7 +234,7 @@ getRealTime(): Promise&lt;number&gt; ...@@ -234,7 +234,7 @@ getRealTime(): Promise&lt;number&gt;
| Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 | | Promise&lt;number&gt; | 以Promise形式返回结果,返回自系统启动以来包括深度睡眠时间经过的时间。 |
- 示例: - 示例:
``` ```
systemTime.getRealTime().then((data) => { systemTime.getRealTime().then((data) => {
console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data));
...@@ -261,7 +261,7 @@ setDate(date: Date, callback: AsyncCallback&lt;void&gt;): void ...@@ -261,7 +261,7 @@ setDate(date: Date, callback: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
- 示例: - 示例:
``` ```
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data,(error, data) => { systemTime.setDate(data,(error, data) => {
...@@ -295,7 +295,7 @@ setDate(date: Date): Promise&lt;void&gt; ...@@ -295,7 +295,7 @@ setDate(date: Date): Promise&lt;void&gt;
| Promise&lt;void&gt; | 返回的异步回调函数。 | | Promise&lt;void&gt; | 返回的异步回调函数。 |
- 示例: - 示例:
``` ```
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data).then((value) => { systemTime.setDate(data).then((value) => {
...@@ -320,7 +320,7 @@ getDate(callback: AsyncCallback&lt;Date&gt;): void ...@@ -320,7 +320,7 @@ getDate(callback: AsyncCallback&lt;Date&gt;): void
| callback | AsyncCallback&lt;Date&gt; | 是 | 回调函数,返回当前系统日期。 | | callback | AsyncCallback&lt;Date&gt; | 是 | 回调函数,返回当前系统日期。 |
- 示例: - 示例:
``` ```
systemTime.getDate((error, data) => { systemTime.getDate((error, data) => {
if (error) { if (error) {
...@@ -346,7 +346,7 @@ getDate(): Promise&lt;Date&gt; ...@@ -346,7 +346,7 @@ getDate(): Promise&lt;Date&gt;
| Promise&lt;Date&gt; | 以Promise形式返回结果,返回当前系统日期。 | | Promise&lt;Date&gt; | 以Promise形式返回结果,返回当前系统日期。 |
- 示例: - 示例:
``` ```
systemTime.getDate().then((data) => { systemTime.getDate().then((data) => {
console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); console.log(`systemTime.getDate success data : ` + JSON.stringify(data));
...@@ -373,7 +373,7 @@ setTimezone(timezone: string, callback: AsyncCallback&lt;void&gt;): void ...@@ -373,7 +373,7 @@ setTimezone(timezone: string, callback: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,可以在回调函数中处理接口返回值。 |
- 示例: - 示例:
``` ```
systemTime.setTimezone('Asia/Shanghai', (error, data) => { systemTime.setTimezone('Asia/Shanghai', (error, data) => {
if (error) { if (error) {
...@@ -406,7 +406,7 @@ setTimezone(timezone: string): Promise&lt;void&gt; ...@@ -406,7 +406,7 @@ setTimezone(timezone: string): Promise&lt;void&gt;
| Promise&lt;void&gt; | 返回的异步回调函数。 | | Promise&lt;void&gt; | 返回的异步回调函数。 |
- 示例: - 示例:
``` ```
systemTime.setTimezone('Asia/Shanghai').then((data) => { systemTime.setTimezone('Asia/Shanghai').then((data) => {
console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data)); console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data));
...@@ -430,7 +430,7 @@ getTimeZone(callback: AsyncCallback&lt;string&gt;): void ...@@ -430,7 +430,7 @@ getTimeZone(callback: AsyncCallback&lt;string&gt;): void
| callback | AsyncCallback&lt;string&gt; | 是 | 回调函数,返回系统时区。 | | callback | AsyncCallback&lt;string&gt; | 是 | 回调函数,返回系统时区。 |
- 示例: - 示例:
``` ```
systemTime.getTimeZone((error, data) => { systemTime.getTimeZone((error, data) => {
if (error) { if (error) {
...@@ -456,7 +456,7 @@ getTimeZone(): Promise&lt;string&gt; ...@@ -456,7 +456,7 @@ getTimeZone(): Promise&lt;string&gt;
| Promise&lt;string&gt; | 以Promise形式返回结果,返回系统时区。 | | Promise&lt;string&gt; | 以Promise形式返回结果,返回系统时区。 |
- 示例: - 示例:
``` ```
systemTime.getDate().then((data) => { systemTime.getDate().then((data) => {
console.log(`systemTime.getTimeZone success data : ` + JSON.stringify(data)); console.log(`systemTime.getTimeZone success data : ` + JSON.stringify(data));
......
...@@ -174,6 +174,6 @@ unmount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void ...@@ -174,6 +174,6 @@ unmount(volumeId: string, callback:AsyncCallback&lt;boolean&gt;):void
| id<sup>9+</sup> | number | 卷id | | id<sup>9+</sup> | number | 卷id |
| uuid<sup>9+</sup> | string | 卷uuid | | uuid<sup>9+</sup> | string | 卷uuid |
| description<sup>9+</sup> | string | 卷相关描述 | | description<sup>9+</sup> | string | 卷相关描述 |
| removeAble<sup>9+</sup> | boolean | 是否为可移动存储设备 | | removable<sup>9+</sup> | boolean | 是否为可移动存储设备 |
| state<sup>9+</sup> | int | 当前卷状态 | | state<sup>9+</sup> | int | 当前卷状态 |
| path<sup>9+</sup> | string | 卷的挂载地址 | | path<sup>9+</sup> | string | 卷的挂载地址 |
\ No newline at end of file
...@@ -269,7 +269,6 @@ isLastWorkTimeOut(workId: number): Promise\<boolean> ...@@ -269,7 +269,6 @@ isLastWorkTimeOut(workId: number): Promise\<boolean>
.catch(err => { .catch(err => {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data);
}); });
})
``` ```
## WorkInfo ## WorkInfo
......
...@@ -48,10 +48,8 @@ PageA跳转到PageB,跳转的共享元素为image, shareid为“shareImage ...@@ -48,10 +48,8 @@ PageA跳转到PageB,跳转的共享元素为image, shareid为“shareImage
<div> <div>
<list> <list>
<list-item type="description"> <list-item type="description">
<div> <image src="item.jpg" shareid="shareImage" onclick="jump" class="shared-transition-style"></image>
<image src="item.jpg" shareid="shareImage" onclick="jump" class="shared-transition-style"></image> <text onclick="jump">Click on picture to Jump to ths details</text>
<text onclick="jump">Click on picture to Jump to ths details</text>
</div>
</list-item> </list-item>
</list> </list>
</div> </div>
...@@ -237,3 +235,145 @@ export default { ...@@ -237,3 +235,145 @@ export default {
b. back场景下:退出页面栈的Page2.js应用transition-enter描述的动画配置,并进行倒播;从页面栈第二位置进入栈顶位置的Page1.js应用transition-exit描述的动画配置,并进行倒播。 b. back场景下:退出页面栈的Page2.js应用transition-enter描述的动画配置,并进行倒播;从页面栈第二位置进入栈顶位置的Page1.js应用transition-exit描述的动画配置,并进行倒播。
![zh-cn_image_0000001238184345](figures/zh-cn_image_0000001238184345.png) ![zh-cn_image_0000001238184345](figures/zh-cn_image_0000001238184345.png)
### 示例
Page1有一个不透明盒子,点击盒子会跳转到Page2,当点击Page2中的盒子,会回退到Page1页面。
1. Page1
```
<!-- xxx.hml -->
<div class="container">
<text>index</text>
<div class="move_page" onclick="jump"></div>
</div>
```
```
<!-- xxx.js -->
import router from '@system.router';
export default {
data: {
},
jump() {
router.push({
uri:'pages/transition2/transition2'
})
}
}
```
```
<!-- xxx.css -->
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.move_page {
width: 100px;
height: 100px;
background-color: #72d3fa;
transition-enter: go_page;
transition-exit: exit_page;
transition-duration: 5s;
transition-timing-function: friction;
}
@keyframes go_page {
from {
opacity: 0;
transform: translate(0px) rotate(60deg) scale(1.0);
}
to {
opacity: 1;
transform: translate(100px) rotate(360deg) scale(1.0);
}
}
@keyframes exit_page {
from {
opacity: 1;
transform: translate(200px) rotate(60deg) scale(2);
}
to {
opacity: 0;
transform: translate(200px) rotate(360deg) scale(2);
}
}
```
2. Page2
```
<!-- xxx.hml -->
<div class="container">
<text>transition</text>
<div class="move_page" onclick="jumpBack"></div>
</div
```
```
<!-- xxx.js -->
import router from '@system.router';
export default {
data: {
},
jumpBack() {
router.back()
}
}
```
```
<!-- xxx.css -->
.container {
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
.move_page {
width: 100px;
height: 100px;
background-color: #f172fa;
transition-enter: go_page;
transition-exit: exit_page;
transition-duration: 5s;
transition-timing-function: ease;
}
@keyframes go_page {
from {
opacity: 0;
transform:translate(100px) rotate(0deg) scale(1.0);
}
to {
opacity: 1;
transform:translate(100px) rotate(180deg) scale(2.0);
}
}
@keyframes exit_page {
from {
opacity: 1;
transform: translate(0px) rotate(60deg) scale(1);
}
to {
opacity: 0;
transform: translate(0px) rotate(360deg) scale(1);
}
}
```
![transition](figures/transition.gif)
...@@ -132,6 +132,7 @@ ...@@ -132,6 +132,7 @@
- [插值计算](ts-interpolation-calculation.md) - [插值计算](ts-interpolation-calculation.md)
- 全局UI方法 - 全局UI方法
- [图片缓存](ts-methods-image-cache.md) - [图片缓存](ts-methods-image-cache.md)
- [媒体查询](ts-methods-media-query.md)
- 弹窗 - 弹窗
- [警告弹窗](ts-methods-alert-dialog-box.md) - [警告弹窗](ts-methods-alert-dialog-box.md)
- [列表选择弹窗](ts-methods-action-sheet.md) - [列表选择弹窗](ts-methods-action-sheet.md)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册