提交 3f4a51dd 编写于 作者: 徐杰

Merge remote-tracking branch 'origin/master' into tiaodan_yafei_0613

Change-Id: Ia61d0e863f93baf45dee85daa6e4db0adfe6a2fa
......@@ -41,8 +41,10 @@ Before developing applications related to tag read and write, you must declare N
}
],
"requestPermissions": [
"name": "ohos.permission.NFC_TAG",
"reason": "tag",
{
"name": "ohos.permission.NFC_TAG",
"reason": "tag",
}
]
}
}
......
......@@ -18,7 +18,7 @@ You can bind a sheet to a component through the **bindSheet** attribute. You can
| Name | Type | Mandatory| Description |
| ------------------ | -------------------------------------- | ---- | ---------------------- |
| height | [SheetSize](#sheetsize10) \| [Length](ts-types.md#length) | No| Height of the sheet. |
| showDragBar | boolean | No | Whether the control bar is visible. |
| dragBar | boolean | No | Whether the control bar is visible. |
## SheetSize<sup>10+</sup>
......
......@@ -50,6 +50,7 @@
- [\@BuilderParam装饰器:引用\@Builder函数](quick-start/arkts-builderparam.md)
- [\@Styles装饰器:定义组件重用样式](quick-start/arkts-style.md)
- [\@Extend装饰器:定义扩展组件样式](quick-start/arkts-extend.md)
- [\@AnimatableExtend装饰器:定义可动画属性](quick-start/arkts-animatable-extend.md)
- [stateStyles:多态样式](quick-start/arkts-statestyles.md)
- 状态管理
- [状态管理概述](quick-start/arkts-state-management-overview.md)
......
......@@ -6,7 +6,7 @@ ArkTS卡片开放了自定义绘制的能力,在卡片上可以通过[Canvas](
```ts
@Entry
@Component
struct Card {
struct WidgetCard {
private canvasWidth: number = 0;
private canvasHeight: number = 0;
// 初始化CanvasRenderingContext2D和RenderingContextSettings
......@@ -26,9 +26,9 @@ struct Card {
this.canvasWidth = this.context.width;
this.canvasHeight = this.context.height;
// 绘制画布的背景
this.context.fillStyle = 'rgba(203, 154, 126, 1.00)';
this.context.fillStyle = '#EEF0FF';
this.context.fillRect(0, 0, this.canvasWidth, this.canvasHeight);
// 在画布的中心绘制一个红色的
// 在画布的中心绘制一个圆
this.context.beginPath();
let radius = this.context.width / 3;
let circleX = this.context.width / 2;
......@@ -36,35 +36,48 @@ struct Card {
this.context.moveTo(circleX - radius, circleY);
this.context.arc(circleX, circleY, radius, 2 * Math.PI, 0, true);
this.context.closePath();
this.context.fillStyle = 'red';
this.context.fillStyle = '#5A5FFF';
this.context.fill();
// 绘制笑脸的左眼
let leftR = radius / 4;
let leftX = circleX - (radius / 2);
let leftY = circleY - (radius / 3.5);
let leftR = radius / 13;
let leftX = circleX - (radius / 2.3);
let leftY = circleY - (radius / 4.5);
this.context.beginPath();
this.context.arc(leftX, leftY, leftR, 0, Math.PI, true);
this.context.strokeStyle = '#ffff00';
this.context.lineWidth = 10;
this.context.arc(leftX, leftY, leftR, 0, 2 * Math.PI, true);
this.context.strokeStyle = '#FFFFFF';
this.context.lineWidth = 15;
this.context.stroke();
// 绘制笑脸的右眼
let rightR = radius / 4;
let rightX = circleX + (radius / 2);
let rightY = circleY - (radius / 3.5);
let rightR = radius / 13;
let rightX = circleX + (radius / 2.3);
let rightY = circleY - (radius / 4.5);
this.context.beginPath();
this.context.arc(rightX, rightY, rightR, 0, Math.PI, true);
this.context.strokeStyle = '#ffff00';
this.context.lineWidth = 10;
this.context.arc(rightX, rightY, rightR, 0, 2 * Math.PI, true);
this.context.strokeStyle = '#FFFFFF';
this.context.lineWidth = 15;
this.context.stroke();
// 绘制笑脸的鼻子
let startX = circleX;
let startY = circleY - 20;
this.context.beginPath();
this.context.moveTo(startX, startY);
this.context.lineTo(startX - 8, startY + 40);
this.context.lineTo(startX + 8, startY + 40);
this.context.strokeStyle = '#FFFFFF';
this.context.lineWidth = 15;
this.context.lineCap = 'round'
this.context.lineJoin = 'round'
this.context.stroke();
// 绘制笑脸的嘴巴
let mouthR = radius / 2.5;
let mouthR = radius / 2;
let mouthX = circleX;
let mouthY = circleY + (radius / 3);
let mouthY = circleY + 10;
this.context.beginPath();
this.context.arc(mouthX, mouthY, mouthR, Math.PI, 0, true);
this.context.strokeStyle = '#ffff00';
this.context.lineWidth = 10;
this.context.arc(mouthX, mouthY, mouthR, Math.PI / 1.4, Math.PI / 3.4, true);
this.context.strokeStyle = '#FFFFFF';
this.context.lineWidth = 15;
this.context.stroke();
this.context.closePath();
})
}
}.height('100%').width('100%')
......@@ -73,4 +86,4 @@ struct Card {
```
运行效果如下图所示。
![WidgetCanvasDemo](figures/WidgetCanvasDemo.png)
![WidgetCanvasDemo](figures/WidgetCanvasDemo.jpeg)
\ No newline at end of file
......@@ -56,7 +56,7 @@ ArkTS卡片与JS卡片具备不同的实现原理及特征,在场景能力上
推荐在开发需求需要动态能力的卡片时使用ArkTS卡片,因为它拥有更加丰富的能力和适应更多的场景,能够提高效率并实现动态化。但如果只需要静态展示卡片,可以考虑使用JS卡片。
# 相关实例
## 相关实例
针对Stage模型卡片提供方的开发,有以下相关实例可供参考:
......
......@@ -23,7 +23,7 @@
## 相关
## 相关
[OpenHarmony应用示例](https://gitee.com/openharmony/applications_app_samples/tree/master/code/SuperFeature/MultiDeviceAppDev)中提供了如下一多示例,感兴趣的开发者可以自行下载、运行及查看效果。
......
......@@ -341,7 +341,7 @@ struct GridRowSample1 {
为了便于理解,下图中自定义预览器的设备屏幕宽度设置为650vp。示例代码中将侧边栏的变化范围控制在[100vp, 600vp],那么右侧的栅格组件宽度相对应在[550vp, 50vp]之间变化。根据代码中对栅格断点的配置,栅格组件宽度发生变化时,其断点相应的发生改变。
![component](figures/component.gif)
![component](figures/component_example2.gif)
```ts
......
......@@ -135,7 +135,9 @@
``` c++
// 调整轨道到指定时间点,后续从该时间点进行解封装
// 注意:mpegts格式文件使用OH_AVDemuxer_SeekToTime功能时,跳转到的位置可能为非关键帧。可在跳转后调用OH_AVDemuxer_ReadSample,通过获取到的OH_AVCodecBufferAttr判断当前帧是否为关键帧。若非关键帧影响应用侧显示等功能,可在跳转后循环读取,获取到后续第一帧关键帧后,再进行解码等处理。
// 注意:
// 1. mpegts格式文件使用OH_AVDemuxer_SeekToTime功能时,跳转到的位置可能为非关键帧。可在跳转后调用OH_AVDemuxer_ReadSample,通过获取到的OH_AVCodecBufferAttr判断当前帧是否为关键帧。若非关键帧影响应用侧显示等功能,可在跳转后循环读取,获取到后续第一帧关键帧后,再进行解码等处理。
// 2. ogg格式文件使用OH_AVDemuxer_SeekToTime功能时,会跳转到传入时间millisecond所在时间间隔(秒)的起始处,可能会导致一定数量的帧误差。
OH_AVDemuxer_SeekToTime(demuxer, 0, OH_AVSeekMode::SEEK_MODE_CLOSEST_SYNC);
```
......
......@@ -13,7 +13,7 @@
```
2. 获取图片。
- 方法一:获取沙箱路径。具体请参考[获取应用文件路径](../application-models/application-context-stage.md#获取应用开发路径)。应用沙箱的介绍及如何向应用沙箱推送文件,请参考[文件管理](../file-management/app-sandbox-directory.md)
- 方法一:获取沙箱路径。具体请参考[获取应用文件路径](../application-models/application-context-stage.md#获取应用文件路径)。应用沙箱的介绍及如何向应用沙箱推送文件,请参考[文件管理](../file-management/app-sandbox-directory.md)
```ts
// Stage模型参考如下代码
......@@ -110,6 +110,11 @@
解码完成,获取到PixelMap对象后,可以进行后续[图片处理](image-transformation.md)
5. 释放pixelMap。
```ts
pixelMap.release();
```
## 开发示例-对资源文件中的图片进行解码
1. 获取resourceManager资源管理。
......@@ -139,3 +144,8 @@
```ts
const pixelMap = await imageSource.createPixelMap();
```
5. 释放pixelMap。
```ts
pixelMap.release();
```
# \@AnimatableExtend:定义可动画属性
@AnimatableExtend装饰器用于自定义可动画的属性方法,在这个属性方法中修改组件不可动画的属性。在动画执行过程时,通过逐帧回调函数修改不可动画属性值,让不可动画属性也能实现动画效果。
- 可动画属性:如果一个属性方法在animation属性前调用,改变这个属性的值可以生效animation属性的动画效果,这个属性称为可动画属性。比如height、width、backgroundColor、translate等。
- 不可动画属性:如果一个属性方法在animation属性前调用,改变这个属性的值不能生效animation属性的动画效果,这个属性称为不可动画属性。比如Text组件的fontSize属性、Ployline组件的points属性等。
> **说明:**
>
> 该装饰器从API Version 10开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
## 装饰器使用说明
### 语法
```ts
@AnimatableExtend(UIComponentName) function functionName(value: typeName) {
.propertyName(value)
}
```
- \@AnimatableExtend仅支持定义在全局,不支持在组件内部定义。
- \@AnimatableExtend定义的函数参数类型必须为number类型或者实现 AnimtableArithmetic\<T\>接口的自定义类型。
- \@AnimatableExtend定义的函数体内只能调用\@AnimatableExtend括号内组件的属性方法。
### AnimtableArithmetic\<T\>接口说明
对复杂数据类型做动画,需要实现AnimtableArithmetic\<T\>接口中加法、减法、乘法和判断相等函数。
| 名称 | 入参类型 | 返回值类型 | 说明
| -------- | -------- |-------- |-------- |
| plus | AnimtableArithmetic\<T\> | AnimtableArithmetic\<T\> | 加法函数 |
| subtract | AnimtableArithmetic\<T\> | AnimtableArithmetic\<T\> | 减法函数 |
| multiply | number | AnimtableArithmetic\<T\> | 乘法函数 |
| equals | AnimtableArithmetic\<T\> | boolean | 相等判断函数 |
## 使用场景
以下示例实现字体大小的动画效果。
```ts
@AnimatableExtend(Text) function animatableFontSize(size: number) {
.fontSize(size)
}
@Entry
@Component
struct AnimatablePropertyExample {
@State fontSize: number = 20
build() {
Column() {
Text("AnimatableProperty")
.animatableFontSize(this.fontSize)
.animation({duration: 1000, curve: "ease"})
Button("Play")
.onClick(() => {
this.fontSize = this.fontSize == 20 ? 36 : 20
})
}.width("100%")
.padding(10)
}
}
```
![image](figures/animatable-font-size.gif)
以下示例实现折线的动画效果。
```ts
class Point {
x: number
y: number
constructor(x: number, y: number) {
this.x = x
this.y = y
}
plus(rhs: Point): Point {
return new Point(this.x + rhs.x, this.y + rhs.y)
}
subtract(rhs: Point): Point {
return new Point(this.x - rhs.x, this.y - rhs.y)
}
multiply(scale: number): Point {
return new Point(this.x * scale, this.y * scale)
}
equals(rhs: Point): boolean {
return this.x === rhs.x && this.y === rhs.y
}
}
class PointVector extends Array<Point> implements AnimatableArithmetic<PointVector> {
constructor(value: Array<Point>) {
super();
value.forEach(p => this.push(p))
}
plus(rhs: PointVector): PointVector {
let result = new PointVector([])
const len = Math.min(this.length, rhs.length)
for (let i = 0; i < len; i++) {
result.push(this[i].plus(rhs[i]))
}
return result
}
subtract(rhs: PointVector): PointVector {
let result = new PointVector([])
const len = Math.min(this.length, rhs.length)
for (let i = 0; i < len; i++) {
result.push(this[i].subtract(rhs[i]))
}
return result
}
multiply(scale: number): PointVector {
let result = new PointVector([])
for (let i = 0; i < this.length; i++) {
result.push(this[i].multiply(scale))
}
return result
}
equals(rhs: PointVector): boolean {
if (this.length != rhs.length) {
return false
}
for (let i = 0; i < this.length; i++) {
if (!this[i].equals(rhs[i])) {
return false
}
}
return true
}
get():Array<[x: number, y: number]> {
let result = []
this.forEach(p => result.push([p.x, p.y]))
return result
}
}
@AnimatableExtend(Polyline) function animatablePoints(points: PointVector) {
.points(points.get())
}
@Entry
@Component
struct AnimatablePropertyExample {
@State points: PointVector = new PointVector([
new Point(50, Math.random() * 200),
new Point(100, Math.random() * 200),
new Point(150, Math.random() * 200),
new Point(200, Math.random() * 200),
new Point(250, Math.random() * 200),
])
build() {
Column() {
Polyline()
.animatablePoints(this.points)
.animation({duration: 1000, curve: "ease"})
.size({height:220, width:300})
.fill(Color.Green)
.stroke(Color.Red)
.backgroundColor('#eeaacc')
Button("Play")
.onClick(() => {
this.points = new PointVector([
new Point(50, Math.random() * 200),
new Point(100, Math.random() * 200),
new Point(150, Math.random() * 200),
new Point(200, Math.random() * 200),
new Point(250, Math.random() * 200),
])
})
}.width("100%")
.padding(10)
}
}
```
![image](figures/animatable-points.gif)
\ No newline at end of file
......@@ -97,7 +97,7 @@ module.json5配置文件包含以下标签。
| [proxyDatas](#proxydatas标签) | 标识当前Module提供的数据代理列表。| 对象数组 | 该标签可缺省,缺省值为空。|
| isolationMode | 标识当前Module的多进程配置项。类型有4种,分别:<br/>-&nbsp;nonisolationFirst:优先在非独立进程中运行。<br/>-&nbsp;isolationFirst:优先在独立进程中运行。<br/>-&nbsp;isolationOnly:只在独立进程中运行。<br/>-&nbsp;nonisolationOnly:只在非独立进程中运行。 |字符串|该标签可缺省, 缺省值为nonisolationFirst。|
| generateBuildHash |标识当前HAP/HSP是否由打包工具生成哈希值。如果存在,则在系统OTA升级但应用的versionCode保持不变时,可根据哈希值判断应用是否需要升级。<br/>该字段仅在[app.json5文件](./app-configuration-file.md)中的generateBuildHash字段为false时使能。<br/><strong>注:</strong>该字段仅对预置应用生效。|布尔值|该标签可缺省, 缺省值为false。|
| compressNativeLibs | 标识libs库是否以压缩存储的方式打包到HAP。如果配置为"false",则libs库以不压缩的方式存储,HAP在安装时无需解压libs,运行时会直接从HAP内加载libs库。 | 布尔值 | 可缺省,缺省值为true。 |
| compressNativeLibs | 标识libs库是否以压缩存储的方式打包到HAP。<br/>-&nbsp;true:libs库以压缩方式存储。<br/>-&nbsp;false:libs库以不压缩方式存储,HAP在安装时无需解压libs,运行时会直接从HAP内加载libs库。 | 布尔值 | 可缺省,缺省值为true。 |
## deviceTypes标签
......
......@@ -370,6 +370,7 @@
- [@ohos.deviceInfo (设备信息)](js-apis-device-info.md)
- [@ohos.distributedHardware.deviceManager (设备管理)](js-apis-device-manager.md)
- [@ohos.geoLocationManager (位置服务)](js-apis-geoLocationManager.md)
- [@ohos.multimodalInput.gestureEvent (手势事件)](js-apis-multimodalinput-gestureevent.md)
- [@ohos.multimodalInput.inputConsumer (组合按键)](js-apis-inputconsumer.md)
- [@ohos.multimodalInput.inputDevice (输入设备)](js-apis-inputdevice.md)
- [@ohos.multimodalInput.inputDeviceCooperate (键鼠穿越)(待停用)](js-apis-cooperate.md)
......
......@@ -875,6 +875,382 @@ router.replaceUrl({
});
```
### pushNamedRoute
pushNamedRoute(options: NamedRouterOptions): Promise&lt;void&gt;
跳转到指定的命名路由页面。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | --------- |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | 是 | 跳转页面描述信息。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | --------- |
| Promise&lt;void&gt; | 异常返回结果。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。
| 错误码ID | 错误信息 |
| --------- | ------- |
| 100001 | if UI execution context not found. |
| 100003 | if the pages are pushed too much. |
| 100004 | if the named route is not exist. |
**示例:**
```ts
let router = uiContext.getRouter();
router.pushNamedRoute({
name: 'myPage',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
}
})
.then(() => {
// success
})
.catch(err => {
console.error(`pushNamedRoute failed, code is ${err.code}, message is ${err.message}`);
})
```
### pushNamedRoute
pushNamedRoute(options: NamedRouterOptions, callback: AsyncCallback&lt;void&gt;): void
跳转到指定的命名路由页面。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | --------- |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | 是 | 跳转页面描述信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异常响应回调。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。
| 错误码ID | 错误信息 |
| --------- | ------- |
| 100001 | if UI execution context not found. |
| 100003 | if the pages are pushed too much. |
| 100004 | if the named route is not exist. |
**示例:**
```ts
let router = uiContext.getRouter();
router.pushNamedRoute({
name: 'myPage',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
}
}, (err) => {
if (err) {
console.error(`pushNamedRoute failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info('pushNamedRoute success');
})
```
### pushNamedRoute
pushNamedRoute(options: NamedRouterOptions, mode: RouterMode): Promise&lt;void&gt;
跳转到指定的命名路由页面。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------- |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | 是 | 跳转页面描述信息。 |
| mode | [RouterMode](js-apis-router.md#routermode9) | 是 | 跳转页面使用的模式。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | --------- |
| Promise&lt;void&gt; | 异常返回结果。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。
| 错误码ID | 错误信息 |
| --------- | ------- |
| 100001 | if UI execution context not found. |
| 100003 | if the pages are pushed too much. |
| 100004 | if the named route is not exist. |
**示例:**
```ts
let router = uiContext.getRouter();
router.pushNamedRoute({
name: 'myPage',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
}
}, router.RouterMode.Standard)
.then(() => {
// success
})
.catch(err => {
console.error(`pushNamedRoute failed, code is ${err.code}, message is ${err.message}`);
})
```
### pushNamedRoute
pushNamedRoute(options: NamedRouterOptions, mode: RouterMode, callback: AsyncCallback&lt;void&gt;): void
跳转到指定的命名路由页面。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------- |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | 是 | 跳转页面描述信息。 |
| mode | [RouterMode](js-apis-router.md#routermode9) | 是 | 跳转页面使用的模式。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异常响应回调。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。
| 错误码ID | 错误信息 |
| --------- | ------- |
| 100001 | if UI execution context not found. |
| 100003 | if the pages are pushed too much. |
| 100004 | if the named route is not exist. |
**示例:**
```ts
let router = uiContext.getRouter();
router.pushNamedRoute({
name: 'myPage',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789]
}
}
}, router.RouterMode.Standard, (err) => {
if (err) {
console.error(`pushNamedRoute failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info('pushNamedRoute success');
})
```
### replaceNamedRoute
replaceNamedRoute(options: NamedRouterOptions): Promise&lt;void&gt;
用指定的命名路由页面替换当前页面,并销毁被替换的页面。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ------------------ |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | 是 | 替换页面描述信息。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | --------- |
| Promise&lt;void&gt; | 异常返回结果。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。
| 错误码ID | 错误信息 |
| --------- | ------- |
| 100001 | if UI execution context not found. |
| 100004 | if the named route is not exist. |
**示例:**
```ts
let router = uiContext.getRouter();
router.replaceNamedRoute({
name: 'myPage',
params: {
data1: 'message'
}
})
.then(() => {
// success
})
.catch(err => {
console.error(`replaceNamedRoute failed, code is ${err.code}, message is ${err.message}`);
})
```
### replaceNamedRoute
replaceNamedRoute(options: NamedRouterOptions, callback: AsyncCallback&lt;void&gt;): void
用指定的命名路由页面替换当前页面,并销毁被替换的页面。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ------------------ |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | 是 | 替换页面描述信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异常响应回调。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。
| 错误码ID | 错误信息 |
| --------- | ------- |
| 100001 | if UI execution context not found. |
| 100004 | if the named route is not exist. |
**示例:**
```ts
let router = uiContext.getRouter();
router.replaceNamedRoute({
name: 'myPage',
params: {
data1: 'message'
}
}, (err) => {
if (err) {
console.error(`replaceNamedRoute failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info('replaceNamedRoute success');
})
```
### replaceNamedRoute
replaceNamedRoute(options: NamedRouterOptions, mode: RouterMode): Promise&lt;void&gt;
用指定的命名路由页面替换当前页面,并销毁被替换的页面。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------- |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | 是 | 替换页面描述信息。 |
| mode | [RouterMode](js-apis-router.md#routermode9) | 是 | 跳转页面使用的模式。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | --------- |
| Promise&lt;void&gt; | 异常返回结果。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。
| 错误码ID | 错误信息 |
| --------- | ------- |
| 100001 | if can not get the delegate. |
| 100004 | if the named route is not exist. |
**示例:**
```ts
let router = uiContext.getRouter();
router.replaceNamedRoute({
name: 'myPage',
params: {
data1: 'message'
}
}, router.RouterMode.Standard)
.then(() => {
// success
})
.catch(err => {
console.error(`replaceNamedRoute failed, code is ${err.code}, message is ${err.message}`);
})
```
### replaceNamedRoute
replaceNamedRoute(options: NamedRouterOptions, mode: RouterMode, callback: AsyncCallback&lt;void&gt;): void
用指定的命名路由页面替换当前页面,并销毁被替换的页面。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------- | ---- | ---------- |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | 是 | 替换页面描述信息。 |
| mode | [RouterMode](js-apis-router.md#routermode9) | 是 | 跳转页面使用的模式。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 异常响应回调。 |
**错误码:**
以下错误码的详细介绍请参见[ohos.router(页面路由)](../errorcodes/errorcode-router.md)错误码。
| 错误码ID | 错误信息 |
| --------- | ------- |
| 100001 | if UI execution context not found. |
| 100004 | if the named route is not exist. |
**示例:**
```ts
let router = uiContext.getRouter();
router.replaceNamedRoute({
name: 'myPage',
params: {
data1: 'message'
}
}, router.RouterMode.Standard, (err) => {
if (err) {
console.error(`replaceNamedRoute failed, code is ${err.code}, message is ${err.message}`);
return;
}
console.info('replaceNamedRoute success');
});
```
### back
back(options?: RouterOptions ): void
......
......@@ -369,10 +369,6 @@ getEncoded(): DataBlob
**错误码:**
> **说明:**
>
> 从API version 10开始,该接口支持抛出错误码。
| 错误码ID | 错误信息 |
| -------- | ---------------------- |
| 801 | this operation is not supported. |
......@@ -794,8 +790,8 @@ createAsyKeyGenerator(algName: string): AsyKeyGenerator
| 错误码ID | 错误信息 |
| -------- | ---------------------- |
| 401 | invalid parameters. |
| 801<sup>10+</sup> | this operation is not supported. |
| 17620001<sup>10+</sup> | memory error. |
| 801 | this operation is not supported. |
| 17620001 | memory error. |
**示例:**
......@@ -837,7 +833,7 @@ generateKeyPair(callback: AsyncCallback\<KeyPair>): void
| -------- | ---------------------- |
| 401 | invalid parameters. |
| 17620001 | memory error. |
| 17630001<sup>10+</sup> | crypto operation error. |
| 17630001 | crypto operation error. |
**示例:**
......@@ -874,7 +870,7 @@ generateKeyPair(): Promise\<KeyPair>
| -------- | ---------------------- |
| 401 | invalid parameters. |
| 17620001 | memory error. |
| 17630001<sup>10+</sup> | crypto operation error. |
| 17630001 | crypto operation error. |
**示例:**
......@@ -912,7 +908,7 @@ convertKey(pubKey: DataBlob, priKey: DataBlob, callback: AsyncCallback\<KeyPair\
| -------- | ---------------------- |
| 401 | invalid parameters. |
| 17620001 | memory error. |
| 17630001<sup>10+</sup> | crypto operation error. |
| 17630001 | crypto operation error. |
**示例:**
......@@ -960,7 +956,7 @@ convertKey(pubKey: DataBlob, priKey: DataBlob): Promise\<KeyPair>
| -------- | ---------------------- |
| 401 | invalid parameters. |
| 17620001 | memory error. |
| 17630001<sup>10+</sup> | crypto operation error. |
| 17630001 | crypto operation error. |
**示例:**
......@@ -1315,7 +1311,7 @@ createCipher(transformation: string): Cipher
| -------- | ---------------------- |
| 401 | invalid parameters. |
| 801 | this operation is not supported. |
| 17620001<sup>10+</sup> | memory error. |
| 17620001 | memory error. |
**示例:**
......@@ -1837,8 +1833,8 @@ Sign实例生成。<br/>支持的规格详见框架概述“[签名验签规格]
| 错误码ID | 错误信息 |
| -------- | ---------------------- |
| 401 | invalid parameters. |
| 801<sup>10+</sup> | this operation is not supported. |
| 17620001<sup>10+</sup> | memory error. |
| 801 | this operation is not supported. |
| 17620001 | memory error. |
**示例:**
......@@ -2224,8 +2220,8 @@ Verify实例生成。<br/>支持的规格详见框架概述“[签名验签规
| 错误码ID | 错误信息 |
| -------- | ---------------------- |
| 401 | invalid parameters. |
| 801<sup>10+</sup> | this operation is not supported. |
| 17620001<sup>10+</sup> | memory error. |
| 801 | this operation is not supported. |
| 17620001 | memory error. |
**示例:**
......@@ -2570,8 +2566,8 @@ KeyAgreement实例生成。<br/>支持的规格详见框架概述“[密钥协
| 错误码ID | 错误信息 |
| -------- | ---------------------- |
| 401 | invalid parameters. |
| 801<sup>10+</sup> | this operation is not supported. |
| 17620001<sup>10+</sup> | memory error. |
| 801 | this operation is not supported. |
| 17620001 | memory error. |
**示例:**
......
......@@ -502,7 +502,7 @@ UDMF提供的数据操作接口可选项,包含intention和key两个可选参
| 名称 | 类型 | 可读 | 可写 | 必填 | 说明 |
|-----------|-------------------------|----|----|----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| intention | [Intention](#intention) | 是 | 是 | 否 | 表示数据操作相关的业务标签。 |
| key | string | 是 | 是 | 否 | UDMF中数据对象的唯一标识符。<br>由udmf:/、intention、bundleName和groupId四部分组成,以'/'连接,比如:udmf://DataHub/com.ohos.test/0123456789。<br>其中udmf:/固定,DataHub为对应枚举的取值,com.ohos.test为包名,0123456789为随机生成的groupId。 |
| key | string | 是 | 是 | 否 | UDMF中数据对象的唯一标识符,可通过[insertData](#udmfinsertdata)接口的返回值获取<br>由udmf:/、intention、bundleName和groupId四部分组成,以'/'连接,比如:udmf://DataHub/com.ohos.test/0123456789。<br>其中udmf:/固定,DataHub为对应枚举的取值,com.ohos.test为包名,0123456789为随机生成的groupId。 |
......
......@@ -50,7 +50,7 @@ import deviceInfo from '@ohos.deviceInfo'
| buildTime | string | 是 | 否 | 构建时间。 |
| buildRootHash | string | 是 | 否 | 构建版本Hash。 |
| udid<sup>7+</sup> | string | 是 | 否 | 设备Udid。<br/>**需要权限**:ohos.permission.sec.ACCESS_UDID|
| distributionOSName<sup>10+</sup> | String | 是 | 否 | 分布式操作系统名称。 |
| distributionOSVersion<sup>10+</sup> | String | 是 | 否 | 分布式操作系统版本号。 |
| distributionOSApiVersion<sup>10+</sup> | number| 是 | 否 | 分布式操作系统api版本。 |
| distributionOSName<sup>10+</sup> | String | 是 | 否 | 发行版系统名称。 |
| distributionOSVersion<sup>10+</sup> | String | 是 | 否 | 发行版系统版本号。 |
| distributionOSApiVersion<sup>10+</sup> | number| 是 | 否 | 发行版系统api版本。 |
| distributionOSReleaseType<sup>10+</sup> | String | 是 | 否 | 发行版系统类型。 |
......@@ -280,7 +280,6 @@ close(file: number|File): Promise&lt;void&gt;
let file = fs.openSync(filePath);
fs.close(file).then(() => {
console.info("close file succeed");
fs.closeSync(file);
}).catch((err) => {
console.info("close file failed with error message: " + err.message + ", error code: " + err.code);
});
......
......@@ -51,6 +51,10 @@ stat(path: string): Promise&lt;Stat&gt;
获取文件信息,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.stat](js-apis-file-fs.md#stat)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -83,6 +87,10 @@ stat(path: string, callback: AsyncCallback&lt;Stat&gt;): void
获取文件信息,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.stat](js-apis-file-fs.md#fsstat-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -107,6 +115,10 @@ statSync(path: string): Stat
以同步方法获取文件的信息。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.statSync](js-apis-file-fs.md#fsstatsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -136,6 +148,10 @@ opendir(path: string): Promise&lt;Dir&gt;
打开文件目录,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.listFile](js-apis-file-fs.md#fslistfile)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -161,13 +177,17 @@ opendir(path: string): Promise&lt;Dir&gt;
});
```
## fileio.opendir
opendir(path: string, callback: AsyncCallback&lt;Dir&gt;): void
打开文件目录,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.listFile](js-apis-file-fs.md#fslistfile-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -193,8 +213,11 @@ opendirSync(path: string): Dir
以同步方法打开文件目录。
**系统能力**:SystemCapability.FileManagement.File.FileIO
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.listFileSync](js-apis-file-fs.md#fslistfilesync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -223,6 +246,10 @@ access(path: string, mode?: number): Promise&lt;void&gt;
检查当前进程是否可访问某文件,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.access](js-apis-file-fs.md#fsaccess)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -256,6 +283,10 @@ access(path: string, mode?: number, callback: AsyncCallback&lt;void&gt;): void
检查当前进程是否可访问某文件,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.access](js-apis-file-fs.md#fsaccess-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -282,6 +313,10 @@ accessSync(path: string, mode?: number): void
以同步方法检查当前进程是否可访问某文件。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.accessSync](js-apis-file-fs.md#fsaccesssync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -309,6 +344,10 @@ close(fd: number): Promise&lt;void&gt;
关闭文件,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.close](js-apis-file-fs.md#fsclose)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -342,6 +381,10 @@ close(fd: number, callback: AsyncCallback&lt;void&gt;): void
关闭文件,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.close](js-apis-file-fs.md#fsclose-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -368,6 +411,10 @@ closeSync(fd: number): void
以同步方法关闭文件。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.closeSync](js-apis-file-fs.md#fsclosesync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -391,6 +438,10 @@ copyFile(src: string|number, dest: string|number, mode?: number): Promise&lt;voi
复制文件,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.copyFile](js-apis-file-fs.md#fscopyfile)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -426,6 +477,10 @@ copyFile(src: string|number, dest: string|number, mode: number, callback: AsyncC
复制文件,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.copyFile](js-apis-file-fs.md#fscopyfile-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -454,6 +509,10 @@ copyFileSync(src: string|number, dest: string|number, mode?: number): void
以同步方法复制文件。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.copyFileSync](js-apis-file-fs.md#fscopyfilesync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -479,6 +538,10 @@ mkdir(path: string, mode?: number): Promise&lt;void&gt;
创建目录,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.mkdir](js-apis-file-fs.md#fsmkdir)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -512,6 +575,10 @@ mkdir(path: string, mode: number, callback: AsyncCallback&lt;void&gt;): void
创建目录,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.mkdir](js-apis-file-fs.md#fsmkdir-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -538,6 +605,10 @@ mkdirSync(path: string, mode?: number): void
以同步方法创建目录。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.mkdirSync](js-apis-file-fs.md#fsmkdirsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -561,6 +632,10 @@ open(path: string, flags?: number, mode?: number): Promise&lt;number&gt;
打开文件,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.open](js-apis-file-fs.md#fsopen)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -595,6 +670,10 @@ open(path: string, flags: number, mode: number, callback: AsyncCallback&lt;numbe
打开文件,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.open](js-apis-file-fs.md#fsopen-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -622,6 +701,10 @@ openSync(path: string, flags?: number, mode?: number): number
以同步方法打开文件。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.openSync](js-apis-file-fs.md#fsopensync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -661,6 +744,10 @@ read(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?: numb
从文件读取数据,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.read](js-apis-file-fs.md#fsread)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -698,6 +785,10 @@ read(fd: number, buffer: ArrayBuffer, options: { offset?: number; length?: numbe
从文件读取数据,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.read](js-apis-file-fs.md#fsread-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -730,6 +821,10 @@ readSync(fd: number, buffer: ArrayBuffer, options?: { offset?: number; length?:
以同步方法从文件读取数据。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.readSync](js-apis-file-fs.md#fsreadsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -762,6 +857,10 @@ rmdir(path: string): Promise&lt;void&gt;
删除目录,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.rmdir](js-apis-file-fs.md#fsrmdir)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -794,6 +893,10 @@ rmdir(path: string, callback: AsyncCallback&lt;void&gt;): void
删除目录,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.rmdir](js-apis-file-fs.md#fsrmdir-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -820,6 +923,10 @@ rmdirSync(path: string): void
以同步方法删除目录。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.rmdirSync](js-apis-file-fs.md#fsrmdirsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -842,6 +949,10 @@ unlink(path: string): Promise&lt;void&gt;
删除文件,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.unlink](js-apis-file-fs.md#fsunlink)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -874,6 +985,10 @@ unlink(path: string, callback: AsyncCallback&lt;void&gt;): void
删除文件,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.unlink](js-apis-file-fs.md#fsunlink-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -899,6 +1014,10 @@ unlinkSync(path: string): void
以同步方法删除文件。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.unlinkSync](js-apis-file-fs.md#fsunlinksync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -921,6 +1040,10 @@ write(fd: number, buffer: ArrayBuffer|string, options?: { offset?: number; lengt
将数据写入文件,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.write](js-apis-file-fs.md#fswrite)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -956,6 +1079,10 @@ write(fd: number, buffer: ArrayBuffer|string, options: { offset?: number; length
将数据写入文件,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.write](js-apis-file-fs.md#fswrite-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -986,6 +1113,10 @@ writeSync(fd: number, buffer: ArrayBuffer|string, options?: { offset?: number; l
以同步方法将数据写入文件。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.writeSync](js-apis-file-fs.md#fswritesync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1017,6 +1148,10 @@ hash(path: string, algorithm: string): Promise&lt;string&gt;
计算文件的哈希值,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[hash.write](js-apis-file-hash.md#hashhash)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1050,6 +1185,10 @@ hash(path: string, algorithm: string, callback: AsyncCallback&lt;string&gt;): vo
计算文件的哈希值,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[hash.write](js-apis-file-hash.md#hashhash-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1078,6 +1217,10 @@ chmod(path: string, mode: number): Promise&lt;void&gt;
改变文件权限,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1111,6 +1254,10 @@ chmod(path: string, mode: number, callback: AsyncCallback&lt;void&gt;): void
改变文件权限,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1137,6 +1284,10 @@ chmodSync(path: string, mode: number): void
以同步方法改变文件权限。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1160,6 +1311,10 @@ fstat(fd: number): Promise&lt;Stat&gt;
基于文件描述符获取文件状态信息,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.stat](js-apis-file-fs.md#fsstat)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1193,6 +1348,10 @@ fstat(fd: number, callback: AsyncCallback&lt;Stat&gt;): void
基于文件描述符获取文件状态信息,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.stat](js-apis-file-fs.md#fsstat-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1219,6 +1378,10 @@ fstatSync(fd: number): Stat
以同步方法基于文件描述符获取文件状态信息。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.statSync](js-apis-file-fs.md#fsstatsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1248,6 +1411,10 @@ ftruncate(fd: number, len?: number): Promise&lt;void&gt;
基于文件描述符截断文件,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.truncate](js-apis-file-fs.md#fstruncate)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1282,6 +1449,10 @@ ftruncate(fd: number, len?: number, callback: AsyncCallback&lt;void&gt;): void
基于文件描述符截断文件,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.truncate](js-apis-file-fs.md#fstruncate-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1310,6 +1481,10 @@ ftruncateSync(fd: number, len?: number): void
以同步方法基于文件描述符截断文件。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.truncateSync](js-apis-file-fs.md#fstruncatesync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1335,6 +1510,10 @@ truncate(path: string, len?: number): Promise&lt;void&gt;
基于文件路径截断文件,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.truncate](js-apis-file-fs.md#fstruncate)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1369,6 +1548,10 @@ truncate(path: string, len?: number, callback: AsyncCallback&lt;void&gt;): void
基于文件路径截断文件,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.truncate](js-apis-file-fs.md#fstruncate-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1396,6 +1579,10 @@ truncateSync(path: string, len?: number): void
以同步方法基于文件路径截断文件。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.truncateSync](js-apis-file-fs.md#fstruncatesync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1420,6 +1607,10 @@ readText(filePath: string, options?: { position?: number; length?: number; encod
基于文本方式读取文件(即直接读取文件的文本内容),使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.readText](js-apis-file-fs.md#fsreadtext)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1453,6 +1644,10 @@ readText(filePath: string, options: { position?: number; length?: number; encodi
基于文本方式读取文件(即直接读取文件的文本内容),使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.readText](js-apis-file-fs.md#fsreadtext-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1479,6 +1674,10 @@ readTextSync(filePath: string, options?: { position?: number; length?: number; e
以同步方法基于文本方式读取文件(即直接读取文件的文本内容)。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.readTextSync](js-apis-file-fs.md#fsreadtextsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1508,6 +1707,10 @@ lstat(path: string): Promise&lt;Stat&gt;
获取链接信息,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.lstat](js-apis-file-fs.md#fslstat)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1540,6 +1743,10 @@ lstat(path: string, callback: AsyncCallback&lt;Stat&gt;): void
获取链接信息,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.lstat](js-apis-file-fs.md#fslstat-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1565,6 +1772,10 @@ lstatSync(path: string): Stat
以同步方法获取链接信息。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.lstatSync](js-apis-file-fs.md#fslstatsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1593,6 +1804,10 @@ rename(oldPath: string, newPath: string): Promise&lt;void&gt;
重命名文件,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.rename](js-apis-file-fs.md#fsrename)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1627,6 +1842,10 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback&lt;void&gt;): v
重命名文件,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.rename](js-apis-file-fs.md#fsrename-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1646,13 +1865,16 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback&lt;void&gt;): v
});
```
## fileio.renameSync<sup>7+</sup>
renameSync(oldPath: string, newPath: string): void
以同步方法重命名文件。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.renameSync](js-apis-file-fs.md#fsrenamesync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1677,6 +1899,10 @@ fsync(fd: number): Promise&lt;void&gt;
同步文件数据,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.fsync](js-apis-file-fs.md#fsfsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1710,6 +1936,10 @@ fsync(fd: number, callback: AsyncCallback&lt;void&gt;): void
同步文件数据,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.fsync](js-apis-file-fs.md#fsfsync-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1736,6 +1966,10 @@ fsyncSync(fd: number): void
以同步方法同步文件数据。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.fsyncSync](js-apis-file-fs.md#fsfsyncsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1759,6 +1993,10 @@ fdatasync(fd: number): Promise&lt;void&gt;
实现文件内容数据同步,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.fdatasync](js-apis-file-fs.md#fsfdatasync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1792,6 +2030,10 @@ fdatasync(fd: number, callback: AsyncCallback&lt;void&gt;): void
实现文件内容数据同步,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.fdatasync](js-apis-file-fs.md#fsfdatasync-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1818,6 +2060,10 @@ fdatasyncSync(fd: number): void
以同步方法实现文件内容数据同步。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.fdatasyncSync](js-apis-file-fs.md#fsfdatasyncsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1841,6 +2087,10 @@ symlink(target: string, srcPath: string): Promise&lt;void&gt;
基于文件路径创建符号链接,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.symlink](js-apis-file-fs.md#fssymlink)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1875,6 +2125,10 @@ symlink(target: string, srcPath: string, callback: AsyncCallback&lt;void&gt;): v
基于文件路径创建符号链接,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.symlink](js-apis-file-fs.md#fssymlink-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1902,6 +2156,10 @@ symlinkSync(target: string, srcPath: string): void
以同步的方法基于文件路径创建符号链接。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.symlinkSync](js-apis-file-fs.md#fssymlinksync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1926,6 +2184,10 @@ chown(path: string, uid: number, gid: number): Promise&lt;void&gt;
基于文件路径改变文件所有者,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1961,6 +2223,10 @@ chown(path: string, uid: number, gid: number, callback: AsyncCallback&lt;void&gt
基于文件路径改变文件所有者,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -1982,13 +2248,16 @@ chown(path: string, uid: number, gid: number, callback: AsyncCallback&lt;void&gt
});
```
## fileio.chownSync<sup>7+</sup>
chownSync(path: string, uid: number, gid: number): void
以同步的方法基于文件路径改变文件所有者。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2014,6 +2283,10 @@ mkdtemp(prefix: string): Promise&lt;string&gt;
创建临时目录,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.mkdtemp](js-apis-file-fs.md#fsmkdtemp)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2045,6 +2318,10 @@ mkdtemp(prefix: string, callback: AsyncCallback&lt;string&gt;): void
创建临时目录,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.mkdtemp](js-apis-file-fs.md#fsmkdtemp-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2069,6 +2346,10 @@ mkdtempSync(prefix: string): string
以同步的方法创建临时目录。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.mkdtempSync](js-apis-file-fs.md#fsmkdtempsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2096,6 +2377,10 @@ fchmod(fd: number, mode: number): Promise&lt;void&gt;
基于文件描述符改变文件权限,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2131,6 +2416,10 @@ fchmod(fd: number, mode: number, callback: AsyncCallback&lt;void&gt;): void
基于文件描述符改变文件权限,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2159,6 +2448,10 @@ fchmodSync(fd: number, mode: number): void
以同步方法基于文件描述符改变文件权限。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2184,6 +2477,10 @@ createStream(path: string, mode: string): Promise&lt;Stream&gt;
基于文件路径打开文件流,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.createStream](js-apis-file-fs.md#fscreatestream)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2217,6 +2514,10 @@ createStream(path: string, mode: string, callback: AsyncCallback&lt;Stream&gt;):
基于文件路径打开文件流,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.createStream](js-apis-file-fs.md#fscreatestream-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2243,6 +2544,10 @@ createStreamSync(path: string, mode: string): Stream
以同步方法基于文件路径打开文件流。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.createStreamSync](js-apis-file-fs.md#fscreatestreamsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2272,6 +2577,10 @@ fdopenStream(fd: number, mode: string): Promise&lt;Stream&gt;
基于文件描述符打开文件流,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.fdopenStream](js-apis-file-fs.md#fsfdopenstream)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2306,6 +2615,10 @@ fdopenStream(fd: number, mode: string, callback: AsyncCallback&lt;Stream&gt;): v
基于文件描述符打开文件流,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.fdopenStream](js-apis-file-fs.md#fsfdopenstream-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2333,6 +2646,10 @@ fdopenStreamSync(fd: number, mode: string): Stream
以同步方法基于文件描述符打开文件流。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.fdopenStreamSync](js-apis-file-fs.md#fsfdopenstreamsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2363,6 +2680,10 @@ fchown(fd: number, uid: number, gid: number): Promise&lt;void&gt;
基于文件描述符改变文件所有者,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2399,6 +2720,10 @@ fchown(fd: number, uid: number, gid: number, callback: AsyncCallback&lt;void&gt;
基于文件描述符改变文件所有者,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2428,6 +2753,10 @@ fchownSync(fd: number, uid: number, gid: number): void
以同步方法基于文件描述符改变文件所有者。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2454,6 +2783,10 @@ lchown(path: string, uid: number, gid: number): Promise&lt;void&gt;
基于文件路径改变文件所有者,更改符号链接本身的所有者,而不是符号链接所指向的实际文件,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2489,6 +2822,10 @@ lchown(path: string, uid: number, gid: number, callback: AsyncCallback&lt;void&g
基于文件路径改变文件所有者,更改符号链接本身的所有者,而不是更改符号链接所指向的实际文件,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2517,6 +2854,10 @@ lchownSync(path: string, uid: number, gid: number): void
以同步方法基于文件路径改变文件所有者,更改符号链接本身的所有者,而不是更改符号链接所指向的实际文件。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2573,6 +2914,10 @@ createWatcher(filename: string, events: number, callback: AsyncCallback&lt;numbe
仅用于read方法,获取文件的读取结果。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.File.FileIO。
| 名称 | 类型 | 可读 | 可写 | 说明 |
......@@ -2586,6 +2931,10 @@ createWatcher(filename: string, events: number, callback: AsyncCallback&lt;numbe
文件具体信息,在调用Stat的方法前,需要先通过[stat()](#fileiostat)方法(同步或异步)来构建一个Stat实例。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stat](js-apis-file-fs.md#stat)替代。
**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.File.FileIO。
### 属性
......@@ -2612,6 +2961,10 @@ isBlockDevice(): boolean
用于判断文件是否是块特殊文件。一个块特殊文件只能以块为粒度进行访问,且访问的时候带缓存。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stat.isBlockDevice](js-apis-file-fs.md#isblockdevice)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -2634,6 +2987,10 @@ isCharacterDevice(): boolean
用于判断文件是否是字符特殊文件。一个字符特殊设备可进行随机访问,且访问的时候不带缓存。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stat.isCharacterDevice](js-apis-file-fs.md#ischaracterdevice)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -2656,6 +3013,10 @@ isDirectory(): boolean
用于判断文件是否是目录。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stat.isDirectory](js-apis-file-fs.md#isdirectory)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -2678,6 +3039,10 @@ isFIFO(): boolean
用于判断文件是否是命名管道(有时也称为FIFO)。命名管道通常用于进程间通信。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stat.isFIFO](js-apis-file-fs.md#isfifo)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -2700,6 +3065,10 @@ isFile(): boolean
用于判断文件是否是普通文件。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stat.isFile](js-apis-file-fs.md#isfile)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -2722,6 +3091,10 @@ isSocket(): boolean
用于判断文件是否是套接字。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stat.isSocket](js-apis-file-fs.md#issocket)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -2744,6 +3117,10 @@ isSymbolicLink(): boolean
用于判断文件是否是符号链接。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stat.isSymbolicLink](js-apis-file-fs.md#issymboliclink)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -2817,6 +3194,9 @@ stop(callback: AsyncCallback&lt;void&gt;): void
文件流,在调用Stream的方法前,需要先通过createStream()方法(同步或异步)来构建一个Stream实例。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream](js-apis-file-fs.md#stream)替代。
### close<sup>7+</sup>
......@@ -2824,6 +3204,10 @@ close(): Promise&lt;void&gt;
关闭文件流,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.close](js-apis-file-fs.md#close)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -2851,6 +3235,10 @@ close(callback: AsyncCallback&lt;void&gt;): void
异步关闭文件流,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.close](js-apis-file-fs.md#close-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2876,6 +3264,10 @@ closeSync(): void
同步关闭文件流。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.closeSync](js-apis-file-fs.md#closesync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**示例:**
......@@ -2893,6 +3285,10 @@ flush(): Promise&lt;void&gt;
刷新文件流,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.flush](js-apis-file-fs.md#flush)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -2920,6 +3316,10 @@ flush(callback: AsyncCallback&lt;void&gt;): void
异步刷新文件流,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.flush](js-apis-file-fs.md#flush-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2945,6 +3345,10 @@ flushSync(): void
同步刷新文件流。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.flushSync](js-apis-file-fs.md#flushsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**示例:**
......@@ -2962,6 +3366,10 @@ write(buffer: ArrayBuffer|string, options?: { offset?: number; length?: number;
将数据写入流文件,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.write](js-apis-file-fs.md#write)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -2996,6 +3404,10 @@ write(buffer: ArrayBuffer|string, options: { offset?: number; length?: number; p
将数据写入流文件,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.write](js-apis-file-fs.md#write-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -3026,6 +3438,10 @@ writeSync(buffer: ArrayBuffer|string, options?: { offset?: number; length?: numb
以同步方法将数据写入流文件。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.writeSync](js-apis-file-fs.md#writesync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -3056,6 +3472,10 @@ read(buffer: ArrayBuffer, options?: { position?: number; offset?: number; length
从流文件读取数据,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.read](js-apis-file-fs.md#read)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -3091,6 +3511,10 @@ read(buffer: ArrayBuffer, options: { position?: number; offset?: number; length?
从流文件读取数据,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.read](js-apis-file-fs.md#read-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -3121,6 +3545,10 @@ readSync(buffer: ArrayBuffer, options?: { position?: number; offset?: number; le
以同步方法从流文件读取数据。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.Stream.readSync](js-apis-file-fs.md#readsync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -3149,6 +3577,9 @@ readSync(buffer: ArrayBuffer, options?: { position?: number; offset?: number; le
管理目录,在调用Dir的方法前,需要先通过opendir方法(同步或异步)来构建一个Dir实例。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.listFile](js-apis-file-fs.md#fslistfile)替代。
### read
......@@ -3156,6 +3587,10 @@ read(): Promise&lt;Dirent&gt;
读取下一个目录项,使用Promise异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.listFile](js-apis-file-fs.md#fslistfile)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -3181,6 +3616,10 @@ read(callback: AsyncCallback&lt;Dirent&gt;): void
读取下一个目录项,使用callback异步回调。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.listFile](js-apis-file-fs.md#fslistfile-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
......@@ -3207,6 +3646,10 @@ readSync(): Dirent
同步读取下一个目录项。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.listFileSync](js-apis-file-fs.md#fslistfilesync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -3228,6 +3671,10 @@ close(): Promise&lt;void&gt;
异步关闭目录,使用promise形式返回结果。目录被关闭后,Dir中持有的文件描述将被释放,后续将无法从Dir中读取目录项。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.listFile](js-apis-file-fs.md#fslistfile)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**示例:**
......@@ -3239,12 +3686,16 @@ close(): Promise&lt;void&gt;
```
### close<sup>7+</sup>
### close<sup>7+</sup>
close(callback: AsyncCallback&lt;void&gt;): void
异步关闭目录,使用callback形式返回结果。目录被关闭后,Dir中持有的文件描述将被释放,后续将无法从Dir中读取目录项。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.listFile](js-apis-file-fs.md#fslistfile-1)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**示例:**
......@@ -3262,6 +3713,10 @@ closeSync(): void
用于关闭目录。目录被关闭后,Dir中持有的文件描述将被释放,后续将无法从Dir中读取目录项。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.listFileSync](js-apis-file-fs.md#fslistfilesync)替代。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**示例:**
......@@ -3275,6 +3730,10 @@ closeSync(): void
在调用Dirent的方法前,需要先通过[dir.read()](#read)方法(同步或异步)来构建一个Dirent实例。
> **说明**:
>
> 从API version 9开始废弃,请使用[fs.listFile](js-apis-file-fs.md#fslistfile)替代。
**系统能力**:以下各项对应的系统能力均为SystemCapability.FileManagement.File.FileIO。
### 属性
......@@ -3290,6 +3749,10 @@ isBlockDevice(): boolean
用于判断当前目录项是否是块特殊文件。一个块特殊文件只能以块为粒度进行访问,且访问的时候带缓存。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -3312,6 +3775,10 @@ isCharacterDevice(): boolean
用于判断当前目录项是否是字符特殊设备。一个字符特殊设备可进行随机访问,且访问的时候不带缓存。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -3334,6 +3801,10 @@ isDirectory(): boolean
用于判断当前目录项是否是目录。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -3356,6 +3827,10 @@ isFIFO(): boolean
用于判断当前目录项是否是命名管道(有时也称为FIFO)。命名管道通常用于进程间通信。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -3378,6 +3853,10 @@ isFile(): boolean
用于判断当前目录项是否是普通文件。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -3400,6 +3879,10 @@ isSocket(): boolean
用于判断当前目录项是否是套接字。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......@@ -3422,6 +3905,10 @@ isSymbolicLink(): boolean
用于判断当前目录项是否是符号链接。
> **说明**:
>
> 从API version 9开始废弃。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**返回值:**
......
......@@ -1692,11 +1692,11 @@ off(type: 'insertText'): void
inputMethodController.off('insertText');
```
### on('deleteLeft' | 'deleteRight')<sup>10+</sup>
### on('deleteLeft')<sup>10+</sup>
on(type: 'deleteLeft' | 'deleteRight', callback: (length: number) => void): void
on(type: 'deleteLeft', callback: (length: number) => void): void
订阅输入法应用向左删除或向右删除事件。使用callback异步回调。
订阅输入法应用向左删除事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -1704,8 +1704,8 @@ on(type: 'deleteLeft' | 'deleteRight', callback: (length: number) => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----- | ---- | ----- |
| type | string | 是 | 设置监听类型。<br/>- type为‘deleteLeft’时表示订阅输入法应用向左删除事件监听。 <br/>- type为‘deleteRight’时表示订阅输入法应用向右删除事件监听。|
| callback | (length: number) => void | 是 | 回调函数,返回需要向左或向右删除的文本的长度。<br/>开发者需要在回调函数中根据传入的删除长度操作编辑框中相应文本。 |
| type | string | 是 | 设置监听类型。<br/>- type为`deleteLeft`表示订阅输入法应用向左删除事件监听。 |
| callback | (length: number) => void | 是 | 回调函数,返回需要向左删除的文本的长度。<br/>开发者需要在回调函数中根据传入的删除长度操作编辑框中相应文本。 |
**错误码:**
......@@ -1725,7 +1725,34 @@ try {
} catch(err) {
console.error(`Failed to subscribe deleteLeft: ${JSON.stringify(err)}`);
}
```
### on('deleteRight')<sup>10+</sup>
on(type: 'deleteRight', callback: (length: number) => void): void
订阅输入法应用向右删除事件。使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----- | ---- | ----- |
| type | string | 是 | 设置监听类型。<br/>- type为`deleteRight`表示订阅输入法应用向右删除事件监听。|
| callback | (length: number) => void | 是 | 回调函数,返回需要向右删除的文本的长度。<br/>开发者需要在回调函数中根据传入的删除长度操作编辑框中相应文本。 |
**错误码:**
以下错误码的详细介绍请参见[输入法框架错误码](../errorcodes/errorcode-inputmethod-framework.md)
| 错误码ID | 错误信息 |
| -------- | -------------------------------------- |
| 12800009 | input method client is detached. |
**示例:**
```js
try {
inputMethodController.on('deleteRight', (length) => {
console.log(`Succeeded in subscribing deleteRight, length: ${length}`);
......@@ -1734,12 +1761,11 @@ try {
console.error(`Failed to subscribe deleteRight: ${JSON.stringify(err)}`);
}
```
### off('deleteLeft')<sup>10+</sup>
### off('deleteLeft' | 'deleteRight')<sup>10+</sup>
off(type: 'deleteLeft'): void
off(type: 'deleteLeft' | 'deleteRight'): void
取消订阅输入法应用向左或向右删除文本事件。
取消订阅输入法应用向左删除文本事件。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -1747,12 +1773,31 @@ off(type: 'deleteLeft' | 'deleteRight'): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>- type为‘deleteLeft’时表示取消订阅输入法应用向左删除的事件监听。 <br/>- type为‘deleteRight’时表示取消订阅输入法应用向右删除的事件监听。|
| type | string | 是 | 设置监听类型。<br/>- type为`deleteLeft`表示取消订阅输入法应用向左删除的事件监听。|
**示例:**
```js
inputMethodController.off('deleteLeft');
```
### off('deleteRight')<sup>10+</sup>
off(type: 'deleteRight'): void
取消订阅输入法应用向右删除文本事件。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| type | string | 是 | 设置监听类型。<br/>- type为`deleteRight`表示取消订阅输入法应用向右删除的事件监听。|
**示例:**
```js
inputMethodController.off('deleteRight');
```
......@@ -2110,11 +2155,11 @@ off(type: 'imeChange', callback?: (inputMethodProperty: InputMethodProperty, inp
inputMethodSetting.off('imeChange');
```
### on('imeShow'|'imeHide')<sup>10+</sup>
### on('imeShow')<sup>10+</sup>
on(type: 'imeShow'|'imeHide', callback: (info: Array\<InputWindowInfo>) => void): void
on(type: 'imeShow', callback: (info: Array\<InputWindowInfo>) => void): void
订阅输入法软键盘显示或隐藏事件。使用callback异步回调。
订阅输入法软键盘显示事件。使用callback异步回调。
**系统接口**:此接口为系统接口。
......@@ -2124,7 +2169,7 @@ on(type: 'imeShow'|'imeHide', callback: (info: Array\<InputWindowInfo>) => void)
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---- | ---- | ---- |
| type | string | 是 | 设置监听类型。<br/>- type为`imeShow`时表示订阅输入法软键盘显示事件。<br/>- type为`imeHide`时表示订阅输入法软键盘隐藏事件。 |
| type | string | 是 | 设置监听类型。<br/>- type为`imeShow`表示订阅输入法软键盘显示事件。 |
| callback | (info: Array\<InputWindowInfo>) => void | 是 | 回调函数,返回输入法软键盘信息。 |
**示例:**
......@@ -2135,11 +2180,36 @@ inputMethodSetting.on('imeShow', (info) => {
});
```
### off('imeShow'|'imeHide')<sup>10+</sup>
### on('imeHide')<sup>10+</sup>
off(type: 'imeShow'|'imeHide', callback?: (info: Array\<InputWindowInfo>) => void): void
on(type: 'imeHide', callback: (info: Array\<InputWindowInfo>) => void): void
取消订阅输入法软键盘显示或隐藏事件。
订阅输入法软键盘隐藏事件。使用callback异步回调。
**系统接口**:此接口为系统接口。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---- | ---- | ---- |
| type | string | 是 | 设置监听类型。<br/>- type为`imeHide`表示订阅输入法软键盘隐藏事件。 |
| callback | (info: Array\<InputWindowInfo>) => void | 是 | 回调函数,返回输入法软键盘信息。 |
**示例:**
```js
inputMethodSetting.on('imeHide', (info) => {
console.info('Succeeded in subscribing imeHide event.');
});
```
### off('imeShow')<sup>10+</sup>
off(type: 'imeShow', callback?: (info: Array\<InputWindowInfo>) => void): void
取消订阅输入法软键盘显示事件。
**系统接口**:此接口为系统接口。
......@@ -2149,7 +2219,7 @@ off(type: 'imeShow'|'imeHide', callback?: (info: Array\<InputWindowInfo>) => voi
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---- | ---- | ------ |
| type | string | 是 | 设置监听类型。<br/>- type为`imeShow`时表示取消订阅输入法软键盘显示事件。<br/>- type为`imeHide`时表示取消订阅输入法软键盘隐藏事件。 |
| type | string | 是 | 设置监听类型。<br/>- type为`imeShow`表示取消订阅输入法软键盘显示事件。 |
| callback | (info: Array\<InputWindowInfo>) => void | 否 | 取消订阅的回调函数。当该参数不填写时,取消订阅type对应的所有回调事件。 |
**示例:**
......@@ -2158,6 +2228,29 @@ off(type: 'imeShow'|'imeHide', callback?: (info: Array\<InputWindowInfo>) => voi
inputMethodSetting.off('imeShow');
```
### off('imeHide')<sup>10+</sup>
off(type: 'imeHide', callback?: (info: Array\<InputWindowInfo>) => void): void
取消订阅输入法软键盘隐藏事件。
**系统接口**:此接口为系统接口。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---- | ---- | ------ |
| type | string | 是 | 设置监听类型。<br/>- type为`imeHide`表示取消订阅输入法软键盘隐藏事件。 |
| callback | (info: Array\<InputWindowInfo>) => void | 否 | 取消订阅的回调函数。当该参数不填写时,取消订阅type对应的所有回调事件。 |
**示例:**
```js
inputMethodSetting.off('imeHide');
```
### listInputMethodSubtype<sup>9+</sup>
listInputMethodSubtype(inputMethodProperty: InputMethodProperty, callback: AsyncCallback&lt;Array&lt;InputMethodSubtype&gt;&gt;): void
......
......@@ -1258,11 +1258,11 @@ promise.then(() => {
});
```
### on<sup>10+</sup>
### on('show')<sup>10+</sup>
on(type: 'show' | 'hide', callback: () => void): void
on(type: 'show', callback: () => void): void
监听当前面板状态,使用callback异步回调。
监听当前面板显示状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -1270,7 +1270,7 @@ on(type: 'show' | 'hide', callback: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | -------- |
| type | 'show'\|'hide' | 是 | 监听当前面板的状态类型,show表示显示状态,hide表示隐藏状态 |
| type | string | 是 | 监听当前面板的状态类型。 <br/>- type为`show`表示显示状态。 |
| callback | () => void | 是 | 回调函数。 |
**示例:**
......@@ -1281,11 +1281,11 @@ panel.on('show', () => {
});
```
### off<sup>10+</sup>
### on('hide')<sup>10+</sup>
off(type: 'show' | 'hide', callback?: () => void): void
on(type: 'hide', callback: () => void): void
取消监听当前面板状态,使用callback异步回调。
监听当前面板隐藏状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
......@@ -1293,7 +1293,30 @@ off(type: 'show' | 'hide', callback?: () => void): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | -------- |
| type | 'show'\|'hide' | 是 | 要取消监听的当前面板状态类型,show表示显示状态,hide表示隐藏状态 |
| type | string | 是 | 监听当前面板的状态类型。 <br/>- type为`hide`表示隐藏状态。 |
| callback | () => void | 是 | 回调函数。 |
**示例:**
```js
panel.on('hide', () => {
console.log('Panel is hiding.');
});
```
### off('show')<sup>10+</sup>
off(type: 'show', callback?: () => void): void
取消监听当前面板显示状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | -------- |
| type | string | 是 | 要取消监听的当前面板状态类型。 <br/>- type为`show`表示显示状态。 |
| callback | () => void | 否 | 回调函数。 |
**示例:**
......@@ -1302,6 +1325,27 @@ off(type: 'show' | 'hide', callback?: () => void): void
panel.off('show');
```
### off('hide')<sup>10+</sup>
off(type: 'hide', callback?: () => void): void
取消监听当前面板隐藏状态,使用callback异步回调。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | -------- |
| type | string | 是 | 要取消监听的当前面板状态类型。 <br/>- type为`hide`表示隐藏状态。 |
| callback | () => void | 否 | 回调函数。 |
**示例:**
```js
panel.off('hide');
```
### changeFlag<sup>10+</sup>
changeFlag(flag: PanelFlag): void
......
# @ohos.multimodalInput.inputMonitor (输入监听)
输入监听模块,提供了监听输入设备事件(当前支持触摸屏和鼠标)的能力。
输入监听模块,提供了监听输入设备事件(当前支持触屏、鼠标和触控板手势)的能力。
> **说明:**
>
......@@ -17,11 +17,11 @@ import inputMonitor from '@ohos.multimodalInput.inputMonitor';
```
## inputMonitor.on
## inputMonitor.on('touch')
on(type: "touch", receiver: TouchEventReceiver): void
on(type: 'touch', receiver: TouchEventReceiver): void
开始监听全局触屏事件。
监听全局触屏事件。
**需要权限:** ohos.permission.INPUT_MONITORING
......@@ -38,7 +38,7 @@ on(type: "touch", receiver: TouchEventReceiver): void
```js
try {
inputMonitor.on("touch", (touchEvent) => {
inputMonitor.on('touch', (touchEvent) => {
console.log(`Monitor on success ${JSON.stringify(touchEvent)}`);
return false;
});
......@@ -47,11 +47,11 @@ try {
}
```
## inputMonitor.on<sup>9+</sup>
## inputMonitor.on('mouse')<sup>9+</sup>
on(type: "mouse", receiver: Callback&lt;MouseEvent&gt;): void
on(type: 'mouse', receiver: Callback&lt;MouseEvent&gt;): void
开始监听全局鼠标事件。
监听全局鼠标事件。
**需要权限:** ohos.permission.INPUT_MONITORING
......@@ -68,7 +68,7 @@ on(type: "mouse", receiver: Callback&lt;MouseEvent&gt;): void
```js
try {
inputMonitor.on("mouse", (mouseEvent) => {
inputMonitor.on('mouse', (mouseEvent) => {
console.log(`Monitor on success ${JSON.stringify(mouseEvent)}`);
return false;
});
......@@ -79,11 +79,11 @@ try {
## inputMonitor.off
## inputMonitor.off('touch')
off(type: "touch", receiver?: TouchEventReceiver): void
off(type: 'touch', receiver?: TouchEventReceiver): void
停止监听全局触屏事件。
取消监听全局触屏事件。
**需要权限:** ohos.permission.INPUT_MONITORING
......@@ -105,8 +105,8 @@ function callback(touchEvent) {
return false;
};
try {
inputMonitor.on("touch", callback);
inputMonitor.off("touch", callback);
inputMonitor.on('touch', callback);
inputMonitor.off('touch', callback);
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
......@@ -120,19 +120,19 @@ function callback(touchEvent) {
return false;
};
try {
inputMonitor.on("touch", callback);
inputMonitor.off("touch");
inputMonitor.on('touch', callback);
inputMonitor.off('touch');
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.off<sup>9+</sup>
## inputMonitor.off('mouse')<sup>9+</sup>
off(type: "mouse", receiver?: Callback&lt;MouseEvent&gt;): void
off(type: 'mouse', receiver?: Callback&lt;MouseEvent&gt;): void
停止监听全局鼠标事件。
取消监听全局鼠标事件。
**需要权限:** ohos.permission.INPUT_MONITORING
......@@ -154,8 +154,8 @@ function callback(mouseEvent) {
return false;
};
try {
inputMonitor.on("mouse", callback);
inputMonitor.off("mouse", callback);
inputMonitor.on('mouse', callback);
inputMonitor.off('mouse', callback);
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
......@@ -169,8 +169,8 @@ function callback(mouseEvent) {
return false;
};
try {
inputMonitor.on("mouse", callback);
inputMonitor.off("mouse");
inputMonitor.on('mouse', callback);
inputMonitor.off('mouse');
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
......@@ -201,7 +201,7 @@ try {
```js
try {
inputMonitor.on("touch", touchEvent => {
inputMonitor.on('touch', touchEvent => {
if (touchEvent.touches.length == 3) { // 当前有三个手指按下
return true;
}
......@@ -211,3 +211,240 @@ try {
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.on('pinch')<sup>10+</sup>
on(type: 'pinch', receiver: Callback&lt;[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)&gt;): void
监听全局的触控板捏合事件。
**需要权限:** ohos.permission.INPUT_MONITORING
**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | 是 | 输入设备事件类型,取值“pinch”。 |
| receiver | Callback&lt;[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)&gt; | 是 | 回调函数,异步上报捏合输入事件。 |
**示例:**
```js
try {
inputMonitor.on('pinch', (pinchEvent) => {
console.log(`Monitor on success ${JSON.stringify(pinchEvent)}`);
return false;
});
} catch (error) {
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.off('pinch')<sup>10+</sup>
off(type: 'pinch', receiver?: Callback&lt;[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)&gt;): void
取消监听全局的触控板捏合事件。
**需要权限:** ohos.permission.INPUT_MONITORING
**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | 是 | 输入设备事件类型,取值“pinch”。 |
| receiver | Callback&lt;[Pinch](js-apis-multimodalinput-gestureevent.md#pinch)&gt; | 否 | 需要取消监听的回调函数,若无此参数,则取消当前应用监听的所有回调函数。 |
**示例:**
```js
// 取消监听单个回调函数
function callback(pinchEvent) {
console.log(`Monitor on success ${JSON.stringify(pinchEvent)}`);
return false;
};
try {
inputMonitor.on('pinch', callback);
inputMonitor.off('pinch', callback);
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
```js
// 取消监听所有回调函数
function callback(pinchEvent) {
console.log(`Monitor on success ${JSON.stringify(pinchEvent)}`);
return false;
};
try {
inputMonitor.on('pinch', callback);
inputMonitor.off('pinch');
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.on('threeFingersSwipe')<sup>10+</sup>
on(type: 'threeFingersSwipe', receiver: Callback&lt;[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)&gt;): void
监听全局的触控板三指滑动事件。
**需要权限:** ohos.permission.INPUT_MONITORING
**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | 是 | 输入设备事件类型,取值“threeFingersSwipe”。 |
| receiver | Callback&lt;[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)&gt; | 是 | 回调函数,异步上报三指滑动输入事件。 |
**示例:**
```js
try {
inputMonitor.on('threeFingersSwipe', (threeFingersSwipe) => {
console.log(`Monitor on success ${JSON.stringify(threeFingersSwipe)}`);
return false;
});
} catch (error) {
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.off('threeFingersSwipe')<sup>10+</sup>
off(type: 'threeFingersSwipe', receiver?: Callback&lt;[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)&gt;): void
取消监听全局的触控板三指滑动事件。
**需要权限:** ohos.permission.INPUT_MONITORING
**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | 是 | 输入设备事件类型,取值“threeFingersSwipe”。 |
| receiver | Callback&lt;[ThreeFingersSwipe](js-apis-multimodalinput-gestureevent.md#threefingersswipe)&gt; | 否 | 需要取消监听的回调函数,若无此参数,则取消当前应用监听的所有回调函数。 |
**示例:**
```js
// 取消监听单个回调函数
function callback(threeFingersSwipe) {
console.log(`Monitor on success ${JSON.stringify(threeFingersSwipe)}`);
return false;
};
try {
inputMonitor.on('threeFingersSwipe', callback);
inputMonitor.off("threeFingersSwipe", callback);
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
```js
// 取消监听所有回调函数
function callback(threeFingersSwipe) {
console.log(`Monitor on success ${JSON.stringify(threeFingersSwipe)}`);
return false;
};
try {
inputMonitor.on("threeFingersSwipe", callback);
inputMonitor.off("threeFingersSwipe");
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.on('fourFingersSwipe')<sup>10+</sup>
on(type: 'fourFingersSwipe', receiver: Callback&lt;[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)&gt;): void
监听全局的触控板四指滑动事件。
**需要权限:** ohos.permission.INPUT_MONITORING
**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | 是 | 输入设备事件类型,取值“fourFingersSwipe”。 |
| receiver | Callback&lt;[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)&gt; | 是 | 回调函数,异步上报四指滑动输入事件。 |
**示例:**
```js
try {
inputMonitor.on('fourFingersSwipe', (fourFingersSwipe) => {
console.log(`Monitor on success ${JSON.stringify(fourFingersSwipe)}`);
return false;
});
} catch (error) {
console.log(`Monitor on failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
## inputMonitor.off('fourFingersSwipe')<sup>10+</sup>
off(type: 'fourFingersSwipe', receiver?: Callback&lt;[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)&gt;): void
取消监听全局的触控板四指滑动事件。
**需要权限:** ohos.permission.INPUT_MONITORING
**系统能力:** SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ------------------- |
| type | string | 是 | 输入设备事件类型,取值“fourFingersSwipe”。 |
| receiver | Callback&lt;[FourFingersSwipe](js-apis-multimodalinput-gestureevent.md#fourfingersswipe)&gt; | 否 | 需要取消监听的回调函数,若无此参数,则取消当前应用监听的所有回调函数。 |
**示例:**
```js
// 取消监听单个回调函数
function callback(fourFingersSwipe) {
console.log(`Monitor on success ${JSON.stringify(fourFingersSwipe)}`);
return false;
};
try {
inputMonitor.on('fourFingersSwipe', callback);
inputMonitor.off('fourFingersSwipe', callback);
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
```js
// 取消监听所有回调函数
function callback(fourFingersSwipe) {
console.log(`Monitor on success ${JSON.stringify(fourFingersSwipe)}`);
return false;
};
try {
inputMonitor.on('fourFingersSwipe', callback);
inputMonitor.off('fourFingersSwipe');
console.log(`Monitor off success`);
} catch (error) {
console.log(`Monitor execute failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
```
# @ohos.multimodalInput.gestureEvent (手势输入事件)
设备上报的手势事件。
> **说明:**
>
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```js
import { Pinch, ThreeFingersSwipe, FourFingersSwipe, ActionType } from '@ohos.multimodalInput.gestureEvent';
```
## Pinch
捏合事件。
**系统能力**:SystemCapability.MultimodalInput.Input.Core
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | ----------- | ---- | ---- | ---------------------------------------- |
| type | [ActionType](#actiontype) | 是 | 否 | 捏合事件类型 |
| scale | number | 是 | 否 | 捏合度,取值范围大于等于0 |
## ThreeFingersSwipe
三指滑动事件。
**系统能力**:SystemCapability.MultimodalInput.Input.Core
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | ----------- | ---- | ---- | ---------------------------------------- |
| type | [ActionType](#actiontype) | 是 | 否 | 三指滑动事件类型 |
| x | number | 是 | 否 | 坐标x |
| y | number | 是 | 否 | 坐标y |
## FourFingersSwipe
四指滑动事件。
**系统能力**:SystemCapability.MultimodalInput.Input.Core
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------------- | ----------- | ---- | ---- | ---------------------------------------- |
| type | [ActionType](#actiontype) | 是 | 否 | 四指滑动事件类型 |
| x | number | 是 | 否 | 坐标x |
| y | number | 是 | 否 | 坐标y |
## ActionType
手势事件类型。
**系统能力**:SystemCapability.MultimodalInput.Input.Core
| 名称 | 值 | 说明 |
| ----------- | --- | --------------- |
| CANCEL | 0 | 取消 |
| BEGIN | 1 | 手势开始 |
| UPDATE | 2 | 手势更新 |
| END | 3 | 手势结束 |
......@@ -41,8 +41,10 @@
}
],
"requestPermissions": [
"name": "ohos.permission.NFC_TAG",
"reason": "tag",
{
"name": "ohos.permission.NFC_TAG",
"reason": "tag",
}
]
}
}
......
......@@ -62,7 +62,7 @@ try {
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| message | string\| [Resource](../arkui-ts/ts-types.md#resource类型)<sup>9+</sup> | 是 | 显示的文本信息。 |
| duration | number | 否 | 默认值1500ms,取值区间:1500ms-10000ms。若小于1500ms则取默认值,若大于10000ms则取上限值10000ms。 |
| bottom | string\| number | 否 | 设置弹窗边框距离屏幕底部的位置。 |
| bottom | string\| number | 否 | 设置弹窗边框距离屏幕底部的位置。<br>默认值:80vp |
## promptAction.showDialog
......@@ -319,7 +319,7 @@ try {
| 名称 | 类型 | 必填 | 说明 |
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| title | string\| [Resource](../arkui-ts/ts-types.md#resource类型)<sup>9+</sup> | 否 | 标题文本。 |
| buttons | [[Button](#button),[Button](#button)?,[Button](#button)?,[Button](#button)?,[Button](#button)?,[Button](#button)?] | 是 | 菜单中菜单项按钮的数组,结构为:{text:'button',&nbsp;color:&nbsp;'\#666666'},支持1-6个按钮。大于6个按钮时弹窗不显示。 |
| buttons | [[Button](#button),[Button](#button)?,[Button](#button)?,[Button](#button)?,[Button](#button)?,[Button](#button)?] | 是 | 菜单中菜单项按钮的数组,结构为:{text:'button',&nbsp;color:&nbsp;'\#666666'},支持1-6个按钮。按钮数量大于6个时,仅显示前6个按钮,之后的按钮不显示。 |
## ActionMenuSuccessResponse
......
......@@ -1888,11 +1888,11 @@ resume(callback: AsyncCallback&lt;void&gt;): void
| conf | [Conf](#conf10) | 是 | 任务的配置信息。 |
### on('progress'|'completed'|'failed')<sup>10+</sup>
### on('progress')<sup>10+</sup>
on(event: "progress" | "completed" | "failed", callback: (progress: Progress) =&gt; void): void
on(event: 'progress', callback: (progress: Progress) =&gt; void): void
订阅任务相关的监听。
订阅任务进度的监听。
**系统能力**: SystemCapability.Request.FileTransferAgent
......@@ -1900,8 +1900,8 @@ on(event: "progress" | "completed" | "failed", callback: (progress: Progress) =&
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | string | 是 | 订阅的事件类型。<br>- 取值为'progress',表示任务进度<br/>- 取值为'completed',表示任务已完成;<br/>- 取值为'failed',表示任务失败。 |
| callback | function | 是 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构|
| event | string | 是 | 订阅的事件类型。<br>- 取值为'progress',表示任务进度。 |
| callback | function | 是 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构|
**错误码:**
......@@ -1950,7 +1950,149 @@ on(event: "progress" | "completed" | "failed", callback: (progress: Progress) =&
};
request.agent.create(context, conf).then((task)=> {
task.on('progress', createOnCallback);
console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
}).catch((err) => {
console.error(`Failed to create a upload task, Code: ${err.code}, message: ${err.message}`);
});
```
> **说明:**
>
> 示例中context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
### on('completed')<sup>10+</sup>
on(event: 'completed', callback: (progress: Progress) =&gt; void): void
订阅任务完成的监听。
**系统能力**: SystemCapability.Request.FileTransferAgent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | string | 是 | 订阅的事件类型。<br>- 取值为'completed',表示任务完成。 |
| callback | function | 是 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构。 |
**错误码:**
以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)
| 错误码ID | 错误信息 |
| -------- | -------- |
| 21900005 | task mode error. |
**示例:**
```js
let context;
let attachments = [{
name: "taskOnTest",
value: {
filename: "taskOnTest.avi",
mimetype: "application/octet-stream",
path: "./taskOnTest.avi",
}
}];
let conf = {
action: request.agent.Action.UPLOAD,
url: 'http://127.0.0.1',
title: 'taskOnTest',
description: 'Sample code for event listening',
mode: request.agent.Mode.BACKGROUND,
overwrite: false,
method: "PUT",
data: attachments,
saveas: "./",
network: request.agent.Network.CELLULAR,
metered: false,
roaming: true,
retry: true,
redirect: true,
index: 0,
begins: 0,
ends: -1,
gauge: false,
precise: false,
token: "it is a secret"
};
let createOnCallback = (progress) => {
console.info('upload task completed.');
};
request.agent.create(context, conf).then((task)=> {
task.on('completed', createOnCallback);
console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
}).catch((err) => {
console.error(`Failed to create a upload task, Code: ${err.code}, message: ${err.message}`);
});
```
> **说明:**
>
> 示例中context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
### on('failed')<sup>10+</sup>
on(event: 'failed', callback: (progress: Progress) =&gt; void): void
订阅任务失败的监听。
**系统能力**: SystemCapability.Request.FileTransferAgent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | string | 是 | 订阅的事件类型。<br>- 取值为'failed',表示任务失败。 |
| callback | function | 是 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构。 |
**错误码:**
以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)
| 错误码ID | 错误信息 |
| -------- | -------- |
| 21900005 | task mode error. |
**示例:**
```js
let context;
let attachments = [{
name: "taskOnTest",
value: {
filename: "taskOnTest.avi",
mimetype: "application/octet-stream",
path: "./taskOnTest.avi",
}
}];
let conf = {
action: request.agent.Action.UPLOAD,
url: 'http://127.0.0.1',
title: 'taskOnTest',
description: 'Sample code for event listening',
mode: request.agent.Mode.BACKGROUND,
overwrite: false,
method: "PUT",
data: attachments,
saveas: "./",
network: request.agent.Network.CELLULAR,
metered: false,
roaming: true,
retry: true,
redirect: true,
index: 0,
begins: 0,
ends: -1,
gauge: false,
precise: false,
token: "it is a secret"
};
let createOnCallback = (progress) => {
console.info('upload task completed.');
};
request.agent.create(context, conf).then((task)=> {
task.on('failed', createOnCallback);
console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
}).catch((err) => {
......@@ -1962,11 +2104,12 @@ on(event: "progress" | "completed" | "failed", callback: (progress: Progress) =&
>
> 示例中context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
### off('progress'|'completed'|'failed')<sup>10+</sup>
off(event: "progress" | "completed" | "failed", callback?: (progress: Progress) =&gt; void): void
### off('progress')<sup>10+</sup>
off(event: 'progress', callback?: (progress: Progress) =&gt; void): void
取消订阅任务相关的监听。
取消订阅任务进度的监听。
**系统能力**: SystemCapability.Request.FileTransferAgent
......@@ -1974,8 +2117,8 @@ off(event: "progress" | "completed" | "failed", callback?: (progress: Progress)
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | string | 是 | 订阅的事件类型。<br>- 取值为'progress',表示任务进度<br/>- 取值为'completed',表示任务已完成;<br/>- 取值为'failed',表示任务失败。 |
| callback | function | 否 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构|
| event | string | 是 | 订阅的事件类型。<br>- 取值为'progress',表示任务进度。 |
| callback | function | 否 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构|
**错误码:**
......@@ -2024,10 +2167,152 @@ off(event: "progress" | "completed" | "failed", callback?: (progress: Progress)
};
request.agent.create(context, conf).then((task)=> {
task.on('progress', createOffCallback);
task.on('completed', createOffCallback);
task.on('failed', createOffCallback);
task.off('progress', createOffCallback);
console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
}).catch((err) => {
console.error(`Failed to create a upload task, Code: ${err.code}, message: ${err.message}`);
});
```
> **说明:**
>
> 示例中context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
### off('completed')<sup>10+</sup>
off(event: 'completed', callback?: (progress: Progress) =&gt; void): void
取消订阅任务完成的监听。
**系统能力**: SystemCapability.Request.FileTransferAgent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | string | 是 | 订阅的事件类型。<br>- 取值为'completed',表示任务完成。 |
| callback | function | 否 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构。 |
**错误码:**
以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)
| 错误码ID | 错误信息 |
| -------- | -------- |
| 21900005 | task mode error. |
**示例:**
```js
let context;
let attachments = [{
name: "taskOffTest",
value: {
filename: "taskOffTest.avi",
mimetype: "application/octet-stream",
path: "./taskOffTest.avi",
}
}];
let conf = {
action: request.agent.Action.UPLOAD,
url: 'http://127.0.0.1',
title: 'taskOffTest',
description: 'Sample code for event listening',
mode: request.agent.Mode.BACKGROUND,
overwrite: false,
method: "PUT",
data: attachments,
saveas: "./",
network: request.agent.Network.CELLULAR,
metered: false,
roaming: true,
retry: true,
redirect: true,
index: 0,
begins: 0,
ends: -1,
gauge: false,
precise: false,
token: "it is a secret"
};
let createOffCallback = (progress) => {
console.info('upload task completed.');
};
request.agent.create(context, conf).then((task)=> {
task.on('completed', createOffCallback);
task.off('completed', createOffCallback);
console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
}).catch((err) => {
console.error(`Failed to create a upload task, Code: ${err.code}, message: ${err.message}`);
});
```
> **说明:**
>
> 示例中context的获取方式请参见[获取UIAbility的上下文信息](../../application-models/uiability-usage.md#获取uiability的上下文信息)。
### off('failed')<sup>10+</sup>
off(event: 'failed', callback?: (progress: Progress) =&gt; void): void
取消订阅任务失败的监听。
**系统能力**: SystemCapability.Request.FileTransferAgent
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| event | string | 是 | 订阅的事件类型。<br>- 取值为'failed',表示任务失败。 |
| callback | function | 否 | 发生相关的事件时触发该回调方法,返回任务进度的数据结构。 |
**错误码:**
以下错误码的详细介绍请参见[上传下载错误码](../errorcodes/errorcode-request.md)
| 错误码ID | 错误信息 |
| -------- | -------- |
| 21900005 | task mode error. |
**示例:**
```js
let context;
let attachments = [{
name: "taskOffTest",
value: {
filename: "taskOffTest.avi",
mimetype: "application/octet-stream",
path: "./taskOffTest.avi",
}
}];
let conf = {
action: request.agent.Action.UPLOAD,
url: 'http://127.0.0.1',
title: 'taskOffTest',
description: 'Sample code for event listening',
mode: request.agent.Mode.BACKGROUND,
overwrite: false,
method: "PUT",
data: attachments,
saveas: "./",
network: request.agent.Network.CELLULAR,
metered: false,
roaming: true,
retry: true,
redirect: true,
index: 0,
begins: 0,
ends: -1,
gauge: false,
precise: false,
token: "it is a secret"
};
let createOffCallback = (progress) => {
console.info('upload task completed.');
};
request.agent.create(context, conf).then((task)=> {
task.on('failed', createOffCallback);
task.off('failed', createOffCallback);
console.info(`Succeeded in creating a upload task. result: ${task.tid}`);
}).catch((err) => {
......@@ -2053,7 +2338,7 @@ start(callback: AsyncCallback&lt;void&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | function | 是 | 回调函数,开启任务成功,err为undefined,否则为错误对象 |
| callback | function | 是 | 回调函数,开启任务成功,err为undefined,否则为错误对象 |
**错误码:**
......@@ -2187,7 +2472,7 @@ pause(callback: AsyncCallback&lt;void&gt;): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | function | 是 | 回调函数,暂停任务成功,err为undefined,否则为错误对象 |
| callback | function | 是 | 回调函数,暂停任务成功,err为undefined,否则为错误对象 |
**错误码:**
......@@ -2564,7 +2849,7 @@ stop(): Promise&lt;void&gt;
create(context: BaseContext, conf: Conf, callback: AsyncCallback&lt;Task&gt;): void
创建要上传或下载的任务,并将其排入队列,使用callback异步回调。
创建要上传或下载的任务,并将其排入队列,应用最多支持创建10个任务,服务承载的任务数最多为300个。使用callback异步回调。
**需要权限**:ohos.permission.INTERNET
......@@ -2641,7 +2926,7 @@ create(context: BaseContext, conf: Conf, callback: AsyncCallback&lt;Task&gt;): v
create(context: BaseContext, conf: Conf): Promise&lt;Task&gt;
创建要上传或下载的任务,并将其排入队列。使用Promise异步回调。
创建要上传或下载的任务,并将其排入队列,应用最多支持创建10个任务,服务承载的任务数最多为300个。使用Promise异步回调。
**需要权限**:ohos.permission.INTERNET
......
......@@ -1662,21 +1662,6 @@ isBandTypeSupported(bandType: WifiBandType): boolean
}
```
## WifiBandType <sup>10+</sup>
表示wifi频段类型的枚举。
**系统能力:** SystemCapability.Communication.WiFi.STA
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| WIFI_BAND_NONE | 0 | 未定义。 |
| WIFI_BAND_2G | 1 | 2G频段。 |
| WIFI_BAND_5G | 2 | 5G频段。 |
| WIFI_BAND_6G | 3 | 6G频段。 |
| WIFI_BAND_60G | 4 | 60G频段。|
## wifi.get5GChannelList<sup>10+</sup>
get5GChannelList(): Array&lt;number&gt;
......@@ -1708,6 +1693,57 @@ get5GChannelList(): Array&lt;number&gt;
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getDisconnectedReason<sup>10+</sup>
getDisconnectedReason(): DisconnectedReason
获取最近一次断连原因
**系统接口:** 此接口为系统接口。
**需要权限:** ohos.permission.GET_WIFI_INFO 和 ohos.permission.GET_WIFI_CONFIG
**系统能力:** SystemCapability.Communication.WiFi.STA
**错误码:**
以下错误码的详细介绍请参见[WIFI错误码](../errorcodes/errorcode-wifi.md)
| **错误码ID** | **错误信息** |
| -------- | -------- |
| 2601000 | Operation failed.|
**返回值:**
| **类型** | **说明** |
| -------- | -------- |
| DisconnectedReason | 最近断开的原因 |
**示例:**
```js
import wifiManager from '@ohos.wifiManager';
try {
let disconnectedReason = wifiManager.getDisconnectedReason();
console.info("disconnectedReason:" + disconnectedReason);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## DisconnectedReason <sup>10+</sup>
表示wifi断开原因的枚举。
**系统接口:** 此接口为系统接口。
**系统能力:** SystemCapability.Communication.WiFi.STA
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| DISC_REASON_DEFAULT | 0 | 默认原因。 |
| DISC_REASON_WRONG_PWD | 1 | 密码错误。 |
| DISC_REASON_CONNECTION_FULL | 2 | 路由器的连接数已达到最大数量限制。 |
## wifi.enableHotspot<sup>9+</sup>
......@@ -2285,6 +2321,8 @@ getP2pLocalDevice(callback: AsyncCallback&lt;WifiP2pDevice&gt;): void
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | 是 | 回调函数。当操作成功时,err为0,data表示本端设备信息。如果error为非0,表示处理出现错误。 |
**错误码:**
| **错误码ID** | **错误信息** |
| -------- | -------- |
| 2801000 | Operation failed.|
......
......@@ -26,7 +26,7 @@ enableHotspot(): void;
以下错误码的详细介绍请参见[WIFI错误码](../errorcodes/errorcode-wifi.md)
| **类型** | **说明** |
| **错误码ID** | **错误信息** |
| -------- | -------- |
| 2701000 | Operation failed.|
......@@ -44,7 +44,7 @@ disableHotspot(): void;
以下错误码的详细介绍请参见[WIFI错误码](../errorcodes/errorcode-wifi.md)
| **类型** | **说明** |
| **错误码ID** | **错误信息** |
| -------- | -------- |
| 2701000 | Operation failed.|
......@@ -68,11 +68,11 @@ getSupportedPowerMode(): Promise&lt;Array&lt;PowerMode&gt;&gt;
以下错误码的详细介绍请参见[WIFI错误码](../errorcodes/errorcode-wifi.md)
| **类型** | **说明** |
| **错误码ID** | **错误信息** |
| -------- | -------- |
| 2701000 | Operation failed.|
## PowerMode
## PowerMode<sup>9+</sup>
表示功率模式的枚举。
......@@ -105,7 +105,7 @@ getSupportedPowerMode(callback: AsyncCallback&lt;Array&lt;PowerMode&gt;&gt;): vo
以下错误码的详细介绍请参见[WIFI错误码](../errorcodes/errorcode-wifi.md)
| **类型** | **说明** |
| **错误码ID** | **错误信息** |
| -------- | -------- |
| 2701000 | Operation failed.|
......@@ -129,7 +129,7 @@ getPowerMode(): Promise&lt;PowerMode&gt;
以下错误码的详细介绍请参见[WIFI错误码](../errorcodes/errorcode-wifi.md)
| **类型** | **说明** |
| **错误码ID** | **错误信息** |
| -------- | -------- |
| 2701000 | Operation failed.|
......@@ -153,13 +153,13 @@ getPowerMode(callback: AsyncCallback&lt;PowerMode&gt;): void
以下错误码的详细介绍请参见[WIFI错误码](../errorcodes/errorcode-wifi.md)
| **类型** | **说明** |
| **错误码ID** | **错误信息** |
| -------- | -------- |
| 2701000 | Operation failed.|
## wifiext.setPowerMode<sup>9+</sup>
setPowerMode(model: PowerMode) : boolean;
setPowerMode(model: PowerMode) : void;
设置功率模式。
......@@ -177,6 +177,6 @@ setPowerMode(model: PowerMode) : boolean;
以下错误码的详细介绍请参见[WIFI错误码](../errorcodes/errorcode-wifi.md)
| **类型** | **说明** |
| **错误码ID** | **错误信息** |
| -------- | -------- |
| 2701000 | Operation failed.|
......@@ -558,3 +558,9 @@
| MIDDLE | 中面积(稳定) | 弹簧动效, 刚性:350,阻尼:35,初始速度:0.5 | 95% |
| HEAVY | 大面积(厚重) | 弹簧动效, 刚性:240,阻尼:28,初始速度:0 | 95% |
## TextContentStyle<sup>10+</sup>
| 名称 | 描述 |
| ------- | ------------------------------------------------------------ |
| DEFAULT | 默认风格,光标宽1.5vp,光标高度与文本选中底板高度和字体大小相关。 |
| INLINE | 内联输入风格。文本选中底板高度与输入框高度相同。 |
......@@ -21,7 +21,7 @@
Image(src: PixelMap | ResourceStr | DrawableDescriptor)
通过图片数据源获取图片,用于后续渲染展示。
通过图片数据源获取图片,用于后续渲染展示。Image组件加载图片失败或图片尺寸为0时,图片组件大小自动为0,不跟随父组件的布局约束。
从API version 9开始,该接口支持在ArkTS卡片中使用。
......@@ -50,7 +50,7 @@ Image(src: PixelMap | ResourceStr | DrawableDescriptor)
| syncLoad<sup>8+</sup> | boolean | 设置是否同步加载图片,默认是异步加载。同步加载时阻塞UI线程,不会显示占位图。<br/>默认值:false<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置图片是否可复制(SVG图片不支持复制)。<br/>当copyOption设置为非CopyOptions.None时,支持使用长按、鼠标右击、快捷组合键'CTRL+C'等方式进行复制。<br/>默认值:CopyOptions.None<br/>该接口支持在ArkTS卡片中使用。 |
| colorFilter<sup>9+</sup> | [ColorFilter](ts-types.md#colorfilter9) | 给图像设置颜色滤镜效果。<br/>该接口支持在ArkTS卡片中使用。 |
| draggable<sup>9+</sup> | boolean | 设置默认拖拽效果。(不能和[onDragStart](ts-universal-events-drag-drop.md)事件同时使用。)<br/>默认值:false<br/>该接口支持在ArkTS卡片中使用。 |
| draggable<sup>(deprecated)</sup> | boolean | 设置默认拖拽效果。(不能和[onDragStart](ts-universal-events-drag-drop.md)事件同时使用。)<br/>默认值:false<br/>该接口支持在ArkTS卡片中使用。 <br />**说明:**<br />从 API version 9 开始支持,从 API version 10 开始废弃,建议使用通用属性[draggable](ts-universal-events-drag-drop.md)替代。 |
> **说明:**
>
......
......@@ -39,7 +39,7 @@ Search(options?: { value?: string; placeholder?: ResourceStr; icon?: string; con
| cancelButton<sup>10+</sup> | {<br/>style? : [CancelButtonStyle](#cancelbuttonstyle10枚举说明)<br/>icon?: [IconOptions](#iconoptions10对象说明) <br/>} | 设置右侧清除按钮样式。 |
| fontColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | 设置输入文本的字体颜色。 |
| caretStyle<sup>10+</sup> | [CaretStyle](#caretstyle10对象说明) | 设置光标样式。 |
| enableKeyboardOnFocus<sup>10+</sup> | boolean | Search获焦时,是否绑定输入法<br/>默认值:true。从API version 10开始,获焦默认绑定输入法。 |
## IconOptions<sup>10+</sup>对象说明
| 参数名 | 参数类型 | 必填 | 参数描述 |
......
# SecLocationButton
安全件的位置按钮,用户通过点击该位置按钮,可以临时获取精准定位权限,而不需要权限弹框授权确认。
安全件的位置按钮,用户通过点击该位置按钮,可以临时获取精准定位权限,而不需要权限弹框授权确认。
> **说明:**
>
......
# SecPasteButton
安全件的粘贴按钮,用户通过点击该粘贴按钮,可以临时获取读取剪贴板权限,而不会触发toast提示。
安全件的粘贴按钮,用户通过点击该粘贴按钮,可以临时获取读取剪贴板权限,而不会触发toast提示。
> **说明:**
>
......@@ -29,7 +29,7 @@
## 属性
不支持通用属性,仅继承[安全件通用属性](ts-universal-attributes-securitycomponent.md#属性)
不支持通用属性,仅继承[安全件通用属性](ts-universal-attributes-securitycomponent.md#属性)
## PasteIconStyle枚举说明
......
# SecSaveButton
安全件的保存按钮,用户通过点击该保存按钮,可以临时获取存储权限,而不需要权限弹框授权确认。
安全件的保存按钮,用户通过点击该保存按钮,可以临时获取存储权限,而不需要权限弹框授权确认。
> **说明:**
>
......@@ -56,7 +56,7 @@
## 属性
不支持通用属性,仅继承[安全件通用属性](ts-universal-attributes-securitycomponent.md#属性)
不支持通用属性,仅继承[安全件通用属性](ts-universal-attributes-securitycomponent.md#属性)
## 事件
......
......@@ -41,7 +41,7 @@ Text(content?: string | Resource)
| maxFontSize | number&nbsp;\|&nbsp;string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 设置文本最大显示字号。<br/>需配合minFontSize以及maxline或布局大小限制使用,单独设置不生效。 <br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| textCase | [TextCase](ts-appendix-enums.md#textcase) | 设置文本大小写。<br />默认值:TextCase.Normal <br/>从API version 9开始,该接口支持在ArkTS卡片中使用。|
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 组件支持设置文本是否可复制粘贴。<br />默认值:CopyOptions.None <br/>该接口支持在ArkTS卡片中使用。 |
| draggable<sup>9+</sup> | boolean | 设置选中文本拖拽效果。<br/>不能和[onDragStart](ts-universal-events-drag-drop.md)事件同时使用;<br/>需配合copyOption一起使用,支持对选中文本的拖拽以及选中内容复制到输入框。<br/>默认值:false |
| draggable<sup>(deprecated)</sup> | boolean | 设置选中文本拖拽效果。<br/>不能和[onDragStart](ts-universal-events-drag-drop.md)事件同时使用;<br/>需配合copyOption一起使用,支持对选中文本的拖拽以及选中内容复制到输入框。<br/>默认值:false <br />**说明:**<br />从 API version 9 开始支持,从 API version 10 开始废弃,建议使用通用属性[draggable](ts-universal-events-drag-drop.md)替代。|
| textShadow<sup>10+</sup> | [ShadowOptions](ts-universal-attributes-image-effect.md#shadowoptions对象说明) | 设置文字阴影效果。 |
| heightAdaptivePolicy<sup>10+</sup> | [TextHeightAdaptivePolicy](ts-appendix-enums.md#textheightadaptivepolicy10) | 设置文本自适应高度的方式。<br/>默认值:TextHeightAdaptivePolicy.MAX_LINES_FIRST。<br/>**说明:**<br/>当设置为TextHeightAdaptivePolicy.MAX_LINES_FIRST时,优先使用`maxLines`属性来调整文本高度。如果使用`maxLines`属性的布局大小超过了布局约束,则尝试在`minFontSize``maxFontSize`的范围内缩小字体以显示更多文本。<br/>当设置为TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST时,优先使用`minFontSize`属性来调整文本高度。如果使用`minFontSize`属性可以将文本布局在一行中,则尝试在`minFontSize``maxFontSize`的范围内增大字体并使用最大可能的字体大小。<br/>当设置为TextHeightAdaptivePolicy.LAYOUT_CONSTRAINT_FIRST时,优先使用布局约束来调整文本高度。如果布局大小超过布局约束,则尝试在`minFontSize``maxFontSize`的范围内缩小字体以满足布局约束。如果将字体大小缩小到`minFontSize`后,布局大小仍然超过布局约束,则删除超过布局约束的行。|
| textIndent<sup>10+</sup> | number&nbsp;\|&nbsp;string | 设置首行文本缩进,默认值0。 |
......
......@@ -20,7 +20,7 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ----------------------- | ---------------------------------------- | ---- | -------------- |
| placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置无输入时的提示文本。输入内容后,提示文本不显示。 |
| placeholder | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置无输入时的提示文本。输入内容后,提示文本不显示。<br/>仅设置placeholder属性时,手柄依然跟随拖动,手柄松开后光标停留在文字开头位置。 |
| text | [ResourceStr](ts-types.md#resourcestr) | 否 | 设置输入框当前的文本内容。</br>当组件设置[stateStyles](ts-universal-attributes-polymorphic-style.md)等刷新属性时,建议通过onChange事件将状态变量与文本实时绑定,</br>避免组件刷新时TextArea中的文本内容异常。<br />从API version 10开始,该参数支持[$$](../../quick-start/arkts-two-way-sync.md)双向绑定变量。 |
| controller<sup>8+</sup> | [TextAreaController](#textareacontroller8) | 否 | 设置TextArea控制器。 |
......@@ -31,21 +31,21 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex
| 名称 | 参数类型 | 描述 |
| ------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置placeholder文本颜色。<br/>默认值跟随主题。 |
| placeholderColor | [ResourceColor](ts-types.md#resourcecolor) | 设置placeholder文本颜色。<br/>默认值跟随主题。 |
| placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式,包括字体大小,字体粗细,字体族,字体风格。目前仅支持默认字体族。 |
| textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本在输入框中的水平对齐方式。<br/>默认值:TextAlign.Start<br/>说明:<br/>可通过[align](ts-universal-attributes-location.md)属性控制文本段落在垂直方向上的位置,此组件中不可通过align属性控制文本段落在水平方向上的位置,即align属性中Alignment.TopStart、Alignment.Top、Alignment.TopEnd效果相同,控制内容在顶部,Alignment.Start、Alignment.Center、Alignment.End效果相同,控制内容垂直居中,Alignment.BottomStart、Alignment.Bottom、Alignment.BottomEnd效果相同,控制内容在底部。 |
| caretColor | [ResourceColor](ts-types.md#resourcecolor) | 设置输入框光标颜色。<br/>默认值:'#007DFF'。 |
| caretColor | [ResourceColor](ts-types.md#resourcecolor) | 设置输入框光标颜色。<br/>默认值:'#007DFF'。 |
| inputFilter<sup>8+</sup> | {<br/>value:&nbsp;[ResourceStr](ts-types.md#resourcestr),<br/>error?:&nbsp;(value:&nbsp;string) => void<br/>} | 通过正则表达式设置输入过滤器。匹配表达式的输入允许显示,不匹配的输入将被过滤。仅支持单个字符匹配,不支持字符串匹配。<br/>-&nbsp;value:设置正则表达式。<br/>-&nbsp;error:正则匹配失败时,返回被过滤的内容。 |
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置输入的文本是否可复制。<br/>默认值:CopyOptions.LocalDevice,支持设备内复制。 <br/>设置CopyOptions.None时,当前TextArea中的文字无法被复制或剪切,仅支持粘贴。 |
| maxLength<sup>10+</sup> | number | 设置文本的最大输入字符数。<br/>默认不设置最大输入字符数限制。 |
| showCounter<sup>10+</sup> | boolean | 设置文本最大输入字符数后,是否显示字数。<br/>默认值:false |
| style<sup>10+</sup> | [TextContentStyle](enums.d.ts#TextContentStyle) | 设置文本框多态样式。<br/>默认值:TextContentStyle.DEFAULT |
| style<sup>10+</sup> | [TextContentStyle](ts-appendix-enums.md#textcontentstyle10) | 设置文本框多态样式。<br/>默认值:TextContentStyle.DEFAULT |
| enableKeyboardOnFocus<sup>10+</sup> | boolean | TextArea获焦时,是否绑定输入法<br/>默认值:true。从API version 10开始,获焦默认绑定输入法。 |
> **说明:**
>
> [通用属性padding](ts-universal-attributes-size.md)的默认值为:<br>{<br>&nbsp;top: 8 vp,<br>&nbsp;right: 16 vp,<br>&nbsp;bottom: 8 vp,<br>&nbsp;left: 16 vp<br> }
## 事件
除支持[通用事件](ts-universal-events-click.md)外,还支持以下事件:
......
......@@ -40,7 +40,7 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te
| inputFilter<sup>8+</sup> | {<br/>value:&nbsp;[ResourceStr](ts-types.md#resourcestr),<br/>error?:&nbsp;(value:&nbsp;string)&nbsp;=&gt;&nbsp;void<br/>} | 正则表达式,匹配表达式的输入允许显示,不匹配的输入将被过滤。目前仅支持单个字符匹配,不支持字符串匹配。<br/>-&nbsp;value:设置正则表达式。<br/>-&nbsp;error:正则匹配失败时,返回被过滤的内容。 |
| copyOption<sup>9+</sup> | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置输入的文本是否可复制。<br/>默认值:CopyOptions.LocalDevice,支持设备内复制。<br/>设置CopyOptions.None时,当前TextInput中的文字无法被复制或剪切,仅支持粘贴。 |
| showPasswordIcon<sup>9+</sup> | boolean | 密码输入模式时,输入框末尾的图标是否显示。<br/>默认值:true |
| style<sup>9+</sup> | [TextInputStyle](#textinputstyle9枚举说明) \| [TextContentStyle](enums.d.ts#TextContentStyle) | 设置输入框为默认风格或内联输入风格。<br/>默认值:TextInputStyle.Default |
| style<sup>9+</sup> | [TextInputStyle](#textinputstyle9枚举说明) \| [TextContentStyle](ts-appendix-enums.md#textcontentstyle10) | 设置输入框为默认风格或内联输入风格。<br/>默认值:TextInputStyle.Default |
| textAlign<sup>9+</sup> | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本在输入框中的水平对齐方式。<br/>默认值:TextAlign.Start<br/>说明:<br/>可通过[align](ts-universal-attributes-location.md)属性控制文本段落在垂直方向上的位置,此组件中不可通过align属性控制文本段落在水平方向上的位置,即align属性中Alignment.TopStart、Alignment.Top、Alignment.TopEnd效果相同,控制内容在顶部,Alignment.Start、Alignment.Center、Alignment.End效果相同,控制内容垂直居中,Alignment.BottomStart、Alignment.Bottom、Alignment.BottomEnd效果相同,控制内容在底部。 |
| selectedBackgroundColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | 设置文本选中底板颜色。<br/>如果未设置透明度,默认为不透明(例如:“0x80000000”为50%透明度黑色)。 |
| caretStyle<sup>10+</sup> | {<br/>width:&nbsp;[Length](ts-types.md#length)<br/>} | 设置光标风格。 |
......@@ -49,6 +49,7 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te
| showError<sup>10+</sup> | string&nbsp;\|&nbsp;undefined | 设置错误状态下提示的错误文本或者不显示错误状态。<br/>默认不显示错误状态。 |
| showUnderline<sup>10+</sup> | boolean | 设置是否开启下划线。<br/>默认值:false |
| passwordIcon<sup>10+</sup> | [PasswordIcon](#passwordicon10对象说明) | 密码输入模式时,设置输入框末尾的图标。<br/>默认为系统提供的密码图标。 |
| enableKeyboardOnFocus<sup>10+</sup> | boolean | TextInput获焦时,是否绑定输入法<br/>默认值:true。从API version 10开始,获焦默认绑定输入法。 |
> **说明:**
>
......
......@@ -200,6 +200,7 @@ struct GridExample {
.width('90%')
.backgroundColor(0xFAEEE0)
.height(300)
.scrollBar(BarState.Off)
Button('next page')
.onClick(() => { // 点击后滑到下一页
this.scroller.scrollPage({ next: true })
......
......@@ -41,8 +41,8 @@ List(value?:{space?: number&nbsp;|&nbsp;string, initialIndex?: number, scroller?
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ------------ | ---------------------------------------- | ---- | ---------------------------------------- |
| space | number&nbsp;\|&nbsp;string | 否 | 子组件主轴方向的间隔。<br/>默认值:0<br/>**说明:** <br/>设置为除-1外其他负数或百分比时,按默认值显示。<br/>space参数值小于List分割线宽度时,子组件主轴方向的间隔取分割线宽度。 |
| initialIndex | number | 否 | 设置当前List初次加载时视口起始位置显示的item的索引值。<br/>默认值:0<br/>**说明:** <br/>设置为除-1外其他负数或超过了当前List最后一个item的索引值时视为无效取值,无效取值按默认值显示。 |
| space | number&nbsp;\|&nbsp;string | 否 | 子组件主轴方向的间隔。<br/>默认值:0<br/>**说明:** <br/>设置为负数时,按默认值显示。<br/>space参数值小于List分割线宽度时,子组件主轴方向的间隔取分割线宽度。 |
| initialIndex | number | 否 | 设置当前List初次加载时视口起始位置显示的item的索引值。<br/>默认值:0<br/>**说明:** <br/>设置为负数或超过了当前List最后一个item的索引值时视为无效取值,无效取值按默认值显示。 |
| scroller | [Scroller](ts-container-scroll.md#scroller) | 否 | 可滚动组件的控制器。用于与可滚动组件进行绑定。<br/>**说明:** <br/>不允许和其他滚动类组件绑定同一个滚动控制对象。 |
## 属性
......@@ -181,6 +181,7 @@ struct ListExample {
}, item => item)
}
.listDirection(Axis.Vertical) // 排列方向
.scrollBar(BarState.Off)
.divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线
.edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果
.onScrollIndex((firstIndex: number, lastIndex: number) => {
......@@ -231,6 +232,7 @@ struct ListLanesExample {
.border({ width: 3, color: Color.Red })
.lanes({ minLength: 40, maxLength: 40 })
.alignListItem(this.alignListItem)
.scrollBar(BarState.Off)
Button("点击更改alignListItem:" + this.alignListItem).onClick(() => {
if (this.alignListItem == ListItemAlign.Start) {
......@@ -289,6 +291,7 @@ struct ListExample{
}
}, item => item)
}.width('90%')
.scrollBar(BarState.Off)
}.width('100%')
Button('edit list')
......
......@@ -42,7 +42,7 @@
| sticky<sup>(deprecated)</sup> | [Sticky](#stickydeprecated枚举说明) | 设置ListItem吸顶效果。<br/>默认值:Sticky.None<br/>从API version9开始废弃,推荐使用[List组件sticky属性](ts-container-list.md#属性)。 |
| editable<sup>(deprecated)</sup> | boolean&nbsp;\|&nbsp;[EditMode](#editmodedeprecated枚举说明) | 当前ListItem元素是否可编辑,进入编辑模式后可删除或移动列表项。<br/>从API version9开始废弃。<br/>默认值:false |
| selectable<sup>8+</sup> | boolean | 当前ListItem元素是否可以被鼠标框选。<br/>**说明:**<br/>外层List容器的鼠标框选开启时,ListItem的框选才生效。<br/>默认值:true |
| swipeAction<sup>9+</sup> | {<br/>start?:&nbsp;CustomBuilder&nbsp;\|&nbsp;[SwipeActionItem](#swipeactionitem10对象说明),<br/>end?:CustomBuilder&nbsp;\|&nbsp;[SwipeActionItem](#swipeactionitem10对象说明),<br/>edgeEffect?:&nbsp;[SwipeEdgeEffect](#swipeedgeeffect9枚举说明),<br/>} | 用于设置ListItem的划出组件。<br/>- start:&nbsp;ListItem向右划动时item左边的组件(List垂直布局时)或ListItem向下划动时item上方的组件(List水平布局时)。<br/>- end:&nbsp;ListItem向左划动时item右边的组件(List垂直布局时)或ListItem向上划动时item下方的组件(List水平布局时)。<br/>- edgeEffect:&nbsp;滑动效果。<br/>**说明:** <br/>start和end对应的@builder函数中顶层必须是单个组件,不能是if/else、ForEach、LazyForEach语句。 |
| swipeAction<sup>9+</sup> | {<br/>start?:&nbsp;CustomBuilder&nbsp;\|&nbsp;[SwipeActionItem](#swipeactionitem10对象说明),<br/>end?:CustomBuilder&nbsp;\|&nbsp;[SwipeActionItem](#swipeactionitem10对象说明),<br/>edgeEffect?:&nbsp;[SwipeEdgeEffect](#swipeedgeeffect9枚举说明),<br/>} | 用于设置ListItem的划出组件。<br/>- start:&nbsp;ListItem向右划动时item左边的组件(List垂直布局时)或ListItem向下划动时item上方的组件(List水平布局时)。<br/>- end:&nbsp;ListItem向左划动时item右边的组件(List垂直布局时)或ListItem向上划动时item下方的组件(List水平布局时)。<br/>- edgeEffect:&nbsp;滑动效果。<br/>**说明:** <br/>- start和end对应的@builder函数中顶层必须是单个组件,不能是if/else、ForEach、LazyForEach语句。<br/> - 滑动手势只在listItem区域上,如果子组件划出ListItem区域外,在ListItem以外部分不会响应划动手势。所以在多列模式下,建议不要将划出组件设置太宽。 |
## Sticky<sup>(deprecated)</sup>枚举说明
从API version9开始废弃,推荐使用[List组件stickyStyle枚举](ts-container-list.md#stickystyle9枚举说明)
......@@ -118,6 +118,7 @@ struct ListItemExample {
}
}, item => item)
}.width('90%')
.scrollBar(BarState.Off)
}.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
}
}
......@@ -125,54 +126,6 @@ struct ListItemExample {
![zh-cn_image_0000001219864159](figures/zh-cn_image_0000001219864159.gif)
```ts
// xxx.ets
@Entry
@Component
struct ListItemExample2 {
@State message: string = 'Hello World'
@Builder itemEnd() {
Row () {
Button("Del").margin("4vp")
Button("Set").margin("4vp")
}.padding("4vp").justifyContent(FlexAlign.SpaceEvenly)
}
build() {
Column() {
List({space:10}) {
ListItem() {
Text(this.message)
.width('100%')
.height(100)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
}
.swipeAction({ end:this.itemEnd})
ListItem() {
Text(this.message)
.width('100%')
.height(100)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
}
.swipeAction({ start:this.itemEnd})
}
}
.padding(10)
.backgroundColor(0xDCDCDC)
.width('100%')
.height('100%')
}
}
```
![zh-cn_image_1501929990650](figures/zh-cn_image_1501929990650.jpg)
```ts
// xxx.ets
......
......@@ -107,12 +107,12 @@ struct ListItemGroupExample {
}
}, item => item)
}
.borderRadius(20)
.divider({ strokeWidth: 1, color: Color.Blue }) // 每行之间的分界线
})
}
.width('90%')
.sticky(StickyStyle.Header|StickyStyle.Footer)
.scrollBar(BarState.Off)
}.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
}
}
......
......@@ -15,8 +15,8 @@
| align | [Alignment](ts-appendix-enums.md#alignment) | 设置元素内容在元素绘制区域内的对齐方式。<br/>默认值:Alignment.Center<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| direction | [Direction](ts-appendix-enums.md#direction) | 设置元素水平方向的布局。<br/>默认值:Direction.Auto<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| position | [Position](ts-types.md#position8) | 绝对定位,设置元素左上角相对于父容器左上角偏移位置。在布局容器中,设置该属性不影响父容器布局,仅在绘制时进行位置调整。<br/>适用于置顶显示、悬浮按钮等组件在父容器中位置固定的场景。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| markAnchor | [Position](ts-types.md#position8) | 设置元素在位置定位时的锚点,以元素左上角作为基准点进行偏移。通常配合position和offset属性使用,单独使用时,效果类似offset<br/>默认值:<br/>{<br/>x: 0,<br/>y: 0<br/>}<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| offset | [Position](ts-types.md#position8) | 相对定位,设置元素相对于自身的偏移量。设置该属性,不影响父容器布局,仅在绘制时进行位置调整。<br/>默认值:<br/>{<br/>x: 0,<br/>y: 0<br/>}<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| markAnchor | [Position](ts-types.md#position8) | 设置元素在位置定位时的锚点,以元素左上角作为基准点进行偏移。通常配合position和offset属性使用,单独使用时,效果类似offset<br/>API version 9及以前,默认值为:<br/>{<br/>x: 0,<br/>y: 0<br/>}<br/>API version 10:无默认值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| offset | [Position](ts-types.md#position8) | 相对定位,设置元素相对于自身的偏移量。设置该属性,不影响父容器布局,仅在绘制时进行位置调整。<br/>API version 9及以前,默认值为:<br/>{<br/>x: 0,<br/>y: 0<br/>}<br/>API version 10:无默认值。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| alignRules<sup>9+</sup> | {<br/>left?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };<br/>right?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };<br/>middle?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };<br/>top?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };<br/>bottom?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };<br/>center?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) }<br/>} | 指定相对容器的对齐规则,仅当父容器为[RelativeContainer](ts-container-relativecontainer.md)时生效。<br/>-&nbsp;left:设置左对齐参数。<br/>-&nbsp;right:设置右对齐参数。<br/>-&nbsp;middle:设置中间对齐的参数。<br/>-&nbsp;top:设置顶部对齐的参数。<br/>-&nbsp;bottom:设置底部对齐的参数。<br/>-&nbsp;center:设置中心对齐的参数。<br/>该接口支持在ArkTS卡片中使用。<br/>**说明:**<br/>-&nbsp;anchor:设置作为锚点的组件的id值。<br>-&nbsp;align:设置相对于锚点组件的对齐方式。 |
......
# SecurityComponent
# 安全组件通用属性
安全控件的基础属性,用于设置安全控件通用的属性。
安全组件的基础属性,用于设置安全组件通用的属性。
> **说明:**
>
......@@ -10,32 +10,32 @@
| 名称 | 参数类型 | 必填 | 描述 |
| ----------- | ------ | ---- | ---------------------------------------- |
| iconSize | [Length](ts-types.md#length) | 否 | 设置安全件上图标的尺寸。<br/> 默认值:16vp |
| layoutDirection | [SecurityComponentLayoutDirection](#securitycomponentlayoutdirection枚举说明) | 否 | 设置安全件上图标和文字分布的方向。 <br/> 默认值:SecurityComponentLayoutDirection.HORIZONTAL|
| layoutOrder | [SecurityComponentLayoutOrder](#securitycomponentlayoutorder枚举说明) | 否 | 设置安全件上图标和文字分布的顺序。 <br/> 默认值:SecurityComponentLayoutOrder.ICON_FIRST|
| position | [Position](ts-types.md#position8) | 否 | 设置绝对定位,设置安全件的左上角相对于父容器左上角的偏移位置。<br/> 默认值:<br/>{ <br/>x: 0,<br/>y: 0<br/>} |
| markAnchor | [Position](ts-types.md#position8) | 否 | 设置绝对定位的锚点,以安全件的左上角作为基准点进行偏移。<br/> 默认值:<br/>{ <br/>x: 0,<br/>y: 0<br/>} |
| offset | [Position](ts-types.md#position8) | 否 | 设置相对定位,安全件相对于自身的偏移量。<br/> 默认值:<br/>{ <br/>x: 0,<br/>y: 0<br/>} |
| fontSize | [Length](ts-types.md#length) | 否 | 设置安全件上文字的尺寸。<br/> 默认值:16fp |
| fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | 否 | 设置安全件上文字的样式。<br/> 默认值:FontStyle.Normal |
| fontWeight | number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string | 否 | 设置安全件上文字粗细。 <br/> 默认值:FontWeight.Medium |
| fontFamily | string \| [Resource](ts-types.md#resource类型) | 否 | 设置安全件上文字的字体。 <br/>默认字体:'HarmonyOS Sans' |
| fontColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置安全件上文字的颜色。<br/> 默认值:#ffffffff |
| iconColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置安全件上图标的颜色。<br/> 默认值:#ffffffff |
| backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置安全件的背景颜色。 <br/> 默认值:#007dff |
| borderStyle | [BorderStyle](ts-appendix-enums.md#borderstyle) | 否 | 设置安全件的边框的样式。 <br/> 默认不设置边框样式 |
| borderWidth | [Length](ts-types.md#length) | 否 | 设置安全件的边框的宽度。 <br/> 默认不设置边框宽度 |
| borderColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置安全件的边框的颜色。 <br/> 默认不设置边框颜色 |
| borderRadius | [Length](ts-types.md#length) | 否 | 设置安全件的边框圆角半径。<br/> 默认值:1/2 按钮整高 |
| padding | [Padding](ts-types.md#padding) \| [Length](ts-types.md#length) | 否 | 设置安全件的内边距。 <br/> 默认值:上下8vp, 左右24vp |
| textIconSpace | [Length](ts-types.md#length) | 否 | 设置安全件中图标和文字的间距。 <br/> 默认值:4vp |
| iconSize | [Length](ts-types.md#length) | 否 | 设置安全件上图标的尺寸。<br/> 默认值:16vp |
| layoutDirection | [SecurityComponentLayoutDirection](#securitycomponentlayoutdirection枚举说明) | 否 | 设置安全件上图标和文字分布的方向。 <br/> 默认值:SecurityComponentLayoutDirection.HORIZONTAL|
| layoutOrder | [SecurityComponentLayoutOrder](#securitycomponentlayoutorder枚举说明) | 否 | 设置安全件上图标和文字分布的顺序。 <br/> 默认值:SecurityComponentLayoutOrder.ICON_FIRST|
| position | [Position](ts-types.md#position8) | 否 | 设置绝对定位,设置安全件的左上角相对于父容器左上角的偏移位置。<br/> 默认值:<br/>{ <br/>x: 0,<br/>y: 0<br/>} |
| markAnchor | [Position](ts-types.md#position8) | 否 | 设置绝对定位的锚点,以安全件的左上角作为基准点进行偏移。<br/> 默认值:<br/>{ <br/>x: 0,<br/>y: 0<br/>} |
| offset | [Position](ts-types.md#position8) | 否 | 设置相对定位,安全件相对于自身的偏移量。<br/> 默认值:<br/>{ <br/>x: 0,<br/>y: 0<br/>} |
| fontSize | [Length](ts-types.md#length) | 否 | 设置安全件上文字的尺寸。<br/> 默认值:16fp |
| fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | 否 | 设置安全件上文字的样式。<br/> 默认值:FontStyle.Normal |
| fontWeight | number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string | 否 | 设置安全件上文字粗细。 <br/> 默认值:FontWeight.Medium |
| fontFamily | string \| [Resource](ts-types.md#resource类型) | 否 | 设置安全件上文字的字体。 <br/>默认字体:'HarmonyOS Sans' |
| fontColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置安全件上文字的颜色。<br/> 默认值:#ffffffff |
| iconColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置安全件上图标的颜色。<br/> 默认值:#ffffffff |
| backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置安全件的背景颜色。 <br/> 默认值:#007dff |
| borderStyle | [BorderStyle](ts-appendix-enums.md#borderstyle) | 否 | 设置安全件的边框的样式。 <br/> 默认不设置边框样式 |
| borderWidth | [Length](ts-types.md#length) | 否 | 设置安全件的边框的宽度。 <br/> 默认不设置边框宽度 |
| borderColor | [ResourceColor](ts-types.md#resourcecolor) | 否 | 设置安全件的边框的颜色。 <br/> 默认不设置边框颜色 |
| borderRadius | [Length](ts-types.md#length) | 否 | 设置安全件的边框圆角半径。<br/> 默认值:1/2 按钮整高 |
| padding | [Padding](ts-types.md#padding) \| [Length](ts-types.md#length) | 否 | 设置安全件的内边距。 <br/> 默认值:上下8vp, 左右24vp |
| textIconSpace | [Length](ts-types.md#length) | 否 | 设置安全件中图标和文字的间距。 <br/> 默认值:4vp |
## SecurityComponentLayoutDirection枚举说明
| 名称 | 描述 |
| ------------------- | ------------------ |
| HORIZONTAL | 安全件上图标和文字分布的方向为水平排列。 |
| VERTICAL | 安全件上图标和文字分布的方向为垂直排列。 |
| HORIZONTAL | 安全件上图标和文字分布的方向为水平排列。 |
| VERTICAL | 安全件上图标和文字分布的方向为垂直排列。 |
## SecurityComponentLayoutOrder枚举说明
......
......@@ -18,7 +18,7 @@
| 名称 | 类型 | 必填 | 描述 |
| ------------------ | -------------------------------------- | ---- | ---------------------- |
| height | [SheetSize](#sheetsize10)&nbsp;\|&nbsp;[Length](ts-types.md#length) | 否 | 半模态高度。 |
| showDragBar | boolean | 否 | 是否显示控制条。 |
| dragBar | boolean | 否 | 是否显示控制条。 |
## SheetSize<sup>10+</sup>
......
......@@ -23,7 +23,7 @@ HiLog模块实现日志打印功能。
| 文件名称 | 描述 |
| -------- | -------- |
| [log.h](log_8h.md) | HiLog模块日志接口定义,通过这些接口实现日志打印相关功能。<br>引用文件:<hilog/log.h> |
| [log.h](log_8h.md) | HiLog模块日志接口定义,通过这些接口实现日志打印相关功能。<br>**引用文件**<hilog/log.h> <br>**库**:libhitrace_ndk.z.so |
### 宏定义
......
......@@ -2097,3 +2097,13 @@
**授权方式**:system_grant
**ACL使能**:FALSE
## ohos.permission.SUPPORT_USER_AUTH
允许应用与用户认证框架交互和注册扩展能力。
**权限级别**: system_basic
**授权方式**:system_grant
**ACL使能**:FALSE
......@@ -9,3 +9,4 @@
- [anm工具](anm-tool.md)
- [restool工具](restool.md)
- [LLDB调试器使用指导](lldb-tool.md)
- [suap工具](suap-tool.md)
# suap工具
SDK upgrade assistance plugin(SDK升级辅助工具插件,简称suap),用于帮助开发者快速解决SDK升级导致的API不兼容问题。
Beta版本不承诺API稳定性,在SDK升级后,可能存在API不兼容的问题,应用开发者对现在工程切换API版本后,需要适配API接口及其底层行为的变更,存在一定的升级成本;因此OpenHarmony提供了SDK升级辅助工具,可以帮助开发者快速了解升级适配全貌,并通过工具提示快速适配升级,显著提高SDK升级效率。
## 工具安装
1.主菜单栏中点击 "File" > "Settings..."。
![suap-settings](figures/suap-settings.png)
2.在Settings弹出框界面,选中"Plugins"进入IDE插件模块
3.点击"Installed"选项旁边齿轮状图标,选择"Install Plugin from Disk..."
4.在文件选择弹出框中选择插件压缩包所在位置,点击"OK"按钮,重启IDE即安装成功(注意:插件安装完成后需要重启IDE)
![suap-install](figures/suap-install.png)
## 使用工具
辅助升级插件安装好后,打开需要升级的OpenHarmony工程。
工程加载完毕后,点击窗口上方主菜单栏的"UpdateCheck" > "Start"。
![suap-use](figures/suap-use.png)
手动选择旧版本SDK路径,需要选择到“ets”文件夹。新版本SDK路径将通过IDE配置文件及当前应用配置的SDK版本自动获取。路径选择完成后,点击“OK”按钮,开始生成辅助升级报告。
![suap-choose-sdk](figures/suap-choose-sdk.png)
报告生成成功后,将弹窗提示,点击“OK”按钮,关闭当前弹窗。
![suap-finish](figures/suap-finish.png)
根据弹窗提示,打开下方工具栏内UpdateReport按钮,查看升级报告
![suap-view-report](figures/suap-view-report.png)
## 报告功能点
1. 报告下方总数为因升级SDK导致当前应用出现的问题总数,帮助快速评估修改工作量
2. 报告的每个标题头都可以单击进行排序
3. 报告中选择类型下拉框可以选择升级类型原因,下方总计会根据选择的类型更改数量
4. 是否已修改功能可以帮助开发者记录哪些问题已修改,避免出现重复工作量
5. 双击代码所在位置列,可以快速定位到当前代码在应用中位置
6. 提示信息列会提供修改建议,供开发者参考修改
7. changelog列如果多个版本,单击之后会出现弹出框,将版本号和链接罗列,点击进行跳转。单个版本变更,单击之后,直接跳转到对应的ChangeLog文档中
![suap-changelog](figures/suap-changelog.png)
## 工具源码使用教程
1.[interface仓](https://gitee.com/openharmony/interface_sdk-js/tree/master/build-tools)中 clone "api_diff"工具(对比两个版本SDK里的API差异)和"应用API解析"工具(用于解析并汇总应用中使用到的API)到本地。
![suap-warehouse](figures/suap-warehouse.png)
2.在api_diff工具和collect_application_api工具目录下进入终端,进行安装和编译。输入命令:npm install,之后进行构建:npm run build。</br>构建成功之后,会在对应的工具文件夹下生成dist=>build=>api-diff.js和dist=>build=>api-collectort.js
![suap-diff](figures/suap-diff.png)
![suap-collect](figures/suap-collect.png)
3.在本地磁盘的最后一个盘符,创建名为'updateCheck'文件夹,内部分别创建'api-diff'和'collect_application_api'文件夹。</br>将上图diff.js文件放置'api-diff'文件夹下,将上图collect_application_api文件夹下lib文件夹以及上图api-collector.js放置在'collect_application_api'文件夹下。
![suap-diff-file](figures/suap-diff-file.png)
![suap-collect-file](figures/suap-collect-file.png)
4.升级辅助工具源码clone下来之后,在idea上打开,需要配置gradle环境,并且在src同级目录下新建'build.gradle.kts'文件,将下面内容粘贴至文件中,刷新gradle,在idea右侧gradle工具栏即可运行项目和打包成插件。
```lombok.config
plugins {
id("java")
id("org.jetbrains.intellij") version "1.5.2"
}
group = "com.example"
version = "1.0-SNAPSHOT"
repositories {
maven {
setUrl("https://mirrors.huaweicloud.com/repository/maven")
}
}
dependencies{
implementation("org.springframework:spring-web:5.2.12.RELEASE")
implementation("org.apache.commons:commons-compress:1.21")
implementation("com.alibaba:fastjson:1.2.28")
implementation("org.apache.logging.log4j:log4j-core:2.19.0")
implementation("commons-httpclient:commons-httpclient:3.1")
}
intellij {
version.set("2021.2")
type.set("IC") // Target IDE Platform
plugins.set(listOf(/* Plugin Dependencies */))
}
tasks {
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = "11"
targetCompatibility = "11"
}
patchPluginXml {
sinceBuild.set("212")
untilBuild.set("522.*")
}
signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}
publishPlugin {
token.set(System.getenv("PUBLISH_TOKEN"))
}
}
```
\ No newline at end of file
......@@ -340,8 +340,8 @@ OffscreenCanvasRenderingContext2D对象和CanvasRenderingContext2D对象提供
![2023032422159](figures/2023032422159.jpg)
## 相关实例
## 相关实例
使用画布绘制自定义图形,有以下相关实例可供参考:
使用画布绘制自定义图形,有以下相关实例可供参考:
- [Lottie动画](https://gitee.com/openharmony/applications_app_samples/tree/master/code/Solutions/Game/Lottie)
\ No newline at end of file
- [Lottie动画](https://gitee.com/openharmony/applications_app_samples/tree/master/code/Solutions/Game/Lottie)
\ No newline at end of file
......@@ -691,6 +691,7 @@
- [anm工具](tools/anm-tool.md)
- [restool工具](tools/restool.md)
- [LLDB调试器使用指导](tools/lldb-tool.md)
- [suap工具](tools/suap-tool.md)
- 示例教程
- [开发案例](https://gitee.com/openharmony/docs/blob/master/zh-cn/third-party-cases/Readme-CN.md)
- [示例代码](https://gitee.com/openharmony/applications_app_samples/blob/master/README_zh.md)
......
# Native API 差异报告
OpenHarmony 4.0.8.5 版本相较于OpenHarmony 之前的版本的API变更如下:
*
## 标准系统接口变更
| 模块名称 | 接口名称 | 变更类型 | 变更说明 |
| -------- | ------------------------------------------------------------ | -------- | -------------------- |
| avmuxer | OH_AVMuxer \*OH_AVMuxer_Create(int32_t fd, OH_AVOutputFormat format); | 新增 | 创建OH_AVMuxer |
| avmuxer | OH_AVErrCode OH_AVMuxer_SetRotation(OH_AVMuxer \*muxer, int32_t rotation); | 新增 | 设置视频旋转角度 |
| avmuxer | OH_AVErrCode OH_AVMuxer_AddTrack(OH_AVMuxer \*muxer, int32_t \*trackIndex, OH_AVFormat \*trackFormat); | 新增 | 添加媒体轨 |
| avmuxer | OH_AVErrCode OH_AVMuxer_Start(OH_AVMuxer \*muxer); | 新增 | 开始封装 |
| avmuxer | OH_AVErrCode OH_AVMuxer_WriteSample(OH_AVMuxer \*muxer, uint32_t trackIndex, OH_AVMemory \*sample, OH_AVCodecBufferAttr info); | 新增 | 将数据写入封装器 |
| avmuxer | OH_AVErrCode OH_AVMuxer_Stop(OH_AVMuxer \*muxer); | 新增 | 停止封装 |
| avmuxer | OH_AVErrCode OH_AVMuxer_Destroy(OH_AVMuxer \*muxer); | 新增 | 销毁OH_AVMuxer |
| avsource | OH_AVSource *OH_AVSource_CreateWithURI(char *uri); | 新增 | 根据 URI 创建 OH_AVSource |
| avsource | OH_AVSource *OH_AVSource_CreateWithFD(int32_t fd, int64_t offset, int64_t size); | 新增 | 根据 FD 创建OH_AVSource |
| avsource | OH_AVErrCode OH_AVSource_Destroy(OH_AVSource *source); | 新增 | 销毁 OH_AVSource |
| avsource | OH_AVFormat *OH_AVSource_GetSourceFormat(OH_AVSource *source); | 新增 | 获取 source 信息 |
| avsource | OH_AVFormat *OH_AVSource_GetTrackFormat(OH_AVSource *source, uint32_t trackCount); | 新增 | 获取 track 信息 |
| avdemuxer | OH_AVDemuxer *OH_AVDemuxer_CreateWithSource(OH_AVSource *source); | 新增 | 根据 source 创建 OH_AVDemuxer |
| avdemuxer | OH_AVErrCode OH_AVDemuxer_Destroy(OH_AVDemuxer *demuxer); | 新增 | 销毁 OH_AVDemuxer |
| avdemuxer | OH_AVErrCode OH_AVDemuxer_SelectTrackByID(OH_AVDemuxer *demuxer, uint32_t trackIndex); | 新增 | 选择需要解封装的轨道 |
| avdemuxer | OH_AVErrCode OH_AVDemuxer_UnselectTrackByID(OH_AVDemuxer *demuxer, uint32_t trackIndex); | 新增 | 取消选择需要解封装的轨道 |
| avdemuxer | OH_AVErrCode OH_AVDemuxer_ReadSample(OH_AVDemuxer *demuxer, uint32_t trackIndex, OH_AVMemory *sample, OH_AVCodecBufferAttr *info); | 新增 | 读取 trackIndex 对应轨道的帧 |
| avdemuxer | OH_AVErrCode OH_AVDemuxer_SeekToTime(OH_AVDemuxer *demuxer, int64_t millisecond, OH_AVSeekMode mode); | 新增 | 跳转到指定时间 |
|avcapability|OH_AVCapability *OH_AVCodec_GetCapability(const char *mime, bool isEncoder);|新增|获取系统推荐的能力句柄|
|avcapability|OH_AVCapability *OH_AVCodec_GetCapabilityByCategory(const char *mime, bool isEncoder, OH_AVCodecCategory category);|新增|获取系统指定软硬件的能力句柄|
|avcapability|bool OH_AVCapability_IsHardware(OH_AVCapability *capability);|新增|确认是否是硬件编解码器|
|avcapability|const char *OH_AVCapability_GetName(OH_AVCapability *capability);|新增|获取codec名字|
|avcapability|int32_t OH_AVCapability_GetMaxSupportedInstances(OH_AVCapability *capability);|新增|获取最大支持的实例数|
|avcapability|OH_AVErrCode OH_AVCapability_GetEncoderBitrateRange(OH_AVCapability *capability, OH_AVRange *bitrateRange);|新增|获取编码支持的码率范围|
|avcapability|bool OH_AVCapability_IsEncoderBitrateModeSupported(OH_AVCapability *capability, OH_BitrateMode bitrateMode);|新增|确认码控模式是否支持|
|avcapability|OH_AVErrCode OH_AVCapability_GetEncoderQualityRange(OH_AVCapability *capability, OH_AVRange *qualityRange);|新增|获取编码质量范围|
|avcapability|OH_AVErrCode OH_AVCapability_GetEncoderComplexityRange(OH_AVCapability *capability, OH_AVRange *complexityRange);|新增|获取编码复杂度范围|
|avcapability|OH_AVErrCode OH_AVCapability_GetAudioSupportedSampleRates(OH_AVCapability *capability, const int32_t **sampleRates, uint32_t *sampleRateNum);|新增|获取支持的音频采样率|
|avcapability|OH_AVErrCode OH_AVCapability_GetAudioChannelCountRange(OH_AVCapability *capability, OH_AVRange *channelCountRange);|新增|获取音频通道数范围|
|avcapability|OH_AVErrCode OH_AVCapability_GetVideoWidthAlignment(OH_AVCapability *capability, int32_t *widthAlignment);|新增|获取视频宽对齐|
|avcapability|OH_AVErrCode OH_AVCapability_GetVideoHeightAlignment(OH_AVCapability *capability, int32_t *heightAlignment);|新增|获取视频高对齐|
|avcapability|OH_AVErrCode OH_AVCapability_GetVideoWidthRangeForHeight(OH_AVCapability *capability, int32_t height, OH_AVRange *widthRange);|新增|获取特定高情况下视频宽范围|
|avcapability|OH_AVErrCode OH_AVCapability_GetVideoHeightRangeForWidth(OH_AVCapability *capability, int32_t width, OH_AVRange *heightRange);|新增|获取特定宽情况下视频高范围|
|avcapability|OH_AVErrCode OH_AVCapability_GetVideoWidthRange(OH_AVCapability *capability, OH_AVRange *widthRange);|新增|获取视频宽范围|
|avcapability|OH_AVErrCode OH_AVCapability_GetVideoHeightRange(OH_AVCapability *capability, OH_AVRange *heightRange);|新增|获取视频高范围|
|avcapability|bool OH_AVCapability_IsVideoSizeSupported(OH_AVCapability *capability, int32_t width, int32_t height);|新增|确认当前视频尺寸是否支持|
|avcapability|OH_AVErrCode OH_AVCapability_GetVideoFrameRateRange(OH_AVCapability *capability, OH_AVRange *frameRateRange);|新增|获取视频帧率范围|
|avcapability|OH_AVErrCode OH_AVCapability_GetVideoFrameRateRangeForSize(OH_AVCapability *capability, int32_t width, int32_t height, OH_AVRange *frameRateRange);|新增|获取特定尺寸下视频帧率范围|
|avcapability|bool OH_AVCapability_AreVideoSizeAndFrameRateSupported(OH_AVCapability *capability, int32_t width, int32_t height, int32_t frameRate);|新增|确认当前视频尺寸和帧率是否支持|
|avcapability|OH_AVErrCode OH_AVCapability_GetVideoSupportedPixelFormats(OH_AVCapability *capability, const int32_t **pixFormats, uint32_t *pixFormatNum);|新增|获取支持的视频像素格式|
|avcapability|OH_AVErrCode OH_AVCapability_GetSupportedProfiles(OH_AVCapability *capability, const int32_t **profiles, uint32_t *profileNum);|新增|获取支持的模板|
|avcapability|OH_AVErrCode OH_AVCapability_GetSupportedLevelsForProfile(OH_AVCapability *capability, int32_t profile, const int32_t **levels,uint32_t *levelNum);|新增|获取特定模板情况下的等级范围|
|avcapability|bool OH_AVCapability_AreProfileAndLevelSupported(OH_AVCapability *capability, int32_t profile, int32_t level);|新增|确认当前模板和等级是否支持|
|avformat|struct OH_AVFormat \*OH_AVFormat_CreateAudioFormat(const char \*mimeType, int32_t sampleRate, int32_t channelCount);|新增|创建音频轨的OH_AVFormat(用于avmuxer)|
|avformat|struct OH_AVFormat \*OH_AVFormat_CreateVideoFormat(const char \*mimeType, int32_t width, int32_t height);|新增|创建视频轨的OH_AVFormat(用于avmuxer)|
|avmemory|OH_AVMemory \*OH_AVMemory_Create(int32_t size);|新增|创建OH_AVMemory|
|avmemory|OH_AVErrCode OH_AVMemory_Destroy(struct OH_AVMemory \*mem);|新增|销毁OH_AVMemory|
| avcodec | OH_AVErrCode OH_AudioDecoder_IsValid(OH_AVCodec \*codec, bool \*isValid); | 新增 | 查询当前codec实例是否有效, 可用于故障恢复 |
| avcodec | OH_AVErrCode OH_AudioEncoder_IsValid(OH_AVCodec \*codec, bool \*isValid); | 新增 | 查询当前codec实例是否有效, 可用于故障恢复 |
| avcodec | OH_AVErrCode OH_VideoDecoder_IsValid(OH_AVCodec \*codec, bool \*isValid); | 新增 | 查询当前codec实例是否有效 |
| avcodec | OH_AVErrCode OH_VideoEncoder_IsValid(OH_AVCodec \*codec, bool \*isValid); | 新增 | 查询当前codec实例是否有效 |
| avcodec | OH_AVErrCode OH_VideoEncoder_PushInputData(OH_AVCodec \*codec, uint32_t index, OH_AVCodecBufferAttr attr); | 新增 | 将填入数据的输入缓冲区提交给视频编码器 |
| avcodec | OH_AVFormat \*OH_VideoEncoder_GetInputDescription(OH_AVCodec \*codec); | 新增 | 获取视频编码器接收的描述信息 |
\ No newline at end of file
# arkui子系统ChangeLog
## cl.arkui.1 stack组件alignContent属性和通用属性align生效顺序。
**说明**
属性之间的处理原则:如果功能相同,属性按覆盖处理即后设置的生效。alignContent和align功能相同,都是子组件在stack容器组件的对齐方式。
**示例:**
```ts
// xxx.ets
@Entry
@Component
struct StackExample {
build() {
Stack({alignContent:Alignment.Start}){
Text("Stack's child").backgroundColor(Color.Brown).height("100").width(100)
}
.width(300).height(300)
.backgroundColor(Color.Pink)
.align(Alignment.Center)
.alignContent(Alignment.TopEnd)
}
}
```
api9:子组件按照通用属性align布局
![stack](figures/api9.png)
api10及以后:子组件按照后设置的alignContent布局
![stack](figures/api10_and_later.png)
**变更影响**
alignContent和align都设置时,api9版本及以前是align生效,api10及以后是后设置的生效。
# security子系统ChangeLog
## cl.security.1 对API9中已经抛出的异常,补写throws标签
对于在API9中已经抛出异常而JS DOC中漏写throws标签的接口,在since 9的注释中补上throws标签。
**变更影响**
对于已发布的JS接口,可能影响异常处理流程,包括同步异常和异步异常。应用需要根据最新的throws标签,排查是否有遗漏的异常处理流程,结合实际情况进行适配。
**关键的接口/组件变更**
修改前的接口原型:
```ts
interface Key {
/**
* Encode the key object to binary data.
*
* @returns { DataBlob } the binary data of the key object.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
getEncoded(): DataBlob;
}
interface AsyKeyGenerator {
/**
* Used to generate asymmetric key pair.
*
* @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 17620001 - memory error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
generateKeyPair(callback: AsyncCallback<KeyPair>): void;
/**
* Used to generate asymmetric key pair.
*
* @returns { Promise<KeyPair> } the promise used to return keypair.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 17620001 - memory error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
generateKeyPair(): Promise<KeyPair>;
/**
* Used to convert asymmetric key data to key pair object.
*
* @param { DataBlob } pubKey - the public key data blob.
* @param { DataBlob } priKey - the private key data blob.
* @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 17620001 - memory error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
convertKey(pubKey: DataBlob, priKey: DataBlob, callback: AsyncCallback<KeyPair>): void;
/**
* Used to convert asymmetric key data to key pair object.
*
* @param { DataBlob } pubKey - the public key data blob.
* @param { DataBlob } priKey - the private key data blob.
* @returns { Promise<KeyPair> } the promise used to return keypair.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 17620001 - memory error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
convertKey(pubKey: DataBlob, priKey: DataBlob): Promise<KeyPair>;
}
/**
* Provides the asymmetric key generator instance func.
*
* @param { string } algName - indicates the algorithm name.
* @returns { AsyKeyGenerator } the generator obj create by algName.
* @throws { BusinessError } 401 - invalid parameters.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
function createAsyKeyGenerator(algName: string): AsyKeyGenerator;
/**
* Create a cipher object for encryption and decryption operations according to the given specifications.
* Two different Cipher objects should be created when using RSA encryption and decryption,
* even with the same specifications.
*
* @param { string } transformation - indicates the description to be transformed to cipher specifications.
* @returns { Cipher } the cipher object returned by the function.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 801 - this operation is not supported.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
function createCipher(transformation: string): Cipher;
/**
* Create sign class.
*
* @param { string } algName - indicates the algorithm name and params.
* @returns { Sign } the sign class.
* @throws { BusinessError } 401 - invalid parameters.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
function createSign(algName: string): Sign;
/**
* Create verify class.
*
* @param { string } algName - indicates the algorithm name and params.
* @returns { Verify } the verify class.
* @throws { BusinessError } 401 - invalid parameters.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
function createVerify(algName: string): Verify;
/**
* Create key agreement class.
*
* @param { string } algName - indicates the algorithm name and params.
* @returns { KeyAgreement } the key agreement class.
* @throws { BusinessError } 401 - invalid parameters.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
function createKeyAgreement(algName: string): KeyAgreement;
```
修改后的接口原型:
```ts
interface Key {
/**
* Encode the key object to binary data.
*
* @returns { DataBlob } the binary data of the key object.
* @throws { BusinessError } 801 - this operation is not supported.
* @throws { BusinessError } 17620001 - memory error.
* @throws { BusinessError } 17630001 - crypto operation error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
getEncoded(): DataBlob;
}
interface AsyKeyGenerator {
/**
* Used to generate asymmetric keypair.
*
* @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 17620001 - memory error.
* @throws { BusinessError } 17630001 - crypto operation error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
generateKeyPair(callback: AsyncCallback<KeyPair>): void;
/**
* Used to generate asymmetric keypair.
*
* @returns { Promise<KeyPair> } the promise used to return keypair.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 17620001 - memory error.
* @throws { BusinessError } 17630001 - crypto operation error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
generateKeyPair(): Promise<KeyPair>;
/**
* Used to convert asymmetric key data to keypair object.
*
* @param { DataBlob } pubKey - the public key data blob.
* @param { DataBlob } priKey - the private key data blob.
* @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 17620001 - memory error.
* @throws { BusinessError } 17630001 - crypto operation error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
convertKey(pubKey: DataBlob, priKey: DataBlob, callback: AsyncCallback<KeyPair>): void;
/**
* Used to convert asymmetric key data to keypair object.
*
* @param { DataBlob } pubKey - the public key data blob.
* @param { DataBlob } priKey - the private key data blob.
* @returns { Promise<KeyPair> } the promise used to return keypair.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 17620001 - memory error.
* @throws { BusinessError } 17630001 - crypto operation error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
convertKey(pubKey: DataBlob, priKey: DataBlob): Promise<KeyPair>;
}
/**
* Create the asymmetric key generator instance according to the given algorithm name.
*
* @param { string } algName - indicates the algorithm name.
* @returns { AsyKeyGenerator } the asymmetric key generator instance.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 801 - this operation is not supported.
* @throws { BusinessError } 17620001 - memory error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
function createAsyKeyGenerator(algName: string): AsyKeyGenerator;
/**
* Create a cipher object for encryption and decryption operations according to the given specifications.
* Two different Cipher objects should be created when using RSA encryption and decryption,
* even with the same specifications.
*
* @param { string } transformation - indicates the description to be transformed to cipher specifications.
* @returns { Cipher } the cipher object returned by the function.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 801 - this operation is not supported.
* @throws { BusinessError } 17620001 - memory error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
function createCipher(transformation: string): Cipher;
/**
* Create a sign object for generating signatures.
*
* @param { string } algName - indicates the algorithm name and params.
* @returns { Sign } the sign class.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 801 - this operation is not supported.
* @throws { BusinessError } 17620001 - memory error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
function createSign(algName: string): Sign;
/**
* Create a verify object for verifying signatures.
*
* @param { string } algName - indicates the algorithm name and the parameters.
* @returns { Verify } the verify class.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 801 - this operation is not supported.
* @throws { BusinessError } 17620001 - memory error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
function createVerify(algName: string): Verify;
/**
* Create a key agreement object.
*
* @param { string } algName - indicates the algorithm name and params.
* @returns { KeyAgreement } the key agreement object.
* @throws { BusinessError } 401 - invalid parameters.
* @throws { BusinessError } 801 - this operation is not supported.
* @throws { BusinessError } 17620001 - memory error.
* @syscap SystemCapability.Security.CryptoFramework
* @since 9
*/
function createKeyAgreement(algName: string): KeyAgreement;
```
**适配指导**
由于漏标的throws异常发生在较少见的情况下,应用可以结合实际情况,排查漏标的throws标签是否需要专门适配。
- 对于同步方法,如createSign等,请使用try/catch方式处理错误信息。
- 对于异步方法,如convertKey等,请使用try/catch方式处理同步的参数错误,使用error对象的方式获取异步的参数错误和业务执行错误。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册