diff --git a/docker/CHANGELOG.md b/docker/CHANGELOG.md old mode 100644 new mode 100755 index c293b830db2a72958e65485bffa18a06396cca15..ab06f14091985eed7a30233c18eb2df2cecaa03c --- a/docker/CHANGELOG.md +++ b/docker/CHANGELOG.md @@ -1,3 +1,9 @@ +### 1.0.0 (2022/03/09) + +合并轻设备和富设备系统docker编译环境。 + + + ### 0.0.7 (2022/02/16) 增加安装doxygen工具。 diff --git a/docker/CHANGELOG_en.md b/docker/CHANGELOG_en.md old mode 100644 new mode 100755 index 1dac4c8e523bf0c6adf63e1c93d289e5a158254e..94189f8d74234167006312d822bad65006ee40a9 --- a/docker/CHANGELOG_en.md +++ b/docker/CHANGELOG_en.md @@ -1,10 +1,16 @@ +### 1.0.0 (2022/03/09) + +Combine the docker build environment of Mini-System Devices (reference memory ≥ 128 KB), Small-System Devices (reference memory ≥ 1 MB) and Standard-System Devices (reference memory ≥ 128 MB). + + + ### 0.0.7 (2022/02/16) Added the installation of doxygen. -### 0.0.6(2022/02/10) +### 0.0.6 (2022/02/10) 1\. Updated hb. diff --git a/docker/Dockerfile b/docker/Dockerfile index 9e5371eae3bdb34a3cc2e0238bf7e47f65c36e55..70560a93c1dd890bf8b6ff1d9f03d2e778adbfe0 100755 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -12,80 +12,71 @@ # limitations under the License. -FROM ubuntu:20.04 -MAINTAINER dongjinguang@huawei.com +FROM ubuntu:18.04 WORKDIR /home/openharmony -RUN apt-get update -y \ - && apt-get install curl wget -y \ - && apt-get install vim -y \ - && apt-get install ssh -y \ - && apt-get install git -y \ - && apt-get install python3.8 -y \ - && apt-get install python3-pip -y \ - && apt-get install dosfstools -y \ - && apt-get install mtools -y \ - && apt-get install scons -y \ - && apt-get install make -y \ - && apt-get install libffi-dev -y \ - && apt-get install zip -y \ - && apt-get install python3-distutils -y \ - && apt-get install binutils -y \ - && apt-get install mtd-utils -y \ - && apt-get install libc6-dev-x32 -y \ - && DEBIAN_FRONTEND="noninteractive" TZ="America/New_York" apt-get -y install tzdata \ - && apt-get install default-jre -y \ - && apt-get install default-jdk -y \ - && apt-get install bison -y \ - && apt-get install flex -y \ - && apt-get install bc -y \ - && apt-get install doxygen -y \ - && apt-get install u-boot-tools -y \ - && apt-get install gcc-arm-linux-gnueabi -y \ - && apt-get install build-essential \ - && apt-get install locales \ - && apt-get install ruby -y \ +RUN sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list \ + && sed -i "s@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list \ + && apt-get update -y \ + && apt-get install -y apt-utils binutils bison flex bc build-essential make mtd-utils gcc-arm-linux-gnueabi u-boot-tools python3.8 python3-pip git zip unzip curl wget gcc g++ ruby=1:2.5.1 dosfstools mtools default-jre default-jdk scons python3.8-distutils perl openssl libssl-dev cpio git-lfs m4 ccache zlib1g-dev tar rsync liblz4-tool genext2fs binutils-dev device-tree-compiler e2fsprogs git-core gnupg gnutls-bin gperf lib32ncurses5-dev libffi-dev zlib* libelf-dev libx11-dev libgl1-mesa-dev lib32z1-dev xsltproc x11proto-core-dev libc6-dev-i386 libxml2-dev lib32z-dev libdwarf-dev \ + && apt-get install -y grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5 libncurses5-dev libncursesw5 libstdc++6 python2.7 gcc-arm-none-eabi \ + && apt-get install -y vim ssh locales \ + && apt-get install -y doxygen \ && locale-gen "en_US.UTF-8" \ - && rm -rf /bin/sh /usr/bin/python /usr/bin/python3 \ + && rm -rf /bin/sh /usr/bin/python /usr/bin/python3 /usr/bin/python3m \ && ln -s /bin/bash /bin/sh \ && ln -s /usr/bin/python3.8 /usr/bin/python3 \ + && ln -s /usr/bin/python3.8 /usr/bin/python3m \ && ln -s /usr/bin/python3.8 /usr/bin/python \ - && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple setuptools \ - && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple kconfiglib \ - && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple pycryptodome \ - && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple ecdsa \ - && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple ohos-build \ + && curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/bin/repo \ + && chmod +x /usr/bin/repo \ + && pip3 install --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple requests setuptools pymongo kconfiglib pycryptodome ecdsa ohos-build pyyaml prompt_toolkit==1.0.14 redis json2html yagmail python-jenkins \ + && pip3 install esdk-obs-python --trusted-host pypi.org \ + && pip3 install six --upgrade --ignore-installed six \ && mkdir -p /home/tools \ + && mkdir -p /home/tools/gn \ && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/clang/10.0.1-62608/linux/llvm.tar.gz \ && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/hc-gen/0.65/linux/hc-gen-0.65-linux.tar \ && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/gcc_riscv32/7.3.0/linux/gcc_riscv32-linux-7.3.0.tar.gz \ && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/ninja/1.9.0/linux/ninja.1.9.0.tar \ && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/compiler/gn/1717/linux/gn-linux-x86-1717.tar.gz \ - && wget -P /home/tools https://mirrors.huaweicloud.com/nodejs/v12.20.0/node-v12.20.0-linux-x64.tar.gz \ - && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/develop_tools/hmos_app_packing_tool.jar \ - && wget -P /home/tools https://repo.huaweicloud.com/harmonyos/develop_tools/hapsigntoolv2.jar \ - && tar xvf /home/tools/llvm.tar.gz -C /home/tools \ - && tar xvf /home/tools/hc-gen-0.65-linux.tar -C /home/tools \ - && tar xvf /home/tools/gcc_riscv32-linux-7.3.0.tar.gz -C /home/tools \ - && tar xvf /home/tools/ninja.1.9.0.tar -C /home/tools \ - && tar xvf /home/tools/gn-linux-x86-1717.tar.gz -C /home/tools \ - && tar xvf /home/tools/node-v12.20.0-linux-x64.tar.gz -C /home/tools \ + && wget -P /home/tools https://mirrors.huaweicloud.com/nodejs/v14.15.4/node-v14.15.4-linux-x64.tar.xz \ + && wget -P /home/tools https://hm-verify.obs.cn-north-4.myhuaweicloud.com/qemu-5.2.0.tar.xz \ + && tar -xvf /home/tools/llvm.tar.gz -C /home/tools \ + && tar -xvf /home/tools/hc-gen-0.65-linux.tar -C /home/tools \ + && tar -xvf /home/tools/gcc_riscv32-linux-7.3.0.tar.gz -C /home/tools \ + && tar -xvf /home/tools/ninja.1.9.0.tar -C /home/tools \ + && tar -xvf /home/tools/gn-linux-x86-1717.tar.gz -C /home/tools/gn \ + && tar -xJf /home/tools/node-v14.15.4-linux-x64.tar.xz -C /home/tools \ + && cp /home/tools/node-v14.15.4-linux-x64/bin/node /usr/local/bin \ + && ln -s /home/tools/node-v14.15.4-linux-x64/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ + && ln -s /home/tools/node-v14.15.4-linux-x64/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \ + && tar -xJf /home/tools/qemu-5.2.0.tar.xz -C /home/tools \ && sed -i '$aexport PATH=/home/tools/llvm/bin:$PATH' /root/.bashrc \ && sed -i '$aexport PATH=/home/tools/hc-gen:$PATH' /root/.bashrc \ && sed -i '$aexport PATH=/home/tools/gcc_riscv32/bin:$PATH' /root/.bashrc \ && sed -i '$aexport PATH=/home/tools/ninja:$PATH' /root/.bashrc \ - && sed -i '$aexport PATH=/home/tools/node-v12.20.0-linux-x64/bin:$PATH' /root/.bashrc \ - && sed -i '$aexport PATH=/home/tools:$PATH' /root/.bashrc \ + && sed -i '$aexport PATH=/home/tools/node-v14.15.4-linux-x64/bin:$PATH' /root/.bashrc \ + && sed -i '$aexport PATH=/home/tools/gn:$PATH' /root/.bashrc \ && sed -i '$aexport PATH=/root/.local/bin:$PATH' /root/.bashrc \ && export PATH=/home/tools/llvm/bin:$PATH \ && export PATH=/home/tools/hc-gen:$PATH \ && export PATH=/home/tools/gcc_riscv32/bin:$PATH \ && export PATH=/home/tools/ninja:$PATH \ && export PATH=/home/tools/node-v12.20.0-linux-x64/bin:$PATH \ - && export PATH=/home/tools:$PATH \ + && export PATH=/home/tools/gn:$PATH \ && export PATH=/root/.local/bin:$PATH \ + && cd /home/tools/qemu-5.2.0 \ + && mkdir build \ + && cd build \ + && ../configure --target-list=arm-softmmu \ + && make -j \ + && make install \ + && cd /home/openharmony \ && rm -rf /home/tools/*.tar \ && rm -rf /home/tools/*.gz \ + && rm -rf /home/tools/*.xz \ + && rm -rf /home/tools/qemu-5.2.0 \ && npm install -g @ohos/hpm-cli --registry https://mirrors.huaweicloud.com/repository/npm/ ENV LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 diff --git a/docker/README.md b/docker/README.md index 6f536192dcc4a7ea2254aab53b7ea6049ce558dd..d38a6f295c20e79da128ae47d1debdc48b4004e7 100755 --- a/docker/README.md +++ b/docker/README.md @@ -2,30 +2,29 @@ ### Docker镜像简介 -本文为小型和轻量系统类设备Docker使用指导,[点此查看](https://gitee.com/openharmony/docs/blob/master/docker/standard/Readme.md)标准系统类设备使用指导。 +本文为OpenHarmony的Docker编译环境使用指导。 OpenHarmony的Docker镜像托管在**HuaweiCloud SWR**上,开发者可以通过该镜像在很大程度上简化编译前的环境配置。 目前容器化构建选项支持情况如下: -| Docker镜像仓库 | 标签 | 说明 | -| :----------------------------------------------------------- | :------ | :----------------------------------------------------------- | -| `swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker` | `0.0.7` | 已经预安装OpenHarmony版本的编译环境,支持轻量系统类设备(参考内存≥128KB)和小型系统类设备(参考内存≥1MB)的版本构建。 | +| Docker镜像仓库 | 标签 | 说明 | +| :----------------------------------------------------------- | :------ | :------------------------------------ | +| `swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker` | `1.0.0` | 已经预安装OpenHarmony版本的编译环境。 | ### 使用方式及步骤 - 开发者在配置好开发环境后,可以通过以下步骤来使用我们提供的Docker环境。详情请参见[Docker编译环境](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/gettools-acquire.md)。 + 开发者在下载好源码后,可以通过以下步骤来使用我们提供的Docker环境。详情请参见[Docker编译环境](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/gettools-acquire.md)。 1. 获取Docker镜像 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境 ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 3. 通过如下命令启动不同平台的编译 ``` - hb set #设置工作目录。 - . #输入源码所在目录,点(.)表示当前目录。 - 在显示的页面中通过键盘上下键选择需要编译的平台,通过回车确定选择。 + hb set #在显示的页面中通过键盘上下键选择需要编译的平台,通过回车确定选择。 hb build -f #执行编译。 ``` + diff --git a/docker/README_en.md b/docker/README_en.md old mode 100644 new mode 100755 index c41dab5a571836e7fc860fc60cef2423daa165f0..9853079a565ee82d2a752ec134b6c29acc7ab43b --- a/docker/README_en.md +++ b/docker/README_en.md @@ -2,30 +2,28 @@ ### Docker Image -This document provides guidance on building the Docker image for mini- and small-system devices. For details about how to build the Docker image for standard-system devices, see [OpenHarmony Docker Image](https://gitee.com/openharmony/docs/blob/master/docker/standard/Readme-en.md) +This document provides guidance on building the Docker image for mini- and small-system devices. The Docker image of OpenHarmony is hosted on [HUAWEI Cloud SWR](https://auth.huaweicloud.com/authui/login.html?service=https%3A%2F%2Fconsole.huaweicloud.com%2Fswr%2F%3Fregion%3Dcn-south-1%26cloud_route_state%3D%2Fapp%2Fwarehouse%2FwarehouseMangeDetail%2Fgoldensir%2Fopenharmony-docker%2Fopenharmony-docker%3Ftype%3DownImage&locale=en-us#/login). Using the Docker image will help simplify environment configurations needed for the building. The following table lists container-based options needed for building in the standalone Docker environment. -| Docker Image Repository | Tag | Description | -| :----------------------------------------------------------- | :------ | :----------------------------------------------------------- | -| `swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker` | `0.0.7` | The OpenHarmony build environment has been pre-installed. This repository applies to Mini-System Devices (reference memory ≥ 128 KB) and Small-System Devices (reference memory ≥ 1 MB). | +| Docker Image Repository | Tag | Description | +| :----------------------------------------------------------- | :------ | :-------------------------------------------------------- | +| `swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker` | `1.0.0` | The OpenHarmony build environment has been pre-installed. | ### Usage - After configuring the development environments, perform the steps below to access the Docker environment. + After downloading the OpenHarmony code, perform the steps below to access the Docker environment. 1. Obtain the Docker image. ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment: ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 3. Run the following script to start building for different platforms. ``` - hb set # Set the working directory. - . # Enter the directory where the source code is stored. If the code is stored in the current directory, enter a period (.). - Press the Up or Down key to select the platform to build on, then press Enter. + hb set # Press the Up or Down key to select the platform to build on, then press Enter. hb build -f # Start building. ``` diff --git a/docker/build.sh b/docker/build.sh index 0c8b1fc8b366bf308a245a0e0d2de01be4986ba9..e1a7618251929cd060b0e33c4763e4bb5e5f9057 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -docker build -t openharmony-docker:0.0.7 . +docker build -t openharmony-docker:1.0.0 . diff --git a/docker/standard/CHANGELOG.md b/docker/standard/CHANGELOG.md deleted file mode 100644 index c37b6bc9eefa502a81f7a28c37063a16ca665504..0000000000000000000000000000000000000000 --- a/docker/standard/CHANGELOG.md +++ /dev/null @@ -1,36 +0,0 @@ - ### 0.0.8(2022/01/16) - -新增安装doxygen。 - - ### 0.0.7(2022/01/11) - -新增安装genext2fs和liblz4-tool。 - - ### 0.0.6(2022/01/04) - -新增安装hb。 - - ### 0.0.5(2021/10/28) - -新增安装tar、binutils、git-lfs、gnutls-bin、python3.8、python3-pip、cpio。 - - ### 0.0.4(2021/09/18) - -1、删除编译依赖的工具预装。 - -2、增加安装ruby。 - - ### 0.0.3(2021/08/30) - -1、更新llvm版本从10.0.1-62608更新到10.0.1-69957。 - -2、增加安装gcc_aarch64。 - - ### 0.0.2(2021/08/11) - -新增安装llvm-10.0.1-62608和restool工具。 - - ### 0.0.1(2021/06/02) - -提供OpenHarmony 2.0版本docker编译环境,预装编译依赖工具。 - diff --git a/docker/standard/CHANGELOG_en.md b/docker/standard/CHANGELOG_en.md deleted file mode 100644 index ce1cceda1cc1fab4f061a0b3dd3db106a88ad27c..0000000000000000000000000000000000000000 --- a/docker/standard/CHANGELOG_en.md +++ /dev/null @@ -1,35 +0,0 @@ - ### 0.0.8 (2022/01/16) - -Added the installation of doxygen. - - ### 0.0.7 (2022/01/11) - -Added the installation of genext2fs and liblz4-tool. - - ### 0.0.6 (2022/01/04) - -Added the installation of hb. - - ### 0.0.5 (2021/10/28) - -Added the installation of tar, binutils, git-lfs, gnutls-bin, python3.8, python3-pip, and cpio. - - ### 0.0.4 (2021/09/18) - -1\. Removed pre-installed build dependency tools. - -2\. Added the Ruby installation. - - ### 0.0.3 (2021/08/30) - -1\. Updated LLVM from 10.0.1-62608 to 10.0.1-69957. - -2\. Added the installation of gcc_aarch64. - - ### 0.0.2 (2021/08/11) - -Added the installation of llvm-10.0.1-62608 and restool. - - ### 0.0.1 (2021/06/02) - -Provided a Docker build environment for OpenHarmony 2.0 and pre-installed build dependency tools. \ No newline at end of file diff --git a/docker/standard/Readme-en.md b/docker/standard/Readme-en.md deleted file mode 100755 index cdfc3cc4a00bccf3d43cfbd20716d7b7979f3258..0000000000000000000000000000000000000000 --- a/docker/standard/Readme-en.md +++ /dev/null @@ -1,31 +0,0 @@ -## Standalone Docker Environment - -This document provides guidance on building the Docker image for standard-system devices. For details about how to build the Docker image for mini- and small-system devices, see [OpenHarmony Docker Image](https://gitee.com/openharmony/docs/blob/master/docker/README_en.md) - -The Docker image of OpenHarmony is hosted on [HUAWEI Cloud SWR](https://auth.huaweicloud.com/authui/login.html?service=https%3A%2F%2Fconsole.huaweicloud.com%2Fswr%2F%3Fregion%3Dcn-south-1%26cloud_route_state%3D%2Fapp%2Fwarehouse%2FwarehouseMangeDetail%2Fgoldensir%2Fopenharmony-docker%2Fopenharmony-docker%3Ftype%3DownImage&locale=en-us#/login). Using the Docker image will help simplify environment configurations needed for the building. After configuring the development environments, perform the steps below to access the Docker environment. The following steps use Ubuntu as an example (Windows is also supported). - -### Setting Up the Docker Environment for Standard-System Devices (reference memory ≥ 128 MB) - -1. Obtain the Docker image. -``` -docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 -``` -2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment: -``` -docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 -``` - -### Building for Standard-System Devices (reference memory ≥ 128 MB) -Run the following script to start building for Standard-System Devices (reference memory ≥ 128 MB) - -``` -./build.sh --product-name {product_name} --ccache -``` -**{product_name}** indicates the platform supported by the current distribution, for example, Hi3516DV300, rk3568. -Files generated during compilation are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory. - - - -**Note** - -You can exit Docker by simply running the **exit** command. \ No newline at end of file diff --git a/docker/standard/Readme.md b/docker/standard/Readme.md deleted file mode 100755 index 5997c8b0ade534df555b6c10dda852c26470c1fe..0000000000000000000000000000000000000000 --- a/docker/standard/Readme.md +++ /dev/null @@ -1,31 +0,0 @@ -## 独立Docker环境 - -本文为标准系统类设备Docker使用指导,[点此查看](https://gitee.com/openharmony/docs/blob/master/docker/README.md)小型和轻量系统类设备使用指导。 - -OpenHarmony的Docker镜像托管在HuaweiCloud SWR上。开发者可以通过该镜像在很大程度上简化编译前的环境配置。开发者在配置好开发环境后,通过以下步骤来使用Docker环境。 - -### 搭建Docker环境-标准系统类设备(参考内存≥128MB) - -1. 获取Docker镜像。 -``` -docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 -``` -2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境。 -``` -docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 -``` - -### 编译源码-标准系统类设备(参考内存≥128MB) -通过如下编译脚本启动标准系统类设备(参考内存≥128MB)的编译。 - -``` -./build.sh --product-name {product_name} --ccache -``` -{product_name}为当前版本支持的平台。比如:Hi3516DV300、rk3568等。 -编译所生成的文件都归档在out/{device_name}/目录下,结果镜像输出在 out/{device_name}/packages/phone/images/ 目录下。 - - - -**说明** - - 退出Docker执行exit命令即可。 \ No newline at end of file diff --git a/docker/standard/build.sh b/docker/standard/build.sh deleted file mode 100755 index d51927c8ef85f25177137361ea5e22fa0c3da081..0000000000000000000000000000000000000000 --- a/docker/standard/build.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -docker build -t openharmony-docker-standard:0.0.8 . diff --git a/docker/standard/dockerfile b/docker/standard/dockerfile deleted file mode 100755 index 5451542fc8a01443781d940093001760ad4bfc5b..0000000000000000000000000000000000000000 --- a/docker/standard/dockerfile +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM ubuntu:18.04 -WORKDIR /home/openharmony - -ARG DEBIAN_FRONTEND=noninteractive -ARG PREBUILTS_DIR=/home/prebuilts -ARG HOME_TOOLS=/home/tools - -RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak - -COPY sources.list /etc/apt - -RUN apt-get update \ - && apt-get install -y \ - apt-utils \ - vim \ - tar \ - binutils \ - software-properties-common \ - openssh-server \ - iputils-ping \ - curl \ - net-tools \ - bsdmainutils \ - kmod \ - bc \ - rsync \ - gawk \ - ssh \ - ccache \ - zip \ - python-dev \ - make \ - m4 \ - gcc-multilib \ - ca-certificates-java \ - unzip \ - python3-yaml \ - perl \ - openssl \ - libssl1.1 \ - gnupg \ - xsltproc \ - x11proto-core-dev \ - tcl \ - python3-crypto \ - python-yaml \ - python-crypto \ - libxml2-utils \ - libxml2-dev \ - libx11-dev \ - libssl-dev \ - libgl1-mesa-dev \ - lib32z1-dev \ - lib32ncurses5-dev \ - g++-multilib \ - flex \ - bison \ - doxygen \ - git \ - git-lfs \ - subversion \ - tofrodos \ - pigz \ - expect \ - python3-xlrd \ - python-xlrd \ - wget \ - git-core \ - gperf \ - build-essential \ - zlib1g-dev \ - libc6-dev-i386 \ - lib32z-dev \ - openjdk-8-jdk \ - ruby \ - gnutls-bin \ - python3.8 \ - python3-pip \ - cpio \ - genext2fs \ - doxygen \ - liblz4-tool \ - && rm -rf /bin/sh /usr/bin/python /usr/bin/python3 \ - && ln -s /bin/bash /bin/sh \ - && ln -s /usr/bin/python3.8 /usr/bin/python3 \ - && ln -s /usr/bin/python3.8 /usr/bin/python \ - && python3 -m pip install --user ohos-build \ - && mkdir -p $PREBUILTS_DIR/prebuilts $HOME_TOOLS - -RUN wget -P $HOME_TOOLS https://mirrors.huaweicloud.com/nodejs/v12.18.4/node-v12.18.4-linux-x64.tar.gz \ - && wget -P $HOME_TOOLS https://mirrors.huaweicloud.com/nodejs/v12.18.4/node-v12.18.4-darwin-x64.tar.gz \ - && tar xvf $HOME_TOOLS/node-v12.18.4-linux-x64.tar.gz -C $PREBUILTS_DIR/prebuilts \ - && tar xvf $HOME_TOOLS/node-v12.18.4-darwin-x64.tar.gz -C $PREBUILTS_DIR/prebuilts \ - && sed -i '$aexport PATH='"$PREBUILTS_DIR"'/prebuilts/node-v12.18.4-linux-x64/bin:$PATH' /root/.bashrc \ - && sed -i '$aexport PATH='"$PREBUILTS_DIR"'/prebuilts/hc-gen:$PATH' /root/.bashrc \ - && export PATH=$PATH:$PREBUILTS_DIR/prebuilts/node-v12.18.4-linux-x64/bin \ - && export PATH=$PATH:$PREBUILTS_DIR/prebuilts/hc-gen \ - && rm -rf $HOME_TOOLS \ - && npm install -g @ohos/hpm-cli --registry https://registry.npm.taobao.org diff --git a/docker/standard/sources.list b/docker/standard/sources.list deleted file mode 100755 index 78030974c6f1729f8d290a59aa3c83f30cc4c472..0000000000000000000000000000000000000000 --- a/docker/standard/sources.list +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2020 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -deb http://mirrors.ustc.edu.cn/ubuntu/ bionic main multiverse restricted universe -deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main multiverse restricted universe -deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main multiverse restricted universe -deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main multiverse restricted universe -deb http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main multiverse restricted universe -deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic main multiverse restricted universe -deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main multiverse restricted universe -deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main multiverse restricted universe -deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-security main multiverse restricted universe -deb-src http://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main multiverse restricted universe \ No newline at end of file diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md index 206b69d6dc613a4e9434bbbf161f2d33c99c1b1c..dd682c80aab3d6eb42c86251fab551a3e0991e10 100644 --- a/en/application-dev/Readme-EN.md +++ b/en/application-dev/Readme-EN.md @@ -3,7 +3,6 @@ - [Application Development Overview](application-dev-guide.md) - [DevEco Studio \(OpenHarmony\) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - [Directory Structure](quick-start/package-structure.md) -- [Getting Started](quick-start/start.md) - [ArkUI](ui/ui-arkui.md) - [JavaScript-based Web-like Development Paradigm](ui/ui-arkui-js.md) diff --git a/en/application-dev/media/audio-overview.md b/en/application-dev/media/audio-overview.md index 5aac5895bc5d0fc7db7ae0351095b1acf265f8e0..c313e9315eb46c440efb116e318148a666d44012 100755 --- a/en/application-dev/media/audio-overview.md +++ b/en/application-dev/media/audio-overview.md @@ -1,8 +1,8 @@ # Audio Overview -OpenHarmony provides the audio module for your application to implement audio-related features, including audio playback and volume management. +You can use APIs provided by the audio module to implement audio-related features, including audio playback and volume management. ->![](../public_sys-resources/icon-note.gif) **NOTE:** +>![](../public_sys-resources/icon-note.gif) **NOTE** >Due to permission issues, the above features are temporarily unavailable for the standard system. ## Basic Concepts diff --git a/en/application-dev/quick-start/Readme-EN.md b/en/application-dev/quick-start/Readme-EN.md index ae9b9c0c16f12b582364364cac781208f5e1494f..cb35fe17513b8b7111db96b57c7fa00605121b1f 100644 --- a/en/application-dev/quick-start/Readme-EN.md +++ b/en/application-dev/quick-start/Readme-EN.md @@ -11,7 +11,4 @@ - [Configuring the OpenHarmony App Signature](configuring-openharmony-app-signature.md) - [Installing and Running Your OpenHarmony App](installing-openharmony-app.md) - [Directory Structure](package-structure.md) -- [Getting Started](start.md) - - [Preparations](start-overview.md) - - [Getting Started with JavaScript](start-with-js.md) diff --git a/en/application-dev/quick-start/figures/en-us_image_0000001167850660.png b/en/application-dev/quick-start/figures/en-us_image_0000001167850660.png deleted file mode 100644 index 469ca774dde99530329d5e7bd62a5a40fb16237b..0000000000000000000000000000000000000000 Binary files a/en/application-dev/quick-start/figures/en-us_image_0000001167850660.png and /dev/null differ diff --git a/en/application-dev/quick-start/start-overview.md b/en/application-dev/quick-start/start-overview.md deleted file mode 100644 index 90ba0afd82988bde9af320446b52a29c52cddfd0..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/start-overview.md +++ /dev/null @@ -1,62 +0,0 @@ -# Preparations - -## Task Description - -This document is intended for novices at developing apps. You will learn the development procedure from the following sections to build two pages and implement redirection from the first page to the second one. The following figure shows how the pages look on the [Previewer](https://developer.harmonyos.com/en/docs/documentation/doc-guides/previewer-0000001054328973#ZH-CN_TOPIC_0000001056725592__section16523172216252). - -For best results, use the [latest version of DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio#download) for your development. - -![](figures/3.png) - -**Table 1** Comparison between ArkUI paradigms - - - - - - - - - - - - - - - - - - - - - - - - -

Comparison Item

-

JavaScript-based Web-like Development Paradigm

-

TypeScript-based Declarative Development Paradigm

-

Language

-

JS

-

eTS

-

Paradigm

-

Web-like paradigm

-

Declarative paradigm

-

Execution

-

Handled by the framework; data-driven automatic UI update

-

Handled by the framework; data-driven automatic UI update

-

Advantages

-

Simple and easy to use

-

Simplified development, less memory usage, and higher running performance

-
- -## Before You Start - -1. Install DevEco Studio and configure the development environment. For details, see [Configuring the OpenHarmony SDK](configuring-openharmony-sdk.md). -2. Create a project as instructed in [Creating an OpenHarmony Project](create-openharmony-project.md). - - If you are using the JavaScript language, select **Empty Ability** for **Template** and **JS** for **Language**. - -3. Use the [previewer](https://developer.harmonyos.com/en/docs/documentation/doc-guides/previewer-0000001054328973#EN-US_TOPIC_0000001056725592__section16523172216252) or [emulator](https://developer.harmonyos.com/en/docs/documentation/doc-guides/run_simulator-0000001053303709) to run the project. - -Now you have created your first OpenHarmony project. You can continue the development by following instructions in [Getting Started with JavaScript](start-with-js.md). - diff --git a/en/application-dev/quick-start/start-with-js.md b/en/application-dev/quick-start/start-with-js.md deleted file mode 100644 index bee0ea9153406836a01c380e4b3b23adb0c45489..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/start-with-js.md +++ /dev/null @@ -1,114 +0,0 @@ -# Getting Started with JavaScript - -For best results, use the [latest version of DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio#download) for your development. - -## Building the First Page - -1. Add a **Text** and a **Button** component to the first page. - - In the **Project** window, choose **entry** \> **src** \> **main** \> **js** \> **default** \> **pages** \> **index**, open the **index.hml** file, and add the components. - - ``` - -
- - - Hello World - - - -
- ``` - -2. Open the **index.css** file and set text and button styles. - - ``` - /* index.css */ - .container { - flex-direction: column; /* Arrange container items vertically. */ - justify-content: center; /* Center the items along the main axis of the container. */ - align-items: center; /* Center the items along the cross axis of the container. */ - width:100%; - height:100%; - } - /* Set the style for the component of the text class. */ - .text{ - font-size: 42px; - } - /* Set the style for the component of the button class. */ - .button { - width: 240px; - height: 60px; - background-color: #007dff; - font-size: 30px; - text-color: white; - margin-top: 20px; - } - ``` - -3. [Preview](https://developer.harmonyos.com/en/docs/documentation/doc-guides/previewer-0000001054328973#EN-US_TOPIC_0000001056725592__section16523172216252) or [run your app on the emulator](https://developer.harmonyos.com/en/docs/documentation/doc-guides/run_simulator-0000001053303709). The following figure shows the running effect. - - ![](figures/1.png) - - -## Creating the Second Page - -1. In the **Project** window, choose **entry** \> **src** \> **main** \> **js** \> **default**, right-click the **pages** folder, and then choose **New** \> **JS Page**. Name the new page **details** and press **Enter**. - - Below is the structure of the **pages** folder: - - ![](figures/en-us_image_0000001167850660.png) - -2. Open the **details.hml** file, add the **** component, and set its layout. - - ``` - -
- - Hi there - -
- ``` - -3. Open the **details.css** file and set the text style. - - ``` - /* details.css */ - .container { - flex-direction: column; - justify-content: center; - align-items: center; - width:100%; - height:100%; - } - .text { - font-size: 42px; - text-align: center; - } - ``` - - -## Implementing Page Redirection - -1. Open the **index.js** file and import the router module. The page router finds the target page based on its URI for the redirection. The sample code is as follows: - - ``` - // index.js - import router from '@system.router'; - - export default { - launch() { - router.push ({ - uri:'pages/details/details', // Specify the page to be redirected to. - }) - } - } - ``` - -2. [Preview](https://developer.harmonyos.com/en/docs/documentation/doc-guides/previewer-0000001054328973#EN-US_TOPIC_0000001056725592__section16523172216252) or [run your app on the emulator](https://developer.harmonyos.com/en/docs/documentation/doc-guides/run_simulator-0000001053303709) again. The following figure shows the running effect. - - ![](figures/2.png) - - -Congratulations! You have finished developing your app in JavaScript. - diff --git a/en/application-dev/quick-start/start.md b/en/application-dev/quick-start/start.md deleted file mode 100644 index 1e4c7a3ff554ac98af6844a00a2275924a3b5305..0000000000000000000000000000000000000000 --- a/en/application-dev/quick-start/start.md +++ /dev/null @@ -1,7 +0,0 @@ -# Getting Started - -- **[Preparations](start-overview.md)** - -- **[Getting Started with JavaScript](start-with-js.md)** - - diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md index d350833093abdc9acfbab6e5bc199c221fc14c97..e762c752f19da81ceba1c65270150c2348a4a644 100644 --- a/en/application-dev/reference/apis/Readme-EN.md +++ b/en/application-dev/reference/apis/Readme-EN.md @@ -5,40 +5,50 @@ - [ParticleAbility Module](js-apis-particleAbility.md) - [DataAbilityHelper Module](js-apis-dataAbilityHelper.md) - [DataUriUtils Module](js-apis-DataUriUtils.md) + - [Bundle Module](js-apis-Bundle.md) - [Context Module](js-apis-Context.md) - Event Notification - [CommonEvent Module](js-apis-commonEvent.md) - [Notification Module](js-apis-notification.md) - [Reminder Agent](js-apis-reminderAgent.md) -- Resource Management +- Resource Management - [Resource Manager](js-apis-resource-manager.md) - [Internationalization \(intl\) ](js-apis-intl.md) - [Internationalization \(i18n\) ](js-apis-i18n.md) -- Media +- Media - [Audio Management](js-apis-audio.md) - [Media](js-apis-media.md) -- Security +- Security - [User Authentication](js-apis-useriam-userauth.md) - - [Access Control](js-apis-abilityAccessCtrl.md) -- Data Management - - [File Management](js-apis-fileio.md) - - [Lightweight Storage](js-apis-data-storage.md) + - [Access Control](js-apis-abilityAccessCtrl.md) +- Data Management + - [Lightweight Storage (deprecated since 8)](js-apis-data-storage.md) - [Distributed Data Management](js-apis-distributed-data.md) - [Relational Database](js-apis-data-rdb.md) - [Result Set](js-apis-data-resultset.md) - [DataAbilityPredicates](js-apis-data-ability.md) + - [Settings](js-apis-settings.md) +- File Management + - [File Management](js-apis-fileio.md) + - [Statfs](js-apis-statfs.md) + - [Environment](js-apis-environment.md) + - [Public File Access and Management](js-apis-filemanager.md) + - [App Storage Statistics](js-apis-storage-statistics.md) + - [Volume Management](js-apis-volumemanager.md) - Account Management - [Distributed Account Management](js-apis-distributed-account.md) + - [App Account Management](js-apis-appAccount.md) - Telephony Service - [Call](js-apis-call.md) - [SMS](js-apis-sms.md) - [SIM Management](js-apis-sim.md) - [Radio](js-apis-radio.md) -- Network and Connectivity +- Network and Connectivity - [WLAN](js-apis-wifi.md) -- Device Management - - [Sensors](js-apis-sensor.md) - - [Vibration](js-apis-vibrator.md) + - [Bluetooth](js-apis-bluetooth.md) +- Device Management + - [Sensor](js-apis-sensor.md) + - [Vibrator](js-apis-vibrator.md) - [Brightness](js-apis-brightness.md) - [Battery Info](js-apis-battery-info.md) - [Power Management](js-apis-power.md) @@ -50,7 +60,7 @@ - [Display](js-apis-display.md) - [Update](js-apis-update.md) - [USB](js-apis-usb.md) -- Basic Features +- Basic Features - [Application Context](js-apis-basic-features-app-context.md) - [Console Logs](js-apis-basic-features-logs.md) - [Page Routing](js-apis-basic-features-routes.md) @@ -59,12 +69,17 @@ - [Timer](js-apis-basic-features-timer.md) - [Setting the System Time](js-apis-system-time.md) - [Animation](js-apis-basic-features-animator.md) + - [WebGL](js-apis-webgl.md) + - [WebGL2](js-apis-webgl2.md) +- DFX - [HiAppEvent](js-apis-hiappevent.md) - [Performance Tracing](js-apis-hitracemeter.md) - [Fault Logger](js-apis-faultLogger.md) - [Distributed Call Chain Tracing](js-apis-hitracechain.md) - [HiLog](js-apis-hilog.md) -- Language Base Class Library + - [HiChecker](js-apis-hichecker.md) + - [HiDebug](js-apis-hidebug.md) +- Language Base Class Library - [Obtaining Process Information](js-apis-process.md) - [URL String Parsing](js-apis-url.md) - [URI String Parsing](js-apis-uri.md) diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md index c3fa3085f88b515ef084d2517807a6155787f083..8fc52e97652cd9755d7f2e3a2094913301cd5709 100644 --- a/en/application-dev/reference/apis/js-apis-Bundle.md +++ b/en/application-dev/reference/apis/js-apis-Bundle.md @@ -12,7 +12,11 @@ SystemCapability.BundleManager.BundleFramework ## Required Permissions -None +| Required Permissions| Permission Level| Description| +|-------| --------- | ---- | +| ohos.permission.GET_BUNDLE_INFO | normal | Permission to query information about the current application.| +| ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED| system_basic | Permission to query information about all applications.| +| ohos.permission.INSTALL_BUNDLE | system_core | Permission to install or uninstall applications.| ## bundle.getApplicationInfo @@ -20,62 +24,35 @@ getApplicationInfo(bundleName: string, bundleFlags: number, userId: number): Pro Obtains the application information of the specified user based on a given bundle name in asynchronous mode. This method uses a promise to return the result. -**Permission required** +**Required permissions** ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | ------ | ---- | ------------------------------------------------------------ | -| bundleName | string | Yes| Bundle name of the application.| -| bundleFlags | number | Yes| Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | Yes| User ID.| +| bundleName | string | Yes | Bundle name of the application. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** -| Type| Description| +| Type | Description| | ----------- | -------- | | Promise\ | Promise used to return the application information.| **Example** ```js -bundle.getApplicationInfo('com.example.myapplicationInstall', 8, 0).then((data) => { - console.info("name: for begin"); - console.info("name:" + data.name); - console.info("bundleName:" + data.bundleName); - console.info("description:" + data.description); - console.info("descriptionId:" + data.descriptionId); - console.info("iconPath:" + data.iconPath); - console.info("iconId:" + data.iconId); - console.info("label:" + data.label); - console.info("labelId:" + data.labelId); - console.info("deviceId:" + data.deviceId); - console.info("signatureKey:" + data.signatureKey); - console.info("process:" + data.process); - console.info("isSystemApp:" + data.isSystemApp); - console.info("isLauncherApp:" + data.isLauncherApp); - console.info("supportedModes:" + data.supportedModes); - - console.info('getApplicationInfo permissions length [' + data.permissions.length + ']'); - for (var j = 0; j < data.permissions.length; j++) { - console.info("permissions[" + j + "]:" + data.permissions[j]); - } - console.info('getApplicationInfo moduleSourceDirs length [' + data.moduleSourceDirs.length + ']'); - for (var j = 0; j < data.moduleSourceDirs.length; j++) { - console.info("moduleSourceDirs[" + j + "]:" + data.moduleSourceDirs[j]); - } - console.info('getApplicationInfo moduleInfos length [' + data.moduleInfos.length + ']'); - for (var j = 0; j < data.moduleInfos.length; j++) { - console.info("moduleInfos[" + j + "]moduleName:" + data.moduleInfos[j].moduleName); - console.info("moduleInfos[" + j + "]moduleSourceDir:" + data.moduleInfos[j].moduleSourceDir); - } - console.info("entryDir:" + data.entryDir); - console.info("codePath:" + data.codePath); - console.info("dataDir:" + data.dataDir); - console.info("dataBaseDir:" + data.dataBaseDir); - console.info("cacheDir:" + data.cacheDir); +let bundleName = "com.example.myapplication"; +let bundleFlags = 0; +let userId = 100; +bundle.getApplicationInfo(bundleName, bundleFlags, userId) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -87,152 +64,69 @@ getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, call Obtains the application information of the specified user based on a given bundle name in asynchronous mode. This method uses a callback to return the result. -**Permission required** +**Required permissions** ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | ------------------------------- | ---- | ------------------------------------------------------------ | -| bundleName | string | Yes| Bundle name of the application.| -| bundleFlags | number | Yes| Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| -| userId | number | Yes| User ID.| -| callback | AsyncCallback\ | Yes| Callback used to return the application information.| +| bundleName | string | Yes | Bundle name of the application. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback\ | Yes | Callback used to return the application information. | **Example** ```js -bundle.getApplicationInfo('com.example.myapplicationInstall', 8, 0, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info("name: for begin"); - console.info("name:" + data.name); - console.info("bundleName:" + data.bundleName); - console.info("description:" + data.description); - console.info("descriptionId:" + data.descriptionId); - console.info("iconPath:" + data.iconPath); - console.info("iconId:" + data.iconId); - console.info("label:" + data.label); - console.info("labelId:" + data.labelId); - console.info("deviceId:" + data.deviceId); - console.info("signatureKey:" + data.signatureKey); - console.info("process:" + data.process); - console.info("isSystemApp:" + data.isSystemApp); - console.info("isLauncherApp:" + data.isLauncherApp); - console.info("supportedModes:" + data.supportedModes); - - console.info('getApplicationInfo permissions length [' + data.permissions.length + ']'); - for (var j = 0; j < data.permissions.length; j++) { - console.info("permissions[" + j + "]:" + data.permissions[j]); - } - console.info('getApplicationInfo moduleSourceDirs length [' + data.moduleSourceDirs.length + ']'); - for (var j = 0; j < data.moduleSourceDirs.length; j++) { - console.info("moduleSourceDirs[" + j + "]:" + data.moduleSourceDirs[j]); - } - console.info('getApplicationInfo moduleInfos length [' + data.moduleInfos.length + ']'); - for (var j = 0; j < data.moduleInfos.length; j++) { - console.info("moduleInfos[" + j + "]moduleName:" + data.moduleInfos[j].moduleName); - console.info("moduleInfos[" + j + "]moduleSourceDir:" + data.moduleInfos[j].moduleSourceDir); - } - console.info("entryDir:" + data.entryDir); - console.info("codePath:" + data.codePath); - console.info("dataDir:" + data.dataDir); - console.info("dataBaseDir:" + data.dataBaseDir); - console.info("cacheDir:" + data.cacheDir); -} +let bundleName = "com.example.myapplication"; +let bundleFlags = 0; +let userId = 100; +bundle.getApplicationInfo(bundleName, bundleFlags, userId, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); + }) ``` ## bundle.getAllBundleInfo -getAllBundleInfo(bundleFlag: BundleFlag): Promise> +getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise> Obtains the information of all available bundles in the system in asynchronous mode. This method uses a promise to return the result. -**Permission required** +**Required permissions** ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ---------- | ---- | ----------------------------------------------------------- | -| bundleFlag | BundleFlag | Yes| Type of information that will be returned.
**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| +| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** -| Type| Description| +| Type | Description | | --------------------------- | ----------------------------------- | | Promise> | Promise used to return the information of all available bundles.| **Example** ```js -bundle.getAllBundleInfo(0).then((data) => { - for (var i = 0; i < data.length; i++) { - console.info("index[" + i + "].name: for begin"); - console.info("index[" + i + "].name:" + data[i].name); - console.info("index[" + i + "].label:" + data[i].label); - console.info("index[" + i + "].description:" + data[i].description); - console.info("index[" + i + "].vendor:" + data[i].vendor); - console.info("index[" + i + "].versionCode:" + data[i].versionCode); - console.info("index[" + i + "].versionName:" + data[i].versionName); - console.info("index[" + i + "].jointUserId:" + data[i].jointUserId); - console.info("index[" + i + "].minSdkVersion:" + data[i].minSdkVersion); - console.info("index[" + i + "].maxSdkVersion:" + data[i].maxSdkVersion); - console.info("index[" + i + "].mainEntry:" + data[i].mainEntry); - console.info("index[" + i + "].cpuAbi:" + data[i].cpuAbi); - console.info("index[" + i + "].appId:" + data[i].appId); - console.info("index[" + i + "].compatibleVersion:" + data[i].compatibleVersion); - console.info("index[" + i + "].targetVersion:" + data[i].targetVersion); - console.info("index[" + i + "].releaseType:" + data[i].releaseType); - console.info("index[" + i + "].uid:" + data[i].uid); - console.info("index[" + i + "].gid:" + data[i].gid); - console.info("index[" + i + "].seInfo:" + data[i].seInfo); - console.info("index[" + i + "].entryModuleName:" + data[i].entryModuleName); - console.info("index[" + i + "].isKeepAlive:" + data[i].isKeepAlive); - console.info("index[" + i + "].isNativeApp:" + data[i].isNativeApp); - console.info("index[" + i + "].installTime:" + data[i].installTime); - console.info("index[" + i + "].updateTime:" + data[i].updateTime); - console.info("index[" + i + "].appInfo.name:" + data[i].applicationInfo.name); - console.info("index[" + i + "].appInfo.bundleName:" + data[i].applicationInfo.bundleName); - console.info('getAllBundleInfo reqPermissions length [' + data[i].reqPermissions.length + ']'); - for (var j = 0; j < data[i].reqPermissions.length; j++) { - console.info("index[" + i + "]reqPermissions[" + j + "]:" + data[i].reqPermissions[j]); - } - console.info('getAllBundleInfo defPermissions length [' + data[i].defPermissions.length + ']'); - for (var j = 0; j < data[i].defPermissions.length; j++) { - console.info("index[" + i + "]defPermissions[" + j + "]:" + data[i].defPermissions[j]); - } - - console.info('getAllBundleInfo hapModuleNames length [' + data[i].hapModuleNames.length + ']'); - for (var j = 0; j < data[i].hapModuleNames.length; j++) { - console.info("index[" + i + "]hapModuleNames[" + j + "]:" + data[i].hapModuleNames[j]); - } - console.info('getAllBundleInfo moduleNames length [' + data[i].moduleNames.length + ']'); - for (var j = 0; j < data[i].moduleNames.length; j++) { - console.info("index[" + i + "]moduleNames[" + j + "]:" + data[i].moduleNames[j]); - } - console.info('getAllBundleInfo modulePublicDirs length [' + data[i].modulePublicDirs.length + ']'); - for (var j = 0; j < data[i].modulePublicDirs.length; j++) { - console.info("index[" + i + "]modulePublicDirs[" + j + "]:" + data[i].modulePublicDirs[j]); - } - console.info('getAllBundleInfo moduleDirs length [' + data[i].moduleDirs.length + ']'); - for (var j = 0; j < data[i].moduleDirs.length; j++) { - console.info("index[" + i + "]moduleDirs[" + j + "]:" + data[i].moduleDirs[j]); - } - console.info('getAllBundleInfo moduleResPaths length [' + data[i].moduleResPaths.length + ']'); - for (var j = 0; j < data[i].moduleResPaths.length; j++) { - console.info("index[" + i + "]moduleResPaths[" + j + "]:" + data[i].moduleResPaths[j]); - } - console.info('getAllBundleInfo abilityInfo length [' + data[i].abilityInfos.length + ']'); - for (var j = 0; j < data[i].abilityInfos.length; j++) { - console.info("index[" + i + "]abilityInfos[" + j + "]name:" + data[i].abilityInfos[j].name); - console.info("index[" + i + "]abilityInfos[" + j + "]package:" + data[i].abilityInfos[j].package); - } - } +let bundleFlag = 0; +let userId = 100; +bundle.getAllBundleInfo(bundleFlag, userId) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -244,177 +138,103 @@ getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| -| callback | AsyncCallback> | Yes| Callback used to return the information of all available bundles.| +| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. | **Example** ```js -bundle.getAllBundleInfo(0, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info('xxx getAllBundleInfo data length [' + data.length + ']'); - for (var i = 0; i < data.length; i++) { - console.info("index[" + i + "].name: for begin"); - console.info("index[" + i + "].name:" + data[i].name); - console.info("index[" + i + "].label:" + data[i].label); - console.info("index[" + i + "].description:" + data[i].description); - console.info("index[" + i + "].vendor:" + data[i].vendor); - console.info("index[" + i + "].versionCode:" + data[i].versionCode); - console.info("index[" + i + "].versionName:" + data[i].versionName); - console.info("index[" + i + "].jointUserId:" + data[i].jointUserId); - console.info("index[" + i + "].minSdkVersion:" + data[i].minSdkVersion); - console.info("index[" + i + "].maxSdkVersion:" + data[i].maxSdkVersion); - console.info("index[" + i + "].mainEntry:" + data[i].mainEntry); - console.info("index[" + i + "].cpuAbi:" + data[i].cpuAbi); - console.info("index[" + i + "].appId:" + data[i].appId); - console.info("index[" + i + "].compatibleVersion:" + data[i].compatibleVersion); - console.info("index[" + i + "].targetVersion:" + data[i].targetVersion); - console.info("index[" + i + "].releaseType:" + data[i].releaseType); - console.info("index[" + i + "].uid:" + data[i].uid); - console.info("index[" + i + "].gid:" + data[i].gid); - console.info("index[" + i + "].seInfo:" + data[i].seInfo); - console.info("index[" + i + "].entryModuleName:" + data[i].entryModuleName); - console.info("index[" + i + "].isKeepAlive:" + data[i].isKeepAlive); - console.info("index[" + i + "].isNativeApp:" + data[i].isNativeApp); - console.info("index[" + i + "].installTime:" + data[i].installTime); - console.info("index[" + i + "].updateTime:" + data[i].updateTime); - console.info("index[" + i + "].appInfo.name:" + data[i].applicationInfo.name); - console.info("index[" + i + "].appInfo.bundleName:" + data[i].applicationInfo.bundleName); - console.info('getAllBundleInfo reqPermissions length [' + data[i].reqPermissions.length + ']'); - for (var j = 0; j < data[i].reqPermissions.length; j++) { - console.info("index[" + i + "]reqPermissions[" + j + "]:" + data[i].reqPermissions[j]); - } - console.info('getAllBundleInfo defPermissions length [' + data[i].defPermissions.length + ']'); - for (var j = 0; j < data[i].defPermissions.length; j++) { - console.info("index[" + i + "]defPermissions[" + j + "]:" + data[i].defPermissions[j]); - } +let bundleFlag = 0; +bundle.getAllBundleInfo(bundleFlag, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); + }) +``` - console.info('getAllBundleInfo hapModuleNames length [' + data[i].hapModuleNames.length + ']'); - for (var j = 0; j < data[i].hapModuleNames.length; j++) { - console.info("index[" + i + "]hapModuleNames[" + j + "]:" + data[i].hapModuleNames[j]); - } - console.info('getAllBundleInfo moduleNames length [' + data[i].moduleNames.length + ']'); - for (var j = 0; j < data[i].moduleNames.length; j++) { - console.info("index[" + i + "]moduleNames[" + j + "]:" + data[i].moduleNames[j]); - } - console.info('getAllBundleInfo modulePublicDirs length [' + data[i].modulePublicDirs.length + ']'); - for (var j = 0; j < data[i].modulePublicDirs.length; j++) { - console.info("index[" + i + "]modulePublicDirs[" + j + "]:" + data[i].modulePublicDirs[j]); - } - console.info('getAllBundleInfo moduleDirs length [' + data[i].moduleDirs.length + ']'); - for (var j = 0; j < data[i].moduleDirs.length; j++) { - console.info("index[" + i + "]moduleDirs[" + j + "]:" + data[i].moduleDirs[j]); - } - console.info('getAllBundleInfo moduleResPaths length [' + data[i].moduleResPaths.length + ']'); - for (var j = 0; j < data[i].moduleResPaths.length; j++) { - console.info("index[" + i + "]moduleResPaths[" + j + "]:" + data[i].moduleResPaths[j]); - } - console.info('getAllBundleInfo abilityInfo length [' + data[i].abilityInfos.length + ']'); - for (var j = 0; j < data[i].abilityInfos.length; j++) { - console.info("index[" + i + "]abilityInfos[" + j + "]name:" + data[i].abilityInfos[j].name); - console.info("index[" + i + "]abilityInfos[" + j + "]package:" + data[i].abilityInfos[j].package); - } - } -} + +## bundle.getAllBundleInfo + +getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>): void + +Obtains the information of all available bundles in the system in asynchronous mode. This method uses a callback to return the result. + +**Required permissions** + +ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------- | ---- | ------------------------------------------------------------ | +| bundleFlag | BundleFlag | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback> | Yes | Callback used to return the information of all available bundles. | + +**Example** + +```js +let bundleFlag = 0; +let userId = 100; +bundle.getAllBundleInfo(bundleFlag, userId, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); + }) ``` ## bundle.getBundleInfo -getBundleInfo(bundleName: string, bundleFlags: number): Promise\ +getBundleInfo(bundleName: string, bundleFlags: number, options?: BundleOptions): Promise\ Obtains the bundle information based on a given bundle name in asynchronous mode. This method uses a promise to return the result. -**Permission required** +**Required permissions** ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | ------ | ---- | ------------------------------------------------------------ | -| bundleName | string | Yes| Bundle name.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| +| bundleName | string | Yes | Bundle name. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| options | BundleOptions | No | Includes **userId** and **networkId**. | **Return value** -| Type| Description| +| Type | Description | | -------------------- | ------------------------------------------ | | Promise\ | Promise used to return the bundle information.| **Example** ```js -bundle.getBundleInfo('com.example.myapplicationInstall', 1).then((data) => { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("vendor:" + data.vendor); - console.info("versionCode:" + data.versionCode); - console.info("versionName:" + data.versionName); - console.info("jointUserId:" + data.jointUserId); - console.info("minSdkVersion:" + data.minSdkVersion); - console.info("maxSdkVersion:" + data.maxSdkVersion); - console.info("mainEntry:" + data.mainEntry); - console.info("cpuAbi:" + data.cpuAbi); - console.info("appId:" + data.appId); - console.info("compatibleVersion:" + data.compatibleVersion); - console.info("targetVersion:" + data.targetVersion); - console.info("releaseType:" + data.releaseType); - console.info("uid:" + data.uid); - console.info("gid:" + data.gid); - console.info("seInfo:" + data.seInfo); - console.info("entryModuleName:" + data.entryModuleName); - console.info("isKeepAlive:" + data.isKeepAlive); - console.info("isNativeApp:" + data.isNativeApp); - console.info("installTime:" + data.installTime); - console.info("updateTime:" + data.updateTime); - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - console.info('getBundleInfo reqPermissions length [' + data.reqPermissions.length + ']'); - for (var j = 0; j < data.reqPermissions.length; j++) { - console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]); - } - console.info('getBundleInfo defPermissions length [' + data.defPermissions.length + ']'); - for (var j = 0; j < data.defPermissions.length; j++) { - console.info("defPermissions[" + j + "]:" + data.defPermissions[j]); - } - - console.info('getBundleInfo hapModuleNames length [' + data.hapModuleNames.length + ']'); - for (var j = 0; j < data.hapModuleNames.length; j++) { - console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]); - } - console.info('getBundleInfo moduleNames length [' + data.moduleNames.length + ']'); - for (var j = 0; j < data.moduleNames.length; j++) { - console.info("moduleNames[" + j + "]:" + data.moduleNames[j]); - } - console.info('getBundleInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']'); - for (var j = 0; j < data.modulePublicDirs.length; j++) { - console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]); - } - console.info('getBundleInfo moduleDirs length [' + data.moduleDirs.length + ']'); - for (var j = 0; j < data.moduleDirs.length; j++) { - console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]); - } - console.info('getBundleInfo moduleResPaths length [' + data.moduleResPaths.length + ']'); - for (var j = 0; j < data.moduleResPaths.length; j++) { - console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]); - } - console.info('getBundleInfo abilityInfo length [' + data.abilityInfos.length + ']'); - for (var j = 0; j < data.abilityInfos.length; j++) { - console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name); - console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package); - } +let bundleName = "com.example.myapplication"; +let bundleFlags = 1; +let options = { + "userId" : 100, + "networkId" : null +}; +bundle.getBundleInfo(bundleName, bundleFlags, options) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -426,87 +246,70 @@ getBundleInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback\< Obtains the bundle information based on a given bundle name in asynchronous mode. This method uses a callback to return the result. -**Permission required** +**Required permissions** ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | -------------------------- | ---- | ------------------------------------------------------------ | -| bundleName | string | Yes| Bundle name.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| -| callback | AsyncCallback\ | Yes| Callback used to return the bundle information.| +| bundleName | string | Yes | Bundle name. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| callback | AsyncCallback\ | Yes | Callback used to return the bundle information. | **Example** ```js -bundle.getBundleInfo('com.example.myapplicationInstall', 1, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("vendor:" + data.vendor); - console.info("versionCode:" + data.versionCode); - console.info("versionName:" + data.versionName); - console.info("jointUserId:" + data.jointUserId); - console.info("minSdkVersion:" + data.minSdkVersion); - console.info("maxSdkVersion:" + data.maxSdkVersion); - console.info("mainEntry:" + data.mainEntry); - console.info("cpuAbi:" + data.cpuAbi); - console.info("appId:" + data.appId); - console.info("compatibleVersion:" + data.compatibleVersion); - console.info("targetVersion:" + data.targetVersion); - console.info("releaseType:" + data.releaseType); - console.info("uid:" + data.uid); - console.info("gid:" + data.gid); - console.info("seInfo:" + data.seInfo); - console.info("entryModuleName:" + data.entryModuleName); - console.info("isKeepAlive:" + data.isKeepAlive); - console.info("isNativeApp:" + data.isNativeApp); - console.info("installTime:" + data.installTime); - console.info("updateTime:" + data.updateTime); - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - console.info('getBundleInfo reqPermissions length [' + data.reqPermissions.length + ']'); - for (var j = 0; j < data.reqPermissions.length; j++) { - console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]); - } - console.info('getBundleInfo defPermissions length [' + data.defPermissions.length + ']'); - for (var j = 0; j < data.defPermissions.length; j++) { - console.info("defPermissions[" + j + "]:" + data.defPermissions[j]); - } - - console.info('getBundleInfo hapModuleNames length [' + data.hapModuleNames.length + ']'); - for (var j = 0; j < data.hapModuleNames.length; j++) { - console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]); - } - console.info('getBundleInfo moduleNames length [' + data.moduleNames.length + ']'); - for (var j = 0; j < data.moduleNames.length; j++) { - console.info("moduleNames[" + j + "]:" + data.moduleNames[j]); - } - console.info('getBundleInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']'); - for (var j = 0; j < data.modulePublicDirs.length; j++) { - console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]); - } - console.info('getBundleInfo moduleDirs length [' + data.moduleDirs.length + ']'); - for (var j = 0; j < data.moduleDirs.length; j++) { - console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]); - } - console.info('getBundleInfo moduleResPaths length [' + data.moduleResPaths.length + ']'); - for (var j = 0; j < data.moduleResPaths.length; j++) { - console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]); - } - console.info('getBundleInfo abilityInfo length [' + data.abilityInfos.length + ']'); - for (var j = 0; j < data.abilityInfos.length; j++) { - console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name); - console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package); - } -} +let bundleName = "com.example.myapplication"; +let bundleFlags = 1; +bundle.getBundleInfo(bundleName, bundleFlags, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) ``` +## bundle.getBundleInfo + +getBundleInfo(bundleName: string, bundleFlags: number, options: BundleOptions, callback: AsyncCallback\): void + +Obtains the bundle information based on a given bundle name in asynchronous mode. This method uses a callback to return the result. + +**Required permissions** + +ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | -------------------------- | ---- | ------------------------------------------------------------ | +| bundleName | string | Yes | Bundle name. | +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| options | BundleOptions | Yes | Includes **userId** and **networkId**. | +| callback | AsyncCallback\ | Yes | Callback used to return the bundle information. | + +**Example** + +```js +let bundleName = "com.example.myapplication"; +let bundleFlags = 1; +let options = { + "userId" : 100, + "networkId" : null +}; +bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) +``` + ## bundle.getAllApplicationInfo @@ -514,64 +317,33 @@ getAllApplicationInfo(bundleFlags: number, userId: number): Promise**0**: The default application information will be returned.
**8**: The application information containing the permission information will be returned.| -| userId | number | Yes| User ID.| +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** -| Type| Description| +| Type | Description | | -------------------------------- | ------------------------------------------------ | | Promise> | Promise used to return the application information.| **Example** ```js -bundle.getAllApplicationInfo(8, 0).then((data) => { - console.info('xxx getAllApplicationInfo data length [' + data.length + ']'); - for (var i = 0; i < data.length; i++) { - console.info("index[" + i + "].name: for begin"); - console.info("index[" + i + "].name:" + data[i].name); - console.info("index[" + i + "].bundleName:" + data[i].bundleName); - console.info("index[" + i + "].description:" + data[i].description); - console.info("index[" + i + "].descriptionId:" + data[i].descriptionId); - console.info("index[" + i + "].iconPath:" + data[i].iconPath); - console.info("index[" + i + "].iconId:" + data[i].iconId); - console.info("index[" + i + "].label:" + data[i].label); - console.info("index[" + i + "].labelId:" + data[i].labelId); - console.info("index[" + i + "].deviceId:" + data[i].deviceId); - console.info("index[" + i + "].signatureKey:" + data[i].signatureKey); - console.info("index[" + i + "].process:" + data[i].process); - console.info("index[" + i + "].isSystemApp:" + data[i].isSystemApp); - console.info("index[" + i + "].isLauncherApp:" + data[i].isLauncherApp); - console.info("index[" + i + "].supportedModes:" + data[i].supportedModes); - - console.info('getAllApplicationInfo Async permissions length [' + data[i].permissions.length + ']'); - for (var j = 0; j < data[i].permissions.length; j++) { - console.info("index[" + i + "]permissions[" + j + "]:" + data[i].permissions[j]); - } - console.info('getAllApplicationInfo Async moduleSourceDirs length [' + data[i].moduleSourceDirs.length + ']'); - for (var j = 0; j < data[i].moduleSourceDirs.length; j++) { - console.info("index[" + i + "]moduleSourceDirs[" + j + "]:" + data[i].moduleSourceDirs[j]); - } - console.info('getAllApplicationInfo Async moduleInfos length [' + data[i].moduleInfos.length + ']'); - for (var j = 0; j < data[i].moduleInfos.length; j++) { - console.info("index[" + i + "]moduleInfos[" + j + "]moduleName:" + data[i].moduleInfos[j].moduleName); - console.info("index[" + i + "]moduleInfos[" + j + "]moduleSourceDir:" + data[i].moduleInfos[j].moduleSourceDir); - } - console.info("index[" + i + "].entryDir:" + data[i].entryDir); - console.info("index[" + i + "].codePath:" + data[i].codePath); - console.info("index[" + i + "].dataDir:" + data[i].dataDir); - console.info("index[" + i + "].dataBaseDir:" + data[i].dataBaseDir); - console.info("index[" + i + "].cacheDir:" + data[i].cacheDir); - } +let bundleFlags = 8; +let userId = 100; +bundle.getAllApplicationInfo(bundleFlags, userId) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -583,62 +355,30 @@ getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallba Obtains the information about all installed applications of the specified user. This method uses a callback to return the result. -**Permission required** +**Required permissions** -ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED or ohos.permission.GET\_BUNDLE\_INFO +ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | -------------------------------------- | ---- | ------------------------------------------------------ | -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default application information will be returned.
**8**: The application information containing the permission information will be returned.| -| userId | number | Yes| User ID.| -| callback | AsyncCallback> | Yes| Callback used to return the application information.| +| bundleFlags | number | Yes | Type of information that will be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback> | Yes | Callback used to return the application information. | **Example** ```js -bundle.getAllApplicationInfo(8, 0, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info('xxx getAllApplicationInfo data length [' + data.length + ']'); - for (var i = 0; i < data.length; i++) { - console.info("index[" + i + "].name: for begin"); - console.info("index[" + i + "].name:" + data[i].name); - console.info("index[" + i + "].bundleName:" + data[i].bundleName); - console.info("index[" + i + "].description:" + data[i].description); - console.info("index[" + i + "].descriptionId:" + data[i].descriptionId); - console.info("index[" + i + "].iconPath:" + data[i].iconPath); - console.info("index[" + i + "].iconId:" + data[i].iconId); - console.info("index[" + i + "].label:" + data[i].label); - console.info("index[" + i + "].labelId:" + data[i].labelId); - console.info("index[" + i + "].deviceId:" + data[i].deviceId); - console.info("index[" + i + "].signatureKey:" + data[i].signatureKey); - console.info("index[" + i + "].process:" + data[i].process); - console.info("index[" + i + "].isSystemApp:" + data[i].isSystemApp); - console.info("index[" + i + "].isLauncherApp:" + data[i].isLauncherApp); - console.info("index[" + i + "].supportedModes:" + data[i].supportedModes); - - console.info('getAllApplicationInfo Async permissions length [' + data[i].permissions.length + ']'); - for (var j = 0; j < data[i].permissions.length; j++) { - console.info("index[" + i + "]permissions[" + j + "]:" + data[i].permissions[j]); - } - console.info('getAllApplicationInfo Async moduleSourceDirs length [' + data[i].moduleSourceDirs.length + ']'); - for (var j = 0; j < data[i].moduleSourceDirs.length; j++) { - console.info("index[" + i + "]moduleSourceDirs[" + j + "]:" + data[i].moduleSourceDirs[j]); - } - console.info('getAllApplicationInfo Async moduleInfos length [' + data[i].moduleInfos.length + ']'); - for (var j = 0; j < data[i].moduleInfos.length; j++) { - console.info("index[" + i + "]moduleInfos[" + j + "]moduleName:" + data[i].moduleInfos[j].moduleName); - console.info("index[" + i + "]moduleInfos[" + j + "]moduleSourceDir:" + data[i].moduleInfos[j].moduleSourceDir); - } - console.info("index[" + i + "].entryDir:" + data[i].entryDir); - console.info("index[" + i + "].codePath:" + data[i].codePath); - console.info("index[" + i + "].dataDir:" + data[i].dataDir); - console.info("index[" + i + "].dataBaseDir:" + data[i].dataBaseDir); - console.info("index[" + i + "].cacheDir:" + data[i].cacheDir); - } -} +let bundleFlags = 8; +let userId = 100; +bundle.getAllApplicationInfo(bundleFlags, userId, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) ``` @@ -649,101 +389,38 @@ queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise**0**: The default ability information will be returned.
**2**: The ability information containing the permission information will be returned.
**4**: The ability information containing the application information will be returned.| -| userId | number | No| User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| +| want | Want | Yes | Want that contains the bundle name. | +| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | **Return value** -| Type| Description| +| Type | Description | | ---------------------------- | ---------------------------- | | Promise\>| Promise used to return the ability information.| **Example** ```js -bundle.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplicationInstall", - abilityName: "com.example.myapplication.MainAbility", - }, - } -}, 1, 0, -}).then((data) => { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("iconPath:" + data.iconPath); - console.info("visible:" + data.visible); - console.info("kind:" + data.kind); - console.info("uri:" + data.uri); - console.info("process:" + data.process); - console.info("package:" + data.package); - console.info("bundleName:" + data.bundleName); - console.info("moduleName:" + data.moduleName); - console.info("applicationName:" + data.applicationName); - console.info("deviceId:" + data.deviceId); - console.info("codePath:" + data.codePath); - console.info("resourcePath:" + data.resourcePath); - console.info("libPath:" + data.libPath); - - console.info('queryAbilityInfo permissions length [' + data.permissions.length + ']'); - for (var j = 0; j < data.permissions.length; j++) { - console.info("permissions[" + j + "]:" + data.permissions[j]); - } - console.info('queryAbilityInfo deviceTypes length [' + data.deviceTypes.length + ']'); - for (var j = 0; j < data.deviceTypes.length; j++) { - console.info("deviceTypes[" + j + "]:" + data.deviceTypes[j]); - } - console.info('queryAbilityInfo deviceCapabilities length [' + data.deviceCapabilities.length + ']'); - for (var j = 0; j < data.deviceCapabilities.length; j++) { - console.info("deviceCapabilities[" + j + "]:" + data.deviceCapabilities[j]); - } - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - // ability type: 0:UNKNOWN, 1:PAGE, 2:SERVICE, 3:DATA - console.info("type:" + data.type); - // orientation: 0:UNSPECIFIED, 1:LANDSCAPE, 2:PORTRAIT, 3:FOLLOWRECENT, - console.info("orientation:" + data.orientation); - // launchMode: 0:SINGLETON, 1:SINGLETOP, 2:STANDARD - console.info("launchMode:" + data.launchMode); - - // the enum of AbilityType - console.info("AbilityType:" + bundle.AbilityType.UNKNOWN); - console.info("AbilityType:" + bundle.AbilityType.PAGE); - console.info("AbilityType:" + bundle.AbilityType.SERVICE); - console.info("AbilityType:" + bundle.AbilityType.DATA); - if (data.type == bundle.AbilityType.PAGE) { - console.info("this AbilityType is PAGE"); - } - // the enum of DisplayOrientation - console.info("DisplayOrientation:" + bundle.DisplayOrientation.UNSPECIFIED); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.LANDSCAPE); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.PORTRAIT); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.FOLLOWRECENT); - if (data.orientation == bundle.DisplayOrientation.UNSPECIFIED) { - console.info("this DisplayOrientation is UNSPECIFIED"); - } - // the enum of LaunchMode - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETON); - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETOP); - console.info("LaunchMode:" + bundle.LaunchMode.STANDARD); - if (data.launchMode == bundle.LaunchMode.STANDARD) { - console.info("this LaunchMode is STANDARD"); - } - +let bundleFlags = 0; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; +bundle.queryAbilityByWant(want, bundleFlags, userId) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -757,93 +434,29 @@ Obtains the ability information of the specified user based on a given want. Thi **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| want | Want | Yes| Want that contains the bundle name.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default ability information will be returned.
**2**: The ability information containing the permission information will be returned.
**4**: The ability information containing the application information will be returned.| -| userId | number | Yes| User ID.| -| callback | AsyncCallback> | Yes| Callback used to return the ability information.| +| want | Want | Yes | Want that contains the bundle name. | +| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. | +| callback | AsyncCallback> | Yes | Callback used to return the ability information. | **Example** ```js -bundle.queryAbilityByWant( - { - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplicationInstall", - abilityName: "com.example.myapplication.MainAbility", - }, - } - }, 1, 0, - }, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("iconPath:" + data.iconPath); - console.info("visible:" + data.visible); - console.info("kind:" + data.kind); - console.info("uri:" + data.uri); - console.info("process:" + data.process); - console.info("package:" + data.package); - console.info("bundleName:" + data.bundleName); - console.info("moduleName:" + data.moduleName); - console.info("applicationName:" + data.applicationName); - console.info("deviceId:" + data.deviceId); - console.info("codePath:" + data.codePath); - console.info("resourcePath:" + data.resourcePath); - console.info("libPath:" + data.libPath); - - console.info('queryAbilityInfo permissions length [' + data.permissions.length + ']'); - for (var j = 0; j < data.permissions.length; j++) { - console.info("permissions[" + j + "]:" + data.permissions[j]); - } - console.info('queryAbilityInfo deviceTypes length [' + data.deviceTypes.length + ']'); - for (var j = 0; j < data.deviceTypes.length; j++) { - console.info("deviceTypes[" + j + "]:" + data.deviceTypes[j]); - } - console.info('queryAbilityInfo deviceCapabilities length [' + data.deviceCapabilities.length + ']'); - for (var j = 0; j < data.deviceCapabilities.length; j++) { - console.info("deviceCapabilities[" + j + "]:" + data.deviceCapabilities[j]); - } - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - // ability type: 0:UNKNOWN, 1:PAGE, 2:SERVICE, 3:DATA - console.info("type:" + data.type); - // orientation: 0:UNSPECIFIED, 1:LANDSCAPE, 2:PORTRAIT, 3:FOLLOWRECENT, - console.info("orientation:" + data.orientation); - // launchMode: 0:SINGLETON, 1:SINGLETOP, 2:STANDARD - console.info("launchMode:" + data.launchMode); - - // the enum of AbilityType - console.info("AbilityType:" + bundle.AbilityType.UNKNOWN); - console.info("AbilityType:" + bundle.AbilityType.PAGE); - console.info("AbilityType:" + bundle.AbilityType.SERVICE); - console.info("AbilityType:" + bundle.AbilityType.DATA); - if (data.type == bundle.AbilityType.PAGE) { - console.info("this AbilityType is PAGE"); - } - // the enum of DisplayOrientation - console.info("DisplayOrientation:" + bundle.DisplayOrientation.UNSPECIFIED); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.LANDSCAPE); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.PORTRAIT); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.FOLLOWRECENT); - if (data.orientation == bundle.DisplayOrientation.UNSPECIFIED) { - console.info("this DisplayOrientation is UNSPECIFIED"); - } - // the enum of LaunchMode - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETON); - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETOP); - console.info("LaunchMode:" + bundle.LaunchMode.STANDARD); - if (data.launchMode == bundle.LaunchMode.STANDARD) { - console.info("this LaunchMode is STANDARD"); - } -} +let bundleFlags = 0; +let userId = 100; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; +bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) ``` ## bundle.queryAbilityByWant @@ -854,288 +467,65 @@ Obtains the ability information based on a given want. This method uses an async **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | ---------------------------------- | ---- | ------------------------------------------------------------ | -| want | Want | Yes| Want that contains the bundle name.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default ability information will be returned.
**2**: The ability information containing the permission information will be returned.
**4**: The ability information containing the application information will be returned.| -| callback | AsyncCallback> | Yes| Callback used to return the ability information.| - -**Example** - -```js -bundle.queryAbilityByWant( - { - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplicationInstall", - abilityName: "com.example.myapplication.MainAbility", - }, - } - }, 1, - }, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("iconPath:" + data.iconPath); - console.info("visible:" + data.visible); - console.info("kind:" + data.kind); - console.info("uri:" + data.uri); - console.info("process:" + data.process); - console.info("package:" + data.package); - console.info("bundleName:" + data.bundleName); - console.info("moduleName:" + data.moduleName); - console.info("applicationName:" + data.applicationName); - console.info("deviceId:" + data.deviceId); - console.info("codePath:" + data.codePath); - console.info("resourcePath:" + data.resourcePath); - console.info("libPath:" + data.libPath); - - console.info('queryAbilityInfo permissions length [' + data.permissions.length + ']'); - for (var j = 0; j < data.permissions.length; j++) { - console.info("permissions[" + j + "]:" + data.permissions[j]); - } - console.info('queryAbilityInfo deviceTypes length [' + data.deviceTypes.length + ']'); - for (var j = 0; j < data.deviceTypes.length; j++) { - console.info("deviceTypes[" + j + "]:" + data.deviceTypes[j]); - } - console.info('queryAbilityInfo deviceCapabilities length [' + data.deviceCapabilities.length + ']'); - for (var j = 0; j < data.deviceCapabilities.length; j++) { - console.info("deviceCapabilities[" + j + "]:" + data.deviceCapabilities[j]); - } - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - // ability type: 0:UNKNOWN, 1:PAGE, 2:SERVICE, 3:DATA - console.info("type:" + data.type); - // orientation: 0:UNSPECIFIED, 1:LANDSCAPE, 2:PORTRAIT, 3:FOLLOWRECENT, - console.info("orientation:" + data.orientation); - // launchMode: 0:SINGLETON, 1:SINGLETOP, 2:STANDARD - console.info("launchMode:" + data.launchMode); - - // the enum of AbilityType - console.info("AbilityType:" + bundle.AbilityType.UNKNOWN); - console.info("AbilityType:" + bundle.AbilityType.PAGE); - console.info("AbilityType:" + bundle.AbilityType.SERVICE); - console.info("AbilityType:" + bundle.AbilityType.DATA); - if (data.type == bundle.AbilityType.PAGE) { - console.info("this AbilityType is PAGE"); - } - // the enum of DisplayOrientation - console.info("DisplayOrientation:" + bundle.DisplayOrientation.UNSPECIFIED); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.LANDSCAPE); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.PORTRAIT); - console.info("DisplayOrientation:" + bundle.DisplayOrientation.FOLLOWRECENT); - if (data.orientation == bundle.DisplayOrientation.UNSPECIFIED) { - console.info("this DisplayOrientation is UNSPECIFIED"); - } - // the enum of LaunchMode - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETON); - console.info("LaunchMode:" + bundle.LaunchMode.SINGLETOP); - console.info("LaunchMode:" + bundle.LaunchMode.STANDARD); - if (data.launchMode == bundle.LaunchMode.STANDARD) { - console.info("this LaunchMode is STANDARD"); - } -} -``` - -## bundle.getBundleArchiveInfo - -getBundleArchiveInfo(hapFilePath: string, bundleFlags: number): Promise\ - -Obtains the bundle information from a given HAP file in asynchronous mode. This method uses a promise to return the result. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ----------- | ------ | ---- | ------------------------------------------------------------ | -| hapFilePath | string | Yes| Path of the HAP file.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| - -**Return value** - -| Type| Description| -| -------------------- | ------------------------------------------ | -| Promise\ | Promise used to return the bundle information.| +| want | Want | Yes | Want that contains the bundle name. | +| bundleFlags | number | Yes | Ability information to be returned. The default value is **0**. The value must be greater than or equal to 0.| +| callback | AsyncCallback> | Yes | Callback used to return the ability information. | **Example** ```js -bundle.getBundleArchiveInfo('/data/test.hap', 1).then((data) => { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("vendor:" + data.vendor); - console.info("versionCode:" + data.versionCode); - console.info("versionName:" + data.versionName); - console.info("jointUserId:" + data.jointUserId); - console.info("minSdkVersion:" + data.minSdkVersion); - console.info("maxSdkVersion:" + data.maxSdkVersion); - console.info("mainEntry:" + data.mainEntry); - console.info("cpuAbi:" + data.cpuAbi); - console.info("appId:" + data.appId); - console.info("compatibleVersion:" + data.compatibleVersion); - console.info("targetVersion:" + data.targetVersion); - console.info("releaseType:" + data.releaseType); - console.info("uid:" + data.uid); - console.info("gid:" + data.gid); - console.info("seInfo:" + data.seInfo); - console.info("entryModuleName:" + data.entryModuleName); - console.info("isKeepAlive:" + data.isKeepAlive); - console.info("isNativeApp:" + data.isNativeApp); - console.info("installTime:" + data.installTime); - console.info("updateTime:" + data.updateTime); - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - console.info('getBundleArchiveInfo reqPermissions length [' + data.reqPermissions.length + ']'); - for (var j = 0; j < data.reqPermissions.length; j++) { - console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]); - } - console.info('getBundleArchiveInfo defPermissions length [' + data.defPermissions.length + ']'); - for (var j = 0; j < data.defPermissions.length; j++) { - console.info("defPermissions[" + j + "]:" + data.defPermissions[j]); - } - console.info('getBundleArchiveInfo hapModuleNames length [' + data.hapModuleNames.length + ']'); - for (var j = 0; j < data.hapModuleNames.length; j++) { - console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]); - } - console.info('getBundleArchiveInfo moduleNames length [' + data.moduleNames.length + ']'); - for (var j = 0; j < data.moduleNames.length; j++) { - console.info("moduleNames[" + j + "]:" + data.moduleNames[j]); - } - console.info('getBundleArchiveInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']'); - for (var j = 0; j < data.modulePublicDirs.length; j++) { - console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]); - } - console.info('getBundleArchiveInfo moduleDirs length [' + data.moduleDirs.length + ']'); - for (var j = 0; j < data.moduleDirs.length; j++) { - console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]); - } - console.info('getBundleArchiveInfo moduleResPaths length [' + data.moduleResPaths.length + ']'); - for (var j = 0; j < data.moduleResPaths.length; j++) { - console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]); - } - console.info('getBundleArchiveInfo abilityInfo length [' + data.abilityInfos.length + ']'); - for (var j = 0; j < data.abilityInfos.length; j++) { - console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name); - console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package); - } +let bundleFlags = 0; +let want = { + bundleName : "com.example.myapplication", + abilityName : "com.example.myapplication.MainAbility" +}; +bundle.queryAbilityByWant(want, bundleFlags, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); }) ``` -## bundle.getBundleArchiveInfo - -getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\): void - -Obtains the bundle information from a given HAP file in asynchronous mode. This method uses a callback to return the result. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ----------- | ------------------------- | ---- | ------------------------------------------------------------ | -| hapFilePath | string | Yes| Path of the HAP file.| -| bundleFlags | number | Yes| Type of information that will be returned.
**0**: The default bundle information will be returned.
**1**: The bundle information containing the ability information will be returned.| -| callback | AsyncCallback | Yes| Callback used to return the bundle information.| - -**Example** - -```js -bundle.getBundleArchiveInfo('/data/test.hap', 1, OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.info("name:" + data.name); - console.info("label:" + data.label); - console.info("description:" + data.description); - console.info("vendor:" + data.vendor); - console.info("versionCode:" + data.versionCode); - console.info("versionName:" + data.versionName); - console.info("jointUserId:" + data.jointUserId); - console.info("minSdkVersion:" + data.minSdkVersion); - console.info("maxSdkVersion:" + data.maxSdkVersion); - console.info("mainEntry:" + data.mainEntry); - console.info("cpuAbi:" + data.cpuAbi); - console.info("appId:" + data.appId); - console.info("compatibleVersion:" + data.compatibleVersion); - console.info("targetVersion:" + data.targetVersion); - console.info("releaseType:" + data.releaseType); - console.info("uid:" + data.uid); - console.info("gid:" + data.gid); - console.info("seInfo:" + data.seInfo); - console.info("entryModuleName:" + data.entryModuleName); - console.info("isKeepAlive:" + data.isKeepAlive); - console.info("isNativeApp:" + data.isNativeApp); - console.info("installTime:" + data.installTime); - console.info("updateTime:" + data.updateTime); - console.info("appInfo.name:" + data.applicationInfo.name); - console.info("appInfo.bundleName:" + data.applicationInfo.bundleName); - console.info('getBundleArchiveInfo reqPermissions length [' + data.reqPermissions.length + ']'); - for (var j = 0; j < data.reqPermissions.length; j++) { - console.info("reqPermissions[" + j + "]:" + data.reqPermissions[j]); - } - console.info('getBundleArchiveInfo defPermissions length [' + data.defPermissions.length + ']'); - for (var j = 0; j < data.defPermissions.length; j++) { - console.info("defPermissions[" + j + "]:" + data.defPermissions[j]); - } - console.info('getBundleArchiveInfo hapModuleNames length [' + data.hapModuleNames.length + ']'); - for (var j = 0; j < data.hapModuleNames.length; j++) { - console.info("hapModuleNames[" + j + "]:" + data.hapModuleNames[j]); - } - console.info('getBundleArchiveInfo moduleNames length [' + data.moduleNames.length + ']'); - for (var j = 0; j < data.moduleNames.length; j++) { - console.info("moduleNames[" + j + "]:" + data.moduleNames[j]); - } - console.info('getBundleArchiveInfo modulePublicDirs length [' + data.modulePublicDirs.length + ']'); - for (var j = 0; j < data.modulePublicDirs.length; j++) { - console.info("modulePublicDirs[" + j + "]:" + data.modulePublicDirs[j]); - } - console.info('getBundleArchiveInfo moduleDirs length [' + data.moduleDirs.length + ']'); - for (var j = 0; j < data.moduleDirs.length; j++) { - console.info("moduleDirs[" + j + "]:" + data.moduleDirs[j]); - } - console.info('getBundleArchiveInfo moduleResPaths length [' + data.moduleResPaths.length + ']'); - for (var j = 0; j < data.moduleResPaths.length; j++) { - console.info("moduleResPaths[" + j + "]:" + data.moduleResPaths[j]); - } - console.info('getBundleArchiveInfo abilityInfo length [' + data.abilityInfos.length + ']'); - for (var j = 0; j < data.abilityInfos.length; j++) { - console.info("abilityInfos[" + j + "]name:" + data.abilityInfos[j].name); - console.info("abilityInfos[" + j + "]package:" + data.abilityInfos[j].package); - } -} -``` - ## bundle.getBundleInstaller getBundleInstaller(): Promise Obtains the bundle installer in asynchronous mode. This method uses a promise to return the result. +**Required permissions** + +ohos.permission.INSTALL_BUNDLE + **Return value** -| Type| Description| +| Type | Description | | ------------------------ | --------------------------------------------------- | | Promise | Promise used to return the bundle installer.| **Example** ```js -bundle.getBundleInstaller().then((data) => { - data.install(['/data/test.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } - }, OnReceiveinstallEvent); - - function OnReceiveinstallEvent(err, data) { - console.info("name: for begin"); - console.info("install result code:" + data.status); - console.info("install result msg:" + data.statusMessage); - } +let bundleFilePaths = ['/data/test.hap']; +let param = { + userId : 100, + installFlag : 1, + isKeepData : false +}; +bundle.getBundleInstaller() +.then((installerObject) => { + console.info('Operation successful. '); + installerObject.install(bundleFilePaths, param) + .then((data) => { + console.info('Operation successful. Data:' + JSON.stringify(data)); + }).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); }) ``` @@ -1145,141 +535,401 @@ getBundleInstaller(callback: AsyncCallback): void; Obtains the bundle installer in asynchronous mode. This method uses a callback to return the result. +**Required permissions** + +ohos.permission.INSTALL_BUNDLE + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ------------------------------ | ---- | ------------------------------------------------- | -| callback | AsyncCallback | Yes| Callback used to return the bundle installer.| +| callback | AsyncCallback | Yes | Callback used to return the bundle installer.| **Example** ```js -bundle.getBundleInstaller((err, data)=>{ - data.uninstall('com.example.myapplication', { - userId: 0, - installFlag: 1, - isKeepData: false - }, OnReceiveinstallEvent); - - function OnReceiveinstallEvent(err, data) { - console.info("name: for begin"); - console.info("uninstall result code:" + data.status); - console.info("uninstall result msg:" + data.statusMessage); - } +let bundleFilePaths = ['/data/test.hap']; +let param = { + userId : 100, + installFlag : 1, + isKeepData : false +}; +bundle.getBundleInstaller((err, installerObject) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + } + console.info('Operation successful. Data:' + JSON.stringify(installerObject)); + installerObject.install(bundleFilePaths, param, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + } + console.info('Operation successful. Data:' + JSON.stringify(data)); + }) }) ``` -## bundle.getAllShortcutInfo -getAllShortcutInfo(bundleName: string): Promise> +## bundle.getLaunchWantForBundle + +getLaunchWantForBundle(bundleName: string): Promise\ + +Obtains the **Want** object that launches the specified application in asynchronous mode. This method uses a promise to return the result. -Obtains the shortcut information of the specified bundle in asynchronous mode. This method uses a promise to return the result. +**Required permissions** + +ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ------ | ---- | -------- | -| bundleName | string | Yes| Bundle name.| +| bundleName | string | Yes | Bundle name of the application.| **Return value** -| Type| Description| -| ----------------------------- | ---------------------------------------------------- | -| Promise\> | Promise used to return the shortcut information.| +| Type | Description | +| --------------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the **Want** object.| **Example** ```js -bundle.getAllShortcutInfo('com.example.third1').then((data) => { - console.log("getAllShortcutInfo data:" + data); -}); +let bundleName = "com.example.myapplication"; +bundle.getLaunchWantForBundle(bundleName) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}) ``` +## bundle.getLaunchWantForBundle +getLaunchWantForBundle(bundleName: string, callback: AsyncCallback): void; -## bundle.getAllShortcutInfo +Obtains the **Want** object that launches the specified application in asynchronous mode. This method uses a callback to return the result. -getAllShortcutInfo(bundleName: string, callback: AsyncCallback>): void +**Required permissions** -Obtains the shortcut information of the specified bundle in asynchronous mode. This method uses a callback to return the result. +ohos.permission.GET\_BUNDLE\_INFO\_PRIVILEGED **Parameters** -| Name| Type| Mandatory| Description| -| ---------- | ------------------------------------ | ---- | -------------------------------------------------- | -| bundleName | string | Yes| Bundle name.| -| callback | AsyncCallback<> | Yes| Callback used to return the shortcut information.| +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------- | +| bundleName | string | Yes | Bundle name of the application.| +| callback | AsyncCallback\ | Yes | Callback used to return the **Want** object.| **Example** ```js -bundle.getAllShortcutInfo('com.example.third1', OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.log("getAllShortcutInfo data:" + data); -} +let bundleName = "com.example.myapplication"; +bundle.getLaunchWantForBundle(bundleName, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) ``` -## bundle.checkPermission -checkPermission(bundleName: string, permission: string): Promise\ +## bundle.getNameForUid + +getNameForUid(uid: number): Promise\ -Checks whether a bundle has the specified permission in asynchronous mode. This method uses a promise to return the result. +Obtains the bundle name based on a UID in asynchronous mode. This method uses a promise to return the result. **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ------ | ---- | -------- | -| bundleName | string | Yes| Bundle name.| -| permission | string | Yes| Permission name.| +| uid | number | Yes | UID based on which the bundle name is to obtain.| **Return value** -| Type| Description| +| Type | Description | | --------------------- | ------------------------------------------------------------ | -| Promise\ | Promise used to return the verification result.
**-1**: The bundle does not have the specified permission.
**0**: The bundle has the specified permission.| +| Promise\ | Promise used to return the bundle name.| **Example** ```js -bundle.checkPermission('com.example.actsbmscheckpermissiontest', 'com.permission.CAMERA').then((data) => { - console.log("checkPermission data:" + data); -}); +let uid = 20010005; +bundle.getNameForUid(uid) +.then((data) => { + console.info('Operation successful. Data: ' + JSON.stringify(data)); +}).catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); +}) ``` -## bundle.checkPermission +## bundle.getNameForUid -checkPermission(bundleName: string, permission: string, callback: AsyncCallback\): void +getNameForUid(uid: number, callback: AsyncCallback): void; -Checks whether a bundle has the specified permission in asynchronous mode. This method uses a callback to return the result. +Obtains the bundle name based on a UID in asynchronous mode. This method uses a callback to return the result. **Parameters** -| Name| Type| Mandatory| Description| -| ---------- | --------------------------- | ---- | ------------------------------------------------------------ | -| bundleName | string | Yes| Bundle name.| -| permission | string | Yes| Permission name.| -| callback | AsyncCallback\ | Yes| Callback used to return the verification result.
**-1**: The bundle does not have the specified permission.
**0**: The bundle has the specified permission.| +| Name | Type | Mandatory| Description | +| ---------- | ------ | ---- | -------- | +| uid | number | Yes | UID based on which the bundle name is to obtain.| +| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.| **Example** ```js -bundle.checkPermission('com.example.actsbmscheckpermissiontest', 'com.permission.CAMERA', OnReceiveEvent); - -function OnReceiveEvent(err, data) { - console.log("checkPermission data:" + data); -} +let uid = 20010005; +bundle.getNameForUid(uid, (err, data) => { + if (err) { + console.error('Operation failed. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation successful. Data:' + JSON.stringify(data)); +}) ``` + ## ElementName -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ----------- | -------- | ------ | ---- | ------------------------------------------------------------ | -| deviceId | Read-only| string | No| ID of the device that runs the ability.| -| bundleName | Read-only| string | Yes| Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.| -| abilityName | Read-only| string | Yes| Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.| +| deviceId | Read-only | string | No | ID of the device that runs the ability. | +| bundleName | Read-only | string | Yes | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.| +| abilityName | Read-only | string | Yes | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.| +| uri | Read-only | string | No | Resource ID.| +| shortName | Read-only | string | No | Short name of the **ElementName**.| ## InstallStatus -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ------------- | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| status | Read-only| InstallErrorCode | Yes| Installation result code.
SUCCESS = 0
STATUS_INSTALL_FAILURE = 1
STATUS_INSTALL_FAILURE_ABORTED = 2
STATUS_INSTALL_FAILURE_INVALID = 3
STATUS_INSTALL_FAILURE_CONFLICT = 4
STATUS_INSTALL_FAILURE_STORAGE = 5
STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6
STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B
STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C
STATUS_ABILITY_NOT_FOUND = 0x40
STATUS_BMS_SERVICE_ERROR = 0x41 | -| statusMessage | Read-only| string | Yes| Message indicating the installation result.| +| status | Read-only | InstallErrorCode | Yes | Installation result code.
SUCCESS = 0
STATUS_INSTALL_FAILURE = 1
STATUS_INSTALL_FAILURE_ABORTED = 2,
STATUS_INSTALL_FAILURE_INVALID = 3
STATUS_INSTALL_FAILURE_CONFLICT = 4
STATUS_INSTALL_FAILURE_STORAGE = 5
STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6
STATUS_UNINSTALL_FAILURE = 7
STATUS_UNINSTALL_FAILURE_BLOCKED = 8
STATUS_UNINSTALL_FAILURE_ABORTED = 9
STATUS_UNINSTALL_FAILURE_CONFLICT = 10
STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B
STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C
STATUS_RECOVER_FAILURE_INVALID = 0x0D
STATUS_ABILITY_NOT_FOUND = 0x40
STATUS_BMS_SERVICE_ERROR = 0x41
STATUS_FAILED_NO_SPACE_LEFT = 0x42
STATUS_GRANT_REQUEST_PERMISSIONS_FAILED = 0x43
STATUS_INSTALL_PERMISSION_DENIED = 0x44
STATUS_UNINSTALL_PERMISSION_DENIED = 0x45 | + +## BundleFlag + +Enumerates the bundle flags. + +| Name | Default Value| Description | +| ------ | ------ | ------ | +| GET_BUNDLE_DEFAULT | 0x00000000 | Obtains the default application information.| +| GET_BUNDLE_WITH_ABILITIES | 0x00000001 | Obtains the bundle information with the ability information.| +| GET_ABILITY_INFO_WITH_PERMISSION | 0x00000002 | Obtains the ability information with the permission information.| +| GET_ABILITY_INFO_WITH_APPLICATION | 0x00000004 | Obtains the ability information with the application information.| +| GET_APPLICATION_INFO_WITH_PERMISSION | 0x00000008 | Obtains the application information with the permission information.| +| GET_BUNDLE_WITH_REQUESTED_PERMISSION | 0x00000010 | Obtains the bundle information with the information about the required permissions.| +| GET_ABILITY_INFO_WITH_METADATA | 0x00000020 | Obtains the ability metadata information.| +| GET_APPLICATION_INFO_WITH_METADATA | 0x00000040 | Obtains the application metadata information.| +| GET_ABILITY_INFO_SYSTEMAPP_ONLY | 0x00000080 | Obtains only the ability information with information about system applications.| +| GET_ABILITY_INFO_WITH_DISABLE | 0x00000100 | Obtains information about disabled abilities.| +| GET_APPLICATION_INFO_WITH_DISABLE | 0x00000200 | Obtains information about disabled applications.| +| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | Obtains all application information.| + +## BundleOptions + +Describes the bundle options. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| userId | number | Yes| Yes| User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| +| networkId | string | Yes| Yes| Network ID. The default value is **null**.| + +## BundleInfo + +Describes the application bundle information. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| name | string | Yes | No | Bundle name. | +| type | string | Yes | No | Bundle type. | +| appId | string | Yes | No | ID of the application to which the bundle belongs. | +| uid | number | Yes | No | UID of the application to which the bundle belongs. | +| installTime | number | Yes | No | Time when the HAP file is installed. | +| updateTime | number | Yes | No | Time when the HAP file is updated. | +| appInfo | ApplicationInfo | Yes | No | Application configuration information. | +| abilityInfo | Array | Yes | No | Ability configuration information. | +| reqPermissions | Array | Yes | No | Array of the permissions to request from the system. | +| reqPermissionDetails | Array | Yes | No | Detailed information of the permissions to request from the system.| +| vendor | string | Yes | No | Vendor of the bundle. | +| versionCode | number | Yes | No | Version number of the bundle. | +| versionName | string | Yes | No | Version description of the bundle. | +| compatibleVersion | number | Yes | No | Earliest SDK version required for running the bundle. | +| targetVersion | number | Yes | No | Latest SDK version required for running the bundle. | +| isCompressNativeLibs | boolean | Yes | No | Whether to compress the native library of the bundle. The default value is **true**. | +| hapModuleInfo | Array | Yes | No | Module configuration information. | +| entryModuleName | string | Yes | No | Name of the entry module. | +| cpuAbi | string | Yes | No | cpuAbi information of the bundle. | +| isSilentInstallation | string | Yes | No | Whether to install the bundle in silent mode. | +| minCompatibleVersionCode | number | Yes | No | Earliest version compatible with the bundle in the distributed scenario. | +| entryInstallationFree | boolean | Yes| No| Whether installation-free is supported for the entry.| +| reqPermissionStates | Array | Yes| No| Permission grant state.| + +## ApplicationInfo + +Describes the application information. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| name | string | Yes | No | Application name. | +| description | string | Yes | No | Application description. | +| descriptionId | number | Yes | No | Application description ID. | +| systemApp | boolean | Yes | No | Whether the application is a system application. The default value is **false**. | +| enabled | boolean | Yes | No | Whether the application is enabled. The default value is **true**. | +| label | string | Yes | No | Application label. | +| labelId | string | Yes | No | Application label ID. | +| icon | string | Yes | No | Application icon. | +| iconId | string | Yes | No | Application icon ID. | +| process | string | Yes | No | Process in which this application runs. If this parameter is not set, the bundle name is used by default.| +| supportedModes | number | Yes | No | Running modes supported by the application. | +| moduleSourceDirs | Array | Yes | No | Relative paths for storing application resources. | +| permissions | Array | Yes | No | Permissions required for accessing the application. | +| moduleInfos | Array | Yes | No | Application module information. | +| entryDir | string | Yes | No | Path for storing application files. | +| customizeData | Map> | Yes | Yes | Custom data of the application. | +| codePath | string | Yes| No| Installation directory of the application.| +| metaData | Map> | Yes| No| Custom metadata of the application.| +| removable | boolean | Yes| No| Whether the application is removable.| +| accessTokenId | number | Yes| No| Access token ID of the application.| +| uid | number | Yes| No| UID of the application.| + +## ModuleInfo + +Describes the application module information. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| moduleName | string | Yes | No | Module name.| +| moduleSourceDir | string | Yes | No | Installation directory.| + +## CustomizeData + +Describes the custom metadata. + +| Name | Type | Readable| Writable| Description | +| ----- | ------ | ---- | ---- | ---------------- | +| name | string | Yes | Yes | Custom metadata name.| +| value | string | Yes | Yes | Custom metadata value. | +| extra | string | Yes | Yes | Custom resources. | + + +## HapModuleInfo + +Describes the HAP module information. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| name | string | Yes | No | Module name. | +| description | string | Yes | No | Module description. | +| descriptionId | number | Yes | No | Module description ID. | +| icon | string | Yes | No | Module icon. | +| label | string | Yes | No | Module label. | +| labelId | number | Yes | No | Module label ID. | +| iconId | number | Yes | No | Module icon ID. | +| backgroundImg | string | Yes | No | Module background image. | +| supportedModes | number | Yes | No | Modes supported by the module. | +| reqCapabilities | Array | Yes | No | Capabilities required for module running.| +| deviceTypes | Array | Yes | No | An array of supported device types.| +| abilityInfo | Array | Yes | No | Ability information. | +| moduleName | string | Yes | No | Module name. | +| mainAbilityName | string | Yes | No | Name of the entry ability. | +| installationFree | boolean | Yes | No | Whether installation-free is supported. | +| mainElementName | string | Yes| No| Information about the entry ability.| + +## ReqPermissionDetail + +Describes the detailed information of the permissions to request from the system. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| name | string | Yes | Yes | Name of the permission to request. | +| reason | string | Yes | Yes | Reason for requesting the permission. | +| usedScene | UsedScene | Yes| Yes| Application scenario and timing for using the permission.| + +## UsedScene + +Describes the application scenario and timing for using the permission. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| abilities | Array | Yes | Yes | Abilities that use the permission.| +| when | string | Yes | Yes | Time when the permission is used. | + + +## AbilityInfo + +Describes ability information. + +| Name | Type| Readable| Writable| Description| +| ------ | ------ | ------ | ------ | ------ | +| bundleName | string | Yes | No | Application bundle name. | +| name | string | Yes | No | Ability name. | +| label | string | Yes | No | Ability name visible to users. | +| description | string | Yes | No | Ability description. | +| icon | string | Yes | No | Index of the ability icon resource file. | +| descriptionId | number | Yes | No | Ability description ID. | +| iconId | number | Yes | No | Ability icon ID. | +| moduleName | string | Yes | No | Name of the HAP file to which the ability belongs. | +| process | string | Yes | No | Process in which this ability runs. If this parameter is not set, the bundle name is used by default.| +| targetAbility | string | Yes | No | Target ability that this ability alias points to. | +| backgroundModes | number | Yes | No | Background service mode of the ability. | +| isVisible | boolean | Yes | No | Whether the ability can be called by other applications. | +| formEnabled | boolean | Yes | No | Whether the ability provides the service widget capability. | +| type | AbilityType | Yes | No | Ability type. | +| orientation | DisplayOrientation | Yes | No | Ability display orientation. | +| launchMode | LaunchMode | Yes | No | Ability launch mode. | +| permissions | Array | Yes | No | Permissions required for other applications to call the ability.| +| deviceTypes | Array | Yes | No | Device types supported by the ability. | +| deviceCapabilities | Array | Yes | No | Device capabilities required for the ability. | +| readPermission | string | Yes | No | Permission required for reading the ability data. | +| writePermission | string | Yes | No | Permission required for writing data to the ability. | +| applicationInfo | ApplicationInfo | Yes | No | Application configuration information. | +| formEntity | number | Yes | No | Area where the ability form can be displayed. | +| minFormHeight | number | Yes | No | Minimum height of the ability form. | +| defaultFormHeight | number | Yes | No | Default height of the ability form. | +| minFormWidth | number | Yes | No | Minimum width of the ability form. | +| defaultFormWidth | number | Yes | No | Default width of the ability form. | +| uri | string | Yes | No | URI of the ability. | +| customizeData | Map> | Yes | Yes | Custom data of the ability. | +| labelId | number | Yes | No | Ability label ID. | +| subType | AbilitySubType | Yes | No | Subtype of the template that can be used by the ability. | +| metaData | Array | Yes| No| Custom metadata of the ability.| +| enabled | boolean | Yes| No| Whether the ability is enabled.| + +## AbilityType + +Describes the ability type. + +| Name | Type| Description | +| ------- | ---- | --------------------------- | +| UNKNOWN | None | Unknown ability type. | +| PAGE | None | Ability that has a UI. | +| SERVICE | None | Ability that does not have a UI. | +| DATA | None | Ability that is used to provide data access services.| + +## DisplayOrientation + +Describes the display orientation. + +| Name | Type| Description | +| ------------- | ---- | ------------------------ | +| UNSPECIFIED | None | The system automatically determines the display orientation. | +| LANDSCAPE | None | Landscape orientation. | +| PORTRAIT | None | Portrait orientation. | +| FOLLOW_RECENT | None | The page ability orientation is the same as that of the nearest ability in the stack.| + +## LaunchMode + +Describes the launch mode. + +| Name | Type| Description | +| ----------- | ---- | ------------------- | +| UNSPECIFIED | 0 | The ability has only one instance.| +| STANDARD | 1 | The ability can have multiple instances. | + +## AbilitySubType + +Describes the ability subtype. + +| Name | Type| Description | +| ----------- | ---- | ----------------------------- | +| UNSPECIFIED | 0 | Undefined ability subtype. | +| CA | 1 | Ability that has a UI.| diff --git a/en/application-dev/reference/apis/js-apis-Context.md b/en/application-dev/reference/apis/js-apis-Context.md index 3687d1cea2288447a3fa87e34b8edb8f9403bbba..ea7efb523f253f83fec2133b7a9acb37ddd5727d 100644 --- a/en/application-dev/reference/apis/js-apis-Context.md +++ b/en/application-dev/reference/apis/js-apis-Context.md @@ -25,12 +25,16 @@ Obtains the local root directory of the application. This method uses a callback If this method is called for the first time, a root directory is created. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | -------------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the local root directory of the application.| +| callback | AsyncCallback\ | Yes | Callback used to return the local root directory of the application.| **Example** @@ -52,9 +56,13 @@ Obtains the local root directory of the application. This method uses a promise If this method is called for the first time, a root directory is created. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | ---------------- | ---------------------- | | Promise\ | Promise used to return the local root directory of the application.| @@ -63,8 +71,8 @@ If this method is called for the first time, a root directory is created. ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getOrCreateLocalDir().then((void) => { - console.info("==========================>getOrCreateLocalDirCallback=======================>"); +context.getOrCreateLocalDir().then((data) => { + console.info("data=" + data); }); ``` @@ -76,14 +84,18 @@ verifyPermission(permission: string, options: PermissionOptions, callback: Async Verifies whether a specific PID and UID have the given permission. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | --------------------------------------- | ---- | ------------------------------------- | -| permission | string | Yes| Name of the permission to verify.| -| options | [PermissionOptions](#permissionoptions) | Yes| Permission options.| -| callback | AsyncCallback\ | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| +| permission | string | Yes | Name of the permission to verify. | +| options | [PermissionOptions](#permissionoptions) | Yes | Permission options. | +| callback | AsyncCallback\ | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| **Example** @@ -91,9 +103,9 @@ Verifies whether a specific PID and UID have the given permission. This method u import featureAbility from '@ohos.ability.featureAbility' import bundle from '@ohos.bundle' var context = featureAbility.getContext(); -var datainfo = await bundle.getBundleInfo('com.context.test',1); -context.verifyPermission("com.example.permission",datainfo.uid) - +bundle.getBundleInfo('com.context.test', 1, (datainfo) =>{ + context.verifyPermission("com.example.permission", datainfo.uid); +}); ``` @@ -107,10 +119,10 @@ Verifies whether the current PID and UID have the given permission. This method **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ---------------------- | ---- | ------------------------------------- | -| permission | string | Yes| Name of the permission to verify.| -| callback | AsyncCallback\ | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| +| permission | string | Yes | Name of the permission to verify. | +| callback | AsyncCallback\ | Yes | Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| **Example** @@ -126,17 +138,21 @@ verifyPermission(permission: string, options?: PermissionOptions): Promise\ | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| @@ -146,8 +162,9 @@ Verifies whether a specific PID and UID have the given permission. This method u import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); var Permission = context.PermissionOptions(1,1); -context.getOrCreateLocalDir('com.context.permission',Permission).then((void) => { - console.info("==========================>verifyPermissionCallback=======================>"); +context.verifyPermission('com.context.permission',Permission).then((data) => { + console.info("======================>verifyPermissionCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); }); ``` @@ -159,26 +176,33 @@ requestPermissionsFromUser(permissions: Array\, requestCode: number, res Requests certain permissions from the system. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- | -| permissions | Array\ | Yes| Permissions to request. This parameter cannot be **null**.| -| requestCode | number | Yes| Request code to be passed to **PermissionRequestResult**.| -| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes| Permission request result.| +| permissions | Array\ | Yes | Permissions to request. This parameter cannot be **null**. | +| requestCode | number | Yes | Request code to be passed to **PermissionRequestResult**.| +| resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes | Permission request result. | **Example** ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getOrCreateLocalDir( +context.requestPermissionsFromUser( ["com.example.permission1", "com.example.permission2", "com.example.permission3", "com.example.permission4", "com.example.permission5"], - 1, + 1,(err, data)=>{ + console.info("====>requestdata====>" + JSON.stringify(data)); + console.info("====>requesterrcode====>" + JSON.stringify(err.code)); + } ) ``` @@ -190,11 +214,15 @@ getApplicationInfo(callback: AsyncCallback\) Obtains information about the current application. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ------------------------------- | ---- | ------------------------ | -| callback | AsyncCallback\ | Yes| Callback used to return the application information.| +| callback | AsyncCallback\ | Yes | Callback used to return the application information.| **Example** @@ -212,9 +240,13 @@ getApplicationInfo(): Promise\ Obtains information about the current application. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | ------------------------- | ------------------ | | Promise\ | Promise used to return the application information.| @@ -223,8 +255,9 @@ Obtains information about the current application. This method uses a promise to ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getApplicationInfo().then((void) => { - console.info("==========================>getApplicationInfoCallback=======================>"); +context.getApplicationInfo().then((data) => { + console.info("=====================>getApplicationInfoCallback===================>"); + console.info("====>data====>" + JSON.stringify(data)); }); ``` @@ -236,11 +269,15 @@ getBundleName(callback: AsyncCallback\): void Obtains the bundle name of the current ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ----------------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the bundle name.| +| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.| **Example** @@ -258,9 +295,13 @@ getBundleName(): Promise\ Obtains the bundle name of the current ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | ---------------- | ------------------------- | | Promise\ | Promise used to return the bundle name.| @@ -269,8 +310,9 @@ Obtains the bundle name of the current ability. This method uses a promise to re ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getBundleName().then((void) => { - console.info("==========================>getBundleNameCallback=======================>"); +context.getBundleName().then((data) => { + console.info("=======================>getBundleNameCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); }); ``` @@ -282,11 +324,15 @@ getProcessInfo(callback: AsyncCallback\) Obtains information about the current process, including the PID and process name. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the process information.| +| callback | AsyncCallback\ | Yes | Callback used to return the process information.| **Example** @@ -304,9 +350,13 @@ getProcessInfo(): Promise\ Obtains information about the current process, including the PID and process name. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | --------------------- | -------------- | | Promise\ | Promise used to return the process information.| @@ -315,8 +365,9 @@ Obtains information about the current process, including the PID and process nam ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getProcessInfo().then((void) => { - console.info("==========================>getProcessInfoCallback=======================>"); +context.getProcessInfo().then((data) => { + console.info("=======================>getProcessInfoCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); }); ``` @@ -330,11 +381,15 @@ Obtains the **ohos.bundle.ElementName** object of the current ability. This meth This method is available only to Page abilities. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | --------------------------- | ---- | ---------------------------------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the **ohos.bundle.ElementName** object.| +| callback | AsyncCallback\ | Yes | Callback used to return the **ohos.bundle.ElementName** object.| **Example** @@ -354,9 +409,13 @@ Obtains the **ohos.bundle.ElementName** object of the current ability. This meth This method is available only to Page abilities. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | --------------------- | ------------------------------------------ | | Promise\ | Promise used to return the **ohos.bundle.ElementName** object.| @@ -365,8 +424,9 @@ This method is available only to Page abilities. ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getElementName().then((void) => { - console.info("==========================>getElementNameCallback=======================>"); +context.getElementName().then((data) => { + console.info("=======================>getElementNameCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); }); ``` @@ -376,9 +436,13 @@ getProcessName(callback: AsyncCallback\): void Obtains the name of the current process. This method uses a callback to return the result. -| Name| Type| Mandatory| Description| +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the process name.| +| callback | AsyncCallback\ | Yes | Callback used to return the process name.| **Example** @@ -396,9 +460,13 @@ getProcessName(): Promise\ Obtains the name of the current process. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | ---------------- | -------------------- | | Promise\ | Promise used to return the process name.| @@ -407,8 +475,9 @@ Obtains the name of the current process. This method uses a promise to return th ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getProcessName().then((void) => { - console.info("==========================>getProcessNameCallback=======================>"); +context.getProcessName().then((data) => { + console.info("=======================>getProcessNameCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); }); ``` @@ -420,11 +489,15 @@ getCallingBundle(callback: AsyncCallback\): void Obtains the bundle name of the calling ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the bundle name.| +| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.| **Example** @@ -442,9 +515,13 @@ getCallingBundle(): Promise\ Obtains the bundle name of the calling ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + **Return value** -| Type| Description| +| Type | Description | | --------------- | ------------------------- | | Promise\ | Promise used to return the bundle name.| @@ -453,22 +530,23 @@ Obtains the bundle name of the calling ability. This method uses a promise to re ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -context.getCallingBundle().then((void) => { - console.info("==========================>getCallingBundleCallback=======================>"); +context.getCallingBundle().then((data) => { + console.info("======================>getCallingBundleCallback====================>"); + console.info("====>data====>" + JSON.stringify(data)); }); ``` ## PermissionOptions -| Name| Readable/Writable| Type| Mandatory| Description| +| Name| Readable/Writable| Type | Mandatory| Description | | ---- | -------- | ------ | ---- | ------ | -| pid | Read-only| number | No| PID.| -| uid | Read-only| number | No| UID.| +| pid | Read-only | number | No | PID.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| +| uid | Read-only | number | No | UID.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| ## PermissionRequestResult -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ----------- | -------- | -------------- | ---- | ------------------ | -| requestCode | Read-only| number | Yes| Request code passed.| -| permissions | Read-only| Array\ | Yes| Permissions passed.| -| authResults | Read-only| Array\ | Yes| Permission request result.| +| requestCode | Read-only | number | Yes | Request code passed.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| +| permissions | Read-only | Array\ | Yes | Permissions passed.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core | +| authResults | Read-only | Array\ | Yes | Permission request result.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core | diff --git a/en/application-dev/reference/apis/js-apis-DataUriUtils.md b/en/application-dev/reference/apis/js-apis-DataUriUtils.md index 4aa00cd0b3c9caa6c12a89b5fc5b629bdf6abc4d..b45c839bc405c3cd65bbebe2f029e9930d8074ee 100644 --- a/en/application-dev/reference/apis/js-apis-DataUriUtils.md +++ b/en/application-dev/reference/apis/js-apis-DataUriUtils.md @@ -27,7 +27,6 @@ Obtains the ID attached to the end of a given URI. **Example** ```js -import dataUriUtils from '@ohos.ability.datauriutils' dataUriUtils.getIdSync("com.example.dataUriUtils/1221") ``` @@ -55,10 +54,9 @@ Attaches an ID to the end of a given URI. **Example** ```js -import dataUriUtils from '@ohos.ability.datauriutils' var idint = 1122; dataUriUtils.attachId( - "com.example.dataUriUtils" + "com.example.dataUriUtils", idint, ) ``` @@ -85,7 +83,6 @@ Deletes the ID from the end of a given URI. **Example** ```js -import dataUriUtils from '@ohos.ability.datauriutils' dataUriUtils.deleteId("com.example.dataUriUtils/1221") ``` @@ -112,10 +109,9 @@ Updates the ID in a given URI. **Example** ```js -import dataUriUtils from '@ohos.ability.datauriutils' var idint = 1122; dataUriUtils.updateId( - "com.example.dataUriUtils" - idint, + "com.example.dataUriUtils", + idint ) ``` diff --git a/en/application-dev/reference/apis/js-apis-ability-context.md b/en/application-dev/reference/apis/js-apis-ability-context.md index 5d85731dc2ee337581c5fa38d7d52d60170675d4..7652774178a2357e7a8cb5928545f80348d1c2d2 100644 --- a/en/application-dev/reference/apis/js-apis-ability-context.md +++ b/en/application-dev/reference/apis/js-apis-ability-context.md @@ -1,12 +1,29 @@ # AbilityContext -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** -> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. Implements the ability context. This module is inherited from **Context**. +## Usage + + +Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**. + + + +``` +import Ability from '@ohos.application.Ability' +class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + let context = this.context; + } +} +``` + + ## Attributes | Name| Type| Readable| Writable| Description| @@ -21,6 +38,10 @@ startAbility(want: Want, callback: AsyncCallback<void>): void Starts an ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -42,14 +63,53 @@ Starts an ability. This method uses a callback to return the result. ## startAbility -startAbility(want: Want): Promise<void>; +startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void + +Starts an ability. This method uses a callback to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the **Want** used for starting an ability.| + | options | StartOptions | Yes| Parameters used for starting the ability.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| + +- Example + + ``` + var want = { + "deviceId": "", + "bundleName": "com.extreme.test", + "abilityName": "com.extreme.test.MainAbility" + }; + var options = { + windowMode: 0, + }; + this.context.startAbility(want, options, (error) => { + console.log("error.code = " + error.code) + }) + ``` + + +## startAbility + +startAbility(want: Want, options: StartOptions): Promise<void>; Starts an ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| + | options | StartOptions | Yes| Parameters used for starting the ability.| - Return value | Type| Description| @@ -63,7 +123,10 @@ Starts an ability. This method uses a promise to return the result. "bundleName": "com.extreme.test", "abilityName": "com.extreme.test.MainAbility" }; - this.context.startAbility(want) + var options = { + windowMode: 0, + }; + this.context.startAbility(want, options) .then((data) => { console.log('Operation successful.') }).catch((error) => { @@ -78,11 +141,15 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): Starts an ability. This method uses a callback to return the execution result when the ability is terminated. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | want |[Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| - | callback | Callback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| + | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| - Example @@ -96,17 +163,55 @@ Starts an ability. This method uses a callback to return the execution result wh ); ``` +## startAbilityForResult + +startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void; + +Starts an ability. This method uses a callback to return the execution result when the ability is terminated. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want |[Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| + | options | StartOptions | Yes| Parameters used for starting the ability.| + | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| + + +- Example + ``` + var options = { + windowMode: 0, + }; + this.context.startAbilityForResult( + {bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options, + (error, result) => { + console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code) + console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode) + } + ); + ``` + ## startAbilityForResult -startAbilityForResult(want: Want): Promise<AbilityResult>; +startAbilityForResult(want: Want, options: StartOptions): Promise<AbilityResult>; Starts an ability. This method uses a promise to return the execution result when the ability is terminated. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| + | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the **Want** used for starting an ability.| + | options | StartOptions | Yes| Parameters used for starting the ability.| + - Return value | Type| Description| @@ -115,7 +220,10 @@ Starts an ability. This method uses a promise to return the execution result whe - Example ``` - this.context.startAbilityForResult({bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}).then((result) => { + var options = { + windowMode: 0, + }; + this.context.startAbilityForResult({bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options).then((result) => { console.log("startAbilityForResult Promise.resolve is called, result.resultCode = " + result.resultCode) }, (error) => { console.log("startAbilityForResult Promise.Reject is called, error.code = " + error.code) @@ -129,16 +237,20 @@ terminateSelf(callback: AsyncCallback<void>): void; Terminates this ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the method is successfully called.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the method is successfully called.| - Example ``` this.context.terminateSelf((err) => { - console.log('terminateSelf result:' + JSON.stringfy(err); - } + console.log('terminateSelf result:' + JSON.stringfy(err)); + }); ``` @@ -148,6 +260,10 @@ terminateSelf(): Promise<void>; Terminates this ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Return value | Type| Description| | -------- | -------- | @@ -157,7 +273,7 @@ Terminates this ability. This method uses a promise to return the result. ``` this.context.terminateSelf(want).then((data) => { console.log('success:' + JSON.stringfy(data)); - )).catch((error) => { + }).catch((error) => { console.log('failed:' + JSON.stringfy(error)); }); ``` @@ -169,11 +285,15 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<voi Terminates this ability. This method uses a callback to return the information to the caller of **startAbilityForResult**. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.| - | callback | Callback<void> | No| Callback used to return the information.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result.| - Example ``` @@ -194,6 +314,10 @@ terminateSelfWithResult(parameter: AbilityResult): Promise<void>; Terminates this ability. This method uses a promise to return information to the caller of **startAbilityForResult**. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -215,3 +339,157 @@ Terminates this ability. This method uses a promise to return information to the } ) ``` + + +## startAbilityByCall + +startAbilityByCall(want: Want): Promise<Caller>; + +Obtains the caller interface of the specified ability, and if the specified ability is not started, starts the ability in the background. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<> | Promise used to return the caller object to communicate with.| + +- Example + + ``` + import Ability from '@ohos.application.Ability'; + var caller; + export default class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + this.context.startAbilityByCall({ + bundleName: "com.example.myservice", + abilityName: "com.example.myservice.MainAbility", + deviceId: "" + }).then((obj) => { + caller = obj; + console.log('Caller GetCaller Get ' + call); + }).catch((e) => { + console.log('Caller GetCaller error ' + e); + }); + } + } + ``` + + +## requestPermissionsFromUser + +requestPermissionsFromUser(permissions: Array<string>, requestCallback: AsyncCallback<PermissionRequestResult>) : void; + +Requests permissions from the user by displaying a pop-up window. This method uses a callback to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | permissions | Array<string> | Yes| Permissions to request.| + | callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result indicating whether the method is successfully called.| + +- Example + + ``` + this.context.requestPermissionsFromUser(permissions,(result) => { + console.log('requestPermissionsFromUserresult:' + JSON.stringfy(result)); + }); + ``` + + +## requestPermissionsFromUser + +requestPermissionsFromUser(permissions: Array<string>) : Promise<PermissionRequestResult>; + +Requests permissions from the user by displaying a pop-up window. This method uses a promise to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | permissions | Array<string> | Yes| Permissions to request.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result indicating whether the method is successfully called.| + +- Example + + ``` + this.context.requestPermissionsFromUser(permissions).then((data) => { + console.log('success:' + JSON.stringfy(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringfy(error)); + }); + ``` + + +## setMissionLabel + +setMissionLabel(label: string, callback:AsyncCallback<void>): void; + +Sets the label of the ability displayed in the task. This method uses a callback to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | label | string | Yes| Label of the ability to set.| + | callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the method is successfully called.| + +- Example + + ``` + this.context.setMissionLabel("test",(result) => { + console.log('requestPermissionsFromUserresult:' + JSON.stringfy(result)); + }); + ``` + + +## setMissionLabel + +setMissionLabel(label: string): Promise<void> + +Sets the label of the ability displayed in the task. This method uses a promise to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | label | string | Yes| Label of the ability to set.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<void> | Promise used to return the result indicating whether the method is successfully called.| + +- Example + + ``` + this.context.setMissionLabel("test").then((data) => { + console.log('success:' + JSON.stringfy(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringfy(error)); + }); + ``` diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index b69cb0e03eb33b0e683d773b4bdcb5a379bb6a41..8a747168fbe34c82c02c7233881a1461da2706c5 100644 --- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -217,3 +217,12 @@ promise.then(data => { console.log(`promise: data->${JSON.stringify(data)}`); }); ``` + +### GrantStatus + +Enumerates the permission grant states. + +| Name| Default Value| Description| +| ----------------------------- | ---------------------- | ----------------------- | +| PERMISSION_DENIED | -1 | Permission denied.| +| PERMISSION_GRANTED | 0 | Permission granted.| diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md index f8f6d6d65bc10a819d5ff85b562d9910e47d7b5d..be6cd158135e72fe8fa598c930fd1bf15e3ddd04 100644 --- a/en/application-dev/reference/apis/js-apis-appAccount.md +++ b/en/application-dev/reference/apis/js-apis-appAccount.md @@ -1,6 +1,7 @@ -# Application Account Management +# App Account Management -> ![icon-note.gif](figures/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -11,6 +12,11 @@ import account_appAccount from '@ohos.account.appAccount'; ``` +## System Capabilities + +SystemCapability.Account.AppAccount + + ## account_appAccount.createAppAccountManager createAppAccountManager(): AppAccountManager; @@ -29,13 +35,13 @@ Creates an **AppAccountManager** instance. ## AppAccountManager -Provides methods to manage application accounts. +Provides methods to manage app accounts. ### addAccount addAccount(name: string, callback: AsyncCallback<void>): void; -Adds an application account to the account management service. This method uses an asynchronous callback to return the result. +Adds an app account to the account management service. This method uses an asynchronous callback to return the result. Required permission: none. @@ -43,8 +49,8 @@ Required permission: none. | Name| Type| Mandatory| Description| | -------- | ------------------- | ---- | ------------------------------------------ | - | name | string | Yes| Name of the application account to add.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the application account is added.| + | name | string | Yes| Name of the app account to add.| + | callback | AsyncCallback<void> | Yes| Callback invoked when the app account is added.| - Example @@ -59,7 +65,7 @@ Required permission: none. addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void; -Adds an application account and its additional information to the account management service. This method uses an asynchronous callback to return the result. +Adds an app account and its additional information to the account management service. This method uses an asynchronous callback to return the result. Required permission: none. @@ -67,9 +73,9 @@ Required permission: none. | Name| Type| Mandatory| Description| | --------- | ------------------- | ---- | ------------------------------------------------------------ | - | name | string | Yes| Name of the application account to add.| - | extraInfo | string | Yes| Additional information (for example, token) of the application account to add. The additional information cannot contain sensitive information about the application account.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the application account and its additional information are added.| + | name | string | Yes| Name of the app account to add.| + | extraInfo | string | Yes| Additional information (for example, token) of the app account to add. The additional information cannot contain sensitive information about the app account.| + | callback | AsyncCallback<void> | Yes| Callback invoked when the app account and its additional information are added.| - Example @@ -86,7 +92,7 @@ Required permission: none. addAccount(name: string, extraInfo?: string): Promise<void>; -Adds an application account and its additional information to the account management service. This method uses a promise to return the result asynchronously. +Adds an app account and its additional information to the account management service. This method uses a promise to return the result. Required permission: none. @@ -94,8 +100,8 @@ Required permission: none. | Name| Type| Mandatory| Description| | --------- | ------ | ---- | ------------------------------------------------------------ | - | name | string | Yes| Name of the application account to add.| - | extraInfo | string | Yes| Additional information of the application account to add. The additional information cannot contain sensitive information about the application account.| + | name | string | Yes| Name of the app account to add.| + | extraInfo | string | Yes| Additional information of the app account to add. The additional information cannot contain sensitive information about the app account.| - Return value @@ -114,18 +120,59 @@ Required permission: none. }); ``` +### addAccountImplicitly8+ + +addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; + +Implicitly adds an app account based on the specified account owner, authentication type, and options. This method uses an asynchronous callback to return the result. + +Required permission: none. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | --------------------- | --- | -------------------------- | + | owner | string | Yes| Bundle name of the app account to add.| + | authType | string | Yes| Authentication type of the app account to add.| + | options | {[key: string]: any} | Yes| Options for the authentication.| + | callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.| + +- Example + + ``` + import featureAbility from '@ohos.ability.featureAbility'; + + function onResultCallback(code, result) { + console.log("resultCode: " + code); + console.log("result: " + JSON.stringify(result)); + } + + function onRequestRedirectedCallback(request) { + let abilityStartSetting = {want: request}; + featureAbility.startAbility(abilityStartSetting, (err)=>{ + console.log("startAbility err: " + JSON.stringify(err)); + }); + } + + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.addAccountImplicitly("LiSi", "readAge", {}, { + onResult: onResultCallback, + onRequestRedirected: onRequestRedirectedCallback + }); + ``` + ### deleteAccount deleteAccount(name: string, callback: AsyncCallback<void>): void; -Deletes an application account from the account management service. This method uses an asynchronous callback to return the result. +Deletes an app account from the account management service. This method uses an asynchronous callback to return the result. - Parameters | Name| Type| Mandatory| Description| | -------- | ------------------- | ---- | ---------------------------------- | - | name | string | Yes| Name of the application account to delete.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the application account is deleted.| + | name | string | Yes| Name of the app account to delete.| + | callback | AsyncCallback<void> | Yes| Callback invoked when the app account is deleted.| - Example @@ -140,13 +187,13 @@ Deletes an application account from the account management service. This method deleteAccount(name: string): Promise<void>; -Deletes an application account from the account management service. This method uses a promise to return the result asynchronously. +Deletes an app account from the account management service. This method uses a promise to return the result. - Parameters | Name| Type| Mandatory| Description| | ------ | ------ | ---- | ------------------------ | - | name | string | Yes| Name of the application account to delete.| + | name | string | Yes| Name of the app account to delete.| - Return value @@ -169,15 +216,15 @@ Deletes an application account from the account management service. This method disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void; -Disables the specified third-party application account from accessing the third-party application with the given bundle name. This method uses an asynchronous callback to return the result. +Disables an app account from accessing an application with the given bundle name. This method uses an asynchronous callback to return the result. - Parameters | Name| Type| Mandatory| Description| | ---------- | ------------------- | ---- | ------------------------------------------------------------ | - | name | string | Yes| Name of the third-party application account.| - | bundleName | string | Yes| Bundle name of the third-party application.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the third-party application account is disabled from accessing the third-party application with the given bundle name.| + | name | string | Yes| App account name.| + | bundleName | string | Yes| Bundle name of an app.| + | callback | AsyncCallback<void> | Yes| Callback invoked when the app account is disabled from accessing the application with the given bundle name.| - Example @@ -192,14 +239,14 @@ Disables the specified third-party application account from accessing the third- disableAppAccess(name: string, bundleName: string): Promise<void>; -Disables the specified third-party application account from accessing the third-party application with the given bundle name. This method uses a promise to return the result asynchronously. +Disables an app account from accessing an application with the given bundle name. This method uses a promise to return the result. - Parameters | Name| Type| Mandatory| Description| | ---------- | ------ | ---- | ---------------------------------- | - | name | string | Yes| Name of the third-party application account.| - | bundleName | string | Yes| Bundle name of a third-party application.| + | name | string | Yes| App account name.| + | bundleName | string | Yes| Bundle name of an app.| - Return value @@ -222,15 +269,15 @@ Disables the specified third-party application account from accessing the third- enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void; -Enables the specified third-party application account to access the third-party application with the given bundle name. This method uses an asynchronous callback to return the result. +Enables an app account to access an application with the given bundle name. This method uses an asynchronous callback to return the result. - Parameters | Name| Type| Mandatory| Description| | ---------- | ------------------- | ---- | ------------------------------------------------------------ | - | name | string | Yes| Application account name.| - | bundleName | string | Yes| Bundle name of the third-party application.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the third-party application account is enabled to access the third-party application with the given bundle name.| + | name | string | Yes| App account name.| + | bundleName | string | Yes| Bundle name of an app.| + | callback | AsyncCallback<void> | Yes| Callback invoked when the app account is enabled to access the application with the given bundle name.| - Example @@ -245,14 +292,14 @@ Enables the specified third-party application account to access the third-party enableAppAccess(name: string, bundleName: string): Promise<void>; -Enables the specified third-party application account to access the third-party application with the given bundle name. This method uses a promise to return the result. +Enables an app account to access an application with the given bundle name. This method uses a promise to return the result. - Parameters | Name| Type| Mandatory| Description| | ---------- | ------ | ---- | ------------------ | - | name | string | Yes| Application account name.| - | bundleName | string | Yes| Bundle name of the third-party application.| + | name | string | Yes| App account name.| + | bundleName | string | Yes| Bundle name of an app.| - Return value @@ -274,7 +321,7 @@ Enables the specified third-party application account to access the third-party checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void; -Checks whether the specified application account allows application data synchronization. This method uses an asynchronous callback to return the result. +Checks whether an app account allows application data synchronization. This method uses an asynchronous callback to return the result. The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only. @@ -282,8 +329,8 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis | Name| Type| Mandatory| Description| | -------- | ---------------------- | ---- | -------------------------------------------- | - | name | string | Yes| Application account name.| - | callback | AsyncCallback<boolean> | Yes| Callback invoked to specify whether the application account allows application data synchronization.| + | name | string | Yes| App account name.| + | callback | AsyncCallback<boolean> | Yes| Callback used to return whether the app account allows application data synchronization.| - Example @@ -299,7 +346,7 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis checkAppAccountSyncEnable(name: string): Promise<boolean>; -Checks whether the specified application account allows application data synchronization. This method uses a promise to return the result asynchronously. +Checks whether an app account allows application data synchronization. This method uses a promise to return the result. The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only. @@ -307,7 +354,7 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis | Name| Type| Mandatory| Description| | ------ | ------ | ---- | -------------- | - | name | string | Yes| Application account name.| + | name | string | Yes| App account name.| - Return value @@ -330,16 +377,16 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void; -Sets a credential for an application account. This method uses an asynchronous callback to return the result. +Sets a credential for an app account. This method uses an asynchronous callback to return the result. - Parameters | Name| Type| Mandatory| Description| | -------------- | ------------------- | ---- | ---------------------------- | - | name | string | Yes| Application account name.| + | name | string | Yes| App account name.| | credentialType | string | Yes| Type of the credential to set.| | credential | string | Yes| Credential to set.| - | callback | AsyncCallback<void> | Yes| Callback invoked when a credential is set for the specified application account.| + | callback | AsyncCallback<void> | Yes| Callback invoked when a credential is set for the specified app account.| - Example @@ -354,13 +401,13 @@ Sets a credential for an application account. This method uses an asynchronous c setAccountCredential(name: string, credentialType: string, credential: string): Promise<void>; -Sets a credential for an application account. This method uses a promise to return the result asynchronously. +Sets a credential for an app account. This method uses a promise to return the result asynchronously. - Parameters | Name| Type| Mandatory| Description| | -------------- | ------ | ---- | -------------------- | - | name | string | Yes| Application account name.| + | name | string | Yes| App account name.| | credentialType | string | Yes| Type of the credential to set.| | credential | string | Yes| Credential to set.| @@ -385,15 +432,15 @@ Sets a credential for an application account. This method uses a promise to retu setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void; -Sets additional information for an application account. This method uses an asynchronous callback to return the result. +Sets additional information for an app account. This method uses an asynchronous callback to return the result. - Parameters | Name| Type| Mandatory| Description| | --------- | ------------------- | ---- | -------------------------------- | - | name | string | Yes| Application account name.| + | name | string | Yes| App account name.| | extraInfo | string | Yes| Additional information to set.| - | callback | AsyncCallback<void> | Yes| Callback invoked when additional information is set for the specified application account.| + | callback | AsyncCallback<void> | Yes| Callback invoked when additional information is set for the specified app account.| - Example @@ -408,13 +455,13 @@ Sets additional information for an application account. This method uses an asyn setAccountExtraInfo(name: string, extraInfo: string): Promise<void>; -Sets additional information for an application account. This method uses a promise to return the result asynchronously. +Sets additional information for an app account. This method uses a promise to return the result asynchronously. - Parameters | Name| Type| Mandatory| Description| | --------- | ------ | ---- | ------------------ | - | name | string | Yes| Application account name.| + | name | string | Yes| App account name.| | extraInfo | string | Yes| Additional information to set.| - Return value @@ -438,7 +485,7 @@ Sets additional information for an application account. This method uses a promi setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void; -Sets whether to enable application data synchronization for an application account. This method uses an asynchronous callback to return the result. +Sets whether to enable application data synchronization for an app account. This method uses an asynchronous callback to return the result. The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only. @@ -446,9 +493,9 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis | Name| Type| Mandatory| Description| | -------- | ------------------- | ---- | -------------------------------------------------- | - | name | string | Yes| Application account name.| - | isEnable | boolean | Yes| Specifies whether to enable application data synchronization.| - | callback | AsyncCallback<void> | Yes| Callback invoked when application data synchronization is enabled or disabled for the application account.| + | name | string | Yes| App account name.| + | isEnable | boolean | Yes| Whether to enable app data synchronization.| + | callback | AsyncCallback<void> | Yes| Callback invoked when application data synchronization is enabled or disabled for the app account.| - Example @@ -463,7 +510,7 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>; -Sets whether to enable application data synchronization for an application account. This method uses a promise to return the result asynchronously. +Sets whether to enable application data synchronization for an app account. This method uses a promise to return the result asynchronously. The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permission is intended for system applications only. @@ -471,8 +518,8 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis | Name| Type| Mandatory| Description| | -------- | ------- | ---- | ---------------------- | - | name | string | Yes| Application account name.| - | isEnable | boolean | Yes| Specifies whether to enable application data synchronization.| + | name | string | Yes| App account name.| + | isEnable | boolean | Yes| Whether to enable app data synchronization.| - Return value @@ -495,16 +542,16 @@ The **ohos.permission.DISTRIBUTED_DATASYNC** permission is required. This permis setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void; -Sets data to be associated with an application account. This method uses an asynchronous callback to return the result. +Sets data to be associated with an app account. This method uses an asynchronous callback to return the result. - Parameters | Name| Type| Mandatory| Description| | -------- | ------------------- | ---- | ---------------------------------- | - | name | string | Yes| Application account name.| + | name | string | Yes| App account name.| | key | string | Yes| Key of the data to set. The private key can be customized.| | value | string | Yes| Value of the data to be set.| - | callback | AsyncCallback<void> | Yes| Callback invoked when the data associated with the specified application account is set.| + | callback | AsyncCallback<void> | Yes| Callback invoked when the data associated with the specified app account is set.| - Example @@ -518,13 +565,13 @@ Sets data to be associated with an application account. This method uses an asyn setAssociatedData(name: string, key: string, value: string): Promise<void>; -Sets data to be associated with an application account. This method uses a promise to return the result asynchronously. +Sets data to be associated with an app account. This method uses a promise to return the result asynchronously. - Parameters | Name| Type| Mandatory| Description| | ------ | ------ | ---- | ---------------------------------- | - | name | string | Yes| Application account name.| + | name | string | Yes| App account name.| | key | string | Yes| Key of the data to set. The private key can be customized.| | value | string | Yes| Value of the data to be set.| @@ -549,15 +596,15 @@ Sets data to be associated with an application account. This method uses a promi getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void; -Obtains the credential of an application account. This method uses an asynchronous callback to return the result. +Obtains the credential of an app account. This method uses an asynchronous callback to return the result. - Parameters | Name| Type| Mandatory| Description| | -------------- | --------------------- | ---- | ---------------------------- | - | name | string | Yes| Application account name.| + | name | string | Yes| App account name.| | credentialType | string | Yes| Type of the credential to obtain.| - | callback | AsyncCallback<string> | Yes| Callback invoked to return the credential of the specified application account.| + | callback | AsyncCallback<string> | Yes| Callback invoked to return the credential of the specified app account.| - Example @@ -573,13 +620,13 @@ Obtains the credential of an application account. This method uses an asynchrono getAccountCredential(name: string, credentialType: string): Promise<string>; -Obtains the credential of an application account. This method uses a promise to return the result asynchronously. +Obtains the credential of an app account. This method uses a promise to return the result asynchronously. - Parameters | Name| Type| Mandatory| Description| | -------------- | ------ | ---- | -------------------- | - | name | string | Yes| Application account name.| + | name | string | Yes| App account name.| | credentialType | string | Yes| Type of the credential to obtain.| - Return value @@ -603,14 +650,14 @@ Obtains the credential of an application account. This method uses a promise to getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void; -Obtains additional information of an application account. This method uses an asynchronous callback to return the result. +Obtains additional information of an app account. This method uses an asynchronous callback to return the result. - Parameters | Name| Type| Mandatory| Description| | -------- | --------------------- | ---- | -------------------------------- | - | name | string | Yes| Application account name.| - | callback | AsyncCallback<string> | Yes| Callback invoked to return the additional information of the specified application account.| + | name | string | Yes| App account name.| + | callback | AsyncCallback<string> | Yes| Callback invoked to return the additional information of the specified app account.| - Example @@ -626,13 +673,13 @@ Obtains additional information of an application account. This method uses an as getAccountExtraInfo(name: string): Promise<string>; -Obtains additional information of an application account. This method uses a promise to return the result asynchronously. +Obtains additional information of an app account. This method uses a promise to return the result asynchronously. - Parameters | Name| Type| Mandatory| Description| | ------ | ------ | ---- | -------------- | - | name | string | Yes| Application account name.| + | name | string | Yes| App account name.| - Return value @@ -655,15 +702,15 @@ Obtains additional information of an application account. This method uses a pro getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void; -Obtains data associated with an application account. This method uses an asynchronous callback to return the result. +Obtains data associated with an app account. This method uses an asynchronous callback to return the result. - Parameters | Name| Type| Mandatory| Description| | -------- | --------------------- | ---- | ---------------------------------- | - | name | string | Yes| Application account name.| - | key | string | Yes| Key of the data to be obtained.| - | callback | AsyncCallback<string> | Yes| Callback invoked to return the data associated with the specified application account.| + | name | string | Yes| App account name.| + | key | string | Yes| Key of the data to obtain.| + | callback | AsyncCallback<string> | Yes| Callback invoked to return the data associated with the specified app account.| - Example @@ -679,13 +726,13 @@ Obtains data associated with an application account. This method uses an asynchr getAssociatedData(name: string, key: string): Promise<string>; -Obtains data associated with an application account. This method uses a promise to return the result asynchronously. +Obtains data associated with an app account. This method uses a promise to return the result asynchronously. - Parameters | Name| Type| Mandatory| Description| | ------ | ------ | ---- | ------------------- | - | name | string | Yes| Application account name.| + | name | string | Yes| App account name.| | key | string | Yes| Key of the data to obtain.| - Return value @@ -709,7 +756,7 @@ Obtains data associated with an application account. This method uses a promise getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void; -Obtains information about all accessible accounts. This method uses an asynchronous callback to return the result. +Obtains information about all accessible app accounts. This method uses an asynchronous callback to return the result. The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only. @@ -717,7 +764,7 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per | Name| Type| Mandatory| Description| | -------- | ------------------------------------ | ---- | ---------------- | - | callback | AsyncCallback<Array<AppAccountInfo>> | Yes| Callback invoked to return information about all accessible accounts.| + | callback | AsyncCallback<Array<AppAccountInfo>> | Yes| Callback invoked to return information about all accessible app accounts.| - Example @@ -733,7 +780,7 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>; -Obtains information about all accessible accounts. This method uses a promise to return the result. +Obtains information about all accessible app accounts. This method uses a promise to return the result. The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only. @@ -758,7 +805,7 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void; -Obtains information about all accounts of the specified account owner. This method uses an asynchronous callback to return the result. +Obtains information about all app accounts of the specified app. This method uses an asynchronous callback to return the result. The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only. @@ -766,8 +813,8 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per | Name| Type| Mandatory| Description| | -------- | ------------------------------------ | ---- | ---------------- | - | owner | string | Yes| Owner of a system application account or third-party application account.| - | callback | AsyncCallback<Array<AppAccountInfo>> | Yes| Callback invoked to return information about all accounts of the specified account owner.| + | owner | string | Yes| Bundle name of the app.| + | callback | AsyncCallback<Array<AppAccountInfo>> | Yes| Callback invoked to return information about all app accounts.| - Example @@ -784,7 +831,7 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>; -Obtains information about all accounts of the specified account owner. This method uses a promise to return the result. +Obtains information about all app accounts of the specified app. This method uses a promise to return the result. The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This permission is intended for system applications only. @@ -792,7 +839,7 @@ The **ohos.permission.GET_ACCOUNTS_PRIVILEGED** permission is required. This per | Name| Type| Mandatory| Description| | ------ | ------ | ---- | ---------- | - | owner | string | Yes| Owner of a system application account or third-party application account.| + | owner | string | Yes| Bundle name of the app.| - Parameters @@ -822,8 +869,8 @@ Subscribes to the account change event of the specified account owners. This met | Name| Type| Mandatory| Description| | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | - | type | 'change' | Yes| Type of the event to subscribe to. The subscriber will receive a notification when the account owner updates the account.| - | owners | Array<string> | Yes| Owners of the account.| + | type | 'change' | Yes| Type of the event to subscribe to. The subscriber will receive a notification when the account owners update their accounts.| + | owners | Array<string> | Yes| Owners of the accounts.| | callback | Callback<Array<AppAccountInfo>> | Yes| Callback invoked to return the account change.| - Example @@ -851,7 +898,7 @@ Unsubscribes from the account change event. This method uses an asynchronous cal | Name| Type| Mandatory| Description| | -------- | -------------------- | ---- | ------------------------ | - | type | 'change' | Yes| Account change event.| + | type | 'change' | Yes| Account change event to unsubscribe from.| | callback | Callback<void> | No| Callback used to report the account change.| - Example @@ -872,11 +919,739 @@ Unsubscribes from the account change event. This method uses an asynchronous cal } ``` +### authenticate8+ + +authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; + +Authenticates an app account to obtain the Open Authorization (OAuth) access token. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | --------------------- | ---- | --------------------------- | + | name | string | Yes| Name of the app account to authenticate.| + | owner | string | Yes| Bundle name of the app.| + | authType | string | Yes| Authentication type.| + | options | {[key: string]: any} | Yes| Options for the authentication.| + | callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.| + +- Example + + ``` + import featureAbility from '@ohos.ability.featureAbility'; + + function onResultCallback(code, result) { + console.log("resultCode: " + code); + console.log("result: " + JSON.stringify(result)); + } + + function onRequestRedirectedCallback(request) { + let abilityStartSetting = {want: request}; + featureAbility.startAbility(abilityStartSetting, (err)=>{ + console.log("startAbility err: " + JSON.stringify(err)); + }); + } + + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "readAge", {}, { + onResult: onResultCallback, + onRequestRedirected: onRequestRedirectedCallback + }); + ``` + +### getOAuthToken8+ + +getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void; + +Obtains the OAuth access token of an app account based on the specified authentication type. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | --------------------------- | ---- | -------------------- | + | name | string | Yes| App account name.| + | owner | string | Yes| Bundle name of the app.| + | authType | string | Yes| Authentication type.| + | callback | AsyncCallback<string> | Yes| Callback invoked to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => { + console.log('getOAuthToken err: ' + JSON.stringify(err)); + console.log('getOAuthToken token: ' + data); + }); + ``` + +### getOAuthToken8+ + +getOAuthToken(name: string, owner: string, authType: string): Promise<string>; + +Obtains the OAuth access token of an app account based on the specified authentication type. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------ | ---- | -------------------- | + | name | string | Yes| App account name.| + | owner | string | Yes| Bundle name of the app.| + | authType | string | Yes| Authentication type.| + +- Parameters + + | Type| Description| + | --------------------- | -------------------------------- | + | Promise<string> | Promise used to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => { + console.log('getOAuthToken token: ' + data); + }).catch((err) => { + console.log("getOAuthToken err: " + JSON.stringify(err)); + }); + ``` + +### setOAuthToken8+ + +setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void; + +Sets an OAuth access token for an app account. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------------------------- | ---- | ------------- | + | name | string | Yes| App account name.| + | authType | string | Yes| Authentication type.| + | token | string | Yes| OAuth access token to set.| + | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => { + console.log('setOAuthToken err: ' + JSON.stringify(err)); + }); + ``` + +### setOAuthToken8+ + +setOAuthToken(name: string, authType: string, token: string): Promise<void>; + +Sets an OAuth access token for an app account. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------ | ---- | ------------- | + | name | string | Yes| App account name.| + | authType | string | Yes| Authentication type.| + | token | string | Yes| OAuth access token to set.| + +- Parameters + + | Type| Description| + | ------------------- | -------------------------------- | + | Promise<void> | Promise used to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => { + console.log('setOAuthToken successfully'); + }).catch((err) => { + console.log('setOAuthToken err: ' + JSON.stringify(err)); + }); + ``` + +### deleteOAuthToken8+ + +deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void; + +Deletes the specified OAuth access token for an app account. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------------------------- | ---- | ------------------ | + | name | string | Yes| App account name.| + | owner | string | Yes| Bundle name of the app.| + | authType | string | Yes| Authentication type.| + | token | string | Yes| OAuth access token to delete.| + | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => { + console.log('deleteOAuthToken err: ' + JSON.stringify(err)); + }); + ``` + +### deleteOAuthToken8+ + +deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>; + +Deletes the specified OAuth access token for an app account. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------ | ---- | ------------------ | + | name | string | Yes| App account name.| + | owner | string | Yes| Bundle name of the app.| + | authType | string | Yes| Authentication type.| + | token | string | Yes| OAuth access token to delete.| + +- Parameters + + | Type| Description| + | ------------------------------ | --------------------- | + | Promise<void> | Promise used to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => { + console.log('deleteOAuthToken successfully'); + }).catch((err) => { + console.log("deleteOAuthToken err: " + JSON.stringify(err)); + }); + ``` + +### setOAuthTokenVisibility8+ + +setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void; + +Sets the visibility of an OAuth access token to the specified app. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------------------------- | ---- | ------------------- | + | name | string | Yes| App account name.| + | authType | string | Yes| Authentication type.| + | bundleName | string | Yes| Bundle name of the app.| + | isVisible | boolean | Yes| Whether the OAuth access token is visible to the app.| + | callback | AsyncCallback<void> | Yes| Callback invoked to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => { + console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); + }); + ``` + +### setOAuthTokenVisibility8+ + +setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>; + +Sets the visibility of an OAuth access token to the specified app. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------------------------- | ---- | ------------------- | + | name | string | Yes| App account name.| + | authType | string | Yes| Authentication type.| + | bundleName | string | Yes| Bundle name of the app.| + | isVisible | boolean | Yes| Whether the OAuth access token is visible to the app.| + +- Parameters + + | Type| Description| + | ------------------------------ | --------------------- | + | Promise<void> | Promise used to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => { + console.log('setOAuthTokenVisibility successfully'); + }).catch((err) => { + console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); + }); + ``` + +### checkOAuthTokenVisibility8+ + +checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void; + +Checks whether an OAuth token is visible to the specified app. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ---------------------------- | ---- | ---------------------- | + | name | string | Yes| App account name.| + | authType | string | Yes| Authentication type.| + | bundleName | string | Yes| Bundle name of the app.| + | callback | AsyncCallback<boolean> | Yes| Callback invoked to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => { + console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); + console.log('checkOAuthTokenVisibility isVisible: ' + data); + }); + ``` + +### checkOAuthTokenVisibility8+ + +checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>; + +Checks whether an OAuth token is visible to the specified app. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------------------------- | ---- | ---------------------- | + | name | string | Yes| App account name.| + | authType | string | Yes| Authentication type.| + | bundleName | string | Yes| Bundle name of the app.| + +- Parameters + + | Type| Description| + | ------------------------------ | ------------------------ | + | Promise<boolean> | Promise used to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => { + console.log('checkOAuthTokenVisibility isVisible: ' + data); + }).catch((err) => { + console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); + }); + ``` + +### getAllOAuthTokens8+ + +getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void; + +Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------------------------------------------------ | ---- | ------------------- | + | name | string | Yes| App account name.| + | owner | string | Yes| Bundle name of the app.| + | callback | AsyncCallback<Array<OAuthTokenInfo>> | Yes| Callback invoked to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => { + console.log("getAllOAuthTokens err: " + JSON.stringify(err)); + console.log('getAllOAuthTokens data: ' + JSON.stringify(data)); + }); + ``` + +### getAllOAuthTokens8+ + +getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>>; + +Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------ | ---- | ------------------- | + | name | string | Yes| App account name.| + | owner | string | Yes| Bundle name of the app.| + +- Parameters + + | Type| Description| + | ------------------------------ | ----------------------------------- | + | Promise<Array<OAuthTokenInfo>> | Promise used to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => { + console.log('getAllOAuthTokens data: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("getAllOAuthTokens err: " + JSON.stringify(err)); + }); + ``` + +### getOAuthList8+ + +getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void; + +Obtains the authorization list of OAuth access tokens of an app account. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ---------------------------------------- | ---- | ------------------ | + | name | string | Yes| App account name.| + | owner | string | Yes| Bundle name of the app.| + | callback | AsyncCallback<Array<string>> | Yes| Callback invoked to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => { + console.log('getOAuthList err: ' + JSON.stringify(err)); + console.log('getOAuthList data: ' + JSON.stringify(data)); + }); + ``` + +### getOAuthList8+ + +getOAuthList(name: string, authType: string): Promise<Array<string>>; + +Obtains the authorization list of OAuth access tokens of an app account. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------ | ---- | ------------------- | + | name | string | Yes| App account name.| + | owner | string | Yes| Bundle name of the app.| + +- Parameters + + | Type| Description| + | ------------------------------ | ------------------------------------ | + | Promise<Array<string>> | Promise used to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => { + console.log('getOAuthList data: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("getOAuthList err: " + JSON.stringify(err)); + }); + ``` + +### getAuthenticatorCallback8+ + +getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void; + +Obtains the authenticator callback for a session. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | --------- | ------------------------------------------ | ---- | -------------- | + | sessionId | string | Yes| ID of the session to authenticate.| + | callback | AsyncCallback<AuthenticatorCallback> | Yes| Callback invoked to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + featureAbility.getWant((err, want) => { + var sessionId = want.parameters[Constants.KEY_SESSION_ID]; + appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => { + if (err.code != ResultCode.SUCCESS) { + console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); + return; + } + var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", + Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; + callback.OnResult(ResultCode.SUCCESS, result); + }); + }); + ``` + +### getAuthenticatorCallback8+ + +getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>; + +Obtains the authenticator callback for a session. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------ | ---- | -------------- | + | sessionId | string | Yes| ID of the session to authenticate.| + +- Parameters + + | Type| Description| + | ------------------------------------ | -------------------------------- | + | Promise<AuthenticatorCallback> | Promise used to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + featureAbility.getWant().then((want) => { + var sessionId = want.parameters[Constants.KEY_SESSION_ID]; + appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { + var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", + Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; + callback.OnResult(ResultCode.SUCCESS, result); + }).catch((err) => { + console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); + }); + }).catch((err) => { + console.log("getWant err: " + JSON.stringify(err)); + }); + ``` + +### getAuthenticatorInfo8+ + +getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void; + +Obtains authenticator information of an app account. This method uses an asynchronous callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | -------------------------------------- | ---- | ------------------- | + | owner | string | Yes| Bundle name of the app.| + | callback | AsyncCallback<AuthenticatorInfo> | Yes| Callback invoked to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => { + console.log("getAuthenticatorInfo err: " + JSON.stringify(err)); + console.log('getAuthenticatorInfo data: ' + JSON.stringify(data)); + }); + ``` + +### getAuthenticatorInfo8+ + +getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>; + +Obtains authenticator information of an app account. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ----- | ------ | ---- | -------------------- | + | owner | string | Yes| Bundle name of the app.| + +- Parameters + + | Type| Description| + | ------------------------------ | ----------------------------------- | + | Promise<AuthenticatorInfo> | Promise used to return the result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => { + console.log('getAuthenticatorInfo: ' + JSON.stringify(data)); + }).catch((err) => { + console.log("getAuthenticatorInfo err: " + JSON.stringify(err)); + }); + ``` + ## AppAccountInfo +Defines app account information. + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ---------------- | +| owner | string | Yes| Bundle name of the app.| +| name | string | Yes| App account name.| + +## OAuthTokenInfo8+ +Defines OAuth access token information. | Name| Type| Mandatory| Description| -| ------ | ------ | ---- | ------------------ | -| owner | string | Yes| Owner of an application account.| -| name | string | Yes| Name of an application account.| +| -------- | ------ | ---- | -------------- | +| authType | string | Yes| Authentication type.| +| token | string | Yes| Value of the access token.| + +## AuthenticatorInfo8+ + +Defines OAuth authenticator information. + +| Name| Type| Mandatory| Description| +| ------- | ------ | ---- | ------------------ | +| owner | string | Yes| Bundle name of the authenticator owner.| +| iconId | string | Yes| ID of the authenticator icon.| +| labelId | string | Yes| ID of the authenticator label.| + +## Constants8+ + +Enumerates the constants. + +| Name| Default Value| Description| +| ----------------------------- | ---------------------- | ----------------------- | +| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation for implicitly adding an account.| +| ACTION_AUTHENTICATE | "authenticate" | Authentication operation.| +| KEY_NAME | "name" | App account name.| +| KEY_OWNER | "owner" | App account owner.| +| KEY_TOKEN | "token" | OAuth access token.| +| KEY_ACTION | "action" | Action.| +| KEY_AUTH_TYPE | "authType" | Authentication type.| +| KEY_SESSION_ID | "sessionId" | Session ID.| +| KEY_CALLER_PID | "callerPid" | Caller process ID (PID).| +| KEY_CALLER_UID | "callerUid" | Caller user ID (UID).| +| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Caller bundle name.| + +## ResultCode8+ + +Enumerates the result codes. + +| Name| Default Value| Description| +| ----------------------------------- | ----- | ---------------------- | +| SUCCESS | 0 | The operation is successful.| +| ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist.| +| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | The app account service is abnormal.| +| ERROR_INVALID_PASSWORD | 10003 | The password is invalid.| +| ERROR_INVALID_REQUEST | 10004 | The request is invalid.| +| ERROR_INVALID_RESPONSE | 10005 | The response is invalid.| +| ERROR_NETWORK_EXCEPTION | 10006 | The network is abnormal.| +| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | The authenticator does not exist.| +| ERROR_OAUTH_CANCELED | 10008 | The authentication is canceled.| +| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | The size of the OAuth list exceeds the limit.| +| ERROR_OAUTH_SERVICE_BUSY | 10010 | The OAuth service is busy.| +| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal.| +| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist.| +| ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out.| +| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth access token does not exist.| +| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth access tokens reaches the limit.| +| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported.| +| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported.| +| ERROR_PERMISSION_DENIED | 10018 | The required permission is missing.| + +## AuthenticatorCallback8+ + +Provides methods for managing the OAuth authenticator callback. + +### onResult8+ + +onResult: (code: number, result: {[key: string]: any}) => void; + +Called back to send the authentication result. + +- Parameters + | Name| Type| Mandatory| Description| + | ------ | -------------------- | ---- | ----------- | + | code | number | Yes| Authentication result code.| + | result | {[key: string]: any} | Yes| Authentication result.| + +- Example + + ``` + const appAccountManager = account_appAccount.createAppAccountManager(); + var sessionId = "1234"; + appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { + var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo", + Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"}; + callback.OnResult(ResultCode.SUCCESS, result); + }).catch((err) => { + console.log("getAuthenticatorCallback err: " + JSON.stringify(err)); + }); + ``` + +### onRequestRedirected8+ + +onRequestRedirected: (request: Want) => void; + +Called back to redirect an authentication request. + +- Parameters + | Name| Type| Mandatory| Description| + | ------- | ---- | ---- | ------------------ | + | request | Want | Yes| Request to be redirected.| + +- Example + + ``` + class MyAuthenticator extends account_appAccount.Authenticator { + addAccountImplicitly(authType, callerBundleName, options, callback) { + callback.onRequestRedirected({ + bundleName: "com.example.ohos.accountjsdemo", + abilityName: "com.example.ohos.accountjsdemo.LoginAbility", + }); + } + + authenticate(name, authType, callerBundleName, options, callback) { + var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"}; + callback.onResult(ResultCode.SUCCESS, result); + } + } + ``` + +## Authenticator8+ + +Defines the OAuth authenticator base class. + +### addAccountImplicitly8+ + +addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; + +Implicitly adds an app account based on the specified authentication type and options. This method uses an asynchronous callback to return the result. + +- Parameters + | Name| Type| Mandatory| Description| + | ---------------- | --------------------- | --- | -------------------------- | + | authType | string | Yes| Authentication type.| + | callerBundleName | string | Yes| Bundle name of the authentication requester.| + | options | {[key: string]: any} | Yes| Options for the authentication.| + | callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.| + +### authenticate8+ + +authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; + +Authenticates an app account to obtain the OAuth access token. This method uses an asynchronous callback to return the result. + +- Parameters + | Name| Type| Mandatory| Description| + | ---------------- | --------------------- | ---- | -------------------------- | + | name | string | Yes| App account name.| + | authType | string | Yes| Authentication type.| + | callerBundleName | string | Yes| Bundle name of the authentication requester.| + | options | {[key: string]: any} | Yes| Options for the authentication.| + | callback | AuthenticatorCallback | Yes| Authenticator callback invoked to return the authentication result.| + +- Example + + ``` + class MyAuthenticator extends account_appAccount.Authenticator { + addAccountImplicitly(authType, callerBundleName, options, callback) { + callback.onRequestRedirected({ + bundleName: "com.example.ohos.accountjsdemo", + abilityName: "com.example.ohos.accountjsdemo.LoginAbility", + }); + } + + authenticate(name, authType, callerBundleName, options, callback) { + var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"}; + callback.onResult(ResultCode.SUCCESS, result); + } + } + + export default { + onConnect(want) { + return new MyAuthenticator(); + } + } + ``` diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md new file mode 100644 index 0000000000000000000000000000000000000000..e3ba42ce0955682922d7d36766a8a4544d111b83 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-arraylist.md @@ -0,0 +1,576 @@ +# Linear Container ArrayList + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +``` +import ArrayList from '@ohos.util.ArrayList' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## ArrayList + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in an array list (called container later).| + + +### constructor + +constructor() + +A constructor used to create an **ArrayList** instance. + +**Example** + +``` +let arrayList = new ArrayList(); +``` + + +### add + +add(element: T): boolean + +Adds an entry at the end of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + + ``` + let arrayList = new ArrayList(); + let result = arrayList.add("a"); + let result1 = arrayList.add(1); + let b = [1, 2, 3]; + let result2 = arrayList.add(b); + let c = {name: "lala", age: "13"}; + let result3 = arrayList.add(false); + ``` + +### insert + +insert(element: T, index: number): void + +Inserts an entry at the specified position in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to insert.| +| index | number | Yes| Index of the position where the entry is to be inserted.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.insert("A", 0); +arrayList.insert(0, 1); +arrayList.insert(true, 2); +``` + +### has + +has(element: T): boolean + +Checks whether this container has the specified entry. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to check.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.| + +**Example** + +``` +let arrayList = new ArrayList(); +let result = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +arrayList.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result1 = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + +### getIndexOf + +getIndexOf(element: T): number + +Obtains the index of the first occurrence of the specified entry in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(2); +arrayList.add(1); +arrayList.add(2); +arrayList.add(4); +let result = arrayList.getIndexOf(2); +``` + +### getLastIndexOf + +getLastIndexOf(element: T): number + +Obtains the index of the last occurrence of the specified entry in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(2); +arrayList.add(1); +arrayList.add(2); +arrayList.add(4); +let result = arrayList.getLastIndexOf(2); +``` + +### removeByIndex + +removeByIndex(index: number): T + +Removes an entry with the specified position from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(2); +arrayList.add(4); +let result = arrayList.removeByIndex(2); +``` + +### remove + +remove(element: T): boolean + +Removes the first occurrence of the specified entry from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result = arrayList.remove(2); +``` + +### removeByRange + +removeByRange(fromIndex: number, toIndex: number): void + +Removes from this container all of the entries within a range, including the entry at the start position but not that at the end position. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fromIndex | number | Yes| Index of the start position.| +| toIndex | number | Yes| Index of the end position.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.removeByRange(2, 4); +arrayList.removeByRange(4, 3); +arrayList.removeByRange(2, 6); +``` + +### replaceAllElements +replaceAllElements(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => T, +thisArg?: Object): void + +Replaces all entries in this container with new entries, and returns the new ones. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked for the replacement.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| arrlist | ArrayList<T> | No| Instance that invokes the **replaceAllElements** method.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.replaceAllElements((value, index) => { + return value = 2 * value; +}); +arrayList.replaceAllElements((value, index) => { + return value = value - 2; +}); +``` + +### forEach +forEach(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => void, +thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| arrlist | ArrayList<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.forEach((value, index) => { + console.log(value, index); +}); +``` + +### sort +sort(comparator?: (firstValue: T, secondValue: T) => number): void + +Sorts entries in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| comparator | function | No| Callback invoked for sorting.| + +comparator + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| firstValue | T | Yes| Previous entry.| +| secondValue | T | Yes| Next entry.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.sort(a, (b => a - b)); +arrayList.sort(a, (b => b - a)); +arrayList.sort(); +``` + +### subArrayList +subArrayList(fromIndex: number, toIndex: number): ArrayList<T> + +Obtains entries within a range in this container, including the entry at the start position but not that at the end position, and returns these entries as a new **ArrayList** instance. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fromIndex | number | Yes| Index of the start position.| +| toIndex | number | Yes| Index of the end position.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| ArrayList<T> | New **ArrayList** instance obtained.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result1 = arrayList.subArrayList(2, 4); +let result2 = arrayList.subArrayList(4, 3); +let result3 = arrayList.subArrayList(2, 6); +``` + +### clear +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.clear(); +``` + +### clone +clone(): ArrayList<T> + +Clones this container and returns a copy. The modification to the copy does not affect the original instance. + + +**Return value** + +| Type| Description| +| -------- | -------- | +| ArrayList<T> | New **ArrayList** instance obtained.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result = arrayList.clone(); +``` + +### getCapacity +getCapacity(): number + +Obtains the capacity of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Capacity obtained.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result = arrayList.getCapacity(); +``` + +### convertToArray +convertToArray(): Array<T> + +Converts this container into an array. + +**Return value** + +| Type| Description| +| -------- | -------- | +| Array<T> | Array obtained.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result = arrayList.convertToArray(); +``` + +### isEmpty +isEmpty(): boolean + +Checks whether this container is empty (contains no entry). + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +let result = arrayList.isEmpty(); +``` + +### increaseCapacityTo +increaseCapacityTo(newCapacity: number): void + +Increases the capacity of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| newCapacity | number | Yes| New capacity.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.increaseCapacityTo(2); +arrayList.increaseCapacityTo(8); +``` + +### trimToCurrentLength +trimToCurrentLength(): void + +Trims the capacity of this container to its current length. + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); +arrayList.trimToCurrentLength(); +``` + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let arrayList = new ArrayList(); +arrayList.add(2); +arrayList.add(4); +arrayList.add(5); +arrayList.add(4); + +// Method 1: +for (let item of arrayList) { + console.log(item); +} + +// Method 2: +let iter = arrayList[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index 80ac13c01931162680670633ac374864c8a24101..85d2dc6b01ebe7dc2dc97e3965985ae1a61efb52 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -1,6 +1,7 @@ # Audio -This module provides the following functions: audio management, audio rendering and system sound management. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -284,8 +285,18 @@ Enumerates audio device types. +## ActiveDeviceType -## AudioRingMode7+ +Enumerates the active device types. + +| Name | Default Value | Default Value | +| ------------- | ------ | ------------------------------------------------------------ | +| SPEAKER | 2 | Speaker.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | +| BLUETOOTH_SCO | 7 | Bluetooth device using the SCO link.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | + + + +## AudioRingMode Enumerates ringer modes. @@ -1028,7 +1039,7 @@ audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data)=> ## audioManager.mute -mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void7+ +mute\(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback\): void Mutes a stream. This method uses an asynchronous callback to return the result. @@ -1096,7 +1107,7 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { ## audioManager.mute -mute\(volumeType: AudioVolumeType, mute: boolean\): Promise7+ +mute\(volumeType: AudioVolumeType, mute: boolean\): Promise Mutes a stream. This method uses a promise to return the result. @@ -1164,7 +1175,7 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => ## audioManager.isMute -isMute\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+ +isMute\(volumeType: AudioVolumeType, callback: AsyncCallback\): void Checks whether a stream is muted. This method uses an asynchronous callback to return the query result. @@ -1223,7 +1234,7 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { ## audioManager.isMute -isMute\(volumeType: AudioVolumeType\): Promise7+ +isMute\(volumeType: AudioVolumeType\): Promise Checks whether a stream is muted. This method uses a promise to return the result. @@ -1282,7 +1293,7 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => ## audioManager.isActive -isActive\(volumeType: AudioVolumeType, callback: AsyncCallback\): void7+ +isActive\(volumeType: AudioVolumeType, callback: AsyncCallback\) Checks whether a stream is active. This method uses an asynchronous callback to return the query result. @@ -1341,7 +1352,7 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { ## audioManager.isActive -isActive\(volumeType: AudioVolumeType\): Promise7+ +isActive\(volumeType: AudioVolumeType\): Promise Checks whether a stream is active. This method uses a promise to return the query result. @@ -1400,7 +1411,7 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => ## audioManager.setRingerMode -setRingerMode\(mode: AudioRingMode, callback: AsyncCallback\): void7+ +setRingerMode\(mode: AudioRingMode, callback: AsyncCallback\): void Sets the ringer mode. This method uses an asynchronous callback to return the result. @@ -1459,7 +1470,7 @@ audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { ## audioManager.setRingerMode -setRingerMode\(mode: AudioRingMode\): Promise7+ +setRingerMode\(mode: AudioRingMode\): Promise Sets the ringer mode. This method uses a promise to return the result. @@ -1518,7 +1529,7 @@ audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => ## audioManager.getRingerMode -getRingerMode\(callback: AsyncCallback\): void7+ +getRingerMode\(callback: AsyncCallback\): void Obtains the ringer mode. This method uses an asynchronous callback to return the query result. @@ -1568,7 +1579,7 @@ audioManager.getRingerMode((err, value) => { ## audioManager.getRingerMode -getRingerMode\(\): Promise7+ +getRingerMode\(\): Promise Obtains the ringer mode. This method uses a promise to return the query result. @@ -1606,7 +1617,7 @@ audioManager.getRingerMode().then((value) => ## audioManager.setAudioParameter -setAudioParameter\(key: string, value: string, callback: AsyncCallback\): void7+ +setAudioParameter\(key: string, value: string, callback: AsyncCallback\): void Sets an audio parameter. This method uses an asynchronous callback to return the result. @@ -1674,7 +1685,7 @@ audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => { ## audioManager.setAudioParameter -setAudioParameter\(key: string, value: string\): Promise7+ +setAudioParameter\(key: string, value: string\): Promise Sets an audio parameter. This method uses a promise to return the result. @@ -1742,7 +1753,7 @@ audioManager.setAudioParameter('PBits per sample', '8 bit').then(() => ## audioManager.getAudioParameter -getAudioParameter\(key: string, callback: AsyncCallback\): void7+ +getAudioParameter\(key: string, callback: AsyncCallback\) Obtains the value of an audio parameter. This method uses an asynchronous callback to return the query result. @@ -1801,7 +1812,7 @@ audioManager.getAudioParameter('PBits per sample', (err, value) => { ## audioManager.getAudioParameter -getAudioParameter\(key: string\): Promise7+ +getAudioParameter\(key: string\): Promise Obtains the value of an audio parameter. This method uses a promise to return the query result. @@ -1979,7 +1990,7 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=> ## audioManager.setDeviceActive -setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback\): void7+ +setDeviceActive\(deviceType: DeviceType, active: boolean, callback: AsyncCallback\): void Sets a device to the active state. This method uses an asynchronous callback to return the result. @@ -2048,7 +2059,7 @@ audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err)=> { ## audioManager.setDeviceActive -setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise7+ +setDeviceActive\(deviceType: DeviceType, active: boolean\): Promise Sets a device to the active state. This method uses a promise to return the result. @@ -2116,7 +2127,7 @@ audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(()=> ## audioManager.isDeviceActive -isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback\): void7+ +isDeviceActive\(deviceType: DeviceType, callback: AsyncCallback\): void Checks whether a device is active. This method uses an asynchronous callback to return the query result. @@ -2175,7 +2186,7 @@ audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => { ## audioManager.isDeviceActive -isDeviceActive\(deviceType: DeviceType\): Promise7+ +isDeviceActive\(deviceType: DeviceType\): Promise Checks whether a device is active. This method uses a promise to return the query result. @@ -2234,7 +2245,7 @@ audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => ## audioManager.setMicrophoneMute -setMicrophoneMute\(mute: boolean, callback: AsyncCallback\): void7+ +setMicrophoneMute\(mute: boolean, callback: AsyncCallback\): void Mutes or unmutes the microphone. This method uses an asynchronous callback to return the result. @@ -2293,7 +2304,7 @@ audioManager.setMicrophoneMute(true, (err) => { ## audioManager.setMicrophoneMute -setMicrophoneMute\(mute: boolean\): Promise7+ +setMicrophoneMute\(mute: boolean\): Promise Mutes or unmutes the microphone. This method uses a promise to return the result. @@ -2352,7 +2363,7 @@ audioManager.setMicrophoneMute(true).then(() => ## audioManager.isMicrophoneMute -isMicrophoneMute\(callback: AsyncCallback\): void7+ +isMicrophoneMute\(callback: AsyncCallback\): void Checks whether the microphone is muted. This method uses an asynchronous callback to return the query result. @@ -2402,7 +2413,7 @@ audioManager.isMicrophoneMute((err, value) => { ## audioManager.isMicrophoneMute -isMicrophoneMute\(\): Promise7+ +isMicrophoneMute\(\): Promise Checks whether the microphone is muted. This method uses a promise to return the query result. @@ -4121,3 +4132,20 @@ None ``` await ringtonePlayer.release(); ``` + + +## AudioDeviceDescriptor + +Describes an audio device. + +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | +| deviceType | [DeviceType](#devicetype) | Yes | No | Device type.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | + + +## AudioDeviceDescriptors + +| Name | Description | +| -------- | -------- | +| AudioDeviceDescriptors | Array of **AudioDeviceDescriptor** objects. It is read-only.
**System capabilities:** SystemCapability.Multimedia.Audio.Device | \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-bluetooth.md b/en/application-dev/reference/apis/js-apis-bluetooth.md index 41295611985e939ba1ada638060c747b9873f5cb..588c942cb2b77556023606197b23a106f9ffc0be 100644 --- a/en/application-dev/reference/apis/js-apis-bluetooth.md +++ b/en/application-dev/reference/apis/js-apis-bluetooth.md @@ -2111,7 +2111,7 @@ let deviceName = gattClient.getDeviceName().then((data) => { getRssiValue(callback: AsyncCallback<number>): void -Obtains the received signal strength indication (RSSI) of the peer BLE device. This method uses an asynchronous callback to return the result. It can be used only after a connection is set up by calling [connect](#connect-boolean). +Obtains the received signal strength indication (RSSI) of the peer BLE device. This method uses an asynchronous callback to return the result. It can be used only after a connection is set up by calling [connect](#connect). **Parameters:** @@ -2140,7 +2140,7 @@ let rssi = gattClient.getRssiValue((err, data)=> { getRssiValue(): Promise<number> -Obtains the RSSI of the peer BLE device. This method uses a promise to return the result. It can be used only after a connection is set up by calling [connect](#connect-boolean). +Obtains the RSSI of the peer BLE device. This method uses a promise to return the result. It can be used only after a connection is set up by calling [connect](#connect). **Return values:** diff --git a/en/application-dev/reference/apis/js-apis-bytrace.md b/en/application-dev/reference/apis/js-apis-bytrace.md index a79e890d2a29af43852f76653150048c23f84c4a..ff5fbcee930005827440c17da32630e0e372ed3b 100644 --- a/en/application-dev/reference/apis/js-apis-bytrace.md +++ b/en/application-dev/reference/apis/js-apis-bytrace.md @@ -1,197 +1,110 @@ -# Performance Tracing +# Performance Tracing ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > - The APIs of this module are no longer maintained since API version 8. It is recommended that you use the APIs of [hiTraceMeter](js-apis-hitracemeter.md) instead. > - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Modules to Import + +## Modules to Import ``` import bytrace from '@ohos.bytrace'; ``` -## Required Permissions - -None - -## bytrace.startTrace - -startTrace\(name: string, taskId: number, expectedTime?: number\): void - -Starts a trace of a task. **expectedTime** is an optional parameter, which specifies the expected duration of the trace. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

Yes

-

Name of the trace task to start.

-

taskId

-

number

-

Yes

-

Task ID.

-

expectedTime

-

number

-

No

-

Expected duration of the trace, in ms.

-
- - >![](../../public_sys-resources/icon-note.gif) **NOTE:** - >If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different **taskId**s must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same **taskId** can be used. For details, see the **bytrace.finishTrace** example. - -- Example - - ``` - bytrace.startTrace("myTestFunc", 1); - bytrace.startTrace("myTestFunc", 1, 5); // The expected duration of the trace is 5 ms. - ``` - - -## bytrace.finishTrace - -finishTrace\(name: string, taskId: number\): void + +## System Capabilities + +SystemCapability.Developtools.Bytrace + + +## bytrace.startTrace + +startTrace(name: string, taskId: number, expectedTime?: number): void + +Starts a trace task. **expectedTime** is an optional parameter, which specifies the expected duration of the trace. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Name of the trace task to start.| +| taskId | number | Yes| Task ID.| +| expectedTime | number | No| Expected duration of the trace, in ms.| + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same taskId can be used. For details, see the bytrace.finishTrace example. + +**Example** + +``` +bytrace.startTrace("myTestFunc", 1); +bytrace.startTrace("myTestFunc", 1, 5); // The expected duration of the trace is 5 ms. +``` + + +## bytrace.finishTrace + +finishTrace(name: string, taskId: number): void Stops a trace task. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

Yes

-

Name of the trace task to stop.

-

taskId

-

number

-

Yes

-

Task ID.

-
- - >![](../../public_sys-resources/icon-note.gif) **NOTE:** - >To stop a trace task, the values of **name** and **taskId** in **finishTrace** must be the same as those in **startTrace**. - -- Example - - ``` - bytrace.finishTrace("myTestFunc", 1); - ``` - - ``` - // Start track tasks with the same name concurrently. - bytrace.startTrace("myTestFunc", 1); - ...... // Service flow - bytrace.startTrace ("myTestFunc", 2); // The second trace task starts while the first task is still running. The first and second tasks have the same name but different task IDs. - ...... // Service flow - bytrace.finishTrace("myTestFunc", 1); - ...... // Service flow - bytrace.finishTrace("myTestFunc", 2); - ``` - - ``` - // Start track tasks with the same name at different times. - bytrace.startTrace("myTestFunc", 1); - ...... // Service flow - bytrace.finishTrace("myTestFunc", 1); // The first trace task ends. - ...... // Service flow - bytrace.startTrace("myTestFunc", 1); // The second trace task starts after the first task ends. The two tasks have the same name and task ID. - ...... // Service flow - bytrace.finishTrace("myTestFunc", 1); - ``` - - -## bytrace.traceByValue - -traceByValue\(name: string, value: number\): void +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Name of the trace task to start.| +| taskId | number | Yes| Task ID.| + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> To stop a trace task, the values of name and task ID in **finishTrace** must be the same as those in **startTrace**. + +**Example** + +``` +bytrace.finishTrace("myTestFunc", 1); +``` + +``` +// Start track tasks with the same name concurrently. +bytrace.startTrace("myTestFunc", 1); +// Service flow +bytrace.startTrace("myTestFunc", 2); // The second trace task starts while the first task is still running. The first and second tasks have the same name but different task IDs. +// Service flow +bytrace.finishTrace("myTestFunc", 1); +// Service flow +bytrace.finishTrace("myTestFunc", 2); +``` + +``` +// Start track tasks with the same name at different times. +bytrace.startTrace("myTestFunc", 1); +// Service flow +bytrace.finishTrace("myTestFunc", 1); // The first trace task ends. +// Service flow +bytrace.startTrace("myTestFunc", 1); // The second trace task starts after the first task ends. The two tasks have the same name and task ID. +// Service flow +bytrace.finishTrace("myTestFunc", 1); +``` + + +## bytrace.traceByValue + +traceByValue(name: string, value: number): void Traces the value changes of a variable. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

Yes

-

Name of the variable to trace.

-

value

-

number

-

Yes

-

Value of the variable to trace.

-
- -- Example - - ``` - let traceCount = 3; - bytrace.traceByValue("myTestCount", traceCount); - ...... - traceCount = 5; - bytrace.traceByValue("myTestCount", traceCount); - ``` +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Name of the variable.| +| value | number | Yes| Value of the variable.| + +**Example** + +``` +let traceCount = 3; +bytrace.traceByValue("myTestCount", traceCount); +traceCount = 4; +bytrace.traceByValue("myTestCount", traceCount); +// Service flow +``` diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 14584a1f0e3c2f9c700bb8afb0bee7168b867f24..dc54b14b351dc85a09abd394681bd1dd2d182568 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -1,6 +1,6 @@ # Call ->**Note:** +>**NOTE** > >The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -17,22 +17,24 @@ dial\(phoneNumber: string, callback: AsyncCallback\): void Initiates a call. This function uses an asynchronous callback to return the execution result. -Before using this API, you must declare the **ohos.permission.PLACE\_CALL** permission (a system permission). +**Required permission**: ohos.permission.PLACE\_CALL (a system permission) -- Parameters - - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | phoneNumber | string | Yes|Phone number.| - | callback |AsyncCallback<boolean>|Yes|Callback used to return the result.
- **true**: success
-**false**: failure| - -- Example +**System capability**: SystemCapability.Telephony.CallManager - ``` - call.dial("138xxxxxxxx", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +**Parameters** + +| Name| Type| Mandatory| Description| +| ----------- | ---------------------------- | ---- | ------------------------------------------------- | +| phoneNumber | string | Yes| Phone number.| +| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.
- **true**: success
- **false**: failure| + +**Example** + +``` +call.dial("138xxxxxxxx", (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## call.dial @@ -41,26 +43,27 @@ dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback - **true**: success
-**false**: failure| +**Parameters** +| Name| Type| Mandatory| Description| +| ----------- | ---------------------------- | ---- | ------------------------------------------------- | +| phoneNumber | string | Yes| Phone number.| +| options | DialOptions | Yes| Call options. For details, see [DialOptions](#DialOptions).| +| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.
- **true**: success
- **false**: failure| -- Example +**Example** - ``` - call.dial("138xxxxxxxx", { - extras: false - }, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +call.dial("138xxxxxxxx", { + extras: false +}, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## call.dial @@ -69,33 +72,35 @@ dial\(phoneNumber: string, options?: DialOptions\): Promise Initiates a call. You can set call options as needed. This function uses a promise to return the execution result. -Before using this API, you must declare the **ohos.permission.PLACE\_CALL** permission (a system permission). +**Required permission**: ohos.permission.PLACE\_CALL (a system permission) -- Parameters +**System capability**: SystemCapability.Telephony.CallManager - | Name| Type| Mandatory| Description| - | ----------- | ----------- | ---- | ------------------------------------------- | - | phoneNumber | string | Yes| Phone number.| - | options | DialOptions | Yes| Call options. For details, see [DialOptions](#DialOptions).| +**Parameters** -- Return values +| Name| Type| Mandatory| Description| +| ----------- | ----------- | ---- | ------------------------------------------- | +| phoneNumber | string | Yes| Phone number.| +| options | DialOptions | Yes| Call options. For details, see [DialOptions](#DialOptions).| + +**Return value** - | Type| Description| - | ---------------------- | --------------------------------- | - | Promise<boolean> | Promise used to return the result.| +| Type| Description| +| ---------------------- | --------------------------------- | +| Promise<boolean> | Promise used to return the result.| -- Example +**Example** - ``` - let promise = call.dial("138xxxxxxxx", { - extras: false - }); - promise.then(data => { - console.log(`dial success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`dial fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let promise = call.dial("138xxxxxxxx", { + extras: false +}); +promise.then(data => { + console.log(`dial success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`dial fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## call.hasCall @@ -103,19 +108,21 @@ hasCall\(callback: AsyncCallback\): void Checks whether a call is in progress. This function uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CallManager - | Name| Type| Mandatory| Description| - | -------- | ---------------------------- | ---- | ------------------------------------------------------------ | - | callback | AsyncCallback<boolean> | Yes| Callback used to return the result:
- **true**: A call is in progress.
- **false**: No call is in progress. | +**Parameters** -- Example +| Name| Type| Mandatory| Description| +| -------- | ---------------------------- | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback<boolean> | Yes| Callback used to return the result:
- **true**: A call is in progress.
- **false**: No call is in progress. | + +**Example** - ``` - call.hasCall((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +call.hasCall((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## call.hasCall @@ -124,22 +131,24 @@ hasCall\(\): Promise Checks whether a call is in progress. This function uses a promise to return the result. -- Return values +**System capability**: SystemCapability.Telephony.CallManager - | Type| Description| - | ---------------------- | --------------------------------------- | - | Promise<boolean> | Promise used to return the result.| +**Return value** -- Example +| Type| Description| +| ---------------------- | --------------------------------------- | +| Promise<boolean> | Promise used to return the result.| - ``` - let promise = call.hasCall(); - promise.then(data => { - console.log(`hasCall success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`hasCall fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +**Example** + +``` +let promise = call.hasCall(); +promise.then(data => { + console.log(`hasCall success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`hasCall fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## call.getCallState @@ -148,19 +157,21 @@ getCallState\(callback: AsyncCallback\): void Obtains the call status. This function uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------------------------------------------- | ---- | ------------------------------------ | - | callback | AsyncCallback<[CallState](#CallState)> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | -------------------------------------------- | ---- | ------------------------------------ | +| callback | AsyncCallback<[CallState](#CallState)> | Yes| Callback used to return the result.| -- Example +**Example** - ``` - call.getCallState((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +call.getCallState((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## call.getCallState @@ -169,118 +180,128 @@ getCallState\(\): Promise Obtains the call status. This function uses a promise to return the result. -- Return values +**System capability**: SystemCapability.Telephony.CallManager + +**Return value** - | Type| Description| - | -------------------------------------- | ----------------------------------------- | - | Promise<[CallState](#CallState)> | Promise used to return the result.| +| Type| Description| +| -------------------------------------- | ----------------------------------------- | +| Promise<[CallState](#CallState)> | Promise used to return the result.| -- Example +**Example** - ``` - let promise = call.getCallState(); - promise.then(data => { - console.log(`getCallState success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`getCallState fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let promise = call.getCallState(); +promise.then(data => { + console.log(`getCallState success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getCallState fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## call.isEmergencyPhoneNumber7+ isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback\): void -Checks whether the call number is an emergency number. This function uses an asynchronous callback to return the result. +Checks whether the call number of the SIM card in the specified slot is an emergency number. This function uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CallManager - | Name| Type| Mandatory| Description| - | ----------- | ---------------------------- | ---- | ------------------------------------------------------------ | - | phoneNumber | string | Yes| Phone number.| - | callback | AsyncCallback<boolean> | Yes| Callback used to return the result.
- **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.| +**Parameters** + +| Name| Type| Mandatory| Description| +| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ | +| phoneNumber | string | Yes| Phone number.| +| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.
- **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.| -- Example +**Example** - ``` - call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## call.isEmergencyPhoneNumber7+ isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback\): void -Checks whether the call number is an emergency number. This function uses an asynchronous callback to return the result. +Checks whether the call number of the SIM card in the specified slot is an emergency number. This function uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CallManager - | Name| Type| Mandatory| Description| - | ----------- | ---------------------------- | ---- | ------------------------------------------------------------ | - | phoneNumber | string | Yes| Phone number.| - | options | EmergencyNumberOptions | Yes| Emergency number options defined in [EmergencyNumberOptions](#EmergencyNumberOptions).| - | callback | AsyncCallback<boolean> | Yes| Callback used to return the result.
- **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.| +**Parameters** + +| Name| Type| Mandatory| Description| +| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ | +| phoneNumber | string | Yes| Phone number.| +| options | EmergencyNumberOptions | Yes| Emergency number options defined in [EmergencyNumberOptions](#EmergencyNumberOptions).| +| callback | AsyncCallback<boolean> | Yes| Callback used to return the result.
- **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.| -- Example +**Example** - ``` - call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## call.isEmergencyPhoneNumber7+ isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): Promise -Checks whether the call number is an emergency number. This function uses a promise to return the result. +Checks whether the call number of the SIM card in the specified slot is an emergency number. This function uses a promise to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CallManager - | Name| Type| Mandatory| Description| - | ----------- | ---------------------- | ---- | ------------------------------------------------------------ | - | phoneNumber | string | Yes| Phone number.| - | options | EmergencyNumberOptions | Yes| Emergency number options defined in [EmergencyNumberOptions](#EmergencyNumberOptions).| +**Parameters** -- Return values +| Name| Type| Mandatory| Description| +| ----------- | ---------------------- | ---- | ------------------------------------------------------------ | +| phoneNumber | string | Yes| Phone number.| +| options | EmergencyNumberOptions | Yes| Emergency number options defined in [EmergencyNumberOptions](#EmergencyNumberOptions).| - | Type| Description| - | ---------------------- | --------------------------------------------------- | - | Promise<boolean> | Promise used to return the result.| +**Return value** -- Example +| Type| Description| +| ---------------------- | --------------------------------------------------- | +| Promise<boolean> | Promise used to return the result.| - ``` - let promise = call.isEmergencyPhoneNumber("138xxxxxxxx", {slotId: 1}); - promise.then(data => { - console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`isEmergencyPhoneNumber fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +**Example** + +``` +let promise = call.isEmergencyPhoneNumber("138xxxxxxxx", {slotId: 1}); +promise.then(data => { + console.log(`isEmergencyPhoneNumber success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`isEmergencyPhoneNumber fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## call.formatPhoneNumber7+ formatPhoneNumber\(phoneNumber: string, callback: AsyncCallback\): void -Formats a phone number. This function uses an asynchronous callback to return the result. +Formats a phone number based on the specified ISO country code. This function uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CallManager - | Name| Type| Mandatory| Description| - | ----------- | --------------------------- | ---- | ------------------------------------ | - | phoneNumber | string | Yes| Phone number.| - | callback | AsyncCallback<string> | Yes| Callback used to return the result.| +**Parameters** -- Example +| Name| Type| Mandatory| Description| +| ----------- | --------------------------- | ---- | ------------------------------------ | +| phoneNumber | string | Yes| Phone number.| +| callback | AsyncCallback<string> | Yes| Callback used to return the result.| - ``` - call.formatPhoneNumber("138xxxxxxxx", (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +**Example** + +``` +call.formatPhoneNumber("138xxxxxxxx", (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## call.formatPhoneNumber7+ @@ -289,23 +310,25 @@ formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: Formats a phone number based on specified formatting options. This function uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** - | Name| Type| Mandatory| Description| - | ----------- | --------------------------- | ---- | ------------------------------------------------------------ | - | phoneNumber | string | Yes| Phone number.| - | options | NumberFormatOptions | Yes| Number formatting options defined in [NumberFormatOptions](#NumberFormatOptions).| - | callback | AsyncCallback<string> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | +| phoneNumber | string | Yes| Phone number.| +| options | NumberFormatOptions | Yes| Number formatting options defined in [NumberFormatOptions](#NumberFormatOptions).| +| callback | AsyncCallback<string> | Yes| Callback used to return the result.| -- Example +**Example** - ``` - call.formatPhoneNumber("138xxxxxxxx",{ - countryCode: "CN" - }, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +call.formatPhoneNumber("138xxxxxxxx",{ + countryCode: "CN" +}, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## call.formatPhoneNumber7+ @@ -314,31 +337,33 @@ formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise Formats a phone number based on specified formatting options. This function uses a promise to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CallManager - | Name| Type| Mandatory| Description| - | ----------- | ------------------- | ---- | ------------------------------------------------------------ | - | phoneNumber | string | Yes| Phone number.| - | options | NumberFormatOptions | Yes| Number formatting options defined in [NumberFormatOptions](#NumberFormatOptions).| +**Parameters** -- Return values +| Name| Type| Mandatory| Description| +| ----------- | ------------------- | ---- | ------------------------------------------------------------ | +| phoneNumber | string | Yes| Phone number.| +| options | NumberFormatOptions | Yes| Number formatting options defined in [NumberFormatOptions](#NumberFormatOptions).| - | Type| Description| - | --------------------- | ------------------------------------------- | - | Promise<string> | Promise used to return the result.| +**Return value** -- Example +| Type| Description| +| --------------------- | ------------------------------------------- | +| Promise<string> | Promise used to return the result.| - ``` - let promise = call.formatPhoneNumber("138xxxxxxxx", { - countryCode: "CN" - }); - promise.then(data => { - console.log(`formatPhoneNumber success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`formatPhoneNumber fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +**Example** + +``` +let promise = call.formatPhoneNumber("138xxxxxxxx", { + countryCode: "CN" +}); +promise.then(data => { + console.log(`formatPhoneNumber success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`formatPhoneNumber fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## call.formatPhoneNumberToE1647+ @@ -350,23 +375,25 @@ The phone number must match the specified country code. For example, for a China All country codes are supported. -- Parameters +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** - | Name| Type| Mandatory| Description| - | ----------- | --------------------------- | ---- | ----------------------------------------------------- | - | phoneNumber | string | Yes| Phone number.| - | countryCode | string | Yes| Country code, for example, **CN** (China). All country codes are supported.| - | callback | AsyncCallback<string> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| ----------- | --------------------------- | ---- | ----------------------------------------------------- | +| phoneNumber | string | Yes| Phone number.| +| countryCode | string | Yes| Country code, for example, **CN** (China). All country codes are supported.| +| callback | AsyncCallback<string> | Yes| Callback used to return the result.| -- Example +**Example** - ``` - call.formatPhoneNumberToE164("138xxxxxxxx",{ - countryCode: "CN" - }, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +call.formatPhoneNumberToE164("138xxxxxxxx",{ + countryCode: "CN" +}, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## call.formatPhoneNumberToE1647+ @@ -379,59 +406,71 @@ The phone number must match the specified country code. For example, for a China All country codes are supported. -- Parameters +**System capability**: SystemCapability.Telephony.CallManager + +**Parameters** - | Name| Type| Mandatory| Description| - | ----------- | ------ | ---- | ---------------------------------------- | - | phoneNumber | string | Yes| Phone number.| - | countryCode | string | Yes| Country code, for example, **CN** (China). All country codes are supported.| +| Name| Type| Mandatory| Description| +| ----------- | ------ | ---- | ---------------------------------------- | +| phoneNumber | string | Yes| Phone number.| +| countryCode | string | Yes| Country code, for example, **CN** (China). All country codes are supported.| -- Return values +**Return value** - | Type| Description| - | --------------------- | ------------------------------------------------------------ | - | Promise<string> | Promise used to return the result.| +| Type| Description| +| --------------------- | ------------------------------------------------------------ | +| Promise<string> | Promise used to return the result.| -- Example +**Example** - ``` - let promise = call.formatPhoneNumberToE164("138xxxxxxxx", { - countryCode: "CN" - }); - promise.then(data => { - console.log(`formatPhoneNumberToE164 success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`formatPhoneNumberToE164 fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let promise = call.formatPhoneNumberToE164("138xxxxxxxx", { + countryCode: "CN" +}); +promise.then(data => { + console.log(`formatPhoneNumberToE164 success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`formatPhoneNumberToE164 fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## DialOptions Provides an option for determining whether a call is a video call. + +**System capability**: SystemCapability.Telephony.CallManager + | Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| extras | boolean | No|Indication of a video call. The options are as follows:
- **true**: video call
- **false**: voice call| +| ------ | ------- | ---- | ------------------------------------------------------------ | +| extras | boolean | No| Indication of a video call. The options are as follows:
- **true**: video call
- **false**: voice call| ## CallState Enumerates call states. + | Variable| Value| Description| -| -------- | -------- | -------- | -| CALL_STATE_UNKNOWN | -1 | The call status fails to be obtained and is unknown.| -| CALL_STATE_IDLE | 0 | No call is in progress.| -| CALL_STATE_RINGING | 1 | The call is in the ringing or waiting state.| -| CALL_STATE_OFFHOOK | 2 | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting.| +| ------------------ | ---- | ------------------------------------------------------------ | +| CALL_STATE_UNKNOWN | -1 | The call status fails to be obtained and is unknown.
**System capability**: SystemCapability.Telephony.CallManager| +| CALL_STATE_IDLE | 0 | No call is in progress.
**System capability**: SystemCapability.Telephony.CallManager| +| CALL_STATE_RINGING | 1 | The call is in the ringing or waiting state.
**System capability**: SystemCapability.Telephony.CallManager| +| CALL_STATE_OFFHOOK | 2 | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting.
**System capability**: SystemCapability.Telephony.CallManager| ## EmergencyNumberOptions7+ Provides an option for determining whether a number is an emergency number for the SIM card in the specified slot. + +**System capability**: SystemCapability.Telephony.CallManager + | Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| slotId | number | No|SIM card slot ID.
- **0**: slot 1
- **1**: slot 2| +| ------ | ------ | ---- | ------------------------------------------ | +| slotId | number | No| SIM card slot ID.
- **0**: slot 1
- **1**: slot 2| ## NumberFormatOptions7+ Provides an option for number formatting. + +**System capability**: SystemCapability.Telephony.CallManager + | Name| Type| Mandatory| Description| -| -------- | -------- | -------- | -------- | -| countryCode | string | No|Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.| +| ----------- | ------ | ---- | ---------------------------------------------------------- | +| countryCode | string | No| Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.| diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index 92aef3bc743bc5a1e0466fecbbefa94a274f5af3..c076a882942d2145b641555efd8ac2bd5a504fd4 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -1,5 +1,8 @@ # Camera +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## Modules to Import ``` diff --git a/en/application-dev/reference/apis/js-apis-commonEvent.md b/en/application-dev/reference/apis/js-apis-commonEvent.md index 31ee5df26f9396629e048888d2a7d4211e526586..32045b0f0c9ed3b12b105e154611456ced48c46b 100644 --- a/en/application-dev/reference/apis/js-apis-commonEvent.md +++ b/en/application-dev/reference/apis/js-apis-commonEvent.md @@ -113,7 +113,7 @@ ## Modules to Import ```js -import CommonEvent from '@ohos.commonevent'; +import CommonEvent from '@ohos.commonEvent'; ``` ## System Capabilities @@ -169,9 +169,9 @@ Publishes a common event with given attributes. This method uses a callback to r ```js // Attributes of a common event. var options = { - code: 0; // Result code of the common event - data: "initial data";// Result data of the common event - isOrdered: true; // The common event is an ordered one. + code: 0, // Result code of the common event + data: "initial data",// Result data of the common event + isOrdered: true // The common event is an ordered one. } // Callback for common event publication function PublishCallBack(err) { @@ -183,6 +183,79 @@ CommonEvent.publish("publish_event", options, PublishCallBack); +## CommonEvent.publishAsUser + +publishAsUser(event: string, userId: number, callback: AsyncCallback\): void + +Publishes a common event to a specific user. This method uses a callback to return the result. + +**Parameters** + +| Name| Readable/Writable| Type| Mandatory| Description| +| -------- | -------- | -------------------- | ---- | ---------------------------------- | +| event | Read-only| string | Yes| Name of the common event to publish.| +| userId | Read-only| number | Yes| User ID.| +| callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| + +**Example** + +```js +// Callback for common event publication +function PublishAsUserCallBack(err) { + if (err.code) { + console.info("publishAsUser failed " + JSON.stringify(err)); + } else { + console.info("publishAsUser"); + } +} +// Specify the user to whom the common event will be published. +var userId = 100; +// Publish a common event. +CommonEvent.publish("publish_event", userId, PublishAsUserCallBack); +``` + + + +## CommonEvent.publishAsUser + +publishAsUser(event: string, userId: number, options: CommonEventPublishData, callback: AsyncCallback\): void + +Publishes a common event with given attributes to a specific user. This method uses a callback to return the result. + +**Parameters** + +| Name| Readable/Writable| Type| Mandatory| Description| +| -------- | -------- | ---------------------- | ---- | ---------------------- | +| event | Read-only| string | Yes| Name of the common event to publish.| +| userId | Read-only| number | Yes| User ID.| +| options | Read-only| [CommonEventPublishData](#commoneventpublishdata) | Yes| Attributes of the common event to publish.| +| callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| + +**Example** + + +```js +// Attributes of a common event. +var options = { + code: 0; // Result code of the common event + data: "initial data";// Result data of the common event +} +// Callback for common event publication +function PublishAsUserCallBack(err) { + if (err.code) { + console.info("publishAsUser failed " + JSON.stringify(err)); + } else { + console.info("publishAsUser"); + } +} +// Specify the user to whom the common event will be published. +var userId = 100; +// Publish a common event. +CommonEvent.publish("publish_event", userId, options, PublishAsUserCallBack); +``` + + + ## CommonEvent.createSubscriber createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\): void @@ -491,7 +564,7 @@ Sets the result code for this common event. This method uses a promise to return | Name| Type| Mandatory| Description| | ------ | ------ | ---- | ------------------ | -| code | number | Yes| Result code of the common event.| +| code | number | Yes| Callback used to return the result code.| **Example** @@ -584,7 +657,7 @@ Sets the result data for this common event. This method uses a promise to return | Name| Type| Mandatory| Description| | ------ | ------ | ---- | -------------------- | -| data | string | Yes| Result data of the common event.| +| data | string | Yes| Callback used to return the result data.| **Example** @@ -632,7 +705,7 @@ Sets the result code and result data for this common event. This method uses a p | Name| Type| Mandatory| Description| | ------ | ------ | ---- | -------------------- | | code | number | Yes| Result code of the common event.| -| data | string | Yes| Result data of the common event.| +| data | string | Yes| Callback used to return the result data.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-data-ability.md b/en/application-dev/reference/apis/js-apis-data-ability.md index f91f7a53f00c1183e07f14014bfad6f489f241ca..4045752d3f6cd83bcb09f939fc1670bd1f766a05 100644 --- a/en/application-dev/reference/apis/js-apis-data-ability.md +++ b/en/application-dev/reference/apis/js-apis-data-ability.md @@ -1,6 +1,7 @@ # DataAbilityPredicates ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../../public_sys-resources/icon-note.gif) **NOTE** +> >The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -9,11 +10,8 @@ import dataAbility from '@ohos.data.dataAbility' ``` ## System Capabilities -SystemCapability.DistributedDataManager.DataShare.Consumer +SystemCapability.DistributedDataManager.DataShare.Core -## Required Permissions - -None ## dataAbility.createRdbPredicates @@ -1697,4 +1695,3 @@ Sets the **DataAbilityPredicates** to match the field with data type **Array< predicates.notIn("NAME", ["Lisa", "Rose"]) ``` - diff --git a/en/application-dev/reference/apis/js-apis-data-rdb.md b/en/application-dev/reference/apis/js-apis-data-rdb.md index e3fc6ff3f954b818b57c59366ebe98987cca9c6c..6d92a418fadd6d56ca0520fbc3b32026a82c037c 100644 --- a/en/application-dev/reference/apis/js-apis-data-rdb.md +++ b/en/application-dev/reference/apis/js-apis-data-rdb.md @@ -1,6 +1,7 @@ # Relational Database -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. diff --git a/en/application-dev/reference/apis/js-apis-data-resultset.md b/en/application-dev/reference/apis/js-apis-data-resultset.md index c672898f18348a1fcf2f7302e31b8168162c2968..654cff58ad2c45b1d809251a7db2059c82b8928b 100644 --- a/en/application-dev/reference/apis/js-apis-data-resultset.md +++ b/en/application-dev/reference/apis/js-apis-data-resultset.md @@ -1,6 +1,7 @@ # Result Set ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../../public_sys-resources/icon-note.gif) **NOTE** +> >The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## System Capabilities @@ -8,7 +9,7 @@ SystemCapability.DistributedDataManager.RelationalStore.Core ## Usage -The **resultSet** object is obtained by using [**RdbStore.query\(\)**](js-apis-data-rdb.md#section6231155031814). +The **resultSet** object is obtained by using [**RdbStore.query\(\)**](js-apis-data-rdb.md#query). ``` import dataRdb from '@ohos.data.rdb'; @@ -20,9 +21,6 @@ promise.then((resultSet) => { console.log("resultSet columnCount:" + resultSet.columnCount); ``` -## Required Permissions - -None ## ResultSet @@ -795,4 +793,3 @@ Closes the result set. }) ``` - diff --git a/en/application-dev/reference/apis/js-apis-data-storage.md b/en/application-dev/reference/apis/js-apis-data-storage.md index f58bf8d37324b73d3b9b143ecec10a538730bc59..b8dd0be285a7e325ee0f5a2e7483bdb5d04400f7 100644 --- a/en/application-dev/reference/apis/js-apis-data-storage.md +++ b/en/application-dev/reference/apis/js-apis-data-storage.md @@ -2,7 +2,8 @@ Lightweight storage provides applications with data processing capability and allows applications to perform lightweight data storage and query. Data is stored in key-value pairs. Keys are of the string type, and values can be of the numeric, string, or Boolean type. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../../public_sys-resources/icon-note.gif) **NOTE** +> >The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -12,11 +13,8 @@ import dataStorage from '@ohos.data.storage' ``` ## System Capabilities -SystemCapability.DistributedDataManager.Preference.Core +SystemCapability.DistributedDataManager.Preferences.Core -## Required Permissions - -None ## Attributes @@ -119,7 +117,7 @@ Reads a specified file and loads the data to the **Storage** instance for data storage.putSync('startup', 'auto') storage.flushSync() })() - ``` + ``` ## dataStorage.getStorage @@ -180,7 +178,7 @@ Reads a specified file and loads the data to the **Storage** instance for data storage.flushSync() }) })() - ``` + ``` ## dataStorage.getStorage @@ -248,7 +246,7 @@ Reads a specified file and loads the data to the **Storage** instance for data console.info("Get the storage failed, path: " + path + '/mystore') }) }() - ``` + ``` ## dataStorage.deleteStorageSync @@ -1614,4 +1612,3 @@ Unsubscribes from data changes. - diff --git a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md index dc09e186854d248a51cb7c1260de5db3febb3dee..49e61156a499d926620ecd0aa7bb6455c4aec9c7 100644 --- a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -1,6 +1,6 @@ # DataAbilityHelper Module (JavaScript SDK APIs) -#### Modules to Import +## Modules to Import ``` import featureAbility from '@ohos.ability.featureAbility' @@ -8,26 +8,27 @@ import ohos_data_ability from '@ohos.data.dataability' import ohos_data_rdb from '@ohos.data.rdb' ``` -#### DataAbilityHelper.openFile(uri: string, mode: string, callback: AsyncCallback\) +## DataAbilityHelper -- Functionality +### openFile - Opens a file with a specified URI. This method uses a callback to return the result. +openFile(uri: string, mode: string, callback: AsyncCallback\): void +Opens a file with a specified URI. This method uses a callback to return the result. -* Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | -------- | -------- | -------------------- | ---- | ------------------------ | - | uri | Read-only| string | Yes| URI of the file to open.| - | mode | Read-only| string | Yes| Mode for opening the file. The value can be **rwt**.| - | callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -* Return values +**Parameters** - Returns a file descriptor. +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ---------------------------------- | +| uri | string | Yes | URI of the file to open. | +| mode | string | Yes | Mode for opening the file. The value can be **rwt**. | +| callback | AsyncCallback\ | Yes | Callback used to return the file descriptor.| -* Example +**Example** ```javascript import featureAbility from '@ohos.ability.featureAbility' @@ -43,24 +44,29 @@ DAHelper.openFile( }); ``` -#### DataAbilityHelper.openFile(uri: string, mode: string) +### openFile -- Functionality +openFile(uri: string, mode: string): Promise\ - Opens a file with a specified URI. This method uses a promise to return the result. +Opens a file with a specified URI. This method uses a promise to return the result. -* Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | ---- | -------- | ------ | ---- | ------------------------ | - | uri | Read-only| string | Yes| URI of the file to open.| - | mode | Read-only| string | Yes| Mode for opening the file. The value can be **rwt**.| +SystemCapability.Ability.AbilityRuntime.FAModel -* Return values +**Parameters** - Returns a file descriptor. +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | ------------------------ | +| uri | string | Yes | URI of the file to open.| +| mode | string | Yes | Mode for opening the file. The value can be **rwt**. | -* Example +**Return value** +| Type | Description | +| ---------------- | ---------------- | +| Promise\ | Promise used to return the file descriptor.| + +**Example** ```javascript import featureAbility from '@ohos.ability.featureAbility' @@ -70,30 +76,30 @@ var DAHelper = featureAbility.acquireDataAbilityHelper( var mode = "rwt"; DAHelper.openFile( "dataability:///com.example.DataAbility", - mode).then((void) => { + mode).then((data) => { console.info("==========================>openFileCallback=======================>"); }); ``` -#### DataAbilityHelper.on(type: 'dataChange', uri: string, callback: AsyncCallback\) +### on('dataChange') -- Functionality +on(type: 'dataChange', uri: string, callback: AsyncCallback\): void - Registers an observer to observe data specified by a given URI. This method uses a callback to return the result. +Registers an observer to observe data specified by a given URI. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | -------- | -------- | -------------------- | ---- | ------------------------ | - | type | Read-only| string | Yes| Type of the event to observe. The value is **dataChange**.| - | uri | Read-only| string | Yes| URI of the data.| - | callback | Read-only| AsyncCallback\ | Yes| Callback invoked when the data is changed.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - void +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| type | string | Yes | Type of the event to observe. The value is **dataChange**. | +| uri | string | Yes | URI of the data.| +| callback | AsyncCallback\ | Yes | Callback invoked when the data is changed. | -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -110,25 +116,25 @@ helper.on( ) ``` -#### DataAbilityHelper.off(type: 'dataChange', uri: string, callback?: AsyncCallback\) +### off('dataChange') -- Functionality +off(type: 'dataChange', uri: string, callback?: AsyncCallback\): void - Unregisters the observer used to observe data specified by a given URI. This method uses a callback to return the result. +Unregisters the observer used to observe data specified by a given URI. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | -------- | -------- | -------------------- | ---- | ------------------------ | - | type | Read-only| string | Yes| Type of the event to observe. The value is **dataChange**.| - | uri | Read-only| string | Yes| URI of the data.| - | callback | Read-only| AsyncCallback\ | No| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - void +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| type | string | Yes | Type of the event to observe. The value is **dataChange**. | +| uri | string | Yes | URI of the data.| +| callback | AsyncCallback\ | No | Callback used to return the result. | -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -149,24 +155,24 @@ helper.off( ) ``` -#### DataAbilityHelper.getType(uri: string, callback: AsyncCallback\) +### getType -- Functionality +getType(uri: string, callback: AsyncCallback\): void - Obtains the MIME type of the data specified by a given URI. This method uses a callback to return the result. +Obtains the MIME type of the data specified by a given URI. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | -------- | -------- | ---------------------- | ---- | ------------------------ | - | uri | Read-only| string | Yes| URI of the data.| - | callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the MIME type that matches the data specified by the URI. +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | --------------------------------------------- | +| uri | string | Yes | URI of the data. | +| callback | AsyncCallback\ | Yes | Callback used to return the MIME type.| -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -180,23 +186,28 @@ DAHelper.getType( }); ``` -#### DataAbilityHelper.getType(uri: string) +### getType + +getType(uri: string): Promise\ -- Functionality +Obtains the MIME type of the data specified by a given URI. This method uses a promise to return the result. - Obtains the MIME type of the data specified by a given URI. This method uses a promise to return the result. +**System capabilities** -- Parameters +SystemCapability.Ability.AbilityRuntime.FAModel - | Name| Readable/Writable| Type| Mandatory| Description| - | ---- | -------- | ------ | ---- | ------------------------ | - | uri | Read-only| string | Yes| URI of the data.| +**Parameters** -- Return value +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | ------------------------ | +| uri | string | Yes | URI of the data.| - Returns the MIME type that matches the data specified by the URI. +**Return value** +| Type | Description | +| ---------------- | ----------------------------------- | +| Promise\ | Promise used to return the MIME type.| -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -210,25 +221,25 @@ DAHelper.getType( }); ``` -#### DataAbilityHelper.getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback>) +### getFileTypes -- Functionality +getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void - Obtains the supported MIME types of a specified file. This method uses a callback to return the result. +Obtains the supported MIME types of a specified file. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | -------------- | -------- | ------------------------------ | ---- | ---------------------------- | - | uri | Read-only| string | Yes| URI of the file.| - | mimeTypeFilter | Read-only| string | Yes| MIME type of the file.| - | callback | Read-only| AsyncCallback\> | Yes| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns a MIME type array. +| Name | Type | Mandatory| Description | +| -------------- | ------------------------------ | ---- | ---------------------------------- | +| uri | string | Yes | URI of the file. | +| mimeTypeFilter | string | Yes | MIME type of the file. | +| callback | AsyncCallback\> | Yes | Callback used to return the supported MIME types.| -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -243,24 +254,31 @@ DAHelper.getFileTypes( }); ``` -#### DataAbilityHelper.getFileTypes(uri: string, mimeTypeFilter: string) -- Functionality - Obtains the supported MIME types of a specified file. This method uses a promise to return the result. +### getFileTypes + +getFileTypes(uri: string, mimeTypeFilter: string): Promise\> + +Obtains the supported MIME types of a specified file. This method uses a promise to return the result. + +**System capabilities** -- Parameters +SystemCapability.Ability.AbilityRuntime.FAModel - | Name| Readable/Writable| Type| Mandatory| Description| - | -------------- | -------- | ------ | ---- | ---------------------------- | - | uri | Read-only| string | Yes| URI of the file.| - | mimeTypeFilter | Read-only| string | Yes| MIME type of the file.| +**Parameters** -- Return value +| Name | Type | Mandatory| Description | +| -------------- | ------ | ---- | ---------------------------- | +| uri | string | Yes | URI of the file. | +| mimeTypeFilter | string | Yes | MIME type of the file.| - Returns a MIME type array. +**Return value** +| Type | Description | +| ------------------------ | ------------------------ | +| Promise\> | Promise used to return the supported MIME types.| -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -275,24 +293,24 @@ DAHelper.getFileTypes( }); ``` -#### DataAbilityHelper.normalizeUri(uri: string, callback: AsyncCallback\) +### normalizeUri -- Functionality +normalizeUri(uri: string, callback: AsyncCallback\): void - Converts the URI that refers to a Data ability into a normalized URI. This method uses a callback to return the result. +Converts the URI that refers to a Data ability into a normalized URI. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | -------- | -------- | ---------------------- | ---- | ----------------------- | - | uri | Read-only| string | Yes| URI object to normalize.| - | callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the normalized URI object if the Data ability supports URI normalization; returns **null** otherwise. +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | ------------------------------------------------------------ | +| uri | string | Yes | URI object to normalize. | +| callback | AsyncCallback\ | Yes | Callback used to return the normalized URI object if the Data ability supports URI normalization. If the Data ability does not support URI normalization, **null** is returned.| -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -306,23 +324,28 @@ DAHelper.normalizeUri( }); ``` -#### DataAbilityHelper.normalizeUri(uri: string) +### normalizeUri -- Functionality +normalizeUri(uri: string): Promise\ - Converts the URI that refers to a Data ability into a normalized URI. This method uses a promise to return the result. +Converts the URI that refers to a Data ability into a normalized URI. This method uses a promise to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | ---- | -------- | ------ | ---- | ----------------------- | - | uri | Read-only| string | Yes| URI object to normalize.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the normalized URI object if the Data ability supports URI normalization; returns **null** otherwise. +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | ----------------------- | +| uri | string | Yes | URI object to normalize.| -- Example +**Return value** +| Type | Description | +| ---------------- | ------------------------------------------------------ | +| Promise\ | Promise used to return the normalized URI object if the Data ability supports URI normalization. If the Data ability does not support URI normalization, **null** is returned.| + +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -336,24 +359,24 @@ DAHelper.normalizeUri( }); ``` -#### DataAbilityHelper.denormalizeUri(uri: string, callback: AsyncCallback\) +### denormalizeUri -- Functionality +denormalizeUri(uri: string, callback: AsyncCallback\): void - Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: string, callback: AsyncCallback\)** to a denormalized one. This method uses a callback to return the result. +Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: string, callback: AsyncCallback\)** to a denormalized one. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | -------- | -------- | ---------------------- | ---- | ----------------------- | - | uri | Read-only| string | Yes| URI object to denormalize.| - | callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the denormalized URI object. +| Name | Type | Mandatory| Description | +| -------- | ---------------------- | ---- | --------------------------------------------------- | +| uri | string | Yes | URI object to normalize. | +| callback | AsyncCallback\ | Yes | Callback used to return the denormalized URI object.| -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -361,29 +384,36 @@ var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); DAHelper.denormalizeUri( - "dataability:///com.example.DataAbility",, + "dataability:///com.example.DataAbility", (err, data) => { console.info("==========================>Called=======================>"); }); ``` -#### DataAbilityHelper.denormalizeUri(uri: string) -- Functionality - Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: string)** to a denormalized one. This method uses a promise to return the result. +### denormalizeUri + +denormalizeUri(uri: string): Promise\ + +Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: string)** to a denormalized one. This method uses a promise to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | ---- | -------- | ------ | ---- | ----------------------- | - | uri | Read-only| string | Yes| URI object to denormalize.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the denormalized URI object. +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | ----------------------- | +| uri | string | Yes | URI object to normalize.| -- Example +**Return value** +| Type | Description | +| ---------------- | ----------------------------------------- | +| Promise\ | Promise used to return the denormalized URI object.| + +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -397,24 +427,24 @@ DAHelper.denormalizeUri( }); ``` -#### DataAbilityHelper.notifyChange(uri: string, callback: AsyncCallback\) +### notifyChange -- Functionality +notifyChange(uri: string, callback: AsyncCallback\): void - Notifies the registered observer of a change to the data specified by the URI. This method uses a callback to return the result. +Notifies the registered observer of a change to the data specified by the URI. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | -------- | -------- | -------------------- | ---- | ------------------------ | - | uri | Read-only| string | Yes| URI of the data.| - | callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - void +| Name | Type | Mandatory| Description | +| -------- | -------------------- | ---- | ------------------------ | +| uri | string | Yes | URI of the data.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -422,29 +452,34 @@ var helper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); helper.notifyChange( - "dataability:///com.example.DataAbility",, + "dataability:///com.example.DataAbility", (err) => { console.info("==========================>Called=======================>"); }); ``` -#### DataAbilityHelper.notifyChange(uri: string) +### notifyChange -- Functionality +notifyChange(uri: string): Promise\ - Notifies the registered observer of a change to the data specified by the URI. This method uses a promise to return the result. +Notifies the registered observer of a change to the data specified by the URI. This method uses a promise to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | ---- | -------- | ------ | ---- | ------------------------ | - | uri | Read-only| string | Yes| URI of the data.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - void +| Name| Type | Mandatory| Description | +| ---- | ------ | ---- | ------------------------ | +| uri | string | Yes | URI of the data.| -- Example +**Return value** +| Type | Description | +| -------------- | --------------------- | +| Promise\ | Promise used to return the result.| + +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -453,30 +488,30 @@ var DAHelper = featureAbility.acquireDataAbilityHelper( ); DAHelper.notifyChange( "dataability:///com.example.DataAbility", - ).then((void) => { + ).then(() => { console.info("==========================>notifyChangeCallback=======================>"); }); ``` -#### DataAbilityHelper.insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\) +### insert -- Functionality +insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\): void - Inserts a single data record into the database. This method uses a callback to return the result. +Inserts a single data record into the database. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | ------------ | -------- | ---------------------- | ---- | ------------------------------------------------------ | - | uri | Read-only| string | Yes| URI of the data to insert.| - | valuesBucket | Read-only| rdb.ValuesBucket | Yes| Data record to insert. If this parameter is **null**, a blank row will be inserted.| - | callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the index of the inserted data record. +| Name | Type | Mandatory| Description | +| ------------ | ---------------------- | ---- | ------------------------------------------------------ | +| uri | string | Yes | URI of the data to insert. | +| valuesBucket | rdb.ValuesBucket | Yes | Data record to insert. If this parameter is **null**, a blank row will be inserted.| +| callback | AsyncCallback\ | Yes | Callback used to return the index of the inserted data record. | -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -497,24 +532,29 @@ DAHelper.insert( }); ``` -#### DataAbilityHelper.insert(uri: string, valuesBucket: rdb.ValuesBucket) +### insert + +insert(uri: string, valuesBucket: rdb.ValuesBucket): Promise\ -- Functionality +Inserts a single data record into the database. This method uses a promise to return the result. - Inserts a single data record into the database. This method uses a promise to return the result. +**System capabilities** -- Parameters +SystemCapability.Ability.AbilityRuntime.FAModel - | Name| Readable/Writable| Type| Mandatory| Description| - | ------------ | -------- | ---------------- | ---- | ------------------------------------------------------ | - | uri | Read-only| string | Yes| URI of the data to insert.| - | valuesBucket | Read-only| rdb.ValuesBucket | Yes| Data record to insert. If this parameter is **null**, a blank row will be inserted.| +**Parameters** -- Return value +| Name | Type | Mandatory| Description | +| ------------ | ---------------- | ---- | ------------------------------------------------------ | +| uri | string | Yes | URI of the data to insert. | +| valuesBucket | rdb.ValuesBucket | Yes | Data record to insert. If this parameter is **null**, a blank row will be inserted.| - Returns the index of the inserted data record. +**Return value** +| Type | Description | +| ---------------- | ------------------------ | +| Promise\ | Promise used to return the index of the inserted data record.| -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -535,25 +575,25 @@ DAHelper.insert( }); ``` -#### DataAbilityHelper.batchInsert(uri: string, valuesBuckets: Array, callback: AsyncCallback\) +### batchInsert -- Functionality +batchInsert(uri: string, valuesBuckets: Array, callback: AsyncCallback\): void - Inserts multiple data records into the database. This method uses a callback to return the result. +Inserts multiple data records into the database. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | ------------ | -------- | ----------------------- | ---- | ------------------------ | - | uri | Read-only| string | Yes| URI of the data to insert.| - | valuesBucket | Read-only| Array | Yes| Data records to insert.| - | callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the number of inserted data records. +| Name | Type | Mandatory| Description | +| ------------ | ----------------------- | ---- | -------------------------------- | +| uri | string | Yes | URI of the data to insert. | +| valuesBucket | Array | Yes | Data records to insert. | +| callback | AsyncCallback\ | Yes | Callback used to return the number of inserted data records.| -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -571,24 +611,29 @@ DAHelper.batchInsert( }); ``` -#### DataAbilityHelper.batchInsert(uri: string, valuesBuckets: Array) +### batchInsert -- Functionality +batchInsert(uri: string, valuesBuckets: Array): Promise\ - Inserts multiple data records into the database. This method uses a promise to return the result. +Inserts multiple data records into the database. This method uses a promise to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | ------------ | -------- | ----------------------- | ---- | ------------------------ | - | uri | Read-only| string | Yes| URI of the data to insert.| - | valuesBucket | Read-only| Array | Yes| Data records to insert.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the number of inserted data records. +| Name | Type | Mandatory| Description | +| ------------ | ----------------------- | ---- | ------------------------ | +| uri | string | Yes | URI of the data to insert.| +| valuesBucket | Array | Yes | Data record to insert. | -- Example +**Return value** +| Type | Description | +| ---------------- | ---------------------- | +| Promise\ | Promise used to return the number of inserted data records.| + +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -606,25 +651,25 @@ DAHelper.batchInsert( }); ``` -#### DataAbilityHelper.delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\) +### delete -- Functionality +delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void - Deletes one or more data records from the database. This method uses a callback to return the result. +Deletes one or more data records from the database. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | ------------ | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | Read-only| string | Yes| URI of the data to delete.| - | valuesBucket | Read-only| dataAbility.DataAbilityPredicates | Yes| Filter criteria. You should define the processing logic when this parameter is **null**.| - | callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the number of deleted data records. +| Name | Type | Mandatory| Description | +| ------------ | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the data to delete. | +| valuesBucket | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| +| callback | AsyncCallback\ | Yes | Callback used to return the number of deleted data records. | -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -641,24 +686,29 @@ DAHelper.delete( }); ``` -#### DataAbilityHelper.delete(uri: string, predicates: dataAbility.DataAbilityPredicates) +### delete + +delete(uri: string, predicates: dataAbility.DataAbilityPredicates): Promise\ -- Functionality +Deletes one or more data records from the database. This method uses a promise to return the result. - Deletes one or more data records from the database. This method uses a promise to return the result. +**System capabilities** -- Parameters +SystemCapability.Ability.AbilityRuntime.FAModel - | Name| Readable/Writable| Type| Mandatory| Description| - | ------------ | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | Read-only| string | Yes| URI of the data to delete.| - | valuesBucket | Read-only| dataAbility.DataAbilityPredicates | Yes| Filter criteria. You should define the processing logic when this parameter is **null**.| +**Parameters** -- Return value +| Name | Type | Mandatory| Description | +| ------------ | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the data to delete. | +| valuesBucket | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| - Returns the number of deleted data records. +**Return value** +| Type | Description | +| ---------------- | ------------------------ | +| Promise\ | Promise used to return the number of deleted data records.| -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -674,26 +724,26 @@ DAHelper.delete( }); ``` -#### DataAbilityHelper.update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\) +### update -- Functionality +update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void - Updates data records in the database. This method uses a callback to return the result. +Updates data records in the database. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | ------------ | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | Read-only| string | Yes| URI of the data to update.| - | valuesBucket | Read-only| rdb.ValuesBucket | Yes| New values.| - | predicates | Read-only| dataAbility.DataAbilityPredicates | Yes| Filter criteria. You should define the processing logic when this parameter is **null**.| - | callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the number of updated data records. +| Name | Type | Mandatory| Description | +| ------------ | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the data to update. | +| valuesBucket | rdb.ValuesBucket | Yes | New values. | +| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| +| callback | AsyncCallback\ | Yes | Callback used to return the number of updated data records. | -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -717,25 +767,30 @@ DAHelper.update( }); ``` -#### DataAbilityHelper.update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates) +### update -- Functionality +update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates): Promise\ - Updates data records in the database. This method uses a promise to return the result. +Updates data records in the database. This method uses a promise to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | ------------ | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | Read-only| string | Yes| URI of the data to update.| - | valuesBucket | Read-only| rdb.ValuesBucket | Yes| New values.| - | predicates | Read-only| dataAbility.DataAbilityPredicates | Yes| Filter criteria. You should define the processing logic when this parameter is **null**.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the number of updated data records. +| Name | Type | Mandatory| Description | +| ------------ | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the data to update. | +| valuesBucket | rdb.ValuesBucket | Yes | New values. | +| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| -- Example +**Return value** +| Type | Description | +| ---------------- | -------------------------------------------- | +| Promise\ | Promise used to return the number of updated data records.| + +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -759,26 +814,26 @@ DAHelper.update( }); ``` -#### DataAbilityHelper.query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\) +### query -- Functionality +query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void - Queries data in the database. This method uses a callback to return the result. +Queries data in the database. This method uses a callback to return the result. -- Parameters +**System capabilities** - | Name| Readable/Writable| Type| Mandatory| Description| - | ---------- | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | Read-only| string | Yes| URI of the data to query.| - | columns | Read-only| rdb.ValuesBucket | Yes| Columns to query. If this parameter is **null**, all columns will be queried.| - | predicates | Read-only| dataAbility.DataAbilityPredicates | Yes| Filter criteria. You should define the processing logic when this parameter is **null**.| - | callback | Read-only| AsyncCallback\ | Yes| Callback used to return the result.| +SystemCapability.Ability.AbilityRuntime.FAModel -- Return value +**Parameters** - Returns the data queried. +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the data to query. | +| columns | rdb.ValuesBucket | Yes | Columns to query. If this parameter is **null**, all columns will be queried. | +| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| +| callback | AsyncCallback\ | Yes | Callback used to return the data queried. | -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -786,7 +841,7 @@ import ohos_data_ability from '@ohos.data.dataability' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); -var cars=new Array({"value1"}, {"value2"}, {"value3"}, {"value4"}); +var cars=new Array("value1", "value2", "value3", "value4"); let da = new ohos_data_ability.DataAbilityPredicates() DAHelper.query( "dataability:///com.example.DataAbility", @@ -799,25 +854,30 @@ DAHelper.query( -#### DataAbilityHelper.query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates) +### query + +query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates): Promise\ -- Functionality +Queries data in the database. This method uses a promise to return the result. - Queries data in the database. This method uses a promise to return the result. +**System capabilities** -- Parameters +SystemCapability.Ability.AbilityRuntime.FAModel - | Name| Readable/Writable| Type| Mandatory| Description| - | ---------- | -------- | --------------------------------- | ---- | ------------------------------------------------ | - | uri | Readable and writable| string | Yes| URI of the data to query.| - | columns | Readable and writable| rdb.ValuesBucket | Yes| Columns to query. If this parameter is **null**, all columns will be queried.| - | predicates | Readable and writable| dataAbility.DataAbilityPredicates | Yes| Filter criteria. You should define the processing logic when this parameter is **null**.| +**Parameters** -- Return value +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the data to query. | +| columns | rdb.ValuesBucket | Yes | Columns to query. If this parameter is **null**, all columns will be queried. | +| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.| - Returns the data queried. +**Return value** +| Type | Description | +| ------------------- | -------------- | +| Promise\ | Promise used to return the data queried.| -- Example +**Example** ```js import featureAbility from '@ohos.ability.featureAbility' @@ -825,7 +885,7 @@ import ohos_data_ability from '@ohos.data.dataability' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); -var cars=new Array({"value1"}, {"value2"}, {"value3"}, {"value4"}); +var cars=new Array("value1", "value2", "value3", "value4"); let da = new ohos_data_ability.DataAbilityPredicates() DAHelper.query( "dataability:///com.example.DataAbility", diff --git a/en/application-dev/reference/apis/js-apis-deque.md b/en/application-dev/reference/apis/js-apis-deque.md new file mode 100644 index 0000000000000000000000000000000000000000..1d94bd6b83d3707b566165ebfd1d0e2cb6f78afe --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-deque.md @@ -0,0 +1,274 @@ +# Linear Container Deque + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import Deque from '@ohos.util.Deque' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## Deque + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a double-ended queue (deque, called container later).| + +### constructor + +constructor() + +A constructor used to create a **Deque** instance. + +**Example** + +``` +let deque = new Deque(); +``` + +### insertFront + +insertFront(element: T): void + +Inserts an entry at the front of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to insert.| + +**Example** + +``` +let deque = new Deque; +deque.insertFront("a"); +deque.insertFront(1); +let b = [1, 2, 3]; +deque.insertFront(b); +let c = {name : "lala", age : "13"}; +deque.insertFront(false); +``` + +### insertEnd + +insertEnd(element: T): void + +Inserts an entry at the end of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to insert.| + +**Example** + +``` +let deque = new Deque; +deque.insertEnd("a"); +deque.insertEnd(1); +let b = [1, 2, 3]; +deque.insertEnd(b); +let c = {name : "lala", age : "13"}; +deque.insertEnd(false); +``` + +### has + +has(element: T): boolean + +Checks whether this container has the specified entry. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to check.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.| + +**Example** + +``` +let deque = new Deque(); +let result = deque.has("Ahfbrgrbgnutfodgorrogorg"); +deque.insertFront("Ahfbrgrbgnutfodgorrogorg"); +let result1 = deque.has("Ahfbrgrbgnutfodgorrogorg"); +``` + +### popFirst + +popFirst(): T + +Removes the first entry of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let deque = new Deque(); +deque.insertFront(2); +deque.insertFront(4); +deque.insertEnd(5); +deque.insertFront(2); +deque.insertFront(4); +let result = deque.popFirst(); +``` + +### popLast + +popLast(): T + +Removes the last entry of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let deque = new Deque(); +deque.insertFront(2); +deque.insertEnd(4); +deque.insertFront(5); +deque.insertFront(2); +deque.insertFront(4); +deque.popLast(); +let result = deque.popLast(); +``` + +### forEach +forEach(callbackfn: (value: T, index?: number, deque?: Deque<T>) => void, +thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the element that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| deque | Deque<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let deque = new Deque(); +deque.insertFront(2); +deque.insertEnd(4); +deque.insertFront(5); +deque.insertEnd(4); +deque.forEach((value, index) => { + console.log(value, index); +}); +``` + +### getFirst + +getFirst(): T; + +Obtains the first entry of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry obtained.| + +**Example** + +``` +let deque = new Deque(); +deque.insertEnd(2); +deque.insertEnd(4); +deque.insertFront(5); +deque.insertFront(4); +let result = deque.getFirst(); +``` + +### getLast + +getLast(): T + +Obtains the last entry of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry obtained.| + +**Example** + +``` +let deque = new Deque(); +deque.insertFront(2); +deque.insertFront(4); +deque.insertFront(5); +deque.insertFront(4); +let result = deque.getLast(); +``` + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** +``` +let deque = new Deque(); +deque.insertFront(2); +deque.insertFront(4); +deque.insertFront(5); +deque.insertFront(4); + +// Method 1: +for (let item of deque) { + console.log(item); +} + +// Method 2: +let iter = deque[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-display.md b/en/application-dev/reference/apis/js-apis-display.md index dd7e82d3265847efcef897ba444739935dc2baf4..5ca404121fdaf677c863f8a23f338c20bd75e136 100644 --- a/en/application-dev/reference/apis/js-apis-display.md +++ b/en/application-dev/reference/apis/js-apis-display.md @@ -1,9 +1,8 @@ # Display -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. - ## Modules to Import ``` @@ -11,24 +10,19 @@ import display from '@ohos.display'; ``` -## Required Permissions - -None - - ## DisplayState Provides the state of a display. | Name| Default Value| Description| | -------- | -------- | -------- | -| STATE_UNKNOWN | 0 | Unknown.| -| STATE_OFF | 1 | The display is shut down.| -| STATE_ON | 2 | The display is powered on.| -| STATE_DOZE | 3 | The display is in sleep mode.| -| STATE_DOZE_SUSPEND | 4 | The display is in sleep mode, and the CPU is suspended.| -| STATE_VR | 5 | The display is in VR mode.| -| STATE_ON_SUSPEND | 6 | The display is powered on, and the CPU is suspended.| +| STATE_UNKNOWN | 0 | Unknown.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| STATE_OFF | 1 | The display is shut down.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| STATE_ON | 2 | The display is powered on.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| STATE_DOZE | 3 | The display is in sleep mode.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| STATE_DOZE_SUSPEND | 4 | The display is in sleep mode, and the CPU is suspended.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| STATE_VR | 5 | The display is in VR mode.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| STATE_ON_SUSPEND | 6 | The display is powered on, and the CPU is suspended.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| ## Display @@ -37,31 +31,33 @@ Describes the attributes of a display. | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| id | number | Yes| No| ID of the display.| -| name | string | Yes| No| Name of the display.| -| alive | boolean | Yes| No| Whether the display is alive.| -| state | [DisplayState](#displaystate) | Yes| No| State of the display.| -| refreshRate | number | Yes| No| Refresh rate of the display.| -| rotation | number | Yes| No| Screen rotation angle of the display.| -| width | number | Yes| No| Width of the display, in pixels.| -| height | number | Yes| No| Height of the display, in pixels.| -| densityDPI | number | Yes| No| Screen density of the display, in DPI.| -| densityPixels | number | Yes| No| Screen density of the display, in pixels.| -| scaledDensity | number | Yes| No| Scaling factor for fonts displayed on the display.| -| xDPI | number | Yes| No| Exact physical dots per inch of the screen in the horizontal direction.| -| yDPI | number | Yes| No| Exact physical dots per inch of the screen in the vertical direction.| +| id | number | Yes| No| ID of the display.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| name | string | Yes| No| Name of the display.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| alive | boolean | Yes| No| Whether the display is alive.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| state | [DisplayState](#DisplayState) | Yes| No| State of the display.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| refreshRate | number | Yes| No| Refresh rate of the display.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| rotation | number | Yes| No| Screen rotation angle of the display.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| width | number | Yes| No| Width of the display, in pixels.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| height | number | Yes| No| Height of the display, in pixels.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| densityDPI | number | Yes| No| Screen density of the display, in DPI.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| densityPixels | number | Yes| No| Screen density of the display, in pixels.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| scaledDensity | number | Yes| No| Scaling factor for fonts displayed on the display.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| xDPI | number | Yes| No| Exact physical dots per inch of the screen in the horizontal direction.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| yDPI | number | Yes| No| Exact physical dots per inch of the screen in the vertical direction.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| ## display.getDefaultDisplay -getDefaultDisplay(callback: AsyncCallback<Display>): void; +getDefaultDisplay(callback: AsyncCallback<Display>): void Obtains the default display object. +**System capabilities**: SystemCapability.WindowManager.WindowManager.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<[Display](#display)> | Yes| Callback used to return the attributes of the default display.| + | callback | AsyncCallback<[Display](#Display)> | Yes| Callback used to return the default display object.| - Example ``` @@ -76,19 +72,47 @@ Obtains the default display object. }); ``` +## display.getDefaultDisplay + +getDefaultDisplay(): Promise<Display> + +Obtains the default display object. + +**System capabilities**: SystemCapability.WindowManager.WindowManager.Core + +- Return value + + | Type| Description| + | ---------------------------------- | ---------------------------------------------- | + | Promise<[Display](#Display)> | Promise used to return the default display object.| + +- Example + + ``` + let promise = display.getDefaultDisplay(); + promise.then(() => { + console.log('getDefaultDisplay success'); + }).catch((err) => { + console.log('getDefaultDisplay fail: ' + JSON.stringify(err)); + }); + ``` ## display.getAllDisplay -getAllDisplay(callback: AsyncCallback<Array<Display>>): void; +getAllDisplay(callback: AsyncCallback<Array<Display>>): void Obtains all the display objects. +**System capabilities**: SystemCapability.WindowManager.WindowManager.Core + - Parameters + | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<Array<[Display](#display)>> | Yes| Callback used to return the attributes of all displays.| + | -------- | ---------------------------------------------------- | ---- | ------------------------------- | + | callback | AsyncCallback<Array<[Display](Display)>> | Yes| Callback used to return all the display objects.| - Example + ``` display.getAllDisplay((err, data) => { if (err) { @@ -99,13 +123,39 @@ Obtains all the display objects. }); ``` +## display.getAllDisplay + +getAllDisplay(): Promise<Array<Display>> + +Obtains all the display objects. + +**System capabilities**: SystemCapability.WindowManager.WindowManager.Core + +- Return value + + | Type| Description| + | ----------------------------------------------- | ------------------------------------------------------- | + | Promise<Array<[Display](#Display)>> | Promise used to return an array containing all the display objects.| + +- Example + + ``` + let promise = display.getAllDisplay(); + promise.then(() => { + console.log('getAllDisplay success'); + }).catch((err) => { + console.log('getAllDisplay fail: ' + JSON.stringify(err)); + }); + ``` ## display.on('add'|'remove'|'change') -on(type: 'add'|'remove'|'change', callback: Callback<number>): void; +on(type: 'add'|'remove'|'change', callback: Callback<number>): void Enables listening. +**System capabilities**: SystemCapability.WindowManager.WindowManager.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -124,10 +174,12 @@ Enables listening. ## display.off('add'|'remove'|'change') -off(type: 'add'|'remove'|'change', callback?: Callback<number>): void; +off(type: 'add'|'remove'|'change', callback?: Callback<number>): void Disables listening. +**System capabilities**: SystemCapability.WindowManager.WindowManager.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | diff --git a/en/application-dev/reference/apis/js-apis-distributed-account.md b/en/application-dev/reference/apis/js-apis-distributed-account.md index f0eaf4979b085d3376d35bec15450e998d879276..de6af60335ced5e58848390edeb0d353efdc33ba 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-account.md +++ b/en/application-dev/reference/apis/js-apis-distributed-account.md @@ -1,6 +1,7 @@ # Distributed Account Management ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../../public_sys-resources/icon-note.gif) **NOTE** +> >The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -9,6 +10,12 @@ import account_distributedAccount from '@ohos.account.distributedAccount'; ``` + +## System Capabilities + +SystemCapability.Account.OsAccount + + ## account\_distributedAccount.getDistributedAccountAbility getDistributedAccountAbility\(\): DistributedAccountAbility @@ -297,4 +304,3 @@ Defines distributed OS account information. - diff --git a/en/application-dev/reference/apis/js-apis-distributed-data.md b/en/application-dev/reference/apis/js-apis-distributed-data.md index 30de34fd1d670b79965c5affa2139ec963999eb8..eb9d6b4f5933cb441dbd7f91324927ade936013e 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-data.md +++ b/en/application-dev/reference/apis/js-apis-distributed-data.md @@ -1,9 +1,11 @@ -# Distributed Data Management +# Distributed Data Management ->![](../../public_sys-resources/icon-note.gif) **NOTE:** +>![](../../public_sys-resources/icon-note.gif) **NOTE** +> >The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Modules to Import + +## Modules to Import ``` import distributedData from '@ohos.data.distributedData'; @@ -12,45 +14,21 @@ import distributedData from '@ohos.data.distributedData'; SystemCapability.DistributedDataManager.KVStore.DistributedKVStore -## distributedData.createKVManager -createKVManager\(config: KVManagerConfig, callback: AsyncCallback\): void -Creates a **KVManager** object to manage key-value \(KV\) stores. This method uses an asynchronous callback to return the result. +## distributedData.createKVManager -- Parameters +createKVManager(config: KVManagerConfig, callback: AsyncCallback<KVManager>): void + +Creates a **KVManager** object to manage key-value (KV) stores. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| config | [KVManagerConfig](#kvmanagerconfig) | Yes| Configuration of the **KVManager** object, including the bundle name and user information of the caller.| +| callback | AsyncCallback<[KVManager](#kvmanager)> | Yes| Callback invoked to return the **KVManager** object created.| - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

config

-

KVManagerConfig

-

Yes

-

Configuration of the KVManager object, including the bundle name and user information of the caller.

-

callback

-

AsyncCallback<KVManager>

-

Yes

-

Callback invoked to return the KVManager object created.

-
- Example @@ -61,7 +39,7 @@ Creates a **KVManager** object to manage key-value \(KV\) stores. This method bundleName : 'com.example.datamanagertest', userInfo : { userId : '0', - userType : 0 + userType : distributedData.UserType.SAME_USER_ID } } distributedData.createKVManager(kvManagerConfig, function (err, manager) { @@ -77,54 +55,23 @@ Creates a **KVManager** object to manage key-value \(KV\) stores. This method } ``` +## distributedData.createKVManager -## distributedData.createKVManager - -createKVManager\(config: KVManagerConfig\): Promise +createKVManager(config: KVManagerConfig): Promise<KVManager> -Creates a **KVManager** object to manage KV stores. This method uses a promise to return the result. +Creates a **KVManager** object to manage KV stores. This method uses a promise to return the result. - Parameters - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

config

-

KVManagerConfig

-

Yes

-

Configuration of the KVManager object, including the bundle name and user information of the caller.

-
+| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| config |[KVManagerConfig](#kvmanager) | Yes| Configuration of the **KVManager** object, including the bundle name and user information of the caller.| -- Return values +- Return value - - - - - - - - - -

Type

-

Description

-

Promise<KVManager>

-

Promise used to return the KVManager object created.

-
+| Type| Description| +| -------- | -------- | +| Promise<[KVManager](#kvmanager)> | Promise used to return the **KVManager** object created.| - Example @@ -135,7 +82,7 @@ Creates a **KVManager** object to manage KV stores. This method uses a promise bundleName : 'com.example.datamanagertest', userInfo : { userId : '0', - userType : 0 + userType : distributedData.UserType.SAME_USER_ID } } distributedData.createKVManager(kvManagerConfig).then((manager) => { @@ -150,167 +97,67 @@ Creates a **KVManager** object to manage KV stores. This method uses a promise ``` -## KVManagerConfig - -Provides configuration of the **KVManager** object, including the bundle name and user information of the caller. - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

userInfo

-

UserInfo

-

Yes

-

User information.

-

bundleName

-

string

-

Yes

-

Bundle name.

-
- -## UserInfo +## KVManagerConfig + +Provides configuration of the **KVManager** object, including the bundle name and user information of the caller. + +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| userInfo | [UserInfo](#userinfo) | Yes| User information.| +| bundleName | string | Yes| Bundle name.| + + + +## UserInfo Defines user information. - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

userId

-

string

-

Yes

-

User ID.

-

userType

-

UserType

-

Yes

-

User type.

-
- -## UserType +| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| userId | string | Yes| User ID.| +| userType | [UserType](#usertype) | Yes| User type.| + + +## UserType Defines the user type. - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

SAME_USER_ID

-

0

-

User who logs in to different devices using the same account.

-
- -## KVManager - -Creates a **KVManager** object to obtain KV store information. Before calling any method in **KVManager**, you must use **createKVManager** to create a **KVManager** object. - -### getKVStore - -getKVStore\(storeId: string, options: Options, callback: AsyncCallback\): void +| Name| Default Value| Description| +| ----- | ------ | ------ | +| SAME\_USER_ID| 0 | User who logs in to different devices using the same account.| + + +## KVManager + +Creates a **KVManager** object to obtain KV store information. Before calling any method in **KVManager**, you must use **createKVManager** to create a **KVManager** object. + +### getKVStore + +getKVStore(storeId: string, options: Options, callback: AsyncCallback<T>): void Creates and obtains a KV store. This method uses an asynchronous callback to return the result. -- Parameters +- Parameters - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

storeId

-

string

-

Yes

-

Unique identifier of the KV store. The length cannot exceed MAX_STORE_ID_LENGTH.

-

options

-

Options

-

Yes

-

Configuration of the KV store.

-

callback

-

AsyncCallback<T>,

-

<T extends KVStore>

-

Yes

-

Callback invoked to return the KV store created.

-
+| Name| Type| Mandatory| Description| +| ----- | ------ | ------ | ------ | +| storeId | string | Yes| Unique identifier of the KV store. The length cannot exceed [MAX\_STORE\_ID\_LENGTH](#constants).| +| options | [Options](#options) | Yes| Configuration of the KV store.| +| callback | AsyncCallback<T>, <T extends KVStore>| Yes| Callback invoked to return the KV store created.| - Example ``` let kvStore; + let kvManager; try { const options = { createIfMissing : true, encrypt : false, backup : false, autoSync : true, - kvStoreType : 1, - securityLevel : 3, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + securityLevel : distributedData.SecurityLevel.S2, }; kvManager.getKVStore('storeId', options, function (err, store) { if (err) { @@ -326,1164 +173,4709 @@ Creates and obtains a KV store. This method uses an asynchronous callback to ret ``` -### getKVStore +### getKVStore -getKVStore\(storeId: string, options: Options\): Promise +getKVStore<T extends KVStore>(storeId: string, options: Options): Promise<T> Creates and obtains a KV store. This method uses a promise to return the result. -- Parameters +- Parameters + +| Name| Type| Mandatory| Description| +| ------- | ---------------------- | ---- | -------------------- | +| storeId | string | Yes| Unique identifier of the KV store. The length cannot exceed [MAX\_STORE\_ID\_LENGTH](#constants).| +| options | [Options](#options) | Yes| Configuration of the KV store.| + + +- Return value + +| Type| Description| +| -------------------------------------- | ------------------------ | +| Promise<T> <T extends KVStore> | Promise used to return the KV store created.| + + +- Example + + ``` + let kvStore; + let kvManager; + try { + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + securityLevel : distributedData.SecurityLevel.S2, + }; + kvManager.getKVStore('storeId', options).then((store) => { + console.log("getKVStore success"); + kvStore = store; + }).catch((err) => { + console.log("getKVStore err: " + JSON.stringify(err)); + }); + } catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + +### closeKVStore8+ ### + +closeKVStore(appId: string, storeId: string, kvStore: KVStore, callback: AsyncCallback<void>): void; + +Closes a KV store. This method uses an asynchronous callback to return the result. + +- Parameters + + +| Name| Type| Mandatory| Description| +| ------- | ----------------- | ---- | --------------------------- | +| appId | string | Yes| Bundle name of the app that invokes the KV store.| +| storeId | string | Yes| Unique identifier of the KV store to close. The length cannot exceed the value of [MAX\_STORE\_ID_LENGTH](#constants).| +| kvStore | [KVStore](#kvstore) | Yes| KV store to close.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the KV store is closed, **true** will be returned. Otherwise, **false** will be returned.| - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

storeId

-

string

-

Yes

-

Unique identifier of the KV store. The length cannot exceed MAX_STORE_ID_LENGTH.

-

options

-

Options

-

Yes

-

Configuration of the KV store.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<T>

-

<T extends KVStore>

-

Promise used to return the KV store created.

-
- Example ``` let kvStore; + let kvManager; + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, + } try { - const options = { - createIfMissing : true, - encrypt : false, - backup : false, - autoSync : true, - kvStoreType : 1, - securityLevel : 3, - }; - kvManager.getKVStore('storeId', options).then((store) => { - console.log("getKVStore success"); + kvManager.getKVStore('storeId', options, async function (err, store) { + console.log('getKVStore success'); kvStore = store; - }).catch((err) => { - console.log("getKVStore err: " + JSON.stringify(err)); + await kvManager.closeKVStore('appId', 'storeId', kvStore, function (err, data) { + console.log('closeKVStore success'); + }); }); } catch (e) { - console.log("An unexpected error occurred. Error:" + e); + console.log('closeKVStore e ' + e); } ``` +### closeKVStore8+ ### -## Options +closeKVStore(appId: string, storeId: string, kvStore: KVStore): Promise<void>; -Provides KV store configuration. +Closes a KV store. This method uses a promise to return the result. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

createIfMissing

-

boolean

-

No

-

Whether to create a KV store if no database file exists. By default, a KV store is created.

-

encrypt

-

boolean

-

No

-

Whether to encrypt database files. By default, database files are not encrypted.

-

backup

-

boolean

-

No

-

Whether to back up database files. By default, database files are backed up.

-

autoSync

-

boolean

-

No

-

Whether database files are automatically synchronized. By default, database files are not automatically synchronized.

-

kvStoreType

-

KVStoreType

-

No

-

Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.

-

securityLevel

-

SecurityLevel

-

No

-

Security level of the KV store. By default, the security level is not set.

-
- -## KVStoreType +- Parameters -Defines the KV store types. +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------------- | +| appId | string | Yes| Bundle name of the app that invokes the KV store.| +| storeId | string | Yes| Unique identifier of the KV store to close. The length cannot exceed the value of [MAX\_STORE\_ID_LENGTH](#constants).| +| kvStore | [KVStore](#kvstore) | Yes| KV store to close.| - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

DEVICE_COLLABORATION

-

0

-

Device KV store.

-

SINGLE_VERSION

-

1

-

Single KV store.

-

MULTI_VERSION

-

2

-

Multi-version KV store. This type is not supported currently.

-
- -## SecurityLevel +- Return value -Defines the KV store security levels. +| Type| Description| +| ------------- | -------------- | +| Promise | Promise used to return the result. If the KV store is closed, **true** will be returned. Otherwise, **false** will be returned.| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

NO_LEVEL

-

0

-

No security level is set for the KV store.

-

S0

-

1

-

The KV store security level is public.

-

S1

-

2

-

The KV store security level is low. If data leakage occurs, minor impact will be caused on the database.

-

S2

-

3

-

The KV store security level is medium. If data leakage occurs, moderate impact will be caused on the database.

-

S3

-

5

-

The KV store security level is high. If data leakage occurs, major impact will be caused on the database.

-

S4

-

6

-

The KV store security level is critical. If data leakage occurs, severe impact will be caused on the database.

-
- -## Constants +- Example -Defines the KV store constants. + ``` + let kvManager; + let kvStore; + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, + } + try { + kvManager.getKVStore('storeId', options).then(async (store) => { + console.log('getKVStore success'); + kvStore = store; + await kvManager.closeKVStore('appId', 'storeId', kvStore).then(() => { + console.log('closeKVStore success'); + }).catch((err) => { + console.log('closeKVStore err ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('CloseKVStore getKVStore err ' + JSON.stringify(err)); + }); + } catch (e) { + console.log('closeKVStore e ' + e); + } + ``` + + +### deleteKVStore8+ ### + +deleteKVStore(appId: string, storeId: string, callback: AsyncCallback<void>): void; + +Deletes a KV store. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| appId | string | Yes| Bundle name of the app that invokes the KV store.| +| storeId | string | Yes| Unique identifier of the KV store to delete. The length cannot exceed the value of [MAX\_STORE\_ID_LENGTH](#constants).| +| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the KV store is deleted, **true** will be returned. Otherwise, **false** will be returned.| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

MAX_KEY_LENGTH

-

1024

-

Maximum length (in bytes) of a key in the KV store.

-

MAX_VALUE_LENGTH

-

4194303

-

Maximum length (in bytes) of a value in the KV store.

-

MAX_KEY_LENGTH_DEVICE

-

896

-

Maximum length of the device coordinate key.

-

MAX_STORE_ID_LENGTH

-

128

-

Maximum length (in bytes) of the KV store ID.

-

MAX_QUERY_LENGTH

-

512000

-

Maximum query length.

-

MAX_BATCH_SIZE

-

128

-

Maximum size of a batch operation.

-
- -## KVStore - -Provides methods to manage data in a KV store, for example, adding or deleting data and subscribing to data changes or completion of data synchronization. Before calling any method in **KVStore**, you must use **getKVStore** to create a **KVStore** object. - -### put - -put\(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback\): void - -Adds a key-value pair of the specified type to the KV store. This method uses an asynchronous callback to return the result. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

key

-

string

-

Yes

-

Key of the key-value pair to add. It cannot be empty, and the length cannot exceed MAX_KEY_LENGTH.

-

value

-

Uint8Array | string | number | boolean

-

Yes

-

Value of the key-value pair to add. The value type can be Uint8Array, number, string, or boolean.

-

A value of the Uint8Array or string type cannot exceed MAX_VALUE_LENGTH.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
- Example ``` - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + let kvManager; + let kvStore; + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, + } try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { - if (err != undefined) { - console.log("put err: " + JSON.stringify(err)); - return; - } - console.log("put success"); + kvManager.getKVStore('store', options, async function (err, store) { + console.log('getKVStore success'); + kvStore = store; + await kvManager.deleteKVStore('appId', 'storeId', function (err, data) { + console.log('deleteKVStore success'); + }); }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); + } catch (e) { + console.log('DeleteKVStore e ' + e); } ``` +### deleteKVStore8+ ### -### put - -put\(key: string, value: Uint8Array | string | number | boolean\): Promise +deleteKVStore(appId: string, storeId: string): Promise<void>; -Adds a key-value pair of the specified type to the KV store. This method uses a promise to return the result. +Deletes a KV store. This method uses a promise to return the result. - Parameters - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

key

-

string

-

Yes

-

Key of the key-value pair to add. It cannot be empty, and the length cannot exceed MAX_KEY_LENGTH.

-

value

-

Uint8Array | string | number | boolean

-

Yes

-

Value of the key-value pair to add. The value type can be Uint8Array, number, string, or boolean.

-

A value of the Uint8Array or string type cannot exceed MAX_VALUE_LENGTH.

-
+| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| appId | string | Yes| Bundle name of the app that invokes the KV store.| +| storeId | string | Yes| Unique identifier of the KV store to delete. The length cannot exceed the value of [MAX\_STORE\_ID_LENGTH](#constants).| -- Return values - - - - - - - - - -

Type

-

Description

-

Promise<void>

-

Promise used to return the result.

-
+- Return value +| Type| Description| +| ------------- | -------------- | +| Promise<void> | Promise used to return the result. If the KV store is deleted, **true** will be returned. Otherwise, **false** will be returned.| - Example ``` - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + let kvManager; + let kvStore; + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : distributedData.KVStoreType.SINGLE_VERSION, + schema : '', + securityLevel : distributedData.SecurityLevel.S2, + } try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log("put success: " + JSON.stringify(data)); + kvManager.getKVStore('storId', options).then(async (store) => { + console.log('getKVStore success'); + kvStore = store; + await kvManager.deleteKVStore('appId', 'storeId').then(() => { + console.log('deleteKVStore success'); + }).catch((err) => { + console.log('deleteKVStore err ' + JSON.stringify(err)); + }); }).catch((err) => { - console.log("put err: " + JSON.stringify(err)); + console.log('getKVStore err ' + JSON.stringify(err)); }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); + } catch (e) { + console.log('deleteKVStore e ' + e); } ``` -### delete +### getAllKVStoreId8+ ### -delete\(key: string, callback: AsyncCallback\): void +getAllKVStoreId(appId: string, callback: AsyncCallback<string[]>): void; -Deletes a KV pair from the KV store. This method uses an asynchronous callback to return the result. +Obtains the IDs of all the KV stores that are created using **getKvStore** and have not been deleted using **deleteKvStore**. This method uses an asynchronous callback to return the result. - Parameters - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

key

-

string

-

Yes

-

Key of the KV pair to delete. It cannot be empty, and the length cannot exceed MAX_KEY_LENGTH.

-

callback

-

AsyncCallback<void>

-

Yes

-

Callback invoked to return the result.

-
+| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| appId | string | Yes| Bundle name of the app that invokes the KV store.| +| callback | AsyncCallback<void> | Yes|Callback used to return the KV store IDs obtained. | - Example ``` - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + let kvManager; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { - if (err != undefined) { - console.log("put err: " + JSON.stringify(err)); - return; - } - console.log("put success"); - kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) { - if (err != undefined) { - console.log("delete err: " + JSON.stringify(err)); - return; - } - console.log("delete success"); - }); + kvManager.getAllKVStoreId('appId', function (err, data) { + console.log('GetAllKVStoreId success'); + console.log('GetAllKVStoreId size = ' + data.length); }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); + } catch (e) { + console.log('GetAllKVStoreId e ' + e); } ``` -### delete +### getAllKVStoreId8+ ### -delete\(key: string\): Promise +getAllKVStoreId(appId: string): Promise<string[]>; -Deletes a KV pair from the KV store. This method uses a promise to return the result. +Obtains the IDs of all the KV stores that are created using **getKvStore** and have not been deleted using **deleteKvStore**. This method uses a promise to return the result. - Parameters - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

key

-

string

-

Yes

-

Key of the KV pair to delete. It cannot be empty, and the length cannot exceed MAX_KEY_LENGTH.

-
+| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| appId | string | Yes| Bundle name of the app that invokes the KV store.| + -- Return values +- Return value - - - - - - - - - -

Type

-

Description

-

Promise<void>

-

Promise used to return the result.

-
+| Type| Description| +| ------------- | -------------- | +| Promise<string[]>| Promise used to return the KV store IDs obtained.| - Example ``` - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + let kvManager; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log("put success: " + JSON.stringify(data)); - kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log("delete success"); - }).catch((err) => { - console.log("delete err: " + JSON.stringify(err)); - }); + console.log('GetAllKVStoreId'); + kvManager.getAllKVStoreId('apppId').then((data) => { + console.log('getAllKVStoreId success'); + console.log('size = ' + data.length); }).catch((err) => { - console.log("put err: " + JSON.stringify(err)); + console.log('getAllKVStoreId err ' + JSON.stringify(err)); }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); + } catch(e) { + console.log('getAllKVStoreId e ' + e); } ``` -### on +### on8+ ### -on\(event: 'dataChange', type: SubscribeType, observer: Callback\): void +on(event: 'distributedDataServiceDie', deathCallback: Callback<void>): void; -Subscribes to data changes of the specified type. This method uses a synchronization callback to return the result. +Subscribes to the **distributedDataServiceDie** events. This method uses a synchronous callback to return the result. - Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

event

-

'dataChange'

-

Type of the events.

-

type

-

SubscribeType

-

Type of data changes.

-

observer

-

Callback<ChangeNotification>

-

Callback invoked to return the result.

-
+| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| event | 'distributedDataServiceDie' | Yes| Type of events to subscribe to. | +| deathCallback | Callback<void> | Yes| Callback invoked when the distributed data service is dead.| + + - Example ``` - kvStore.on('dataChange', 2, function (data) { - console.log("dataChange callback call data: " + JSON.stringify(data)); - }); + let kvManager; + try { + + console.log('KVManagerOn'); + const deathCallback = function () { + console.log('death callback call'); + } + kvManager.on('distributedDataServiceDie', deathCallback); + } catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } ``` -### on +### off8+ ### -on\(event: 'syncComplete', syncCallback: Callback\>\): void +off(event: 'distributedDataServiceDie', deathCallback?: Callback<void>): void; -Subscribes to notifications of data synchronization completion. This method uses a synchronization callback to return the result. +Unsubscribes from the **distributedDataServiceDie** events. This method uses a synchronous callback to return the result. - Parameters - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

event

-

'syncComplete'

-

Type of the events.

-

syncCallback

-

Callback<Array<[string, number]>>

-

Callback invoked to return the result.

-
+| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| event | 'distributedDataServiceDie' | Yes| Type of events to unsubscribe from. | +| deathCallback | Callback<void> | No| Callback used to return the **distributedDataServiceDie** events.| + - Example ``` - kvStore.on('syncComplete', function (data) { - console.log("syncComplete callback call data: " + data); - }); + let kvManager; + try { + console.log('KVManagerOff'); + const deathCallback = function () { + console.log('death callback call'); + } + kvManager.off('distributedDataServiceDie', deathCallback); + } catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` +## Options -## SubscribeType +Provides KV store configuration. -Defines the subscription type. +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| createIfMissing | boolean | No| Whether to create a KV store if no database file exists. By default, a KV store is created.| +| encrypt | boolean | No|Whether to encrypt database files. By default, database files are not encrypted.| +| backup | boolean | No|Whether to back up database files. By default, database files are backed up. | +| autoSync | boolean | No|Whether to automatically synchronize database files. By default, database files are not automatically synchronized.| +| kvStoreType | [KVStoreType](#kvstoretype) | No|Type of the KV store to create. By default, a device KV store is created. The device KV store stores data for multiple devices that collaborate with each other.| +| securityLevel | [SecurityLevel](#securitylevel) | No|Security level of the KV store. By default, the security level is not set.| - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

SUBSCRIBE_TYPE_LOCAL

-

0

-

Local data changes.

-

SUBSCRIBE_TYPE_REMOTE

-

1

-

Peer data changes.

-

SUBSCRIBE_TYPE_ALL

-

2

-

Local and peer data changes.

-
- -## ChangeNotification -Defines the content of data change notifications, including inserted data, updated data, deleted data, and device ID. +## KVStoreType - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

insertEntries

-

Entry[]

-

Yes

-

Yes

-

Data inserted.

-

updateEntries

-

Entry[]

-

Yes

-

Yes

-

Data updated.

-

deleteEntries

-

Entry[]

-

Yes

-

Yes

-

Data deleted.

-

deviceId

-

string

-

Yes

-

Yes

-

UUID of the device.

-
- -## Entry - -Defines the key-value pairs stored in the database. - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

key

-

string

-

Yes

-

Yes

-

Key of the key-value pair stored in the database.

-

value

-

Value

-

Yes

-

Yes

-

Value of the key-value pair stored in the database.

-
- -## Value - -Defines the value in a key-value pair. - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

type

-

ValueType

-

Yes

-

Yes

-

Type of the value.

-

value

-

Uint8Array | string | number | boolean

-

Yes

-

Yes

-

Specific value. A value of the Uint8Array or string type cannot exceed MAX_VALUE_LENGTH.

-
- -## ValueType - -Defines the types of the value in a key-value pair. - -It can be used only by internal applications. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

STRING

-

0

-

String.

-

INTEGER

-

1

-

Integer.

-

FLOAT

-

2

-

Float (single-precision floating point).

-

BYTE_ARRAY

-

3

-

Byte array.

-

BOOLEAN

-

4

-

Boolean.

-

DOUBLE

-

5

-

Double (double-precision floating point).

-
- -## SingleKVStore - -Provides methods to query and synchronize data in a single KV store. This class inherits from **KVStore**. Before calling any method in **SingleKVStore**, you must use **getKVStore** to create a **KVStore** object. - -### get - -get\(key: string, callback: AsyncCallback\): void +Defines the KV store types. -Obtains the value of a specified key. This method uses an asynchronous callback to return the result. +| Name| Default Value| Description| +| --- | ---- | ----------------------- | +| DEVICE_COLLABORATION | 0 | Device KV store.| +| SINGLE_VERSION | 1 | Single KV store.| +| MULTI_VERSION | 2 | Multi-version KV store. This type is not supported currently.| -- Parameters - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

key

-

string

-

Yes

-

Key of the value to obtain. It cannot be empty, and the length cannot exceed MAX_KEY_LENGTH.

-

callback

-

AsyncCallback<Uint8Array | string | boolean | number>

-

Yes

-

Callback invoked to return the value obtained.

-
+ +## SecurityLevel + +Defines the KV store security levels. + +| Name| Default Value| Description| +| --- | ---- | ----------------------- | +| NO_LEVEL | 0 | No security level is set for the KV store.| +| S0 | 1 | The KV store security level is public.| +| S1 | 2 | The KV store security level is low. If data leakage occurs, minor impact will be caused on the database.| +| S2 | 3 | The KV store security level is medium. If data leakage occurs, moderate impact will be caused on the database.| +| S3 | 5 | The KV store security level is high. If data leakage occurs, major impact will be caused on the database.| +| S4 | 6 | The KV store security level is critical. If data leakage occurs, severe impact will be caused on the database.| + + +## Constants + +Defines the KV store constants. + +| Name| Default Value| Description| +| --- | ---- | ----------------------- | +| MAX\_KEY_LENGTH| 1024 | Maximum length (in bytes) of a key in the KV store.| +| MAX\_VALUE_LENGTH| 4194303 | Maximum length (in bytes) of a value in the KV store.| +| MAX\_KEY\_LENGTH\_DEVICE| 896 | Maximum length of the device coordinate key.| +| MAX\_STORE\_ID\_LENGTH| 128 | Maximum length (in bytes) of a KV store ID.| +| MAX\_QUERY_LENGTH| 512000 | Maximum query length.| +| MAX\_BATCH_SIZE| 128 | Maximum size of a batch operation.| + +## Schema8+ ## + +Defines a database schema. When creating or opening a KV store, you can create a **Schema** object and put it into **Options**. + +### toJsonString8+ ### + +toJsonString():string; + +Obtains the schema in JSON format. + +- Return value + +| Type| Description| +| ------------- | -------------- | +| string |Schema in JSON format obtained.| - Example ``` - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + import ddm from '@ohos.data.distributedData'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { - if (err != undefined) { - console.log("put err: " + JSON.stringify(err)); - return; - } - console.log("put success"); - kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) { - console.log("get success data: " + data); - }); - }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); + let schema = new ddm.Schema(); + const str = schema.toJsonString(); + console.log("schema: " + str); + } catch (e) { + console.log("toJsonString " + e); } ``` -### get +## FieldNode8+ ## -get\(key: string\): Promise +Defines a node of a **Schema** instance. It provides methods for defining values stored in the KV store. -Obtains the value of a specified key. This method uses a promise to return the result. +### appendChild8+ ### + +appendChild(child: FieldNode): boolean; + +Adds a child node to this **FieldNode**. - Parameters - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

key

-

string

-

Yes

-

Key of the value to obtain. It cannot be empty, and the length cannot exceed MAX_KEY_LENGTH.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<Uint8Array | string | boolean | number>

-

Promise used to return the result.

-
+| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| child | [FieldNode](#FieldNode) | Yes| Child node to add.| + +- Return value + +| Type| Description| +| ------------- | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise.| - Example ``` - const KEY_TEST_STRING_ELEMENT = 'key_test_string'; - const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + import ddm from '@ohos.data.distributedData'; try { - kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { - console.log("put success: " + JSON.stringify(data)); - kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { - console.log("get success data: " + data); - }).catch((err) => { - console.log("get err: " + JSON.stringify(err)); - }); + let node = new ddm.FieldNode("root"); + let child1 = new ddm.FieldNode("child1"); + let child2 = new ddm.FieldNode("child2"); + let child3 = new ddm.FieldNode("child3"); + node.appendChild(child1); + node.appendChild(child2); + node.appendChild(child3); + console.log("appendNode " + node.toJson()); + child1 = null; + child2 = null; + child3 = null; + node = null; + } catch (e) { + console.log("AppendChild " + e); + } + ``` + + +### toJson8+ ### + +toJson(): string; + +Obtains the field name. + +- Return value + +| Type| Description| +| ------ | -------------- | +| string |Field name obtained.| + +- Example + + ``` + import ddm from '@ohos.data.distributedData'; + try { + let node = new ddm.FieldNode("root"); + let child = new ddm.FieldNode("child"); + node.appendChild(child); + console.log("appendNode " + node.toJson()); + } catch (e) { + console.log("ToJson " + e); + } + ``` + + +## KvStoreResultSet8+ ## + +Provides methods to obtain the KV store result set and query or move the data read position. Before calling any method in **KvStoreResultSet**, you must use **KvStore** to create a **KvStore** instance. + +### getCount8+ ### + +getCount(): number; + +Obtains the number of rows in the result set. + +- Return value + +| Type| Description| +| ------ | -------------- | +| number |Number of rows obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; }).catch((err) => { - console.log("put err: " + JSON.stringify(err)); + console.log('getResultSet fail ' + err); }); - }catch (e) { - console.log("An unexpected error occurred. Error:" + e); + const count = resultSet.getCount(); + console.log("GetCount " + count); + } catch (e) { + console.log("GetCount fail " + e); } ``` -### sync +### getPosition8+ ### -sync\(deviceIdList: string\[\], mode: SyncMode, allowedDelayMs?: number\): void +getPosition(): number; -Triggers synchronization of the KV store, which is in manual synchronization mode. +Obtains the current data read position (position from which data is read) in the result set. -- Parameters +- Return value - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

deviceIdList

-

string[]

-

Yes

-

List of IDs of the devices in the same networking environment to be synchronized.

-

mode

-

SyncMode

-

Yes

-

Synchronization mode.

-

allowedDelayMs

-

number

-

No

-

Allowed delay time, in ms.

-
+| Type| Description| +| ------ | -------------- | +| number |Current data read position obtained.| - Example ``` - kvStore.sync(deviceIds, 1, 1000); + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const positon = resultSet.getPosition(); + console.log("getPosition " + positon); + } catch (e) { + console.log("GetPosition fail " + e); + } ``` -## SyncMode +### moveToFirst8+ ### -Defines the synchronization mode. +moveToFirst(): boolean; + +Moves the data read position to the first row. + +- Return value + +| Type| Description| +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise.| - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

PULL_ONLY

-

0

-

Pull data from the peer end to the local end only.

-

PUSH_ONLY

-

1

-

Push data from the local end to the peer end only.

-

PUSH_PULL

-

2

-

Push data from the local end to the peer end and then pull data from the peer end to the local end.

-
+- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToFirst(); + console.log("moveToFirst " + moved); + } catch (e) { + console.log("MoveToFirst fail " + e); + } + ``` + + +### moveToLast8+ ### + +moveToLast(): boolean; + +Moves the data read position to the last row. + +- Return value + +| Type| Description| +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToLast(); + console.log("moveToLast " + moved); + } catch (e) { + console.log("moveToLast fail " + e); + } + ``` + + +### moveToNext8+ ### + +moveToNext(): boolean; + +Moves the data read position to the next row. + +- Return value + +| Type| Description| +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToNext(); + console.log("moveToNext " + moved); + } catch (e) { + console.log("moveToNext fail " + e); + } + ``` + + +### moveToPrevious8+ ### + +moveToPrevious(): boolean; + +Moves the data read position to the previous row. + +- Return value + +| Type| Description| +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToPrevious(); + console.log("moveToPrevious " + moved); + } catch (e) { + console.log("moveToPrevious fail " + e); + } + ``` + + +### move8+ ### + +move(offset: number): boolean; + +Moves the data read position with the specified offset from the current position. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| offset | number | Yes| Offset to move the data read position. A negative value means to move backward, and a positive value means to move forward.| + +- Return value + +| Type| Description| +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.move(); + console.log("move " + moved); + } catch (e) { + console.log("move fail " + e); + } + ``` + + +### moveToPosition8+ ### + +moveToPosition(position: number): boolean; + +Moves the data read position from 0 to an absolute position. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| position | number | Yes|Absolute position to move to.| + +- Return value + +| Type| Description| +| ------ | -------------- | +| boolean |Returns **true** if the operation is successful; returns **false** otherwise.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToPosition(); + console.log("moveToPosition " + moved); + } catch (e) { + console.log("moveToPosition fail " + e); + } + ``` + + +### isFirst8+ ### + +isFirst(): boolean; + +Checks whether the data read position is the first row. + +- Return value + +| Type| Description| +| ------ | -------------- | +| boolean |Returns **true** if the data read position is the first row; returns **false** otherwise.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.isFirst(); + console.log("isFirst " + moved); + } catch (e) { + console.log("isFirst fail " + e); + } + ``` + + +### isLast8+ ### + +isLast(): boolean; + +Checks whether the data read position is the last row. + +- Return value + +| Type| Description| +| ------ | -------------- | +| boolean |Returns **true** if the data read position is the last row; returns **false** otherwise.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.isLast(); + console.log("isLast " + moved); + } catch (e) { + console.log("isLast fail " + e); + } + ``` + + +### isBeforeFirst8+ ### + +isBeforeFirst(): boolean; + +Checks whether the data read position is before the first row. + +- Return value + +| Type| Description| +| ------ | -------------- | +| boolean |Returns **true** if the read position is before the first row; returns **false** otherwise.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.isBeforeFirst(); + console.log("isBeforeFirst " + moved); + } catch (e) { + console.log("isBeforeFirst fail " + e); + } + ``` + + +### isAfterLast8+ ### + +isAfterLast(): boolean; + +Checks whether the data read position is after the last row. + +- Return value + +| Type| Description| +| ------ | -------------- | +| boolean |Returns **true** if the data read position is after the last row; returns **false** otherwise.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.isAfterLast(); + console.log("isAfterLast " + moved); + } catch (e) { + console.log("isAfterLast fail " + e); + } + ``` + + +### getEntry8+ ### + +getEntry(): Entry; + +Obtains a KV pair. + +- Return value + +| Type| Description| +| ------ | ------- | +| Entry |KV pair obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + err); + }); + const moved = resultSet.moveToNext(); + const entry = resultSet.getEntry(); + console.log("getEntry " + JSON.stringify(entry)); + } catch (e) { + console.log("getEntry fail " + e); + } + ``` + + +## Query8+ ## + +Provides methods to create a **Query** object, which defines different data query criteria. + +### reset8+ ### + +reset(): Query; + +Resets the **Query** object that contains common query options. + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object reset.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.equalTo("key", "value"); + console.log("query is " + query.getSqlLike()); + query.reset(); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("simply calls should be ok :" + e); + } + ``` + + +### equalTo8+ ### + +equalTo(field: string, value: number|string|boolean): Query; + +Creates a **Query** object to match the specified field whose value is equal to the specified value. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| value | number/string/boolean | Yes| Value specified.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.equalTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### notEqualTo8+ ### + +notEqualTo(field: string, value: number|string|boolean): Query; + +Creates a **Query** object to match the specified field whose value is not equal to the specified value. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| value | number/string/boolean | Yes| Value specified.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### greaterThan8+ ### + +greaterThan(field: string, value: number|string|boolean): Query; + +Creates a **Query** object to match the specified field whose value is greater than the specified value. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| value | number/string/boolean | Yes| Value specified.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.greaterThan("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### lessThan8+ ### + +lessThan(field: string, value: number|string): Query; + +Creates a **Query** object to match the specified field whose value is less than the specified value. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| value | number/string/boolean | Yes| Value specified.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.lessThan("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### greaterThanOrEqualTo8+ ### + +greaterThanOrEqualTo(field: string, value: number|string): Query; + +Creates a **Query** object to match the specified field whose value is greater than or equal to the specified value. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| value | number/string/boolean | Yes| Value specified.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.greaterThanOrEqualTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### lessThanOrEqualTo8+ ### + +lessThanOrEqualTo(field: string, value: number|string): Query; + +Creates a **Query** object to match the specified field whose value is less than or equal to the specified value. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| value | number/string/boolean | Yes| Value specified.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.lessThanOrEqualTo("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### isNull8+ ### + +isNull(field: string): Query; + +Creates a **Query** object to match the specified field whose value is **null**. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.isNull("field"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### inNumber8+ ### + +inNumber(field: string, valueList: number[]): Query; + +Creates a **Query** object to match the specified field whose value is within the specified list of numbers. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| valueList | number[] | Yes| List of numbers.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.inNumber("field", [0, 1]); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### inString8+ ### + +inString(field: string, valueList: string[]): Query; + +Creates a **Query** object to match the specified field whose value is within the specified list of strings. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| valueList | string[] | Yes| List of strings.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.inString("field", ['test1', 'test2']); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### notInNumber8+ ### + +notInNumber(field: string, valueList: number[]): Query; + +Creates a **Query** object to match the specified field whose value is not within the specified list of numbers. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| valueList | number[] | Yes| List of numbers.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.notInNumber("field", [0, 1]); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### notInString8+ ### + +notInString(field: string, valueList: string[]): Query; + +Creates a **Query** object to match the specified field whose value is not within the specified list of strings. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| valueList | string[] | Yes| List of strings.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.notInString("field", ['test1', 'test2']); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### like8+ ### + +like(field: string, value: string): Query; + +Creates a **Query** object to match the specified field whose value is similar to the specified string. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| valueList | string | Yes| String specified.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.like("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### unlike8+ ### + +unlike(field: string, value: string): Query; + +Creates a **Query** object to match the specified field whose value is not similar to the specified string. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| +| valueList | string | Yes| String specified.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.unlike("field", "value"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### and8+ ### + +and(): Query; + +Creates a **Query** object with the AND condition. + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value1"); + query.and(); + query.notEqualTo("field", "value2"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### or8+ ### + +or(): Query; + +Creates a **Query** object with the OR condition. + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value1"); + query.or(); + query.notEqualTo("field", "value2"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### orderByAsc8+ ### + +orderByAsc(field: string): Query; + +Creates a **Query** object to sort the query results in ascending order. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + query.orderByAsc("field"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### orderByDesc8+ ### + +orderByDesc(field: string): Query; + +Creates a **Query** object to sort the query results in descending order. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field to match. It must start with $ and cannot contain ^.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + query.orderByDesc("field"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### limit8+ ### + +limit(total: number, offset: number): Query; + +Creates a **Query** object to specify the number of results and where to start. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| total | number | Yes|Number of results to query.| +| offset | number | Yes|Start position for query.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.notEqualTo("field", "value"); + query.limit("total", "offset"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### isNotNull8+ ### + +isNotNull(field: string): Query; + +Creates a **Query** object with a specified field that is not null. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| fieId | string | Yes|Field specified.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.isNotNull("field"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### beginGroup8+ ### + +beginGroup(): Query; + +Creates a **Query** object for a query condition group with a left parenthesis. + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.beginGroup(); + query.isNotNull("field"); + query.endGroup(); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### endGroup8+ ### + +endGroup(): Query; + +Creates a **Query** object for a query condition group with a right parenthesis. + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.beginGroup(); + query.isNotNull("field"); + query.endGroup(); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### prefixKey8+ ### + +prefixKey(prefix: string): Query; + +Creates a **Query** object with a specified key prefix. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| prefix | string | Yes|Key prefix.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.prefixKey("$.name"); + query.prefixKey("0"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### setSuggestIndex8+ ### + +setSuggestIndex(index: string): Query; + +Creates a **Query** object with an index preferentially used for query. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| index | string | Yes|Index preferentially used for query.| + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.setSuggestIndex("$.name"); + query.setSuggestIndex("0"); + console.log("query is " + query.getSqlLike()); + query = null; + } catch (e) { + console.log("dumplicated calls should be ok :" + e); + } + ``` + + +### deviceId8+ ### + +deviceId(deviceId:string):Query; + +Creates a **Query** object with the device ID as the key prefix. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId | string | Yes|Device ID.| + + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object created.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + query.deviceId("deviceId"); + console.log("query is " + query.getSqlLike()); + } catch (e) { + console.log("should be ok on Method Chaining : " + e); + } + ``` + + +### getSqlLike8+ ### + +getSqlLike():string; + +Obtains the query statement of this **Query** object. + +- Return value + +| Type| Description| +| ------ | ------- | +| [Query](#querysup8sup) |**Query** object.| + +- Example + + ``` + try { + let query = new distributedData.Query(); + let sql1 = query.getSqlLike(); + console.log("GetSqlLike sql=" + sql1); + } catch (e) { + console.log("dumplicated calls should be ok : " + e); + } + ``` + + +## KVStore + +Provides methods to manage data in a KV store, for example, adding or deleting data and subscribing to data changes or completion of data synchronization. Before calling any method in **KVStore**, you must use **getKVStore** to obtain a **KVStore** object. + +### put + +put(key: string, value: Uint8Array | string | number | boolean, callback: AsyncCallback<void>): void + +Adds a KV pair of the specified type to this KV store. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| key | string | Yes|Key of the KV pair to add. It cannot be empty, and the length cannot exceed [MAX\_KEY\_LENGTH](#constants).| +| value | Uint8Array / string / number / boolean | Yes|Value of the KV pair to add. The value type can be Uint8Array, number, string, or boolean. A value of the Uint8Array or string type cannot exceed [MAX\_VALUE\_LENGTH](#constants).| + + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + }); + }catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + + +### put + +put(key: string, value: Uint8Array | string | number | boolean): Promise<void> + +Adds a KV pair of the specified type to this KV store. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| key | string | Yes|Key of the KV pair to add. It cannot be empty, and the length cannot exceed [MAX\_KEY\_LENGTH](#constants).| +| value | Uint8Array / string / number / boolean | Yes|Value of the KV pair to add. The value type can be Uint8Array, number, string, or boolean. A value of the Uint8Array or string type cannot exceed [MAX\_VALUE\_LENGTH](#constants).| + +- Return value + +| Type| Description| +| ------ | ------- | +| Promise<void> |Promise used to return the result.| + + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { + console.log("put success: " + JSON.stringify(data)); + }).catch((err) => { + console.log("put err: " + JSON.stringify(err)); + }); + }catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + + +### delete + +delete(key: string, callback: AsyncCallback<void>): void + +Deletes a KV pair from this KV store. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| key | string | Yes|Key of the KV pair to delete. It cannot be empty, and the length cannot exceed [MAX\_KEY\_LENGTH](#constants).| +| callback | AsyncCallback<void> | Yes|Callback used to return the result.| + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("delete err: " + JSON.stringify(err)); + return; + } + console.log("delete success"); + }); + }); + }catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + + +### delete + +delete(key: string): Promise<void> + +Deletes a KV pair from this KV store. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| key | string | Yes|Key of the KV pair to delete. It cannot be empty, and the length cannot exceed [MAX\_KEY\_LENGTH](#constants).| + +- Return value + +| Type| Description| +| ------ | ------- | +| Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { + console.log("put success: " + JSON.stringify(data)); + kvStore.delete(KEY_TEST_STRING_ELEMENT).then((data) => { + console.log("delete success"); + }).catch((err) => { + console.log("delete err: " + JSON.stringify(err)); + }); + }).catch((err) => { + console.log("put err: " + JSON.stringify(err)); + }); + }catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + + +### on + +on(event: 'dataChange', type: SubscribeType, observer: Callback<ChangeNotification>): void + +Subscribes to data changes of the specified type. This method uses a synchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| event |'dataChange' | Yes|Type of the events to subscribe to.| +| type |[SubscribeType](#subscribetypea) | Yes|Type of data changes.| +| observer |Callback<[ChangeNotification](#changenotificationa)> | Yes|Callback used to return the result.| + + +- Example + + ``` + let kvStore; + kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) { + console.log("dataChange callback call data: " + JSON.stringify(data)); + }); + ``` + + +### on + +on(event: 'syncComplete', syncCallback: Callback8+ + +off(event:'dataChange', observer?: Callback<ChangeNotification>): void; + +Unsubscribes from data change events. This method uses a synchronouscallback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| event |'dataChange' | Yes|Type of the events to unsubscribe from.| +| observer |Callback<[ChangeNotification](#changenotificationa)> |No|Callback used to return the result.| + +- Example + + ``` + let kvStore; + kvStore.on('dataChange', function (data) { + console.log("syncComplete callback call data: " + data); + }); + kvStore.off('dataChange', function (data) { + console.log("syncComplete callback call data: " + data); + }); + ``` + + +### putBatch8+ + +putBatch(entries: Entry[], callback: AsyncCallback<void>): void; + +Inserts KV pairs in batches to this KV store. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| entries |[Entry](#entry)[] | Yes|KV pairs to insert in batches.| +| callback |Asyncallback<void> |Yes|Callback used to return the result.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + await kvStore.getEntries('batch_test_string_key', function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }); + }); + }catch(e) { + console.log('PutBatch e ' + e); + } + + ``` + + +### putBatch8+ + +putBatch(entries: Entry[]): Promise<void>; + +Inserts KV pairs in batches to this KV store. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| entries |[Entry](#entry)[] | Yes|KV pairs to insert in batches.| + +- Return value + +| Type| Description| +| ------ | ------- | +| Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + await kvStore.getEntries('batch_test_string_key').then((entrys) => { + console.log('getEntries success'); + console.log('PutBatch ' + JSON.stringify(entries)); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('PutBatch e ' + e); + } + ``` + + +### deleteBatch8+ + +deleteBatch(keys: string[], callback: AsyncCallback<void>): void; + +Deletes KV pairs in batches from this KV store. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| keys |string[] | Yes|KV pairs to delete in batches.| +| callback |AsyncCallback<void> | Yes|Callback used to return the result.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + let keys = []; + for (var i = 0; i < 5; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + keys.push(key + i); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + await kvStore.deleteBatch(keys, async function (err,data) { + console.log('deleteBatch success'); + }); + }); + }catch(e) { + console.log('DeleteBatch e ' + e); + } + ``` + + +### deleteBatch8+ ### + +deleteBatch(keys: string[]): Promise<void>; + +Deletes KV pairs in batches from this KV store. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| keys |string[] | Yes|KV pairs to delete in batches.| + +- Return value + +| Type| Description| +| ------ | ------- | +| Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + let keys = []; + for (var i = 0; i < 5; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + keys.push(key + i); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + await kvStore.deleteBatch(keys).then((err) => { + console.log('deleteBatch success'); + }).catch((err) => { + console.log('deleteBatch fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('DeleteBatch e ' + e); + } + ``` + + +### startTransaction8+ ### + +startTransaction(callback: AsyncCallback<void>): void; + +Starts the transaction in this KV store. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| callback |AsyncCallback<void> | Yes|Callback used to return the result.| + +- Example + + ``` + let kvStore; + function putBatchString(len, prefix) { + let entries = []; + for (var i = 0; i < len; i++) { + var entry = { + key : prefix + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + return entries; + } + try { + var count = 0; + kvStore.on('dataChange', 0, function (data) { + console.log('startTransaction 0' + data) + count++; + }); + kvStore.startTransaction(async function (err,data) { + console.log('startTransaction success'); + let entries = putBatchString(10, 'batch_test_string_key'); + console.log('entries: ' + JSON.stringify(entries)); + await kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + }); + }); + }catch(e) { + console.log('startTransaction e ' + e); + } + ``` + + +### startTransaction8+ ### + +startTransaction(): Promise<void>; + +Starts the transaction in this KV store. This method uses a promise to return the result. + +- Return value + +| Type| Description| +| ------ | ------- | +| Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + try { + var count = 0; + kvStore.on('dataChange', distributedData.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { + console.log('startTransaction ' + JSON.stringify(data)); + count++; + }); + kvStore.startTransaction().then(async (err) => { + console.log('startTransaction success'); + }).catch((err) => { + console.log('startTransaction fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('startTransaction e ' + e); + } + ``` + + +### commit8+ ### + +commit(callback: AsyncCallback<void>): void; + +Commits the transaction in this KV store. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| callback |AsyncCallback<void> | Yes|Callback used to return the result.| + +- Example + + ``` + let kvStore; + try { + kvStore.commit(function (err,data) { + if (err == undefined) { + console.log('commit success'); + } else { + console.log('commit fail'); + } + }); + }catch(e) { + console.log('Commit e ' + e); + } + ``` + + +### commit8+ ### + +commit(): Promise<void>; + +Commits the transaction in this KV store. This method uses a promise to return the result. + +- Return value + +| Type| Description| +| ------ | ------- | +| Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + try { + kvStore.commit().then(async (err) => { + console.log('commit success'); + }).catch((err) => { + console.log('commit fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('Commit e ' + e); + } + ``` + + +### rollback8+ ### + +rollback(callback: AsyncCallback<void>): void; + +Rolls back the transaction in this KV store. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| callback |AsyncCallback<void> | Yes|Callback used to return the result.| + +- Example + + ``` + let kvStore; + try { + kvStore.rollback(function (err,data) { + if (err == undefined) { + console.log('commit success'); + } else { + console.log('commit fail'); + } + }); + }catch(e) { + console.log('Rollback e ' + e); + } + ``` + + +### rollback8+ ### + +rollback(): Promise<void>; + +Rolls back the transaction in this KV store. This method uses a promise to return the result. + +- Return value + +| Type| Description| +| ------ | ------- | +| Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + try { + kvStore.rollback().then(async (err) => { + console.log('rollback success'); + }).catch((err) => { + console.log('rollback fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('Rollback e ' + e); + } + ``` + + +### enableSync8+ ### + +enableSync(enabled: boolean, callback: AsyncCallback<void>): void; + +Sets data synchronization, which can be enabled or disable. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| enabled |boolean | Yes|Whether to enable data synchronization. The value **true** means to enable data synchronization, and **false** means the opposite.| +| callback |AsyncCallback<void> | Yes|Callback used to return the result.| + +- Example + + ``` + let kvStore; + try { + kvStore.enableSync(true, function (err,data) { + if (err == undefined) { + console.log('enableSync success'); + } else { + console.log('enableSync fail'); + } + }); + }catch(e) { + console.log('EnableSync e ' + e); + } + ``` + + +### enableSync8+ ### + +enableSync(enabled: boolean): Promise<void>; + +Sets data synchronization, which can be enabled or disable. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| enabled |boolean | Yes|Whether to enable data synchronization. The value **true** means to enable data synchronization, and **false** means the opposite.| + +- Return value + +| Type| Description| +| ------ | ------- | +| Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + try { + kvStore.enableSync(true).then((err) => { + console.log('enableSync success'); + }).catch((err) => { + console.log('enableSync fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('EnableSync e ' + e); + } + ``` + + +### setSyncRange8+ ### + +setSyncRange(localLabels: string[], remoteSupportLabels: string[], callback: AsyncCallback<void>): void; + +Sets the data synchronization range. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| localLabels |string[] | Yes|Synchronization labels set for the local device.| +| remoteSupportLabels |string[] | Yes|Synchronization labels set for remote devices.| +| callback |AsyncCallback<void> | Yes|Callback used to return the result.| + +- Example + + ``` + let kvStore; + try { + const localLabels = ['A', 'B']; + const remoteSupportLabels = ['C', 'D']; + kvStore.setSyncRange(localLabels, remoteSupportLabels, function (err,data) { + console.log('SetSyncRange put success'); + }); + }catch(e) { + console.log('SetSyncRange e ' + e); + } + ``` + + +### setSyncRange8+ ### + +setSyncRange(localLabels: string[], remoteSupportLabels: string[]): Promise<void>; + +Sets the data synchronization range. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| localLabels |string[] | Yes|Synchronization labels set for the local device.| +| remoteSupportLabels |string[] | Yes|Synchronization labels set for remote devices.| + + +- Return value + +| Type| Description| +| ------ | ------- | +| Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + try { + const localLabels = ['A', 'B']; + const remoteSupportLabels = ['C', 'D']; + kvStore.setSyncRange(localLabels, remoteSupportLabels).then((err) => { + console.log('setSyncRange success'); + }).catch((err) => { + console.log('delete fail ' + err); + }); + }catch(e) { + console.log('SetSyncRange e ' + e); + } + ``` + + +## SubscribeType + +Defines the subscription type. + +| Name| Default Value| Description| +| ----- | ------ | ----------------------- | +| SUBSCRIBE_TYPE_LOCAL |0 |Local data changes.| +| SUBSCRIBE_TYPE_REMOTE |1 |Remote data changes.| +| SUBSCRIBE_TYPE_ALL |2 |Local and remote data changes.| + +## ChangeNotification + +Defines the content of data change notifications, including inserted data, updated data, deleted data, and device ID. + +| Name| Type|Readable|Writable| Description| +| ----- | ------- | -----| ------|------------------------ | +| insertEntries | [Entry](#entry)[] | Yes| Yes|Data inserted.| +| updateEntries | [Entry](#entry)[] | Yes| Yes|Data updated.| +| deleteEntries | [Entry](#entry)[] | Yes| Yes|Data deleted.| +| deviceId | string | Yes| Yes|UUID of the device.| + +## Entry + +Defines the KV pairs stored in the KV store. + +| Name| Type|Readable|Writable| Description| +| ----- | ------- | -----| ------|------------------------ | +| key | string | Yes| Yes|Key of the KV pair stored in the KV store.| +| value | [Value](#value) | Yes| Yes|Value of the KV pair stored in the KV store.| + + +## Value + +Defines the value in a KV pair. + +| Name| Type|Readable|Writable| Description| +| ----- | ------- | -----| ------|------------------------ | +| type | [ValueType](#value) | Yes| Yes|Type of the value.| +| value | Uint8Array / string / number / boolean| Yes| Yes|Specific value.| + +## ValueType + +Enumerates the types of values in KV pairs. + +These value types can be used only by internal applications. + +| Name| Default Value| Description| +| ----- | ------ | ----------------------- | +| STRING |0 |String.| +| INTEGER |1 |Integer.| +| FLOAT |2 |Float (single-precision floating point).| +| BYTE_ARRAY |3 |Byte array.| +| BOOLEAN |4 |Boolean.| +| DOUBLE |5 |Double (double-precision floating point).| + +## SingleKVStore + +Provides methods to query and synchronize data in a single KV store. This class inherits from **KVStore**. Before calling any method in **SingleKVStore**, you must use **getKVStore** to obtain a **SingleKVStore** object. + +### get + +get(key: string, callback: AsyncCallback<Uint8Array | string | boolean | number>): void + +Obtains the value of a specified key. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| key |string | Yes|Key of the value to obtain. It cannot be empty, and the length cannot exceed [MAX\_KEY\_LENGTH](#constants).| +| callback |AsyncCallback<Uint8Array / string / boolean / number>) | Yes|Callback used to return the value obtained.| + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, function (err,data) { + if (err != undefined) { + console.log("put err: " + JSON.stringify(err)); + return; + } + console.log("put success"); + kvStore.get(KEY_TEST_STRING_ELEMENT, function (err,data) { + console.log("get success data: " + data); + }); + }); + }catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + + +### get + +get(key: string): Promise<Uint8Array | string | boolean | number> + +Obtains the value of a specified key. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| key |string | Yes|Key of the value to obtain. It cannot be empty, and the length cannot exceed [MAX\_KEY\_LENGTH](#constants).| + + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<Uint8Array / string / boolean / number> |Promise used to return the value obtained.| + + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-test-string'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((data) => { + console.log("put success: " + JSON.stringify(data)); + kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { + console.log("get success data: " + data); + }).catch((err) => { + console.log("get err: " + JSON.stringify(err)); + }); + }).catch((err) => { + console.log("put err: " + JSON.stringify(err)); + }); + }catch (e) { + console.log("An unexpected error occurred. Error:" + e); + } + ``` + +### getEntries8+ ### + +getEntries(keyPrefix: string, callback: AsyncCallback<Entry[]>): void; + +Obtains the KV pairs that match the specified key prefix. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| keyPrefix |string | Yes|Key prefix to match.| +| callback |AsyncCallback<Entry[]> | Yes|Callback used to return the KV pairs obtained.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_number_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.INTEGER, + value : 222 + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + await kvStore.getEntries('batch_test_number_key', function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }); + }); + }catch(e) { + console.log('PutBatch e ' + e); + } + ``` + + +### getEntries8+ ### + +getEntries(keyPrefix: string): Promise<Entry[]>; + +Obtains the KV pairs that match the specified key prefix. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| keyPrefix |string | Yes|Key prefix to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<[Entry](#entry)[]> |Promise used to return the KV pairs obtained.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + console.log('entries: ' + entries); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + await kvStore.getEntries('batch_test_string_key').then((entrys) => { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entrys[0].value: ' + JSON.stringify(entrys[0].value)); + console.log('entrys[0].value.value: ' + entrys[0].value.value); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('PutBatch e ' + e); + } + ``` + + +### getEntries8+ ### + +getEntries(query: Query, callback: AsyncCallback<Entry[]>): void; + +Obtains the KV pairs that match the specified **Query** object. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| +| callback |AsyncCallback<Entry[]> | Yes|Callback used to return the KV pairs obtained.| + +- Example + + ``` + let kvStore; + try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getEntries(query, function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }); + }); + console.log('GetEntries success'); + }catch(e) { + console.log('GetEntries e ' + e); + } + ``` + + +### getEntries8+ ### + +getEntries(query: Query): Promise<Entry[]>; + +Obtains the KV pairs that match the specified **Query** object. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<[Entry](#entry)[]> |Promise used to return the KV pairs obtained.| + +- Example + + ``` + try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getEntries(query).then((entrys) => { + console.log('getEntries success'); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('GetEntries putBatch fail ' + JSON.stringify(err)) + }); + console.log('GetEntries success'); + }catch(e) { + console.log('GetEntries e ' + e); + } + ``` + + +### getResultSet8+ ### + +getResultSet(keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>): void; + +Obtains the result set with the specified key prefix from this single KV store. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| keyPrefix |string | Yes|Key prefix to match.| +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultsetsup8sup)> | Yes|Callback used to return the result set obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('GetResultSet putBatch success'); + await kvStore.getResultSet('batch_test_string_key', async function (err, result) { + console.log('GetResultSet getResultSet success'); + resultSet = result; + kvStore.closeResultSet(resultSet, function (err, data) { + console.log('GetResultSet closeResultSet success'); + }) + }); + }); + }catch(e) { + console.log('GetResultSet e ' + e); + } + ``` + + +### getResultSet8+ ### + +getResultSet(keyPrefix: string): Promise<KvStoreResultSet>; + +Obtains the result set with the specified key prefix from this single KV store. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| keyPrefix |string | Yes|Key prefix to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<[KvStoreResultSet](#kvstoreresultsetsup8sup)> |Promise used to return the result set obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('PutBatch putBatch fail ' + JSON.stringify(err)); + }); + kvStore.getResultSet('batch_test_string_key').then((result) => { + console.log('GetResult getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('GetResult closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('GetResult e ' + e); + } + ``` + + +### getResultSet8+ ### + +getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): void; + +Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |Query | Yes|**Query** object to match.| +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultsetsup8sup)> | Yes|Callback used to return the **KvStoreResultSet** object obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getResultSet(query, async function (err, result) { + console.log('getResultSet success'); + resultSet = result; + }); + }); + } catch(e) { + console.log('GetResultSet e ' + e); + } + ``` + + +### getResultSet8+ ### + +getResultSet(query: Query): Promise<KvStoreResultSet>; + +Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<[KvStoreResultSet](#kvstoreresultsetsup8sup)> |Promise used to return the **KvStoreResultSet** object obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSet(query).then((result) => { + console.log(' getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('GetResultSet e ' + e); + } + ``` + +### closeResultSet8+ ### + +closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>): void; + +Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| resultSet |[KvStoreResultSet](#kvstoreresultsetsup8sup) | Yes|**KvStoreResultSet** object to close.| +| callback |AsyncCallback<void> | Yes|Callback used to return the execution result.| + +- Example + + ``` + let kvStore; + try { + let resultSet = null; + kvStore.closeResultSet(resultSet, function (err, data) { + if (err == undefined) { + console.log('closeResultSet success'); + } else { + console.log('closeResultSet fail'); + } + }); + }catch(e) { + console.log('CloseResultSet e ' + e); + } + ``` + + +### closeResultSet8+ ### + +closeResultSet(resultSet: KvStoreResultSet): Promise<void>; + +Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| resultSet |[KvStoreResultSet](#kvstoreresultsetsup8sup) | Yes|**KvStoreResultSet** object to close.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + try { + let resultSet = null; + kvStore.closeResultSet(resultSet).then(() => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('CloseResultSet e ' + e); + } + ``` + + +### getResultSize8+ ### + +getResultSize(query: Query, callback: AsyncCallback<number>): void; + +Obtains the number of results matching the specified **Query** object. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| +| callback |AsyncCallback<number> | Yes|Callback used to return the number of results obtained.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getResultSize(query, async function (err, resultSize) { + console.log('getResultSet success'); + }); + }); + } catch(e) { + console.log('GetResultSize e ' + e); + } + ``` + + +### getResultSize8+ ### + +getResultSize(query: Query): Promise<number>; + +Obtains the number of results matching the specified **Query** object. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<number> |Promise used to return the number of results obtained.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSize(query).then((resultSize) => { + console.log('getResultSet success'); + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('GetResultSize e ' + e); + } + ``` + + +### removeDeviceData8+ ### + +removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void; + +Deletes data of a device. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| callback |AsyncCallback<void> | Yes|Callback used to return the result.| + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; + const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { + console.log('put success'); + const deviceid = 'no_exist_device_id'; + await kvStore.removeDeviceData(deviceid, async function (err,data) { + if (err == undefined) { + console.log('removeDeviceData success'); + } else { + console.log('removeDeviceData fail'); + await kvStore.get(KEY_TEST_STRING_ELEMENT, async function (err,data) { + console.log('RemoveDeviceData get success'); + }); + } + }); + }); + }catch(e) { + console.log('RemoveDeviceData e ' + e); + } + ``` + + +### removeDeviceData8+ ### + +removeDeviceData(deviceId: string): Promise<void>; + +Deletes data of a device. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; + const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { + console.log('removeDeviceData put success'); + }).catch((err) => { + console.log('put fail ' + JSON.stringify(err)); + }); + const deviceid = 'no_exist_device_id'; + kvStore.removeDeviceData(deviceid).then((err) => { + console.log('removeDeviceData success'); + }).catch((err) => { + console.log('removeDeviceData fail ' + JSON.stringify(err)); + }); + kvStore.get(KEY_TEST_STRING_ELEMENT).then((data) => { + console.log('get success data:' + data); + }).catch((err) => { + console.log('RemoveDeviceData get fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('RemoveDeviceData e ' + e); + } + ``` + + +### on8+ ### + +on(event: 'syncComplete', syncCallback: Callback { + console.log('syncComplete put success'); + }).catch((error) => { + console.log('syncComplete put fail ' + error); + }); + }catch(e) { + console.log('syncComplete put e ' + e); + } + ``` + + +### off8+ ### + +off(event: 'syncComplete', syncCallback?: Callback8+ ### + +setSyncParam(defaultAllowedDelayMs: number, callback: AsyncCallback<void>): void; + +Sets the default delay of database synchronization. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| defaultAllowedDelayMs |number | Yes|Default delay allowed for database synchronization, in ms.| +| callback |AsyncCallback<void> | Yes|Callback used to return the result.| + + +- Example + + ``` + let kvStore; + try { + const defaultAllowedDelayMs = 500; + kvStore.setSyncParam(defaultAllowedDelayMs, function (err,data) { + console.log('SetSyncParam put success'); + }); + }catch(e) { + console.log('testSingleKvStoreSetSyncParam e ' + e); + } + ``` + + +### setSyncParam8+ ### + +setSyncParam(defaultAllowedDelayMs: number): Promise<void>; + +Sets the default delay of database synchronization. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| defaultAllowedDelayMs |number | Yes|Default delay allowed for database synchronization, in ms.| + + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + try { + const defaultAllowedDelayMs = 500; + kvStore.setSyncParam(defaultAllowedDelayMs).then((err) => { + console.log('SetSyncParam put success'); + }).catch((err) => { + console.log('SetSyncParam put fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('SetSyncParam e ' + e); + } + ``` + + +### getSecurityLevel8+ ### + +getSecurityLevel(callback: AsyncCallback<SecurityLevel>): void; + +Obtains the security level of this KV store. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| callback |AsyncCallback<[SecurityLevel](#securitylevel)> | Yes|Callback used to return the security level obtained.| + +- Example + + ``` + let kvStore; + try { + kvStore.getSecurityLevel(function (err,data) { + console.log('getSecurityLevel success'); + }); + }catch(e) { + console.log('GetSecurityLeve e ' + e); + } + ``` + + +### getSecurityLevel8+ ### + +getSecurityLevel(): Promise<SecurityLevel>; + +Obtains the security level of this KV store. This method uses a promise to return the result. + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<[SecurityLevel](#securitylevel)> |Promise used to return the security level obtained.| + + +- Example + + ``` + let kvStore; + try { + kvStore.getSecurityLevel().then((data) => { + console.log(' getSecurityLevel success'); + }).catch((err) => { + console.log('getSecurityLevel fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('GetSecurityLeve e ' + e); + } + ``` + + +## DeviceKVStore8+ ## + +Provides methods to manage distributed data by device in the distributed system. This class inherits from **KvStore** and provides data query and synchronization methods. Before calling any method in **DeviceKVStore**, you must use **getKVStore** to obtain a **DeviceKVStore** object. + +### get8+ ### + +get(deviceId: string, key: string, callback: AsyncCallback<boolean|string|number|Uint8Array>): void; + +Obtains the string value that matches the specified key for a device. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| key |string | Yes|Key to match.| +| callback |AsyncCallback<boolean/string/number/Uint8Array> | Yes|Callback used to return the value obtained.| + + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; + const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; + try{ + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { + console.log('put success'); + kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, function (err,data) { + console.log('get success'); + }); + }) + }catch(e) { + console.log('get e' + e); + } + ``` + + +### get8+ ### + +get(deviceId: string, key: string): Promise<boolean|string|number|Uint8Array>; + +Obtains the string value that matches the specified key for a device. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| key |string | Yes|Key to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<boolean/string/number/Uint8Array> |Promise used to return the value obtained.| + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string_2'; + const VALUE_TEST_STRING_ELEMENT = 'value-string-002'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then(async (data) => { + console.log(' put success'); + kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { + console.log('get success'); + }).catch((err) => { + console.log('get fail ' + JSON.stringify(err)); + }); + }).catch((error) => { + console.log('put error' + error); + }); + } catch (e) { + console.log('Get e ' + e); + } + ``` + + +### getEntries8+ ### + +getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback<Entry[]>): void; + +Obtains the KV pairs that match the specified key prefix for a device. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| keyPrefix |string | Yes|Key prefix to match.| +| callback |AsyncCallback<[Entry](#entry)[]> | Yes|Callback used to return the KV pairs obtained.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + console.log('entries: ' + entries); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + await kvStore.getEntries('localDeviceId', 'batch_test_string_key', function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }); + }); + }catch(e) { + console.log('PutBatch e ' + e); + } + ``` + + +### getEntries8+ ### + +getEntries(deviceId: string, keyPrefix: string): Promise<Entry[]>; + +Obtains the KV pairs that match the specified key prefix for a device. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| keyPrefix |string | Yes|Key prefix to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<[Entry](#entry)[]> |Promise used to return the KV pairs obtained.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + console.log('entries: ' + entries); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + await kvStore.getEntries('localDeviceId', 'batch_test_string_key').then((entrys) => { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + console.log('entrys[0].value: ' + JSON.stringify(entrys[0].value)); + console.log('entrys[0].value.value: ' + entrys[0].value.value); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('PutBatch e ' + e); + } + ``` + + +### getEntries8+ ### + +getEntries(query: Query, callback: AsyncCallback<Entry[]>): void; + +Obtains the KV pairs matching the specified **Query** object. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| +| callback |AsyncCallback<[Entry](#entry)[]> | Yes|Callback used to return the KV pairs obtained.| + +- Example + + ``` + let kvStore; + try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + expect(err == undefined).assertTrue(); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + await kvStore.getEntries(query, function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }); + }); + console.log('GetEntries success'); + }catch(e) { + console.log('GetEntries e ' + e); + } + ``` + + +### getEntries8+ ### + +getEntries(query: Query): Promise<Entry[]>; + +Obtains the KV pairs matching the specified **Query** object. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<[Entry](#entry)[]> |Promise used to return the KV pairs obtained.| + +- Example + + ``` + let kvStore; + try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getEntries(query).then((entrys) => { + console.log('getEntries success'); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('GetEntries putBatch fail ' + JSON.stringify(err)) + }); + console.log('GetEntries success'); + }catch(e) { + console.log('GetEntries e ' + e); + } + ``` + + +### getEntries8+ ### + +getEntries(deviceId: string, query: Query, callback: AsyncCallback<Entry[]>): void; + +Obtains the KV pairs matching the specified **Query** object for a device. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| +| callback |AsyncCallback<[Entry](#entry)[]> | Yes|Callback used to return the KV pairs obtained.| + +- Example + + ``` + let kvStore; + try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries, async function (err,data) { + console.log('putBatch success'); + expect(err == undefined).assertTrue(); + var query = new distributedData.Query(); + query.deviceId('localDeviceId'); + query.prefixKey("batch_test"); + await kvStore.getEntries('localDeviceId', query, function (err,entrys) { + console.log('getEntries success'); + console.log('entrys.length: ' + entrys.length); + console.log('entrys[0]: ' + JSON.stringify(entrys[0])); + }) + }); + console.log('GetEntries success'); + }catch(e) { + console.log('GetEntries e ' + e); + } + ``` + + +### getEntries8+ ### + +getEntries(deviceId: string, query: Query): Promise<Entry[]>; + +Obtains the KV pairs matching the specified **Query** object for a device. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<[Entry](#entry)[]> |Promise used to return the KV pairs obtained.| + +- Example + + ``` + let kvStore; + try { + var arr = new Uint8Array([21,31]); + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_bool_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.BYTE_ARRAY, + value : arr + } + } + entries.push(entry); + } + console.log('entries: ' + JSON.stringify(entries)); + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + var query = new distributedData.Query(); + query.deviceId('localDeviceId'); + query.prefixKey("batch_test"); + await kvStore.getEntries('localDeviceId', query).then((entrys) => { + console.log('getEntries success'); + }).catch((err) => { + console.log('getEntries fail ' + JSON.stringify(err)); + }); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + console.log('GetEntries success'); + }catch(e) { + console.log('GetEntries e ' + e); + } + ``` + + +### getResultSet8+ ### + +getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback<KvStoreResultSet>): void; + +Obtains the **KvStoreResultSet** object that matches the specified key prefix for a device. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| keyPrefix |string | Yes|Key prefix to match.| +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultsetsup8sup)[]> | Yes|Callback used to return the **KvStoreResultSet** object obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('localDeviceId', 'batch_test_string_key', async function (err, result) { + console.log('getResultSet success'); + resultSet = result; + await kvStore.closeResultSet(resultSet, function (err, data) { + console.log('closeResultSet success'); + }) + }); + }catch(e) { + console.log('GetResultSet e ' + e); + } + ``` + + +### getResultSet8+ ### + +getResultSet(deviceId: string, keyPrefix: string): Promise<KvStoreResultSet>; + +Obtains the **KvStoreResultSet** object that matches the specified key prefix for a device. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| keyPrefix |string | Yes|Key prefix to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<[KvStoreResultSet](#kvstoreresultsetsup8sup)[]> |Promise used to return the **KvStoreResultSet** object obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + kvStore.getResultSet('localDeviceId', 'batch_test_string_key').then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('GetResultSet e ' + e); + } + ``` + + +### getResultSet8+ ### + +getResultSet(query: Query, callback: AsyncCallback<KvStoreResultSet>): void; + +Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultsetsup8sup)[]> | Yes|Callback used to return the **KvStoreResultSet** object obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + await kvStore.getResultSet(query, async function (err, result) { + console.log('getResultSet success'); + resultSet = result; + await kvStore.closeResultSet(resultSet, function (err, data) { + console.log('closeResultSet success'); + }) + }); + }); + } catch(e) { + console.log('GetResultSet e ' + e); + } + ``` + + +### getResultSet8+ ### + +getResultSet(query: Query): Promise<KvStoreResultSet>; + +Obtains the **KvStoreResultSet** object that matches the specified **Query** object. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<[KvStoreResultSet](#kvstoreresultsetsup8sup)[]> |Promise used to return the **KvStoreResultSet** object obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + err); + }); + const query = new distributedData.Query(); + query.deviceId('localDeviceId'); + query.prefixKey("batch_test"); + console.log("GetResultSet " + query.getSqlLike()); + kvStore.getResultSet(query).then((result) => { + console.log('getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('GetResultSet e ' + e); + } + ``` + + +### getResultSet8+ ### + +getResultSet(deviceId: string, query: Query, callback: AsyncCallback<KvStoreResultSet>): void; + +Obtains the **KvStoreResultSet** object that matches the specified **Query** object for a device. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| +| callback |AsyncCallback<[KvStoreResultSet](#kvstoreresultsetsup8sup)[]> | Yes|Callback used to return the **KvStoreResultSet** object obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getResultSet('localDeviceId', query, async function (err, result) { + console.log('getResultSet success'); + resultSet = result; + await kvStore.closeResultSet(resultSet, function (err, data) { + console.log('closeResultSet success'); + }) + }); + }); + } catch(e) { + console.log('GetResultSet e ' + e); + } + ``` + + +### getResultSet8+ ### + +getResultSet(deviceId: string, query: Query): Promise<KvStoreResultSet>; + +Obtains the **KvStoreResultSet** object that matches the specified **Query** object for a device. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<[KvStoreResultSet](#kvstoreresultsetsup8sup)[]> |Promise used to return the **KvStoreResultSet** object obtained.| + +- Example + + ``` + let kvStore; + try { + let resultSet; + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('GetResultSet putBatch success'); + }).catch((err) => { + console.log('PutBatch putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSet('localDeviceId', query).then((result) => { + console.log('GetResultSet getResultSet success'); + resultSet = result; + }).catch((err) => { + console.log('GetResultSet getResultSet fail ' + JSON.stringify(err)); + }); + query.deviceId('localDeviceId'); + console.log("GetResultSet " + query.getSqlLike()); + kvStore.closeResultSet(resultSet).then((err) => { + console.log('GetResultSet closeResultSet success'); + }).catch((err) => { + console.log('GetResultSet closeResultSet fail ' + JSON.stringify(err)); + }); + + }catch(e) { + console.log('GetResultSet e ' + e); + } + ``` + + +### closeResultSet8+ ### + +closeResultSet(resultSet: KvStoreResultSet, callback: AsyncCallback<void>): void; + +Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| resultSet |[KvStoreResultSet](#getresultsetsup8sup) | Yes|**KvStoreResultSet** object to close.| +| callback |AsyncCallback<void> | Yes|Callback used to return the result.| + +- Example + + ``` + let kvStore; + try { + console.log('CloseResultSet success'); + let resultSet = null; + kvStore.closeResultSet(resultSet, function (err, data) { + if (err == undefined) { + console.log('closeResultSet success'); + } else { + console.log('closeResultSet fail'); + } + }); + }catch(e) { + console.log('CloseResultSet e ' + e); + } + ``` + + +### closeResultSet8+ ### + +closeResultSet(resultSet: KvStoreResultSet): Promise<void>; + +Closes the **KvStoreResultSet** object obtained by **getResultSet**. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| resultSet |[KvStoreResultSet](#getresultsetsup8sup) | Yes|**KvStoreResultSet** object to close.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + try { + console.log('CloseResultSet success'); + let resultSet = null; + kvStore.closeResultSet(resultSet).then(() => { + console.log('closeResultSet success'); + }).catch((err) => { + console.log('closeResultSet fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('CloseResultSet e ' + e); + } + ``` + + +### getResultSize8+ ### + +getResultSize(query: Query, callback: AsyncCallback<number>): void; + +Obtains the number of results that matches the specified **Query** object. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| +| callback |AsyncCallback<number> | Yes|Callback used to return the number of results obtained.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + await kvStore.getResultSize(query, async function (err, resultSize) { + console.log('getResultSet success'); + }); + }); + } catch(e) { + console.log('GetResultSize e ' + e); + } + ``` + + +### getResultSize8+ ### + +getResultSize(query: Query): Promise<number>; + +Obtains the number of results that matches the specified **Query** object. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<number> |Promise used to return the number of results obtained.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + query.deviceId('localDeviceId'); + kvStore.getResultSize(query).then((resultSize) => { + console.log('getResultSet success'); + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('GetResultSize e ' + e); + } + ``` + + +### getResultSize8+ ### + +getResultSize(deviceId: string, query: Query, callback: AsyncCallback<number>): void; + +Obtains the number of results that matches the specified **Query** object for a device. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| +| callback |AsyncCallback<number> | Yes|Callback used to return the number of results obtained.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries, async function (err, data) { + console.log('putBatch success'); + const query = new distributedData.Query(); + query.prefixKey("batch_test"); + await kvStore.getResultSize('localDeviceId', query, async function (err, resultSize) { + console.log('getResultSet success'); + }); + }); + } catch(e) { + console.log('GetResultSize e ' + e); + } + ``` + + +### getResultSize8+ ### + +getResultSize(deviceId: string, query: Query): Promise<number>; + +Obtains the number of results that matches the specified **Query** object for a device. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| query |[Query](#querysup8sup) | Yes|**Query** object to match.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<number> |Promise used to return the number of results obtained.| + +- Example + + ``` + let kvStore; + try { + let entries = []; + for (var i = 0; i < 10; i++) { + var key = 'batch_test_string_key'; + var entry = { + key : key + i, + value : { + type : distributedData.ValueType.STRING, + value : 'batch_test_string_value' + } + } + entries.push(entry); + } + kvStore.putBatch(entries).then(async (err) => { + console.log('putBatch success'); + }).catch((err) => { + console.log('putBatch fail ' + JSON.stringify(err)); + }); + var query = new distributedData.Query(); + query.prefixKey("batch_test"); + kvStore.getResultSize('localDeviceId', query).then((resultSize) => { + console.log('getResultSet success'); + }).catch((err) => { + console.log('getResultSet fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('GetResultSize e ' + e); + } + ``` + + +### removeDeviceData8+ ### + +removeDeviceData(deviceId: string, callback: AsyncCallback<void>): void; + +Removes data of a device from this KV store. This method uses an asynchronous callback to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| +| callback |AsyncCallback<void> | Yes|Callback used to return the result.| + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, async function (err,data) { + console.log('RemoveDeviceData put success'); + const deviceid = 'no_exist_device_id'; + await kvStore.removeDeviceData(deviceid, async function (err,data) { + if (err == undefined) { + console.log('removeDeviceData success'); + } else { + console.log('removeDeviceData fail'); + await kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT, async function (err,data) { + console.log('RemoveDeviceData get success'); + }); + } + }); + }); + }catch(e) { + console.log('RemoveDeviceData e ' + e); + } + ``` + + +### removeDeviceData8+ ### + +removeDeviceData(deviceId: string): Promise<void>; + +Removes data of a device from this KV store. This method uses a promise to return the result. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceId |string | Yes|ID of the target device.| + +- Return value + +| Type| Description| +| ------ | ------- | +|Promise<void> |Promise used to return the result.| + +- Example + + ``` + let kvStore; + const KEY_TEST_STRING_ELEMENT = 'key_test_string'; + const VALUE_TEST_STRING_ELEMENT = 'value-string-001'; + try { + kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT).then((err) => { + console.log('RemoveDeviceData put success'); + }).catch((err) => { + console.log('RemoveDeviceData put fail ' + JSON.stringify(err)); + }); + const deviceid = 'no_exist_device_id'; + kvStore.removeDeviceData(deviceid).then((err) => { + console.log('removeDeviceData success'); + }).catch((err) => { + console.log('removeDeviceData fail ' + JSON.stringify(err)); + }); + kvStore.get('localDeviceId', KEY_TEST_STRING_ELEMENT).then((data) => { + console.log('RemoveDeviceData get success data:' + data); + }).catch((err) => { + console.log('RemoveDeviceData get fail ' + JSON.stringify(err)); + }); + }catch(e) { + console.log('RemoveDeviceData e ' + e); + } + ``` + + +### sync8+ ### + +sync(deviceIdList: string[], mode: SyncMode, allowedDelayMs?: number): void; + +Manually triggers KV store synchronization synchronously. + +- Parameters + +| Name| Type| Mandatory| Description| +| ----- | ------ | ---- | ----------------------- | +| deviceIdList |string[] | Yes|IDs of the devices to be synchronized.| +| mode |[SyncMode](#syncmode) | Yes|Data synchronization mode, which can be **PUSH**, **PULL**, or **PUSH_PULL**.| +| allowedDelayMs |number | No|Allowed synchronization delay time, in ms.| + + +- Example + + ``` + let kvStore; + const KEY_TEST_SYNC_ELEMENT = 'key_test_sync'; + const VALUE_TEST_SYNC_ELEMENT = 'value-string-001'; + try { + kvStore.on('syncComplete', function (data) { + console.log('Sync dataChange'); + }); + kvStore.put(KEY_TEST_SYNC_ELEMENT + 'testSync101', VALUE_TEST_SYNC_ELEMENT, function (err,data) { + console.log('Sync put success'); + const devices = ['deviceList']; + const mode = distributedData.SyncMode.PULL_ONLY; + kvStore.sync(devices, mode); + }); + }catch(e) { + console.log('Sync e' + e); + } + ``` + +### on8+ ### + +on(event: 'syncComplete', syncCallback: Callback { + console.log('syncComplete put success'); + }).catch((error) => { + console.log('syncComplete put fail ' + error); + }); + }catch(e) { + console.log('syncComplete put e ' + e); + } + ``` + + +### off8+ ### + +off(event: 'syncComplete', syncCallback?: CallbackSystem capabilities: SystemCapability.Ability.AbilityRuntime.Core| diff --git a/en/application-dev/reference/apis/js-apis-featureAbility.md b/en/application-dev/reference/apis/js-apis-featureAbility.md index 8ec9fcf1b2a61bb2f38b5381b924f5b13c1e0f9a..505e8cee17663326854d0e2c903a3bc682e9a2b1 100644 --- a/en/application-dev/reference/apis/js-apis-featureAbility.md +++ b/en/application-dev/reference/apis/js-apis-featureAbility.md @@ -16,17 +16,22 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\) Starts an ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | --------------------- | ---- | ------------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```javascript import featureAbility from '@ohos.ability.featureAbility' +import wantConstant from '@ohos.ability.wantConstant' featureAbility.startAbility( { want: @@ -34,15 +39,14 @@ featureAbility.startAbility( action: "", entities: [""], type: "", - flags: FLAG_AUTH_READ_URI_PERMISSION, + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", bundleName: "com.example.startability", abilityName: "com.example.startability.MainAbility", uri: "" }, }, - ); -) +); ``` @@ -53,16 +57,21 @@ startAbility(parameter: StartAbilityParameter): Promise\ Starts an ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ----------------------------------------------- | ---- | --------------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| **Example** ```javascript import featureAbility from '@ohos.ability.featureAbility' +import wantConstant from '@ohos.ability.wantConstant' featureAbility.startAbility( { want: @@ -70,14 +79,14 @@ featureAbility.startAbility( action: "action.system.home", entities: ["entity.system.home"], type: "MIMETYPE", - flags: FLAG_AUTH_READ_URI_PERMISSION, - deviceId: deviceId, + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, + deviceId: "", bundleName: "com.example.startability", abilityName: "com.example.startability.MainAbility", uri: "" }, } - ).then((void) => { + ).then((data) => { console.info("==========================>startAbility=======================>"); }); ``` @@ -88,15 +97,19 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper Obtains a **dataAbilityHelper** object. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type | Mandatory| Description | | ---- | ------ | ---- | ------------------------ | -| uri | string | Yes| URI of the file to open.| +| uri | string | Yes | URI of the file to open.| **Return value** -| Type| Description| +| Type | Description | | ----------------- | -------------------------------------------- | | DataAbilityHelper | A utility class used to help other abilities access the Data ability.| @@ -115,17 +128,22 @@ startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\ Starts an ability. This method uses a callback to return the execution result when the ability is destroyed. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ----------------------------------------------- | ---- | --------------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| -| callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes| Callback used to return the result.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| +| callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes | Callback used to return the result. | **Example** ```javascript import featureAbility from '@ohos.ability.featureability'; +import wantConstant from '@ohos.ability.wantConstant' featureAbility.startAbilityForResult( { want: @@ -133,7 +151,7 @@ featureAbility.startAbilityForResult( action: "action.system.home", entities: ["entity.system.home"], type: "MIMETYPE", - flags: FLAG_AUTH_READ_URI_PERMISSION, + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", bundleName: "com.example.featureabilitytest", abilityName: "com.example.featureabilitytest.MainAbility", @@ -149,14 +167,18 @@ startAbilityForResult(parameter: StartAbilityParameter): Promise\ Starts an ability. This method uses a promise to return the execution result when the ability is destroyed. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ----------------------------------------------- | ---- | ------------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| **Return value** -| Type| Description| +| Type | Description | | ----------------------------------------- | -------------- | | Promise\<[AbilityResult](#abilityresult)> | Promised returned with the execution result.| @@ -164,6 +186,7 @@ Starts an ability. This method uses a promise to return the execution result whe ```javascript import featureAbility from '@ohos.ability.featureability'; +import wantConstant from '@ohos.ability.wantConstant' featureAbility.startAbilityForResult( { want: @@ -171,7 +194,7 @@ featureAbility.startAbilityForResult( action: "action.system.home", entities: ["entity.system.home"], type: "MIMETYPE", - flags: FLAG_AUTH_READ_URI_PERMISSION, + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", bundleName: "com.example.featureabilitytest", abilityName: "com.example.featureabilitytest.MainAbility", @@ -190,7 +213,7 @@ featureAbility.startAbilityForResult( }, requestCode: 2, }, -).then((void) => { +).then((data) => { console.info("==========================>startAbilityForResult=======================>"); }); ``` @@ -201,17 +224,22 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\ Destroys this Page ability, with the result code and data sent to the caller. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ------------- | ---- | ------------------- | -| parameter | [AbilityResult](#abilityresult) | Yes| Ability to start.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```javascript import featureAbility from '@ohos.ability.featureAbility' +import wantConstant from '@ohos.ability.wantConstant' featureAbility.terminateSelfWithResult( { resultCode: 1, @@ -220,7 +248,7 @@ featureAbility.terminateSelfWithResult( action: "action.system.home", entities: ["entity.system.home"], type: "MIMETYPE", - flags: FLAG_AUTH_READ_URI_PERMISSION, + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", bundleName: "com.example.featureabilitytest", abilityName: "com.example.featureabilitytest.MainAbility", @@ -246,14 +274,18 @@ terminateSelfWithResult(parameter: AbilityResult): Promise\ Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ------------------------------- | ---- | ------------------- | -| parameter | [AbilityResult](#abilityresult) | Yes| Ability to start.| +| parameter | [AbilityResult](#abilityresult) | Yes | Ability to start.| **Return value** -| Type| Description| +| Type | Description | | -------------- | ----------------------- | | Promise\ | Promise used to return the result.| @@ -261,6 +293,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ```javascript import featureAbility from '@ohos.ability.featureability'; +import wantConstant from '@ohos.ability.wantConstant' featureAbility.terminateSelfWithResult( { resultCode: 1, @@ -269,7 +302,7 @@ featureAbility.terminateSelfWithResult( action: "action.system.home", entities: ["entity.system.home"], type: "MIMETYPE", - flags: FLAG_AUTH_READ_URI_PERMISSION, + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", bundleName: "com.example.featureabilitytest", abilityName: "com.example.featureabilitytest.MainAbility", @@ -286,7 +319,7 @@ featureAbility.terminateSelfWithResult( } }, } -).then((void) => { +).then((data) => { console.info("==========================>terminateSelfWithResult=======================>"); }); ``` @@ -299,11 +332,15 @@ hasWindowFocus(callback: AsyncCallback\): void Checks whether the main window of this ability has the focus. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ----------------------- | ---- | ------------------------------------------------------------ | -| callback | AsyncCallback\ | Yes| Callback used to return the result.
Returns **true** if the main window of this ability has the focus; returns **false** otherwise.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.
Returns **true** if the main window of this ability has the focus; returns **false** otherwise.| **Example** @@ -320,9 +357,13 @@ hasWindowFocus(): Promise\ Checks whether the main window of this ability has the focus. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Return value** -| Type| Description| +| Type | Description | | ----------------- | ---------------------------------------------------------- | | Promise\ | Returns **true** if the main window of this ability has the focus; returns **false** otherwise.| @@ -330,7 +371,7 @@ Checks whether the main window of this ability has the focus. This method uses a ```javascript import featureAbility from '@ohos.ability.featureability'; -featureAbility.hasWindowFocus().then((void) => { +featureAbility.hasWindowFocus().then((data) => { console.info("==========================>hasWindowFocus=======================>"); }); ``` @@ -343,11 +384,15 @@ getWant(callback: AsyncCallback\): void Obtains the **Want** object sent from this ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ----------------------------- | ---- | ------------------ | -| callback | AsyncCallback\<[Want](#want)> | Yes| Callback used to return the result.| +| callback | AsyncCallback\<[Want](#want)> | Yes | Callback used to return the result.| **Example** @@ -364,8 +409,12 @@ getWant(): Promise\ Obtains the **Want** object sent from this ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Return value** -| Type| Description| +| Type | Description | | ----------------------- | ------------------------- | | Promise\<[Want](#want)> | Promise used to return the result.| @@ -373,7 +422,7 @@ Obtains the **Want** object sent from this ability. This method uses a promise t ```javascript import featureAbility from '@ohos.ability.featureability'; -featureAbility.getWant().then((void) => { +featureAbility.getWant().then((data) => { console.info("==========================>getWantCallBack=======================>"); }); ``` @@ -384,8 +433,12 @@ getContext(): Context Obtains the application context. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Return value** -| Type| Description| +| Type | Description | | ------- | -------------------- | | Context | Application context returned.| @@ -405,11 +458,15 @@ terminateSelf(callback: AsyncCallback\): void Destroys this Page ability, with the result code and data sent to the caller. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ---------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -426,8 +483,12 @@ terminateSelf(): Promise\ Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Return value** -| Type| Description| +| Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| @@ -435,7 +496,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ```javascript import featureAbility from '@ohos.ability.featureability'; -featureAbility.terminateSelf().then((void) => { console.info("==========================>terminateSelfCallBack=======================>"); +featureAbility.terminateSelf().then((data) => { console.info("==========================>terminateSelfCallBack=======================>"); }); ``` @@ -445,37 +506,42 @@ connectAbility(request: Want, options:ConnectOptions): number Connects this ability to a specific Service ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ------- | -------------- | ---- | ---------------------------- | -| request | [Want](#want) | Yes| Service ability to connect.| -| options | ConnectOptions | Yes| Callback used to return the result.| +| request | [Want](#want) | Yes | Service ability to connect.| +| options | ConnectOptions | Yes | Callback used to return the result. | Want -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable | Type | Mandatory| Description | | ------------ | -------- | -------- | ---- | ---------------------------------- | -| deviceId | Read-only| string | No| Device ID of the Service ability to connect. The default value is the local device ID.| -| bundleName | Read-only| string | Yes| Bundle name of the Service ability to connect.| -| abilityName | Read-only| string | Yes| Class name of the Service ability to connect.| +| deviceId | Read-only | string | No | Device ID of the Service ability to connect. The default value is the local device ID.
System capabilities: SystemCapability.Ability.AbilityBase| +| bundleName | Read-only | string | Yes | Bundle name of the Service ability to connect.
System capabilities: SystemCapability.Ability.AbilityBase | +| abilityName | Read-only | string | Yes | Class name of the Service ability to connect.
System capabilities: SystemCapability.Ability.AbilityBase | ConnectOptions -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ------------ | -------- | -------- | ---- | ---------------------------------- | -| onConnect | Read-only| function | Yes| Callback invoked when the connection is successful.| -| onDisconnect | Read-only| function | Yes| Callback invoked when the connection fails.| -| onFailed | Read-only| function | Yes| Callback invoked when **connectAbility** fails to be called.| +| onConnect | Read-only | function | Yes | Callback invoked when the connection is successful.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core | +| onDisconnect | Read-only | function | Yes | Callback invoked when the connection fails.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core | +| onFailed | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| **Return value** -| Type| Description| +| Type | Description | | ------ | ------------------------ | | number | Returns the ID of the Service ability connected.| **Example** ```javascript +import rpc from '@ohos.rpc' import featureAbility from '@ohos.ability.featureAbility' function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); @@ -488,7 +554,7 @@ function onFailedCallback(code){ } var connId = featureAbility.connectAbility( { - deviceId: deviceId, + deviceId: "", bundleName: "com.ix.ServiceAbility", abilityName: "ServiceAbilityA", }, @@ -506,16 +572,21 @@ disconnectAbility(connection: number, callback:AsyncCallback\): void Disconnects this ability from a specific Service ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ------------- | ---- | ------------------------------ | -| connection | number | Yes| ID of the Service ability to disconnect.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| connection | number | Yes | ID of the Service ability to disconnect.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```javascript +import rpc from '@ohos.rpc' import featureAbility from '@ohos.ability.featureAbility' function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); @@ -550,20 +621,25 @@ disconnectAbility(connection: number): Promise\ Disconnects this ability from a specific Service ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ---------- | ------ | ---- | ------------------------------ | -| connection | number | Yes| ID of the Service ability to disconnect.| +| connection | number | Yes | ID of the Service ability to disconnect.| **Return value** -| Type| Description| +| Type | Description | | -------------- | ----------------------- | | Promise\ | Promise used to return the result.| **Example** ```javascript +import rpc from '@ohos.rpc' import featureAbility from '@ohos.ability.featureAbility' function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); @@ -588,91 +664,51 @@ var connId = featureAbility.connectAbility( var result = await featureAbility.disconnectAbility(connId); ``` -## featureAbility.continueAbility - -continueAbility(options: ContinueAbilityOptions, callback: AsyncCallback\): void - -Migrates an ability to another device. This method uses a callback to return the execution result. - -**Parameters** - -| Name| Type| Mandatory| Description| -| -------- | ---------------------- | ---- | ------------------- | -| options | ContinueAbilityOptions | Yes| Ability to migrate.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| - -ContinueAbilityOptions - -| Name| Readable/Writable| Type| Mandatory| Description| -| ---------- | -------- | ------- | ---- | ------------------------------------------------------------ | -| deviceId | Read-only| string | Yes| Information about the ability to migrate.| -| reversible | Read-only| boolean | Yes| Whether migration back is supported. Currently, this feature is not supported. This parameter is reserved and can be set to **false**.| - -**Example** - -```javascript -import featureAbility from '@ohos.ability.featureAbility' - -async StartContinueAbility(deviceId) { - let continueAbilityOptions = { - reversible: false, - deviceId: deviceId, - } - function ContinueAbilityCallback(err, data) { - console.info("[Demo] ContinueAbilityCallback, result err = " + JSON.stringify(err)); - console.info("[Demo] ContinueAbilityCallback, result data= " + JSON.stringify(data)); - } - await featureAbility.continueAbility(continueAbilityOptions, ContinueAbilityCallback); - console.info('[Demo] featureAbility.StartContinueAbility end'); -} -this.StartContinueAbility(remoteDeviceId); //remoteDeviceId is acquired from DeviceManager -``` - ## AbilityResult -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ---------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | -| resultCode | Read-only| number | Yes| Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.| -| want | Read-only| [Want](#want) | No| Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**.| +| resultCode | Read-only | number | Yes | Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.
System capabilities: SystemCapability.Ability.AbilityBase| +| want | Read-only | [Want](#want) | No | Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**.
System capabilities: SystemCapability.Ability.AbilityBase | ## StartAbilityParameter -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| want | Read-only| [Want](#want) | Yes| Information about the ability to start.| -| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.| +| want | Read-only | [Want](#want) | Yes | Information about the ability to start.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| ## Want -| Name| Readable/Writable| Type| Mandatory| Description| +| Name | Readable/Writable| Type | Mandatory| Description | | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| deviceId | Read-only| string | No| ID of the device that runs the ability.| -| bundleName | Read-only| string | No| Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| -| abilityName | Read-only| string | No| Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| -| uri | Read-only| string | No| URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| -| type | Read-only| string | No| MIME type, for example, text/plain or image/*.| -| flags | Read-only| number | No| How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).| -| action | Read-only| string | No| Action option.| -| parameters | Read-only| {[key: string]: any} | No| List of parameters in a **Want** object.| -| entities | Read-only| Array\ | No| List of entities.| +| deviceId | Read-only | string | No | ID of the device that runs the ability.
System capabilities: SystemCapability.Ability.AbilityBase | +| bundleName | Read-only | string | No | Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.
System capabilities: SystemCapability.Ability.AbilityBase| +| abilityName | Read-only | string | No | Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.
System capabilities: SystemCapability.Ability.AbilityBase| +| uri | Read-only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.
System capabilities: SystemCapability.Ability.AbilityBase| +| type | Read-only | string | No | MIME type, for example, text/plain or image/*.
System capabilities: SystemCapability.Ability.AbilityBase | +| flags | Read-only | number | No | How the **Want** object will be handled. By default, a number is passed. For details, see [flags](#flags).
System capabilities: SystemCapability.Ability.AbilityBase| +| action | Read-only | string | No | Action option.
System capabilities: SystemCapability.Ability.AbilityBase | +| parameters | Read-only | {[key: string]: any} | No | List of parameters in a **Want** object.
System capabilities: SystemCapability.Ability.AbilityBase | +| entities | Read-only | Array\ | No | List of entities.
System capabilities: SystemCapability.Ability.AbilityBase | ## flags -| Name| Name| Description| +| Name | Name | Description | | ------------------------------------ | ---------- | ------------------------------------------------------------ | -| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.| -| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.| -| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.| -| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.| -| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.| -| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.| -| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.| -| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.| -| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.| -| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.| -| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.| -| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.| -| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.| -| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.| -| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.| -| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.| +| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.
System capabilities: SystemCapability.Ability.AbilityBase| +| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.
System capabilities: SystemCapability.Ability.AbilityBase| diff --git a/en/application-dev/reference/apis/js-apis-fileio.md b/en/application-dev/reference/apis/js-apis-fileio.md index 99084fd0717ccb3d55367305451e0d2a1530fcb4..9b88c6a1bb9e4eeae87f45ca47c5bec6cc290842 100644 --- a/en/application-dev/reference/apis/js-apis-fileio.md +++ b/en/application-dev/reference/apis/js-apis-fileio.md @@ -553,7 +553,7 @@ Synchronously opens a file. | -------- | -------- | -------- | -------- | | path | string | Yes| Absolute path of the target file.| | flags | number | No| Option for opening a file. You must specify one of the following options. By default, the file is opened in read-only mode.
- **0o0**: Open the file in read-only mode.
- **0o1**: Open the file in write-only mode.
- **0o2**: Open the file in read/write mode.
You can also specify the following options, separated using a bitwise OR operator (|). By default, no extra option is specified.
- **0o100**: If the file does not exist, create it. If you use this option, you must also specify **mode**.
- **0o200**: If **0o100** is added and the file already exists, throw an exception.
- **0o1000**: If the file exists and is open in write-only or read/write mode, truncate the file length to 0.
- **0o2000**: Open the file in append mode. New data will be appended to the file (added to the end of the file).
- **0o4000**: If **path** points to a named pipe (also known as a FIFO), block special file, or character special file, perform non-blocking operations on the open file and in subsequent I/Os.
- **0o200000**: If **path** points to a directory, throw an exception.
- **0o400000**: If **path** points to a symbolic link, throw an exception.
- **0o4010000**: Open the file in synchronous I/O mode.| - | mode | number | No| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.| + | mode | number | No| Permissions on the file. You can specify multiple permissions, separated using a bitwise OR operator (|). The default value is **0o666**.
- **0o666**: The owner, user group, and other users have the read and write permissions on the file.
- **0o700**: The owner has the read, write, and execute permissions.
- **0o400**: The owner has the read permission.
- **0o200**: The owner has the write permission.
- **0o100**: The owner has the execute permission.
- **0o070**: The user group has the read, write, and execute permissions.
- **0o040**: The user group has the read permission.
- **0o020**: The user group has the write permission.
- **0o010**: The user group has the execute permission.
- **0o007**: Other users have the read, write, and execute permissions.
- **0o004**: Other users have the read permission.
- **0o002**: Other users have the write permission.
- **0o001**: Other users have the execute permission.
The file permissions of newly created files are affected by **umask**, which is set as the process starts. Currently, the modification of **umask** is not open. - Return value | Type| Description| diff --git a/en/application-dev/reference/apis/js-apis-formextension.md b/en/application-dev/reference/apis/js-apis-formextension.md index 3368ad16eb84fb8477f4b086d372b5289f85d209..ee3e0f92b41b9edc4d28eab38dc63c4722119230 100644 --- a/en/application-dev/reference/apis/js-apis-formextension.md +++ b/en/application-dev/reference/apis/js-apis-formextension.md @@ -1,6 +1,6 @@ # FormExtension -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. Provides **FormExtension** APIs. @@ -42,14 +42,16 @@ Called to notify the widget provider that a **Form** instance (widget) has been - Example ``` - onCreate(want) { - console.log('FormExtension onCreate, want:' + want.abilityName); - let dataObj1 = { - temperature:"11c", - "time":"11:00" - }; - let obj1 = formBindingData.createFormBindingData(dataObj1); - return obj1; + export default class MyFormExtension extends FormExtension { + onCreate(want) { + console.log('FormExtension onCreate, want:' + want.abilityName); + let dataObj1 = { + temperature:"11c", + "time":"11:00" + }; + let obj1 = formBindingData.createFormBindingData(dataObj1); + return obj1; + } } ``` @@ -68,8 +70,10 @@ Called to notify the widget provider that a temporary widget has been converted - Example ``` - onCastToNormal(formId) { - console.log('FormExtension onCastToNormal, formId:' + formId); + export default class MyFormExtension extends FormExtension { + onCastToNormal(formId) { + console.log('FormExtension onCastToNormal, formId:' + formId); + } } ``` @@ -88,14 +92,16 @@ Called to notify the widget provider that a widget has been updated. After obtai - Example ``` - onUpdate(formId) { - console.log('FormExtension onUpdate, formId:' + formId); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - this.context.updateForm(formId, obj2) - .then((data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }).catch((error) => { - console.error('Operation updateForm failed. Cause: ' + error);}); + export default class MyFormExtension extends FormExtension { + onUpdate(formId) { + console.log('FormExtension onUpdate, formId:' + formId); + let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + this.context.updateForm(formId, obj2) + .then((data)=>{ + console.log('FormExtension context updateForm, data:' + data); + }).catch((error) => { + console.error('Operation updateForm failed. Cause: ' + error);}); + } } ``` @@ -114,17 +120,19 @@ Called to notify the widget provider of the change of visibility. - Example ``` - onVisibilityChange(newStatus) { - console.log('FormExtension onVisibilityChange, newStatus:' + newStatus); - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - - for (let key in newStatus) { - console.log('FormExtension onVisibilityChange, key:' + key + ", value=" + newStatus[key]); - this.context.updateForm(key, obj2) - .then((data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }).catch((error) => { - console.error('Operation updateForm failed. Cause: ' + error);}); + export default class MyFormExtension extends FormExtension { + onVisibilityChange(newStatus) { + console.log('FormExtension onVisibilityChange, newStatus:' + newStatus); + let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + + for (let key in newStatus) { + console.log('FormExtension onVisibilityChange, key:' + key + ", value=" + newStatus[key]); + this.context.updateForm(key, obj2) + .then((data)=>{ + console.log('FormExtension context updateForm, data:' + data); + }).catch((error) => { + console.error('Operation updateForm failed. Cause: ' + error);}); + } } } ``` @@ -145,8 +153,10 @@ Called to instruct the widget provider to receive and process the widget event. - Example ``` - onEvent(formId, message) { - console.log('FormExtension onEvent, formId:' + formId + ", message:" + message); + export default class MyFormExtension extends FormExtension { + onEvent(formId, message) { + console.log('FormExtension onEvent, formId:' + formId + ", message:" + message); + } } ``` @@ -165,7 +175,9 @@ Called to notify the widget provider that a **Form** instance (widget) has been - Example ``` - onDestroy(formId) { - console.log('FormExtension onDestroy, formId:' + formId); + export default class MyFormExtension extends FormExtension { + onDestroy(formId) { + console.log('FormExtension onDestroy, formId:' + formId); + } } ``` diff --git a/en/application-dev/reference/apis/js-apis-hashset.md b/en/application-dev/reference/apis/js-apis-hashset.md new file mode 100644 index 0000000000000000000000000000000000000000..7ba96f84539cccb36815d4b147853b9aacc269dc --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-hashset.md @@ -0,0 +1,275 @@ +# Nonlinear Container HashSet + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import HashSet from '@ohos.util.HashSet'; +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## HashSet + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a hash set (called container later).| + + +### constructor + +constructor() + +A constructor used to create a **HashSet** instance. + +**Example** + +``` +let hashSet = new HashSet(); +``` + + +### isEmpty + +isEmpty(): boolean + +Checks whether this container is empty (contains no entry). + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +const hashSet = new HashSet(); +hashSet.isEmpty(); +``` + + +### has + +has(value: T): boolean + +Checks whether this container contains the specified entry. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Entry to check.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.| + +**Example** + +``` +let hashSet = new HashSet(); +let result = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result1 = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + + +### add + +add(value: T): boolean + +Adds an entry to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + +``` +let hashSet = new HashSet(); +let result = hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + + +### remove + +remove(value: T): boolean + +Removes an entry from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.| + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("sdfs"); +let result = hashSet.remove("sdfs"); +``` + + +### clear + +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("sdfs"); +hashSet.clear(); +``` + + +### values + +values(): IterableIterator<T> + +Obtains an iterator that contains all the values in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("sdfs"); +let iter = hashSet.values(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` + + +### forEach + +forEach(callbackfn: (value: T, key?: T, set?: HashSet<T>) => void, thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| key | T | No| Key of the entry that is currently traversed (same as **value**).| +| set | HashSet<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("sdfs"); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.forEach((value, key) => { + console.log(value, key); +}); +``` + + +### entries +entries(): IterableIterator<[T, T]> + +Obtains an iterator that contains all the entries in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<[T, T]> | Iterator obtained.| + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("sdfs"); +let iter = hashSet.entries(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp[0]); + console.log(temp[1]); + temp = iter.next().value; +} +``` + + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let hashSet = new HashSet(); +hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +hashSet.add("sdfs"); + +// Method 1: +for (let item of hashSet) { + console.log("value: " + item); +} + +// Method 2: +let iter = hashSet[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-hiappevent.md b/en/application-dev/reference/apis/js-apis-hiappevent.md index a2db965ba8d4d04035796696c45cb49c09f0867d..0d8534643b50338f4b9a96c97ed1c7f86bd2381b 100644 --- a/en/application-dev/reference/apis/js-apis-hiappevent.md +++ b/en/application-dev/reference/apis/js-apis-hiappevent.md @@ -1,418 +1,157 @@ -# HiAppEvent +# Application dotting ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Modules to Import + +## Modules to Import ``` import hiAppEvent from '@ohos.hiAppEvent'; ``` + ## System Capabilities SystemCapability.HiviewDFX.HiAppEvent -## hiAppEvent.write -write\(eventName: string, eventType: EventType, keyValues: object, callback: AsyncCallback\): void +## hiAppEvent.write + +write(eventName: string, eventType: EventType, keyValues: object, callback: AsyncCallback<void>): void Writes event information to the event file of the current day. This function supports JSON parameters and uses an asynchronous callback to return the result. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

eventName

-

string

-

Yes

-

Indicates the application event name.

-

eventType

-

EventType

-

Yes

-

Indicates the application event type.

-

keyValues

-

object

-

Yes

-

Indicates an array of JSON parameters of the application event. A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).

-

callback

-

AsyncCallback<void>

-

No

-

Indicates the callback function, which can be used to process the received return value.

-
  • Value 0 indicates that the event verification is successful, and the event will be written to the event file asynchronously.
  • A value greater than 0 indicates that invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored.
  • A value smaller than 0 indicates that the event verification fails, and the event will not be written to the event file.
-
- -- Example - - ``` - hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str_data":"strValue"}, (err, value) => { - if (err) { - // Event writing exception: Write the event to the event file after the invalid parameters in the event are ignored, or stop writing the event if the event verification fails. - console.error(`failed to write event because ${err.code}`); - return; - } - +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| eventName | string | Yes| App event name.| +| eventType | [EventType](#eventtype) | Yes| Application event type.| +| keyValues | object | Yes| Array of JSON parameters of the application event. A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).| +| callback | AsyncCallback<void> | No| Callback used to process the received return value.
- The value **0** indicates that the event parameter verification is successful, and the event will be written to the event file asynchronously.
- A value greater than **0** indicates that invalid parameters are present in the event, and the event will be written to the event file asynchronously after the invalid parameters are ignored.
- A value smaller than **0** indicates that the event parameter verification fails, and the event will not be written to the event file asynchronously.| + +**Example** + +``` +hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str_data":"strValue"}, (err, value) => { + if (err) { + // Event writing exception: Write the event to the event file after the invalid parameters in the event are ignored, or stop writing the event if the event verification fails. + console.error(`failed to write event because ${err.code}`); + return; + } + + // Event writing succeeded. + console.log(`success to write event: ${value}`); +}); +``` + + +## hiAppEvent.write + +write(eventName: string, eventType: EventType, keyValues: object): Promise<void> + +Writes event information to the event file of the current day. This function supports JSON parameters and uses a promise to return the result. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| eventName | string | Yes| App event name.| +| eventType | [EventType](#eventtype) | Yes| Application event type.| +| keyValues | object | Yes| Array of JSON parameters of the application event. A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to process the callback in the then() and catch() methods when event writing succeeded or failed.| + +**Example** + +``` +hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str_data":"strValue"}) + .then((value) => { // Event writing succeeded. console.log(`success to write event: ${value}`); + }).catch((err) => { + // Event writing exception: Write the event to the event file after the invalid parameters in the event are ignored, or stop writing the event if the event verification fails. + console.error(`failed to write event because ${err.code}`); }); - ``` +``` -## hiAppEvent.write +## hiAppEvent.configure -write\(eventName: string, eventType: EventType, keyValues: object\): Promise +configure(config: ConfigOption): boolean -Writes event information to the event file of the current day. This function supports JSON parameters and uses a promise to return the result. +Configures the application event logging function, such as setting the event logging switch and maximum size of the directory that stores the event logging files. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

eventName

-

string

-

Yes

-

Indicates the application event name.

-

eventType

-

EventType

-

Yes

-

Indicates the application event type.

-

keyValues

-

object

-

Yes

-

Indicates an array of JSON parameters of the application event. A key must be a string, and a value must be a string, number, boolean, or Array (which can only be a string, number, or boolean).

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<void>

-

Promise used to process the callback in the then() and catch() methods when event writing succeeded or failed.

-
- -- Example - - ``` - hiAppEvent.write("test_event", hiAppEvent.EventType.FAULT, {"int_data":100, "str_data":"strValue"}) - .then((value) => { - // Event writing succeeded. - console.log(`success to write event: ${value}`); - }).catch((err) => { - // Event writing exception: Write the event to the event file after the invalid parameters in the event are ignored, or stop writing the event if the event verification fails. - console.error(`failed to write event because ${err.code}`); - }); - ``` - - -## hiAppEvent.configure - -configure\(config: ConfigOption\): boolean +**Parameters** -Configures the application event logging function, such as setting the event logging switch and maximum size of the directory that stores the event logging files. +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| config | [ConfigOption](#configoption) | Yes| Configuration items for application event logging.| -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

config

-

ConfigOption

-

Yes

-

Configuration items for application event logging.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

Returns true if the configuration is successful; returns false otherwise.

-
- -- Example - - ``` - // Configure the application event logging switch. - hiAppEvent.configure({ - disable: true - }); - - // Configure the maximum size of the directory that stores the event logging files. - hiAppEvent.configure({ - maxStorage: '100M' - }); - ``` +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the configuration is successful; returns **false** otherwise.| + +**Example** +``` +// Set the application event logging switch. +hiAppEvent.configure({ + disable: true +}); + +// Configure the maximum size of the directory that stores the event logging files. +hiAppEvent.configure({ + maxStorage: '100M' +}); +``` -## ConfigOption +## ConfigOption Provides the configuration items for application event logging. - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

disable

-

boolean

-

No

-

Application event logging switch. The value true means to disable the application event logging function, and the value false means the opposite.

-

maxStorage

-

string

-

No

-

Maximum size of the event file storage directory. The default value is 10M. If the specified size is exceeded, the oldest event logging files in the storage directory will be deleted to free up space.

-
- -## EventType +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| disable | boolean | No| Application event logging switch. The value true means to disable the application event logging function, and the value false means the opposite.| +| maxStorage | string | No| Maximum size of the event file storage directory. The default value is **10M**. If the specified size is exceeded, the oldest event logging files in the storage directory will be deleted to free up space.| + + +## EventType Enumerates event types. - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

FAULT

-

1

-

Fault event

-

STATISTIC

-

2

-

Statistical event

-

SECURITY

-

3

-

Security event

-

BEHAVIOR

-

4

-

Behavior event

-
- -## Event +| Name| Default Value| Description| +| -------- | -------- | -------- | +| FAULT | 1 | Fault event| +| STATISTIC | 2 | Statistical event| +| SECURITY | 3 | Security event| +| BEHAVIOR | 4 | Behavior event| + + +## Event Provides constants that define the names of all predefined events. - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

USER_LOGIN

-

string

-

Yes

-

No

-

User login event.

-

USER_LOGOUT

-

string

-

Yes

-

No

-

User logout event.

-

DISTRIBUTED_SERVICE_START

-

string

-

Yes

-

No

-

Distributed service startup event.

-
- -## Param +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| USER_LOGIN | string | Yes| No| User login event.| +| USER_LOGOUT | string | Yes| No| User logout event.| +| DISTRIBUTED_SERVICE_START | string | Yes| No| Distributed service startup event.| -Provides constants that define the names of all predefined event parameters. - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

USER_ID

-

string

-

Yes

-

No

-

Custom user ID.

-

DISTRIBUTED_SERVICE_NAME

-

string

-

Yes

-

No

-

Distributed service name.

-

DISTRIBUTED_SERVICE_INSTANCE_ID

-

string

-

Yes

-

No

-

Distributed service instance ID.

-
+## Param + +Provides constants that define the names of all predefined event parameters. +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| USER_ID | string | Yes| No| Custom user ID.| +| DISTRIBUTED_SERVICE_NAME | string | Yes| No| Distributed service name.| +| DISTRIBUTED_SERVICE_INSTANCE_ID | string | Yes| No| Distributed service instance ID.| diff --git a/en/application-dev/reference/apis/js-apis-hichecker.md b/en/application-dev/reference/apis/js-apis-hichecker.md new file mode 100644 index 0000000000000000000000000000000000000000..70022fd0211204446dee616640221bd394f61e7e --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-hichecker.md @@ -0,0 +1,126 @@ +# HiChecker + +> **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import hichecker from '@ohos.hichecker'; +``` + + +## System Capabilities + +SystemCapability.HiviewDFX.HiChecker + +## Rule Constants + +Provides the constants of all rule types. + +| Name| Type| Description| +| ---------------------------------- | -------- | ------------------------------------------------------ | +| RULE_CAUTION_PRINT_LOG | BigInt | Alarm rule, which is programmed to print a log when an alarm is generated.| +| RULE_CAUTION_TRIGGER_CRASH | BigInt | Alarm rule, which is programmed to force the application to exit when an alarm is generated.| +| RULE_THREAD_CHECK_SLOW_PROCESS | BigInt | Caution rule, which is programmed to detect whether any time-consuming function is invoked.| +| RULE_CHECK_SLOW_EVENT | BigInt | Caution rule, which is programmed to detect whether the event distribution or processing time has exceeded the specified time threshold.| +| RULE_CHECK_ABILITY_CONNECTION_LEAK | BigInt | Caution rule, which is programmed to detect whether ability leakage has occurred.| + + +## hichecker.addRule + +addRule(rule: BigInt): void + +Adds one or more rules. HiChecker detects unexpected operations or gives feedback based on the added rules. + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | ---------------- | +| rule | BigInt | Yes| Rule to be added.| + +**Example** + +``` +// Add a rule. +hichecker.addRule(hichecker.RULE_CAUTION_PRINT_LOG); + +// Add multiple rules. +hichecker.addRule( + hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); +``` + +## hichecker.removeRule + +removeRule(rule: BigInt): void + +Removes one or more rules. The removed rules will become ineffective. + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | ---------------- | +| rule | BigInt | Yes| Rule to be removed.| + +**Example** + +``` +// Remove a rule. +hichecker.removeRule(hichecker.RULE_CAUTION_PRINT_LOG); + +// Remove multiple rules. +hichecker.removeRule( + hichecker.RULE_CAUTION_PRINT_LOG | hichecker.RULE_CAUTION_TRIGGER_CRASH); +``` + +## hichecker.getRule + +getRule(): BigInt + +Obtains a collection of thread, process, and alarm rules that have been added. + +**Return value** + +| Type| Description| +| ------ | ---------------------- | +| BigInt | Collection of added rules.| + +**Example** + +``` +// Add a rule. +hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); + +// Obtain the collection of added rules. +hichecker.getRule(); // return 1n; +``` + +## hichecker.contains + +contains(rule: BigInt): boolean + +Checks whether the specified rule exists in the collection of added rules. If the rule is of the thread level, this operation is performed only on the current thread. + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | ---------------- | +| rule | BigInt | Yes| Rule to be checked.| + +**Return value** + +| Type| Description| +| ------- | ---------------------------------------------------------- | +| boolean | Returns **true** if the rule exists in the collection of added rules; returns **false** otherwise.| + +**Example** + +``` +// Add a rule. +hichecker.addRule(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); + +// Check whether the added rule exists in the collection of added rules. +hichecker.contains(hichecker.RULE_THREAD_CHECK_SLOW_PROCESS); // return true; +hichecker.contains(hichecker.RULE_CAUTION_PRINT_LOG); // return false; +``` diff --git a/en/application-dev/reference/apis/js-apis-hidebug.md b/en/application-dev/reference/apis/js-apis-hidebug.md new file mode 100644 index 0000000000000000000000000000000000000000..78b6282ce68b0b4776914472b9f0cc1ad9a0c6f0 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-hidebug.md @@ -0,0 +1,170 @@ +# HiDebug + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +You can run the hidebug command to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data. + +## Modules to Import + +``` +import hidebug from '@ohos.hidebug'; +``` + + +## System Capabilities +SystemCapability.HiviewDFX.HiProfiler.HiDebug + + +## hidebug.getNativeHeapSize + +getNativeHeapSize(): bigint + +Obtains the total size of the native heap memory. + + +- **Return value** + | Type| Description| + | -------- | -------- | + | bigint | Total size of the native heap memory.| + + +- **Example** + ``` + let nativeHeapSize = hidebug.getNativeHeapSize(); + ``` + + +## hidebug.getNativeHeapAllocatedSize + +getNativeHeapAllocatedSize(): bigint + +Obtains the size of the allocated native heap memory. + + +- **Return value** + | Type| Description| + | -------- | -------- | + | bigint | Size of the allocated native heap memory.| + + +- **Example** + ``` + let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize(); + ``` + + +## hidebug.getNativeHeapFreeSize + +getNativeHeapFreeSize(): bigint + +Obtains the size of the free native heap memory. + + +- **Return value** + | Type| Description| + | -------- | -------- | + | bigint | Size of the free native heap memory.| + + +- **Example** + ``` + let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize(); + ``` + + +## hidebug.getPss + +getPss(): bigint + +Obtains the PSS of this process. + + +- **Return value** + | Type| Description| + | -------- | -------- | + | bigint | PSS of the process.| + + +- **Example** + ``` + let pss = hidebug.getPss(); + ``` + + +## hidebug.getSharedDirty + +getSharedDirty(): bigint + +Obtains the size of the shared dirty memory of this process. + + +- **Return value** + | Type| Description| + | -------- | -------- | + | bigint | Size of the shared dirty memory of the process.| + + +- **Example** + ``` + let sharedDirty = hidebug.getSharedDirty()); + ``` + + +## hidebug.startProfiling + +startProfiling(filename : string) : void + +Starts the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------ | ---- | ------------------------------------------------------------ | +| filename | string | Yes| User-defined profile name. The `filename.json` file is generated in the `files` directory of the application based on the specified `filename`.| + +**Example** + +```js +hidebug.startProfiling("cpuprofiler-20220216"); +// Code block +// ... +// Code block +hidebug.stopProfiling(); +``` + + + +## hidebug.stopProfiling + +stopProfiling() : void + +Stops the profiling method. `stopProfiling()` and `startProfiling()` are called in pairs. `stopProfiling()` always occurs after `startProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`. + +**Example** + +```js +hidebug.startProfiling("cpuprofiler-20220216"); +// Code block +// ... +// Code block +hidebug.stopProfiling(); +``` + +## hidebug.dumpHeapData + +dumpHeapData(filename : string) : void + +Exports the heap data. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------ | ---- | ------------------------------------------------------------ | +| filename | string | Yes| User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the app based on the specified `filename`.| + +**Example** + +```js +hidebug.dumpHeapData("heap-20220216"); +``` diff --git a/en/application-dev/reference/apis/js-apis-hitracechain.md b/en/application-dev/reference/apis/js-apis-hitracechain.md index 370e48bd2a3bca058451d15a2b4f42ab77dd9b05..2ad97f096f7abedaa6e8dceb06678d564c287802 100644 --- a/en/application-dev/reference/apis/js-apis-hitracechain.md +++ b/en/application-dev/reference/apis/js-apis-hitracechain.md @@ -1,6 +1,6 @@ # Distributed Call Chain Tracing -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -58,7 +58,7 @@ Defines a **HiTraceId** object. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | chainId | bigint | Yes| Call chain ID.| -| spandId | number | No| Span ID.| +| spanId | number | No| Span ID.| | parentSpanId | number | No| Parent span ID.| | flags | number | No| Trace flag combination.| @@ -68,20 +68,24 @@ begin(name: string, flags: number = HiTraceFlag.DEFAULT): HiTraceId Starts call chain tracing. This API works in synchronous manner. -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | name | string | Yes| Traced service name.| - | flags | number | Yes| [Trace flag combination](#hitraceflag).| -- Return value - | Type| Description| - | -------- | -------- | - | [HiTraceId](#hitraceid) | **HiTraceId** instance.| - -- Example - ``` - let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); - ``` +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Traced service name.| +| flags | number | Yes| Trace flag combination. For details, see [HiTraceFlag](#hitraceflag).| + +**Return value** + +| Type| Description| +| -------- | -------- | +| [HiTraceId](#hitraceid) | **HiTraceId** instance.| + +**Example** + +``` +let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); +``` ## hiTraceChain.end @@ -89,17 +93,19 @@ end(id: HiTraceId): void Stops call chain tracing. This API works in synchronous manner. -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| + +**Example** -- Example - ``` - let asyncTraceId = hiTraceChain.begin("business"); - // End the call chain tracing after the service logic is executed for several times. - hiTraceChain.end(asyncTraceId); - ``` +``` +let asyncTraceId = hiTraceChain.begin("business"); +// End the call chain tracing after the service logic is executed for several times. +hiTraceChain.end(asyncTraceId); +``` ## hiTraceChain.getId @@ -107,17 +113,19 @@ getId(): HiTraceId Obtains the trace ID. This API works in synchronous manner. -- Return value - | Type| Description| - | -------- | -------- | - | [HiTraceId](#hitraceid) | **HiTraceId** instance.| +**Return value** + +| Type| Description| +| -------- | -------- | +| [HiTraceId](#hitraceid) | **HiTraceId** instance.| -- Example - ``` - let traceId = hiTraceChain.begin("business"); - // Obtain the current trace ID after the service logic is executed for several times. - let curTraceId = hiTraceChain.getId(); - ``` +**Example** + +``` +let traceId = hiTraceChain.begin("business"); +// Obtain the current trace ID after the service logic is executed for several times. +let curTraceId = hiTraceChain.getId(); +``` ## hiTraceChain.setId @@ -125,17 +133,19 @@ setId(id: HiTraceId): void Sets a trace ID. This API works in synchronous manner. -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| -- Example - ``` - let traceId = hiTraceChain.begin("business"); - // Set the current trace ID after the service logic is executed for several times. - hiTraceChain.setId(asyncTraceId); - ``` +**Example** + +``` +let traceId = hiTraceChain.begin("business"); +// Set the current trace ID after the service logic is executed for several times. +hiTraceChain.setId(asyncTraceId); +``` ## hiTraceChain.clearId @@ -143,12 +153,13 @@ clearId(): void Clears the trace ID. This API works in synchronous manner. -- Example - ``` - let traceId = hiTraceChain.begin("business"); - // Clear the current trace ID after the service logic is executed for several times. - hiTraceChain.clearId(); - ``` +**Example** + +``` +let traceId = hiTraceChain.begin("business"); +// Clear the current trace ID after the service logic is executed for several times. +hiTraceChain.clearId(); +``` ## hiTraceChain.createSpan @@ -156,17 +167,19 @@ createSpan(): HiTraceId Creates a trace span. This API works in synchronous manner. -- Return value - | Type| Description| - | -------- | -------- | - | [HiTraceId](#hitraceid) | **HiTraceId** instance.| +**Return value** -- Example - ``` - let traceId = hiTraceChain.begin("business"); - // Create a trace span after the service logic is executed for several times. - let spanTraceId = hiTraceChain.createSpan(); - ``` +| Type| Description| +| -------- | -------- | +| [HiTraceId](#hitraceid) | **HiTraceId** instance.| + +**Example** + +``` +let traceId = hiTraceChain.begin("business"); +// Create a trace span after the service logic is executed for several times. +let spanTraceId = hiTraceChain.createSpan(); +``` ## hiTraceChain.tracepoint @@ -174,20 +187,22 @@ tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTr Triggers a trace point. This API works in synchronous manner. -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | mode | [HiTraceCommunicationMode](#hitracecommunicationmode) | Yes| Communication mode for the trace point.| - | type | [HiTraceTracepointType](#hitracetracepointtype)| Yes| Trace point type.| - | id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance for trace point triggering.| - | msg | string | No| Trace description passed for trace point triggering.| - -- Example - ``` - let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); - // Trigger the trace point after the service logic is executed for several times. - hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.THREAD, hiTraceChain.HiTraceTracepointType.SS, asyncTraceId, "Just a example"); - ``` +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| mode | [HiTraceCommunicationMode](#hitracecommunicationmode) | Yes| Communication mode for the trace point.| +| type | [HiTraceTracepointType](#hitracetracepointtype)| Yes| Trace point type.| +| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance for trace point triggering.| +| msg | string | No| Trace description passed for trace point triggering.| + +**Example** + +``` +let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); +// Trigger the trace point after the service logic is executed for several times. +hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.THREAD, hiTraceChain.HiTraceTracepointType.SS, asyncTraceId, "Just a example"); +``` ## hiTraceChain.isValid @@ -195,20 +210,24 @@ isValid(id: HiTraceId): boolean Checks whether a **HiTraceId** instance is valid. This API works in synchronous manner. -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| -- Return value - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the **HiTraceId** instance is valid; returns **false** otherwise.| - -- Example - ``` - let traceId = hiTraceChain.begin("business"); - let traceIdIsvalid = hiTraceChain.isValid(traceId); - ``` +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the **HiTraceId** instance is valid; returns **false** otherwise.| + +**Example** + +``` +let traceId = hiTraceChain.begin("business"); +let traceIdIsvalid = hiTraceChain.isValid(traceId); +``` ## hiTraceChain.isFlagEnabled @@ -216,21 +235,26 @@ isFlagEnabled(id: HiTraceId, flag: HiTraceFlag): boolean Checks whether the specified trace flag in the **HiTraceId** instance is enabled. This API works in synchronous manner. -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| - | flag | [HiTraceFlag](#hitraceflag) | Yes| Specified trace flag.| -- Return value - | Type| Description| - | -------- | -------- | - | boolean | Returns **true** if the specified trace flag in the **HiTraceId** instance is enabled; returns **false** otherwise.| -- Example - ``` - let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); - // The value of enabledDoNotCreateSpanFlag is true. - let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); - ``` +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| +| flag | [HiTraceFlag](#hitraceflag) | Yes| Specified trace flag.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified trace flag in the **HiTraceId** instance is enabled; returns **false** otherwise.| + +**Example** + +``` +let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); +// The value of enabledDoNotCreateSpanFlag is true. +let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); +``` ## hiTraceChain.enableFlag @@ -238,16 +262,17 @@ enableFlag(id: HiTraceId, flag: HiTraceFlag): void Enables the specified trace flag in the **HiTraceId** instance. This API works in synchronous manner. -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| - | flag | [HiTraceFlag](#hitraceflag) | Yes| Specified trace flag.| - -- Example - ``` - let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); - hiTraceChain.enable(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); - // The value of enabledDoNotCreateSpanFlag is true. - let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); - ``` +**Parameters** +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| id | [HiTraceId](#hitraceid) | Yes| **HiTraceId** instance.| +| flag | [HiTraceFlag](#hitraceflag) | Yes| Specified trace flag.| + +**Example** + +``` +let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); +hiTraceChain.enable(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); +// The value of enabledDoNotCreateSpanFlag is true. +let enabledDoNotCreateSpanFlag = hiTraceChain.isFlagEnabled(asyncTraceId, hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); +``` diff --git a/en/application-dev/reference/apis/js-apis-hitracemeter.md b/en/application-dev/reference/apis/js-apis-hitracemeter.md index fc8599f907aeaa7f0e0314f704b84d2139ba9a96..17f62fb18b40894ad208879228387f45eed67f93 100644 --- a/en/application-dev/reference/apis/js-apis-hitracemeter.md +++ b/en/application-dev/reference/apis/js-apis-hitracemeter.md @@ -1,6 +1,6 @@ # Performance Tracing -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -18,26 +18,26 @@ SystemCapability.HiviewDFX.HiTrace ## hiTraceMeter.startTrace -startTrace(name: string, taskId: number, expectedTime?: number): void +startTrace(name: string, taskId: number): void -Starts a trace task. **expectedTime** is an optional parameter, which specifies the expected duration of the trace. +Starts a trace task. +If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | name | string | Yes| Name of the trace task to start.| - | taskId | number | Yes| Task ID.| - | expectedTime | number | No| Expected duration of the trace, in ms.| +If the trace tasks with the same name are not performed at the same time, the same taskId can be used. For a specific example, refer to an example in [hiTraceMeter.finishTrace](#hitracemeterfinishtrace). - > ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** - > If multiple trace tasks with the same name need to be performed at the same time or a trace task needs to be performed multiple times concurrently, different task IDs must be specified in **startTrace**. If the trace tasks with the same name are not performed at the same time, the same task ID can be used. For details, see the **hiTraceMeter.finishTrace** example. +**Parameters** -- Example - ``` - hiTraceMeter.startTrace("myTestFunc", 1); - hiTraceMeter.startTrace("myTestFunc", 1, 5); // The expected duration of the trace task is 5 ms. - ``` +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Name of the trace task to start.| +| taskId | number | Yes| Task ID.| + +**Example** + +``` +hiTraceMeter.startTrace("myTestFunc", 1); +``` ## hiTraceMeter.finishTrace @@ -46,62 +46,62 @@ finishTrace(name: string, taskId: number): void Stops a trace task. +To stop a trace task, the values of name and task ID in **finishTrace** must be the same as those in [startTrace](#hitracemeterstarttrace). + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Name of the trace task to start.| +| taskId | number | Yes| Task ID.| + +**Example** + +``` +hiTraceMeter.finishTrace("myTestFunc", 1); +``` + +``` +// Start track tasks with the same name concurrently. +hiTraceMeter.startTrace("myTestFunc", 1); +// Service flow +hiTraceMeter.startTrace("myTestFunc", 2); // The second trace task starts while the first task is still running. The first and second tasks have the same name but different task IDs. +// Service flow +hiTraceMeter.finishTrace("myTestFunc", 1); +// Service flow +hiTraceMeter.finishTrace("myTestFunc", 2); +``` -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | name | string | Yes| Name of the trace task to start.| - | taskId | number | Yes| Task ID.| - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** - > To stop a trace task, the values of name and task ID in **finishTrace** must be the same as those in **startTrace**. - -- Example - ``` - hiTraceMeter.finishTrace("myTestFunc", 1); - ``` - - ``` - // Start track tasks with the same name concurrently. - hiTraceMeter.startTrace("myTestFunc", 1); - // Service flow - hiTraceMeter.startTrace("myTestFunc", 2); // The second trace task starts while the first task is still running. The first and second tasks have the same name but different task IDs. - // Service flow - hiTraceMeter.finishTrace("myTestFunc", 1); - // Service flow - hiTraceMeter.finishTrace("myTestFunc", 2); - ``` - - ``` - // Start track tasks with the same name at different times. - hiTraceMeter.startTrace("myTestFunc", 1); - // Service flow - hiTraceMeter.finishTrace("myTestFunc", 1); // The first trace task ends. - // Service flow - hiTraceMeter.startTrace("myTestFunc", 1); // The second trace task starts after the first task ends. The two tasks have the same name and task ID. - // Service flow - hiTraceMeter.finishTrace("myTestFunc", 1); - ``` +``` +// Start track tasks with the same name at different times. +hiTraceMeter.startTrace("myTestFunc", 1); +// Service flow +hiTraceMeter.finishTrace("myTestFunc", 1); // The first trace task ends. +// Service flow +hiTraceMeter.startTrace("myTestFunc", 1); // The second trace task starts after the first task ends. The two tasks have the same name and task ID. +// Service flow +hiTraceMeter.finishTrace("myTestFunc", 1); +``` ## hiTraceMeter.traceByValue -traceByValue(name: string, value: number): void +traceByValue(name: string, count: number): void Traces the value changes of a variable. +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Name of the variable.| +| count | number | Yes| Value of the variable.| -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | name | string | Yes| Name of the variable.| - | value | number | Yes| Value of the variable.| - -- Example - ``` - let traceCount = 3; - hiTraceMeter.traceByValue("myTestCount", traceCount); - traceCount = 4; - hiTraceMeter.traceByValue("myTestCount", traceCount); - // Service flow - ``` +**Example** +``` +let traceCount = 3; +hiTraceMeter.traceByValue("myTestCount", traceCount); +traceCount = 4; +hiTraceMeter.traceByValue("myTestCount", traceCount); +// Service flow +``` diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md index 27dc8eb464f9615f0b61462a5f7f81d71195d1f1..7a604fdd852e43c09c418312c6797ea96e7fc6e0 100644 --- a/en/application-dev/reference/apis/js-apis-i18n.md +++ b/en/application-dev/reference/apis/js-apis-i18n.md @@ -1,2665 +1,1252 @@ -# Internationalization \(i18n\) +# Internationalization – i18n ->![](public_sys-resources/icon-note.gif) **NOTE:** ->- The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ->- This module contains enhanced i18n APIs, which are not defined in ECMA 402. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> - This module contains enhanced i18n APIs, which are not defined in ECMA 402. -## Modules to Import + +## Modules to Import ``` import i18n from '@ohos.i18n'; ``` -## Required Permissions - -None -## i18n.getDisplayLanguage +## i18n.getDisplayLanguage -getDisplayLanguage\(language: string, locale: string, sentenceCase?: boolean\): string +getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string Obtains the localized script for the specified language. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

language

-

string

-

Yes

-

Specified language.

-

locale

-

string

-

Yes

-

Locale ID.

-

sentenceCase

-

boolean

-

No

-

Whether to use sentence case for the localized script.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Localized script for the specified language.

-
- -- Example - - ``` - I18n.getDisplayLanguage("zh", "en-GB", true); - I18n.getDisplayLanguage("zh", "en-GB"); - ``` - - -## i18n.getDisplayCountry - -getDisplayCountry\(country: string, locale: string, sentenceCase?: boolean\): string +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | language | string | Yes| Specified language.| + | locale | string | Yes| Locale ID.| + | sentenceCase | boolean | No| Whether to use sentence case for the localized script.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Localized script for the specified language.| + +- Example + ``` + i18n.getDisplayLanguage("zh", "en-GB", true); + i18n.getDisplayLanguage("zh", "en-GB"); + ``` + + +## i18n.getDisplayCountry + +getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): string Obtains the localized script for the specified country. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

country

-

string

-

Yes

-

Specified country.

-

locale

-

string

-

Yes

-

Locale ID.

-

sentenceCase

-

boolean

-

No

-

Whether to use sentence case for the localized script.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Localized script for the specified country.

-
- -- Example - - ``` - I18n.getDisplayCountry("zh-CN", "en-GB", true); - I18n.getDisplayCountry("zh-CN", "en-GB"); - ``` - - -## i18n.isRTL8+ - -isRTL\(locale: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | country | string | Yes| Specified country.| + | locale | string | Yes| Locale ID.| + | sentenceCase | boolean | No| Whether to use sentence case for the localized script.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Localized script for the specified country.| + +- Example + ``` + i18n.getDisplayCountry("zh-CN", "en-GB", true); + i18n.getDisplayCountry("zh-CN", "en-GB"); + ``` + + +## i18n.isRTL8+ + +isRTL(locale: string): boolean Checks whether the localized script for the specified language is displayed from right to left. -- Parameters - - - - - - - - - - - - -

Name

-

Type

-

Description

-

locale

-

string

-

Locale ID.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the localized script is displayed from right to left, and value false indicates the opposite.

-
- -- Example - - ``` - i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned. - i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned. - ``` - - -## i18n.getSystemLanguage - -getSystemLanguage\(\): string +**System capability**: SystemCapability.Global.I18n -Obtains the system language. +- Parameters + | Name| Type| Description| + | -------- | -------- | -------- | + | locale | string | Locale ID.| -- Return values +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the localized script is displayed from right to left, and value **false** indicates the opposite.| - - - - - - - - - -

Type

-

Description

-

string

-

System language ID.

-
+- Example + ``` + i18n.isRTL("zh-CN");// Since Chinese is not written from right to left, false is returned. + i18n.isRTL("ar-EG");// Since Arabic is written from right to left, true is returned. + ``` -- Example - ``` - I18n.getSystemLanguage(); - ``` +## i18n.getSystemLanguage +getSystemLanguage(): string -## i18n.getSystemRegion +Obtains the system language. -getSystemRegion\(\): string +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | string | System language ID.| + +- Example + ``` + i18n.getSystemLanguage(); + ``` -Obtains the system region. -- Return values +## i18n.getSystemRegion - - - - - - - - - -

Type

-

Description

-

string

-

System region ID.

-
+getSystemRegion(): string -- Example +Obtains the system region. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | string | System region ID.| - ``` - I18n.getSystemRegion(); - ``` +- Example + ``` + i18n.getSystemRegion(); + ``` -## i18n.getSystemLocale +## i18n.getSystemLocale -getSystemLocale\(\): string +getSystemLocale(): string Obtains the system locale. -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

System locale ID.

-
- -- Example - - ``` - I18n.getSystemLocale(); - ``` - - -## i18n.getCalendar8+ - -getCalendar\(locale: string, type? : string\): Calendar - -Obtains a **Calendar** object. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

Valid locale value, for example, zh-Hans-CN.

-

type

-

string

-

No

-

Valid calendar type. Currently, the valid types are as follows: buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic_civil, islamic_tbla, islamic_umalqura, japanese, and persian. If this parameter is left unspecified, the default calendar type of the specified locale is used.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Calendar

-

Calendar object.

-
- -- Example - - ``` - I18n.getCalendar("zh-Hans", "gregory"); - ``` - - -## Calendar8+ - -### setTime8+ - -setTime\(date: Date\): void - -Sets the date for this **Calendar** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

date

-

Date

-

Yes

-

Date to be set for the Calendar object.

-
- - -- Example - - ``` - var calendar = I18n.getCalendar("en-US", "gregory"); - var date = new Date(2021, 10, 7, 8, 0, 0, 0); - calendar.setTime(date); - ``` - - -### setTime8+ - -setTime\(time: number\): void - -Sets the date and time for this **Calendar** object. The value is represented by the number of milliseconds that have elapsed since the Unix epoch \(00:00:00 UTC on January 1, 1970\). - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

time

-

number

-

Yes

-

Number of milliseconds that have elapsed since the Unix epoch.

-
- - -- Example - - ``` - var calendar = I18n.getCalendar("en-US", "gregory"); - calendar.setTime(10540800000); - ``` - - -### set8+ - -set\(year: number, month: number, date:number, hour?: number, minute?: number, second?: number\): void - -Sets the year, month, day, hour, minute, and second for this **Calendar** object. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

year

-

number

-

Yes

-

Year to set.

-

month

-

number

-

Yes

-

Month to set.

-

date

-

number

-

Yes

-

Day to set.

-

hour

-

number

-

No

-

Hour to set.

-

minute

-

number

-

No

-

Minute to set.

-

second

-

number

-

No

-

Second to set.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 - ``` - - -### setTimeZone8+ - -setTimeZone\(timezone: string\): void - -Sets the time zone of this **Calendar** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

timezone

-

string

-

Yes

-

Time zone, for example, Asia/Shanghai.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setTimeZone("Asia/Shanghai"); - ``` - - -### getTimeZone8+ - -getTimeZone\(\): string - -Obtains the time zone of this **Calendar** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Time zone of the Calendar object.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setTimeZone("Asia/Shanghai"); - calendar.getTimeZone(); // Asia/Shanghai" - ``` - - -### getFirstDayOfWeek8+ - -getFirstDayOfWeek\(\): number - -Obtains the start day of a week for this **Calendar** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Start day of a week. The value 1 indicates Sunday, and value 7 indicates Saturday.

-
+**System capability**: SystemCapability.Global.I18n +- Return value + | Type| Description| + | -------- | -------- | + | string | System locale ID.| -- Example - - ``` - var calendar = I18n.getCalendar("en-US", "gregory"); - calendar.getFirstDayOfWeek(); - ``` - - -### setFirstDayOfWeek8+ - -setFirstDayOfWeek\(value: number\): void - -Sets the start day of a week for this **Calendar** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

number

-

No

-

Start day of a week. The value 1 indicates Sunday, and value 7 indicates Saturday.

-
+- Example + ``` + i18n.getSystemLocale(); + ``` -- Example - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setFirstDayOfWeek(0); - ``` +## i18n.getCalendar8+ +getCalendar(locale: string, type? : string): Calendar -### getMinimalDaysInFirstWeek8+ +Obtains a **Calendar** object. -getMinimalDaysInFirstWeek\(\): number +**System capability**: SystemCapability.Global.I18n -Obtains the minimum number of days in the first week of a year. +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| Valid locale value, for example, **zh-Hans-CN**.| + | type | string | No| Valid calendar type. Currently, the valid types are as follows: buddhist, chinese, coptic, ethiopic, hebrew, gregory, indian, islamic\_civil, islamic\_tbla, islamic\_umalqura, japanese, and persian. If this parameter is left unspecified, the default calendar type of the specified locale is used.| + +- Return value + | Type| Description| + | -------- | -------- | + | [Calendar](#calendar8) | **Calendar** object.| + +- Example + ``` + i18n.getCalendar("zh-Hans", "gregory"); + ``` + + +## Calendar8+ + + +### setTime8+ + +setTime(date: Date): void + +Sets the date for this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | date | Date | Yes| Date to be set for the **Calendar** object.| + +- Example + ``` + var calendar = I18n.getCalendar("en-US", "gregory"); + var date = new Date(2021, 10, 7, 8, 0, 0, 0); + calendar.setTime(date); + ``` + + +### setTime8+ + +setTime(time: number): void + +Sets the date and time for this **Calendar** object. The value is represented by the number of milliseconds that have elapsed since the Unix epoch (00:00:00 UTC on January 1, 1970). + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | time | number | Yes| Number of milliseconds that have elapsed since the Unix epoch.| + +- Example + ``` + var calendar = I18n.getCalendar("en-US", "gregory"); + calendar.setTime(10540800000); + ``` + + +### set8+ + +set(year: number, month: number, date:number, hour?: number, minute?: number, second?: number): void + +Sets the year, month, day, hour, minute, and second for this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | year | number | Yes| Year to set.| + | month | number | Yes| Month to set.| + | date | number | Yes| Day to set.| + | hour | number | No| Hour to set.| + | minute | number | No| Minute to set.| + | second | number | No| Second to set.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 + ``` + + +### setTimeZone8+ + +setTimeZone(timezone: string): void + +Sets the time zone of this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | timezone | string | Yes| Time zone, for example, **Asia/Shanghai**.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setTimeZone("Asia/Shanghai"); + ``` + + +### getTimeZone8+ + +getTimeZone(): string + +Obtains the time zone of this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | string | Time zone of the **Calendar** object.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setTimeZone("Asia/Shanghai"); + calendar.getTimeZone(); // Asia/Shanghai" + ``` + + +### getFirstDayOfWeek8+ + +getFirstDayOfWeek(): number + +Obtains the start day of a week for this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Start day of a week. The value **1** indicates Sunday, and value **7** indicates Saturday.| + +- Example + ``` + var calendar = I18n.getCalendar("en-US", "gregory"); + calendar.getFirstDayOfWeek(); + ``` + + +### setFirstDayOfWeek8+ + +setFirstDayOfWeek(value: number): void + +Sets the start day of a week for this **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | value | number | No| Start day of a week. The value **1** indicates Sunday, and value **7** indicates Saturday.| -- Return values +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setFirstDayOfWeek(0); + ``` - - - - - - - - - -

Type

-

Description

-

number

-

Minimum number of days in the first week of a year.

-
-- Example +### getMinimalDaysInFirstWeek8+ - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.getMinimalDaysInFirstWeek(); - ``` +getMinimalDaysInFirstWeek(): number + +Obtains the minimum number of days in the first week of a year. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Minimum number of days in the first week of a year.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.getMinimalDaysInFirstWeek(); + ``` -### setMinimalDaysInFirstWeek8+ +### setMinimalDaysInFirstWeek8+ -setMinimalDaysInFirstWeek\(value: number\): void +setMinimalDaysInFirstWeek(value: number): void Sets the minimum number of days in the first week of a year. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

number

-

No

-

Minimum number of days in the first week of a year.

-
- -- Example - - ``` - var calendar = i18n.getCalendar("zh-Hans"); - calendar.setMinimalDaysInFirstWeek(3); - ``` - - -### get8+ - -get\(field: string\): number - -Obtains the value of the specified field in the **Calendar** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

field

-

string

-

Yes

-

Value of the specified field in the Calendar object. Currently, the valid fields are as follows: era, year, month, week_of_year, week_of_month, date, day_of_year, day_of_week, day_of_week_in_month, hour, hour_of_day, minute, second, millisecond, zone_offset, dst_offset, year_woy, dow_local, extended_year, julian_day, milliseconds_in_day, and is_leap_month.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Value of the specified field. For example, if the year in the internal date of this Calendar object is 1990, the get("year") function will return 1990.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 - calendar.get("hour_of_day"); // 8 - ``` - - -### getDisplayName8+ - -getDisplayName\(locale: string\): string - -Obtains the name of the **Calendar** object displayed for the specified locale. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

Locale for which the name of the Calendar object is displayed. For example, if locale is en-US, the name of the Buddhist calendar will be Buddhist Calendar.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Name of the Calendar object displayed for the specified locale.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("en-US", "buddhist"); - calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh. - ``` - - -### isWeekend8+ - -isWeekend\(date?: Date\): boolean - -Checks whether the specified date in this **Calendar** object is a weekend. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

date

-

Date

-

No

-

Specified date in this Calendar object. If this parameter is left unspecified, the system checks whether the current date in the Calendar object is a weekend.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the date is a weekend, and value false indicates a weekday.

-
- -- Example - - ``` - var calendar = I18n.getCalendar("zh-Hans"); - calendar.setTime(2021, 11, 11, 8, 0, 0); // Set the time to 2021.11.11 08:00:00. - calendar.isWeekend(); // false - var date = new Date(2011, 11, 6, 9, 0, 0); - calendar.isWeekend(date); // true - ``` - - -## PhoneNumberFormat8+ - -### constructor8+ - -constructor\(country: string, options?: PhoneNumberFormatOptions\) - -Creates a **PhoneNumberFormat** object. +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | value | number | No| Minimum number of days in the first week of a year.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setMinimalDaysInFirstWeek(3); + ``` + + +### get8+ + +get(field: string): number + +Obtains the value of the specified field in the **Calendar** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | field | string | Yes| Value of the specified field in the **Calendar** object. Currently, a valid field can be any of the following: era, year, month, week\_of\_year, week\_of\_month, date, day\_of\_year, day\_of\_week, day\_of\_week\_in\_month, hour, hour\_of\_day, minute, second, millisecond, zone\_offset, dst\_offset, year\_woy, dow\_local, extended\_year, julian\_day, milliseconds\_in\_day, is\_leap\_month.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | Value of the specified field. For example, if the year in the internal date of this **Calendar** object is **1990**, the **get("year")** function will return **1990**.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setTime(2021, 10, 1, 8, 0, 0); // set time to 2021.10.1 08:00:00 + calendar.get("hour_of_day"); // 8 + ``` + + +### getDisplayName8+ + +getDisplayName(locale: string): string + +Obtains the name of the **Calendar** object displayed for the specified locale. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| Locale for which the name of the **Calendar** object is displayed. For example, if **locale** is **en-US**, the name of the Buddhist calendar will be **Buddhist Calendar**.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Name of the **Calendar** object displayed for the specified locale.| + +- Example + ``` + var calendar = i18n.getCalendar("en-US", "buddhist"); + calendar.getDisplayName("zh"); // Obtain the name of the Buddhist calendar in zh. + ``` + + +### isWeekend8+ + +isWeekend(date?: Date): boolean + +Checks whether the specified date in this **Calendar** object is a weekend. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | date | Date | No| Specified date in this **Calendar** object. If this parameter is left unspecified, the system checks whether the current date in the **Calendar** object is a weekend.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the date is a weekend, and value **false** indicates a weekday.| + +- Example + ``` + var calendar = i18n.getCalendar("zh-Hans"); + calendar.setTime(2021, 11, 11, 8, 0, 0); // set time to 2021.11.11 08:00:00 + calendar.isWeekend(); // false + var date = new Date(2011, 11, 6, 9, 0, 0); + calendar.isWeekend(date); // true + ``` + + +## PhoneNumberFormat8+ + + +### constructor8+ + +constructor(country: string, options?: PhoneNumberFormatOptions) + +Creates a **PhoneNumberFormat** object. + +**System capability**: SystemCapability.Global.I18n Parameters +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| country | string | Yes| Country or region to which the phone number to be formatted belongs.| +| options | [PhoneNumberFormatOptions](#phonenumberformatoptions8) | No| Options of the **PhoneNumberFormat** object.| - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

country

-

string

-

Yes

-

Country or region to which the phone number to be formatted belongs.

-

options

-

PhoneNumberFormatOptions

-

No

-

Options of the PhoneNumberFormat object.

-
- -- Example - - ``` - var phoneNumberFormat= new I18n.PhoneNumberFormat("CN", {"type": "E164"}); - ``` - - -### isValidNumber8+ - -isValidNumber\(number: string\): boolean +- Example + ``` + var phoneNumberFormat= new i18n.PhoneNumberFormat("CN", {"type": "E164"}); + ``` + + +### isValidNumber8+ + +isValidNumber(number: string): boolean Checks whether the format of the specified phone number is valid. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

number

-

string

-

Yes

-

Phone number to be checked.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates the phone number format is valid, and value false indicates the opposite.

-
- - -- Example - - ``` - var phonenumberfmt = new I18n.PhoneNumberFormat("CN"); - phonenumberfmt.isValidNumber("15812312312"); - ``` - - -### format8+ - -format\(number: string\): string +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | number | string | Yes| Phone number to be checked.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates the phone number format is valid, and value **false** indicates the opposite.| + +- Example + ``` + var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); + phonenumberfmt.isValidNumber("15812312312"); + ``` + + +### format8+ + +format(number: string): string Formats a phone number. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

number

-

string

-

Yes

-

Phone number to be formatted.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Formatted phone number.

-
- - -- Example - - ``` - var phonenumberfmt = new I18n.PhoneNumberFormat("CN"); - phonenumberfmt.format("15812312312"); - ``` - - -## PhoneNumberFormatOptions8+ - -Defines the options for this **PhoneNumberFormat** object. - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

type

-

string

-

Yes

-

Yes

-

Format type of a phone number. The available options are as follows: E164, INTERNATIONAL, NATIONAL, and RFC3966.

-
- -## UnitInfo8+ +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | number | string | Yes| Phone number to be formatted.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Formatted phone number.| + +- Example + ``` + var phonenumberfmt = new i18n.PhoneNumberFormat("CN"); + phonenumberfmt.format("15812312312"); + ``` + + +## PhoneNumberFormatOptions8+ + +Defines the options for this PhoneNumberFormat object. + + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| type | string | Yes| Yes| Format type of a phone number. The value can be **E164**, **INTERNATIONAL**, **NATIONAL**, or **RFC3966**.
**System capability**: SystemCapability.Global.I18n| + + +## UnitInfo8+ Defines the measurement unit information. - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Readable

-

Writable

-

Description

-

unit

-

string

-

Yes

-

Yes

-

Name of the measurement unit, for example, meter, inch, or cup.

-

measureSystem

-

string

-

Yes

-

Yes

-

Measurement system. The value can be SI, US, or UK.

-
- -## Util8+ - -### unitConvert8+ - -unitConvert\(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string\): string + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| unit | string | Yes| Yes| Name of the measurement unit, for example, **meter**, **inch**, or **cup**.| +| measureSystem | string | Yes| Yes| Measurement system. The value can be **SI**, **US**, or **UK**.
**System capability**: SystemCapability.Global.I18n| + + +## Util8+ + + +### unitConvert8+ + +unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, style?: string): string Converts one measurement unit into another and formats the unit based on the specified locale and style. -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

fromUnit

-

UnitInfo

-

Yes

-

Measurement unit to be converted.

-

toUnit

-

UnitInfo

-

Yes

-

Measurement unit to be converted to.

-

value

-

number

-

Yes

-

Value of the measurement unit to be converted.

-

locale

-

string

-

Yes

-

Locale used for formatting, for example, zh-Hans-CN.

-

style

-

string

-

No

-

Style used for formatting. The value can be long, short, or medium.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Character string obtained after formatting based on the measurement unit specified by toUnit.

-
- - -- Example - - ``` - I18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long"); - ``` - - -## i18n.getInstance8+ - -getInstance\(locale?: string\): IndexUtil - -Creates an **IndexUtil** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

No

-

A string containing locale information, including the language, optional script, and region.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

IndexUtil

-

IndexUtil object mapping to the specified locale.

-
- - -- Example - - ``` - var indexUtil= I18n.getInstance("zh-CN"); - ``` - - -## IndexUtil8+ - -### getIndexList8+ - -getIndexList\(\): Array - -Obtains the index list for this **locale** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

Array<string>

-

Index list for this locale.

-
- - -- Example - - ``` - var indexUtil = i18n.getInstance("zh-CN"); - var indexList = indexUtil.getIndexList(); - ``` - - -### addLocale8+ - -addLocale\(locale: string\) - -Adds the index of the new **locale** object to the index list. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

A string containing locale information, including the language, optional script, and region.

-
- - -- Example - - ``` - var indexUtil = i18n.getInstance("zh-CN"); - indexUtil.addLocale("en-US"); - ``` - - -### getIndex8+ - -getIndex\(text: string\): string - -Obtains the index of a **text** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

text

-

string

-

Yes

-

text object whose index is to be obtained.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Index of the text object.

-
- - -- Example - - ``` - var indexUtil= i18n.getInstance("zh-CN"); - indexUtil.getIndex("hi"); // Return h. - ``` - - -## Character8+ - -### isDigit8+ - -isDigit\(char: string\): boolean - -Checks whether the input character is a digit. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is a digit, and value false indicates the opposite.

-
- - -- Example - - ``` - var isdigit = Character.isDigit("1"); // Return true. - ``` - - -### isSpaceChar8+ - -isSpaceChar\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | fromUnit | [UnitInfo](#unitinfo8) | Yes| Measurement unit to be converted.| + | toUnit | [UnitInfo](#unitinfo8) | Yes| Measurement unit to be converted to.| + | value | number | Yes| Value of the measurement unit to be converted.| + | locale | string | Yes| Locale used for formatting, for example, **zh-Hans-CN**.| + | style | string | No| Style used for formatting. The value can be **long**, **short**, or **medium**.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Character string obtained after formatting based on the measurement unit specified by **toUnit**.| + +- Example + ``` + I18n.Util.unitConvert({unit: "cup", measureSystem: "US"}, {unit: "liter", measureSystem: "SI"}, 1000, "en-US", "long"); + ``` + + +## IndexUtil8+ + + +### getInstance8+ + +getInstance(): IndexUtil + +Creates an **IndexUtil** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | No| A string containing locale information, including the language, optional script, and region.| + +- Return value + | Type| Description| + | -------- | -------- | + | [IndexUtil](#indexutil8) | **IndexUtil** object mapping to the specified locale.| + +- Example + ``` + var indexUtil= i18n.IndexUtil.getInstance("zh-CN"); + ``` + + +### getIndexList8+ + +getIndexList(): Array<string> + +Obtains the index list for this **locale** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | Array<string> | Index list for this **locale** object.| + +- Example + ``` + var indexUtil = i18n.getInstance("zh-CN"); + var indexList = indexUtil.getIndexList(); + ``` + + +### addLocale8+ + +addLocale(locale: string) + +Adds the index of the new **locale** object to the index list. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| A string containing locale information, including the language, optional script, and region.| + +- Example + ``` + var indexUtil = i18n.getInstance("zh-CN"); + indexUtil.addLocale("en-US"); + ``` + + +### getIndex8+ + +getIndex(text: string): string + +Obtains the index of a text object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | text | string | Yes| **text** object whose index is to be obtained.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Index of the **text** object.| + +- Example + ``` + var indexUtil= i18n.getInstance("zh-CN"); + indexUtil.getIndex("hi"); // Return h. + ``` + + +## Character8+ + + +### isDigit8+ + +isDigit(char: string): boolean + +Checks whether the input character string is composed of digits. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is a digit, and value **false** indicates the opposite.| + +- Example + ``` + var isdigit = Character.isDigit("1"); // Return true. + ``` + + +### isSpaceChar8+ + +isSpaceChar(char: string): boolean Checks whether the input character is a space. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is a space, and value false indicates the opposite.

-
- - -- Example - - ``` - var isspacechar = Character.isSpaceChar("a"); // Return false. - ``` - - -### isWhitespace8+ - -isWhitespace\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is a space, and value **false** indicates the opposite.| + +- Example + ``` + var isspacechar = Character.isSpaceChar("a"); // Return false. + ``` + + +### isWhitespace8+ + +isWhitespace(char: string): boolean Checks whether the input character is a white space. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is a white space, and value false indicates the opposite.

-
- - -- Example - - ``` - var iswhitespace = Character.isWhitespace("a"); // Return false. - ``` - - -### isRTL8+ - -isRTL\(char: string\): boolean - -Checks whether the input character is of the right to left \(RTL\) language. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is of the RTL language, and value false indicates the opposite.

-
- - -- Example - - ``` - var isrtl = Character.isRTL("a"); // Return false. - ``` - - -### isIdeograph8+ - -isIdeograph\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is a white space, and value **false** indicates the opposite.| + +- Example + ``` + var iswhitespace = Character.isWhitespace("a"); // Return false. + ``` + + +### isRTL8+ + +isRTL(char: string): boolean + +Checks whether the input character is of the right to left (RTL) language. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is of the RTL language, and value **false** indicates the opposite.| + +- Example + ``` + var isrtl = Character.isRTL("a"); // Return false. + ``` + + +### isIdeograph8+ + +isIdeograph(char: string): boolean Checks whether the input character is an ideographic character. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is an ideographic character, and value false indicates the opposite.

-
- - -- Example - - ``` - var isideograph = Character.isIdeograph("a"); // Return false. - ``` - - -### isLetter8+ - -isLetter\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is an ideographic character, and value **false** indicates the opposite.| + +- Example + ``` + var isideograph = Character.isIdeograph("a"); // Return false. + ``` + + +### isLetter8+ + +isLetter(char: string): boolean Checks whether the input character is a letter. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is a letter, and value false indicates the opposite.

-
- - -- Example - - ``` - var isletter = Character.isLetter("a"); // Return true. - ``` - - -### isLowerCase8+ - -isLowerCase\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is a letter, and value **false** indicates the opposite.| + +- Example + ``` + var isletter = Character.isLetter("a"); // Return true. + ``` + + +### isLowerCase8+ + +isLowerCase(char: string): boolean Checks whether the input character is a lowercase letter. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is a lowercase letter, and value false indicates the opposite.

-
- - -- Example - - ``` - var islowercase = Character.isLowerCase("a"); // Return true. - ``` - - -### isUpperCase8+ - -isUpperCase\(char: string\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the input character is a lowercase letter, and value **false** indicates the opposite.| + +- Example + ``` + var islowercase = Character.isLowerCase("a"); // Return true. + ``` + + +### isUpperCase8+ + +isUpperCase(char: string): boolean Checks whether the input character is an uppercase letter. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the input character is an uppercase letter, and value false indicates the opposite.

-
- - -- Example - - ``` - var isuppercase = Character.isUpperCase("a"); // Return false. - ``` - - -### getType8+ - -getType\(char: string\): string +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value true indicates that the input character is an uppercase letter, and value false indicates the opposite.| + +- Example + ``` + var isuppercase = Character.isUpperCase("a"); // Return false. + ``` + + +### getType8+ + +getType(char: string): string Obtains the type of the input character string. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

char

-

string

-

Yes

-

Input character.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Type of the input character.

-
- - -- Example - - ``` - var type = Character.getType("a"); - ``` - - -## i18n.getLineInstance8+ - -getLineInstance\(locale: string\): BreakIterator - -Obtains a [BreakIterator](#section1312302611613) object for text segmentation. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

Valid locale value, for example, zh-Hans-CN. The BreakIterator object segments text according to the rules of the specified locale.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

BreakIterator

-

Break iterator used for text segmentation.

-
- -- Example - - ``` - I18n.getLineInstance("en"); - ``` - - -## BreakIterator8+ - -### setLineBreakText8+ - -setLineBreakText\(text: string\): void - -Sets the text to be processed by the [BreakIterator](#section1312302611613) object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

text

-

string

-

Yes

-

Text to be processed by the BreakIterator object.

-
- +**System capability**: SystemCapability.Global.I18n -- Example +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | char | string | Yes| Input character.| - ``` - var iterator = I18n.getLineInstance("en"); - var iterator.setLineBreakText("Apple is my favorite fruit."); - ``` - - -### getLineBreakText8+ +- Return value + | Type| Description| + | -------- | -------- | + | string | Type of the input character.| -getLineBreakText\(\): string - -Obtains the text being processed by the [BreakIterator](#section1312302611613) object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Text being processed by the BreakIterator object.

-
- - -- Example +- Example + ``` + var type = Character.getType("a"); + ``` - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.getLineBreakText(); // Apple is my favorite fruit. - ``` +## i18n.getLineInstance8+ -### current8+ +getLineInstance(locale: string): BreakIterator -current\(\): number +Obtains a [BreakIterator](#breakiterator8) object for text segmentation. -Obtains the position of the [BreakIterator](#section1312302611613) object in the text being processed. +**System capability**: SystemCapability.Global.I18n -- Return values +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| Valid locale value, for example, **zh-Hans-CN**. The [BreakIterator](#breakiterator8) object segments text according to the rules of the specified locale.| - - - - - - - - - -

Type

-

Description

-

number

-

Position of the BreakIterator object in the text being processed.

-
+- Return value + | Type| Description| + | -------- | -------- | + | [BreakIterator](#breakiterator8) | [BreakIterator](#breakiterator8) object used for text segmentation.| +- Example + ``` + i18n.getLineInstance("en"); + ``` -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - breakIter.current(); // 0 - ``` +## BreakIterator8+ -### first8+ - -first\(\): number - -Puts the [BreakIterator](#section1312302611613) object to the first text boundary, which is always at the beginning of the processed text. - -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Offset to the first text boundary of the processed text.

-
+### setLineBreakText8+ -- Example +setLineBreakText(text: string): void - ``` - iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - breakIter.first(); // 0 - ``` +Sets the text to be processed by the [BreakIterator](#breakiterator8) object. +**System capability**: SystemCapability.Global.I18n -### last8+ +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | text | string | Yes| Text to be processed by the **BreakIterator** object.| -last\(\): number +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + ``` -Puts the [BreakIterator](#section1312302611613) object to the last text boundary, which is always the next position after the end of the processed text. -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Offset of the last text boundary of the processed text.

-
+### getLineBreakText8+ +getLineBreakText(): string -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.last(); // 27 - ``` +Obtains the text being processed by the [BreakIterator](#breakiterator8) object. +**System capability**: SystemCapability.Global.I18n -### next8+ +- Return value + | Type| Description| + | -------- | -------- | + | string | Text being processed by the **BreakIterator** object.| -next\(index?: number\): number +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.getLineBreakText(); // Apple is my favorite fruit. + ``` -Moves the [BreakIterator](#section1312302611613) object backward by the specified number of text boundaries if the specified index is a positive number. If the index is a negative number, the [BreakIterator](#section1312302611613) object will be moved forward by the corresponding number of text boundaries. If no index is specified, the index will be treated as **1**. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

index

-

number

-

No

-

Number of text boundaries by which the BreakIterator object is moved. A positive value indicates that the text boundary is moved backward, and a negative value indicates the opposite. If no index is specified, the index will be treated as 1.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Position of the BreakIterator object in the text after it is moved by the specified number of text boundaries. The value -1 is returned if the position of the BreakIterator object is outside of the processed text after it is moved by the specified number of text boundaries.

-
- - -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.first(); // 0 - iterator.next(); // 6 - iterator.next(10); // -1 - ``` - - -### previous8+ - -previous\(\): number - -Moves the [BreakIterator](#section1312302611613) object to the previous text boundary. - -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Position of the BreakIterator object in the text after it is moved to the previous text boundary. The value -1 is returned if the position of the BreakIterator object is outside of the processed text after it is moved by the specified number of text boundaries.

-
- - -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.first(); // 0 - iterator.next(3); // 12 - iterator.previous(); // 9 - ``` - - -### following8+ - -following\(offset: number\): number - -Moves the [BreakIterator](#section1312302611613) object to the text boundary after the position specified by the offset. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

offset

-

number

-

Yes

-

Offset to the position before the text boundary to which the BreakIterator object is moved.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

The value -1 is returned if the text boundary to which the BreakIterator object is moved is outside of the processed text.

-
- - -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.following(0); // 6 - iterator.following(100); // -1 - iterator.current(); // 27 - ``` - - -### isBoundary8+ - -isBoundary\(offset: number\): boolean - -Checks whether the position specified by the offset is a text boundary. If **true** is returned, the [BreakIterator](#section1312302611613) object is moved to the position specified by the offset. If **false** is returned, the [BreakIterator](#section1312302611613) object is moved to the text boundary after the position specified by the offset, which is equivalent to calling [following\(offset\)](#section1743155314301). - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

offset

-

number

-

Yes

-

Position to check.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the position specified by the offset is a text boundary, and value false indicates the opposite.

-
- - -- Example - - ``` - var iterator = I18n.getLineInstance("en"); - iterator.setLineBreakText("Apple is my favorite fruit."); - iterator.isBoundary(0); // true; - iterator.isBoundary(5); // false; - ``` - - -## i18n.is24HourClock8+ - -is24HourClock\(\): boolean +### current8+ -Checks whether the 24-hour clock is used. +current(): number + +Obtains the position of the [BreakIterator](#breakiterator8) object in the text being processed. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Position of the **BreakIterator** object in the text being processed.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + breakIter.current(); // 0 + ``` + + +### first8+ + +first(): number + +Puts the [BreakIterator](#breakiterator8) object to the first text boundary, which is always at the beginning of the processed text. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Offset to the first text boundary of the processed text.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + breakIter.first(); // 0 + ``` + + +### last8+ + +last(): number + +Puts the [BreakIterator](#breakiterator8) object to the last text boundary, which is always the next position after the end of the processed text. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Offset of the last text boundary of the processed text.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.last(); // 27 + ``` + + +### next8+ + +next(index?: number): number + +Moves the [BreakIterator](#breakiterator8) object backward by the specified number of text boundaries if the specified index is a positive number. If the index is a negative number, the [BreakIterator](#breakiterator8) object will be moved forward by the corresponding number of text boundaries. If no index is specified, the index will be treated as **1**. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | index | number | No| Number of text boundaries by which the [BreakIterator](#breakiterator8) object is moved. A positive value indicates that the text boundary is moved backward, and a negative value indicates the opposite. If no index is specified, the index will be treated as **1**.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved by the specified number of text boundaries. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.first(); // 0 + iterator.next(); // 6 + iterator.next(10); // -1 + ``` + + +### previous8+ + +previous(): number + +Moves the [BreakIterator](#breakiterator8) object to the previous text boundary. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | number | Position of the [BreakIterator](#breakiterator8) object in the text after it is moved to the previous text boundary. The value **-1** is returned if the position of the [BreakIterator](#breakiterator8) object is outside of the processed text after it is moved by the specified number of text boundaries.| -- Return values +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.first(); // 0 + iterator.next(3); // 12 + iterator.previous(); // 9 + ``` - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the 24-hour clock is used, and value false indicates the opposite.

-
+### following8+ -- Example +following(offset: number): number - ``` - var is24HourClock = i18n.is24HourClock(); - ``` +Moves the [BreakIterator](#breakiterator8) object to the text boundary after the position specified by the offset. Position of the [BreakIterator](#breakiterator8) object after it is moved to the text boundary after the position specified by the offset. +**System capability**: SystemCapability.Global.I18n -## i18n.set24HourClock8+ +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | offset | number | Yes| Offset to the position before the text boundary to which the [BreakIterator](#breakiterator8) object is moved.| -set24HourClock\(option: boolean\): boolean +- Return value + | Type| Description| + | -------- | -------- | + | number | The value **-1** is returned if the text boundary to which the [BreakIterator](#breakiterator8) object is moved is outside of the processed text.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.following(0); // 6 + iterator.following(100); // -1 + iterator.current(); // 27 + ``` + + +### isBoundary8+ + +isBoundary(offset: number): boolean + +Checks whether the position specified by the offset is a text boundary. If **true** is returned, the [BreakIterator](#breakiterator8) object is moved to the position specified by the offset. If **false** is returned, the [BreakIterator](#breakiterator8) object is moved to the text boundary after the position specified by the offset, which is equivalent to calling [following](#following8)(offset). + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | offset | number | Yes| Position to check.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the position specified by the offset is a text boundary, and value **false** indicates the opposite.| + +- Example + ``` + iterator = I18n.getLineInstance("en"); + iterator.setLineBreakText("Apple is my favorite fruit."); + iterator.isBoundary(0); // true; + iterator.isBoundary(5); // false; + ``` + + +## i18n.is24HourClock8+ + +is24HourClock(): boolean + +Checks whether the 24-hour clock is used. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the 24-hour clock is used, and value **false** indicates the opposite.| + +- Example + ``` + var is24HourClock = i18n.is24HourClock(); + ``` + + +## i18n.set24HourClock8+ + +set24HourClock(option: boolean): boolean Sets the 24-hour clock. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

option

-

boolean

-

Yes

-

Whether to enable the 24-hour clock. The value true means to enable the 24-hour clock, and value false means the opposite.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the 24-hour clock is enabled, and value false indicates the opposite.

-
- - -- Example - - ``` - // Set the system time to the 24-hour format. - var success = I18n.set24HourClock(true); - ``` - - -## i18n.addPreferredLanguage8+ - -addPreferredLanguage\(language: string, index?: number\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | option | boolean | Yes| Whether to enable the 24-hour clock. The value **true** means to enable the 24-hour clock, and value **false** means the opposite.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the 24-hour clock is enabled, and value **false** indicates the opposite.| + +- Example + ``` + // Set the system time to the 24-hour clock. + var success = I18n.set24HourClock(true); + ``` + + +## i18n.addPreferredLanguage8+ + +addPreferredLanguage(language: string, index?: number): boolean Adds a preferred language to the specified position on the preferred language list. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

language

-

string

-

Yes

-

Preferred language to add.

-

index

-

number

-

No

-

Position to which the preferred language is added.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the preferred language is added, and value false indicates the opposite.

-
- - -- Example - - ``` - // Add zh-CN to the preferred language list. - var language = 'zh-CN'; - var index = 0; - var success = i18n.addPreferredLanguage(langauge, index); - ``` - - -## i18n.removePreferredLanguage8+ - -removePreferredLanguage\(index: number\): boolean +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | language | string | Yes| Preferred language to add.| + | index | number | No| Position to which the preferred language is added.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the preferred language is successfully added, and value **false** indicates the opposite.| + +- Example + ``` + // Add zh-CN to the preferred language list. + var language = 'zh-CN'; + var index = 0; + var success = i18n.addPreferredLanguage(language, index); + ``` + + +## i18n.removeDisplayLanguage8+ + +removeDisplayLanguage(index: number): boolean Deletes a preferred language from the specified position on the preferred language list. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

index

-

number

-

Yes

-

Position of the preferred language to delete.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

The value true indicates that the preferred language is deleted, and value false indicates the opposite.

-
- - -- Example - - ``` - // Delete the first preferred language from the preferred language list. - var index = 0; - var success = i18n.removePreferredLanguage(index); - ``` - - -## i18n.getPreferredLanguageList8+ - -getPreferredLanguageList\(\): Array +**System capability**: SystemCapability.Global.I18n -Obtains the preferred language list. +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | index | number | Yes| Position of the preferred language to delete.| -- Return values +- Return value + | Type| Description| + | -------- | -------- | + | boolean | The value **true** indicates that the preferred language is deleted, and value **false** indicates the opposite.| - - - - - - - - - -

Type

-

Description

-

Array<string>

-

Preferred language list.

-
+- Example + ``` + // Delete the first preferred language from the preferred language list. + var index = 0; + var success = i18n.removePreferredLanguage(index); + ``` -- Example +## i18n.getPreferredLanguageList8+ - ``` - var preferredLanguageList = i18n.getPreferredLanguageList(); - ``` +getPreferredLanguageList(): Array +Obtains the preferred language list. -## i18n.getFirstPreferredLanguage8+ +**System capability**: SystemCapability.Global.I18n -getFirstPreferredLanguage\(\): string +- Return value + | Type| Description| + | -------- | -------- | + | Array | Preferred language list.| -Obtains the preferred language that best matches the HAP resource. +- Example + ``` + var preferredLanguageList = i18n.getPreferredLanguageList(); + ``` -- Return values - - - - - - - - - -

Type

-

Description

-

string

-

Preferred language that best matches the HAP resource.

-
+## i18n.getFirstPreferredLanguage8+ +getFirstPreferredLanguage(): string + +Obtains the preferred language that best matches the HAP resource. -- Example +**System capability**: SystemCapability.Global.I18n - ``` - var firstPreferredLangauge = i18n.getFirstPreferredLangauge(); - ``` +- Return value + | Type| Description| + | -------- | -------- | + | string | Preferred language that best matches the HAP resource.| +- Example + ``` + var firstPreferredLanguage = i18n.getFirstPreferredLanguage(); + ``` diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md index f18b8b8bf316bb4b680d03cef06dbcd19e14bbfe..719154b9fcaf6c484cdf5b7c195be310d1c96c0e 100644 --- a/en/application-dev/reference/apis/js-apis-intl.md +++ b/en/application-dev/reference/apis/js-apis-intl.md @@ -1,1996 +1,681 @@ -# Internationalization (intl) +# Internationalization – intl ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ->- This module contains standard i18n APIs, which are defined in ECMA 402. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> - This module contains standard i18n APIs, which are defined in ECMA 402. -## Modules to Import + +## Modules to Import ``` import Intl from '@ohos.intl'; ``` -## Required Permissions - -None - -## Locale - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

language

-

string

-

Yes

-

No

-

Language associated with the locale, for example, zh.

-

script

-

string

-

Yes

-

No

-

Script type of the language, for example, Hans.

-

region

-

string

-

Yes

-

No

-

Region associated with the locale, for example, CN.

-

baseName

-

string

-

Yes

-

No

-

Basic key information about the locale, which consists of the language, script, and region, for example, zh-Hans-CN.

-

caseFirst

-

string

-

Yes

-

No

-

Whether case is taken into account for the locale's collation rules. The value can be upper, lower, or false.

-

calendar

-

string

-

Yes

-

No

-

Calendar for the locale. The value can be buddhist, chinese, coptic, dangi, ethioaa, ethiopic, gregory, hebrew, indian, islamic, islamic-umalqura, islamic-tbla, islamic-civil, islamic-rgsa, iso8601, japanese, persian, roc, or islamicc.

-

collation

-

string

-

Yes

-

No

-

Collation rules for the locale. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, and zhuyin.

-

hourCycle

-

string

-

Yes

-

No

-

Time system for the locale. The value can be h11, h12, h23, or h24.

-

numberingSystem

-

string

-

Yes

-

No

-

Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, and wcho.

-

numeric

-

boolean

-

Yes

-

No

-

Whether to apply special collation rules for numeric characters.

-
- -### constructor - -constructor\(locale: string, options?: options\) - -Creates a **Locale** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-
- - -- Example - - ``` - var locale = new Intl.Locale("zh-CN"); - ``` - - -### toString - -toString\(\): string + +## Locale + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| language | string | Yes| No| Language associated with the locale, for example, **zh**.
**System capability**: SystemCapability.Global.I18n| +| script | string | Yes| No| Script type of the language, for example, **Hans**.
**System capability**: SystemCapability.Global.I18n| +| region | string | Yes| No| Region associated with the locale, for example, **CN**.
**System capability**: SystemCapability.Global.I18n| +| baseName | string | Yes| No| Basic key information about the locale, which consists of the language, script, and region, for example, **zh-Hans-CN**.
**System capability**: SystemCapability.Global.I18n| +| caseFirst | string | Yes| No| Whether case is taken into account for the locale's collation rules. The value can be **upper**, **lower**, or **false**.
**System capability**: SystemCapability.Global.I18n| +| calendar | string | Yes| No| Calendar for the locale. The value can be any of the following: buddhist, chinese, coptic, dangi, ethioaa, ethiopic, gregory, hebrew, indian, islamic, islamic-umalqura, islamic-tbla, islamic-civil, islamic-rgsa, iso8601, japanese, persian, roc, islamicc.
**System capability**: SystemCapability.Global.I18n| +| collation | string | Yes| No| Rule for sorting regions. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, zhuyin.
**System capability**: SystemCapability.Global.I18n| +| hourCycle | string | Yes| No| Time system for the locale. The value can be any of the following: h12, h23, h11, and h24.
**System capability**: SystemCapability.Global.I18n| +| numberingSystem | string | Yes| No| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.
**System capability**: SystemCapability.Global.I18n| +| numeric | boolean | Yes| No| Whether to apply special collation rules for numeric characters.
**System capability**: SystemCapability.Global.I18n| + + +### constructor + +constructor(locale: string, options?: options) + +Creates a Locale object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| A string containing locale information, including the language, optional script, and region.| + | options | options | No| Options for creating the **Locale** object.| + +- Example + ``` + var locale = new Intl.Locale("zh-CN"); + ``` + + +### toString + +toString(): string Converts locale information to a string. -- Return values +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | string | String containing locale information.| + +- Example + ``` + var locale = new Intl.Locale("zh-CN"); + locale.toString(); + ``` + + +### maximize + +maximize(): Locale + +Maximizes information of the **Locale** object. If the script and locale information is missing, add the information. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | [Locale](#locale) | **Locale** object with the maximized information.| + +- Example + ``` + var locale = new Intl.Locale("zh-CN"); + locale.maximize(); + ``` + - - - - - - - - - -

Type

-

Description

-

string

-

String containing locale information.

-
+### minimize +minimize(): Locale -- Example +Minimizes information of the **Locale** object. If the script and locale information is present, delete the information. - ``` - var locale = new Intl.Locale("zh-CN"); - locale.toString(); - ``` - - -### maximize - -maximize\(\): Locale - -Maximizes information of the **Locale** object. If the script and locale information is missing, add the information. - -- Return values - - - - - - - - - - -

Type

-

Description

-

Locale

-

Locale object with the maximized information.

-
+**System capability**: SystemCapability.Global.I18n +- Return value + | Type| Description| + | -------- | -------- | + | [Locale](#locale) | **Locale** object with the minimized information.| -- Example +- Example + ``` + var locale = new Intl.Locale("zh-CN"); + locale.minimize(); + ``` - ``` - var locale = new Intl.Locale("zh-CN"); - locale.maximize(); - ``` +## DateTimeFormat -### minimize - -minimize\(\): Locale - -Minimizes information of the **Locale** object. If the script and locale information is present, delete the information. - -- Return values - - - - - - - - - - -

Type

-

Description

-

Locale

-

Locale object with the minimized information.

-
- - -- Example - - ``` - var locale = new Intl.Locale("zh-CN"); - locale.minimize(); - ``` - - -## DateTimeFormat - -### constructor - -constructor\(locale: string, options?: DateTimeOptions\) - -Creates a **DateTimeOptions** object for the specified locale. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

options

-

DateTimeOptions

-

No

-

Options for creating a DateTimeFormat object.

-
- - -- Example - - ``` - var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' }); - ``` - - -### constructor - -constructor\(locales: Array, options?: DateTimeOptions\) - -Creates a **DateTimeOptions** object for the specified array of locales. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locales

-

Array<string>

-

Yes

-

An array of strings containing locale information.

-

options

-

DateTimeOptions

-

No

-

Options for creating a DateTimeFormat object.

-
- - -- Example - - ``` - var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' }); - ``` - - -### format - -format\(date: Date\): string + +### constructor + +constructor(locale: string, options?: DateTimeOptions) + +Creates a **DateTimeOptions** object for the specified locale. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string | Yes| A string containing locale information, including the language, optional script, and region.| + | options | [DateTimeOptions](#datetimeoptions) | No| Options for creating a **DateTimeFormat** object.| + +- Example + ``` + var datefmt= new Intl.DateTimeFormat("zh-CN", { dateStyle: 'full', timeStyle: 'medium' }); + ``` + + +### constructor + +constructor(locales: Array<string>, options?: DateTimeOptions) + +Creates a **DateTimeOptions** object for the specified locale. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locales | Array<string> | Yes| An array of strings containing locale information.| + | options | [DateTimeOptions](#datetimeoptions) | No| Options for creating a **DateTimeFormat** object.| + +- Example + ``` + var datefmt= new Intl.DateTimeFormat(["ban", "zh"], { dateStyle: 'full', timeStyle: 'medium' }); + ``` + + +### format + +format(date: Date): string Formats the specified date and time. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

date

-

Date

-

Yes

-

Date and time to be formatted.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

A string containing the formatted date and time.

-
- - -- Example - - ``` - var date = new Date(2021, 11, 17, 3, 24, 0); - var datefmt = new Intl.DateTimeFormat("en-GB"); - datefmt.format(date); - ``` - - -### formatRange - -formatRange\(fromDate: Date, toDate: Date\): string +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | date | Date | Yes| Date and time to be formatted.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | A string containing the formatted date and time.| + +- Example + ``` + var date = new Date(2021, 11, 17, 3, 24, 0); + var datefmt = new Intl.DateTimeFormat("en-GB"); + datefmt.format(date); + ``` + + +### formatRange + +formatRange(fromDate: Date, toDate: Date): string Formats the specified date range. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

startDate

-

Date

-

Yes

-

Start date and time to be formatted.

-

endDate

-

Date

-

Yes

-

End date and time to be formatted.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

A string containing the formatted date and time range.

-
- - -- Example - - ``` - var startDate = new Date(2021, 11, 17, 3, 24, 0); - var endDate = new Date(2021, 11, 18, 3, 24, 0); - var datefmt = new Intl.DateTimeFormat("en-GB"); - datefmt.formatRange(startDate, endDate); - ``` - - -### resolvedOptions - -resolvedOptions\(\): DateTimeOptions - -Obtains the formatting options for **DateTimeFormat** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

DateTimeOptions

-

Formatting options for DateTimeFormat objects.

-
- - -- Example - - ``` - var datefmt = new Intl.DateTimeFormat("en-GB"); - datefmt.resolvedOptions(); - ``` - - -## DateTimeOptions - -Provides the options for the **DateTimeFormat** object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

locale

-

string

-

Yes

-

No

-

Locale, for example, zh-Hans-CN.

-

dateStyle

-

string

-

Yes

-

Yes

-

Date display format. The value can be long, short, medium, or full.

-

timeStyle

-

string

-

Yes

-

Yes

-

Time display format. The value can be long, short, medium, or full.

-

hourCycle

-

string

-

Yes

-

Yes

-

Time system for the locale. The value can be h11, h12, h23, or h24.

-

timeZone

-

string

-

Yes

-

Yes

-

Time zone represented by a valid IANA time zone ID.

-

numberingSystem

-

string

-

Yes

-

Yes

-

Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, and wcho.

-

hour12

-

boolean

-

Yes

-

Yes

-

Whether to use the 12-hour clock.

-

weekday

-

string

-

Yes

-

Yes

-

Workday display format. The value can be long, short, or narrow.

-

era

-

string

-

Yes

-

Yes

-

Era display format. The value can be long, short, or narrow.

-

year

-

string

-

Yes

-

Yes

-

Year display format. The value can be numeric or 2-digit.

-

month

-

string

-

Yes

-

Yes

-

Month display format. The value can be numeric, 2-digit, long, short, or narrow.

-

day

-

string

-

Yes

-

Yes

-

Day display format. The value can be numeric or 2-digit.

-

hour

-

string

-

Yes

-

Yes

-

Hour display format. The value can be numeric or 2-digit.

-

minute

-

string

-

Yes

-

Yes

-

Minute display format. The value can be numeric or 2-digit.

-

second

-

string

-

Yes

-

Yes

-

Second display format. The value can be numeric or 2-digit.

-

timeZoneName

-

string

-

Yes

-

Yes

-

Localized representation of a time zone name.

-

dayPeriod

-

string

-

Yes

-

Yes

-

Time period display format. The value can be long, short, or narrow.

-

localeMatcher

-

string

-

Yes

-

Yes

-

Locale matching algorithm. The value can be lookup or best fit.

-

formatMatcher

-

string

-

Yes

-

Yes

-

Format matching algorithm. The value can be basic or best fit.

-
- -## NumberFormat - -### constructor - -constructor\(locale: string, options?: NumberOptions\) - -Creates a **NumberFormat** object for the specified locale. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

options

-

NumberOptions

-

No

-

Options for creating a NumberFormat object.

-
- -- Example - - ``` - var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"}); - ``` - - -### constructor - -constructor\(locales: Array, options?: NumberOptions\) - -Creates a **NumberFormat** object for the specified array of locales. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locales

-

Array<string>

-

Yes

-

An array of strings containing locale information.

-

options

-

NumberOptions

-

No

-

Options for creating a NumberFormat object.

-
- - -- Example - - ``` - var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); - ``` - - -### format - -format\(number: number\): string; +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | startDate | Date | Yes| Start date and time to be formatted.| + | endDate | Date | Yes| End date and time to be formatted.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | A string containing the formatted date and time range.| + +- Example + ``` + var startDate = new Date(2021, 11, 17, 3, 24, 0); + var endDate = new Date(2021, 11, 18, 3, 24, 0); + var datefmt = new Intl.DateTimeFormat("en-GB"); + datefmt.formatRange(startDate, endDate); + ``` + + +### resolvedOptions + +resolvedOptions(): DateTimeOptions + +Obtains the formatting options for **DateTimeFormat** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | [DateTimeOptions](#datetimeoptions) | Formatting options for **DateTimeFormat** objects.| + +- Example + ``` + var datefmt = new Intl.DateTimeFormat("en-GB"); + datefmt.resolvedOptions(); + ``` + + +## DateTimeOptions + +Provides the options for the **DateTimeFormat** object. + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.
**System capability**: SystemCapability.Global.I18n| +| dateStyle | string | Yes| Yes| Date display format. The value can be **long**, **short**, **medium**, or **full**.
**System capability**: SystemCapability.Global.I18n| +| timeStyle | string | Yes| Yes| Time display format. The value can be **long**, **short**, **medium**, or **full**.
**System capability**: SystemCapability.Global.I18n| +| hourCycle | string | Yes| Yes| Time system for the locale. The value can be any of the following: h11, h12, h23, h24.
**System capability**: SystemCapability.Global.I18n| +| timeZone | string | Yes| Yes| Time zone represented by a valid IANA time zone ID.
**System capability**: SystemCapability.Global.I18n| +| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.
**System capability**: SystemCapability.Global.I18n| +| hour12 | boolean | Yes| Yes| Whether to use the 12-hour clock.
**System capability**: SystemCapability.Global.I18n| +| weekday | string | Yes| Yes| Workday display format. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| +| era | string | Yes| Yes| Era display format. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| +| year | string | Yes| Yes| Year display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| +| month | string | Yes| Yes| Month display format. The value can be any of the following: numeric, 2-digit, long, short, narrow.
**System capability**: SystemCapability.Global.I18n| +| day | string | Yes| Yes| Day display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| +| hour | string | Yes| Yes| Hour display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| +| minute | string | Yes| Yes| Minute display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| +| second | string | Yes| Yes| Seconds display format. The value can be **numeric** or **2-digit**.
**System capability**: SystemCapability.Global.I18n| +| timeZoneName | string | Yes| Yes| Localized representation of a time zone name.
**System capability**: SystemCapability.Global.I18n| +| dayPeriod | string | Yes| Yes| Time period display format. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| +| formatMatcher | string | Yes| Yes| Format matching algorithm. The value can be **basic** or **best fit**.
**System capability**: SystemCapability.Global.I18n| + + +## NumberFormat + + +### constructor + +constructor(locale: string, options?: NumberOptions) + +Creates a **NumberFormat** object for the specified locale. + +**System capability**: SystemCapability.Global.I18n + +Parameters +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| locale | string | Yes| A string containing locale information, including the language, optional script, and region.| +| options | [NumberOptions](#numberoptions) | No| Options for creating a **NumberFormat** object.| + +- Example + ``` + var numfmt = new Intl.NumberFormat("en-GB", {style:'decimal', notation:"scientific"}); + ``` + + +### constructor + +constructor(locales: Array<string>, options?: NumberOptions) + +Creates a **NumberFormat** object for the specified locale. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locales | Array<string> | Yes| An array of strings containing locale information.| + | options | [NumberOptions](#numberoptions) | No| Options for creating a **NumberFormat** object.| + +- Example + ``` + var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); + ``` + + +### format + +format(number: number): string; Formats a number. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

number

-

number

-

Yes

-

Number to be formatted.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Formatted number.

-
- - -- Example - - ``` - var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); - numfmt.format(1223); - ``` - - -### resolvedOptions - -resolvedOptions\(\): NumberOptions - -Obtains the options of the **NumberFormat** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

NumberOptions

-

Options of the NumberFormat object.

-
- - -- Example - - ``` - var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); - numfmt.resolvedOptions(); - ``` - - -## NumberOptions +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | number | number | Yes| Number to be formatted.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Formatted number.| + + +- Example + ``` + var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); + numfmt.format(1223); + ``` + + +### resolvedOptions + +resolvedOptions(): NumberOptions + +Obtains the options of the **NumberFormat** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | [NumberOptions](#numberoptions) | Formatting options for **NumberFormat** objects.| + + +- Example + ``` + var numfmt = new Intl.NumberFormat(["en-GB", "zh"], {style:'decimal', notation:"scientific"}); + numfmt.resolvedOptions(); + ``` + + +## NumberOptions Provides the device capability. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

locale

-

string

-

Yes

-

No

-

Locale, for example, zh-Hans-CN.

-

currency

-

string

-

Yes

-

Yes

-

Currency unit, for example, EUR, CNY, or USD.

-

currencySign

-

string

-

Yes

-

Yes

-

Currency unit symbol. The value can be symbol, narrowSymbol, code, or name.

-

currencyDisplay

-

string

-

Yes

-

Yes

-

Currency display mode. The value can be symbol, narrowSymbol, code, or name.

-

unit

-

string

-

Yes

-

Yes

-

Unit name, for example, meter, inch, or hectare.

-

unitDisplay

-

string

-

Yes

-

Yes

-

Unit display format. The value can be long, short, or medium.

-

unitUsage

-

string

-

Yes

-

Yes

-

Unit use case. The value can be any of the following: default, area-land-agricult, area-land-commercl, area-land-residntl, length-person, length-person-small, length-rainfall, length-road, length-road-small, length-snowfall, length-vehicle, length-visiblty, length-visiblty-small, length-person-informal, length-person-small-informal, length-road-informal, speed-road-travel, speed-wind, temperature-person, temperature-weather, and volume-vehicle-fuel.

-

signDisplay

-

string

-

Yes

-

Yes

-

Number sign display format. The value can be auto, never, always, or expectZero.

-

compactDisplay

-

string

-

Yes

-

Yes

-

Compact display format. The value can be long or short.

-

notation

-

string

-

Yes

-

Yes

-

Number notation. The value can be standard, scientific, engineering, or compact.

-

localeMatcher

-

string

-

Yes

-

Yes

-

Locale matching algorithm. The value can be lookup or best fit.

-

style

-

string

-

Yes

-

Yes

-

Number display format. The value can be decimal, currency, percent, or unit.

-

numberingSystem

-

string

-

Yes

-

Yes

-

Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, and wcho.

-

useGrouping

-

boolean

-

Yes

-

Yes

-

Whether to use grouping for display.

-

miniumumIntegerDigits

-

number

-

Yes

-

Yes

-

Minimum number of digits allowed in the integer part of a number. The value ranges from 1 to 21.

-

miniumumFractionDigits

-

number

-

Yes

-

Yes

-

Minimum number of digits in the fraction part of a number. The value ranges from 0 to 20.

-

maxiumumFractionDigits

-

number

-

Yes

-

Yes

-

Maximum number of digits in the fraction part of a number. The value ranges from 1 to 21.

-

miniumumSignificantDigits

-

number

-

Yes

-

Yes

-

Minimum number of the least significant digits. The value ranges from 1 to 21.

-

maxiumumSignificantDigits

-

number

-

Yes

-

Yes

-

Maximum number of the least significant digits. The value ranges from 1 to 21.

-
- -## Collator8+ - -### constructor8+ - -constructor\(\) - -Creates a **Collator** object. - -- Example - - ``` - var collator = new Intl.Collator(); - ``` - - -### constructor8+ - -constructor\(locale: string | Array, options?: CollatorOptions\) - -Creates a **Collator** object based on the specified locale and options. +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| locale | string | Yes| No| Locale, for example, **zh-Hans-CN**.
**System capability**: SystemCapability.Global.I18n| +| currency | string | Yes| Yes| Currency unit, for example, **EUR**, **CNY**, or **USD**.
**System capability**: SystemCapability.Global.I18n| +| currencySign | string | Yes| Yes| Currency unit symbol. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.
**System capability**: SystemCapability.Global.I18n| +| currencyDisplay | string | Yes| Yes| Currency display mode. The value can be **symbol**, **narrowSymbol**, **code**, or **name**.
**System capability**: SystemCapability.Global.I18n| +| unit | string | Yes| Yes| Unit name, for example, **meter**, **inch**, or **hectare**.
**System capability**: SystemCapability.Global.I18n| +| unitDisplay | string | Yes| Yes| Unit display format. The value can be **long**, **short**, or **medium**.
**System capability**: SystemCapability.Global.I18n| +| unitUsage | string | Yes| Yes| Unit usage scenario. The value can be any of the following: default, area-land-agricult, area-land-commercl, area-land-residntl, length-person, length-person-small, length-rainfall, length-road, length-road-small, length-snowfall, length-vehicle, length-visiblty, length-visiblty-small, length-person-informal, length-person-small-informal, length-road-informal, speed-road-travel, speed-wind, temperature-person, temperature-weather, volume-vehicle-fuel.
**System capability**: SystemCapability.Global.I18n| +| signDisplay | string | Yes| Yes| Number sign display format. The value can be **auto**, **never**, always**, or **expectZero**.
**System capability**: SystemCapability.Global.I18n| +| compactDisplay | string | Yes| Yes| Compact display format. The value can be **long** or **short**.
**System capability**: SystemCapability.Global.I18n| +| notation | string | Yes| Yes| Number formatting specification. The value can be **standard**, **scientific**, engineering**, or **compact**.
**System capability**: SystemCapability.Global.I18n| +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| +| style | string | Yes| Yes| Number display format. The value can be **decimal**, **currency**, **percent**, or **unit**.
**System capability**: SystemCapability.Global.I18n| +| numberingSystem | string | Yes| Yes| Numbering system for the locale. The value can be any of the following: adlm, ahom, arab, arabext, bali, beng, bhks, brah, cakm, cham, deva, diak, fullwide, gong, gonm, gujr, guru, hanidec, hmng, hmnp, java, kali, khmr, knda, lana, lanatham, laoo, latn, lepc, limb, mathbold, mathdbl, mathmono, mathsanb, mathsans, mlym, modi, mong, mroo, mtei, mymr, mymrshan, mymrtlng, newa, nkoo, olck, orya, osma, rohg, saur, segment, shrd, sind, sinh, sora, sund, takr, talu, tamldec, telu, thai, tibt, tirh, vaii, wara, wcho.
**System capability**: SystemCapability.Global.I18n| +| useGrouping | boolean | Yes| Yes| Whether to use grouping for display.
**System capability**: SystemCapability.Global.I18n| +| miniumumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| miniumumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **1** to **20**.
**System capability**: SystemCapability.Global.I18n| +| maxiumumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| miniumumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| maxiumumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| -Parameters - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string|Array<string>

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

options

-

CollatorOptions

-

No

-

Options for creating a Collator object.

-
- -- Example - - ``` - var collator = new Intl.Collator("zh-CN", {"localeMatcher": "lookup", "usage": "sort"}); - ``` - - -### compare8+ - -compare\(first: string, second: string\): number - -Compares two strings based on the sorting policy of the **Collator**. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

first

-

string

-

Yes

-

First string to compare.

-

second

-

string

-

Yes

-

Second string to compare.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Comparison result. If the value is a negative number, the first string is before the second string. If the value of number is 0, the first string is equal to the second string. If the value of number is a positive number, the first string is after the second string.

-
- - -- Example - - ``` - var collator = new intl.Collator("zh-Hans"); - collator.compare("first", "second"); - ``` - - -### resolvedOptions8+ - -resolvedOptions\(\): CollatorOptions - -Returns properties reflecting the locale and collation options of a **Collator** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

CollatorOptions

-

Properties of the Collator object.

-
- - -- Example - - ``` - var collator = new intl.Collator("zh-Hans"); - var options = collator.resolvedOptions(); - ``` - - -## CollatorOptions8+ - -Represents the properties of a **Collator** object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

localeMatcher

-

string

-

Yes

-

Yes

-

Locale matching algorithm. The value can be lookup or best fit.

-

usage

-

string

-

Yes

-

Yes

-

Whether the comparison is for sorting or for searching. The value can be sort or search.

-

sensitivity

-

string

-

Yes

-

Yes

-

Differences in the strings that lead to non-zero return values. The value can be base, accent, case, or variant.

-

ignorePunctuation

-

boolean

-

Yes

-

Yes

-

Whether punctuation is ignored. The value can be true or false.

-

collation

-

string

-

Yes

-

Yes

-

Sorting policy. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, and zhuyin.

-

numeric

-

boolean

-

Yes

-

Yes

-

Whether numeric collation is used. The value can be true or false.

-

caseFirst

-

string

-

Yes

-

Yes

-

Whether upper case or lower case is sorted first. The value can be upper, lower, or false.

-
- -## PluralRules8+ - -### constructor8+ - -constructor\(\) - -Create a **PluralRules** object. - -- Example - - ``` - var pluralRules = new Intl.PluralRules(); - ``` - - -### constructor8+ - -constructor\(locale: string | Array, options?: PluralRulesOptions\) - -Creates a **PluralRules** object based on the specified locale and options. +## Collator8+ + + +### constructor8+ + +constructor() + +Creates a Collator object. + +**System capability**: SystemCapability.Global.I18n + +- Example + ``` + var collator = new Intl.Collator(); + ``` + + +### constructor8+ + +constructor(locale: string | Array<string>, options?: CollatorOptions) + +Creates a Collator object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | locale | string\|Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| + | options | [CollatorOptions](#collatoroptions) | No| Options for creating a **Collator** object.| + +- Example + ``` + var collator = new Intl.Collator("zh-CN", {"localeMatcher": "lookup", "usage": "sort"}); + ``` + + +### compare8+ + +compare(first: string, second: string): number + +Compares two strings based on the sorting policy of the **Collator** object. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | first | string | Yes| First string to compare.| + | second | string | Yes| Second string to compare.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | Comparison result. If the value is a negative number, the first string is before the second string. If the value of number is **0**, the first string is equal to the second string. If the value of number is a positive number, the first string is after the second string.| + +- Example + ``` + var collator = new Intl.Collator("zh-Hans"); + collator.compare("first", "second"); + ``` + + +### resolvedOptions8+ + +resolvedOptions(): CollatorOptions + +Returns properties reflecting the locale and collation options of a **Collator** object. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | [CollatorOptions](#collatoroptions) | Properties of the **Collator** object.| + +- Example + ``` + var collator = new Intl.Collator("zh-Hans"); + var options = collator.resolvedOptions(); + ``` + + +## CollatorOptions8+ + +Represents the properties of a **Collator** object. + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| +| usage | string | Yes| Yes| Whether the comparison is for sorting or for searching. The value can be **sort** or **search**.
**System capability**: SystemCapability.Global.I18n| +| sensitivity | string | Yes| Yes| Differences in the strings that lead to non-zero return values. The value can be **base**, **accent**, **case**, or **variant**.
**System capability**: SystemCapability.Global.I18n| +| ignorePunctuation | boolean | Yes| Yes| Whether punctuation is ignored. The value can be **true** or **false**.
**System capability**: SystemCapability.Global.I18n| +| collation | string | Yes| Yes| Rule for sorting regions. The value can be any of the following: big5han, compat, dict, direct, ducet, eor, gb2312, phonebk, phonetic, pinyin, reformed, searchjl, stroke, trad, unihan, zhuyin.
**System capability**: SystemCapability.Global.I18n| +| numeric | boolean | Yes| Yes| Whether numeric collation is used. The value can be **true** or **false**.
**System capability**: SystemCapability.Global.I18n| +| caseFirst | string | Yes| Yes| Whether upper case or lower case is sorted first. The value can be **upper**, **lower**, or **false**.
**System capability**: SystemCapability.Global.I18n| + + +## PluralRules8+ + + +### constructor8+ + +constructor() + +Create a **PluralRules** object. + +**System capability**: SystemCapability.Global.I18n + +- Example + ``` + var pluralRules = new Intl.PluralRules(); + ``` + + +### constructor8+ + +constructor(locale: string | Array<string>, options?: PluralRulesOptions) + +Create a **PluralRules** object. + +**System capability**: SystemCapability.Global.I18n Parameters +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| locale | string\|Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| +| options | [PluralRulesOptions](#pluralrulesoptions) | No| Options for creating a **PluralRules** object.| + +- Example + ``` + var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); + ``` - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string|Array<string>

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

options

-

PluralRulesOptions

-

No

-

Options for creating a PluralRules object.

-
- -- Example - - ``` - var pluralRules= new Intl.PluraRules("zh-CN", {"localeMatcher": "lookup", "type": "cardinal"}); - ``` - - -### select8+ - -select\(n: number\): string + +### select8+ + +select(n: number): string Obtains a string that represents the singular-plural type of the specified number. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

n

-

number

-

Yes

-

Number for which the singular-plural type is to be obtained.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Singular-plural type. The options are as follows: zero, one, two, few, many, and others.

-
- - -- Example - - ``` - var pluralRules = new intl.PluralRules("zh-Hans"); - pluralRules.select(1); - ``` - - -## PluralRulesOptions8+ - -Represents the properties of a **PluralRules** object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

localeMatcher

-

string

-

Yes

-

Yes

-

Locale matching algorithm. The value can be lookup or best fit.

-

type

-

string

-

Yes

-

Yes

-

Sorting type. The value can be cardinal or ordinal.

-

minimumIntegerDigits

-

number

-

Yes

-

Yes

-

Minimum number of digits allowed in the integer part of a number. The value ranges from 1 to 21.

-

minimumFractionDigits

-

number

-

Yes

-

Yes

-

Minimum number of digits in the fraction part of a number. The value ranges from 0 to 20.

-

maximumFractionDigits

-

number

-

Yes

-

Yes

-

Maximum number of digits in the fraction part of a number. The value ranges from 1 to 21.

-

minimumSignificantDigits

-

number

-

Yes

-

Yes

-

Minimum number of the least significant digits. The value ranges from 1 to 21.

-

maximumSignificantDigits

-

number

-

Yes

-

Yes

-

Maximum number of the least significant digits. The value ranges from 1 to 21.

-
- -## RelativeTimeFormat8+ - -### constructor8+ - -constructor\(\) - -Creates a **RelativeTimeFormat** object. - -- Example - - ``` - var relativetimefmt = new Intl.RelativeTimeFormat(); - ``` - - -### constructor8+ - -constructor\(locale: string | Array, options?: RelativeTimeFormatInputOptions\) - -Creates a **RelativeTimeFormat** object based on the specified locale and options. +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | n | number | Yes| Number for which the singular-plural type is to be obtained.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Singular-plural type. The value can be any of the following: one, two, few, many, others.| + +- Example + ``` + var pluralRules = new Intl.PluralRules("zh-Hans"); + pluralRules.select(1); + ``` + + +## PluralRulesOptions8+ + +Represents the properties of a **PluralRules** object. + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| +| type | string | Yes| Yes| Sorting type. The value can be **cardinal** or **ordinal**.
**System capability**: SystemCapability.Global.I18n| +| minimumIntegerDigits | number | Yes| Yes| Minimum number of digits allowed in the integer part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| minimumFractionDigits | number | Yes| Yes| Minimum number of digits in the fraction part of a number. The value ranges from **0** to **20**.
**System capability**: SystemCapability.Global.I18n| +| maximumFractionDigits | number | Yes| Yes| Maximum number of digits in the fraction part of a number. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| minimumSignificantDigits | number | Yes| Yes| Minimum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| +| maximumSignificantDigits | number | Yes| Yes| Maximum number of the least significant digits. The value ranges from **1** to **21**.
**System capability**: SystemCapability.Global.I18n| + + +## RelativeTimeFormat8+ + + +### constructor8+ + +constructor() + +Creates a **RelativeTimeFormat** object. + +**System capability**: SystemCapability.Global.I18n + +- Example + ``` + var relativetimefmt = new Intl.RelativeTimeFormat(); + ``` + + +### constructor8+ + +constructor(locale: string | Array<string>, options?: RelativeTimeFormatInputOptions) + +Creates a **RelativeTimeFormat** object. + +**System capability**: SystemCapability.Global.I18n Parameters +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| locale | string\|Array<string> | Yes| A string containing locale information, including the language, optional script, and region.| +| options | [RelativeTimeFormatInputOptions](#relativetimeformatinputoptions) | No| Options for creating a **RelativeTimeFormat** object.| + +- Example + ``` + var relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {"localeMatcher": "lookup", "numeric": "always", "style": "long"}); + ``` + - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

locale

-

string|Array<string>

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

options

-

RelativeTimeFormatInputOptions

-

No

-

Options for creating a RelativeTimeFormat object.

-
- -- Example - - ``` - var relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {"localeMatcher": "lookup", "numeric": "always", "style": "long"}); - ``` - - -### format8+ - -format\(value: numeric, unit: string\): string +### format8+ + +format(value: numeric, unit: string): string Formats the value and unit based on the specified locale and formatting options. -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

numeric

-

Yes

-

Value to format.

-

unit

-

string

-

Yes

-

Unit to format. The value can be year, quarter, month, week, day, hour, minute, or second.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

string

-

Relative time after formatting.

-
- - -- Example - - ``` - var relativetimefmt = new Intl.RelativeTimeFormat("zh-CN"); - relativetimefmt.format(3, "quarter") - ``` - - -### formatToParts8+ - -formatToParts\(value: numeric, unit: string\): Array - -Returns an array of **RelativeTimeFormat** objects in parts for locale-aware formatting. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

value

-

numeric

-

Yes

-

Value to format.

-

unit

-

string

-

Yes

-

Unit to format. The value can be year, quarter, month, week, day, hour, minute, or second.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Array<Object>

-

An array of RelativeTimeFormat objects in parts.

-
- - -- Example - - ``` - var relativetimefmt = new Intl.RelativeTimeFormat("en", {"numeric": "auto"}); - var parts = relativetimefmt.format(10, "seconds"); - ``` - - -### resolvedOptions8+ - -resolvedOptions\(\): RelativeTimeFormatResolvedOptions - -Obtains the formatting options for **RelativeTimeFormat** objects. - -- Return values - - - - - - - - - - -

Type

-

Description

-

RelativeTimeFormatResolvedOptions

-

Formatting options for RelativeTimeFormat objects.

-
- - -- Example - - ``` - var relativetimefmt= new Intl.RelativeTimeFormat("en-GB"); - relativetimefmt.resolvedOptions(); - ``` - - -## RelativeTimeFormatInputOptions8+ - -Represents the properties of a **RelativeTimeFormat** object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

localeMatcher

-

string

-

Yes

-

Yes

-

Locale matching algorithm. The value can be lookup or best fit.

-

numeric

-

string

-

Yes

-

Yes

-

Format of the output message. The value can be always or auto.

-

style

-

string

-

Yes

-

Yes

-

Length of the internationalized message. The value can be long, short, or narrow.

-
- -## RelativeTimeFormatResolvedOptions8+ - -Represents the properties of a **RelativeTimeFormat** object. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Parameter Type

-

Readable

-

Writable

-

Description

-

locale

-

string

-

Yes

-

Yes

-

A string containing locale information, including the language, optional script, and locale.

-

numeric

-

string

-

Yes

-

Yes

-

Format of the output message. The value can be always or auto.

-

style

-

string

-

Yes

-

Yes

-

Length of the internationalized message. The value can be long, short, or narrow.

-

numberingSystem

-

string

-

Yes

-

Yes

-

Numbering system.

-
+**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | value | numeric | Yes| Value to format.| + | unit | string | Yes| Unit to format. The value can be any of the following: year, quarter, month, week, day, hour, minute, second.| + +- Return value + | Type| Description| + | -------- | -------- | + | string | Relative time after formatting.| + +- Example + ``` + var relativetimefmt = new Intl.RelativeTimeFormat("zh-CN"); + relativetimefmt.format(3, "quarter") + ``` + + +### formatToParts8+ + +formatToParts(value: numeric, unit: string): Array<Object> + +Returns an array of RelativeTimeFormat objects in parts for locale-aware formatting. + +**System capability**: SystemCapability.Global.I18n + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | value | numeric | Yes| Value to format.| + | unit | string | Yes| Unit to format. The value can be any of the following: year, quarter, month, week, day, hour, minute, second.| + +- Return value + | Type| Description| + | -------- | -------- | + | Array<Object> | An array of **RelativeTimeFormat** objects in parts.| + +- Example + ``` + var relativetimefmt = new Intl.RelativeTimeFormat("en", {"numeric": "auto"}); + var parts = relativetimefmt.format(10, "seconds"); + ``` + + +### resolvedOptions8+ + +resolvedOptions(): RelativeTimeFormatResolvedOptions + +Obtains the formatting options for **RelativeTimeFormat** objects. + +**System capability**: SystemCapability.Global.I18n + +- Return value + | Type| Description| + | -------- | -------- | + | [RelativeTimeFormatResolvedOptions](#relativetimeformatresolvedoptions) | Formatting options for **RelativeTimeFormat** objects.| + +- Example + ``` + var relativetimefmt= new Intl.RelativeTimeFormat("en-GB"); + relativetimefmt.resolvedOptions(); + ``` + + +## RelativeTimeFormatInputOptions8+ + +Represents the properties of a **RelativeTimeFormat** object. + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| localeMatcher | string | Yes| Yes| Locale matching algorithm. The value can be **lookup** or **best fit**.
**System capability**: SystemCapability.Global.I18n| +| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.
**System capability**: SystemCapability.Global.I18n| +| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| + + +## RelativeTimeFormatResolvedOptions8+ + +Represents the properties of a **RelativeTimeFormat** object. + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| locale | string | Yes| Yes| A string containing locale information, including the language, optional script, and region.
**System capability**: SystemCapability.Global.I18n| +| numeric | string | Yes| Yes| Format of the output message. The value can be **always** or **auto**.
**System capability**: SystemCapability.Global.I18n| +| style | string | Yes| Yes| Length of an internationalized message. The value can be **long**, **short**, or **narrow**.
**System capability**: SystemCapability.Global.I18n| +| numberingSystem | string | Yes| Yes| Numbering system.
**System capability**: SystemCapability.Global.I18n| diff --git a/en/application-dev/reference/apis/js-apis-lightweightset.md b/en/application-dev/reference/apis/js-apis-lightweightset.md new file mode 100644 index 0000000000000000000000000000000000000000..cf32ebe8d594116443ca52474d2721674214388a --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-lightweightset.md @@ -0,0 +1,505 @@ +# Nonlinear Container LightWeightSet + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import LightWeightSet from '@ohos.util.LightWeightSet' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## LightWeightSet + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a lightweight set (called container later).| + + +### constructor + +constructor() + +A constructor used to create a **LightWeightSet** instance. + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +``` + + +### isEmpty + +isEmpty(): boolean + +Checks whether this container is empty. + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +const lightWeightSet = new LightWeightSet(); +let result = lightWeightSet.isEmpty(); +``` + +### add + +add(obj: T): boolean + +Adds an entry to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| obj | T | Yes| Entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +let result = lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + + +### addAll + +addAll(set: LightWeightSet<T>): boolean + +Adds all entries in a **LightWeightSet** instance to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| set | LightWeightSet<T> | Yes| **LightWeightSet** instance whose entries are to be added to the current container.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let set = new LightWeightSet(); +set.add("sfage"); +let result = lightWeightSet.addAll(set); +``` + + +### hasAll + +hasAll(set: LightWeightSet<T>): boolean + +Checks whether this container contains all entries of the specified **LightWeightSet** instance. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| set | LightWeightSet<T> | Yes| **LightWeightSet** instance to be used for comparison.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if all the entries in the specified **LightWeightSet** instance are contained; returns **false** otherwise.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let set = new LightWeightSet(); +set.add("sdfs"); +let result = lightWeightSet.hasAll(set); +``` + + +### has + +has(key: T): boolean + +Checks whether this container has the specified key. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key| T | Yes| Key to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified key is contained; returns **false** otherwise.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +let result = lightWeightSet.has(123); +lightWeightSet.add(123); +let result = lightWeightSet.has(123); +``` + + +### equal + +equal(obj: Object): boolean + +Checks whether this container contains objects of the same type as the specified **obj**. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| obj | Object | Yes| Object to be used for comparison.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container contains objects of the same type as the specified **obj**; returns **false** otherwise.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let obj = {"Ahfbrgrbgnutfodgorrogorgrogofdfdf", "sdfs"}; +let result = lightWeightSet.equal(obj); +``` + + +### increaseCapacityTo + +increaseCapacityTo(minimumCapacity: number): void + +Increases the capacity of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| minimumCapacity | number | Yes| Minimum number of entries to accommodate in the container.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.increaseCapacityTo(10); +``` + + +### getIndexOf + +getIndexOf(key: T): number + +Obtains the position index of the entry with the specified key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | T | Yes| Key of the entry to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Position index of the entry.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.getIndexOf("sdfs"); +``` + + +### remove + +remove(key: T): T + +Removes an entry of the specified key from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | T | Yes| Key of the entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value of the entry removed.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.remove("sdfs"); +``` + + +### removeAt + +removeAt(index: number): boolean + +Removes the entry at the specified position from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.removeAt(1); +``` + + +### getValueAt + +getValueAt(index: number): T + +Obtains the value of the entry at the specified position in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value obtained.| + +**Parameters** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.getValueAt(1); +``` + + +### clear + +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +lightWeightSet.clear(); +``` + + +### toString + +toString(): String + +Obtains a string that contains all entries in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| String | String obtained.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.toString(); +``` + + +### toArray + +toArray(): Array<T> + +Obtains an array that contains all objects in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| Array<T> | Array obtained.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let result = lightWeightSet.toArray(); +``` + + +### values + +values(): IterableIterator<T> + +Obtains an iterator that contains all the values in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let iter = lightWeightSet.values(); +let index = 0; +while(index < lightWeightSet.length) { + console.log(JSON.stringify(iter.next().value)); + index++; +} +``` + + +### forEach + +forEach(callbackfn: (value: T, key?: T, set?: LightWeightSet<T>) => void, thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| key | T | No| Key of the entry that is currently traversed (same as **value**).| +| set | LightWeightSet<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("sdfs"); +lightWeightSet.add("dfsghsf"); +lightWeightSet.forEach((value, key) => { + console.log(value, key); +}); +``` + + +### entries + +entries(): IterableIterator<[T, T]> + +Obtains an iterator that contains all the entries in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<[T, T]> | Iterator obtained.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); +let iter = lightWeightSet.entries(); +let index = 0; +while(index < lightWeightSet.length) { + console.log(JSON.stringify(iter.next().value)); + index++; +} +``` + + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let lightWeightSet = new LightWeightSet(); +lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +lightWeightSet.add("sdfs"); + +// Method 1: +for (let item of lightWeightSet) { + console.log("value: " + item); +} + +// Method 2: +let iter = lightWeightSet[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-list.md b/en/application-dev/reference/apis/js-apis-list.md new file mode 100644 index 0000000000000000000000000000000000000000..fc7e38d2a1ae33b561f3902ea3906b5b1cadab16 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-list.md @@ -0,0 +1,619 @@ +# Linear Container List + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import List from '@ohos.util.List' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + + +## List + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a list (called container later).| + + +### constructor + +constructor(head?: NodeObj<T>) + +A constructor used to create a **List** instance. + +**Parameters** + +| Name| Value Type | Readable| Description| +| -------- | -------- | -------- | -------- | +| head | NodeObj<T> | Yes| Node object, including **element** and **next**.| + +**Example** + +``` +let list = new List(); +``` + + +### add + +add(element: T): boolean + +Adds an entry at the end of this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Element to add.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + +``` +let list = new List; +let result = list.add("a"); +let result1 = list.add(1); +let b = [1, 2, 3]; +list.add(b); +let c = {name : "lala", age : "13"}; +let result3 = list.add(false); +``` + +### insert + +insert(element: T, index: number): void + +Inserts an entry at the specified position in this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Element to insert.| +| index | number | Yes| Index of the position where the entry is to be inserted.| + +**Example** + +``` +let list = new List(); +list.insert("A", 0); +list.insert(0, 1); +list.insert(true, 2); +``` + +### has + +has(element: T): boolean + +Checks whether this container has the specified entry. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| boolean | Returns **true** if the specified entry is contained; returns **false** otherwise.| + +**Example** + +``` +let list = new List(); +let result = list.has("Ahfbrgrbgnutfodgorrogorg"); +list.add("Ahfbrgrbgnutfodgorrogorg"); +let result1 = list.has("Ahfbrgrbgnutfodgorrogorg"); +``` + +### get + +get(index: number): T + +Obtains the entry at the specified position in this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry to obtain.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| T | Entry obtained.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(2); +list.add(1); +list.add(2); +list.add(4); +let result = list.get(2); +``` + +### getLastIndexOf + +getLastIndexOf(element: T): number + +Obtains the index of the last occurrence of the specified entry in this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(2); +list.add(1); +list.add(2); +list.add(4); +let result = list.getLastIndexOf(2); +``` + +### getIndexOf + +getIndexOf(element: T): number + +Obtains the index of the first occurrence of the specified entry in this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(2); +list.add(1); +list.add(2); +list.add(4); +list.getIndexOf(2); +let result = list.getIndexOf(2); +``` + +### equal + +equal(obj: Object): boolean + +Compares whether a specified object is equal to this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| obj | Object | Yes| Object used for comparison.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| boolean | Returns **true** if the two are equal; returns **false** otherwise.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(2); +let obj1 = new List(); +obj1.add(2); +obj1.add(4); +obj1.add(5); +list.equal(obj1); +let obj2 = {name : "lala", age : "13"}; +let result = list.equal(obj2); +``` + +### removeByIndex + +removeByIndex(index: number): T + +Removes an entry at the specified position from this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry to remove.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(2); +list.add(4); +let result = list.removeByIndex(2); +``` + +### remove + +remove(element: T): boolean + +Removes the first occurrence of the specified entry from this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to remove.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.remove(2); +``` + +### replaceAllElements +replaceAllElements(callbackfn: (value: T, index?: number, list?: List<T>) => T, +thisArg?: Object): void + +Replaces all entries in this container with new entries, and returns the new ones. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked for the replacement.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| list | List<T> | No| Instance that invokes the **replaceAllElements** method.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +list.replaceAllElements((value, index) => { + return value = 2 * value; +}); +list.replaceAllElements((value, index) => { + return value = value - 2; +}); +``` + +### forEach +forEach(callbackfn: (value: T, index?: number, List?: List<T>) => void, +thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| List | List<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +list.forEach((value, index) => { + console.log(value, index); +}); + +``` + +### sort +sort(comparator: (firstValue: T, secondValue: T) => number): void + +Sorts entries in this container. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| comparator | function | Yes| Callback invoked for sorting.| + +comparator + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| firstValue | T | Yes| Previous entry.| +| secondValue | T | Yes| Next entry.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +list.sort(a, (b => a - b)); +list.sort(a, (b => b - a)); +``` + +### getSubList +getSubList(fromIndex: number, toIndex: number): List<T> + +Obtains entries within a range in this container, including the entry at the start position but not that at the end position, and returns these entries as a new **List** instance. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fromIndex | number | Yes| Index of the start position.| +| toIndex | number | Yes| Index of the end position.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| List<T> | New **List** instance obtained.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.subList(2, 4); +let result1 = list.subList(4, 3); +let result2 = list.subList(2, 6); +``` + +### clear +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +list.clear(); +``` + +### set +set(index: number, element: T): T +Replaces an entry at the specified position in this container with a given entry. + +**Parameters** + +| Name| Value Type | Mandatory| Description| +| -------- | -------- | -------- | -------- | +| index | number | Yes| Position index of the entry to replace.| +| element | T | Yes| Entry to be used for replacement.| + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| T | New entry.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +list.set(2, "b"); + +``` + +### convertToArray +convertToArray(): Array<T> + +Converts this container into an array. + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| Array<T> | Array obtained.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.convertToArray(); +``` + +### isEmpty +isEmpty(): boolean + +Checks whether this container is empty (contains no entry). + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.isEmpty(); +``` + +### getFirst + +getFirst(): T + +Obtains the first entry in this container. + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| T | The first entry obtained.| + +**Example** + +``` +let list = new Vector(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.getFirst(); +``` + +### getLast + +getLast(): T + +Obtains the last entry in this container. + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| T | The last entry obtained.| + +**Example** + +``` +let list = new Vector(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); +let result = list.getLast(); +``` + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T>; + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Value Type | Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let list = new List(); +list.add(2); +list.add(4); +list.add(5); +list.add(4); + +// Method 1: +for (let item of list) { + console.log(item); +} + +// Method 2: +let iter = list[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-observer.md b/en/application-dev/reference/apis/js-apis-observer.md new file mode 100644 index 0000000000000000000000000000000000000000..bb658c1fbd35dcf714092ef915d9c6792a432dcc --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-observer.md @@ -0,0 +1,265 @@ +# Observer + +>**NOTE** +> +>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import observer from '@ohos.telephony.observer' +``` + +## observer.on('networkStateChange') + +on\(type: \'networkStateChange\', callback: Callback\): void; + +Registers an observer for network status change events. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ----------------------------------------- | ---- | --------------------------------- | +| type | string | Yes| Network status change event.| +| callback | Callback\<[NetworkState](js-apis-radio.md#NetworkState)\> | Yes| Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#NetworkState).| + +**Example** + +``` +observer.on('networkStateChange', data =>{ + console.log("on networkStateChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.on('networkStateChange') + +on\(type: \'networkStateChange\', options: { slotId: number }, callback: Callback\): void; + +Registers an observer for network status change events of the SIM card in the specified slot. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| type | string | Yes| Network status change event.| +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | Callback\<[NetworkState](js-apis-radio.md#NetworkState)\> | Yes| Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#NetworkState).| + +**Example** + +``` +observer.on('networkStateChange', {slotId: 0}, data =>{ + console.log("on networkStateChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.off('networkStateChange') + +off\(type: \'networkStateChange\', callback?: Callback\): void; + +Unregisters the observer for network status change events. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +>**NOTE** +> +>You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------ | ---- | --------------------------------- | +| type | string | Yes| Network status change event.| +| callback | Callback\<[NetworkState](js-apis-radio.md#NetworkState)\> | No| Callback used to return the result. For details, see [NetworkState](js-apis-radio.md#NetworkState).| + +**Example** + +``` +let callback = data => { + console.log("on networkStateChange, data:" + JSON.stringify(data)); +} +observer.on('networkStateChange', callback); +// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +observer.off('networkStateChange', callback); +observer.off('networkStateChange'); +``` + +## observer.on('signalInfoChange') + +on\(type: \'signalInfoChange\', callback: Callback\>): void; + +Registers an observer for signal status change events. This function uses an asynchronous callback to return the execution result. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes| Signal status change event.| +| callback | Callback\> | Yes| Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#SignalInformation).| + +**Example** + +``` +observer.on('signalInfoChange', data =>{ + console.log("on signalInfoChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.on('signalInfoChange') + +on\(type: \'signalInfoChange\', options: { slotId: number }, callback: Callback\>): void; + +Registers an observer for signal status change events of the SIM card in the specified slot. This function uses an asynchronous callback to return the execution result. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| type | string | Yes| Signal status change event.| +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | Callback\> | Yes| Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#SignalInformation).| + +**Example** + +``` +observer.on('signalInfoChange', {slotId: 0}, data =>{ + console.log("on signalInfoChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.off('signalInfoChange') + +off\(type: \'signalInfoChange\', callback?: Callback\>): void; + +Unregisters the observer for signal status change events. This function uses an asynchronous callback to return the execution result. + +>**NOTE** +> +>You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes| Signal status change event.| +| callback | Callback\> | No| Callback used to return the result. For details, see [SignalInformation](js-apis-radio.md#SignalInformation).| + +**Example** + +``` +let callback = data => { + console.log("on signalInfoChange, data:" + JSON.stringify(data)); +} +observer.on('signalInfoChange', callback); +// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +observer.off('signalInfoChange', callback); +observer.off('signalInfoChange'); +``` + + +## observer.on('callStateChange') + +on(type: 'callStateChange', callback: Callback\<{ state: [CallState](js-apis-call.md#CallState), number: string }\>): void; + +Registers an observer for call status change events. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.READ_CALL_LOG + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes| Call status change event.| +| callback | Callback\<{ state: [CallState](js-apis-call.md#CallState), number: string }\> | Yes| Callback used to return the result. For details, see [CallState](js-apis-call.md#CallState)
**number**: phone number.| + +**Example** + +``` +observer.on('callStateChange', value =>{ + console.log("on callStateChange, state:" + value.state + ", number:" + value.number); +}); +``` + + +## observer.on('callStateChange') + +on(type: 'callStateChange', options: { slotId: number }, callback: Callback<{ state: [CallState](js-apis-call.md#CallState), number: string }>): void; + +Registers an observer for call status change events. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.READ_CALL_LOG + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes| Call status change event.| +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | Callback\<{ state: [CallState](js-apis-call.md#CallState), number: string }\> | Yes| Callback used to return the result. For details, see [CallState](js-apis-call.md#CallState)
**number**: phone number.| + +**Example** + +``` +observer.on('callStateChange', {slotId: 0}, value =>{ + console.log("on callStateChange, state:" + value.state + ", number:" + value.number); +}); +``` + + +## observer.off('callStateChange') + +off(type: 'callStateChange', callback?: Callback<{ state: [CallState](js-apis-call.md#CallState), number: string }>): void; + +Unregisters the observer for call status change events. This function uses an asynchronous callback to return the execution result. + +**Required permission**: ohos.permission.READ_CALL_LOG + +>**NOTE** +> +>You can pass the callback of the **on** function if you want to cancel listening for a certain type of event. If you do not pass the callback, you will cancel listening for all events. + +**System capability**: SystemCapability.Telephony.StateRegistry + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | Yes| Call status change event.| +| callback | Callback\<{ state: [CallState](js-apis-call.md#CallState), number: string }\> | No| Callback used to return the result. For details, see [CallState](js-apis-call.md#CallState)
**number**: phone number.| + +**Example** + +``` +let callback = value => { + console.log("on callStateChange, state:" + value.state + ", number:" + value.number); +} +observer.on('callStateChange', callback); +// You can pass the callback of the on method to cancel listening for a certain type of callback. If you do not pass the callback, you will cancel listening for all callbacks. +observer.off('callStateChange', callback); +observer.off('callStateChange'); +``` diff --git a/en/application-dev/reference/apis/js-apis-particleAbility.md b/en/application-dev/reference/apis/js-apis-particleAbility.md index fdeb2c639f496331410ad5c19dac882ea3ac74d4..84d4281dd8e8c1faa843cd92856f75c54d5d5d50 100644 --- a/en/application-dev/reference/apis/js-apis-particleAbility.md +++ b/en/application-dev/reference/apis/js-apis-particleAbility.md @@ -14,20 +14,25 @@ import particleAbility from '@ohos.ability.particleAbility' startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\: void -Starts a Service ability. This method uses a callback to return the result. +Starts a particle ability. This method uses a callback to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ----------------------------------------------- | ---- | ----------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| +| callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```js import particleAbility from '@ohos.ability.particleAbility' +import wantConstant from '@ohos.ability.wantConstant' particleAbility.startAbility( { want: @@ -35,7 +40,7 @@ particleAbility.startAbility( action: "action.system.home", entities: ["entity.system.home"], type: "MIMETYPE", - flags: FLAG_AUTH_READ_URI_PERMISSION; + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", bundleName: "com.example.Data", abilityName: "com.example.Data.MainAbility", @@ -52,17 +57,25 @@ particleAbility.startAbility( ## particleAbility.startAbility +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + startAbility(parameter: StartAbilityParameter): Promise\ -Starts a Service ability. This method uses a promise to return the result. +Starts a particle ability. This method uses a promise to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------- | ----------------------------------------------- | ---- | ----------------- | -| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.| +| parameter | [StartAbilityParameter](#startabilityparameter) | Yes | Ability to start.| **Return value** -| Type| Description| +| Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| @@ -70,6 +83,7 @@ Starts a Service ability. This method uses a promise to return the result. ```js import particleAbility from '@ohos.ability.particleAbility' +import wantConstant from '@ohos.ability.wantConstant' particleAbility.startAbility( { want: @@ -77,14 +91,14 @@ particleAbility.startAbility( action: "action.system.home", entities: ["entity.system.home"], type: "MIMETYPE", - flags: FLAG_AUTH_READ_URI_PERMISSION; + flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, deviceId: "", bundleName: "com.example.Data", - abilityName: "com.example.Data.MainAbility", + abilityName: "com.example. Data.MainAbility", uri:"" }, }, -).then((void) => { +).then((data) => { console.info("particleAbility startAbility"); }); ``` @@ -95,13 +109,17 @@ particleAbility.startAbility( terminateSelf(callback: AsyncCallback\): void -Terminates this Service ability. This method uses a callback to return the result. +Terminates this particle ability. This method uses a callback to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | -------------------- | -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +| callback | AsyncCallback\ | Yes | Callback used to return the result.| **Example** @@ -120,10 +138,14 @@ particleAbility.terminateSelf( terminateSelf(): Promise\ -Terminates this Service ability. This method uses a promise to return the result. +Terminates this particle ability. This method uses a promise to return the result. + +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel **Return value** -| Type| Description| +| Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| @@ -131,7 +153,7 @@ Terminates this Service ability. This method uses a promise to return the result ```js import particleAbility from '@ohos.ability.particleAbility' -particleAbility.terminateSelf().then((void) => { +particleAbility.terminateSelf().then((data) => { console.info("particleAbility terminateSelf"); }); ``` @@ -144,15 +166,19 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper Obtains a **dataAbilityHelper** object. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.FAModel + **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type | Mandatory| Description | | :--- | ------ | ---- | ------------------------ | -| uri | string | Yes| URI of the file to open.| +| uri | string | Yes | URI of the file to open.| **Return value** -| Type| Description| +| Type | Description | | ----------------- | -------------------------------------------- | | DataAbilityHelper | A utility class used to help other abilities access a Data ability.| @@ -164,210 +190,251 @@ var uri = ""; particleAbility.acquireDataAbilityHelper(uri) ``` -## particleAbility.connectAbility +## StartAbilityParameter -connectAbility(request: Want, options:ConnectOptions): number +| Name | Readable/Writable| Type | Mandatory| Description | +| ------------------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | +| want | Read-only | [Want](#want) | Yes | Information about the ability to start.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| -Connects this ability to a specific Service ability. This method uses a callback to return the result. +## Want -**Parameters** +| Name | Readable/Writable| Type | Mandatory| Description | +| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| deviceId | Read-only | string | No | ID of the device running the ability to start.
System capabilities: SystemCapability.Ability.AbilityBase | +| bundleName | Read-only | string | No | Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.
System capabilities: SystemCapability.Ability.AbilityBase| +| abilityName | Read-only | string | No | Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.
System capabilities: SystemCapability.Ability.AbilityBase| +| uri | Read-only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.
System capabilities: SystemCapability.Ability.AbilityBase| +| type | Read-only | string | No | MIME type, for example, **text/plain** or **image/***.
System capabilities: SystemCapability.Ability.AbilityBase | +| flags | Read-only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](#flags).
System capabilities: SystemCapability.Ability.AbilityBase| +| action | Read-only | string | No | Action option.
System capabilities: SystemCapability.Ability.AbilityBase | +| parameters | Read-only | {[key: string]: any} | No | List of parameters in the **Want** object.
System capabilities: SystemCapability.Ability.AbilityBase | +| entities | Read-only | Array\ | No | List of entities.
System capabilities: SystemCapability.Ability.AbilityBase | -| Name| Type| Mandatory| Description| -| ------- | -------------- | ---- | -------------------------- | -| request | [Want](#want) | Yes| Service ability to connect.| -| options | ConnectOptions | Yes| Callback used to return the result.| +## flags -ConnectOptions +| Name | Value | Description | +| ------------------------------------ | ---------- | ------------------------------------------------------------ | +| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.
System capabilities: SystemCapability.Ability.AbilityBase| +| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.
System capabilities: SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.
System capabilities: SystemCapability.Ability.AbilityBase| -| Name| Readable/Writable| Type| Mandatory| Description| -| ------------ | -------- | -------- | ---- | ---------------------------------- | -| onConnect | Read-only| function | Yes| Callback invoked when the connection is set up.| -| onDisconnect | Read-only| function | Yes| Callback invoked when the connection is interrupted.| -| onFailed | Read-only| function | Yes| Callback invoked when the connection fails.| +## AbilityStartSetting -**Return value** -| Type| Description| -| ------ | -------------------------- | -| number | Unique identifier of the connection between the client and the service side.| +The **AbilityStartSetting** attribute is an object defined as [key: string]: any. The key is a type of **AbilityStartSetting**, and the value is a type of **AbilityWindowConfiguration**. -**Example** +Defines special attributes of an ability, for example, **featureAbility.AbilityStartSetting.BOUNDS_KEY**. -```javascript -import particleAbility from '@ohos.ability.particleAbility' -function onConnectCallback(element, remote){ - console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); -} -function onDisconnectCallback(element){ - console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) -} -function onFailedCallback(code){ - console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) -} -var connId = particleAbility.connectAbility( - { - bundleName: "com.ix.ServiceAbility", - abilityName: "com.ix.ServiceAbility.ServiceAbilityA", - }, - { - onConnect: onConnectCallback, - onDisconnect: onDisconnectCallback, - onFailed: onFailedCallback, - }, -); -``` +| Name | Value | Description | +| --------------- | --------------- | -------------------------- | +| BOUNDS_KEY | "abilityBounds" | Ability window size.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| WINDOW_MODE_KEY | "windowMode" | Ability window display mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| DISPLAY_ID_KEY | "displayId" | Display device ID.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| -## particleAbility.disconnectAbility +## AbilityWindowConfiguration -disconnectAbility(connection: number, callback:AsyncCallback\): void +Defines the window display modes of a Page ability, for example, **featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED**. -Disconnects this ability from a specific Service ability. This method uses a callback to return the result. +| Name | Value| Description | +| --------------------------- | ---- | ---------- | +| WINDOW_MODE_UNDEFINED | 0 | The Page ability is in an undefined window display mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| WINDOW_MODE_FULLSCREEN | 1 | The Page ability is in full screen mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | +| WINDOW_MODE_SPLIT_PRIMARY | 100 | The Page ability is displayed in the primary window when it is in split-screen mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| +| WINDOW_MODE_SPLIT_SECONDARY | 101 | The Page ability is displayed in the secondary window when it is in split-screen mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel| +| WINDOW_MODE_FLOATING | 102 | The Page ability is displayed in floating window mode.
System capabilities: SystemCapability.Ability.AbilityRuntime.FAModel | -**Parameters** -| Name| Type| Mandatory| Description| -| ---------- | ------------- | ---- | ------------------------------ | -| connection | number | Yes| ID of the Service ability to disconnect.| -| callback | AsyncCallback\ | Yes| Callback used to return the result.| +## particleAbility.startBackgroundRunning -**Example** +startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback<void>): void; -```javascript -import particleAbility from '@ohos.ability.particleAbility' -function onConnectCallback(element, remote){ - console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); -} -function onDisconnectCallback(element){ - console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) -} -function onFailedCallback(code){ - console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) +Requests a continuous task from the system. This method uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) + +**System capabilities** + +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | id | number | Yes| Notification ID of a continuous task.| + | request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.| + | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| + +- **Example** +```js +import notification from '@ohos.notification'; +import particleAbility from '@ohos.ability.particleAbility'; +import wantAgent from '@ohos.wantAgent'; + +function callback(err, data) { + if (err) { + console.error("Operation failed Cause: " + err); + } else { + console.info("Operation succeeded"); + } } -var connId = particleAbility.connectAbility( - { - bundleName: "com.ix.ServiceAbility", - abilityName: "com.ix.ServiceAbility.ServiceAbilityA", - }, - { - onConnect: onConnectCallback, - onDisconnect: onDisconnectCallback, - onFailed: onFailedCallback, - }, -); -var result = particleAbility.disconnectAbility(connId, - (error,data) => { - console.log('particleAbilityTest DisConnectAbility result errCode : ' + error.code + " data: " + data) - }, -); + +let wantAgentInfo = { + wants: [ + { + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility" + } + ], + operationType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG] +}; + +wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + let basicContent = { + title: "title", + text: "text" + }; + let notificationContent = { + contentType: notification.ContentType.NOTIFICATION_CONTENT_TEXT, + normal: basicContent + }; + let request = { + content: notificatonContent, + wantAgent: wantAgentObj + }; + let id = 1; + particleAbility.startBackgroundRunning(id, request, callback); +}); + ``` -## particleAbility.disconnectAbility +## particleAbility.startBackgroundRunning -disconnectAbility(connection: number): Promise\ +startBackgroundRunning(id: number, request: NotificationRequest): Promise<void> -Disconnects this ability from a specific Service ability. This method uses a promise to return the result. +**System capabilities** -**Parameters** +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask +Requests a continuous task from the system. This method uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) + +**Parameters** | Name| Type| Mandatory| Description| -| ---------- | ------ | ---- | ------------------------------ | -| connection | number | Yes| ID of the Service ability to disconnect.| +| -------- | -------- | -------- | -------- | +| id | number | Yes| Notification ID of a continuous task.| +| request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.| **Return value** -| Type| Description| +| Type | Description | | -------------- | ------------------------- | | Promise\ | Promise used to return the result.| -**Example** +- **Example** +```js +import notification from '@ohos.notification'; +import particleAbility from '@ohos.ability.particleAbility'; +import wantAgent from '@ohos.wantAgent'; -```javascript -import particleAbility from '@ohos.ability.particleAbility' -function onConnectCallback(element, remote){ - console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); -} -function onDisconnectCallback(element){ - console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) -} -function onFailedCallback(code){ - console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) -} -var connId = particleAbility.connectAbility( - { - bundleName: "com.ix.ServiceAbility", - abilityName: "com.ix.ServiceAbility.ServiceAbilityA", - }, - { - onConnect: onConnectCallback, - onDisconnect: onDisconnectCallback, - onFailed: onFailedCallback, - }, -); -var result = particleAbility.disconnectAbility(connId).then((void) => { - console.info("particleAbilityTest disconnectAbility"); +let wantAgentInfo = { + wants: [ + { + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.MainAbility" + } + ], + operationType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG] +}; + +wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { + let basicContent = { + title: "title", + text: "text" + }; + let notificationContent = { + contentType: notification.ContentType.NOTIFICATION_CONTENT_TEXT, + normal: basicContent + }; + let request = { + content: notificatonContent, + wantAgent: wantAgentObj + }; + let id = 1; + particleAbility.startBackgroundRunning(id, request).then(() => { + console.info("Operation succeeded"); + }).catch((err) => { + console.error("Operation failed Cause: " + err); + }); }); + ``` -## StartAbilityParameter +## particleAbility.cancelBackgroundRunning -| Name| Readable/Writable| Type| Mandatory| Description| -| ------------------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | -| want | Read-only| [Want](#want) | Yes| Information about the ability to start.| -| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.| +cancelBackgroundRunning(callback: AsyncCallback<void>): void; -## Want +Requests to cancel a continuous task from the system. This method uses an asynchronous callback to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) -| Name| Readable/Writable| Type| Mandatory| Description| -| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| deviceId | Read-only| string | No| ID of the device running the ability to start.| -| bundleName | Read-only| string | No| Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| -| abilityName | Read-only| string | No| Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.| -| uri | Read-only| string | No| URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.| -| type | Read-only| string | No| MIME type, for example, **text/plain** or **image/***.| -| flags | Read-only| number | No| How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](#flags).| -| action | Read-only| string | No| Action option.| -| parameters | Read-only| {[key: string]: any} | No| List of parameters in the **Want** object.| -| entities | Read-only| Array\ | No| List of entities.| +**System capabilities** -## flags +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -| Name| Value| Description| -| ------------------------------------ | ---------- | ------------------------------------------------------------ | -| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.| -| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.| -| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.| -| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.| -| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.| -| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.| -| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.| -| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.| -| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.| -| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.| -| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.| -| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.| -| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.| -| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.| -| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.| -| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.| +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<void> | Yes| Callback used to return the execution result.| -## AbilityStartSetting +- **Example** +```js +import particleAbility from '@ohos.ability.particleAbility'; -The **AbilityStartSetting** attribute is an object defined as [key: string]: any. The key is a type of **AbilityStartSetting**, and the value is a type of **AbilityWindowConfiguration**. +function callback(err, data) { + if (err) { + console.error("Operation failed Cause: " + err); + } else { + console.info("Operation succeeded"); + } +} -Defines special attributes of an ability, for example, **featureAbility.AbilityStartSetting.BOUNDS_KEY**. +particleAbility.cancelBackgroundRunning(callback); -| Name| Value| Description| -| --------------- | --------------- | -------------------------- | -| BOUNDS_KEY | "abilityBounds" | Ability window size.| -| WINDOW_MODE_KEY | "windowMode" | Ability window display mode.| -| DISPLAY_ID_KEY | "displayId" | Display device ID.| +``` -## AbilityWindowConfiguration +## particleAbility.cancelBackgroundRunning -Defines the window display modes of a Page ability, for example, **featureAbility.AbilityWindowConfiguration.WINDOW_MODE_UNDEFINED**. +cancelBackgroundRunning(): Promise<void>; -| Name| Value| Description| -| --------------------------- | ---- | ---------- | -| WINDOW_MODE_UNDEFINED | 0 | The Page ability is in an undefined window display mode.| -| WINDOW_MODE_FULLSCREEN | 1 | The Page ability is in full screen mode.| -| WINDOW_MODE_SPLIT_PRIMARY | 100 | The Page ability is displayed in the primary window when it is in split-screen mode.| -| WINDOW_MODE_SPLIT_SECONDARY | 101 | The Page ability is displayed in the secondary window when it is in split-screen mode.| -| WINDOW_MODE_FLOATING | 102 | The Page ability is displayed in floating window mode.| +Requests to cancel a continuous task from the system. This method uses a promise to return the result. (This method is of API 7 and will be deprecated. Use the counterpart in API 8.) + +**System capabilities** + +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + +**Return value** +| Type | Description | +| -------------- | ------------------------- | +| Promise\ | Promise used to return the result.| + +- **Example** +```js +import particleAbility from '@ohos.ability.particleAbility'; + +particleAbility.cancelBackgroundRunning().then(() => { + console.info("Operation succeeded"); +}).catch((err) => { + console.error("Operation failed Cause: " + err); +}); + +``` diff --git a/en/application-dev/reference/apis/js-apis-power.md b/en/application-dev/reference/apis/js-apis-power.md index 6932b76b9240ba8161b4d5a288d9a468caf9b1e5..6cd3cbf21a44e593a4b3abfd367987dabfbbf805 100644 --- a/en/application-dev/reference/apis/js-apis-power.md +++ b/en/application-dev/reference/apis/js-apis-power.md @@ -1,9 +1,10 @@ -# Power Management +# Power Management ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Modules to Import + +## Modules to Import ``` import power from '@ohos.power'; @@ -14,163 +15,94 @@ import power from '@ohos.power'; SystemCapability.PowerManager.PowerManager -## power.shutdownDevice +## power.shutdownDevice -shutdownDevice\(reason: string\): void +shutdownDevice(reason: string): void Shuts down the system. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

reason

-

string

-

Yes

-

Reason for system shutdown.

-
- -- Example - - ``` - power.shutdownDevice("shutdown_test"); - console.info('power_shutdown_device_test success') - ``` - - -## power.rebootDevice - -rebootDevice\(reason: string\): void - -Reboots the system. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

reason

-

string

-

Yes

-

Reason for system reboot.

-
- -- Example - - ``` - power.rebootDevice("reboot_test"); - console.info('power_reboot_device_test success') - ``` - - -## power.isScreenOn - -isScreenOn\(callback: AsyncCallback\): void +Before using this API, you must declare the **ohos.permission.SHUTDOWN** permission. -Checks the screen status of the current device. +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| reason | string | Yes| Reason for system shutdown.| + +**Example** + +``` +power.shutdownDevice("shutdown_test"); +console.info('power_shutdown_device_test success') +``` + + +## power.rebootDevice -- Parameters - - - - - - - - - - - - - - -

Type

-

Type

-

Mandatory

-

Description

-

callback

-

AsyncCallback<boolean>

-

Yes

-

Callback used to obtain the return value.

-

The value true indicates that the screen is on, and value false indicates the opposite.

-
- - -- Example - - ``` - power.isScreenOn((error, screenOn) => { - if (typeof error === "undefined") { - console.info('screenOn status is ' + screenOn); - } else { - console.log('error: ' + error); - } - }) - ``` - - -## power.isScreenOn - -isScreenOn\(\): Promise +rebootDevice(reason: string): void + +Restarts the device. + +Before using this API, you must declare the **ohos.permission.REBOOT** permission (to reboot) or the **ohos.permission.REBOOT_RECOVERY** permission (to reboot and enter the recovery mode) + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| reason | string | Yes| Reason for system reboot.| + +**Example** + +``` +power.rebootDevice("reboot_test"); +console.info('power_reboot_device_test success') +``` + + +## power.isScreenOn + +isScreenOn(callback: AsyncCallback<boolean>): void Checks the screen status of the current device. -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<boolean>

-

Promise used to asynchronously obtain the return value. The value true indicates that the screen is on, and value false indicates the opposite.

-
- -- Example - - ``` - power.isScreenOn() - .then(screenOn => { +**Parameters** + +| Type| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | Yes| Callback used to obtain the return value.
The value **true** indicates that the screen is on, and value **false** indicates the opposite.| + +**Example** + +``` +power.isScreenOn((error, screenOn) => { + if (typeof error === "undefined") { console.info('screenOn status is ' + screenOn); - }) - .catch(error => { + } else { console.log('error: ' + error); - }) - ``` + } +}) +``` +## power.isScreenOn + +isScreenOn(): Promise<boolean> + +Checks the screen status of the current device. + +**Return value** +| Type| Description| +| -------- | -------- | +| Promise<boolean> | Promise used to asynchronously obtain the return value.
The value **true** indicates that the screen is on, and value **false** indicates the opposite.| + +**Example** + +``` +power.isScreenOn() +.then(screenOn => { + console.info('screenOn status is ' + screenOn); +}) +.catch(error => { + console.log('error: ' + error); +}) +``` diff --git a/en/application-dev/reference/apis/js-apis-queue.md b/en/application-dev/reference/apis/js-apis-queue.md new file mode 100644 index 0000000000000000000000000000000000000000..543dcf5ea8664993511256b4f41a4e859bba0327 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-queue.md @@ -0,0 +1,187 @@ +# Linear Container Queue + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import Queue from '@ohos.util.Queue' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + + +## Queue + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a queue (called container later).| + + +### constructor + +constructor() + +A constructor used to create a **Queue** instance. + +**Example** + +``` +let queue = new Queue(); +``` + + +### add + +add(element: T): boolean + +Adds an entry at the end of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + +``` +let queue = new Queue(); +let result = queue.add("a"); +let result1 = queue.add(1); +queue.add(1); +let b = [1, 2, 3]; +queue.add(b); +let c = {name : "lala", age : "13"}; +let result3 = queue.add(c); +``` + +### pop + +pop(): T + +Removes the first entry from this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let queue = new Queue(); +queue.add(2); +queue.add(4); +queue.add(5); +queue.add(2); +queue.add(4); +let result = queue.pop(); +``` + +### getFirst + +getFirst(): T + +Obtains the first entry of this container. + +**Parameters** + +| Type| Description| +| -------- | -------- | +| T | The first entry obtained.| + +**Example** + +``` +let queue = new Queue(); +queue.add(2); +queue.add(4); +queue.add(5); +queue.add(2); +let result = queue.getFirst(); +``` + +### forEach +forEach(callbackfn: (value: T, index?: number, Queue?: Queue<T>) => void, +thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| Queue | Queue<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let queue = new Queue(); +queue.add(2); +queue.add(4); +queue.add(5); +queue.add(4); +queue.forEach((value, index) => { + console.log(value, index); +}); + +``` + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** +``` +let queue = new Queue(); +queue.add(2); +queue.add(4); +queue.add(5); +queue.add(4); + +// Method 1: +for (let item of queue) { + console.log(item); +} + +// Method 2: +let iter = queue[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index 0c5c2e4e31605656adb3a031425c6bdb0394ebdd..2ced67717197ec4576aa69c5424deca6c734c312 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -1,6 +1,6 @@ # Radio ->**Note:** +>**NOTE** > >The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -15,25 +15,27 @@ import radio from '@ohos.telephony.radio' getRadioTech\(slotId: number, callback: AsyncCallback<\{psRadioTech: RadioTechnology, csRadioTech: RadioTechnology\}\>\): void -Obtains the radio access technologies (RATs) used by the CS and PS domains. This function uses an asynchronous callback to return the result. +Obtains the radio access technology (RAT) used by the CS and PS domains. This function uses an asynchronous callback to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Required permission**: ohos.permission.GET_NETWORK_INFO -- Parameters +**System capability**: SystemCapability.Telephony.CoreService - | Name| Type| Mandatory| Description| - | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | - | slotId | number | Yes| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback\<{psRadioTech: [RadioTechnology](#RadioTechnology), csRadioTech:[RadioTechnology](#RadioTechnology)}\> | Yes| Callback used to return the result.| +**Parameters** -- Example +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\<{psRadioTech: [RadioTechnology](#RadioTechnology), csRadioTech:[RadioTechnology](#RadioTechnology)}\> | Yes| Callback used to return the result.| - ``` - let slotId = 0; - radio.getRadioTech(slotId, (err, data) =>{ - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +**Example** + +``` +let slotId = 0; +radio.getRadioTech(slotId, (err, data) =>{ + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## radio.getRadioTech @@ -42,31 +44,33 @@ getRadioTech\(slotId: number\): Promise<\{psRadioTech: RadioTechnology, csRadioT Obtains the RAT used by the CS and PS domains. This function uses a promise to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Required permission**: ohos.permission.GET_NETWORK_INFO -- Parameters +**System capability**: SystemCapability.Telephony.CoreService - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | -------------------------------------- | - | slotId | number | Yes| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +**Parameters** -- Return values +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | Type| Description| - | ------------------------------------------------------------ | ----------------------------------------------- | - | Promise<{psRadioTech: [RadioTechnology](#RadioTechnology), csRadioTech: [RadioTechnology](#RadioTechnology)}> | Promise used to return the result.| +**Return value** -- Example +| Type| Description| +| ------------------------------------------------------------ | ----------------------------------------------- | +| Promise<{psRadioTech: [RadioTechnology](#RadioTechnology), csRadioTech: [RadioTechnology](#RadioTechnology)}> | Promise used to return the result.| - ``` - let slotId = 0; - let promise = radio.getRadioTech(slotId); - promise.then(data => { - console.log(`getRadioTech success, data->${JSON.stringify(data)}`); - }).catch(err => { - console.log(`getRadioTech fail, err->${JSON.stringify(err)}`); - }); - ``` +**Example** + +``` +let slotId = 0; +let promise = radio.getRadioTech(slotId); +promise.then(data => { + console.log(`getRadioTech success, data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getRadioTech fail, err->${JSON.stringify(err)}`); +}); +``` ## radio.getNetworkState @@ -75,21 +79,23 @@ getNetworkState\(callback: AsyncCallback\): void Obtains the network status. This function uses an asynchronous callback to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Required permission**: ohos.permission.GET_NETWORK_INFO -- Parameters +**System capability**: SystemCapability.Telephony.CoreService - | Name| Type| Mandatory| Description| - | -------- | ---------------------------------------------- | ---- | ---------- | - | callback | AsyncCallback\<[NetworkState](#NetworkState)\> | Yes| Callback used to return the result.| +**Parameters** -- Example +| Name| Type| Mandatory| Description| +| -------- | ---------------------------------------------- | ---- | ---------- | +| callback | AsyncCallback\<[NetworkState](#NetworkState)\> | Yes| Callback used to return the result.| - ``` - radio.getNetworkState((err, data) =>{ - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +**Example** + +``` +radio.getNetworkState((err, data) =>{ + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## radio.getNetworkState @@ -98,23 +104,25 @@ getNetworkState\(slotId: number, callback: AsyncCallback\): void Obtains the network status of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CoreService -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | ---------------------------------------------- | ---- | -------------------------------------- | - | slotId | number | Yes| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback\<[NetworkState](#NetworkState)\> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | ---------------------------------------------- | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\<[NetworkState](#NetworkState)\> | Yes| Callback used to return the result.| -- Example +**Example** - ``` - let slotId = 0; - radio.getNetworkState(slotId, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +let slotId = 0; +radio.getNetworkState(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## radio.getNetworkState @@ -123,31 +131,33 @@ getNetworkState\(slotId?: number\): Promise Obtains the network status of the SIM card in the specified slot. This function uses a promise to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CoreService -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | -------------------------------------- | - | slotId | number | No| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | No| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| -- Return values +**Return value** - | Type| Description| - | ---------------------------------------- | --------------------------- | - | Promise\<[NetworkState](#NetworkState)\> | Promise used to return the result.| +| Type| Description| +| ---------------------------------------- | --------------------------- | +| Promise\<[NetworkState](#NetworkState)\> | Promise used to return the result.| -- Example +**Example** - ``` - let slotId = 0; - let promise = radio.getNetworkState(slotId); - promise.then(data => { - console.log(`getNetworkState success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.log(`getNetworkState fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let slotId = 0; +let promise = radio.getNetworkState(slotId); +promise.then(data => { + console.log(`getNetworkState success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getNetworkState fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## radio.getNetworkSelectionMode @@ -156,21 +166,23 @@ getNetworkSelectionMode\(slotId: number, callback: AsyncCallback - **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback\<[NetworkSelectionMode](#NetworkSelectionMode)\> | Yes| Callback used to return the result.| +**Parameters** -- Example +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\<[NetworkSelectionMode](#NetworkSelectionMode)\> | Yes| Callback used to return the result.| - ``` - let slotId = 0; - radio.getNetworkSelectionMode(slotId, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +**Example** + +``` +let slotId = 0; +radio.getNetworkSelectionMode(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## radio.getNetworkSelectionMode @@ -179,29 +191,31 @@ getNetworkSelectionMode\(slotId: number\): Promise Obtains the network selection mode of the SIM card in the specified slot. This function uses a promise to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CoreService - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | -------------------------------------- | - | slotId | number | Yes| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +**Parameters** -- Return values +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | Type| Description| - | -------------------------------------------------------- | ------------------------------- | - | Promise\<[NetworkSelectionMode](#NetworkSelectionMode)\> | Promise used to return the result.| +**Return value** -- Example +| Type| Description| +| -------------------------------------------------------- | ------------------------------- | +| Promise\<[NetworkSelectionMode](#NetworkSelectionMode)\> | Promise used to return the result.| - ``` - let slotId = 0; - let promise = radio.getNetworkSelectionMode(slotId); - promise.then(data => { - console.log(`getNetworkSelectionMode success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.log(`getNetworkSelectionMode fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +**Example** + +``` +let slotId = 0; +let promise = radio.getNetworkSelectionMode(slotId); +promise.then(data => { + console.log(`getNetworkSelectionMode success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getNetworkSelectionMode fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## radio.getISOCountryCodeForNetwork7+ @@ -210,21 +224,23 @@ getISOCountryCodeForNetwork\(slotId: number, callback: AsyncCallback\): Obtains the ISO country code of the network with which the SIM card in the specified slot is registered. This function uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CoreService - | Name| Type| Mandatory| Description| - | -------- | ----------------------- | ---- | ---------------------------------------- | - | slotId | number | Yes| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback\ | Yes| Callback used to return the result, which is a country code, for example, **CN** (China).| +**Parameters** -- Example +| Name| Type| Mandatory| Description| +| -------- | ----------------------- | ---- | ---------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\ | Yes| Callback used to return the result. which is a country code, for example, **CN** (China).| - ``` - let slotId = 0; - radio.getISOCountryCodeForNetwork(slotId, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +**Example** + +``` +let slotId = 0; +radio.getISOCountryCodeForNetwork(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## radio.getISOCountryCodeForNetwork7+ @@ -233,29 +249,31 @@ getISOCountryCodeForNetwork\(slotId: number\): Promise Obtains the ISO country code of the network with which the SIM card in the specified slot is registered. This function uses a promise to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | -------------------------------------- | - | slotId | number | Yes| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| -- Return values +**Return value** - | Type| Description| - | ----------------- | ------------------------------------------------------------ | - | Promise\ | Promise used to return the result, which is an ISO country code, for example, **CN** (China).| +| Type| Description| +| ----------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result, which is an ISO country code, for example, **CN** (China).| -- Example +**Example** - ``` - let slotId = 0; - let promise = radio.getISOCountryCodeForNetwork(slotId); - promise.then(data => { - console.log(`getISOCountryCodeForNetwork success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.log(`getISOCountryCodeForNetwork fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let slotId = 0; +let promise = radio.getISOCountryCodeForNetwork(slotId); +promise.then(data => { + console.log(`getISOCountryCodeForNetwork success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getISOCountryCodeForNetwork fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## radio.getSignalInformation @@ -264,21 +282,23 @@ getSignalInformation\(slotId: number, callback: AsyncCallback - **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback\\> | Yes| Callback used to return the result, which is a list of [SignalInformation](#SignalInformation) objects.| +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\\> | Yes| Callback used to return the result, which is a list of [SignalInformation](#SignalInformation) objects.| -- Example +**Example** - ``` - let slotId = 0; - radio.getSignalInformation(slotId, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +let slotId = 0; +radio.getSignalInformation(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## radio.getSignalInformation @@ -287,78 +307,176 @@ getSignalInformation\(slotId: number\): Promise\> Obtains a list of signal strengths of the network with which the SIM card in the specified slot is registered. This function uses a promise to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.CoreService - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | -------------------------------------- | - | slotId | number | Yes| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +**Parameters** -- Return values +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | Type| Description| - | ----------------------------------------------------------- | ------------------------------------------------------------ | - | Promise\\> | Promise used to return the result, which is a list of [SignalInformation](#SignalInformation) objects.| +**Return value** -- Example +| Type| Description| +| ----------------------------------------------------------- | ------------------------------------------------------------ | +| Promise\\> | Promise used to return the result, which is a list of [SignalInformation](#SignalInformation) objects.| - ``` - let slotId = 0; - let promise = radio.getSignalInformation(slotId); - promise.then(data => { - console.log(`getSignalInformation success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`getSignalInformation fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +**Example** + +``` +let slotId = 0; +let promise = radio.getSignalInformation(slotId); +promise.then(data => { + console.log(`getSignalInformation success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getSignalInformation fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## radio.isRadioOn7+ isRadioOn\(callback: AsyncCallback\): void -Checks whether radio is turned on. This function uses an asynchronous callback to return the result. +Checks whether the radio service is enabled on the primary SIM card. This function uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------ | ---- | ------------------------------------------------------- | +| callback | AsyncCallback\ | Yes| Callback used to return the result.
- **true**: The radio service is enabled.
- **false**: The radio service is disabled.| + +**Example** + +``` +radio.isRadioOn((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.isRadioOn7+ + +isRadioOn\(slotId: number, callback: AsyncCallback\): void + +Checks whether the radio service is enabled on the SIM card in the specified slot. This function uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------ | ---- | ------------------------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\ | Yes| Callback used to return the result.
- **true**: The radio service is enabled.
- **false**: The radio service is disabled.| -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +**Example** -- Parameters +``` +let slotId = 0; +radio.isRadioOn(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.isRadioOn7+ + +isRadioOn\(slotId?: number\): Promise - | Name| Type| Mandatory| Description| - | -------- | ------------------------ | ---- | ------------------------------------------------------- | - | callback | AsyncCallback\ | Yes| Callback used to return the result.
- **true**: Radio is turned on.
- **false**: Radio is turned off.| +Checks whether the radio service is enabled. This function uses a promise to return the result. -- Example +**Required permission**: ohos.permission.GET_NETWORK_INFO - ``` - radio.isRadioOn((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +**System capability**: SystemCapability.Telephony.CoreService +**Parameters** -## radio.isRadioOn7+ +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | No| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2
If the slot ID is not specified, this function is defaulted to check whether the radio service is enabled on the primary SIM card.| -isRadioOn\(\): Promise +**Return value** + +| Type| Description| +| ------------------ | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result.
- **true**: The radio service is enabled.
- **false**: The radio service is disabled.| + +**Example** + +``` +let slotId = 0; +let promise = radio.isRadioOn(slotId); +promise.then(data => { + console.log(`isRadioOn success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`isRadioOn fail, promise: err->${JSON.stringify(err)}`); +}); +``` -Checks whether radio is turned on. This function uses a promise to return the result. -Before using this API, you must declare the **ohos.permission.GET\_NETWORK\_INFO** permission. +## radio.getOperatorName7+ -- Return values +getOperatorName\(slotId: number, callback: AsyncCallback\): void - | Type| Description| - | ------------------ | ------------------------------------------------------------ | - | Promise\ | Promise used to return the result.
- **true**: Radio is turned on.
- **false**: Radio is turned off.| +Obtains the carrier name. This function uses an asynchronous callback to return the result. -- Example +**System capability**: SystemCapability.Telephony.CoreService - ``` - let promise = radio.isRadioOn(); - promise.then(data => { - console.log(`isRadioOn success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`isRadioOn fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ----------------------- | ---- | ------------------------------------------ | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\ | Yes| Callback used to return the result, which is the carrier name, for example, China Mobile.| + +**Example** + +``` +let slotId = 0; +radio.getOperatorName(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.getOperatorName7+ + +getOperatorName\(slotId: number\): Promise + +Obtains the carrier name. This function uses a promise to return the result. + +**System capability**: SystemCapability.Telephony.CoreService + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| + +**Return value** + +| Type| Description| +| ----------------- | ------------------------------------------------------------ | +| Promise\ | Promise used t return the result, which is the carrier name, for example, China Mobile.| + +**Example** + +``` +let slotId = 0; +let promise = radio.getOperatorName(slotId); +promise.then(data => { + console.log(`getOperatorName success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getOperatorName fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## RadioTechnology @@ -367,19 +485,19 @@ Enumerates the RATs. | Variable| Value| Description| | ------------------------- | ---- | ------------------------------------------------------------ | -| RADIO_TECHNOLOGY_UNKNOWN | 0 | Unknown| -| RADIO_TECHNOLOGY_GSM | 1 | Global System for Mobile Communication (GSM)| -| RADIO_TECHNOLOGY_1XRTT | 2 | Single-Carrier Radio Transmission Technology (1XRTT)| -| RADIO_TECHNOLOGY_WCDMA | 3 | Wideband Code Division Multiple Access (WCDMA)| -| RADIO_TECHNOLOGY_HSPA | 4 | High Speed Packet Access (HSPA)| -| RADIO_TECHNOLOGY_HSPAP | 5 | Evolved High Speed Packet Access (HSPA+)| -| RADIO_TECHNOLOGY_TD_SCDMA | 6 | Time Division Synchronous Code Division Multiple Access (TD-SCDMA)| -| RADIO_TECHNOLOGY_EVDO | 7 | Evolution-Data Optimized (EVDO)| -| RADIO_TECHNOLOGY_EHRPD | 8 | Evolved High Rate Package Data (EHRPD)| -| RADIO_TECHNOLOGY_LTE | 9 | Long Term Evolution (LTE)| -| RADIO_TECHNOLOGY_LTE_CA | 10 | Long Term Evolution_Carrier Aggregation (LTE_CA)| -| RADIO_TECHNOLOGY_IWLAN | 11 | Industrial Wireless LAN (IWLAN)| -| RADIO_TECHNOLOGY_NR | 12 | New Radio (NR)| +| RADIO_TECHNOLOGY_UNKNOWN | 0 | Unknown RAT
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_GSM | 1 | Global System for Mobile Communication (GSM)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_1XRTT | 2 | Single-Carrier Radio Transmission Technology (1XRTT)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_WCDMA | 3 | Wideband Code Division Multiple Access (WCDMA)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_HSPA | 4 | High Speed Packet Access (HSPA)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_HSPAP | 5 | Evolved High Speed Packet Access (HSPA+)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_TD_SCDMA | 6 | Time Division Synchronous Code Division Multiple Access (TD-SCDMA)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_EVDO | 7 | Evolution-Data Optimized (EVDO)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_EHRPD | 8 | Evolved High Rate Package Data (EHRPD)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_LTE | 9 | Long Term Evolution (LTE)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_LTE_CA | 10 | Long Term Evolution_Carrier Aggregation (LTE_CA)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_IWLAN | 11 | Industrial Wireless LAN (IWLAN)
**System capability**: SystemCapability.Telephony.CoreService| +| RADIO_TECHNOLOGY_NR | 12 | New Radio (NR)
**System capability**: SystemCapability.Telephony.CoreService| ## SignalInformation @@ -387,51 +505,52 @@ Enumerates the RATs. Defines the signal strength. | Attribute| Type| Description| -| ----------- | --------------------------- | ------------------ | -| signalType | [NetworkType](#NetworkType) | Signal strength type.| -| signalLevel | number | Signal strength level.| +| ----------- | --------------------------- | ------------------------------------------------------------ | +| signalType | [NetworkType](#NetworkType) | Signal strength type.
**System capability**: SystemCapability.Telephony.CoreService| +| signalLevel | number | Signal strength level.
**System capability**: SystemCapability.Telephony.CoreService| ## NetworkType -Enumerates network types. +Defines the network type. | Variable| Value| Description| | -------------------- | ---- | ------------------------------------------------------------ | -| NETWORK_TYPE_UNKNOWN | 0 | Unknown| -| NETWORK_TYPE_GSM | 1 | GSM network| -| NETWORK_TYPE_CDMA | 2 | CDMA network| -| NETWORK_TYPE_WCDMA | 3 | WCDMA network| -| NETWORK_TYPE_TDSCDMA | 4 | TD-SCDMA network| -| NETWORK_TYPE_LTE | 5 | LTE network| -| NETWORK_TYPE_NR | 6 | 5G NR network| +| NETWORK_TYPE_UNKNOWN | 0 | Unknown network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_GSM | 1 | GSM network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_CDMA | 2 | CDMA network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_WCDMA | 3 | WCDMA network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_TDSCDMA | 4 | TD-SCDMA network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_LTE | 5 | LTE network
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_TYPE_NR | 6 | 5G NR network
**System capability**: SystemCapability.Telephony.CoreService| ## NetworkState Defines the network registration status. | Variable| Type| Description| -| ----------------- | --------------------- | ------------------------------ | -| longOperatorName | string | Long carrier name of the registered network.| -| shortOperatorName | string | Short carrier name of the registered network.| -| plmnNumeric | string | PLMN code of the registered network.| -| isRoaming | boolean | Whether the user is roaming.| -| regState | [RegState](#RegState) | Network registration status of the device.| -| nsaState | [NsaState](#NsaState) | NSA network registration status of the device.| -| isCaActive | boolean | Whether carrier aggregation (CA) is supported.| -| isEmergency | boolean | Whether only emergency calls are allowed.| +| ----------------- | --------------------- | ------------------------------------------------------------ | +| longOperatorName | string | Long carrier name of the registered network.
**System capability**: SystemCapability.Telephony.CoreService| +| shortOperatorName | string | Short carrier name of the registered network.
**System capability**: SystemCapability.Telephony.CoreService| +| plmnNumeric | string | PLMN code of the registered network.
**System capability**: SystemCapability.Telephony.CoreService| +| isRoaming | boolean | Whether the user is roaming.
**System capability**: SystemCapability.Telephony.CoreService| +| regState | [RegState](#RegState) | Network registration status of the device.
**System capability**: SystemCapability.Telephony.CoreService| +| cfgTech8+ | [RadioTechnology](#RadioTechnology) | RAT of the device.
**System capability**: SystemCapability.Telephony.CoreService| +| nsaState | [NsaState](#NsaState) | NSA network registration status of the device.
**System capability**: SystemCapability.Telephony.CoreService| +| isCaActive | boolean | CA status.
**System capability**: SystemCapability.Telephony.CoreService| +| isEmergency | boolean | Whether only emergency calls are allowed.
**System capability**: SystemCapability.Telephony.CoreService| ## RegState -Enumerates network registration states. +Defines the network registration status. | Variable| Value| Description| -| ----------------------------- | ---- | -------------------------- | -| REG_STATE_NO_SERVICE | 0 | The device cannot use any service.| -| REG_STATE_IN_SERVICE | 1 | The device can use services normally. | -| REG_STATE_EMERGENCY_CALL_ONLY | 2 | The device can use only the emergency call service.| -| REG_STATE_POWER_OFF | 3 | The cellular radio service is disabled.| +| ----------------------------- | ---- | ------------------------------------------------------------ | +| REG_STATE_NO_SERVICE | 0 | The device cannot use any service.
**System capability**: SystemCapability.Telephony.CoreService| +| REG_STATE_IN_SERVICE | 1 | The device can use services normally.
**System capability**: SystemCapability.Telephony.CoreService| +| REG_STATE_EMERGENCY_CALL_ONLY | 2 | The device can use only the emergency call service.
**System capability**: SystemCapability.Telephony.CoreService| +| REG_STATE_POWER_OFF | 3 | The cellular radio service is disabled.
**System capability**: SystemCapability.Telephony.CoreService| ## NsaState @@ -439,13 +558,13 @@ Enumerates network registration states. Enumerates NSA network states. | Variable| Value| Description| -| -------------------------- | ---- | ---------------------------------------------------------- | -| NSA_STATE_NOT_SUPPORT | 1 | The device is in idle or connected state in an LTE cell that does not support NSA.| -| NSA_STATE_NO_DETECT | 2 | The device is in the idle state in an LTE cell that supports NSA but does not support NR coverage detection.| -| NSA_STATE_CONNECTED_DETECT | 3 | The device is connected to the LTE network in an LTE cell that supports NSA and NR coverage detection.| -| NSA_STATE_IDLE_DETECT | 4 | The device is in the idle state in an LTE cell that supports NSA and NR coverage detection.| -| NSA_STATE_DUAL_CONNECTED | 5 | The device is connected to the LTE/NR network in an LTE cell that supports NSA.| -| NSA_STATE_SA_ATTACHED | 6 | The device is idle or connected to the NG-RAN cell when being attached to the 5G Core.| +| -------------------------- | ---- | ------------------------------------------------------------ | +| NSA_STATE_NOT_SUPPORT | 1 | The device is in idle or connected state in an LTE cell that does not support NSA.
**System capability**: SystemCapability.Telephony.CoreService| +| NSA_STATE_NO_DETECT | 2 | The device is in the idle state in an LTE cell that supports NSA but does not support NR coverage detection.
**System capability**: SystemCapability.Telephony.CoreService| +| NSA_STATE_CONNECTED_DETECT | 3 | The device is connected to the LTE network in an LTE cell that supports NSA and NR coverage detection.
**System capability**: SystemCapability.Telephony.CoreService| +| NSA_STATE_IDLE_DETECT | 4 | The device is in the idle state in an LTE cell that supports NSA and NR coverage detection.
**System capability**: SystemCapability.Telephony.CoreService| +| NSA_STATE_DUAL_CONNECTED | 5 | The device is connected to the LTE/NR network in an LTE cell that supports NSA.
**System capability**: SystemCapability.Telephony.CoreService| +| NSA_STATE_SA_ATTACHED | 6 | The device is idle or connected to the NG-RAN cell when being attached to the 5G Core.
**System capability**: SystemCapability.Telephony.CoreService| ## NetworkSelectionMode @@ -453,7 +572,7 @@ Enumerates NSA network states. Enumerates network selection modes. | Variable| Value| Description| -| --------------------------- | ---- | -------------- | -| NETWORK_SELECTION_UNKNOWN | 0 | Unknown network selection mode.| -| NETWORK_SELECTION_AUTOMATIC | 1 | Automatic network selection mode.| -| NETWORK_SELECTION_MANUAL | 2 | Manual network selection mode.| +| --------------------------- | ---- | ------------------------------------------------------------ | +| NETWORK_SELECTION_UNKNOWN | 0 | Unknown network selection mode.
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_SELECTION_AUTOMATIC | 1 | Automatic network selection mode.
**System capability**: SystemCapability.Telephony.CoreService| +| NETWORK_SELECTION_MANUAL | 2 | Manual network selection mode.
**System capability**: SystemCapability.Telephony.CoreService| diff --git a/en/application-dev/reference/apis/js-apis-runninglock.md b/en/application-dev/reference/apis/js-apis-runninglock.md index 106d47b814e282b0d22b84d1f84dfe1163313172..beefced18a8644010ac28c30c1e40a902e5e6cb2 100644 --- a/en/application-dev/reference/apis/js-apis-runninglock.md +++ b/en/application-dev/reference/apis/js-apis-runninglock.md @@ -1,403 +1,226 @@ -# Running Lock +# Running Lock ->![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** ->The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Modules to Import + +## Modules to Import ``` import runninglock from '@ohos.runningLock'; ``` + ## System Capabilities SystemCapability.PowerManager.PowerManager -## RunningLockType - -Enumerates the types of running locks. - - - - - - - - - - - - - - - - -

Description

-

Default Value

-

Description

-

BACKGROUND

-

1

-

A lock that prevents the system from hibernating.

-

PROXIMITY_SCREEN_CONTROL

-

2

-

A lock that determines whether to turn on or off the screen based on the distance away from the screen.

-
- -## runninglock.isRunningLockTypeSupported - -isRunningLockTypeSupported\(type: RunningLockType, callback: AsyncCallback\): void - -Checks whether a specified type of **RunningLock** is supported. This function uses an asynchronous callback to return the result. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

type

-

RunningLockType

-

Yes

-

Type of the RunningLock object.

-

callback

-

AsyncCallback<boolean>

-

Yes

-

Callback used to obtain the return value.

-

The value true indicates that the specified type of RunningLock is supported, and value false indicates the opposite.

-
- -- Example - - ``` - runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (error, supported) => { - if (typeof error === "undefined") { - console.info('BACKGROUND support status is ' + supported); - } else { - console.log('error: ' + error); - } - }) - ``` - - -## runninglock.isRunningLockTypeSupported - -isRunningLockTypeSupported\(type: RunningLockType\): Promise - -Checks whether a specified type of **RunningLock** is supported. This function uses a promise to return the result. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

type

-

RunningLockType

-

Yes

-

Type of the RunningLock object.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<boolean>

-

Promise used to asynchronously obtain the return value. The value true indicates that the specified type of RunningLock is supported, and value false indicates the opposite.

-
- -- Example - - ``` - runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL) - .then(supported => { - console.info('PROXIMITY_SCREEN_CONTROL support status is ' + supported); - }) - .catch(error => { +## RunningLockType + +Enumerates the types of **RunningLock** objects. + +| Name| Default Value| Description| +| -------- | -------- | -------- | +| BACKGROUND | 1 | Defines a **RunningLock** object.| +| PROXIMITY_SCREEN_CONTROL | 2 | A lock that determines whether to turn on or off the screen based on the distance away from the screen.| + + +## isRunningLockTypeSupported + +isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback<boolean>): void + +Checks whether a specified type of RunningLock is supported. This function uses an asynchronous callback to return the result. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| type | RunningLockType | Yes| Type of the **RunningLock** object.| +| callback | AsyncCallback<boolean> | Yes| Callback used to obtain the return value.
The value **true** indicates that the specified type of **RunningLock** is supported, and value **false** indicates the opposite.| + +**Example** + +``` +runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.BACKGROUND, (error, supported) => { + if (typeof error === "undefined") { + console.info('BACKGROUND support status is ' + supported); + } else { console.log('error: ' + error); - }); - ``` - - -## runninglock.createRunningLock - -createRunningLock\(name: string, type: RunningLockType, callback: AsyncCallback\): void - -Creates a **RunningLock** object. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

Yes

-

Name of the RunningLock object.

-

type

-

RunningLockType

-

Yes

-

Type of the RunningLock object to be created.

-

callback

-

AsyncCallback<RunningLock>

-

Yes

-

Callback used to obtain the return value.

-
- -- Example - - ``` - runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) - .then(runninglock => { - var used = runninglock.isUsed(); - console.info('runninglock is used: ' + used); - runninglock.lock(500); - used = runninglock.isUsed(); - console.info('after lock runninglock is used ' + used); - }) - .catch(error => { - console.log('create runningLock test error: ' + error); - }) - ``` - - -## runninglock.createRunningLock - -createRunningLock\(name: string, type: RunningLockType\): Promise - -Creates a **RunningLock** object. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

name

-

string

-

Yes

-

Name of the RunningLock object.

-

type

-

RunningLockType

-

Yes

-

Type of the RunningLock object to be created.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<RunningLock>

-

Promise used to asynchronously obtain the returned RunningLock object.

-
- -- Example - - ``` - runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) - .then(runninglock => { - console.info('create runningLock success'); - }) - .catch(error => { - console.log('create runningLock test error: ' + error); - }) - ``` - - -## RunningLock - -Defines a **RunningLock** object. - -### lock - -lock\(timeout: number\): void - -Locks and holds a **RunningLock** object. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

timeout

-

number

-

No

-

Duration for locking and holding the RunningLock object.

-
- -- Example - - ``` - runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) - .then(runningLock => { - runningLock.lock(100) - console.info('create runningLock success') - }) - .catch(error => { - console.log('Lock runningLock test error: ' + error) - }); - ``` - - -### unlock - -unlock\(\): void - -Releases a **Runninglock** object. - -- Example - - ``` - runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) - .then(runningLock => { - runningLock.unlock() - console.info('unLock runningLock success') - }) - .catch(error => { - console.log('unLock runningLock test error: ' + error) - }); - ``` - - -### isUsed - -isUsed\(\): boolean - -Checks the status of the **Runninglock** object. - -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

Returns true if the Runninglock object is held; returns false if the Runninglock object is released.

-
- -- Example - - ``` - runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) - .then(runningLock => { - var used = runningLock.isUsed() - console.info('runningLock used status: ' + used) - }) - .catch(error => { - console.log('runningLock isUsed test error: ' + error) - }); - ``` + } +}) +``` + + +## isRunningLockTypeSupported + +isRunningLockTypeSupported(type: RunningLockType): Promise<boolean> + +Checks whether a specified type of **RunningLock** is supported. This function uses an asynchronous callback to return the result. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| type | RunningLockType | Yes| Type of the **RunningLock** object.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<boolean> | Promise used to asynchronously obtain the return value. The value **true** indicates that the specified type of **RunningLock** is supported, and value **false** indicates the opposite.| + +**Example** + +``` +runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL) +.then(supported => { + console.info('PROXIMITY_SCREEN_CONTROL support status is ' + supported); +}) +.catch(error => { + console.log('error: ' + error); +}); +``` + + +## createRunningLock + +createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback<RunningLock>): void + +Creates a **RunningLock** object. + +Before using this API, you must declare the **ohos.permission.RUNNING_LOCK** permission. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Name of the **RunningLock** object.| +| type | RunningLockType | Yes| Type of the **RunningLock** object to be created.| +| callback | AsyncCallback<[RunningLock](#runninglock)> | Yes| Callback used to obtain the return value.| + +**Example** + +``` +runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) +.then(runninglock => { + var used = runninglock.isUsed(); + console.info('runninglock is used: ' + used); + runninglock.lock(500); + used = runninglock.isUsed(); + console.info('after lock runninglock is used ' + used); +}) +.catch(error => { + console.log('create runningLock test error: ' + error); +}) +``` + + +## createRunningLock +createRunningLock(name: string, type: RunningLockType): Promise<RunningLock> +Creates a **RunningLock** object. + +Before using this API, you must declare the **ohos.permission.RUNNING_LOCK** permission. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Name of the **RunningLock** object.| +| type | RunningLockType | Yes| Type of the **RunningLock** object to be created.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<[RunningLock](#runninglock)> | Promise used to asynchronously obtain the returned **RunningLock** object.| + +**Example** + +``` +runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) +.then(runninglock => { + console.info('create runningLock success'); +}) +.catch(error => { + console.log('create runningLock test error: ' + error); +}) +``` + + +## RunningLock + +Defines a **RunningLock** object. + + +### lock + +lock(timeout: number): void + +Locks and holds a **RunningLock** object. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| timeout | number | No| Duration for locking and holding the **RunningLock** object.| + +**Example** + +``` +runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) +.then(runningLock => { + runningLock.lock(100) + console.info('create runningLock success') +}) +.catch(error => { + console.log('Lock runningLock test error: ' + error) +}); +``` + + +### unlock + +unlock(): void + +Releases a **Runninglock** object. + +**Example** + +``` +runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) +.then(runningLock => { + runningLock.unlock() + console.info('unLock runningLock success') +}) +.catch(error => { + console.log('unLock runningLock test error: ' + error) +}); +``` + + +### isUsed + +isUsed(): boolean + +Checks the status of the **Runninglock** object. + +**Return value** +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the **Runninglock** object is held; returns **false** if the **Runninglock** object is released.| + +**Example** + +``` +runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.BACKGROUND) +.then(runningLock => { + var used = runningLock.isUsed() + console.info('runningLock used status: ' + used) +}) +.catch(error => { + console.log('runningLock isUsed test error: ' + error) +}); +``` diff --git a/en/application-dev/reference/apis/js-apis-screenshot.md b/en/application-dev/reference/apis/js-apis-screenshot.md new file mode 100644 index 0000000000000000000000000000000000000000..1a402eb84c10b9a6e914f0a10b789eebe1df61e1 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-screenshot.md @@ -0,0 +1,126 @@ +# Screenshot + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +``` +import screenshot from '@ohos.screenshot'; +``` + +## ScreenshotOptions + +Describes screenshot options. + +| Name| Type| Mandatory| Description| +| ---------- | ------------- | ---- | ------------------------------------------------------------ | +| screenRect | [Rect](#Rect) | No| Region of the screen to capture. If this parameter is null, the full screen will be captured.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| imageSize | [Size](#Size) | No| Size of the screen region to capture. If this parameter is null, the full screen will be captured.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| rotation | number | No| Rotation angle of the screenshot. The value can be **0**, **90**, **180**, or **270**. The default value is **0**.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| + + +## Rect + +Describes the region of the screen to capture. + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | ------------------------------------------------------------ | +| left | number | Yes| Left boundary of the screen region to capture.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| top | number | Yes| Top boundary of the screen region to capture.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| width | number | Yes| Width of the screen region to capture.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| height | number | Yes| Height of the screen region to capture.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| + + +## Size + +Describes the size of the screen region to capture. + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | ------------------------------------------------------------ | +| width | number | Yes| Width of the screen region to capture.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| +| height | number | Yes| Height of the screen region to capture.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core| + +## screenshot.save + +save(options?: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>): void + +Takes a screenshot and saves it as a **PixelMap** object. This method uses a callback to return the result. + +**System capabilities**: SystemCapability.WindowManager.WindowManager.Core + +**Required permissions**: ohos.permission.CAPTURE_SCREEN + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | + | options | [ScreenshotOptions](#ScreenshotOptions) | No| Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| + | callback | AsyncCallback<image.PixelMap> | Yes| Callback used to return a **PixelMap** object.| + +- Example + + ``` + var ScreenshotOptions = { + "screenRect": { + "left": 200, + "top": 100, + "width": 200, + "height": 200}, + "imageSize": { + "width": 300, + "height": 300}, + "rotation": 0 + }; + screenshot.save(ScreenshotOptions, (err, data) => { + if (err) { + console.error('Failed to save the screenshot. Error: ' + JSON.stringify(err)); + return; + } + console.info('Screenshot saved. Data: ' + JSON.stringify(data)); + }); + ``` + +## screenshot.save + +save(options?: ScreenshotOptions): Promise<image.PixelMap> + +Takes a screenshot and saves it as a **PixelMap** object. This method uses a promise to return the result. + +**System capabilities**: SystemCapability.WindowManager.WindowManager.Core + +**Required permissions**: ohos.permission.CAPTURE_SCREEN + +- Parameters + + | Name| Type| Mandatory| Description| + | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | + | options | [ScreenshotOptions](#ScreenshotOptions) | No| Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| + +- Return value + + | Type| Description| + | ----------------------------- | ----------------------------------------------- | + | Promise<image.PixelMap> | Promise used to return an **image.PixelMap** object.| + +- Example + + ``` + var ScreenshotOptions = { + "screenRect": { + "left": 200, + "top": 100, + "width": 200, + "height": 200}, + "imageSize": { + "width": 300, + "height": 300}, + "rotation": 0 + }; + let promise = screenshot.save(ScreenshotOptions); + promise.then(() => { + console.log('screenshot save success'); + }).catch((err) => { + console.log('screenshot save fail: ' + JSON.stringify(err)); + }); + ``` diff --git a/en/application-dev/reference/apis/js-apis-sensor.md b/en/application-dev/reference/apis/js-apis-sensor.md index 440a79eab1934eba07f7ca2c90cdc20c96fafe62..8b9cf97f184547b9f5ce59da96bf85a6021bee55 100644 --- a/en/application-dev/reference/apis/js-apis-sensor.md +++ b/en/application-dev/reference/apis/js-apis-sensor.md @@ -1,6 +1,6 @@ # Sensor -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -1172,9 +1172,72 @@ Unsubscribes from sensor data changes. console.info("Succeeded in unsubscribing from acceleration sensor data."); } ); - ``` +## sensor.transformCoordinateSystem + +transformCoordinateSystem(inRotationVector: Array<number>, coordinates: CoordinatesOptions, callback: AsyncCallback<Array<number>>): void + +Rotates a rotation vector so that it can represent the coordinate system in different ways. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------------- | ----------------------------------------- | ---- | ---------------------- | + | inRotationVector | Array<number> | Yes| Rotation vector to rotate.| + | coordinates | [CoordinatesOptions](#coordinatesoptions) | Yes| Direction of the coordinate system.| + | callback | AsyncCallback<Array<number>> | Yes| Callback used to return the rotation vector after being rotated.| + +- Example + + ``` + sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) { + if (err) { + console.error("Operation failed. Error code: " + err.code + ", message: " + err.message); + return; + } + console.info("Operation successed. Data obtained: " + data.x); + for (var i=0; i < data.length; i++) { + console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); + } + }) + ``` + +## sensor.transformCoordinateSystem + +transformCoordinateSystem(inRotationVector: Array<number>, coordinates: CoordinatesOptions): Promise<Array<number>> + +Rotates a rotation vector so that it can represent the coordinate system in different ways. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------------- | ----------------------------------------- | ---- | ---------------- | + | inRotationVector | Array<number> | Yes| Rotation vector to rotate.| + | coordinates | [CoordinatesOptions](#coordinatesoptions) | Yes| Direction of the coordinate system.| + +- Return value + + | Type| Description| + | ---------------------------------- | ---------------------- | + | Promise<Array<number>> | Promise used to return the rotation vector after being converted.| + +- Example + + ``` + const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}); + promise.then((data) => { + console.info("Operation successed."); + for (var i=0; i < data.length; i++) { + console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); + } + }).catch((err) => { + console.info("Operation failed"); + }) + ``` + + + ## sensor.getGeomagneticField @@ -1207,7 +1270,7 @@ Obtains the geomagnetic field of a geographic location. This method uses a callb getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise<GeomagneticResponse> -Obtains the geomagnetic field of a geographic location. This method uses a callback to return the result. +Obtains the geomagnetic field of a geographic location. This method uses a promise to return the result. - Parameters | Name| Type| Mandatory| Description| @@ -1218,7 +1281,7 @@ Obtains the geomagnetic field of a geographic location. This method uses a callb - Return value | Type| Description| | -------- | -------- | - | Promise<[GeomagneticResponse](#geomagneticresponse)> | Callback used to return the geomagnetic field.| + | Promise<[GeomagneticResponse](#geomagneticresponse)> | Promise used to return the geomagnetic field.| - Example ``` @@ -1232,6 +1295,437 @@ Obtains the geomagnetic field of a geographic location. This method uses a callb }) ``` +## sensor.getAltitude + +getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback<number>): void + +Obtains the altitude at which the device is located based on the sea-level atmospheric pressure and the current atmospheric pressure. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | --------------- | --------------------------- | ---- | ------------------------------------- | + | seaPressure | number | Yes| Sea-level atmospheric pressure, in hPa.| + | currentPressure | number | Yes| Current atmospheric pressure at the altitude where the device is located, in hPa.| + | callback | AsyncCallback<number> | Yes| Callback used to return the altitude, in meters.| + +- Example + + ``` + sensor.getAltitude(0, 200, function(err, data) { + if (err) { + console.error( + "Operation failed. Error code: " + err.code + ", message: " + err.message); + return; + } + console.info("Successed to get getAltitude interface get data: " + data); + }); + ``` + +## sensor.getAltitude + +getAltitude(seaPressure: number, currentPressure: number): Promise<number> + +Obtains the altitude at which the device is located based on the sea-level atmospheric pressure and the current atmospheric pressure. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | --------------- | ------ | ---- | ------------------------------------- | + | seaPressure | number | Yes| Sea-level atmospheric pressure, in hPa.| + | currentPressure | number | Yes| Atmospheric pressure at the altitude where the device is located, in hPa.| + +- Return value + + | Type| Description| + | --------------------- | ------------------------------------ | + | Promise<number> | Promise used to return the altitude, in meters.| + +- Example + + ``` + const promise = sensor.getAltitude(0, 200); + promise.then((data) => { + console.info(' sensor_getAltitude_Promise success', data); + }).catch((err) => { + console.error("Operation failed"); + }) + ``` + + +## sensor.getGeomagneticDip + +getGeomagneticDip(inclinationMatrix: Array<number>, callback: AsyncCallback<number>): void + +Obtains the magnetic dip based on the inclination matrix. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ----------------- | --------------------------- | ---- | ---------------------------- | + | inclinationMatrix | Array<number> | Yes| Inclination matrix.| + | callback | AsyncCallback<number> | Yes| Callback used to return the magnetic dip, in radians.| + +- Example + + ``` + sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { + if (err) { + console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info(Successed to get getGeomagneticDip interface get data: " + data); + }) + ``` + +## sensor.getGeomagneticDip + +getGeomagneticDip(inclinationMatrix: Array<number>): Promise<number> + +Obtains the magnetic dip based on the inclination matrix. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ----------------- | ------------------- | ---- | -------------- | + | inclinationMatrix | Array<number> | Yes| Inclination matrix.| + +- Return value + + | Type| Description| + | --------------------- | ---------------------------- | + | Promise<number> | Promise used to return the magnetic dip, in radians.| + +- Example + + ``` + const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]); + promise.then((data) => { + console.info(' getGeomagneticDip_promise successed', data); + }).catch((err) => { + console.error("Operation failed"); + }) + ``` + +## sensor. getAngleModify + +getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>, callback: AsyncCallback<Array<number>>): void + +Obtains the angle change between two rotation matrices. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | --------------------- | ---------------------------------------- | ---- | --------------------------------- | + | currentRotationMatrix | Array<number> | Yes| Current rotation matrix.| + | preRotationMatrix | Array<number> | Yes| The other rotation matrix.| + | callback | AsyncCallback<Array<number>> | Yes| Callback used to return the angle change around the z, x, and y axes.| + +- Example + + ``` + sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) { + if (err) { + console.error(LABEL + 'Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info("SensorJsAPI--->Successed to get getAngleModifiy interface get data: " + data.x); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }) + ``` + + +## sensor. getAngleModify + +getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Array<number>): Promise<Array<number>> + +Obtains the angle change between two rotation matrices. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | --------------------- | ------------------- | ---- | ------------------ | + | currentRotationMatrix | Array<number> | Yes| Current rotation matrix.| + | preRotationMatrix | Array<number> | Yes| The other rotation matrix.| + +- Return value + + | Type| Description| + | ---------------------------------- | --------------------------------- | + | Promise<Array<number>> | Promise used to return the angle change around the z, x, and y axes.| + +- Example + + ``` + const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]); + promise.then((data) => { + console.info(LABEL + 'getAngleModifiy_promise success'); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }).catch((reason) => { + console.info(LABEL + "promise::catch", reason); + }) + ``` + + +## sensor.createRotationMatrix + +createRotationMatrix(rotationVector: Array<number>, callback: AsyncCallback<Array<number>>): void + +Converts a rotation vector into a rotation matrix. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ---------------------------------------- | ---- | -------------- | + | rotationVector | Array<number> | Yes| Rotation vector to convert.| + | callback | AsyncCallback<Array<number>> | Yes| Callback used to return the rotation matrix.| + +- Example + + ``` + sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { + if (err) { + console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }) + ``` + + +## sensor.createRotationMatrix + +createRotationMatrix(rotationVector: Array<number>): Promise<Array<number>> + +Converts a rotation vector into a rotation matrix. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ------------------- | ---- | -------------- | + | rotationVector | Array<number> | Yes| Rotation vector to convert.| + +- Return value + + | Type| Description| + | ---------------------------------- | -------------- | + | Promise<Array<number>> | Promise used to return the rotation matrix.| + +- Example + + ``` + const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]); + promise.then((data) => { + console.info(LABEL + 'createRotationMatrix_promise success'); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }).catch((reason) => { + console.info(LABEL + "promise::catch", reason); + }) + ``` + + +## sensor.createQuaternion + +createQuaternion(rotationVector: Array<number>, callback: AsyncCallback<Array<number>>): void + +Converts a rotation vector into a quaternion. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ---------------------------------------- | ---- | -------------- | + | rotationVector | Array<number> | Yes| Rotation vector to convert.| + | callback | AsyncCallback<Array<number>> | Yes| Callback used to return the quaternion.| + +- Example + + ``` + sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { + if (err) { + console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info("SensorJsAPI--->Successed to get createQuaternion interface get data: " + data.x); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }) + ``` + + +## sensor.createQuaternion + +createQuaternion(rotationVector: Array<number>): Promise<Array<number>> + +Converts a rotation vector into a quaternion. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ------------------- | ---- | -------------- | + | rotationVector | Array<number> | Yes| Rotation vector to convert.| + +- Return value + + | Type| Description| + | ---------------------------------- | ------------ | + | Promise<Array<number>> | Promise used to return the quaternion.| + +- Example + + ``` + const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]); + promise.then((data) => { + console.info('createQuaternion_promise successed'); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }).catch((err) => { + console.info('promise failed'); + }) + ``` + + +## sensor.getDirection + +getDirection(rotationMatrix: Array<number>, callback: AsyncCallback<Array<number>>): void + +Obtains the device direction based on the rotation matrix. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ---------------------------------------- | ---- | --------------------------------- | + | rotationMatrix | Array<number> | Yes| Rotation matrix.| + | callback | AsyncCallback<Array<number>> | Yes| Callback used to return the rotation angle around the z, x, and y axes.| + +- Example + + ``` + sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { + if (err) { + console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info(LABEL + "SensorJsAPI--->Successed to get getDirection interface get data: " + data.x); + for (var i = 1; i < data.length; i++) { + console.info(TAG +"sensor_getDirection_callback" + data[i]); + } + }) + ``` + + +## sensor.getDirection + +getDirection(rotationMatrix: Array<number>): Promise<Array<number>> + +Obtains the device direction based on the rotation matrix. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------------- | ------------------- | ---- | -------------- | + | rotationMatrix | Array<number> | Yes| Rotation matrix.| + +- Return value + + | Type| Description| + | ---------------------------------- | --------------------------------- | + | Promise<Array<number>> | Promise used to return the rotation angle around the z, x, and y axes.| + +- Example + + ``` + const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]); + promise.then((data) => { + console.info(' sensor_getAltitude_Promise success', data.x); + for (var i = 1; i < data.length; i++) { + console.info(TAG +"sensor_getDirection_promise" + data[i]); + } + }).catch((err) => { + console.info('promise failed'); + }) + ``` + + +## sensor.createRotationMatrix + +createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>, callback: AsyncCallback<RotationMatrixResponse>): void + +Creates a rotation matrix based on the gravity vector and geomagnetic vector. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ----------- | ------------------------------------------------------------ | ---- | -------------- | + | gravity | Array<number> | Yes| Gravity vector.| + | geomagnetic | Array<number> | Yes| Geomagnetic vector.| + | callback | AsyncCallback<[RotationMatrixResponse](#rotationmatrixresponse)> | Yes| Callback used to return the rotation matrix.| + +- Example + + ``` + sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) { + if (err) { + console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + + err.message); + return; + } + console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]) + } + }) + ``` + + +## sensor.createRotationMatrix + +createRotationMatrix(gravity: Array<number>, geomagnetic: Array<number>,): Promise<RotationMatrixResponse> + +Creates a rotation matrix based on the gravity vector and geomagnetic vector. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ----------- | ------------------- | ---- | -------------- | + | gravity | Array<number> | Yes| Gravity vector.| + | geomagnetic | Array<number> | Yes| Geomagnetic vector.| + +- Return value + + | Type| Description| + | ------------------------------------------------------------ | -------------- | + | Promise<[RotationMatrixResponse](#rotationmatrixresponse)> | Promise used to return the rotation matrix.| + +- Example + + ``` + const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]); + promise.then((data) => { + console.info(LABEL + 'createRotationMatrix_promise successed'); + for (var i=0; i < data.length; i++) { + console.info(LABEL + "data[" + i + "]: " + data[i]); + } + }).catch((err) => { + console.info(LABEL + 'promise failed'); + }) + ``` + ## SensorType @@ -1519,6 +2013,25 @@ Describes the sensor data reporting frequency. | -------- | -------- | -------- | | interval | number | Frequency at which a sensor reports data. The default value is 200,000,000 ns.| +## RotationMatrixResponse + +Describes the response for setting the rotation matrix. + +| Name| Type| Readable| Writable| Description| +| ----------- | ------------------- | ---- | ---- | ---------- | +| rotation | Array<number> | Yes| Yes| Rotation matrix.| +| inclination | Array<number> | Yes| Yes| Inclination matrix.| + + +## CoordinatesOptions + +Describes the coordinate options. + +| Name| Type| Readable| Writable| Description| +| ---- | -------- | ---- | ---- | ----------- | +| x | number | Yes| Yes| X coordinate direction.| +| y | number | Yes| Yes| Y coordinate direction.| + ## GeomagneticResponse diff --git a/en/application-dev/reference/apis/js-apis-service-extension-context.md b/en/application-dev/reference/apis/js-apis-service-extension-context.md index fa46ef6df13d0e7bd7b4c8dd788fbe4184417488..1c1d2b615a5b9344fab4247aa3b3e84b963c3a0b 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-service-extension-context.md @@ -1,6 +1,6 @@ # ServiceExtensionContext -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -16,10 +16,14 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; Starts an ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to start, such as the ability name and bundle name.| + | want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to start, such as the ability name and bundle name.| | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the method is successfully called.| - Example @@ -29,8 +33,8 @@ Starts an ability. This method uses a callback to return the result. "abilityName": "com.example.myapp.MyAbility" }; this.context.startAbility(want, (err) => { - console.log('startAbility result:' + JSON.stringfy(err); - } + console.log('startAbility result:' + JSON.stringfy(err)); + }); ``` @@ -40,10 +44,14 @@ startAbility(want: Want): Promise<void>; Starts an ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to start, such as the ability name and bundle name.| + | want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to start, such as the ability name and bundle name.| - Return value | Type| Description| @@ -58,7 +66,7 @@ Starts an ability. This method uses a promise to return the result. }; this.context.startAbility(want).then((data) => { console.log('success:' + JSON.stringfy(data)); - )).catch((error) => { + }).catch((error) => { console.log('failed:' + JSON.stringfy(error)); }); ``` @@ -70,6 +78,10 @@ terminateSelf(callback: AsyncCallback<void>): void; Terminates this ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -78,8 +90,8 @@ Terminates this ability. This method uses a callback to return the result. - Example ``` this.context.terminateSelf((err) => { - console.log('terminateSelf result:' + JSON.stringfy(err); - } + console.log('terminateSelf result:' + JSON.stringfy(err)); + }); ``` @@ -89,6 +101,10 @@ terminateSelf(): Promise<void>; Terminates this ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Return value | Type| Description| | -------- | -------- | @@ -98,7 +114,7 @@ Terminates this ability. This method uses a promise to return the result. ``` this.context.terminateSelf(want).then((data) => { console.log('success:' + JSON.stringfy(data)); - )).catch((error) => { + }).catch((error) => { console.log('failed:' + JSON.stringfy(error)); }); ``` @@ -110,10 +126,14 @@ connectAbility(want: Want, options: ConnectOptions): number; Connects this ability to a Service ability. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-featureAbility.md#Want)| Yes| Information about the ability to connect to, such as the ability name and bundle name.| + | want | [Want](js-apis-featureAbility.md#Want) | Yes| Information about the ability to connect to, such as the ability name and bundle name.| | options | [ConnectOptions](#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.| - Return value @@ -128,8 +148,8 @@ Connects this ability to a Service ability. "abilityName": "com.example.myapp.MyAbility" }; let options = { - onConnect: function(elementName, proxy) {} - onDisConnect: function(elementName) {} + onConnect: function(elementName, proxy) {}, + onDisConnect: function(elementName) {}, onFailed: function(code) {} } let connection = this.context.connectAbility(want,options); @@ -142,6 +162,10 @@ disconnectAbility(connection: number, callback:AsyncCallback<void>): void; Disconnects this ability from the Service ability. This method uses a callback to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -151,8 +175,8 @@ Disconnects this ability from the Service ability. This method uses a callback t - Example ``` this.context.disconnectAbility(connection, (err) => { // connection is the return value of connectAbility. - console.log('terminateSelf result:' + JSON.stringfy(err); - } + console.log('terminateSelf result:' + JSON.stringfy(err)); + }); ``` @@ -162,6 +186,10 @@ disconnectAbility(connection: number): Promise<void>; Disconnects this ability from the Service ability. This method uses a promise to return the result. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -171,12 +199,12 @@ Disconnects this ability from the Service ability. This method uses a promise to | Type| Description| | -------- | -------- | | Promise<void> | Promise used to return the result indicating whether the method is successfully called.| - + - Example ``` this.context.disconnectAbility(connection).then((data) => { // connection is the return value of connectAbility. console.log('success:' + JSON.stringfy(data)); - )).catch((error) => { + }).catch((error) => { console.log('failed:' + JSON.stringfy(error)); }); ``` @@ -188,6 +216,6 @@ Defines the **ConnectOptions** data structure. | Name| Description| | -------- | -------- | -| onConnect(elementName:ElementName, remote:IRemoteObject) | Called when this ability is connected to a Service ability.| -| onDisconnect(elementName:ElementName) | Called when the peer service is abnormal or killed.| -| onFailed(code: number) | Called when the connection fails.| +| onConnect(elementName:ElementName, remote:IRemoteObject) | Called when this ability is connected to a Service ability.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| +| onDisconnect(elementName:ElementName) | Called when the peer service is abnormal or killed.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| +| onFailed(code: number) | Called when the connection fails.
System capabilities: SystemCapability.Ability.AbilityRuntime.Core| diff --git a/en/application-dev/reference/apis/js-apis-service-extension.md b/en/application-dev/reference/apis/js-apis-service-extension.md index 22f46948c07041a90488fef30df310ddb2f1294f..0a6b357e97fad6ee1474e6925067361d78e0c6a1 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension.md +++ b/en/application-dev/reference/apis/js-apis-service-extension.md @@ -1,6 +1,6 @@ # ServiceExtension -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -32,6 +32,10 @@ onCreate(want: Want): void; Called when an extension is created to initialize the service logic. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -39,8 +43,10 @@ Called when an extension is created to initialize the service logic. - Example ``` - onCreate(want) { + class ServiceExt extends ServiceExtension { + onCreate(want) { console.log('onCreate, want:' + want.abilityName); + } } ``` @@ -51,11 +57,16 @@ onDestroy(): void; Called when this extension is destroyed to clear resources. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Example ``` - onDestroy() { + class ServiceExt extends ServiceExtension { + onDestroy() { console.log('onDestroy'); - destory(); + } } ``` @@ -66,6 +77,10 @@ onRequest(want: Want, startId: number): void; Called after **onCreate** is invoked when an ability is started by calling **startAbility**. The value of **startId** is incremented for each ability that is started. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -74,8 +89,10 @@ Called after **onCreate** is invoked when an ability is started by calling **sta - Example ``` - onRequest(want: Want, startId: number) { + class ServiceExt extends ServiceExtension { + onRequest(want, startId) { console.log('onRequest, want:' + want.abilityName); + } } ``` @@ -86,6 +103,10 @@ onConnect(want: Want): rpc.RemoteObject; Called after **onCreate** is invoked when an ability is started by calling **connectAbility**. A **RemoteObject** object is returned for communication with the client. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -106,10 +127,11 @@ Called after **onCreate** is invoked when an ability is started by calling **con onRemoteRequest(code, data, reply, option) { } } - ... - onConnect(want) { + class ServiceExt extends ServiceExtension { + onConnect(want) { console.log('onConnect , want:' + want.abilityName); return new StubTest("test"); + } } ``` @@ -120,6 +142,10 @@ onDisconnect(want: Want): void; Called when the ability is disconnected. +**System capabilities** + +SystemCapability.Ability.AbilityRuntime.Core + - Parameters | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | @@ -127,7 +153,9 @@ Called when the ability is disconnected. - Example ``` - onDisconnect(want) { + class ServiceExt extends ServiceExtension { + onDisconnect(want) { console.log('onDisconnect, want:' + want.abilityName); + } } ``` diff --git a/en/application-dev/reference/apis/js-apis-settings.md b/en/application-dev/reference/apis/js-apis-settings.md index afb02dba1e8104b405b6d280c75e55466d398165..bc2b4d022ac2bf949104cbb192e1a8776be3c565 100644 --- a/en/application-dev/reference/apis/js-apis-settings.md +++ b/en/application-dev/reference/apis/js-apis-settings.md @@ -19,9 +19,9 @@ import settings from '@ohos.settings'; None -## settings.getUri +## settings.getUriSync -getUri(name: string): string +getUriSync(name: string): string Obtains the URI of a data item. @@ -38,13 +38,13 @@ Obtains the URI of a data item. - Example ``` // Obtain the URI of a data item. - let urivar = settings.getUri('settings.screen.brightness'); + let urivar = settings.getUriSync('settings.screen.brightness'); ``` -## settings.getValue +## settings.getValueSync -getValue(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string +getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string Obtains the value of a data item. @@ -66,18 +66,18 @@ Obtains the value of a data item. // Obtain the value of 'settings.screen.brightness' (this data item already exists in the database). let brightness = 'settings.screen.brightness'; - let uri = settings.getUri(brightness); + let uri = settings.getUriSync(brightness); let helper = featureAbility.acquireDataAbilityHelper(uri); - let value = settings.getValue(helper, brightness, '10'); + let value = settings.getValueSync(helper, brightness, '10'); ``` -## settings.setValue +## settings.setValueSync -setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean +setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean Sets the value of a data item. -If the specified data item exists in the database, the **setValue** method updates the value of the data item. If the data item does not exist in the database, the **setValue** method inserts the data item into the database. +If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database. To use this method, you must have the **ohos.permission.WRITE_SYSTEM_SETTING** permission. @@ -97,10 +97,10 @@ To use this method, you must have the **ohos.permission.WRITE_SYSTEM_SETTING** p ``` import featureAbility from '@ohos.featureAbility'; - // Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValue method + // Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync method will update the value of the data item.) let brightness = 'settings.screen.brightness'; - let uri = settings.getUri(brightness); + let uri = settings.getUriSync(brightness); let helper = featureAbility.acquireDataAbilityHelper(uri); - let ret = settings.setValue(helper, brightness, '100'); + let ret = settings.setValueSync(helper, brightness, '100'); ``` diff --git a/en/application-dev/reference/apis/js-apis-sim.md b/en/application-dev/reference/apis/js-apis-sim.md index bf7ff76d1586154ed1aff89465935d259901f5c9..4af4fa4a29edfd12e607bdb3f153fb9d03d3d5fc 100644 --- a/en/application-dev/reference/apis/js-apis-sim.md +++ b/en/application-dev/reference/apis/js-apis-sim.md @@ -1,6 +1,6 @@ # SIM Management ->**Note:** +>**NOTE** > >The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -18,21 +18,20 @@ Obtains the integrated circuit card identity (ICCID) of the SIM card in the spe Before using this API, you must declare the **ohos.permission.GET\_TELEPHONY\_STATE** permission. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | --------------------------- | ---- | -------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback<string> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | --------------------------- | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback<string> | Yes| Callback used to return the result.| +**Example** -- Example - - ``` - sim.getSimIccId(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +sim.getSimIccId(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## sim.getSimIccId @@ -43,28 +42,28 @@ Obtains the ICCID of the SIM card in the specified slot. This function uses a pr Before using this API, you must declare the **ohos.permission.GET\_TELEPHONY\_STATE** permission. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | -------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| -- Return values +**Return value** - | Type| Description| - | --------------------- | ---------------------------------- | - | Promise<string> | Promise used to return the result.| +| Type| Description| +| --------------------- | ---------------------------------- | +| Promise<string> | Promise used to return the result.| -- Example +**Example** - ``` - let promise = sim.getSimIccId(0); - promise.then(data => { - console.log(`getSimIccId success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.log(`getSimIccId fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let promise = sim.getSimIccId(0); +promise.then(data => { + console.log(`getSimIccId success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getSimIccId fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## sim.getDefaultVoiceSlotId7+ @@ -72,19 +71,19 @@ getDefaultVoiceSlotId\(callback: AsyncCallback\): void Obtains the default slot ID of the SIM card that provides voice services. This function uses an asynchronous callback to return the result. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | --------------------------- | ---- | ---------- | - | callback | AsyncCallback<number> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | --------------------------- | ---- | ---------- | +| callback | AsyncCallback<number> | Yes| Callback invoked to traverse the entries in the container.| -- Example +**Example** - ``` - sim.getDefaultVoiceSlotId((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +sim.getDefaultVoiceSlotId((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## sim.getDefaultVoiceSlotId7+ @@ -93,22 +92,22 @@ getDefaultVoiceSlotId\(\): Promise Obtains the default slot ID of the SIM card that provides voice services. This function uses a promise to return the result. -- Return values +**Return value** - | Type| Description| - | ----------------- | --------------------------------------- | - | Promise\ | Promise used to return the result.| +| Type| Description| +| ----------------- | --------------------------------------- | +| Promise\ | Promise used to return the result.| -- Example +**Example** - ``` - let promise = sim.getDefaultVoiceSlotId(); - promise.then(data => { - console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.log(`getDefaultVoiceSlotId fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let promise = sim.getDefaultVoiceSlotId(); +promise.then(data => { + console.log(`getDefaultVoiceSlotId success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getDefaultVoiceSlotId fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## sim.getISOCountryCodeForSim @@ -116,20 +115,20 @@ getISOCountryCodeForSim\(slotId: number, callback: AsyncCallback\): voi Obtains the ISO country code of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | ----------------------- | ---- | ---------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback\ | Yes| Callback used to return the result, which is a country code, for example, **CN** (China).| +| Name| Type| Mandatory| Description| +| -------- | ----------------------- | ---- | ---------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\ | Yes| Callback used to return the result, which is a country code, for example, **CN** (China).| -- Example +**Example** - ``` - sim.getISOCountryCodeForSim(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +sim.getISOCountryCodeForSim(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## sim.getISOCountryCodeForSim @@ -138,28 +137,28 @@ getISOCountryCodeForSim\(slotId: number\): Promise Obtains the ISO country code of the SIM card in the specified slot. This function uses a promise to return the result. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | -------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| -- Return values +**Return value** - | Type| Description| - | ----------------- | ------------------------------------------------------------ | - | Promise\ | Promise used to return the result, which is a country code, for example, **CN** (China).| +| Type| Description| +| ----------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result, which is a country code, for example, **CN** (China).| -- Example +**Example** - ``` - let promise = sim.getISOCountryCodeForSim(0); - promise.then(data => { - console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.log(`getISOCountryCodeForSim fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let promise = sim.getISOCountryCodeForSim(0); +promise.then(data => { + console.log(`getISOCountryCodeForSim success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getISOCountryCodeForSim fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## sim.getSimOperatorNumeric @@ -168,20 +167,20 @@ getSimOperatorNumeric\(slotId: number, callback: AsyncCallback\): void Obtains the public land mobile network (PLMN) ID of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | ----------------------- | ---- | -------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback\ | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | ----------------------- | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| -- Example +**Example** - ``` - sim.getSimOperatorNumeric(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +sim.getSimOperatorNumeric(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## sim.getSimOperatorNumeric @@ -190,28 +189,28 @@ getSimOperatorNumeric\(slotId: number\): Promise Obtains the PLMN ID of the SIM card in the specified slot. This function uses a promise to return the result. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | -------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| -- Return values +**Return value** - | Type| Description| - | ----------------- | ------------------------------------------------ | - | Promise\ | Promise used to return the result.| +| Type| Description| +| ----------------- | ------------------------------------------------ | +| Promise\ | Promise used to return the result.| -- Example +**Example** - ``` - let promise = sim.getSimOperatorNumeric(0); - promise.then(data => { - console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.log(`getSimOperatorNumeric fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let promise = sim.getSimOperatorNumeric(0); +promise.then(data => { + console.log(`getSimOperatorNumeric success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getSimOperatorNumeric fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## sim.getSimSpn @@ -220,20 +219,20 @@ getSimSpn\(slotId: number, callback: AsyncCallback\): void Obtains the service provider name (SPN) of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | ----------------------- | ---- | -------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback\ | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | ----------------------- | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| -- Example +**Example** - ``` - sim.getSimSpn(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +sim.getSimSpn(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## sim.getSimSpn @@ -242,28 +241,28 @@ getSimSpn\(slotId: number\): Promise Obtains the SPN of the SIM card in the specified slot. This function uses a promise to return the result. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | -------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| -- Return values +**Return value** - | Type| Description| - | ----------------- | ----------------------------------------- | - | Promise\ | Promise used to return the result.| +| Type| Description| +| ----------------- | ----------------------------------------- | +| Promise\ | Promise used to return the result.| -- Example +**Example** - ``` - let promise = sim.getSimSpn(0); - promise.then(data => { - console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.log(`getSimSpn fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let promise = sim.getSimSpn(0); +promise.then(data => { + console.log(`getSimSpn success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getSimSpn fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## sim.getSimState @@ -272,20 +271,20 @@ getSimState\(slotId: number, callback: AsyncCallback\): void Obtains the status of the SIM card in the specified slot. This function uses an asynchronous callback to return the result. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------------------------------------- | ---- | ----------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback\<[SimState](#SimState)\> | Yes| Callback used to return the result. For details, see [SimState](#SimState).| +| Name| Type| Mandatory| Description| +| -------- | -------------------------------------- | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\<[SimState](#SimState)\> | Yes| Callback used to return the result, For details, see [SimState](#SimState).| -- Example +**Example** - ``` - sim.getSimState(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +sim.getSimState(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## sim.getSimState @@ -294,28 +293,28 @@ getSimState\(slotId: number\): Promise Obtains the status of the SIM card in the specified slot. This function uses a promise to return the result. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | -------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| -- Return values +**Return value** - | Type| Description| - | -------------------------------- | ------------------------------------------ | - | Promise\<[SimState](#SimState)\> | Promise used to return the result.| +| Type| Description| +| -------------------------------- | ------------------------------------------ | +| Promise\<[SimState](#SimState)\> | Promise used to return the result.| -- Example +**Example** - ``` - let promise = sim.getSimState(0); - promise.then(data => { - console.log(`getSimState success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.log(`getSimState fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let promise = sim.getSimState(0); +promise.then(data => { + console.log(`getSimState success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getSimState fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## sim.getSimGid1 @@ -325,20 +324,20 @@ Obtains the group identifier level 1 (GID1) of the SIM card in the specified slo Before using this API, you must declare the **ohos.permission.GET\_TELEPHONY\_STATE** permission. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | ----------------------- | ---- | -------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback\ | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | ----------------------- | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback\ | Yes| Callback used to return the result.| -- Example +**Example** - ``` - sim.getSimGid1(0, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +sim.getSimGid1(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## sim.getSimGid1 @@ -349,28 +348,28 @@ Obtains the GID1 of the SIM card in the specified slot. This function uses a pro Before using this API, you must declare the **ohos.permission.GET\_TELEPHONY\_STATE** permission. -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | -------------------------------------- | - | slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| -- Return values +**Return value** - | Type| Description| - | ----------------- | ------------------------------------------------------------ | - | Promise\ | Promise used to return the result.| +| Type| Description| +| ----------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result.| -- Example +**Example** - ``` - let promise = sim.getSimGid1(0); - promise.then(data => { - console.log(`getSimGid1 success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.log(`getSimGid1 fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let promise = sim.getSimGid1(0); +promise.then(data => { + console.log(`getSimGid1 success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getSimGid1 fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## SimState diff --git a/en/application-dev/reference/apis/js-apis-sms.md b/en/application-dev/reference/apis/js-apis-sms.md index d1e0be717b9be664da8e0c29a74ac0f262c195dc..b3cca70e284d04d0c3f4ad09dae27a42de549252 100644 --- a/en/application-dev/reference/apis/js-apis-sms.md +++ b/en/application-dev/reference/apis/js-apis-sms.md @@ -1,6 +1,6 @@ # SMS ->**Note:** +>**NOTE** > >The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -16,24 +16,26 @@ createMessage\(pdu: Array, specification: string, callback: AsyncCallba Creates an SMS message instance based on the protocol data unit (PDU) and the specified SMS protocol. This function uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.SmsMms - | Name| Type| Mandatory| Description| - | ------------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ | - | pdu | Array<number> | Yes| Protocol data unit, which is obtained from the received SMS message.| - | specification | string | Yes| SMS protocol type. The options are as follows:
- **3gpp**: GSM/UMTS/LTE SMS
- **3gpp2**: CDMA SMS| - | callback | AsyncCallback<[ShortMessage](#ShortMessage)> | Yes| Callback used to return the result.| +**Parameters** -- Example +| Name| Type| Mandatory| Description| +| ------------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ | +| pdu | Array<number> | Yes| PDU, which is obtained from the received SMS message.| +| specification | string | Yes| SMS protocol type. The options are as follows:
- **3gpp**: GSM/UMTS/LTE SMS
- **3gpp2**: CDMA SMS| +| callback | AsyncCallback<[ShortMessage](#ShortMessage)> | Yes| Callback used to return the result.| - ``` - const specification = '3gpp'; - // Display PDUs using numbers in an array, for example, [0x08, 0x91, ...]. - const pdu = [0x08, 0x91]; - sms.createMessage(pdu, specification, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +**Example** + +``` +const specification = '3gpp'; +// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...]. +const pdu = [0x08, 0x91]; +sms.createMessage(pdu, specification, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## sms.createMessage @@ -42,32 +44,34 @@ createMessage\(pdu: Array, specification: string\): Promise - **3gpp**: GSM/UMTS/LTE SMS
- **3gpp2**: CDMA SMS| +| Name| Type| Mandatory| Description| +| ------------- | ------------------- | ---- | ------------------------------------------------------------ | +| pdu | Array<number> | Yes| PDU, which is obtained from the received SMS message.| +| specification | string | Yes| SMS protocol type. The options are as follows:
- **3gpp**: GSM/UMTS/LTE SMS
- **3gpp2**: CDMA SMS| -- Return values +**Return value** - | Type| Description| - | -------------------------------------------- | --------------------------------- | - | Promise<[ShortMessage](#ShortMessage)> | Promise used to return the result.| +| Type| Description| +| -------------------------------------------- | --------------------------------- | +| Promise<[ShortMessage](#ShortMessage)> | Promise used to return the result.| -- Example +**Example** - ``` - const specification = '3gpp'; - // Display PDUs using numbers in an array, for example, [0x08, 0x91, ...]. - const pdu = [0x08, 0x91]; - let promise = sms.createMessage(pdu, specification); - promise.then(data => { - console.log(`createMessage success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`createMessage fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +const specification = '3gpp'; +// Display PDUs using numbers in an array, for example, [0x08, 0x91, ...]. +const pdu = [0x08, 0x91]; +let promise = sms.createMessage(pdu, specification); +promise.then(data => { + console.log(`createMessage success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`createMessage fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## sms.sendMessage @@ -75,31 +79,33 @@ sendMessage(options: SendMessageOptions): void Sends an SMS message. -Before using this API, you must declare the **ohos.permission.SEND_MESSAGES** permission. +**Required permission**: ohos.permission.SEND_MESSAGES -- Parameters +**System capability**: SystemCapability.Telephony.SmsMms - | Name| Type| Mandatory| Description| - | ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | - | options | [SendMessageOptions](#SendMessageOptions) | Yes| Options (including the callback) for sending an SMS message. For details, see [SendMessageOptions](#SendMessageOptions).| +**Parameters** + +| Name| Type| Mandatory| Description| +| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [SendMessageOptions](#SendMessageOptions) | Yes| Options (including the callback) for sending an SMS message. For details, see [SendMessageOptions](#SendMessageOptions).| -- Example +**Example** - ``` - let sendCallback = function (err, data) { - console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - } - let deliveryCallback = function (err, data) { - console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - } - let slotId = 0; - let content ='SMS message content'; - let destinationHost = '+861xxxxxxxxxx'; - let serviceCenter = '+861xxxxxxxxxx'; - let destinationPort = 1000; - let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback}; - sms.sendMessage(options); - ``` +``` +let sendCallback = function (err, data) { + console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +} +let deliveryCallback = function (err, data) { + console.log(`deliveryCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +} +let slotId = 0; +let content ='SMS message content'; +let destinationHost = '+861xxxxxxxxxx'; +let serviceCenter = '+861xxxxxxxxxx'; +let destinationPort = 1000; +let options = {slotId, content, destinationHost, serviceCenter, destinationPort, sendCallback, deliveryCallback}; +sms.sendMessage(options); +``` ## sms.getDefaultSmsSlotId7+ @@ -108,19 +114,21 @@ getDefaultSmsSlotId\(callback: AsyncCallback\): void Obtains the default slot of the SIM card used to send SMS messages. This function uses an asynchronous callback to return the result. -- Parameters +**System capability**: SystemCapability.Telephony.SmsMms - | Name| Type| Mandatory| Description| - | -------- | --------------------------- | ---- | ---------------------------------------- | - | callback | AsyncCallback<number> | Yes| Callback used to return the result.
- **0**: slot 1
- **1**: slot 2| +**Parameters** -- Example +| Name| Type| Mandatory| Description| +| -------- | --------------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback<number> | Yes| Callback used to return the result.
- **0**: slot 1
- **1**: slot 2| - ``` - sms.getDefaultSmsSlotId((err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +**Example** + +``` +sms.getDefaultSmsSlotId((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## sms.getDefaultSmsSlotId7+ @@ -129,22 +137,24 @@ getDefaultSmsSlotId\(\): Promise Obtains the default slot of the SIM card used to send SMS messages. This function uses a promise to return the result. -- Return values +**System capability**: SystemCapability.Telephony.SmsMms - | Type| Description| - | --------------- | ------------------------------------------------------------ | - | Promise | Promise used to return the result.
- **0**: slot 1
- **1**: slot 2| +**Return value** -- Example +| Type| Description| +| --------------- | ------------------------------------------------------------ | +| Promise | Promise used to return the result.
- **0**: slot 1
- **1**: slot 2| - ``` - let promise = call.getDefaultSmsSlotId(); - promise.then(data => { - console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`getDefaultSmsSlotId fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +**Example** + +``` +let promise = call.getDefaultSmsSlotId(); +promise.then(data => { + console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getDefaultSmsSlotId fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## sms.setSmscAddr7+ @@ -153,25 +163,27 @@ setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback\): Sets the short message service center (SMSC) address. This function uses an asynchronous callback to return the result. -Before using this API, you must declare the **ohos.permission.SET\_TELEPHONY\_STATE** permission. +**Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission) + +**System capability**: SystemCapability.Telephony.SmsMms -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | -------- | ------------------------- | ---- | ----------------------------------------- | - | slotId | number | Yes| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | smscAddr | string | Yes| SMSC address. | - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | ------------------------- | ---- | ----------------------------------------- | +| slotId | number | Yes| SIM card slot ID:
- **0**: slot 1
- **1**: slot 2| +| smscAddr | string | Yes| SMSC address. | +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| -- Example +**Example** - ``` - let slotId = 0; - let smscAddr = '+861xxxxxxxxxx'; - sms.setSmscAddr(slotId, smscAddr, (err,data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +``` +let slotId = 0; +let smscAddr = '+861xxxxxxxxxx'; +sms.setSmscAddr(slotId, smscAddr, (err,data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## sms.setSmscAddr7+ @@ -180,33 +192,35 @@ setSmscAddr\(slotId: number, smscAddr: string\): Promise Sets the SMSC address. This function uses a promise to return the result. -Before using this API, you must declare the **ohos.permission.SET\_TELEPHONY\_STATE** permission. +**Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission) -- Parameters +**System capability**: SystemCapability.Telephony.SmsMms - | Name| Type| Mandatory| Description| - | -------- | ------ | ---- | ----------------------------------------- | - | slotId | number | Yes| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | smscAddr | string | Yes| SMSC address.| +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------ | ---- | ----------------------------------------- | +| slotId | number | Yes| SIM card slot ID:
- **0**: slot 1
- **1**: slot 2| +| smscAddr | string | Yes| SMSC address. | -- Return values +**Return value** - | Type| Description| - | ------------------- | ------------------------------- | - | Promise<void> | Promise used to return the result.| +| Type| Description| +| ------------------- | ------------------------------- | +| Promise<void> | Promise used to return the result.| -- Example +**Example** - ``` - let slotId = 0; - let smscAddr = '+861xxxxxxxxxx'; - let promise = sms.setSmscAddr(slotId, smscAddr); - promise.then(data => { - console.log(`setSmscAddr success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`setSmscAddr fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let slotId = 0; +let smscAddr = '+861xxxxxxxxxx'; +let promise = sms.setSmscAddr(slotId, smscAddr); +promise.then(data => { + console.log(`setSmscAddr success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`setSmscAddr fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## sms.getSmscAddr7+ @@ -215,23 +229,25 @@ getSmscAddr\(slotId: number, callback: AsyncCallback\): void Obtains the SMSC address. This function uses an asynchronous callback to return the result. -Before using this API, you must declare the **ohos.permission.GET\_TELEPHONY\_STATE** permission. +**Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission) -- Parameters +**System capability**: SystemCapability.Telephony.SmsMms - | Name| Type| Mandatory| Description| - | -------- | --------------------------- | ---- | ----------------------------------------- | - | slotId | number | Yes| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| - | callback | AsyncCallback<string> | Yes| Callback used to return the result.| +**Parameters** -- Example +| Name| Type| Mandatory| Description| +| -------- | --------------------------- | ---- | ----------------------------------------- | +| slotId | number | Yes| SIM card slot ID:
- **0**: slot 1
- **1**: slot 2| +| callback | AsyncCallback<string> | Yes| Callback used to return the result.| - ``` - let slotId = 0; - sms.getSmscAddr(slotId, (err, data) => { - console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); - }); - ``` +**Example** + +``` +let slotId = 0; +sms.getSmscAddr(slotId, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` ## sms.getSmscAddr7+ @@ -240,37 +256,41 @@ getSmscAddr\(slotId: number\): Promise Obtains the SMSC address. This function uses a promise to return the result. -Before using this API, you must declare the **ohos.permission.GET\_TELEPHONY\_STATE** permission. +**Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission) + +**System capability**: SystemCapability.Telephony.SmsMms -- Parameters +**Parameters** - | Name| Type| Mandatory| Description| - | ------ | ------ | ---- | ----------------------------------------- | - | slotId | number | Yes| SIM card slot ID. The options are as follows:
- **0**: slot 1
- **1**: slot 2| +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | ----------------------------------------- | +| slotId | number | Yes| SIM card slot ID:
- **0**: slot 1
- **1**: slot 2| -- Return values +**Return value** - | Type| Description| - | --------------------- | --------------------------------------------- | - | Promise<string> | Promise used to return the result.| +| Type| Description| +| --------------------- | --------------------------------------------- | +| Promise<string> | Promise used to return the result.| -- Example +**Example** - ``` - let slotId = 0; - let promise = sms.getSmscAddr(slotId); - promise.then(data => { - console.log(`getSmscAddr success, promise: data->${JSON.stringify(data)}`); - }).catch(err => { - console.error(`getSmscAddr fail, promise: err->${JSON.stringify(err)}`); - }); - ``` +``` +let slotId = 0; +let promise = sms.getSmscAddr(slotId); +promise.then(data => { + console.log(`getSmscAddr success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getSmscAddr fail, promise: err->${JSON.stringify(err)}`); +}); +``` ## ShortMessage Defines an SMS message instance. +**System capability**: SystemCapability.Telephony.SmsMms + | Variable| Type| Description| | ------------------------ | --------------------------------------- | ------------------------------------------------------------ | | emailAddress | string | Email address.| @@ -281,13 +301,13 @@ Defines an SMS message instance. | isSmsStatusReportMessage | boolean | Whether the received SMS message is an SMS delivery status report. The default value is **false**.
SMS delivery status report: a message sent from the SMSC to show the current status of the SMS message you delivered.| | messageClass | [ShortMessageClass](#ShortMessageClass) | SMS message type.| | pdu | Array<number> | PDU in the SMS message.| -|protocolId|number|Protocol identifier used for delivering the SMS message.| -|scAddress|string|SMSC address.| -|scTimestamp|number|SMSC timestamp.| -|status|number|SMS message status sent by the SMSC in the **SMS-STATUS-REPORT** message.| -|userRawData|Array<number>|User data excluding the data header.| -|visibleMessageBody|string|SMS message body.| -|visibleRawAddress|string|Sender address to be displayed on the UI.| +| protocolId | number | ID of the protocol used for sending SMS messages.| +| scAddress | string | Address of the short message service center (SMSC).| +| scTimestamp | number | SMSC timestamp.| +| status | number | SMS message status sent by the SMSC in the **SMS-STATUS-REPORT** message.| +| userRawData | Array<number> | User data except the data header.| +| visibleMessageBody | string | SMS message body.| +| visibleRawAddress | string | Sender address.| ## ShortMessageClass @@ -295,12 +315,12 @@ Defines an SMS message instance. Enumerates SMS message types. | Variable| Value| Description| -| ---------------- | ---- | ---------------------------------------- | -| UNKNOWN | 0 | Unknown type.| -| INSTANT_MESSAGE | 1 | Instant message, which is displayed immediately after being received.| -| OPTIONAL_MESSAGE | 2 | Message stored in the device or SIM card.| -| SIM_MESSAGE | 3 | Message containing SIM card information, which is to be stored in the SIM card.| -| FORWARD_MESSAGE | 4 | Message to be forwarded to another device.| +| ---------------- | ---- | ------------------------------------------------------------ | +| UNKNOWN | 0 | Unknown type.
**System capability**: SystemCapability.Telephony.SmsMms| +| INSTANT_MESSAGE | 1 | Instant message, which is displayed immediately after being received.
**System capability**: SystemCapability.Telephony.SmsMms| +| OPTIONAL_MESSAGE | 2 | Message stored in the device or SIM card.
**System capability**: SystemCapability.Telephony.SmsMms| +| SIM_MESSAGE | 3 | Message containing SIM card information, which is to be stored in the SIM card.
**System capability**: SystemCapability.Telephony.SmsMms| +| FORWARD_MESSAGE | 4 | Message to be forwarded to another device.
**System capability**: SystemCapability.Telephony.SmsMms| ## SendMessageOptions @@ -309,20 +329,24 @@ Provides the options (including callbacks) for sending an SMS message. For example, you can specify the SMS message type by the optional parameter **content**. +**System capability**: SystemCapability.Telephony.SmsMms + | Name| Type| Mandatory| Description| | ---------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | | slotId | number | Yes| Slot ID of the SIM card used for sending SMS messages:
- **0**: slot 1
- **1**: slot 2| | destinationHost | string | Yes| Destination address of the SMS message.| -| content | string \| Array<number> | Yes| SMS message type. If the content is comprised of character strings, the SMS message is a text message. If the content is comprised of byte arrays, the SMS message is a data message.| +| content | string \| Array<number> | Yes| SMS message type. If the content is composed of character strings, the SMS message is a text message. If the content is composed of byte arrays, the SMS message is a data message.| | serviceCenter | string | No| SMSC address. By default, the SMSC address in the SIM card is used.| -| destinationPort | number | No| Destination port of the SMS message. This parameter is mandatory only for a data message. | +| destinationPort | number | No| Destination port of the SMS message. This parameter is mandatory only for a data message. Otherwise, it is optional.| | sendCallback | AsyncCallback<[ISendShortMessageCallback](#ISendShortMessageCallback)> | No| Callback used to return the SMS message sending result. For details, see [ISendShortMessageCallback](#ISendShortMessageCallback).| | deliveryCallback | AsyncCallback<[IDeliveryShortMessageCallback](#IDeliveryShortMessageCallback)> | No| Callback used to return the SMS message delivery report. For details, see [IDeliveryShortMessageCallback](#IDeliveryShortMessageCallback).| ## ISendShortMessageCallback -Provides the callback for the SMS message delivery report. It consists of three parts: SMS message sending result, URI for storing the sent SMS message, and whether the SMS message is the last part of a long SMS message. +Provides the callback for the SMS message sending result. It consists of three parts: SMS message sending result, URI for storing the sent SMS message, and whether the SMS message is the last part of a long SMS message. + +**System capability**: SystemCapability.Telephony.SmsMms | Name| Type| Mandatory| Description| | ---------- | ------------------------------- | ---- | ------------------------------------------------------------ | @@ -333,7 +357,9 @@ Provides the callback for the SMS message delivery report. It consists of three ## IDeliveryShortMessageCallback -Provides the callback for the SMS message delivery report. +Provides the callback for the SMS message sending result. Return the SMS delivery report. + +**System capability**: SystemCapability.Telephony.SmsMms | Name| Type| Mandatory| Description| | ------ | ------------------- | ---- | -------------- | @@ -344,9 +370,11 @@ Provides the callback for the SMS message delivery report. Enumerates SMS message sending results. +**System capability**: SystemCapability.Telephony.SmsMms + | Name| Value| Description| | ------------------------------------ | ---- | ------------------------------------------------------ | -| SEND_SMS_SUCCESS | 0 | The SMS message is sent successfully.| +| SEND_SMS_SUCCESS | 0 | SMS message sent successfully.| | SEND_SMS_FAILURE_UNKNOWN | 1 | Failed to send the SMS message due to unknown reasons.| | SEND_SMS_FAILURE_RADIO_OFF | 2 | Failed to send the SMS message because the modem is shut down.| | SEND_SMS_FAILURE_SERVICE_UNAVAILABLE | 3 | Failed to send the SMS message because the network is unavailable or SMS message sending or receiving is not supported.| diff --git a/en/application-dev/reference/apis/js-apis-stack.md b/en/application-dev/reference/apis/js-apis-stack.md new file mode 100644 index 0000000000000000000000000000000000000000..2cec7c7cc3489abc2cd0316c837e1a3403844d83 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-stack.md @@ -0,0 +1,236 @@ +# Linear Container Stack + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import Stack from '@ohos.util.Stack' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + + +## Stack + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a stack (called container later).| + + +### constructor + +constructor() + +A constructor used to create a **Stack** instance. + +**Example** + +``` +let stack = new Stack(); +``` + + +### push + +push(item: T): T + +Adds an entry at the top of this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| item | T | Yes| Element to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Element added.| + +**Example** + +``` +let stack = new Stack(); +let result = stack.push("a"); +let result1 = stack.push(1); +let b = [1, 2, 3]; +stack.push(b); +let c = {name : "lala", age : "13"}; +let result3 = stack.push(c); +``` + +### pop + +pop(): T + +Removes the top entry from this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Example** + +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(2); +stack.push(4); +let result = stack.pop(); +``` + +### peek + +peek(): T + +Obtains the top entry of this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry obtained.| + +**Example** + +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(2); +let result = stack.peek(); +``` + +### locate + +locate(element: T): number + +Obtains the index of the first occurrence of the specified entry in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| element | T | Yes| Entry to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| number | Returns the position index if obtained; returns **-1** if the specified entry is not found.| + +**Example** + +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(2); +let result = stack.locate(2); +``` + +### forEach +forEach(callbackfn: (value: T, index?: number, stack?: Stack<T>) => void, +thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| index | number | No| Position index of the entry that is currently traversed.| +| stack | Stack<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(4); +stack.forEach((value, index) => { + console.log(value, index); +}); +``` + +### isEmpty +isEmpty(): boolean + +Checks whether this container is empty (contains no entries). + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(4); +let result = stack.isEmpty(); +``` + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** +``` +let stack = new Stack(); +stack.push(2); +stack.push(4); +stack.push(5); +stack.push(4); + +// Method 1: +for (let item of stack) { + console.log(item); +} + +// Method 2: +let iter = stack[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-storage-statistics.md b/en/application-dev/reference/apis/js-apis-storage-statistics.md new file mode 100644 index 0000000000000000000000000000000000000000..91690344eefbab65a7023f9cb7b8561a7626d657 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-storage-statistics.md @@ -0,0 +1,184 @@ +# App Storage Statistics + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```js +import storagestatistics from "@ohos.storagestatistics"; +``` + +## System Capabilities + +SystemCapability.FileManagement.StorageService.SpatialStatistics + +## storagestatistics.getTotalSizeOfVolume + +getTotalSizeOfVolume(volumeUuid: string): Promise<number> + +Asynchronously obtains the total space of the specified volume. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------ | ---- | ---- | + | volumeUuid | string | Yes| Universally unique identifier (UUID) of the volume.| + +- Return value + + | Type| Description| + | --------------------- | ---------------- | + | Promise<number> | Promise used to return the total space of the volume.| + +- Example + + ```js + let uuid = ""; + storagestatistics.getTotalSizeOfVolume(uuid).then(function(number){ + console.info("getTotalSizeOfVolume successfully:"+ number); + }).catch(function(err){ + console.info("getTotalSizeOfVolume failed with error:"+ err); + }); + ``` + +## storagestatistics.getTotalSizeOfVolume + +getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void + +Asynchronously obtains the total space of the specified volume. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------------------------------------ | ---- | -------------------------- | + | volumeUuid | string | Yes| UUID of the volume.| + | callback | callback:AsyncCallback<number> | Yes| Callback invoked to return the total space of the volume.| + +- Example + + ```js + let uuid = ""; + storagestatistics.getTotalSizeOfVolume(uuid, function(error, number){ + // Do something + }); + ``` + + + +## storagestatistics.getFreeSizeOfVolume + +getFreeSizeOfVolume(volumeUuid: string): Promise<number> + +Asynchronously obtains the available space of the specified volume. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------ | ---- | ---- | + | volumeUuid | string | Yes| UUID of the volume.| + +- Return value + + | Type| Description| + | --------------------- | ------------------ | + | Promise<number> | Promise used to return the available space of the volume.| + +- Example + + ```js + let uuid = ""; + storagestatistics.getFreeSizeOfVolume(uuid).then(function(number){ + console.info("getFreeSizeOfVolume successfully:"+ number); + }).catch(function(err){ + console.info("getFreeSizeOfVolume failed with error:"+ err); + }); + + ``` + +## storagestatistics.getFreeSizeOfVolume + +getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void + +Asynchronously obtains the available space of the specified volume. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | ------------------------------------ | ---- | ---------------------------- | + | volumeUuid | string | Yes| UUID of the volume.| + | callback | callback:AsyncCallback<number> | Yes| Callback invoked to return the available space of the volume.| + +- Example + + ```js + let uuid = ""; + storagestatistics.getFreeSizeOfVolume(uuid, function(error, number){ + // Do something + }); + ``` + +## storagestatistics.getBundleStats + +getBundleStats(volumeUuid: string, packageName:String, ): Promise<BundleStats> + +Asynchronously obtains the bundle status on the specified volume. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ----------- | ------ | ---- | -------- | + | volumeUuid | string | Yes| UUID of the volume.| + | packageName | string | Yes| Bundle name of the app.| + +- Return value + + | Type| Description| + | ------------------------------------------ | -------------------------- | + | Promise<[Bundlestats](#bundlestats)> | Promise used to return the bundle status on the volume.| + +- Example + + ```js + let uuid = ""; + let packageName = ""; + storagestatistics.getBundleStats(uuid, packageName).then(function(BundleStats){ + console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); + }).catch(function(err){ + console.info("getBundleStats failed with error:"+ err); + }); + ``` + +## storagestatistics.getBundleStats + +getBundleStats(volumeUuid: string, callback:AsyncCallback<BundleStats>):void + +Asynchronously obtains the bundle status on the specified volume. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | ---------- | --------------------------------------------------------- | ---- | ------------------------------------ | + | volumeUuid | string | Yes| UUID of the volume.| + | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | Yes| Callback invoked to return the bundle status on the volume.| + +- Example + + ```js + let uuid = ""; + let packageName = ""; + storagestatistics.getBundleStats(uuid, packageName, function(error, BundleStats){ + // Do something + }); + ``` + +## BundleStats + +### Attributes + +| Name| Type| Description| +| --------- | ------ | -------------- | +| appSize | number | Size of the app.| +| cacheSize | number | Size of the cached data.| +| dataSize | number | Total data size of the app.| diff --git a/en/application-dev/reference/apis/js-apis-telephony-data.md b/en/application-dev/reference/apis/js-apis-telephony-data.md new file mode 100644 index 0000000000000000000000000000000000000000..8cb2951bda1838891021ab653db926958859786c --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-telephony-data.md @@ -0,0 +1,289 @@ +# Cellular Data + +>**NOTE** +> +>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +``` +import data from '@ohos.telephony.data'; +``` + +## data.getDefaultCellularDataSlotId + +getDefaultCellularDataSlotId(callback: AsyncCallback\): void + +Obtains the default SIM card used for mobile data. This function uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ----------------------- | ---- | ------------------------------------------ | +| callback | AsyncCallback\ | Yes| Callback used to return the result.
**0**: slot 1
**1**: slot 2| + +**Example** + +``` +data.getDefaultCellularDataSlotId((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.getDefaultCellularDataSlotId + +getDefaultCellularDataSlotId(): Promise\ + +Obtains the default SIM card used for mobile data. This function uses a promise to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Return value** + +| Type| Description| +| ----------------- | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result, wherein:
**0**: slot 1
**1**: slot 2| + +**Example** + +``` +let promise = data.getDefaultCellularDataSlotId(); +promise.then((data) => { + console.log(`test success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`test fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## data.getCellularDataFlowType + +getCellularDataFlowType(callback: AsyncCallback\): void + +Obtains the cellular data flow type, which can be uplink or downlink. This function uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ---------------------------------------------- | ---- | ---------- | +| callback | AsyncCallback\<[DataFlowType](#DataFlowType)\> | Yes| Callback used to return the result.| + +**Example** + +``` +data.getCellularDataFlowType((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.getCellularDataFlowType + +getCellularDataFlowType(): Promise\ + +Obtains the cellular data flow type, which can be uplink or downlink. This function uses a promise to return the result. + +**System capability**: SystemCapability.Telephony.CellularData + +**Return value** + +| Type| Description| +| ---------------------------------------- | ----------------------------------------------- | +| Promise\<[DataFlowType](#DataFlowType)\> | Promise used to return the result. | + +**Example** + +``` +let promise = data.getCellularDataFlowType(); +promise.then((data) => { + console.log(`test success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`test fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## data.getCellularDataState + +getCellularDataState(callback: AsyncCallback\): void + +Obtains the connection status of the packet switched (PS) domain. This function uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------------------------------------ | ---- | ---------- | +| callback | AsyncCallback\<[DataConnectState](#DataConnectState)\> | Yes| Callback used to return the result.| + +**Example** + +``` +data.getCellularDataState((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.getCellularDataState + +getCellularDataState(): Promise\ + +Obtains the connection status of the PS domain. This function uses a promise to return the result. + +**System capability**: SystemCapability.Telephony.CellularData + +**Return value** + +| Type| Description| +| ------------------------------------------------ | ------------------------------------- | +| Promise\<[DataConnectState](#DataConnectState)\> | Promise used to return the result.| + +**Example** + +``` +let promise = data.getCellularDataState(); +promise.then((data) => { + console.log(`test success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`test fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## data.isCellularDataEnabled + +isCellularDataEnabled(callback: AsyncCallback\): void + +Checks whether the cellular data service is enabled. This function uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------ | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\ | Yes| Callback used to return the result.
**true**: The cellular data service is enabled.
**false**: The cellular data service is disabled.| + +**Example** + +``` +data.isCellularDataEnabled((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.isCellularDataEnabled + +isCellularDataEnabled(): Promise\ + +Checks whether the cellular data service is enabled. This function uses a promise to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Return value** + +| Type| Description| +| ------------------ | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result, wherein:
**true**: The cellular data service is enabled.
**false**: The cellular data service is disabled.| + +**Example** + +``` +let promise = data.isCellularDataEnabled(); +promise.then((data) => { + console.log(`test success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`test fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## data.isCellularDataRoamingEnabled + +isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback\): void + +Checks whether roaming is enabled for the cellular data service. This function uses an asynchronous callback to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | ------------------------ | ---- | ------------------------------------------------------------ | +| slotId | number | Yes| Card slot ID. The options are as follows:
**0**: slot 1
**1**: slot 2| +| callback | AsyncCallback\ | Yes| Callback used to return the result.
**true**: Roaming is enabled for the cellular data service.
**false**: Roaming is disabled for the cellular data service.| + +**Example** + +``` +data.isCellularDataRoamingEnabled(0,(err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + +## data.isCellularDataRoamingEnabled + +isCellularDataRoamingEnabled(slotId: number): Promise\ + +Checks whether roaming is enabled for the cellular data service. This method uses a promise to return the result. + +**Required permission**: ohos.permission.GET_NETWORK_INFO + +**System capability**: SystemCapability.Telephony.CellularData + +**Parameters** + +| Name| Type| Mandatory| Description| +| ------ | ------ | ---- | ---------------------------------------- | +| slotId | number | Yes| Card slot ID. The options are as follows:
**0**: slot 1
**1**: slot 2| + +**Return value** + +| Type| Description| +| ------------------ | ------------------------------------------------------------ | +| Promise\ | Promise used to return the result, wherein:
**true**: Roaming is enabled for the cellular data service.
**false**: Roaming is disabled for the cellular data service.| + +**Example** + +``` +let promise = data.isCellularDataRoamingEnabled(0); +promise.then((data) => { + console.log(`test success, promise: data->${JSON.stringify(data)}`); +}).catch((err) => { + console.error(`test fail, promise: err->${JSON.stringify(err)}`); +}); +``` + +## DataFlowType + + Defines the cellular data flow type. + +| Name| Value| Description| +| ------ | ---------------------- | ------------------------------------------------------------ | +| 0 | DATA_FLOW_TYPE_NONE | No uplink or downlink data is available.
**System capability**: SystemCapability.Telephony.CellularData| +| 1 | DATA_FLOW_TYPE_DOWN | Only the downlink data is available.
**System capability**: SystemCapability.Telephony.CellularData| +| 2 | DATA_FLOW_TYPE_UP | Only the uplink data is available.
**System capability**: SystemCapability.Telephony.CellularData| +| 3 | DATA_FLOW_TYPE_UP_DOWN | Both uplink data and downlink data are available.
**System capability**: SystemCapability.Telephony.CellularData| +| 4 | DATA_FLOW_TYPE_DORMANT | No uplink or downlink data is available because the lower-layer link is in the dormant state.
**System capability**: SystemCapability.Telephony.CellularData| + +## DataConnectState + + Describes the connection status of a cellular data link. + +| Name| Value| Description| +| ------ | ----------------------- | ------------------------------------------------------------ | +| -1 | DATA_STATE_UNKNOWN| The status of the cellular data link is unknown.
**System capability**: SystemCapability.Telephony.CellularData| +| 0 | DATA_STATE_DISCONNECTED | The cellular data link is disconnected.
**System capability**: SystemCapability.Telephony.CellularData| +| 1 | DATA_STATE_CONNECTING | The cellular data link is being connected.
**System capability**: SystemCapability.Telephony.CellularData| +| 2 | DATA_STATE_CONNECTED | The cellular data link is connected.
**System capability**: SystemCapability.Telephony.CellularData| +| 3 | DATA_STATE_SUSPENDED | The cellular data link is suspended.
**System capability**: SystemCapability.Telephony.CellularData| diff --git a/en/application-dev/reference/apis/js-apis-thermal.md b/en/application-dev/reference/apis/js-apis-thermal.md new file mode 100644 index 0000000000000000000000000000000000000000..9c534aae3b5dee1be7890153cd9eba768d770a64 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-thermal.md @@ -0,0 +1,98 @@ +# Thermal Management + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import thermal from '@ohos.thermal'; +``` + + +## ThermalLevel + +Represents the thermal level. + +| Name| Default Value| Description| +| -------- | -------- | -------- | +| COOL | 0 | The device is cool, and services are not restricted.| +| NORMAL | 1 | The device is operational but is not cool. You need to pay attention to its heating.| +| WARM | 2 | The device is warm. You need to stop or delay some imperceptible services.| +| HOT | 3 | The device is heating up. You need to stop all imperceptible services and downgrade or reduce the load of other services.| +| OVERHEATED | 4 | The device is overheated. You need to stop all imperceptible services and downgrade or reduce the load of major services.| +| WARNING | 5 | The device is overheated and is about to enter the emergency state. You need to stop all imperceptible services and downgrade major services to the maximum extent.| +| EMERGENCY | 6 | The device has entered the emergency state. You need to stop all services except those for the emergency help purposes.| + + +## thermal.subscribeThermalLevel + +subscribeThermalLevel(callback: AsyncCallback<ThermalLevel>): void + +Subscribes to thermal level changes. + +**System Capabilities** + +SystemCapability.PowerManager.ThermalManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<ThermalLevel> | Yes| Callback used to obtain the return value.
Return value: thermal level| + +**Example** + +``` +thermal.subscribeThermalLevel((lev) => { + console.info("Thermal level is: " + lev); +}) +``` + +## thermal.unsubscribeThermalLevel + +unsubscribeThermalLevel(callback?: AsyncCallback): void + +Unsubscribes from thermal level changes. + +**System Capabilities** + +SystemCapability.PowerManager.ThermalManager + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | No| Callback without a return value.| + +**Example** + +``` +thermal.unsubscribeThermalLevel(() => { + console.info("Unsubscribe completed."); +}); +``` + +## thermal.getThermalLevel + +getThermalLevel(): ThermalLevel + +Obtains the current thermal level. + +**System Capabilities** + +SystemCapability.PowerManager.ThermalManager + +**Return value** + +| Type| Description| +| -------- | -------- | +| ThermalLevel | Thermal level obtained.| + +**Example** + +``` +var lev = thermal.getThermalLevel(); +console.info("Thermal level is: " + lev); +``` diff --git a/en/application-dev/reference/apis/js-apis-treemap.md b/en/application-dev/reference/apis/js-apis-treemap.md new file mode 100644 index 0000000000000000000000000000000000000000..047a66fbf44e97d3c45ac04d04ba5be64b629fd1 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-treemap.md @@ -0,0 +1,518 @@ +# Nonlinear Container TreeMap + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import TreeMap from '@ohos.util.TreeMap' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## TreeMap + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a tree map (called container later).| + + +### constructor + +constructor(comparator?:(firstValue: K, secondValue: K) => boolean) + +A constructor used to create a **TreeMap** instance. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| comparator | function | No| Custom comparator.| + +**Example** + +``` +let treeMap = new TreeMap(); +``` + + +### isEmpty + +isEmpty(): boolean; + +Checks whether this container is empty (contains no entry). + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +const treeMap = new TreeMap(); +let result = treeMap.isEmpty(); +``` + + +### hasKey + +hasKey(key: K): boolean; + +Checks whether this container has the specified key. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified key is contained; returns **false** otherwise.| + +**Example** + +``` +let treeMap = new TreeMap(); +let result = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +let result1 = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + + +### hasValue + +hasValue(value: V): boolean + +Checks whether this container has the specified value. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | V | Yes| Value to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified value is contained; returns **false** otherwise.| + +**Example** + +``` +let treeMap = new TreeMap(); +let result = treeMap.hasValue(123); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +let result1 = treeMap.hasValue(123); +``` + + +### get + +get(key: K): V + +Obtains the value of the specified key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| V | Value of the key.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let result = treeMap.get("sdfs"); +``` + + +### getFirstKey + +getFirstKey(): K; + +Obtains the first key in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| K | Key obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let result = treeMap.getFirstKey(); +``` + + +### getLastKey + +getLastKey(): K; + +Obtains the last key in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| K | Key obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let result = treeMap.getLastKey(); +``` + + +### setAll + +setAll(map: TreeMap): void + +Adds all entries in a **TreeMap** instance to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| map | TreeMap | Yes| **TreeMap** instance whose entries are to be added to the current container.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let map = new TreeMap(); +treeMap.setAll(map); +``` + + +### set +set(key: K, value: V): Object + +Adds an entry to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of the entry to add.| +| value | V | Yes| Value of the entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Object | Container that contains the new entry.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +``` + + +### remove + +remove(key: K): V; + +Removes the entry with the specified key from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of the entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| V | Value of the entry removed.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +treeMap.remove("sdfs"); +``` + + +### getLowerKey + +getLowerKey(key: K): K + +Obtains the key that is placed in front of the input key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Input key.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| K | Key obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +treeMap.set("zdfgsd", 356); +let result = treeMap.getLowerKey("sdfs"); +``` + + +### getHigherKey + +getHigherKey(key: K): K + +Obtains the key that is placed next to the input key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Input key.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| K | Key obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +treeMap.set("zdfgsd", 356); +let result = treeMap.getHigherKey("sdfs"); +``` + +### replace +replace(key: K, newValue: V): boolean + +Replaces an entry in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of the entry to replace.| +| newValue | V | Yes| New value of the entry.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is replaced successfully; returns **false** otherwise.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("sdfs", 123); +let result = treeMap.replace("sdfs", 357); +``` + + +### clear + +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +treeMap.clear(); +``` + + +### keys + +keys(): IterableIterator<K> + +Obtains an iterator that contains all the keys in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<K> | Iterator obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let iter = treeMap.keys(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` + + +### values + +values(): IterableIterator<V> + +Obtains an iterator that contains all the values in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<V> | Iterator obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let iter = treeMap.values(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` + + +### forEach + +forEach(callbackfn: (value: V, key?: K, map?: TreeMap) => void, thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | V | Yes| Value of the entry that is currently traversed.| +| key | K | Yes| Key of the entry that is currently traversed.| +| map | TreeMap | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("sdfs", 123); +treeMap.set("dfsghsf", 357); +treeMap.forEach((value, key) => { + console.log(value, key); +}); +``` + + +### entries + +entries(): IterableIterator<[K, V]> + +Obtains an iterator that contains all the entries in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<[K, V]> | Iterator obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); +let iter = treeMap.entries(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp[0]); + console.log(temp[1]); + temp = iter.next().value; +} +``` + + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<[K, V]>; + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** +| Type| Description| +| -------- | -------- | +| IterableIterator<[K, V]> | Iterator obtained.| + +**Example** + +``` +let treeMap = new TreeMap(); +treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +treeMap.set("sdfs", 356); + +// Method 1: +for (let item of treeMap) { + console.log("key: " + item[0]); + console.log("value: " + item[1]); +} + +// Method 2: +let iter = treeMap[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp[0]); + console.log(temp[1]); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-treeset.md b/en/application-dev/reference/apis/js-apis-treeset.md new file mode 100644 index 0000000000000000000000000000000000000000..bc937047ab2edb71d6c27322ba93f785632e9079 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-treeset.md @@ -0,0 +1,428 @@ +# Nonlinear Container TreeSet + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + + +## Modules to Import + +``` +import TreeSet from '@ohos.util.TreeSet' +``` + +## System Capabilities + +SystemCapability.Utils.Lang + +## TreeSet + + +### Attributes + +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Number of entries in a tree set (called container later).| + + +### constructor + +constructor(comparator?:(firstValue: T, secondValue: T) => boolean) + +A constructor used to create a **TreeSet** instance. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| comparator | function | No| Custom comparator.| + +**Example** + +``` +let treeSet = new TreeSet(); +``` + + +### isEmpty + +isEmpty(): boolean + +Checks whether this container is empty (contains no entry). + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the container is empty; returns **false** otherwise.| + +**Example** + +``` +const treeSet = new TreeSet(); +let result = treeSet.isEmpty(); +``` + + +### has + +has(value: T): boolean + +Checks whether this container has the specified value. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value to query.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the specified value is contained; returns **false** otherwise.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.has(123); +treeSet.add(123); +let result1 = treeSet.has(123); +``` + + +### getFirstValue + +getFirstValue(): T + +Obtains the value of the first entry in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let result = treeSet.getFirstValue(); +``` + + +### getLastValue + +getLastValue(): T + +Obtains the value of the last entry in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let result = treeSet.getLastValue(); +``` + + +### add +add(value: T): boolean + +Adds an entry to this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Entry to add.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is added successfully; returns **false** otherwise.| + +**Example** + +``` +let treeSet = new TreeSet(); +let result = treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +``` + + +### remove + +remove(value: T): boolean; + +Removes the entry with the specified key from this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Key of the entry to remove.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the entry is removed successfully; returns **false** otherwise.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let result = treeSet.remove("sdfs"); +``` + + +### getLowerValue + +getLowerValue(key: T): T + +Obtains the value that is placed in front of the input key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | T | Yes| Input key.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +treeSet.add("zdfgsd"); +let result = treeSet.getLowerValue("sdfs"); +``` + + +### getHigherValue + +getHigherValue(key: T): T + +Obtains the value that is placed next to the input key in this container. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | T | Yes| Input key.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Value obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +treeSet.add("zdfgsd"); +let result = treeSet.getHigherValue("sdfs"); +``` + + +### popFirst + +popFirst(): T + +Removes the first entry in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Return value** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let result = treeSet.popFirst(); +``` + + +### popLast + +popLast(): T + +Removes the last entry in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| T | Entry removed.| + +**Return value** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let result = treeSet.popLast(); +``` + + +### clear + +clear(): void + +Clears this container and sets its length to **0**. + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +treeSet.clear(); +``` + + +### values + +values(): IterableIterator<T> + +Obtains an iterator that contains all the values in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let iter = treeSet.values(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` + + +### forEach + +forEach(callbackfn: (value: T, key?: T, set?: TreeSet<T>) => void, thisArg?: Object): void + +Uses a callback to traverse the entries in this container and obtain their position indexes. + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes| Callback invoked to traverse the entries in the container.| +| thisArg | Object | No| Value to use when the callback is invoked.| + +callbackfn +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | T | Yes| Value of the entry that is currently traversed.| +| key | T | No| Key of the entry that is currently traversed (same as **value**).| +| set | TreeSet<T> | No| Instance that invokes the **forEach** method.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("sdfs"); +treeSet.add("dfsghsf"); +treeSet.forEach((value, key) => { + console.log(value, key) +}); +``` + + +### entries + +entries(): IterableIterator<[T, T]> + +Obtains an iterator that contains all the entries in this container. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<[T, T]> | Iterator obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); +let iter = treeSet.entries(); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp[0]); + console.log(temp[1]); + temp = iter.next().value; +} +``` + + +### [Symbol.iterator] + +[Symbol.iterator]\(): IterableIterator<T> + + +Obtains an iterator, each item of which is a JavaScript object. + +**Return value** + +| Type| Description| +| -------- | -------- | +| IterableIterator<T> | Iterator obtained.| + +**Example** + +``` +let treeSet = new TreeSet(); +treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +treeSet.add("sdfs"); + +// Method 1: +for (let item of treeSet) { + console.log("value: " + item); +} + +// Method 2: +let iter = treeSet[Symbol.iterator](); +let temp = iter.next().value; +while(temp != undefined) { + console.log(temp); + temp = iter.next().value; +} +``` diff --git a/en/application-dev/reference/apis/js-apis-update.md b/en/application-dev/reference/apis/js-apis-update.md index b9f9de86cacd44575f7105c82e0715eec3f622a6..3dbd1691e8dff68ae28eb0faa725fd5d4e3ec9bd 100644 --- a/en/application-dev/reference/apis/js-apis-update.md +++ b/en/application-dev/reference/apis/js-apis-update.md @@ -1,6 +1,6 @@ # Update -The update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications. +The Update module applies to updates throughout the entire system, including built-in resources and preset applications, but not third-party applications. There are two types of updates: SD card update and over the air (OTA) update. @@ -10,109 +10,212 @@ There are two types of updates: SD card update and over the air (OTA) update. ## Modules to Import ```js -import client from '@ohos.update' +import update from '@ohos.update' ``` ## Required Permissions None +## Obtaining an Updater Object + +### update.getUpdater + +getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater + +Obtains the **Updater** object for local update. + +**System capability**: SystemCapability.Updater.update_service + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | -------- | +| upgradeFile | string | Yes | Update file.| +| updateType | [UpdateTypes](#updatetypes) | Yes | Update type.| + +**Return value** + +| Type | Description | +| ------------------- | -------- | +| [Updater](#updater) | **Updater** object.| + +**Example** + +``` +try { + let updater = update.getUpdater('/data/updater/updater.zip', 'OTA'); +} catch(error) { + console.error(" Fail to get updater error: " + error); +} +``` + +### update.getUpdaterForOther + +getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater + +Obtains the **Updater** object for the device to be updated. + +**System capability**: SystemCapability.Updater.update_service + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | ---------- | +| upgradeFile | string | Yes | Update file. | +| device | string | Yes | Device to be updated.| +| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | + +**Return value** + +| Type | Description | +| ------------------- | -------- | +| [Updater](#updater) | **Updater** object.| + +**Example** + +``` +try { + let updater = update.getUpdaterForOther('/data/updater/updater.zip', '1234567890', 'OTA'); +} catch(error) { + console.error(" Fail to get updater error: " + error); +} +``` + +### update.getUpdaterFromOther + +getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater + +Obtains the **Updater** object from another device for the device to be updated. + +**System capability**: SystemCapability.Updater.update_service + +**Parameters** + +| Name | Type | Mandatory| Description | +| ----------- | --------------------------- | ---- | ---------- | +| upgradeFile | string | Yes | Update file. | +| device | string | Yes | Device to be updated.| +| updateType | [UpdateTypes](#updatetypes) | Yes | Update type. | + +**Return value** + +| Type | Description | +| ------------------- | -------- | +| [Updater](#updater) | **Updater** object.| + +**Example** + +``` +try { + let updater = update.getUpdaterFromOther('/data/updater/updater.zip', '1234567890', 'OTA'); +} catch(error) { + console.error(" Fail to get updater error: " + error); +} +``` + ## Updater ### getNewVersionInfo getNewVersionInfo(callback: AsyncCallback\): void -Obtains the new version information. This method uses an asynchronous callback to return the result. +Obtains the new version information. This function uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Updater.update_service **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ------------------------------------------------ | ---- | ------------------ | -| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No| Callback used to return the new version information.| +| callback | AsyncCallback<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information.| **Example** ``` -updater.getNewVersionInfo(info => { +update.getNewVersionInfo(info => { console.log("getNewVersionInfo success " + info.status); console.log(`info versionName = ` + info.result[0].versionName); console.log(`info versionCode = ` + info.result[0].versionCode); console.log(`info verifyInfo = ` + info.result[0].verifyInfo); -)}; +}); ``` ### getNewVersionInfo getNewVersionInfo(): Promise\ -Obtains the new version information. This method uses a promise to return the result. +Obtains the new version information. This function uses a promise to return the result. -**Return values** +**System capability**: SystemCapability.Updater.update_service -| Type| Description| +**Return value** + +| Type | Description | | ------------------------------------------- | ------------------------- | | Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.| **Example** ``` -var p = updater.getNewVersionInfo(); -p.then(function (value) { +updater.getNewVersionInfo().then(value => { console.log(`info versionName = ` + value.result[0].versionName); console.log(`info versionCode = ` + value.result[0].versionCode); console.log(`info verifyInfo = ` + value.result[0].verifyInfo); -}).catch(function (err) { +}).catch(err => { console.log("getNewVersionInfo promise error: " + err.code); -)}; +}); ``` ### checkNewVersion checkNewVersion(callback: AsyncCallback\): void -Checks whether the current version is the latest. This method uses an asynchronous callback to return the result. +Checks whether the current version is the latest. This function uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Updater.update_service **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ------------------------------------------------- | ---- | ------------------ | -| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No| Callback used to return the new version information.| +| callback | AsyncCallback\<[NewVersionInfo](#newversioninfo)> | No | Callback used to return the new version information.| **Example** ``` -updater.checkNewVersion(info => { +update.checkNewVersion(info => { console.log("checkNewVersion success " + info.status); console.log(`info versionName = ` + info.result[0].versionName); console.log(`info versionCode = ` + info.result[0].versionCode); console.log(`info verifyInfo = ` + info.result[0].verifyInfo); -)}; +}); ``` ### checkNewVersion checkNewVersion(): Promise\ -Checks whether the current version is the latest. This method uses a promise to return the result. +Checks whether the current version is the latest. This function uses a promise to return the result. + +**System capability**: SystemCapability.Updater.update_service -**Return values** +**Return value** -| Type| Description| +| Type | Description | | ------------------------------------------- | ------------------------- | | Promise\<[NewVersionInfo](#newversioninfo)> | Promise used to return the new version information.| **Example** ``` -var p = updater.checkNewVersion(); -p.then(function (value) { +update.checkNewVersion().then(value => { console.log(`info versionName = ` + value.result[0].versionName); console.log(`info versionCode = ` + value.result[0].versionCode); console.log(`info verifyInfo = ` + value.result[0].verifyInfo); -}).catch(function (err) { +}).catch(err => { console.log("checkNewVersion promise error: " + err.code); -)}; +}); ``` ### verifyUpdatePackage @@ -121,45 +224,45 @@ verifyUpdatePackage(upgradeFile: string, certsFile: string): void Verifies whether the update package is valid. +**System capability**: SystemCapability.Updater.update_service + **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ----------- | ------ | ---- | ------------------ | -| upgradeFile | string | Yes| Path of the update package to be verified.| -| certsFile | string | Yes| Certificate path.| +| upgradeFile | string | Yes | Path of the update package to be verified.| +| certsFile | string | Yes | Certificate path. | **Example** ``` -var getVar = update.getUpdater(); -getVar.on("verifyProgress", function (callback){ - console.info('on verifyProgress ' + callback.percent); +update.on("verifyProgress", callback => { + console.info('on verifyProgress ' + callback.percent); }); -getVar.verifyUpdatePackage("XXX", "XXX"); -getVar.off("verifyProgress"); +update.verifyUpdatePackage("XXX", "XXX"); ``` ### rebootAndCleanUserData rebootAndCleanUserData(): Promise\ -Reboots the device and clears the user partition data. This method uses a promise to return the result. +Reboots the device and clears the user partition data. This function uses a promise to return the result. -**Return values** +**System capability**: SystemCapability.Updater.update_service -| Type| Description| +**Return value** + +| Type | Description | | ---------------- | ------------------------------- | | Promise\ | Promise used to return the execution result.| **Example** ``` -var getVar = update.getUpdater(); -p = getVar.rebootAndCleanUserData(); -p.then(function (value) { - console.info("rebootAndCleanUserData promise success: " + value); -}).catch(function (err) { - console.info("rebootAndCleanUserData promise error: " + err.code); +update.rebootAndCleanUserData().then(result => { + console.log("rebootAndCleanUserData " + result); +}).catch(err => { + console.info("rebootAndCleanUserData promise error: " + err.code); }); ``` @@ -167,24 +270,21 @@ p.then(function (value) { rebootAndCleanUserData(callback: AsyncCallback\): void -Reboots the device and clears the user partition data. This method uses an asynchronous callback to return the result. +Reboots the device and clears the user partition data. This function uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Updater.update_service **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | -------- | ---- | ---------------------- | -| callback | Function | Yes| AsyncCallback\ | +| callback | AsyncCallback\| Yes | Callback used to return the execution result.| **Example** ``` -var getVar = update.getUpdater(); -getVar.rebootAndCleanUserData(function (err, data) { - if (err.code == 0) { - console.info("rebootAndCleanUserData callback success:" + data) - } else { - console.info("rebootAndCleanUserData callback err:" + err.code) - } +update.rebootAndCleanUserData(result => { + console.log("rebootAndCleanUserData ", result) }); ``` @@ -192,21 +292,22 @@ getVar.rebootAndCleanUserData(function (err, data) { applyNewVersion(): Promise\ -Installs the update package. This method uses a promise to return the result. +Installs the update package. This function uses a promise to return the result. -**Return values** +**System capability**: SystemCapability.Updater.update_service -| Type| Description| +**Return value** + +| Type | Description | | ---------------- | ------------------------------- | | Promise\ | Promise used to return the execution result.| **Example** ``` -var getVar = update.getUpdater(); -p.then(function (value) { - console.info("applyNewVersion promise success: " + value); -}).catch(function (err) { +update.applyNewVersion().then(result => { + console.log("appVewVersion ", result) +}).catch(err => { console.info("applyNewVersion promise error: " + err.code); }); ``` @@ -215,24 +316,21 @@ p.then(function (value) { applyNewVersion(callback: AsyncCallback\): void -Installs the update package. This method uses an asynchronous callback to return the result. +Installs the update package. This function uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Updater.update_service **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | -------- | ---- | ---------------------- | -| callback | Function | Yes| AsyncCallback\ | +| callback| AsyncCallback\| Yes | Callback used to return the execution result.| **Example** ``` -var getVar = update.getUpdater(); -getVar.applyNewVersion(function (err, data) { - if (err.code == 0) { - console.info("applyNewVersion callback success:" + data) - } else { - console.info("applyNewVersion callback err:" + err.code) - } +update.applyNewVersion(result => { + console.log("applyNewVersion ", result) }); ``` @@ -242,6 +340,8 @@ download(): void Downloads the new version and displays the download process. +**System capability**: SystemCapability.Updater.update_service + **Example** ``` @@ -249,7 +349,7 @@ updater.on("downloadProgress", progress => { console.log("downloadProgress on" + progress); console.log(`downloadProgress status: ` + progress.status); console.log(`downloadProgress percent: ` + progress.percent); -)}; +}); updater.download(); ``` @@ -259,6 +359,8 @@ updater.upgrade():void Starts an update. +**System capability**: SystemCapability.Updater.update_service + **Example** ``` @@ -266,7 +368,7 @@ updater.on("upgradeProgress", progress => { console.log("upgradeProgress on" + progress); console.log(`upgradeProgress status: ` + progress.status); console.log(`upgradeProgress percent: ` + progress.percent); -)}; +}); updater.upgrade(); ``` @@ -274,45 +376,50 @@ updater.upgrade(); setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\): void -Sets the update policy. This method uses an asynchronous callback to return the result. +Sets the update policy. This function uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Updater.update_service **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | ----------------------------- | ---- | ------------ | -| policy | [UpdatePolicy](#updatepolicy) | Yes| Update policy to set.| -| callback | AsyncCallback\ | Yes| Callback used to return the execution result.| +| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.| +| callback | AsyncCallback\ | Yes | Callback used to return the execution result.| **Example** ``` // Set the update policy. let policy = { -autoDownload: false, -autoDownloadNet: true, -mode: 2, -autoUpgradeInterval: [ 2, 3 ], -autoUpgradeCondition: 2 + autoDownload: false, + autoDownloadNet: true, + mode: 2, + autoUpgradeInterval: [ 2, 3 ], + autoUpgradeCondition: 2 } -updater.setUpdatePolicy(policy, function(result) { -console.log("setUpdatePolicy ", result)}); +update.setUpdatePolicy(policy, result => { + console.log("setUpdatePolicy ", result) +}); ``` ### setUpdatePolicy setUpdatePolicy(policy: UpdatePolicy): Promise\ -Sets the update policy. This method uses a promise to return the result. +Sets the update policy. This function uses a promise to return the result. + +**System capability**: SystemCapability.Updater.update_service **Parameters** -| Name| Type| Mandatory| Description| +| Name| Type | Mandatory| Description | | ------ | ----------------------------- | ---- | ------------ | -| policy | [UpdatePolicy](#updatepolicy) | Yes| Update policy to set.| +| policy | [UpdatePolicy](#updatepolicy) | Yes | Update policy to set.| -**Return values** +**Return value** -| Type| Description| +| Type | Description | | ---------------- | ----------------------- | | Promise\ | Promise used to return the execution result.| @@ -320,238 +427,153 @@ Sets the update policy. This method uses a promise to return the result. ``` let policy = { -autoDownload: false, -autoDownloadNet: true, -mode: 2, -autoUpgradeInterval: [ 2, 3 ], -autoUpgradeCondition: 2 + autoDownload: false, + autoDownloadNet: true, + mode: 2, + autoUpgradeInterval: [ 2, 3 ], + autoUpgradeCondition: 2 } -updater.setUpdatePolicy(policy) -.then(data=> -console.log('Policy set successfully') -) +update.setUpdatePolicy(policy).then(result => + console.log("setUpdatePolicy ", result) +).catch(err => { + console.log("setUpdatePolicy promise error: " + err.code); +}); ``` ### getUpdatePolicy getUpdatePolicy(callback: AsyncCallback\): void -Obtains the update policy. This method uses an asynchronous callback to return the result. +Obtains the update policy. This function uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Updater.update_service **Parameters** -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | -------- | --------------------------------------------- | ---- | -------------------- | -| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No| Callback used to return the update policy.| +| callback | AsyncCallback\<[UpdatePolicy](#updatepolicy)> | No | Callback used to return the update policy.| **Example** ``` -updater.getUpdatePolicy(policy => { +update.getUpdatePolicy(policy => { console.log("getUpdatePolicy success"); console.log(`policy autoDownload = ` + policy.autoDownload); console.log(`policy autoDownloadNet = ` + policy.autoDownloadNet); console.log(`policy mode = ` + policy.mode); -)}; +}); ``` ### getUpdatePolicy getUpdatePolicy(): Promise\ -Obtains the update policy. This method uses a promise to return the result. +Obtains the update policy. This function uses a promise to return the result. -**Return values** +**System capability**: SystemCapability.Updater.update_service -| Type| Description| +**Return value** + +| Type | Description | | --------------------------------------- | --------------------------- | | Promise\<[UpdatePolicy](#updatepolicy)> | Promise used to return the update policy.| **Example** ``` -p = updater.getUpdatePolicy(); -p.then(function (value) { +update.getUpdatePolicy().then(value => { console.log(`info autoDownload = ` + value.autoDownload); console.log(`info autoDownloadNet = ` + value.autoDownloadNet); console.log(`info mode = ` + value.mode); -}).catch(function (err) { +}).catch(err => { console.log("getUpdatePolicy promise error: " + err.code); -)}; -``` - -## update.getUpdater - -getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater - -Obtains the updater for the local update. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ----------- | --------------------------- | ---- | -------- | -| upgradeFile | string | Yes| Update file.| -| updateType | [UpdateTypes](#updatetypes) | Yes| Update type.| - -**Return values** - -| Type| Description| -| ------------------- | -------- | -| [Updater](#updater) | Updater object.| - -**Example** - -``` -try { - page.data.updater = update.getUpdater('/data/updater/updater.zip', 'OTA'); -} catch(error) { - console.error("Failed to get updater. Error: " + error); -} -``` - -## update.getUpdaterForOther - -getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater - -Obtains the updater for the device to be updated. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ----------- | --------------------------- | ---- | ---------- | -| upgradeFile | string | Yes| Update file.| -| device | string | Yes| Device to be updated.| -| updateType | [UpdateTypes](#updatetypes) | Yes| Update type.| - -**Return values** - -| Type| Description| -| ------------------- | -------- | -| [Updater](#updater) | Updater object.| - -**Example** - -``` -try { - page.data.updater = update.getUpdaterForOther('/data/updater/updater.zip', '1234567890', 'OTA'); -} catch(error) { - console.error("Failed to get updater. Error: " + error); -} -``` - -## update.getUpdaterFromOther - -getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater - -Obtains the updater from another device for the device to be updated. - -**Parameters** - -| Name| Type| Mandatory| Description| -| ----------- | --------------------------- | ---- | ---------- | -| upgradeFile | string | Yes| Update file.| -| device | string | Yes| Device to be updated.| -| updateType | [UpdateTypes](#updatetypes) | Yes| Update type.| - -**Return values** - -| Type| Description| -| ------------------- | -------- | -| [Updater](#updater) | Updater object.| - -**Example** - -``` -try { - page.data.updater = update.getUpdaterFromOther('/data/updater/updater.zip', '1234567890', 'OTA'); -} catch(error) { - console.error("Failed to get updater. Error: " + error); -} +}); ``` ## UpdateTypes -Describes the update type. +Enumerates update types. -| Name| Description| +| Name| Description | | ------ | -------- | -| OTA | OTA update.| -| patch | Patch update.| +| OTA | OTA update.
**System capability**: SystemCapability.Updater.update_service| +| patch | Patch update.
**System capability**: SystemCapability.Updater.update_service| ## PackageTypes -Enumerates the update package types. +Enumerates update package types. -| Name| Default Value| Description| +| Name | Default Value| Description | | -------------------- | ------ | -------------- | -| PACKAGE_TYPE_NORMAL | 1 | Common update package.| -| PACKAGE_TYPE_BASE | 2 | Basic update package.| -| PACKAGE_TYPE_CUST | 3 | Custom update package.| -| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package.| -| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package.| -| PACKAGE_TYPE_VERSION | 6 | Version update package.| -| PACKAGE_TYPE_PATCH | 7 | Patch package.| +| PACKAGE_TYPE_NORMAL | 1 | Common update package.
**System capability**: SystemCapability.Updater.update_service| +| PACKAGE_TYPE_BASE | 2 | Basic update package.
**System capability**: SystemCapability.Updater.update_service| +| PACKAGE_TYPE_CUST | 3 | Custom update package.
**System capability**: SystemCapability.Updater.update_service| +| PACKAGE_TYPE_PRELOAD | 4 | Preinstalled update package.
**System capability**: SystemCapability.Updater.update_service| +| PACKAGE_TYPE_COTA | 5 | Parameter configuration update package.
**System capability**: SystemCapability.Updater.update_service| +| PACKAGE_TYPE_VERSION | 6 | Version update package.
**System capability**: SystemCapability.Updater.update_service| +| PACKAGE_TYPE_PATCH | 7 | Patch package.
**System capability**: SystemCapability.Updater.update_service| ## InstallMode -Enumerates the update modes. +Enumerates update modes. -| Name| Default Value| Description| +| Name | Default Value| Description | | ------------------- | ------ | -------- | -| INSTALL_MODE_NORMAL | 0 | Normal update.| -| INSTALL_MODE_NIGHT | 1 | Update at night.| -| INSTALL_MODE_AUTO | 2 | Automatic update.| +| INSTALL_MODE_NORMAL | 0 | Normal update.
**System capability**: SystemCapability.Updater.update_service| +| INSTALL_MODE_NIGHT | 1 | Update at night.
**System capability**: SystemCapability.Updater.update_service| +| INSTALL_MODE_AUTO | 2 | Automatic update.
**System capability**: SystemCapability.Updater.update_service| ## NewVersionStatus -Enumerates the new version check results. +Enumerates new version check results. -| Name| Default Value| Description| +| Name | Default Value| Description | | ------------------- | ------ | ---------------- | -| VERSION_STATUS_ERR | -1 | System error while checking for the new version.| -| VERSION_STATUS_NEW | 0 | New version detected.| -| VERSION_STATUS_NONE | 1 | No new version detected.| -| VERSION_STATUS_BUSY | 2 | System busy while checking for the new version.| +| VERSION_STATUS_ERR | -1 | System error while checking for the new version.
**System capability**: SystemCapability.Updater.update_service| +| VERSION_STATUS_NEW | 0 | New version detected.
**System capability**: SystemCapability.Updater.update_service| +| VERSION_STATUS_NONE | 1 | No new version detected.
**System capability**: SystemCapability.Updater.update_service| +| VERSION_STATUS_BUSY | 2 | System busy while checking for the new version.
**System capability**: SystemCapability.Updater.update_service| ## UpdatePolicy Defines the update policy. -| Name| Parameter type.| Mandatory| Description| +| Name | Type | Mandatory| Description | | ------------------- | --------------------------- | ---- | -------------- | -| autoDownload | bool | Yes| Automatic update switch.| -| installMode | [InstallMode](#installmode) | Yes| Update mode.| -| autoUpgradeInterval | Array\ | Yes| Period of time for automatic update.| +| autoDownload | bool | Yes | Automatic update switch.
**System capability**: SystemCapability.Updater.update_service| +| installMode | [InstallMode](#installmode) | Yes | Update mode.
**System capability**: SystemCapability.Updater.update_service| +| autoUpgradeInterval | Array\ | Yes | Period of time for automatic update.
**System capability**: SystemCapability.Updater.update_service| ## NewVersionInfo Defines the new version information. -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | --------------- | ------------------------------------------- | ---- | -------- | -| status | [NewVersionStatus](#newversionstatus) | Yes| Update status.| -| errMsg | string | Yes| Error message.| -| checkResults | Array<[CheckResult](#checkresult)> | Yes| Check result.| -| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes| Description.| +| status | [NewVersionStatus](#newversionstatus) | Yes | Update status.
**System capability**: SystemCapability.Updater.update_service| +| errMsg | string | Yes | Error message.
**System capability**: SystemCapability.Updater.update_service| +| checkResults | Array<[CheckResult](#checkresult)> | Yes | Version check result.
**System capability**: SystemCapability.Updater.update_service| +| descriptionInfo | Array\<[DescriptionInfo](#descriptioninfo)> | Yes | Version description information.
**System capability**: SystemCapability.Updater.update_service| ## CheckResult -Defines the check result. +Defines the version check result. -| Name| Type| Mandatory| Description| +| Name | Type | Mandatory| Description | | ------------- | ----------------------------- | ---- | ------------ | -| versionName | string | Yes| Version name.| -| versionCode | number | Yes| Version code.| -| size | number | Yes| Version size.| -| verifyInfo | string | Yes| Version verification information.| -| packageType | [PackageTypes](#packagetypes) | Yes| Version type.| -| descriptionId | string | Yes| Version description.| +| versionName | string | Yes | Version name.
**System capability**: SystemCapability.Updater.update_service| +| versionCode | number | Yes | Version code.
**System capability**: SystemCapability.Updater.update_service| +| size | number | Yes | Version size.
**System capability**: SystemCapability.Updater.update_service| +| verifyInfo | string | Yes | Version verification information.
**System capability**: SystemCapability.Updater.update_service| +| packageType | [PackageTypes](#packagetypes) | Yes | Version type.
**System capability**: SystemCapability.Updater.update_service| +| descriptionId | string | Yes | Version description information.
**System capability**: SystemCapability.Updater.update_service| ## DescriptionInfo Defines the version description information. -| Name| Type| Mandatory| Description| +| Name | Type| Mandatory| Description | | ------------- | -------- | ---- | ----------------- | -| descriptionId | string | Yes| Version ID information.| -| content | string | Yes| Version changelog information.| +| descriptionId | string | Yes | Version ID information.
**System capability**: SystemCapability.Updater.update_service| +| content | string | Yes | Version changelog information.
**System capability**: SystemCapability.Updater.update_service| diff --git a/en/application-dev/reference/apis/js-apis-usb.md b/en/application-dev/reference/apis/js-apis-usb.md index 94c9f4a7a53229f888b8afd5bb998c1057822297..5ec4d9e336475374b6519a4f724f3666931e4b6d 100644 --- a/en/application-dev/reference/apis/js-apis-usb.md +++ b/en/application-dev/reference/apis/js-apis-usb.md @@ -1,1432 +1,540 @@ -# USB +# USB ->**NOTE:** ->The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. -## Modules to Import +## Modules to Import ``` import usb from "@ohos.usb"; ``` -## Required Permissions +## usb.getDevices -None. - -## usb.getDevices - -usb.getDevices\(\): Array\> +usb.getDevices(): Array<Readonly<USBDevice>> Obtains the USB device list. -- Return values - - - - - - - - - - -

Type

-

Description

-

Array<Readonly<USBDevice>>

-

USB device list.

-
- -- Example - - ``` - let devicesList = usb.getDevices(); - console.log(`devicesList = ${JSON.stringify(devicesList)}`); - // devicesList is a list of USB devices. - // A simple example of devicesList is provided as follows: - [ - { - name: "1-1", - serial: "", - manufacturerName: "", - productName: "", - version: "", - vendorId: 7531, - productId: 2, - clazz: 9, - subclass: 0, - protocol: 1, - devAddress: 1, - busNum: 1, - configs: [ - { - id: 1, - attributes: 224, - isRemoteWakeup: true, - isSelfPowered: true, - maxPower: 0, - name: "1-1", - interfaces: [ - { - id: 0, - protocol: 0, - clazz: 9, - subclass: 0, - alternateSetting: 0, - name: "1-1", - endpoints: [ - { - address: 129, - attributes: 3, - interval: 12, - maxPacketSize: 4, - direction: 128, - number: 1, - type: 3, - interfaceId: 0, - }, - ], - }, - ], - }, - ], - }, - ] - ``` - - -## usb.connectDevice - -usb.connectDevice\(device: USBDevice\): Readonly +**System capability**: SystemCapability.USB.USBManager + +- Return value + | Type| Description| + | -------- | -------- | + | Array<Readonly<[USBDevice](#usbdevice)>> | Device information list.| + +- Example + ``` + let devicesList = usb.getDevices(); + console.log(`devicesList = ${JSON.stringify(devicesList)}`); + // devicesList is a list of USB devices. + // A simple example of devicesList is provided as follows: + [ + { + name: "1-1", + serial: "", + manufacturerName: "", + productName: "", + version: "", + vendorId: 7531, + productId: 2, + clazz: 9, + subclass: 0, + protocol: 1, + devAddress: 1, + busNum: 1, + configs: [ + { + id: 1, + attributes: 224, + isRemoteWakeup: true, + isSelfPowered: true, + maxPower: 0, + name: "1-1", + interfaces: [ + { + id: 0, + protocol: 0, + clazz: 9, + subclass: 0, + alternateSetting: 0, + name: "1-1", + endpoints: [ + { + address: 129, + attributes: 3, + interval: 12, + maxPacketSize: 4, + direction: 128, + number: 1, + type: 3, + interfaceId: 0, + }, + ], + }, + ], + }, + ], + }, + ] + ``` + + +## usb.connectDevice + +usb.connectDevice(device: USBDevice): Readonly<USBDevicePipe> Connects to a USB device. -Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list, and then call [usb.requestRight](#section1865915394353) to request the device access permission. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

device

-

USBDevice

-

Yes

-

USB device information.

-
- - -- Return values - - - - - - - - - - -

Type

-

Description

-

Readonly<USBDevicePipe>

-

USB device pipe for data transfer.

-
- -- Example - - ``` - let devicepipe= usb.connectDevice(device); - console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); - ``` - - -## usb.hasRight - -usb.hasRight\(deviceName: string\): boolean - -Checks whether the user has the permission to access the device. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

deviceName

-

string

-

Yes

-

Device name.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

boolean

-

Returns true if the user has the permission to access the device; returns false otherwise.

-
- -- Example - - ``` - let divicesName="1-1"; - let bool = usb.hasRight(divicesName); - console.log(bool); - ``` - - -## usb.requestRight - -usb.requestRight\(deviceName: string\): Promise +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, and then call [usb.requestRight](#usbrequestright) to request the device access permission. + +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | device | [USBDevice](#usbdevice) | Yes| USB device information.| + +- Return value + | Type| Description| + | -------- | -------- | + | Readonly<[USBDevicePipe](#usbdevicepipe)> | USB device pipe for data transfer.| + +- Example + ``` + let devicepipe= usb.connectDevice(device); + console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); + ``` + + +## usb.hasRight + +usb.hasRight(deviceName: string): boolean + +Checks whether the application has the permission to access the device. + +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceName | string | Yes| Device name.| + +- Return value + | Type| Description| + | -------- | -------- | + | boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.| + +- Example + ``` + let divicesName="1-1"; + let bool = usb.hasRight(divicesName); + console.log(bool); + ``` + + +## usb.requestRight + +usb.requestRight(deviceName: string): Promise<boolean> Requests the temporary permission for the application to access the USB device. -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

deviceName

-

string

-

Yes

-

Device name.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<boolean>

-

Returns true if the temporary device access permissions are granted; returns false otherwise.

-
- -- Example - - ``` - let divicesName="1-1"; - usb.requestRight(divicesName).then((ret) => { - console.log(`requestRight = ${JSON.stringify(ret)}`); - }); - ``` - - -## usb.claimInterface - -usb.claimInterface\(pipe: USBDevicePipe, iface: USBInterface, force?: boolean\): number +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceName | string | Yes| Device name.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<boolean> | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise.| + +- Example + ``` + let divicesName="1-1"; + usb.requestRight(divicesName).then((ret) => { + console.log(`requestRight = ${JSON.stringify(ret)}`); + }); + ``` + + +## usb.claimInterface + +usb.claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number Claims a USB interface. -Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list and USB interfaces, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

pipe

-

USBDevicePipe

-

Yes

-

Device pipe, which is used to determine the bus number and device address.

-

iface

-

USBInterface

-

Yes

-

USB interface, which is used to determine the index of the interface to claim.

-

force

-

boolean

-

No

-

Optional parameter that determines whether to forcibly claim the USB interface. The default value is false, indicating not to forcibly claim the USB interface.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Returns 0 if the USB interface is successfully claimed; returns an error code otherwise.

-
- -- Example - - ``` - let ret = usb.claimInterface(devicepipe, interfaces); - console.log(`claimInterface = ${ret}`); - ``` - - -## usb.releaseInterface - -usb.releaseInterface\(pipe: USBDevicePipe, iface: USBInterface\): number +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and USB interfaces, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| + | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim.| + | force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.| + +- Example + ``` + let ret = usb.claimInterface(devicepipe, interfaces); + console.log(`claimInterface = ${ret}`); + ``` + + +## usb.releaseInterface + +usb.releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number Releases a USB interface. -Before you do this, ensure that you have claimed the interface by calling [usb.claimInterface](#section41056254494). - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

pipe

-

USBDevicePipe

-

Yes

-

Device pipe, which is used to determine the bus number and device address.

-

iface

-

USBInterface

-

Yes

-

USB interface, which is used to determine the index of the interface to release.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Returns 0 if the USB interface is successfully released; returns an error code otherwise.

-
- -- Example - - ``` - let ret = usb.releaseInterface(devicepipe, interfaces); - console.log(`releaseInterface = ${ret}`); - ``` - - -## usb.setConfiguration - -usb.setConfiguration\(pipe: USBDevicePipe, config: USBConfig\): number +Before you do this, ensure that you have claimed the interface by calling [usb.claimInterface](#usbclaiminterface). + +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| + | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.| + +- Example + ``` + let ret = usb.releaseInterface(devicepipe, interfaces); + console.log(`releaseInterface = ${ret}`); + ``` + + +## usb.setConfiguration + +usb.setConfiguration(pipe: USBDevicePipe, config: USBConfig): number Sets the device configuration. -Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list and device configuration, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

pipe

-

USBDevicePipe

-

Yes

-

Device pipe, which is used to determine the bus number and device address.

-

config

-

USBConfig

-

Yes

-

USB configuration to set.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Returns 0 if the USB configuration is successfully set; returns an error code otherwise.

-
- -- Example - - ``` - let ret = usb.setConfiguration(devicepipe, config); - console.log(`setConfiguration = ${ret}`); - ``` - - -## usb.setInterface - -usb.setInterface\(pipe: USBDevicePipe, iface: USBInterface\): number +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and device configuration, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| + | config | [USBConfig](#usbconfig) | Yes| USB configuration to set.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.| + +- Example + ``` + let ret = usb.setConfiguration(devicepipe, config); + console.log(`setConfiguration = ${ret}`); + ``` + + +## usb.setInterface + +usb.setInterface(pipe: USBDevicePipe, iface: USBInterface): number Sets a USB interface. -Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list and interfaces, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. - -- Parameters - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

pipe

-

USBDevicePipe

-

Yes

-

Device pipe, which is used to determine the bus number and device address.

-

iface

-

USBInterface

-

Yes

-

USB interface to set.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Returns 0 if the USB interface is successfully set; returns an error code otherwise.

-
- -- Example - - ``` - let ret = usb.setInterface(devicepipe, interfaces); - console.log(`setInterface = ${ret}`); - ``` - - -## usb.getRawDescriptor - -usb.getRawDescriptor\(pipe: USBDevicePipe\): Uint8Array +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and interfaces, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| + | iface | [USBInterface](#usbinterface) | Yes| USB interface to set.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.| + +- Example + ``` + let ret = usb.setInterface(devicepipe, interfaces); + console.log(`setInterface = ${ret}`); + ``` + + +## usb.getRawDescriptor + +usb.getRawDescriptor(pipe: USBDevicePipe): Uint8Array Obtains the raw USB descriptor. -Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

pipe

-

USBDevicePipe

-

Yes

-

Device pipe, which is used to determine the bus number and device address.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Uint8Array

-

Raw descriptor data.

-
- -- Example - - ``` - let ret = usb.getRawDescriptor(devicepipe); - ``` - - -## usb.getFileDescriptor - -usb.getFileDescriptor\(pipe: USBDevicePipe\): number +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| + +- Return value + | Type| Description| + | -------- | -------- | + | Uint8Array | Raw descriptor data.| + +- Example + ``` + let ret = usb.getRawDescriptor(devicepipe); + ``` + + +## usb.getFileDescriptor + +usb.getFileDescriptor(pipe: USBDevicePipe): number Obtains the file descriptor. -Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

pipe

-

USBDevicePipe

-

Yes

-

Device pipe, which is used to determine the bus number and device address.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

File descriptor of the USB device.

-
- -- Example - - ``` - let ret = usb.getFileDescriptor(devicepipe); - ``` - - -## usb.controlTransfer - -usb.controlTransfer\(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number\): Promise +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | File descriptor of the USB device.| + +- Example + ``` + let ret = usb.getFileDescriptor(devicepipe); + ``` + + +## usb.controlTransfer + +usb.controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise<number> Performs control transfer. -Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

pipe

-

USBDevicePipe

-

Yes

-

USB device pipe, which is used to determine the USB device.

-

contrlparam

-

USBControlParams

-

Yes

-

Control transfer parameters.

-

timeout

-

number

-

No

-

Timeout duration. This parameter is optional. The default value is 0, indicating no timeout.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<number>

-

Returns the size of the transmitted or received data block if the control transfer is successful; returns -1 if an exception occurs.

-
- -- Example - - ``` - usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { - console.log(`controlTransfer = ${JSON.stringify(ret)}`); - }) - ``` - - -## usb.bulkTransfer - -usb.bulkTransfer\(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number\): Promise +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| + | contrlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters.| + | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<number> | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.| + +- Example + ``` + usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { + console.log(`controlTransfer = ${JSON.stringify(ret)}`); + }) + ``` + + +## usb.bulkTransfer + +usb.bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise<number> Performs bulk transfer. -Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list and endpoints, call [usb.requestRight](#section1865915394353) to request the device access permission, call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#section41056254494) to claim the USB interface. - -- Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

pipe

-

USBDevicePipe

-

Yes

-

USB device pipe, which is used to determine the USB device.

-

endpoint

-

USBEndpoint

-

Yes

-

USB endpoint, which is used to determine the USB port for data transfer.

-

buffer

-

Uint8Array

-

Yes

-

Buffer for writing or reading data.

-

timeout

-

number

-

No

-

Timeout duration. This parameter is optional. The default value is 0, indicating no timeout.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

Promise<number>

-

Returns the size of the transmitted or received data block if the control transfer is successful; returns -1 if an exception occurs.

-
- -- Example - - ``` - // Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission. - // Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. - // Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. - usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { - console.log(`bulkTransfer = ${JSON.stringify(ret)}`); - }); - ``` - - -## usb.closePipe - -usb.closePipe\(pipe: USBDevicePipe\): number +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and endpoints, call [usb.requestRight](#usbrequestright) to request the device access permission, call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#usbclaiminterface) to claim the USB interface. + +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| + | endpoint | [USBEndpoint](#usbendpoint) | Yes| USB endpoint, which is used to determine the USB port for data transfer.| + | buffer | Uint8Array | Yes| Buffer for writing or reading data.| + | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.| + +- Return value + | Type| Description| + | -------- | -------- | + | Promise<number> | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.| + +- Example + ``` + // Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission. + // Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. + // Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. + usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { + console.log(`bulkTransfer = ${JSON.stringify(ret)}`); + }); + ``` + + +## usb.closePipe + +usb.closePipe(pipe: USBDevicePipe): number Closes a USB device pipe. -Before you do this, call [usb.getDevices](#section1885592111287) to obtain the USB device list, call [usb.requestRight](#section1865915394353) to request the device access permission, and call [usb.connectDevice](#section910254722918) to obtain **devicepipe** as an input parameter. - -- Parameters - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Description

-

pipe

-

USBDevicePipe

-

Yes

-

USB device pipe.

-
- -- Return values - - - - - - - - - - -

Type

-

Description

-

number

-

Returns 0 if the USB device pipe is closed successfully; returns an error code otherwise.

-
- -- Example - - ``` - let ret = usb.closePipe(devicepipe); - console.log(`closePipe = ${ret}`); - ``` - - -## USBEndpoint - -Represents the USB endpoint from which data is sent or received. You can obtain the USB endpoint through [USBInterface](#section1564414611311). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

address

-

number

-

Endpoint address.

-

attributes

-

number

-

Endpoint attributes.

-

interval

-

number

-

Endpoint interval.

-

maxPacketSize

-

number

-

Maximum size of data packets on the endpoint.

-

direction

-

USBRequestDirection

-

Endpoint direction.

-

number

-

number

-

Endpoint number.

-

type

-

number

-

Endpoint type.

-

interfaceId

-

number

-

Unique ID of the interface to which the endpoint belongs.

-
- -## USBInterface - -Represents a USB interface. One [USBConfig](#section1172111051715) can contain multiple **USBInterface** instances, each providing a specific function. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

id

-

number

-

Unique ID of the USB interface.

-

protocol

-

number

-

Interface protocol.

-

clazz

-

number

-

Device type.

-

subClass

-

number

-

Device subclass.

-

alternateSetting

-

number

-

Settings for alternating between descriptors of the same USB interface.

-

name

-

string

-

Interface name.

-

endpoints

-

Array<USBEndpoint>

-

Endpoints that belong to the USB interface.

-
- -## USBConfig - -Represents the USB configuration. One [USBDevice](#section14936845182012) can contain multiple **USBConfig** instances. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

id

-

number

-

Unique ID of the USB configuration.

-

attributes

-

number

-

Configuration attributes.

-

maxPower

-

number

-

Maximum power consumption, in mA.

-

name

-

string

-

Configuration name, which can be left empty.

-

isRemoteWakeup

-

boolean

-

Support for remote wakeup.

-

isSelfPowered

-

boolean

-

Support for independent power supplies.

-

interfaces

-

Array <USBInterface>

-

Supported interface attributes.

-
- -## USBDevice - -Represents a USB device. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

busNum

-

number

-

Bus address.

-

devAddress

-

number

-

Device address.

-

serial

-

string

-

Device SN.

-

name

-

string

-

Device name.

-

manufacturerName

-

string

-

Device manufacturer.

-

productName

-

string

-

Product name.

-

version

-

string

-

Product version.

-

vendorId

-

number

-

Vendor ID.

-

productId

-

number

-

Product ID.

-

clazz

-

number

-

Device class.

-

subClass

-

number

-

Device subclass.

-

protocol

-

number

-

Device protocol code.

-

configs

-

Array<USBConfig>

-

Device configuration descriptor information.

-
- -## USBDevicePipe +Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. + +**System capability**: SystemCapability.USB.USBManager + +- Parameters + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.| + +- Return value + | Type| Description| + | -------- | -------- | + | number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.| + +- Example + ``` + let ret = usb.closePipe(devicepipe); + console.log(`closePipe = ${ret}`); + ``` + + +## USBEndpoint + +Represents the USB endpoint from which data is sent or received. You can obtain the USB endpoint through [USBInterface](#usbinterface). + +| Name| Type| Description| +| -------- | -------- | -------- | +| address | number | Endpoint address.
**System capability**: SystemCapability.USB.USBManager| +| attributes | number | Endpoint attributes.
**System capability**: SystemCapability.USB.USBManager| +| interval | number | Endpoint interval.
**System capability**: SystemCapability.USB.USBManager| +| maxPacketSize | number | Maximum size of data packets on the endpoint.
**System capability**: SystemCapability.USB.USBManager| +| direction | [USBRequestDirection](#usbrequestdirection) | Endpoint direction.
**System capability**: SystemCapability.USB.USBManager| +| number | number | Endpoint number.
**System capability**: SystemCapability.USB.USBManager| +| type | number | Endpoint type.
**System capability**: SystemCapability.USB.USBManager| +| interfaceId | number | Unique ID of the interface to which the endpoint belongs.
**System capability**: SystemCapability.USB.USBManager| + + +## USBInterface + +Represents a USB interface. One [USBConfig](#usbconfig) can contain multiple **USBInterface** instances, each providing a specific function. + +| Name| Type| Description| +| -------- | -------- | -------- | +| id | number | Unique ID of the USB interface.
**System capability**: SystemCapability.USB.USBManager| +| protocol | number | Interface protocol.
**System capability**: SystemCapability.USB.USBManager| +| clazz | number | Device type.
**System capability**: SystemCapability.USB.USBManager| +| subClass | number | Device subclass.
**System capability**: SystemCapability.USB.USBManager| +| alternateSetting | number | Settings for alternating between descriptors of the same USB interface.
**System capability**: SystemCapability.USB.USBManager| +| name | string | Interface name.
**System capability**: SystemCapability.USB.USBManager| +| endpoints | Array<[USBEndpoint](#usbendpoint)> | Endpoints that belong to the USB interface.
**System capability**: SystemCapability.USB.USBManager| + + +## USBConfig + +Represents the USB configuration. One [USBDevice](#usbdevice) can contain multiple **USBConfig** instances. + +| Name| Type| Description| +| -------- | -------- | -------- | +| id | number | Unique ID of the USB configuration.
**System capability**: SystemCapability.USB.USBManager| +| attributes | number | Configuration attributes.
**System capability**: SystemCapability.USB.USBManager| +| maxPower | number | Maximum power consumption, in mA.
**System capability**: SystemCapability.USB.USBManager| +| name | string | Configuration name, which can be left empty.
**System capability**: SystemCapability.USB.USBManager| +| isRemoteWakeup | boolean | Support for remote wakeup.
**System capability**: SystemCapability.USB.USBManager| +| isSelfPowered | boolean | Support for independent power supplies.
**System capability**: SystemCapability.USB.USBManager| +| interfaces | Array <[USBInterface](#usbinterface)> | Supported interface attributes.
**System capability**: SystemCapability.USB.USBManager| + + +## USBDevice + +Represents the USB device information. + +| Name| Type| Description| +| -------- | -------- | -------- | +| busNum | number | Bus address.
**System capability**: SystemCapability.USB.USBManager| +| devAddress | number | Device address.
**System capability**: SystemCapability.USB.USBManager| +| serial | string | Device SN.
**System capability**: SystemCapability.USB.USBManager| +| name | string | Device name.
**System capability**: SystemCapability.USB.USBManager| +| manufacturerName | string | Device manufacturer.
**System capability**: SystemCapability.USB.USBManager| +| productName | string | Product information.
**System capability**: SystemCapability.USB.USBManager| +| version | string | Version.
**System capability**: SystemCapability.USB.USBManager| +| vendorId | number | Vendor ID.
**System capability**: SystemCapability.USB.USBManager| +| productId | number | Product ID.
**System capability**: SystemCapability.USB.USBManager| +| clazz | number | Device class.
**System capability**: SystemCapability.USB.USBManager| +| subClass | number | Device subclass.
**System capability**: SystemCapability.USB.USBManager| +| protocol | number | Device protocol code.
**System capability**: SystemCapability.USB.USBManager| +| configs | Array<[USBConfig](#usbconfig)> | Device configuration descriptor information.
**System capability**: SystemCapability.USB.USBManager| + + +## USBDevicePipe Represents a USB device pipe, which is used to determine a USB device. - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

busNum

-

number

-

Bus address.

-

devAddress

-

number

-

Device address.

-
- -## USBControlParams +| Name| Type| Description| +| -------- | -------- | -------- | +| busNum | number | Bus address.
**System capability**: SystemCapability.USB.USBManager| +| devAddress | number | Device address.
**System capability**: SystemCapability.USB.USBManager| + + +## USBControlParams Represents control transfer parameters. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Type

-

Description

-

request

-

number

-

Request type.

-

target

-

USBRequestTargetType

-

Request target type.

-

reqType

-

USBControlRequestType

-

Request control type.

-

value

-

number

-

Request parameter value.

-

index

-

number

-

Index of the request parameter value.

-

data

-

Uint8Array

-

Data written to or read from the buffer.

-
- -## USBRequestTargetType - -Enumerates USB request target types. - - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

USB_REQUEST_TARGET_DEVICE

-

0

-

Device

-

USB_REQUEST_TARGET_INTERFACE

-

1

-

Interface

-

USB_REQUEST_TARGET_ENDPOINT

-

2

-

Endpoint

-

USB_REQUEST_TARGET_OTHER

-

3

-

Others

-
- -## USBControlRequestType +| Name| Type| Description| +| -------- | -------- | -------- | +| request | number | Request type.| +| target | [USBRequestTargetType](#usbrequesttargettype) | Request target type.
**System capability**: SystemCapability.USB.USBManager| +| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Request control type.
**System capability**: SystemCapability.USB.USBManager| +| value | number | Request parameters
**System capability**: SystemCapability.USB.USBManager| +| index | number | Index of the request parameter value.
**System capability**: SystemCapability.USB.USBManager| +| data | Uint8Array | Buffer for writing or reading data.
**System capability**: SystemCapability.USB.USBManager| + + +## USBRequestTargetType + +Represents the request target type. + + +| Name| Default Value| Description| +| -------- | -------- | -------- | +| USB\_REQUEST\_TARGET\_DEVICE | 0 | Device.
**System capability**: SystemCapability.USB.USBManager| +| USB\_REQUEST\_TARGET\_INTERFACE | 1 | Interface.
**System capability**: SystemCapability.USB.USBManager| +| USB\_REQUEST\_TARGET\_ENDPOINT | 2 | Endpoint
**System capability**: SystemCapability.USB.USBManager| +| USB_REQUEST_TARGET_OTHER | 3 | Others
**System capability**: SystemCapability.USB.USBManager| + + +## USBControlRequestType Enumerates control request types. - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

USB_REQUEST_TYPE_STANDARD

-

0

-

Standard

-

USB_REQUEST_TYPE_CLASS

-

1

-

Class

-

USB_REQUEST_TYPE_VENDOR

-

2

-

Vendor

-
- -## USBRequestDirection +| Name| Default Value| Description| +| -------- | -------- | -------- | +| USB\_REQUEST\_TYPE\_STANDARD | 0 | Standard
**System capability**: SystemCapability.USB.USBManager| +| USB\_REQUEST\_TYPE\_CLASS | 1 | Class
**System capability**: SystemCapability.USB.USBManager| +| USB\_REQUEST\_TYPE\_VENDOR | 2 | Vendor
**System capability**: SystemCapability.USB.USBManager| + + +## USBRequestDirection Enumerates request directions. - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

USB_REQUEST_TYPE_STANDARD

-

0

-

Request for writing data from the host to the device.

-

USB_REQUEST_TYPE_CLASS

-

0x80

-

Request for reading data from the device to the host.

-
- - - - - - - - - - - - - - - - - - - - - - - - -

Name

-

Default Value

-

Description

-

NONE

-

0

-

None.

-

ACM

-

1

-

Serial port device

-

ECM

-

2

-

Ethernet port device

-

HDC

-

4

-

HDC device

-
+| Name| Default Value| Description| +| -------- | -------- | -------- | +| USB\_REQUEST\_TYPE\_STANDARD | 0 | Request for writing data from the host to the device.
**System capability**: SystemCapability.USB.USBManager| +| USB\_REQUEST\_TYPE\_CLASS | 0x80 | Request for reading data from the device to the host.
**System capability**: SystemCapability.USB.USBManager| diff --git a/en/application-dev/reference/apis/js-apis-useriam-userauth.md b/en/application-dev/reference/apis/js-apis-useriam-userauth.md index 267445bbd619c466f4416e2647c6782e19c61465..1ce2456d568800cb8fe2cddd48d697e6acfd3d0e 100644 --- a/en/application-dev/reference/apis/js-apis-useriam-userauth.md +++ b/en/application-dev/reference/apis/js-apis-useriam-userauth.md @@ -10,6 +10,10 @@ import userIAM_userAuth from '@ohos.userIAM.userAuth'; ``` +## System Capabilities + +SystemCapability.UserIAM.UserAuth + ## Required Permissions ohos.permission.ACCESS\_BIOMETRIC diff --git a/en/application-dev/reference/apis/js-apis-volumemanager.md b/en/application-dev/reference/apis/js-apis-volumemanager.md new file mode 100644 index 0000000000000000000000000000000000000000..736d206d573b17b20d1cdd1bb4a1f6f80ee93c6b --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-volumemanager.md @@ -0,0 +1,168 @@ +# Volume Management + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```js +import volumemanager from "@ohos.volumemanager"; +``` + +## System Capabilities + +SystemCapability.FileManagement.StorageService.Volume + +## volumemanager.getAllVolumes + +getAllVolumes(): Promise<Volume[]> + +Asynchronously obtains information about all available volumes. This method uses a promise to return the result. + +- Return value + + | Type| Description| + | ---------------------------------- | -------------------------- | + | Promise<[Volume](#volume)[]> | Promise used to return the execution result.| + +- Example + + ```js + volumemanager.getAllVolumes().then(function(volumes){ + // do something + }); + ``` + +## volumemanager.getAllVolumes + +getAllVolumes(callback:AsyncCallback<Volume[]>):void + +Asynchronously obtains information about all available volumes. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------------------------------------------------- | ---- | ------------------------------------ | + | callback | callback:AsyncCallback<[Volume](#volume)[]> | Yes| Callback invoked to return the volume information obtained.| + +- Example + + ```js + let uuid = ""; + volumemanager.getAllVolumes(uuid, function(error, volumes){ + // do something + }); + ``` + + +## volumemanager.mount + +mount(volumeId: string): Promise<boolean> + +Asynchronously mounts a volume. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes| Volume ID.| + +- Return value + + | Type| Description| + | ---------------------- | ---------- | + | Promise<boolean> | Promise used to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.mount(volumeId).then(function(flag){ + // do something + }); + ``` + +## volumemanager.mount + +mount(volumeId: string, callback:AsyncCallback<boolean>):void + +Asynchronously mounts a volume. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | Yes| Volume ID.| + | callback | callback:AsyncCallback<boolean> | Yes| Callback invoked to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.mount(volumeId, function(error, flag){ + // do something + }); + ``` + +## volumemanager.unmount + +unmount(volumeId: string): Promise<boolean> + +Asynchronously unmounts a volume. This method uses a promise to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------ | ---- | ---- | + | volumeId | string | Yes| Volume ID.| + +- Return value + + | Type| Description| + | ---------------------- | ---------- | + | Promise<boolean> | Promise used to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.unmount(volumeId).then(function(flag){ + // do something + }); + ``` + +## volumemanager.unmount + +unmount(volumeId: string, callback:AsyncCallback<boolean>):void + +Asynchronously unmounts a volume. This method uses a callback to return the result. + +- Parameters + + | Name| Type| Mandatory| Description| + | -------- | ------------------------------------- | ---- | -------------------- | + | volumeId | string | Yes| Volume ID.| + | callback | callback:AsyncCallback<boolean> | Yes| Callback invoked to return the execution result.| + +- Example + + ```js + let volumeId = ""; + volumemanager.unmount(volumeId, function(error, flag){ + // do something + }); + ``` + +## Volume + +### Attributes + +| Name| Type| Description| +| ----------- | ------- | -------------------- | +| id | number | Volume ID.| +| uuid | string | Universally unique identifier (UUID) of the volume.| +| description | string | Description of the volume.| +| removeAble | boolean | Whether the volume is a removable storage device.| +| state | int | Current volume status.| +| path | string | Mount address of the volume.| diff --git a/en/application-dev/reference/apis/js-apis-webgl.md b/en/application-dev/reference/apis/js-apis-webgl.md index 8247029ffb23e8667c3625f364a96f58c316eb2e..da8d99f69cf791cf35f3e9bb3346ea8b1f96ca5e 100644 --- a/en/application-dev/reference/apis/js-apis-webgl.md +++ b/en/application-dev/reference/apis/js-apis-webgl.md @@ -1,696 +1,587 @@ -# WebGL +# webgl -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -This module provides WebGL APIs that correspond to the OpenGL ES 2.0 feature set. For more information, see [WebGL™](https://www.khronos.org/registry/webgl/specs/latest/1.0/). - - +This module provides WebGL APIs that correspond to the OpenGL ES 2.0 feature set. For more information, see [WebGL™](https://www.khronos.org/registry/webgl/specs/latest/2.0/). ## Modules to Import + ``` -import webgl from 'ohos.webglnapi' +import webgl from '@ohos.webglnapi'; ``` -## System Capabilities +## Invoking Method -SystemCapability.Graphic.Graphic2D.WebGL +Create a **<canvas>** component in the HML file. The following is an example: + +``` +
+ + +
+``` -## Invoking Method +Obtain the **<canvas>** component instance in the JS file. The following is an example: + ``` -// Obtain the component instance. -const el = this.$refs.canvas -// Obtain the WebGL context from the component instance. +// Obtain the component instance. +const el = this.$refs.canvas1; +// Obtain the WebGL context from the component instance. const gl = el.getContext('webgl'); // Call the WebGL API. gl.clearColor(0.0, 0.0, 0.0, 1.0); -gl.flush(); ``` -## GLenum - -| Name| Type| -| -------- | -------- | -| GLenum | number | - - -## GLboolean - -| Name| Type| -| -------- | -------- | -| GLboolean | boolean | - - -## GLbitfield - -| Name| Type| -| -------- | -------- | -| GLbitfield | number | - - -## GLbyte - -| Name| Type| -| -------- | -------- | -| GLbyte | number | - - -## GLshort - -| Name| Type| -| -------- | -------- | -| GLshort | number | - - -## GLint - -| Name| Type| -| -------- | -------- | -| GLint | number | - - -## GLsizei - -| Name| Type| -| -------- | -------- | -| GLsizei | number | - - -## GLintptr - -| Name| Type| -| -------- | -------- | -| GLintptr | number | - - -## GLsizeiptr - -| Name| Type| -| -------- | -------- | -| GLsizeiptr | number | - - -## GLubyte - -| Name| Type| -| -------- | -------- | -| GLubyte | number | - - -## GLushort - -| Name| Type| -| -------- | -------- | -| GLushort | number | - +## Type -## GLuint + **Table1** Type -| Name| Type| -| -------- | -------- | -| GLuint | number | - - -## GLfloat - -| Name| Type| -| -------- | -------- | -| GLfloat | number | - - -## GLclampf - -| Name| Type| -| -------- | -------- | -| GLclampf | number | - - -## TexImageSource - -| Name| Type| -| -------- | -------- | -| TexImageSource | ImageData | - - -## Float32List - -| Name| Type| -| -------- | -------- | -| Float32List | array | - - -## Int32List - -| Name| Type| -| -------- | -------- | -| Int32List | array | - - -## WebGLPowerPreference - -| Name| Type| +| Name | Type | Description | +| -------- | -------- | -------- | +| GLenum | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLboolean | boolean | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLbitfield | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLbyte | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLshort | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLint | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLsizei | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLintptr | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLsizeiptr | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLubyte | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLushort | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLuint | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLfloat | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| GLclampf | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| TexImageSource | ImageData | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| Float32List | array | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| Int32List | array | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLPowerPreference | string | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | + + +## Interface + + **Table2** Interface + +| Name | Description | | -------- | -------- | -| WebGLPowerPreference | string | - - -## webgl.WebGLContextAttributes +| [WebGLContextAttributes](#webglcontextattributes) | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLBuffer | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLFrameBuffer | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLProgram | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLRenderbuffer | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLShader | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLTexture | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLUniformLocation | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| [WebGLActiveInfo](#webglactiveinfo) | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| [WebGLShaderPrecisionFormat](#webglshaderprecisionformat) | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| [WebGLRenderingContextBase](#webglrenderingcontextbase) | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | +| [WebGLRenderingContextOverloads](#webglrenderingcontextoverloads) | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL | + + +## WebGLContextAttributes WebGLContextAttributes -| Name| Type| Mandatory| + | Name | Type | Mandatory | | -------- | -------- | -------- | -| alpha | boolean | No| -| depth | boolean | No| -| stencil | boolean | No| -| antialias | boolean | No| -| premultipliedAlpha | boolean | No| -| preserveDrawingBuffer | boolean | No| -| powerPreference | WebGLPowerPreference | No| -| failIfMajorPerformanceCaveat | boolean | No| -| desynchronized | boolean | No| - - -## webgl.WebGLBuffer - -WebGLBuffer - - -## webgl.WebGLFrameBuffer - -WebGLFrameBuffer - - -## webgl.WebGLProgram - -WebGLProgram - - -## webgl.WebGLRenderbuffer - -WebGLRenderbuffer - - -## webgl.WebGLShader - -WebGLShader - - -## webgl.WebGLTexture - -WebGLTexture - - -## webgl.WebGLUniformLocation - -WebGLUniformLocation +| alpha | boolean | No | +| depth | boolean | No | +| stencil | boolean | No | +| antialias | boolean | No | +| premultipliedAlpha | boolean | No | +| preserveDrawingBuffer | boolean | No | +| powerPreference | WebGLPowerPreference | No | +| failIfMajorPerformanceCaveat | boolean | No | +| desynchronized | boolean | No | -## webgl.WebGLActiveInfo +## WebGLActiveInfo WebGLActiveInfo -| Name| Type| Mandatory| + | Name | Type | Mandatory | | -------- | -------- | -------- | -| size | [GLint](#glint) | Yes| -| type | [GLenum](#glenum) | Yes| -| name | string | Yes| +| size | GLint | Yes | +| type | GLenum | Yes | +| name | string | Yes | -## webgl.WebGLShaderPrecisionFormat +## WebGLShaderPrecisionFormat WebGLShaderPrecisionFormat -| Name| Type| Mandatory| + | Name | Type | Mandatory | | -------- | -------- | -------- | -| rangeMin | [GLint](#glint) | Yes| -| rangeMax | [GLint](#glint) | Yes| -| precision | [GLint](#glint) | Yes| +| rangeMin | GLint | Yes | +| rangeMax | GLint | Yes | +| precision | GLint | Yes | -## webgl.WebGLRenderingContextBase +## WebGLRenderingContextBase WebGLRenderingContextBase ### Attributes -| Name| Type| Mandatory| + | Name | Type | Mandatory | | -------- | -------- | -------- | -| DEPTH_BUFFER_BIT | [GLenum](#glenum) | Yes| -| STENCIL_BUFFER_BIT | [GLenum](#glenum) | Yes| -| COLOR_BUFFER_BIT | [GLenum](#glenum) | Yes| -| POINTS | [GLenum](#glenum) | Yes| -| LINES | [GLenum](#glenum) | Yes| -| LINE_LOOP | [GLenum](#glenum) | Yes| -| LINE_STRIP | [GLenum](#glenum) | Yes| -| TRIANGLES | [GLenum](#glenum) | Yes| -| TRIANGLE_STRIP | [GLenum](#glenum) | Yes| -| TRIANGLE_FAN | [GLenum](#glenum) | Yes| -| ZERO | [GLenum](#glenum) | Yes| -| ONE | [GLenum](#glenum) | Yes| -| SRC_COLOR | [GLenum](#glenum) | Yes| -| ONE_MINUS_SRC_COLOR | [GLenum](#glenum) | Yes| -| SRC_ALPHA | [GLenum](#glenum) | Yes| -| ONE_MINUS_SRC_ALPHA | [GLenum](#glenum) | Yes| -| DST_ALPHA | [GLenum](#glenum) | Yes| -| ONE_MINUS_DST_ALPHA | [GLenum](#glenum) | Yes| -| DST_COLOR | [GLenum](#glenum) | Yes| -| ONE_MINUS_DST_COLOR | [GLenum](#glenum) | Yes| -| SRC_ALPHA_SATURATE | [GLenum](#glenum) | Yes| -| FUNC_ADD | [GLenum](#glenum) | Yes| -| BLEND_EQUATION | [GLenum](#glenum) | Yes| -| BLEND_EQUATION_RGB | [GLenum](#glenum) | Yes| -| BLEND_EQUATION_ALPHA | [GLenum](#glenum) | Yes| -| FUNC_SUBTRACT | [GLenum](#glenum) | Yes| -| FUNC_REVERSE_SUBTRACT | [GLenum](#glenum) | Yes| -| BLEND_DST_RGB | [GLenum](#glenum) | Yes| -| BLEND_SRC_RGB | [GLenum](#glenum) | Yes| -| BLEND_DST_ALPHA | [GLenum](#glenum) | Yes| -| BLEND_SRC_ALPHA | [GLenum](#glenum) | Yes| -| CONSTANT_COLOR | [GLenum](#glenum) | Yes| -| ONE_MINUS_CONSTANT_COLOR | [GLenum](#glenum) | Yes| -| CONSTANT_ALPHA | [GLenum](#glenum) | Yes| -| ONE_MINUS_CONSTANT_ALPHA | [GLenum](#glenum) | Yes| -| BLEND_COLOR | [GLenum](#glenum) | Yes| -| ARRAY_BUFFER | [GLenum](#glenum) | Yes| -| ELEMENT_ARRAY_BUFFER | [GLenum](#glenum) | Yes| -| ARRAY_BUFFER_BINDING | [GLenum](#glenum) | Yes| -| ELEMENT_ARRAY_BUFFER_BINDING | [GLenum](#glenum) | Yes| -| STREAM_DRAW | [GLenum](#glenum) | Yes| -| STATIC_DRAW | [GLenum](#glenum) | Yes| -| DYNAMIC_DRAW | [GLenum](#glenum) | Yes| -| BUFFER_SIZE | [GLenum](#glenum) | Yes| -| BUFFER_USAGE | [GLenum](#glenum) | Yes| -| CURRENT_VERTEX_ATTRIB | [GLenum](#glenum) | Yes| -| FRONT | [GLenum](#glenum) | Yes| -| BACK | [GLenum](#glenum) | Yes| -| FRONT_AND_BACK | [GLenum](#glenum) | Yes| -| CULL_FACE | [GLenum](#glenum) | Yes| -| BLEND | [GLenum](#glenum) | Yes| -| DITHER | [GLenum](#glenum) | Yes| -| STENCIL_TEST | [GLenum](#glenum) | Yes| -| DEPTH_TEST | [GLenum](#glenum) | Yes| -| SCISSOR_TEST | [GLenum](#glenum) | Yes| -| POLYGON_OFFSET_FILL | [GLenum](#glenum) | Yes| -| SAMPLE_ALPHA_TO_COVERAGE | [GLenum](#glenum) | Yes| -| SAMPLE_COVERAGE | [GLenum](#glenum) | Yes| -| NO_ERROR | [GLenum](#glenum) | Yes| -| INVALID_ENUM | [GLenum](#glenum) | Yes| -| INVALID_VALUE | [GLenum](#glenum) | Yes| -| INVALID_OPERATION | [GLenum](#glenum) | Yes| -| OUT_OF_MEMORY | [GLenum](#glenum) | Yes| -| CW | [GLenum](#glenum) | Yes| -| CCW | [GLenum](#glenum) | Yes| -| ALIASED_POINT_SIZE_RANGE | [GLenum](#glenum) | Yes| -| ALIASED_LINE_WIDTH_RANGE | [GLenum](#glenum) | Yes| -| CULL_FACE_MODE | [GLenum](#glenum) | Yes| -| FRONT_FACE | [GLenum](#glenum) | Yes| -| DEPTH_RANGE | [GLenum](#glenum) | Yes| -| DEPTH_WRITEMASK | [GLenum](#glenum) | Yes| -| DEPTH_CLEAR_VALUE | [GLenum](#glenum) | Yes| -| DEPTH_FUNC | [GLenum](#glenum) | Yes| -| STENCIL_CLEAR_VALUE | [GLenum](#glenum) | Yes| -| STENCIL_FUNC | [GLenum](#glenum) | Yes| -| STENCIL_FAIL | [GLenum](#glenum) | Yes| -| STENCIL_PASS_DEPTH_FAIL | [GLenum](#glenum) | Yes| -| STENCIL_PASS_DEPTH_PASS | [GLenum](#glenum) | Yes| -| STENCIL_REF | [GLenum](#glenum) | Yes| -| STENCIL_VALUE_MASK | [GLenum](#glenum) | Yes| -| STENCIL_WRITEMASK | [GLenum](#glenum) | Yes| -| STENCIL_BACK_FUNC | [GLenum](#glenum) | Yes| -| STENCIL_BACK_FAIL | [GLenum](#glenum) | Yes| -| STENCIL_BACK_PASS_DEPTH_FAIL | [GLenum](#glenum) | Yes| -| STENCIL_BACK_PASS_DEPTH_PASS | [GLenum](#glenum) | Yes| -| STENCIL_BACK_REF | [GLenum](#glenum) | Yes| -| STENCIL_BACK_VALUE_MASK | [GLenum](#glenum) | Yes| -| STENCIL_BACK_WRITEMASK | [GLenum](#glenum) | Yes| -| VIEWPORT | [GLenum](#glenum) | Yes| -| SCISSOR_BOX | [GLenum](#glenum) | Yes| -| COLOR_CLEAR_VALUE | [GLenum](#glenum) | Yes| -| COLOR_WRITEMASK | [GLenum](#glenum) | Yes| -| UNPACK_ALIGNMENT | [GLenum](#glenum) | Yes| -| PACK_ALIGNMENT | [GLenum](#glenum) | Yes| -| MAX_TEXTURE_SIZE | [GLenum](#glenum) | Yes| -| MAX_VIEWPORT_DIMS | [GLenum](#glenum) | Yes| -| SUBPIXEL_BITS | [GLenum](#glenum) | Yes| -| RED_BITS | [GLenum](#glenum) | Yes| -| GREEN_BITS | [GLenum](#glenum) | Yes| -| BLUE_BITS | [GLenum](#glenum) | Yes| -| ALPHA_BITS | [GLenum](#glenum) | Yes| -| DEPTH_BITS | [GLenum](#glenum) | Yes| -| STENCIL_BITS | [GLenum](#glenum) | Yes| -| POLYGON_OFFSET_UNITS | [GLenum](#glenum) | Yes| -| POLYGON_OFFSET_FACTOR | [GLenum](#glenum) | Yes| -| TEXTURE_BINDING_2D | [GLenum](#glenum) | Yes| -| SAMPLE_BUFFERS | [GLenum](#glenum) | Yes| -| SAMPLES | [GLenum](#glenum) | Yes| -| SAMPLE_COVERAGE_VALUE | [GLenum](#glenum) | Yes| -| SAMPLE_COVERAGE_INVERT | [GLenum](#glenum) | Yes| -| COMPRESSED_TEXTURE_FORMATS | [GLenum](#glenum) | Yes| -| DONT_CARE | [GLenum](#glenum) | Yes| -| FASTEST | [GLenum](#glenum) | Yes| -| NICEST | [GLenum](#glenum) | Yes| -| GENERATE_MIPMAP_HINT | [GLenum](#glenum) | Yes| -| BYTE | [GLenum](#glenum) | Yes| -| UNSIGNED_BYTE | [GLenum](#glenum) | Yes| -| SHORT | [GLenum](#glenum) | Yes| -| UNSIGNED_SHORT | [GLenum](#glenum) | Yes| -| INT | [GLenum](#glenum) | Yes| -| UNSIGNED_INT | [GLenum](#glenum) | Yes| -| FLOAT | [GLenum](#glenum) | Yes| -| DEPTH_COMPONENT | [GLenum](#glenum) | Yes| -| ALPHA | [GLenum](#glenum) | Yes| -| RGB | [GLenum](#glenum) | Yes| -| RGBA | [GLenum](#glenum) | Yes| -| LUMINANCE | [GLenum](#glenum) | Yes| -| LUMINANCE_ALPHA | [GLenum](#glenum) | Yes| -| UNSIGNED_SHORT_4_4_4_4 | [GLenum](#glenum) | Yes| -| UNSIGNED_SHORT_5_5_5_1 | [GLenum](#glenum) | Yes| -| UNSIGNED_SHORT_5_6_5 | [GLenum](#glenum) | Yes| -| FRAGMENT_SHADER | [GLenum](#glenum) | Yes| -| VERTEX_SHADER | [GLenum](#glenum) | Yes| -| MAX_VERTEX_ATTRIBS | [GLenum](#glenum) | Yes| -| MAX_VERTEX_UNIFORM_VECTORS | [GLenum](#glenum) | Yes| -| MAX_VARYING_VECTORS | [GLenum](#glenum) | Yes| -| MAX_COMBINED_TEXTURE_IMAGE_UNITS | [GLenum](#glenum) | Yes| -| MAX_VERTEX_TEXTURE_IMAGE_UNITS | [GLenum](#glenum) | Yes| -| MAX_TEXTURE_IMAGE_UNITS | [GLenum](#glenum) | Yes| -| MAX_FRAGMENT_UNIFORM_VECTORS | [GLenum](#glenum) | Yes| -| SHADER_TYPE | [GLenum](#glenum) | Yes| -| DELETE_STATUS | [GLenum](#glenum) | Yes| -| LINK_STATUS | [GLenum](#glenum) | Yes| -| VALIDATE_STATUS | [GLenum](#glenum) | Yes| -| ATTACHED_SHADERS | [GLenum](#glenum) | Yes| -| ACTIVE_UNIFORMS | [GLenum](#glenum) | Yes| -| ACTIVE_ATTRIBUTES | [GLenum](#glenum) | Yes| -| SHADING_LANGUAGE_VERSION | [GLenum](#glenum) | Yes| -| CURRENT_PROGRAM | [GLenum](#glenum) | Yes| -| NEVER | [GLenum](#glenum) | Yes| -| LESS | [GLenum](#glenum) | Yes| -| EQUAL | [GLenum](#glenum) | Yes| -| LEQUAL | [GLenum](#glenum) | Yes| -| GREATER | [GLenum](#glenum) | Yes| -| NOTEQUAL | [GLenum](#glenum) | Yes| -| GEQUAL | [GLenum](#glenum) | Yes| -| ALWAYS | [GLenum](#glenum) | Yes| -| KEEP | [GLenum](#glenum) | Yes| -| REPLACE | [GLenum](#glenum) | Yes| -| INCR | [GLenum](#glenum) | Yes| -| DECR | [GLenum](#glenum) | Yes| -| INVERT | [GLenum](#glenum) | Yes| -| INCR_WRAP | [GLenum](#glenum) | Yes| -| DECR_WRAP | [GLenum](#glenum) | Yes| -| VENDOR | [GLenum](#glenum) | Yes| -| RENDERER | [GLenum](#glenum) | Yes| -| VERSION | [GLenum](#glenum) | Yes| -| NEAREST | [GLenum](#glenum) | Yes| -| LINEAR | [GLenum](#glenum) | Yes| -| NEAREST_MIPMAP_NEAREST | [GLenum](#glenum) | Yes| -| LINEAR_MIPMAP_NEAREST | [GLenum](#glenum) | Yes| -| NEAREST_MIPMAP_LINEAR | [GLenum](#glenum) | Yes| -| LINEAR_MIPMAP_LINEAR | [GLenum](#glenum) | Yes| -| TEXTURE_MAG_FILTER | [GLenum](#glenum) | Yes| -| TEXTURE_MIN_FILTER | [GLenum](#glenum) | Yes| -| TEXTURE_WRAP_S | [GLenum](#glenum) | Yes| -| TEXTURE_WRAP_T | [GLenum](#glenum) | Yes| -| TEXTURE_2D | [GLenum](#glenum) | Yes| -| TEXTURE | [GLenum](#glenum) | Yes| -| TEXTURE_CUBE_MAP | [GLenum](#glenum) | Yes| -| TEXTURE_BINDING_CUBE_MAP | [GLenum](#glenum) | Yes| -| TEXTURE_CUBE_MAP_POSITIVE_X | [GLenum](#glenum) | Yes| -| TEXTURE_CUBE_MAP_NEGATIVE_X | [GLenum](#glenum) | Yes| -| TEXTURE_CUBE_MAP_POSITIVE_Y | [GLenum](#glenum) | Yes| -| TEXTURE_CUBE_MAP_NEGATIVE_Y | [GLenum](#glenum) | Yes| -| TEXTURE_CUBE_MAP_POSITIVE_Z | [GLenum](#glenum) | Yes| -| TEXTURE_CUBE_MAP_NEGATIVE_Z | [GLenum](#glenum) | Yes| -| TEXTURE0 | [GLenum](#glenum) | Yes| -| TEXTURE1 | [GLenum](#glenum) | Yes| -| TEXTURE2 | [GLenum](#glenum) | Yes| -| TEXTURE3 | [GLenum](#glenum) | Yes| -| TEXTURE4 | [GLenum](#glenum) | Yes| -| TEXTURE5 | [GLenum](#glenum) | Yes| -| TEXTURE6 | [GLenum](#glenum) | Yes| -| TEXTURE7 | [GLenum](#glenum) | Yes| -| TEXTURE8 | [GLenum](#glenum) | Yes| -| TEXTURE9 | [GLenum](#glenum) | Yes| -| TEXTURE10 | [GLenum](#glenum) | Yes| -| TEXTURE11 | [GLenum](#glenum) | Yes| -| TEXTURE12 | [GLenum](#glenum) | Yes| -| TEXTURE13 | [GLenum](#glenum) | Yes| -| TEXTURE14 | [GLenum](#glenum) | Yes| -| TEXTURE15 | [GLenum](#glenum) | Yes| -| TEXTURE16 | [GLenum](#glenum) | Yes| -| TEXTURE17 | [GLenum](#glenum) | Yes| -| TEXTURE18 | [GLenum](#glenum) | Yes| -| TEXTURE19 | [GLenum](#glenum) | Yes| -| TEXTURE20 | [GLenum](#glenum) | Yes| -| TEXTURE21 | [GLenum](#glenum) | Yes| -| TEXTURE22 | [GLenum](#glenum) | Yes| -| TEXTURE23 | [GLenum](#glenum) | Yes| -| TEXTURE24 | [GLenum](#glenum) | Yes| -| TEXTURE25 | [GLenum](#glenum) | Yes| -| TEXTURE26 | [GLenum](#glenum) | Yes| -| TEXTURE27 | [GLenum](#glenum) | Yes| -| TEXTURE28 | [GLenum](#glenum) | Yes| -| TEXTURE29 | [GLenum](#glenum) | Yes| -| TEXTURE30 | [GLenum](#glenum) | Yes| -| TEXTURE31 | [GLenum](#glenum) | Yes| -| ACTIVE_TEXTURE | [GLenum](#glenum) | Yes| -| REPEAT | [GLenum](#glenum) | Yes| -| CLAMP_TO_EDGE | [GLenum](#glenum) | Yes| -| MIRRORED_REPEAT | [GLenum](#glenum) | Yes| -| FLOAT_VEC2 | [GLenum](#glenum) | Yes| -| FLOAT_VEC3 | [GLenum](#glenum) | Yes| -| FLOAT_VEC4 | [GLenum](#glenum) | Yes| -| INT_VEC2 | [GLenum](#glenum) | Yes| -| INT_VEC3 | [GLenum](#glenum) | Yes| -| INT_VEC4 | [GLenum](#glenum) | Yes| -| BOOL | [GLenum](#glenum) | Yes| -| BOOL_VEC2 | [GLenum](#glenum) | Yes| -| BOOL_VEC3 | [GLenum](#glenum) | Yes| -| BOOL_VEC4 | [GLenum](#glenum) | Yes| -| FLOAT_MAT2 | [GLenum](#glenum) | Yes| -| FLOAT_MAT3 | [GLenum](#glenum) | Yes| -| FLOAT_MAT4 | [GLenum](#glenum) | Yes| -| SAMPLER_2D | [GLenum](#glenum) | Yes| -| SAMPLER_CUBE | [GLenum](#glenum) | Yes| -| VERTEX_ATTRIB_ARRAY_ENABLED | [GLenum](#glenum) | Yes| -| VERTEX_ATTRIB_ARRAY_SIZE | [GLenum](#glenum) | Yes| -| VERTEX_ATTRIB_ARRAY_STRIDE | [GLenum](#glenum) | Yes| -| VERTEX_ATTRIB_ARRAY_TYPE | [GLenum](#glenum) | Yes| -| VERTEX_ATTRIB_ARRAY_NORMALIZED | [GLenum](#glenum) | Yes| -| VERTEX_ATTRIB_ARRAY_POINTER | [GLenum](#glenum) | Yes| -| VERTEX_ATTRIB_ARRAY_BUFFER_BINDING | [GLenum](#glenum) | Yes| -| IMPLEMENTATION_COLOR_READ_TYPE | [GLenum](#glenum) | Yes| -| IMPLEMENTATION_COLOR_READ_FORMAT | [GLenum](#glenum) | Yes| -| COMPILE_STATUS | [GLenum](#glenum) | Yes| -| LOW_FLOAT | [GLenum](#glenum) | Yes| -| MEDIUM_FLOAT | [GLenum](#glenum) | Yes| -| HIGH_FLOAT | [GLenum](#glenum) | Yes| -| LOW_INT | [GLenum](#glenum) | Yes| -| MEDIUM_INT | [GLenum](#glenum) | Yes| -| HIGH_INT | [GLenum](#glenum) | Yes| -| FRAMEBUFFER | [GLenum](#glenum) | Yes| -| RENDERBUFFER | [GLenum](#glenum) | Yes| -| RGBA4 | [GLenum](#glenum) | Yes| -| RGB5_A1 | [GLenum](#glenum) | Yes| -| RGB565 | [GLenum](#glenum) | Yes| -| DEPTH_COMPONENT16 | [GLenum](#glenum) | Yes| -| STENCIL_INDEX8 | [GLenum](#glenum) | Yes| -| DEPTH_STENCIL | [GLenum](#glenum) | Yes| -| RENDERBUFFER_WIDTH | [GLenum](#glenum) | Yes| -| RENDERBUFFER_HEIGHT | [GLenum](#glenum) | Yes| -| RENDERBUFFER_INTERNAL_FORMAT | [GLenum](#glenum) | Yes| -| RENDERBUFFER_RED_SIZE | [GLenum](#glenum) | Yes| -| RENDERBUFFER_GREEN_SIZE | [GLenum](#glenum) | Yes| -| RENDERBUFFER_BLUE_SIZE | [GLenum](#glenum) | Yes| -| RENDERBUFFER_ALPHA_SIZE | [GLenum](#glenum) | Yes| -| RENDERBUFFER_DEPTH_SIZE | [GLenum](#glenum) | Yes| -| RENDERBUFFER_STENCIL_SIZE | [GLenum](#glenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE | [GLenum](#glenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_OBJECT_NAME | [GLenum](#glenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL | [GLenum](#glenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE | [GLenum](#glenum) | Yes| -| COLOR_ATTACHMENT0 | [GLenum](#glenum) | Yes| -| DEPTH_ATTACHMENT | [GLenum](#glenum) | Yes| -| STENCIL_ATTACHMENT | [GLenum](#glenum) | Yes| -| DEPTH_STENCIL_ATTACHMENT | [GLenum](#glenum) | Yes| -| NONE | [GLenum](#glenum) | Yes| -| FRAMEBUFFER_COMPLETE | [GLenum](#glenum) | Yes| -| FRAMEBUFFER_INCOMPLETE_ATTACHMENT | [GLenum](#glenum) | Yes| -| FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT | [GLenum](#glenum) | Yes| -| FRAMEBUFFER_INCOMPLETE_DIMENSIONS | [GLenum](#glenum) | Yes| -| FRAMEBUFFER_UNSUPPORTED | [GLenum](#glenum) | Yes| -| FRAMEBUFFER_BINDING | [GLenum](#glenum) | Yes| -| RENDERBUFFER_BINDING | [GLenum](#glenum) | Yes| -| MAX_RENDERBUFFER_SIZE | [GLenum](#glenum) | Yes| -| INVALID_FRAMEBUFFER_OPERATION | [GLenum](#glenum) | Yes| -| UNPACK_FLIP_Y_WEBGL | [GLenum](#glenum) | Yes| -| UNPACK_PREMULTIPLY_ALPHA_WEBGL | [GLenum](#glenum) | Yes| -| CONTEXT_LOST_WEBGL | [GLenum](#glenum) | Yes| -| UNPACK_COLORSPACE_CONVERSION_WEBGL | [GLenum](#glenum) | Yes| -| BROWSER_DEFAULT_WEBGL | [GLenum](#glenum) | Yes| -| canvas | HTMLCanvasElement \| OffscreenCanvas | Yes| -| drawingBufferWidth | [GLsizei](#glsizei) | Yes| -| drawingBufferHeight | [GLsizei](#glsizei) | Yes| +| DEPTH_BUFFER_BIT | GLenum | Yes | +| STENCIL_BUFFER_BIT | GLenum | Yes | +| COLOR_BUFFER_BIT | GLenum | Yes | +| POINTS | GLenum | Yes | +| LINES | GLenum | Yes | +| LINE_LOOP | GLenum | Yes | +| LINE_STRIP | GLenum | Yes | +| TRIANGLES | GLenum | Yes | +| TRIANGLE_STRIP | GLenum | Yes | +| TRIANGLE_FAN | GLenum | Yes | +| ZERO | GLenum | Yes | +| ONE | GLenum | Yes | +| SRC_COLOR | GLenum | Yes | +| ONE_MINUS_SRC_COLOR | GLenum | Yes | +| SRC_ALPHA | GLenum | Yes | +| ONE_MINUS_SRC_ALPHA | GLenum | Yes | +| DST_ALPHA | GLenum | Yes | +| ONE_MINUS_DST_ALPHA | GLenum | Yes | +| DST_COLOR | GLenum | Yes | +| ONE_MINUS_DST_COLOR | GLenum | Yes | +| SRC_ALPHA_SATURATE | GLenum | Yes | +| FUNC_ADD | GLenum | Yes | +| BLEND_EQUATION | GLenum | Yes | +| BLEND_EQUATION_RGB | GLenum | Yes | +| BLEND_EQUATION_ALPHA | GLenum | Yes | +| FUNC_SUBTRACT | GLenum | Yes | +| FUNC_REVERSE_SUBTRACT | GLenum | Yes | +| BLEND_DST_RGB | GLenum | Yes | +| BLEND_SRC_RGB | GLenum | Yes | +| BLEND_DST_ALPHA | GLenum | Yes | +| BLEND_SRC_ALPHA | GLenum | Yes | +| CONSTANT_COLOR | GLenum | Yes | +| ONE_MINUS_CONSTANT_COLOR | GLenum | Yes | +| CONSTANT_ALPHA | GLenum | Yes | +| ONE_MINUS_CONSTANT_ALPHA | GLenum | Yes | +| BLEND_COLOR | GLenum | Yes | +| ARRAY_BUFFER | GLenum | Yes | +| ELEMENT_ARRAY_BUFFER | GLenum | Yes | +| ARRAY_BUFFER_BINDING | GLenum | Yes | +| ELEMENT_ARRAY_BUFFER_BINDING | GLenum | Yes | +| STREAM_DRAW | GLenum | Yes | +| STATIC_DRAW | GLenum | Yes | +| DYNAMIC_DRAW | GLenum | Yes | +| BUFFER_SIZE | GLenum | Yes | +| BUFFER_USAGE | GLenum | Yes | +| CURRENT_VERTEX_ATTRIB | GLenum | Yes | +| FRONT | GLenum | Yes | +| BACK | GLenum | Yes | +| FRONT_AND_BACK | GLenum | Yes | +| CULL_FACE | GLenum | Yes | +| BLEND | GLenum | Yes | +| DITHER | GLenum | Yes | +| STENCIL_TEST | GLenum | Yes | +| DEPTH_TEST | GLenum | Yes | +| SCISSOR_TEST | GLenum | Yes | +| POLYGON_OFFSET_FILL | GLenum | Yes | +| SAMPLE_ALPHA_TO_COVERAGE | GLenum | Yes | +| SAMPLE_COVERAGE | GLenum | Yes | +| NO_ERROR | GLenum | Yes | +| INVALID_ENUM | GLenum | Yes | +| INVALID_VALUE | GLenum | Yes | +| INVALID_OPERATION | GLenum | Yes | +| OUT_OF_MEMORY | GLenum | Yes | +| CW | GLenum | Yes | +| CCW | GLenum | Yes | +| LINE_WIDTH | GLenum | Yes | +| ALIASED_POINT_SIZE_RANGE | GLenum | Yes | +| ALIASED_LINE_WIDTH_RANGE | GLenum | Yes | +| CULL_FACE_MODE | GLenum | Yes | +| FRONT_FACE | GLenum | Yes | +| DEPTH_RANGE | GLenum | Yes | +| DEPTH_WRITEMASK | GLenum | Yes | +| DEPTH_CLEAR_VALUE | GLenum | Yes | +| DEPTH_FUNC | GLenum | Yes | +| STENCIL_CLEAR_VALUE | GLenum | Yes | +| STENCIL_FUNC | GLenum | Yes | +| STENCIL_FAIL | GLenum | Yes | +| STENCIL_PASS_DEPTH_FAIL | GLenum | Yes | +| STENCIL_PASS_DEPTH_PASS | GLenum | Yes | +| STENCIL_REF | GLenum | Yes | +| STENCIL_VALUE_MASK | GLenum | Yes | +| STENCIL_WRITEMASK | GLenum | Yes | +| STENCIL_BACK_FUNC | GLenum | Yes | +| STENCIL_BACK_FAIL | GLenum | Yes | +| STENCIL_BACK_PASS_DEPTH_FAIL | GLenum | Yes | +| STENCIL_BACK_PASS_DEPTH_PASS | GLenum | Yes | +| STENCIL_BACK_REF | GLenum | Yes | +| STENCIL_BACK_VALUE_MASK | GLenum | Yes | +| STENCIL_BACK_WRITEMASK | GLenum | Yes | +| VIEWPORT | GLenum | Yes | +| SCISSOR_BOX | GLenum | Yes | +| COLOR_CLEAR_VALUE | GLenum | Yes | +| COLOR_WRITEMASK | GLenum | Yes | +| UNPACK_ALIGNMENT | GLenum | Yes | +| PACK_ALIGNMENT | GLenum | Yes | +| MAX_TEXTURE_SIZE | GLenum | Yes | +| MAX_VIEWPORT_DIMS | GLenum | Yes | +| SUBPIXEL_BITS | GLenum | Yes | +| RED_BITS | GLenum | Yes | +| GREEN_BITS | GLenum | Yes | +| BLUE_BITS | GLenum | Yes | +| ALPHA_BITS | GLenum | Yes | +| DEPTH_BITS | GLenum | Yes | +| STENCIL_BITS | GLenum | Yes | +| POLYGON_OFFSET_UNITS | GLenum | Yes | +| POLYGON_OFFSET_FACTOR | GLenum | Yes | +| TEXTURE_BINDING_2D | GLenum | Yes | +| SAMPLE_BUFFERS | GLenum | Yes | +| SAMPLES | GLenum | Yes | +| SAMPLE_COVERAGE_VALUE | GLenum | Yes | +| SAMPLE_COVERAGE_INVERT | GLenum | Yes | +| COMPRESSED_TEXTURE_FORMATS | GLenum | Yes | +| DONT_CARE | GLenum | Yes | +| FASTEST | GLenum | Yes | +| NICEST | GLenum | Yes | +| GENERATE_MIPMAP_HINT | GLenum | Yes | +| BYTE | GLenum | Yes | +| UNSIGNED_BYTE | GLenum | Yes | +| SHORT | GLenum | Yes | +| UNSIGNED_SHORT | GLenum | Yes | +| INT | GLenum | Yes | +| UNSIGNED_INT | GLenum | Yes | +| FLOAT | GLenum | Yes | +| DEPTH_COMPONENT | GLenum | Yes | +| ALPHA | GLenum | Yes | +| RGB | GLenum | Yes | +| RGBA | GLenum | Yes | +| LUMINANCE | GLenum | Yes | +| LUMINANCE_ALPHA | GLenum | Yes | +| UNSIGNED_SHORT_4_4_4_4 | GLenum | Yes | +| UNSIGNED_SHORT_5_5_5_1 | GLenum | Yes | +| UNSIGNED_SHORT_5_6_5 | GLenum | Yes | +| FRAGMENT_SHADER | GLenum | Yes | +| VERTEX_SHADER | GLenum | Yes | +| MAX_VERTEX_ATTRIBS | GLenum | Yes | +| MAX_VERTEX_UNIFORM_VECTORS | GLenum | Yes | +| MAX_VARYING_VECTORS | GLenum | Yes | +| MAX_COMBINED_TEXTURE_IMAGE_UNITS | GLenum | Yes | +| MAX_VERTEX_TEXTURE_IMAGE_UNITS | GLenum | Yes | +| MAX_TEXTURE_IMAGE_UNITS | GLenum | Yes | +| MAX_FRAGMENT_UNIFORM_VECTORS | GLenum | Yes | +| SHADER_TYPE | GLenum | Yes | +| DELETE_STATUS | GLenum | Yes | +| LINK_STATUS | GLenum | Yes | +| VALIDATE_STATUS | GLenum | Yes | +| ATTACHED_SHADERS | GLenum | Yes | +| ACTIVE_UNIFORMS | GLenum | Yes | +| ACTIVE_ATTRIBUTES | GLenum | Yes | +| SHADING_LANGUAGE_VERSION | GLenum | Yes | +| CURRENT_PROGRAM | GLenum | Yes | +| NEVER | GLenum | Yes | +| LESS | GLenum | Yes | +| EQUAL | GLenum | Yes | +| LEQUAL | GLenum | Yes | +| GREATER | GLenum | Yes | +| NOTEQUAL | GLenum | Yes | +| GEQUAL | GLenum | Yes | +| ALWAYS | GLenum | Yes | +| KEEP | GLenum | Yes | +| REPLACE | GLenum | Yes | +| INCR | GLenum | Yes | +| DECR | GLenum | Yes | +| INVERT | GLenum | Yes | +| INCR_WRAP | GLenum | Yes | +| DECR_WRAP | GLenum | Yes | +| VENDOR | GLenum | Yes | +| RENDERER | GLenum | Yes | +| VERSION | GLenum | Yes | +| NEAREST | GLenum | Yes | +| LINEAR | GLenum | Yes | +| NEAREST_MIPMAP_NEAREST | GLenum | Yes | +| LINEAR_MIPMAP_NEAREST | GLenum | Yes | +| NEAREST_MIPMAP_LINEAR | GLenum | Yes | +| LINEAR_MIPMAP_LINEAR | GLenum | Yes | +| TEXTURE_MIN_FILTER | GLenum | Yes | +| TEXTURE_WRAP_S | GLenum | Yes | +| TEXTURE_WRAP_T | GLenum | Yes | +| TEXTURE_2D | GLenum | Yes | +| TEXTURE | GLenum | Yes | +| TEXTURE_CUBE_MAP | GLenum | Yes | +| TEXTURE_BINDING_CUBE_MAP | GLenum | Yes | +| TEXTURE_CUBE_MAP_POSITIVE_X | GLenum | Yes | +| TEXTURE_CUBE_MAP_NEGATIVE_X | GLenum | Yes | +| TEXTURE_CUBE_MAP_POSITIVE_Y | GLenum | Yes | +| TEXTURE_CUBE_MAP_NEGATIVE_Y | GLenum | Yes | +| TEXTURE_CUBE_MAP_POSITIVE_Z | GLenum | Yes | +| TEXTURE_CUBE_MAP_NEGATIVE_Z | GLenum | Yes | +| MAX_CUBE_MAP_TEXTURE_SIZE | GLenum | Yes | +| TEXTURE0 | GLenum | Yes | +| TEXTURE1 | GLenum | Yes | +| TEXTURE2 | GLenum | Yes | +| TEXTURE3 | GLenum | Yes | +| TEXTURE4 | GLenum | Yes | +| TEXTURE5 | GLenum | Yes | +| TEXTURE6 | GLenum | Yes | +| TEXTURE7 | GLenum | Yes | +| TEXTURE8 | GLenum | Yes | +| TEXTURE9 | GLenum | Yes | +| TEXTURE10 | GLenum | Yes | +| TEXTURE11 | GLenum | Yes | +| TEXTURE12 | GLenum | Yes | +| TEXTURE13 | GLenum | Yes | +| TEXTURE14 | GLenum | Yes | +| TEXTURE15 | GLenum | Yes | +| TEXTURE16 | GLenum | Yes | +| TEXTURE17 | GLenum | Yes | +| TEXTURE18 | GLenum | Yes | +| TEXTURE19 | GLenum | Yes | +| TEXTURE20 | GLenum | Yes | +| TEXTURE21 | GLenum | Yes | +| TEXTURE22 | GLenum | Yes | +| TEXTURE23 | GLenum | Yes | +| TEXTURE24 | GLenum | Yes | +| TEXTURE25 | GLenum | Yes | +| TEXTURE26 | GLenum | Yes | +| TEXTURE27 | GLenum | Yes | +| TEXTURE28 | GLenum | Yes | +| TEXTURE29 | GLenum | Yes | +| TEXTURE30 | GLenum | Yes | +| TEXTURE31 | GLenum | Yes | +| ACTIVE_TEXTURE | GLenum | Yes | +| REPEAT | GLenum | Yes | +| CLAMP_TO_EDGE | GLenum | Yes | +| MIRRORED_REPEAT | GLenum | Yes | +| FLOAT_VEC2 | GLenum | Yes | +| FLOAT_VEC3 | GLenum | Yes | +| FLOAT_VEC4 | GLenum | Yes | +| INT_VEC2 | GLenum | Yes | +| INT_VEC3 | GLenum | Yes | +| INT_VEC4 | GLenum | Yes | +| BOOL | GLenum | Yes | +| BOOL_VEC2 | GLenum | Yes | +| BOOL_VEC3 | GLenum | Yes | +| BOOL_VEC4 | GLenum | Yes | +| FLOAT_MAT2 | GLenum | Yes | +| FLOAT_MAT3 | GLenum | Yes | +| FLOAT_MAT4 | GLenum | Yes | +| SAMPLER_2D | GLenum | Yes | +| SAMPLER_CUBE | GLenum | Yes | +| VERTEX_ATTRIB_ARRAY_ENABLED | GLenum | Yes | +| VERTEX_ATTRIB_ARRAY_SIZE | GLenum | Yes | +| VERTEX_ATTRIB_ARRAY_STRIDE | GLenum | Yes | +| VERTEX_ATTRIB_ARRAY_TYPE | GLenum | Yes | +| VERTEX_ATTRIB_ARRAY_NORMALIZED | GLenum | Yes | +| VERTEX_ATTRIB_ARRAY_POINTER | GLenum | Yes | +| VERTEX_ATTRIB_ARRAY_BUFFER_BINDING | GLenum | Yes | +| IMPLEMENTATION_COLOR_READ_TYPE | GLenum | Yes | +| IMPLEMENTATION_COLOR_READ_FORMAT | GLenum | Yes | +| COMPILE_STATUS | GLenum | Yes | +| LOW_FLOAT | GLenum | Yes | +| MEDIUM_FLOAT | GLenum | Yes | +| HIGH_FLOAT | GLenum | Yes | +| LOW_INT | GLenum | Yes | +| MEDIUM_INT | GLenum | Yes | +| HIGH_INT | GLenum | Yes | +| FRAMEBUFFER | GLenum | Yes | +| RENDERBUFFER | GLenum | Yes | +| RGBA4 | GLenum | Yes | +| RGB5_A1 | GLenum | Yes | +| RGB565 | GLenum | Yes | +| DEPTH_COMPONENT16 | GLenum | Yes | +| STENCIL_INDEX8 | GLenum | Yes | +| DEPTH_STENCIL | GLenum | Yes | +| RENDERBUFFER_WIDTH | GLenum | Yes | +| RENDERBUFFER_HEIGHT | GLenum | Yes | +| RENDERBUFFER_INTERNAL_FORMAT | GLenum | Yes | +| RENDERBUFFER_RED_SIZE | GLenum | Yes | +| RENDERBUFFER_GREEN_SIZE | GLenum | Yes | +| RENDERBUFFER_BLUE_SIZE | GLenum | Yes | +| RENDERBUFFER_ALPHA_SIZE | GLenum | Yes | +| RENDERBUFFER_DEPTH_SIZE | GLenum | Yes | +| RENDERBUFFER_STENCIL_SIZE | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE | GLenum | Yes | +| COLOR_ATTACHMENT0 | GLenum | Yes | +| DEPTH_ATTACHMENT | GLenum | Yes | +| STENCIL_ATTACHMENT | GLenum | Yes | +| DEPTH_STENCIL_ATTACHMENT | GLenum | Yes | +| NONE | GLenum | Yes | +| FRAMEBUFFER_COMPLETE | GLenum | Yes | +| FRAMEBUFFER_INCOMPLETE_ATTACHMENT | GLenum | Yes | +| FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT | GLenum | Yes | +| FRAMEBUFFER_INCOMPLETE_DIMENSIONS | GLenum | Yes | +| FRAMEBUFFER_UNSUPPORTED | GLenum | Yes | +| FRAMEBUFFER_BINDING | GLenum | Yes | +| RENDERBUFFER_BINDING | GLenum | Yes | +| MAX_RENDERBUFFER_SIZE | GLenum | Yes | +| INVALID_FRAMEBUFFER_OPERATION | GLenum | Yes | +| UNPACK_FLIP_Y_WEBGL | GLenum | Yes | +| UNPACK_PREMULTIPLY_ALPHA_WEBGL | GLenum | Yes | +| CONTEXT_LOST_WEBGL | GLenum | Yes | +| UNPACK_COLORSPACE_CONVERSION_WEBGL | GLenum | Yes | +| BROWSER_DEFAULT_WEBGL | GLenum | Yes | +| canvas | HTMLCanvasElement \| OffscreenCanvas | Yes | +| drawingBufferWidth | GLsizei | Yes | +| drawingBufferHeight | GLsizei | Yes | ### Methods -| Method| Return Value Type| + | Method | Return Value Type | | -------- | -------- | -| getContextAttributes() | WebGLContextAttributes \| null | -| isContextLost() | boolean | -| getSupportedExtensions() | string[] \| null | -| getExtension(name: string) | any | -| activeTexture(texture: GLenum) | void | -| attachShader(program: WebGLProgram, shader: WebGLShader) | void | -| bindAttribLocation(program: WebGLProgram, index: GLuint, name: string) | void | -| bindBuffer(target: GLenum, buffer: WebGLBuffer \| null) | void | -| bindFramebuffer(target: GLenum, framebuffer: WebGLFramebuffer \| null) | void | -| bindRenderbuffer(target: GLenum, renderbuffer: WebGLRenderbuffer \| null) | void | -| bindTexture(target: GLenum, texture: WebGLTexture \| null) | void | -| blendColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) | void | -| blendEquation(mode: GLenum) | void | -| blendEquationSeparate(modeRGB: GLenum, modeAlpha: GLenum) | void | -| blendFunc(sfactor: GLenum, dfactor: GLenum) | void | -| blendFuncSeparate(srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum) | void | -| checkFramebufferStatus(target: GLenum) | GLenum | -| clear(mask: GLbitfield) | void | -| clearColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) | void | -| clearDepth(depth: GLclampf) | void | -| clearStencil(s: GLint) | void | -| colorMask(red: GLboolean, green: GLboolean, blue: GLboolean, alpha: GLboolean) | void | -| compileShader(shader: WebGLShader) | void | -| copyTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, x: GLint, y: GLint, width: GLsizei, height: GLsizei, border: GLint) | void | -| copyTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | -| createBuffer() | WebGLBuffer \| null | -| createFramebuffer() | WebGLFramebuffer \| null | -| createProgram() | WebGLProgram \| null | -| createRenderbuffer() | WebGLRenderbuffer \| null | -| createShader(type: GLenum) | WebGLShader \| null | -| createTexture() | WebGLTexture \| nullvoid | -| cullFace(mode: GLenum) | void | -| deleteBuffer(buffer: WebGLBuffer \| null) | void | -| deleteFramebuffer(framebuffer: WebGLFramebuffer \| null) | void | -| deleteProgram(program: WebGLProgram \| null) | void | -| deleteRenderbuffer(renderbuffer: WebGLRenderbuffer \| null) | void | -| deleteShader(shader: WebGLShader \| null) | void | -| deleteTexture(texture: WebGLTexture \| null) | void | -| depthFunc(func: GLenum) | void | -| depthMask(flag: GLboolean) | void | -| depthRange(zNear: GLclampf, zFar: GLclampf) | void | -| detachShader(program: WebGLProgram, shader: WebGLShader) | void | -| disable(cap: GLenum) | void | -| disableVertexAttribArray(index: GLuint) | void | -| drawArrays(mode: GLenum, first: GLint, count: GLsizei) | void | -| drawElements(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr) | void | -| enable(cap: GLenum) | void | -| enableVertexAttribArray(index: GLuint) | void | -| finish() | void | -| flush() | void | -| framebufferRenderbuffer(target: GLenum, attachment: GLenum, renderbuffertarget: GLenum, renderbuffer: WebGLRenderbuffer \| null) | void | -| framebufferTexture2D(target: GLenum, attachment: GLenum, textarget: GLenum, texture: WebGLTexture \| null, level: GLint) | void | -| frontFace(mode: GLenum) | void | -| generateMipmap(target: GLenum) | void | -| getActiveAttrib(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | -| getActiveUniform(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | -| getAttachedShaders(program: WebGLProgram) | WebGLShader[] \| null | -| getAttribLocation(program: WebGLProgram, name: string) | GLint | -| getBufferParameter(target: GLenum, pname: GLenum) | any | -| getParameter(pname: GLenum) | any | -| getError() | GLenum | -| getFramebufferAttachmentParameter(target: GLenum, attachment: GLenum, pname: GLenum) | any | -| getProgramParameter(program: WebGLProgram, pname: GLenum) | any | -| getProgramInfoLog(program: WebGLProgram) | string \| null | -| getRenderbufferParameter(target: GLenum, pname: GLenum) | any | -| getShaderParameter(shader: WebGLShader, pname: GLenum) | any | -| getShaderPrecisionFormat(shadertype: GLenum, precisiontype: GLenum) | WebGLShaderPrecisionFormat \| null | -| getShaderInfoLog(shader: WebGLShader) | string \| null | -| getShaderSource(shader: WebGLShader) | string \| null | -| getTexParameter(target: GLenum, pname: GLenum) | any | -| getUniform(program: WebGLProgram, location: WebGLUniformLocation) | any | -| getUniformLocation(program: WebGLProgram, name: string) | WebGLUniformLocation \| null | -| getVertexAttrib(index: GLuint, pname: GLenum) | any | -| getVertexAttribOffset(index: GLuint, pname: GLenum) | GLintptr | -| hint(target: GLenum, mode: GLenum) | void | -| isBuffer(buffer: WebGLBuffer \| null) | GLboolean | -| isEnabled(cap: GLenum) | GLboolean | -| isFramebuffer(framebuffer: WebGLFramebuffer \| null) | GLboolean | -| isProgram(program: WebGLProgram \| null) | GLboolean | -| isRenderbuffer(renderbuffer: WebGLRenderbuffer \| null) | GLboolean | -| isShader(shader: WebGLShader \| null) | GLboolean | -| isTexture(texture: WebGLTexture \| null) | GLboolean | -| lineWidth(width: GLfloat) | void | -| linkProgram(program: WebGLProgram) | void | -| pixelStorei(pname: GLenum, param: GLint \| GLboolean) | void | -| polygonOffset(factor: GLfloat, units: GLfloat) | void | -| renderbufferStorage(target: GLenum, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | -| sampleCoverage(value: GLclampf, invert: GLboolean) | void | -| scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | -| shaderSource(shader: WebGLShader, source: string) | void | -| stencilFunc(func: GLenum, ref: GLint, mask: GLuint) | void | -| stencilFuncSeparate(face: GLenum, func: GLenum, ref: GLint, mask: GLuint) | void | -| stencilMask(mask: GLuint) | void | -| stencilMaskSeparate(face: GLenum, mask: GLuint) | void | -| stencilOp(fail: GLenum, zfail: GLenum, zpass: GLenum) | void | -| stencilOpSeparate(face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum) | void | -| texParameterf(target: GLenum, pname: GLenum, param: GLfloat) | void | -| texParameteri(target: GLenum, pname: GLenum, param: GLint) | void | -| uniform1f(location: WebGLUniformLocation \| null, x: GLfloat) | void | -| uniform2f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat) | void | -| uniform3f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat) | void | -| uniform4f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) | void | -| uniform1i(location: WebGLUniformLocation \| null, x: GLint) | void | -| uniform2i(location: WebGLUniformLocation \| null, x: GLint, y: GLint) | void | -| uniform3i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint) | void | -| uniform4i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint, w: GLint) | void | -| useProgram(program: WebGLProgram \| null) | void | -| validateProgram(program: WebGLProgram) | void | -| vertexAttrib1f(index: GLuint, x: GLfloat) | void | -| vertexAttrib2f(index: GLuint, x: GLfloat, y: GLfloat) | void | -| vertexAttrib3f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat) | void | -| vertexAttrib4f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) | void | -| vertexAttrib1fv(index: GLuint, values: Float32List) | void | -| vertexAttrib2fv(index: GLuint, values: Float32List) | void | -| vertexAttrib3fv(index: GLuint, values: Float32List) | void | -| vertexAttrib4fv(index: GLuint, values: Float32List) | void | -| vertexAttribPointer(index: GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLintptr) | void | -| viewport(x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | - - -## webgl.WebGLRenderingContextOverloads +| getContextAttributes() | WebGLContextAttributes \| null | +| isContextLost() | boolean | +| getSupportedExtensions() | string[] \| null | +| getExtension(name: string) | any | +| activeTexture(texture: GLenum) | void | +| attachShader(program: WebGLProgram, shader: WebGLShader) | void | +| bindAttribLocation(program: WebGLProgram, index: GLuint, name: string) | void | +| bindBuffer(target: GLenum, buffer: WebGLBuffer \| null) | void | +| bindFramebuffer(target: GLenum, framebuffer: WebGLFramebuffer \| null) | void | +| bindRenderbuffer(target: GLenum, renderbuffer: WebGLRenderbuffer \| null) | void | +| bindTexture(target: GLenum, texture: WebGLTexture \| null) | void | +| blendColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) | void | +| blendEquation(mode: GLenum) | void | +| blendEquationSeparate(modeRGB: GLenum, modeAlpha: GLenum) | void | +| blendFunc(sfactor: GLenum, dfactor: GLenum) | void | +| blendFuncSeparate(srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum) | void | +| checkFramebufferStatus(target: GLenum) | GLenum | +| clear(mask: GLbitfield) | void | +| clearColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) | void | +| clearDepth(depth: GLclampf) | void | +| clearStencil(s: GLint) | void | +| colorMask(red: GLboolean, green: GLboolean, blue: GLboolean, alpha: GLboolean) | void | +| compileShader(shader: WebGLShader) | void | +| copyTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, x: GLint, y: GLint, width: GLsizei, height: GLsizei, border: GLint) | void | +| copyTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | +| createBuffer() | WebGLBuffer \| null | +| createFramebuffer() | WebGLFramebuffer \| null | +| createProgram() | WebGLProgram \| null | +| createRenderbuffer() | WebGLRenderbuffer \| null | +| createShader(type: GLenum) | WebGLShader \| null | +| createTexture() | WebGLTexture \| null | +| cullFace(mode: GLenum) | void | +| deleteBuffer(buffer: WebGLBuffer \| null) | void | +| deleteFramebuffer(framebuffer: WebGLFramebuffer \| null) | void | +| deleteProgram(program: WebGLProgram \| null) | void | +| deleteRenderbuffer(renderbuffer: WebGLRenderbuffer \| null) | void | +| deleteShader(shader: WebGLShader \| null) | void | +| deleteTexture(texture: WebGLTexture \| null) | void | +| depthFunc(func: GLenum) | void | +| depthMask(flag: GLboolean) | void | +| depthRange(zNear: GLclampf, zFar: GLclampf) | void | +| detachShader(program: WebGLProgram, shader: WebGLShader) | void | +| disable(cap: GLenum) | void | +| disableVertexAttribArray(index: GLuint) | void | +| drawArrays(mode: GLenum, first: GLint, count: GLsizei) | void | +| drawElements(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr) | void | +| enable(cap: GLenum) | void | +| enableVertexAttribArray(index: GLuint) | void | +| finish() | void | +| flush() | void | +| framebufferRenderbuffer(target: GLenum, attachment: GLenum, renderbuffertarget: GLenum, renderbuffer: WebGLRenderbuffer \| null) | void | +| framebufferTexture2D(target: GLenum, attachment: GLenum, textarget: GLenum, texture: WebGLTexture \| null, level: GLint) | void | +| frontFace(mode: GLenum) | void | +| generateMipmap(target: GLenum) | void | +| getActiveAttrib(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | +| getActiveUniform(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | +| getAttachedShaders(program: WebGLProgram) | WebGLShader[] \| null | +| getAttribLocation(program: WebGLProgram, name: string) | GLint | +| getBufferParameter(target: GLenum, pname: GLenum) | any | +| getParameter(pname: GLenum) | any | +| getError() | GLenum | +| getFramebufferAttachmentParameter(target: GLenum, attachment: GLenum, pname: GLenum) | any | +| getProgramParameter(program: WebGLProgram, pname: GLenum) | any | +| getProgramInfoLog(program: WebGLProgram) | string \| null | +| getRenderbufferParameter(target: GLenum, pname: GLenum) | any | +| getShaderParameter(shader: WebGLShader, pname: GLenum) | any | +| getShaderPrecisionFormat(shadertype: GLenum, precisiontype: GLenum) | WebGLShaderPrecisionFormat \| null | +| getShaderInfoLog(shader: WebGLShader) | string \| null | +| getShaderSource(shader: WebGLShader) | string \| null | +| getTexParameter(target: GLenum, pname: GLenum) | any | +| getUniform(program: WebGLProgram, location: WebGLUniformLocation) | any | +| getUniformLocation(program: WebGLProgram, name: string) | WebGLUniformLocation \| null | +| getVertexAttrib(index: GLuint, pname: GLenum) | any | +| getVertexAttribOffset(index: GLuint, pname: GLenum) | GLintptr | +| hint(target: GLenum, mode: GLenum) | void | +| isBuffer(buffer: WebGLBuffer \| null) | GLboolean | +| isEnabled(cap: GLenum) | GLboolean | +| isFramebuffer(framebuffer: WebGLFramebuffer \| null) | GLboolean | +| isProgram(program: WebGLProgram \| null) | GLboolean | +| isRenderbuffer(renderbuffer: WebGLRenderbuffer \| null) | GLboolean | +| isShader(shader: WebGLShader \| null) | GLboolean | +| isTexture(texture: WebGLTexture \| null) | GLboolean | +| lineWidth(width: GLfloat) | void | +| linkProgram(program: WebGLProgram) | void | +| pixelStorei(pname: GLenum, param: GLint \| GLboolean) | void | +| polygonOffset(factor: GLfloat, units: GLfloat) | void | +| renderbufferStorage(target: GLenum, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | +| sampleCoverage(value: GLclampf, invert: GLboolean) | void | +| scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | +| shaderSource(shader: WebGLShader, source: string) | void | +| stencilFunc(func: GLenum, ref: GLint, mask: GLuint) | void | +| stencilFuncSeparate(face: GLenum, func: GLenum, ref: GLint, mask: GLuint) | void | +| stencilMask(mask: GLuint) | void | +| stencilMaskSeparate(face: GLenum, mask: GLuint) | void | +| stencilOp(fail: GLenum, zfail: GLenum, zpass: GLenum) | void | +| stencilOpSeparate(face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum) | void | +| texParameterf(target: GLenum, pname: GLenum, param: GLfloat) | void | +| texParameteri(target: GLenum, pname: GLenum, param: GLint) | void | +| uniform1f(location: WebGLUniformLocation \| null, x: GLfloat) | void | +| uniform2f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat) | void | +| uniform3f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat) | void | +| uniform4f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) | void | +| uniform1i(location: WebGLUniformLocation \| null, x: GLint) | void | +| uniform2i(location: WebGLUniformLocation \| null, x: GLint, y: GLint) | void | +| uniform3i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint) | void | +| uniform4i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint, w: GLint) | void | +| useProgram(program: WebGLProgram \| null) | void | +| validateProgram(program: WebGLProgram) | void | +| vertexAttrib1f(index: GLuint, x: GLfloat) | void | +| vertexAttrib2f(index: GLuint, x: GLfloat, y: GLfloat) | void | +| vertexAttrib3f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat) | void | +| vertexAttrib4f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) | void | +| vertexAttrib1fv(index: GLuint, values: Float32List) | void | +| vertexAttrib2fv(index: GLuint, values: Float32List) | void | +| vertexAttrib3fv(index: GLuint, values: Float32List) | void | +| vertexAttrib4fv(index: GLuint, values: Float32List) | void | +| vertexAttribPointer(index: GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLintptr) | void | +| viewport(x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | + + +## WebGLRenderingContextOverloads WebGLRenderingContextOverloads -| Method| Return Value Type| + | Method | Return Value Type | | -------- | -------- | -| bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum) | void | -| bufferData(target: GLenum, data: BufferSource \| null, usage: GLenum) | void | -| bufferSubData(target: GLenum, offset: GLintptr, data: BufferSource) | void | -| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: ArrayBufferView) | void | -| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: ArrayBufferView) | void | -| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | -| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | -| texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | -| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | -| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | -| uniform1fv(location: WebGLUniformLocation \| null, v: Float32List) | void | -| uniform2fv(location: WebGLUniformLocation \| null, v: Float32List) | void | -| uniform3fv(location: WebGLUniformLocation \| null, v: Float32List) | void | -| uniform4fv(location: WebGLUniformLocation \| null, v: Float32List) | void | -| uniform1iv(location: WebGLUniformLocation \| null, v: Int32List) | void | -| uniform2iv(location: WebGLUniformLocation \| null, v: Int32List) | void | -| uniform3iv(location: WebGLUniformLocation \| null, v: Int32List) | void | -| uniform4iv(location: WebGLUniformLocation \| null, v: Int32List) | void | -| uniformMatrix2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | -| uniformMatrix3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | -| uniformMatrix4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | +| bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum) | void | +| bufferData(target: GLenum, data: BufferSource \| null, usage: GLenum) | void | +| bufferSubData(target: GLenum, offset: GLintptr, data: BufferSource) | void | +| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: ArrayBufferView) | void | +| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: ArrayBufferView) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void; | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| uniform1fv(location: WebGLUniformLocation \| null, v: Float32List) | void | +| uniform2fv(location: WebGLUniformLocation \| null, v: Float32List) | void | +| uniform3fv(location: WebGLUniformLocation \| null, v: Float32List) | void | +| uniform4fv(location: WebGLUniformLocation \| null, v: Float32List) | void | +| uniform1iv(location: WebGLUniformLocation \| null, v: Int32List) | void | +| uniform2iv(location: WebGLUniformLocation \| null, v: Int32List) | void | +| uniform3iv(location: WebGLUniformLocation \| null, v: Int32List) | void | +| uniform4iv(location: WebGLUniformLocation \| null, v: Int32List) | void | +| uniformMatrix2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | +| uniformMatrix3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | +| uniformMatrix4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | diff --git a/en/application-dev/reference/apis/js-apis-webgl2.md b/en/application-dev/reference/apis/js-apis-webgl2.md index fcfa00293db8a95fdaa20bfb28c66df16f1d26f3..9b94a14e3db63f0b935801631a926101cb859fef 100644 --- a/en/application-dev/reference/apis/js-apis-webgl2.md +++ b/en/application-dev/reference/apis/js-apis-webgl2.md @@ -1,6 +1,6 @@ -# WebGL2 +# webgl2 -> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** +> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -10,492 +10,474 @@ This module provides WebGL APIs that correspond to the OpenGL ES 3.0 feature set ## Modules to Import + ``` -import webgl from 'ohos.webglnapi' +import webgl from '@ohos.webglnapi'; ``` -## System Capabilities +## Invoking Method -SystemCapability.Graphic.Graphic2D.WebGL2 +Create a **<canvas>** component in the HML file. The following is an example: + +``` +
+ + +
+``` -## Invoking Method +Obtain the **<canvas>** component instance in the JS file. The following is an example: + ``` -// Obtain the component instance. -const el = this.$refs.canvas -// Obtain the WebGL context from the component instance. +// Obtain the component instance. +const el = this.$refs.canvas1; +// Obtain the WebGL context from the component instance. const gl = el.getContext('webgl'); -const gl2 = el.getContext('webgl2'); // Call the WebGL API. -gl2.readBuffer(gl.COLOR_ATTACHMENT0) +gl.clearColor(0.0, 0.0, 0.0, 1.0); ``` -## GLenum - -| Name| Type| -| -------- | -------- | -| GLenum | number | - - -## Glint64 - -| Name| Type| -| -------- | -------- | -| Glint64 | number | +## Type + **Table1** Type -## Gluint64 +| Name | Type | Description | +| -------- | -------- | -------- | +| GLenum | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL2 | +| GLint64 | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL2 | +| GLuint64 | number | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL2 | +| Uint32List | array | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL2 | -| Name| Type| -| -------- | -------- | -| Gluint64 | number | +## Interface -## Uint32List + **Table2** Interface -| Name| Type| +| Name | Description | | -------- | -------- | -| Uint32List | array | +| [WebGL2RenderingContextBase](#webgl2renderingcontextbase) | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL2 | +| [WebGL2RenderingContextOverloads](#webgl2renderingcontextoverloads) | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL2 | +| WebGLQuery | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL2 | +| WebGLSampler | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL2 | +| WebGLSync | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL2 | +| WebGLTransformFeedback | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL2 | +| WebGLVertexArrayObject | **System capabilities**: SystemCapability.Graphic.Graphic2D.WebGL2 | -## webgl.webGL2RenderingContexBase +## WebGL2RenderingContextBase -WebGL2RenderingContexBase +WebGL2RenderingContextBase ### Attributes -| Name| Type| Mandatory| -| -------- | ------- | --------- | -| READ_BUFFER | [GLenum](#GLenum) | Yes| -| UNPACK_ROW_LENGTH | [GLenum](#GLenum) | Yes| -| UNPACK_SKIP_ROWS | [GLenum](#GLenum) | Yes| -| UNPACK_SKIP_PIXELS | [GLenum](#GLenum) | Yes| -| PACK_ROW_LENGTH | [GLenum](#GLenum) | Yes| -| PACK_SKIP_ROWS | [GLenum](#GLenum) | Yes| -| PACK_SKIP_PIXELS | [GLenum](#GLenum) | Yes| -| COLOR | [GLenum](#GLenum) | Yes| -| DEPTH | [GLenum](#GLenum) | Yes| -| STENCIL | [GLenum](#GLenum) | Yes| -| RED | [GLenum](#GLenum) | Yes| -| RGB8 | [GLenum](#GLenum) | Yes| -| RGBA8 | [GLenum](#GLenum) | Yes| -| RGB10_A2 | [GLenum](#GLenum) | Yes| -| TEXTURE_BINDING_3D | [GLenum](#GLenum) | Yes| -| UNPACK_SKIP_IMAGES | [GLenum](#GLenum) | Yes| -| UNPACK_IMAGE_HEIGHT | [GLenum](#GLenum) | Yes| -| TEXTURE_3D | [GLenum](#GLenum) | Yes| -| TEXTURE_WRAP_R | [GLenum](#GLenum) | Yes| -| MAX_3D_TEXTURE_SIZE | [GLenum](#GLenum) | Yes| -| UNSIGNED_INT_2_10_10_10_REV | [GLenum](#GLenum) | Yes| -| MAX_ELEMENTS_VERTICES | [GLenum](#GLenum) | Yes| -| MAX_ELEMENTS_INDICES | [GLenum](#GLenum) | Yes| -| TEXTURE_MIN_LOD | [GLenum](#GLenum) | Yes| -| TEXTURE_MAX_LOD | [GLenum](#GLenum) | Yes| -| TEXTURE_BASE_LEVEL | [GLenum](#GLenum) | Yes| -| TEXTURE_MAX_LEVEL | [GLenum](#GLenum) | Yes| -| MIN | [GLenum](#GLenum) | Yes| -| MAX | [GLenum](#GLenum) | Yes| -| DEPTH_COMPONENT24 | [GLenum](#GLenum) | Yes| -| MAX_TEXTURE_LOD_BIAS | [GLenum](#GLenum) | Yes| -| TEXTURE_COMPARE_MODE | [GLenum](#GLenum) | Yes| -| TEXTURE_COMPARE_FUNC | [GLenum](#GLenum) | Yes| -| CURRENT_QUERY | [GLenum](#GLenum) | Yes| -| QUERY_RESULT | [GLenum](#GLenum) | Yes| -| QUERY_RESULT_AVAILABLE | [GLenum](#GLenum) | Yes| -| STREAM_READ | [GLenum](#GLenum) | Yes| -| STREAM_COPY | [GLenum](#GLenum) | Yes| -| STATIC_READ | [GLenum](#GLenum) | Yes| -| STATIC_COPY | [GLenum](#GLenum) | Yes| -| DYNAMIC_READ | [GLenum](#GLenum) | Yes| -| DYNAMIC_COPY | [GLenum](#GLenum) | Yes| -| MAX_DRAW_BUFFERS | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER0 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER1 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER2 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER3 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER4 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER5 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER6 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER7 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER8 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER9 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER10 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER11 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER12 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER13 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER14 | [GLenum](#GLenum) | Yes| -| DRAW_BUFFER15 | [GLenum](#GLenum) | Yes| -| MAX_FRAGMENT_UNIFORM_COMPONENTS | [GLenum](#GLenum) | Yes| -| MAX_VERTEX_UNIFORM_COMPONENTS | [GLenum](#GLenum) | Yes| -| SAMPLER_3D | [GLenum](#GLenum) | Yes| -| SAMPLER_2D_SHADOW | [GLenum](#GLenum) | Yes| -| FRAGMENT_SHADER_DERIVATIVE_HINT | [GLenum](#GLenum) | Yes| -| PIXEL_PACK_BUFFER | [GLenum](#GLenum) | Yes| -| PIXEL_UNPACK_BUFFER | [GLenum](#GLenum) | Yes| -| PIXEL_PACK_BUFFER_BINDING | [GLenum](#GLenum) | Yes| -| PIXEL_UNPACK_BUFFER_BINDING | [GLenum](#GLenum) | Yes| -| FLOAT_MAT2x3 | [GLenum](#GLenum) | Yes| -| FLOAT_MAT2x4 | [GLenum](#GLenum) | Yes| -| FLOAT_MAT3x2 | [GLenum](#GLenum) | Yes| -| FLOAT_MAT3x4 | [GLenum](#GLenum) | Yes| -| FLOAT_MAT4x2 | [GLenum](#GLenum) | Yes| -| FLOAT_MAT4x3 | [GLenum](#GLenum) | Yes| -| SRGB | [GLenum](#GLenum) | Yes| -| SRGB8 | [GLenum](#GLenum) | Yes| -| SRGB8_ALPHA8 | [GLenum](#GLenum) | Yes| -| COMPARE_REF_TO_TEXTURE | [GLenum](#GLenum) | Yes| -| RGBA32F | [GLenum](#GLenum) | Yes| -| RGB32F | [GLenum](#GLenum) | Yes| -| RGBA16F | [GLenum](#GLenum) | Yes| -| RGB16F | [GLenum](#GLenum) | Yes| -| VERTEX_ATTRIB_ARRAY_INTEGER | [GLenum](#GLenum) | Yes| -| MAX_ARRAY_TEXTURE_LAYERS | [GLenum](#GLenum) | Yes| -| MIN_PROGRAM_TEXEL_OFFSET | [GLenum](#GLenum) | Yes| -| MAX_PROGRAM_TEXEL_OFFSET | [GLenum](#GLenum) | Yes| -| MAX_VARYING_COMPONENTS | [GLenum](#GLenum) | Yes| -| TEXTURE_2D_ARRAY | [GLenum](#GLenum) | Yes| -| TEXTURE_BINDING_2D_ARRAY | [GLenum](#GLenum) | Yes| -| R11F_G11F_B10F | [GLenum](#GLenum) | Yes| -| UNSIGNED_INT_10F_11F_11F_REV | [GLenum](#GLenum) | Yes| -| RGB9_E5 | [GLenum](#GLenum) | Yes| -| UNSIGNED_INT_5_9_9_9_REV | [GLenum](#GLenum) | Yes| -| TRANSFORM_FEEDBACK_BUFFER_MODE | [GLenum](#GLenum) | Yes| -| MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS | [GLenum](#GLenum) | Yes| -| TRANSFORM_FEEDBACK_VARYINGS | [GLenum](#GLenum) | Yes| -| TRANSFORM_FEEDBACK_BUFFER_START | [GLenum](#GLenum) | Yes| -| TRANSFORM_FEEDBACK_BUFFER_SIZE | [GLenum](#GLenum) | Yes| -| TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN | [GLenum](#GLenum) | Yes| -| RASTERIZER_DISCARD | [GLenum](#GLenum) | Yes| -| MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS | [GLenum](#GLenum) | Yes| -| MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS | [GLenum](#GLenum) | Yes| -| INTERLEAVED_ATTRIBS | [GLenum](#GLenum) | Yes| -| SEPARATE_ATTRIBS | [GLenum](#GLenum) | Yes| -| TRANSFORM_FEEDBACK_BUFFER | [GLenum](#GLenum) | Yes| -| TRANSFORM_FEEDBACK_BUFFER_BINDING | [GLenum](#GLenum) | Yes| -| RGBA32UI | [GLenum](#GLenum) | Yes| -| RGB32UI | [GLenum](#GLenum) | Yes| -| RGBA16UI | [GLenum](#GLenum) | Yes| -| RGB16UI | [GLenum](#GLenum) | Yes| -| RGBA8UI | [GLenum](#GLenum) | Yes| -| RGB8UI | [GLenum](#GLenum) | Yes| -| RGBA32I | [GLenum](#GLenum) | Yes| -| RGB32I | [GLenum](#GLenum) | Yes| -| RGBA16I | [GLenum](#GLenum) | Yes| -| RGB16I | [GLenum](#GLenum) | Yes| -| RGBA8I | [GLenum](#GLenum) | Yes| -| RGB8I | [GLenum](#GLenum) | Yes| -| RED_INTEGER | [GLenum](#GLenum) | Yes| -| RGB_INTEGER | [GLenum](#GLenum) | Yes| -| RGBA_INTEGER | [GLenum](#GLenum) | Yes| -| SAMPLER_2D_ARRAY | [GLenum](#GLenum) | Yes| -| SAMPLER_2D_ARRAY_SHADOW | [GLenum](#GLenum) | Yes| -| SAMPLER_CUBE_SHADOW | [GLenum](#GLenum) | Yes| -| UNSIGNED_INT_VEC2 | [GLenum](#GLenum) | Yes| -| UNSIGNED_INT_VEC3 | [GLenum](#GLenum) | Yes| -| UNSIGNED_INT_VEC4 | [GLenum](#GLenum) | Yes| -| INT_SAMPLER_2D | [GLenum](#GLenum) | Yes| -| INT_SAMPLER_3D | [GLenum](#GLenum) | Yes| -| INT_SAMPLER_CUBE | [GLenum](#GLenum) | Yes| -| INT_SAMPLER_2D_ARRAY | [GLenum](#GLenum) | Yes| -| UNSIGNED_INT_SAMPLER_2D | [GLenum](#GLenum) | Yes| -| UNSIGNED_INT_SAMPLER_3D | [GLenum](#GLenum) | Yes| -| UNSIGNED_INT_SAMPLER_CUBE | [GLenum](#GLenum) | Yes| -| UNSIGNED_INT_SAMPLER_2D_ARRAY | [GLenum](#GLenum) | Yes| -| DEPTH_COMPONENT32F | [GLenum](#GLenum) | Yes| -| DEPTH32F_STENCIL8 | [GLenum](#GLenum) | Yes| -| FLOAT_32_UNSIGNED_INT_24_8_REV | [GLenum](#GLenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING | [GLenum](#GLenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE | [GLenum](#GLenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_RED_SIZE | [GLenum](#GLenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_GREEN_SIZE | [GLenum](#GLenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_BLUE_SIZE | [GLenum](#GLenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE | [GLenum](#GLenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE | [GLenum](#GLenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE | [GLenum](#GLenum) | Yes| -| FRAMEBUFFER_DEFAULT | [GLenum](#GLenum) | Yes| -| UNSIGNED_INT_24_8 | [GLenum](#GLenum) | Yes| -| DEPTH24_STENCIL8 | [GLenum](#GLenum) | Yes| -| UNSIGNED_NORMALIZED | [GLenum](#GLenum) | Yes| -| DRAW_FRAMEBUFFER_BINDING | [GLenum](#GLenum) | Yes| -| READ_FRAMEBUFFER | [GLenum](#GLenum) | Yes| -| DRAW_FRAMEBUFFER | [GLenum](#GLenum) | Yes| -| READ_FRAMEBUFFER_BINDING | [GLenum](#GLenum) | Yes| -| RENDERBUFFER_SAMPLES | [GLenum](#GLenum) | Yes| -| FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER | [GLenum](#GLenum) | Yes| -| MAX_COLOR_ATTACHMENTS | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT1 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT2 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT3 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT4 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT5 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT6 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT7 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT8 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT9 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT10 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT11 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT12 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT13 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT14 | [GLenum](#GLenum) | Yes| -| COLOR_ATTACHMENT15 | [GLenum](#GLenum) | Yes| -| FRAMEBUFFER_INCOMPLETE_MULTISAMPLE | [GLenum](#GLenum) | Yes| -| MAX_SAMPLES | [GLenum](#GLenum) | Yes| -| HALF_FLOAT | [GLenum](#GLenum) | Yes| -| RG | [GLenum](#GLenum) | Yes| -| RG_INTEGER | [GLenum](#GLenum) | Yes| -| R8 | [GLenum](#GLenum) | Yes| -| RG8 | [GLenum](#GLenum) | Yes| -| R16F | [GLenum](#GLenum) | Yes| -| R32F | [GLenum](#GLenum) | Yes| -| RG16F | [GLenum](#GLenum) | Yes| -| RG32F | [GLenum](#GLenum) | Yes| -| R8I | [GLenum](#GLenum) | Yes| -| R8UI | [GLenum](#GLenum) | Yes| -| R16I | [GLenum](#GLenum) | Yes| -| R16UI | [GLenum](#GLenum) | Yes| -| R32I | [GLenum](#GLenum) | Yes| -| R32UI | [GLenum](#GLenum) | Yes| -| RG8I | [GLenum](#GLenum) | Yes| -| RG8UI | [GLenum](#GLenum) | Yes| -| RG16I | [GLenum](#GLenum) | Yes| -| RG16UI | [GLenum](#GLenum) | Yes| -| RG32I | [GLenum](#GLenum) | Yes| -| RG32UI | [GLenum](#GLenum) | Yes| -| VERTEX_ARRAY_BINDING | [GLenum](#GLenum) | Yes| -| R8_SNORM | [GLenum](#GLenum) | Yes| -| RG8_SNORM | [GLenum](#GLenum) | Yes| -| RGB8_SNORM | [GLenum](#GLenum) | Yes| -| SIGNED_NORMALIZED | [GLenum](#GLenum) | Yes| -| COPY_READ_BUFFER | [GLenum](#GLenum) | Yes| -| COPY_WRITE_BUFFER | [GLenum](#GLenum) | Yes| -| COPY_READ_BUFFER_BINDING | [GLenum](#GLenum) | Yes| -| COPY_WRITE_BUFFER_BINDING | [GLenum](#GLenum) | Yes| -| UNIFORM_BUFFER | [GLenum](#GLenum) | Yes| -| UNIFORM_BUFFER_BINDING | [GLenum](#GLenum) | Yes| -| UNIFORM_BUFFER_START | [GLenum](#GLenum) | Yes| -| UNIFORM_BUFFER_SIZE | [GLenum](#GLenum) | Yes| -| MAX_VERTEX_UNIFORM_BLOCKS | [GLenum](#GLenum) | Yes| -| MAX_FRAGMENT_UNIFORM_BLOCKS | [GLenum](#GLenum) | Yes| -| MAX_COMBINED_UNIFORM_BLOCKS | [GLenum](#GLenum) | Yes| -| MAX_UNIFORM_BUFFER_BINDINGS | [GLenum](#GLenum) | Yes| -| MAX_UNIFORM_BLOCK_SIZE | [GLenum](#GLenum) | Yes| -| MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS | [GLenum](#GLenum) | Yes| -| MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS | [GLenum](#GLenum) | Yes| -| UNIFORM_BUFFER_OFFSET_ALIGNMENT | [GLenum](#GLenum) | Yes| -| ACTIVE_UNIFORM_BLOCKS | [GLenum](#GLenum) | Yes| -| UNIFORM_TYPE | [GLenum](#GLenum) | Yes| -| UNIFORM_SIZE | [GLenum](#GLenum) | Yes| -| UNIFORM_BLOCK_INDEX | [GLenum](#GLenum) | Yes| -| UNIFORM_OFFSET | [GLenum](#GLenum) | Yes| -| UNIFORM_ARRAY_STRIDE | [GLenum](#GLenum) | Yes| -| UNIFORM_MATRIX_STRIDE | [GLenum](#GLenum) | Yes| -| UNIFORM_IS_ROW_MAJOR | [GLenum](#GLenum) | Yes| -| UNIFORM_BLOCK_BINDING | [GLenum](#GLenum) | Yes| -| UNIFORM_BLOCK_DATA_SIZE | [GLenum](#GLenum) | Yes| -| UNIFORM_BLOCK_ACTIVE_UNIFORMS | [GLenum](#GLenum) | Yes| -| UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES | [GLenum](#GLenum) | Yes| -| UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER | [GLenum](#GLenum) | Yes| -| UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER | [GLenum](#GLenum) | Yes| -| INVALID_INDEX | [GLenum](#GLenum) | Yes| -| MAX_VERTEX_OUTPUT_COMPONENTS | [GLenum](#GLenum) | Yes| -| MAX_FRAGMENT_INPUT_COMPONENTS | [GLenum](#GLenum) | Yes| -| MAX_SERVER_WAIT_TIMEOUT | [GLenum](#GLenum) | Yes| -| OBJECT_TYPE | [GLenum](#GLenum) | Yes| -| SYNC_CONDITION | [GLenum](#GLenum) | Yes| -| SYNC_STATUS | [GLenum](#GLenum) | Yes| -| SYNC_FLAGS | [GLenum](#GLenum) | Yes| -| SYNC_FENCE | [GLenum](#GLenum) | Yes| -| SYNC_GPU_COMMANDS_COMPLETE | [GLenum](#GLenum) | Yes| -| UNSIGNALED | [GLenum](#GLenum) | Yes| -| SIGNALED | [GLenum](#GLenum) | Yes| -| ALREADY_SIGNALED | [GLenum](#GLenum) | Yes| -| TIMEOUT_EXPIRED | [GLenum](#GLenum) | Yes| -| CONDITION_SATISFIED | [GLenum](#GLenum) | Yes| -| WAIT_FAILED | [GLenum](#GLenum) | Yes| -| SYNC_FLUSH_COMMANDS_BIT | [GLenum](#GLenum) | Yes| -| VERTEX_ATTRIB_ARRAY_DIVISOR | [GLenum](#GLenum) | Yes| -| ANY_SAMPLES_PASSED | [GLenum](#GLenum) | Yes| -| ANY_SAMPLES_PASSED_CONSERVATIVE | [GLenum](#GLenum) | Yes| -| SAMPLER_BINDING | [GLenum](#GLenum) | Yes| -| RGB10_A2UI | [GLenum](#GLenum) | Yes| -| INT_2_10_10_10_REV | [GLenum](#GLenum) | Yes| -| TRANSFORM_FEEDBACK | [GLenum](#GLenum) | Yes| -| TRANSFORM_FEEDBACK_PAUSED | [GLenum](#GLenum) | Yes| -| TRANSFORM_FEEDBACK_ACTIVE | [GLenum](#GLenum) | Yes| -| TRANSFORM_FEEDBACK_BINDING | [GLenum](#GLenum) | Yes| -| TEXTURE_IMMUTABLE_FORMAT | [GLenum](#GLenum) | Yes| -| MAX_ELEMENT_INDEX | [GLenum](#GLenum) | Yes| -| TEXTURE_IMMUTABLE_LEVELS | [GLenum](#GLenum) | Yes| -| TIMEOUT_IGNORED | [GLenum](#GLenum) | Yes| -| MAX_CLIENT_WAIT_TIMEOUT_WEBGL | [GLenum](#GLenum) | Yes| + | Name | Type | Mandatory | +| -------- | -------- | -------- | +| READ_BUFFER | GLenum | Yes | +| UNPACK_ROW_LENGTH | GLenum | Yes | +| UNPACK_SKIP_ROWS | GLenum | Yes | +| UNPACK_SKIP_PIXELS | GLenum | Yes | +| PACK_ROW_LENGTH | GLenum | Yes | +| PACK_SKIP_ROWS | GLenum | Yes | +| PACK_SKIP_PIXELS | GLenum | Yes | +| COLOR | GLenum | Yes | +| DEPTH | GLenum | Yes | +| STENCIL | GLenum | Yes | +| RED | GLenum | Yes | +| RGB8 | GLenum | Yes | +| RGBA8 | GLenum | Yes | +| RGB10_A2 | GLenum | Yes | +| TEXTURE_BINDING_3D | GLenum | Yes | +| UNPACK_SKIP_IMAGES | GLenum | Yes | +| UNPACK_IMAGE_HEIGHT | GLenum | Yes | +| TEXTURE_3D | GLenum | Yes | +| TEXTURE_WRAP_R | GLenum | Yes | +| MAX_3D_TEXTURE_SIZE | GLenum | Yes | +| UNSIGNED_INT_2_10_10_10_REV | GLenum | Yes | +| MAX_ELEMENTS_VERTICES | GLenum | Yes | +| MAX_ELEMENTS_INDICES | GLenum | Yes | +| TEXTURE_MIN_LOD | GLenum | Yes | +| TEXTURE_MAX_LOD | GLenum | Yes | +| TEXTURE_BASE_LEVEL | GLenum | Yes | +| TEXTURE_MAX_LEVEL | GLenum | Yes | +| MIN | GLenum | Yes | +| MAX | GLenum | Yes | +| DEPTH_COMPONENT24 | GLenum | Yes | +| MAX_TEXTURE_LOD_BIAS | GLenum | Yes | +| TEXTURE_COMPARE_MODE | GLenum | Yes | +| TEXTURE_COMPARE_FUNC | GLenum | Yes | +| CURRENT_QUERY | GLenum | Yes | +| QUERY_RESULT | GLenum | Yes | +| QUERY_RESULT_AVAILABLE | GLenum | Yes | +| STREAM_READ | GLenum | Yes | +| STREAM_COPY | GLenum | Yes | +| STATIC_READ | GLenum | Yes | +| STATIC_COPY | GLenum | Yes | +| DYNAMIC_READ | GLenum | Yes | +| DYNAMIC_COPY | GLenum | Yes | +| MAX_DRAW_BUFFERS | GLenum | Yes | +| DRAW_BUFFER0 | GLenum | Yes | +| DRAW_BUFFER1 | GLenum | Yes | +| DRAW_BUFFER2 | GLenum | Yes | +| DRAW_BUFFER3 | GLenum | Yes | +| DRAW_BUFFER4 | GLenum | Yes | +| DRAW_BUFFER5 | GLenum | Yes | +| DRAW_BUFFER6 | GLenum | Yes | +| DRAW_BUFFER7 | GLenum | Yes | +| DRAW_BUFFER8 | GLenum | Yes | +| DRAW_BUFFER9 | GLenum | Yes | +| DRAW_BUFFER10 | GLenum | Yes | +| DRAW_BUFFER11 | GLenum | Yes | +| DRAW_BUFFER12 | GLenum | Yes | +| DRAW_BUFFER13 | GLenum | Yes | +| DRAW_BUFFER14 | GLenum | Yes | +| DRAW_BUFFER15 | GLenum | Yes | +| MAX_FRAGMENT_UNIFORM_COMPONENTS | GLenum | Yes | +| MAX_VERTEX_UNIFORM_COMPONENTS | GLenum | Yes | +| SAMPLER_3D | GLenum | Yes | +| SAMPLER_2D_SHADOW | GLenum | Yes | +| FRAGMENT_SHADER_DERIVATIVE_HINT | GLenum | Yes | +| PIXEL_PACK_BUFFER | GLenum | Yes | +| PIXEL_UNPACK_BUFFER | GLenum | Yes | +| PIXEL_PACK_BUFFER_BINDING | GLenum | Yes | +| PIXEL_UNPACK_BUFFER_BINDING | GLenum | Yes | +| FLOAT_MAT2x3 | GLenum | Yes | +| FLOAT_MAT2x4 | GLenum | Yes | +| FLOAT_MAT3x2 | GLenum | Yes | +| FLOAT_MAT3x4 | GLenum | Yes | +| FLOAT_MAT4x2 | GLenum | Yes | +| FLOAT_MAT4x3 | GLenum | Yes | +| SRGB | GLenum | Yes | +| SRGB8 | GLenum | Yes | +| SRGB8_ALPHA8 | GLenum | Yes | +| COMPARE_REF_TO_TEXTURE | GLenum | Yes | +| RGBA32F | GLenum | Yes | +| RGB32F | GLenum | Yes | +| RGBA16F | GLenum | Yes | +| RGB16F | GLenum | Yes | +| VERTEX_ATTRIB_ARRAY_INTEGER | GLenum | Yes | +| MAX_ARRAY_TEXTURE_LAYERS | GLenum | Yes | +| MIN_PROGRAM_TEXEL_OFFSET | GLenum | Yes | +| MAX_PROGRAM_TEXEL_OFFSET | GLenum | Yes | +| MAX_VARYING_COMPONENTS | GLenum | Yes | +| TEXTURE_2D_ARRAY | GLenum | Yes | +| TEXTURE_BINDING_2D_ARRAY | GLenum | Yes | +| R11F_G11F_B10F | GLenum | Yes | +| UNSIGNED_INT_10F_11F_11F_REV | GLenum | Yes | +| RGB9_E5 | GLenum | Yes | +| UNSIGNED_INT_5_9_9_9_REV | GLenum | Yes | +| TRANSFORM_FEEDBACK_BUFFER_MODE | GLenum | Yes | +| MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS | GLenum | Yes | +| TRANSFORM_FEEDBACK_VARYINGS | GLenum | Yes | +| TRANSFORM_FEEDBACK_BUFFER_START | GLenum | Yes | +| TRANSFORM_FEEDBACK_BUFFER_SIZE | GLenum | Yes | +| TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN | GLenum | Yes | +| RASTERIZER_DISCARD | GLenum | Yes | +| MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS | GLenum | Yes | +| MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS | GLenum | Yes | +| INTERLEAVED_ATTRIBS | GLenum | Yes | +| SEPARATE_ATTRIBS | GLenum | Yes | +| TRANSFORM_FEEDBACK_BUFFER | GLenum | Yes | +| TRANSFORM_FEEDBACK_BUFFER_BINDING | GLenum | Yes | +| RGBA32UI | GLenum | Yes | +| RGB32UI | GLenum | Yes | +| RGBA16UI | GLenum | Yes | +| RGB16UI | GLenum | Yes | +| RGBA8UI | GLenum | Yes | +| RGB8UI | GLenum | Yes | +| RGBA32I | GLenum | Yes | +| RGB32I | GLenum | Yes | +| RGBA16I | GLenum | Yes | +| RGB16I | GLenum | Yes | +| RGBA8I | GLenum | Yes | +| RGB8I | GLenum | Yes | +| RED_INTEGER | GLenum | Yes | +| RGB_INTEGER | GLenum | Yes | +| RGBA_INTEGER | GLenum | Yes | +| SAMPLER_2D_ARRAY | GLenum | Yes | +| SAMPLER_2D_ARRAY_SHADOW | GLenum | Yes | +| SAMPLER_CUBE_SHADOW | GLenum | Yes | +| UNSIGNED_INT_VEC2 | GLenum | Yes | +| UNSIGNED_INT_VEC3 | GLenum | Yes | +| UNSIGNED_INT_VEC4 | GLenum | Yes | +| INT_SAMPLER_2D | GLenum | Yes | +| INT_SAMPLER_3D | GLenum | Yes | +| INT_SAMPLER_CUBE | GLenum | Yes | +| INT_SAMPLER_2D_ARRAY | GLenum | Yes | +| UNSIGNED_INT_SAMPLER_2D | GLenum | Yes | +| UNSIGNED_INT_SAMPLER_3D | GLenum | Yes | +| UNSIGNED_INT_SAMPLER_CUBE | GLenum | Yes | +| UNSIGNED_INT_SAMPLER_2D_ARRAY | GLenum | Yes | +| DEPTH_COMPONENT32F | GLenum | Yes | +| DEPTH32F_STENCIL8 | GLenum | Yes | +| FLOAT_32_UNSIGNED_INT_24_8_REV | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_RED_SIZE | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_GREEN_SIZE | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_BLUE_SIZE | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE | GLenum | Yes | +| FRAMEBUFFER_DEFAULT | GLenum | Yes | +| UNSIGNED_INT_24_8 | GLenum | Yes | +| DEPTH24_STENCIL8 | GLenum | Yes | +| UNSIGNED_NORMALIZED | GLenum | Yes | +| DRAW_FRAMEBUFFER_BINDING | GLenum | Yes | +| READ_FRAMEBUFFER | GLenum | Yes | +| DRAW_FRAMEBUFFER | GLenum | Yes | +| READ_FRAMEBUFFER_BINDING | GLenum | Yes | +| RENDERBUFFER_SAMPLES | GLenum | Yes | +| FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER | GLenum | Yes | +| MAX_COLOR_ATTACHMENTS | GLenum | Yes | +| COLOR_ATTACHMENT1 | GLenum | Yes | +| COLOR_ATTACHMENT2 | GLenum | Yes | +| COLOR_ATTACHMENT3 | GLenum | Yes | +| COLOR_ATTACHMENT4 | GLenum | Yes | +| COLOR_ATTACHMENT5 | GLenum | Yes | +| COLOR_ATTACHMENT6 | GLenum | Yes | +| COLOR_ATTACHMENT7 | GLenum | Yes | +| COLOR_ATTACHMENT8 | GLenum | Yes | +| COLOR_ATTACHMENT9 | GLenum | Yes | +| COLOR_ATTACHMENT10 | GLenum | Yes | +| COLOR_ATTACHMENT11 | GLenum | Yes | +| COLOR_ATTACHMENT12 | GLenum | Yes | +| COLOR_ATTACHMENT13 | GLenum | Yes | +| COLOR_ATTACHMENT14 | GLenum | Yes | +| COLOR_ATTACHMENT15 | GLenum | Yes | +| FRAMEBUFFER_INCOMPLETE_MULTISAMPLE | GLenum | Yes | +| MAX_SAMPLES | GLenum | Yes | +| HALF_FLOAT | GLenum | Yes | +| RG | GLenum | Yes | +| RG_INTEGER | GLenum | Yes | +| R8 | GLenum | Yes | +| RG8 | GLenum | Yes | +| R16F | GLenum | Yes | +| R32F | GLenum | Yes | +| RG16F | GLenum | Yes | +| RG32F | GLenum | Yes | +| R8I | GLenum | Yes | +| R8UI | GLenum | Yes | +| R16I | GLenum | Yes | +| R16UI | GLenum | Yes | +| R32I | GLenum | Yes | +| R32UI | GLenum | Yes | +| RG8I | GLenum | Yes | +| RG8UI | GLenum | Yes | +| RG16I | GLenum | Yes | +| RG16UI | GLenum | Yes | +| RG32I | GLenum | Yes | +| RG32UI | GLenum | Yes | +| VERTEX_ARRAY_BINDING | GLenum | Yes | +| R8_SNORM | GLenum | Yes | +| RG8_SNORM | GLenum | Yes | +| RGB8_SNORM | GLenum | Yes | +| SIGNED_NORMALIZED | GLenum | Yes | +| COPY_READ_BUFFER | GLenum | Yes | +| COPY_WRITE_BUFFER | GLenum | Yes | +| COPY_READ_BUFFER_BINDING | GLenum | Yes | +| COPY_WRITE_BUFFER_BINDING | GLenum | Yes | +| UNIFORM_BUFFER | GLenum | Yes | +| UNIFORM_BUFFER_BINDING | GLenum | Yes | +| UNIFORM_BUFFER_START | GLenum | Yes | +| UNIFORM_BUFFER_SIZE | GLenum | Yes | +| MAX_VERTEX_UNIFORM_BLOCKS | GLenum | Yes | +| MAX_FRAGMENT_UNIFORM_BLOCKS | GLenum | Yes | +| MAX_COMBINED_UNIFORM_BLOCKS | GLenum | Yes | +| MAX_UNIFORM_BUFFER_BINDINGS | GLenum | Yes | +| MAX_UNIFORM_BLOCK_SIZE | GLenum | Yes | +| MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS | GLenum | Yes | +| MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS | GLenum | Yes | +| UNIFORM_BUFFER_OFFSET_ALIGNMENT | GLenum | Yes | +| ACTIVE_UNIFORM_BLOCKS | GLenum | Yes | +| UNIFORM_TYPE | GLenum | Yes | +| UNIFORM_SIZE | GLenum | Yes | +| UNIFORM_BLOCK_INDEX | GLenum | Yes | +| UNIFORM_OFFSET | GLenum | Yes | +| UNIFORM_ARRAY_STRIDE | GLenum | Yes | +| UNIFORM_MATRIX_STRIDE | GLenum | Yes | +| UNIFORM_IS_ROW_MAJOR | GLenum | Yes | +| UNIFORM_BLOCK_BINDING | GLenum | Yes | +| UNIFORM_BLOCK_DATA_SIZE | GLenum | Yes | +| UNIFORM_BLOCK_ACTIVE_UNIFORMS | GLenum | Yes | +| UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES | GLenum | Yes | +| UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER | GLenum | Yes | +| UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER | GLenum | Yes | +| INVALID_INDEX | GLenum | Yes | +| MAX_VERTEX_OUTPUT_COMPONENTS | GLenum | Yes | +| MAX_FRAGMENT_INPUT_COMPONENTS | GLenum | Yes | +| MAX_SERVER_WAIT_TIMEOUT | GLenum | Yes | +| OBJECT_TYPE | GLenum | Yes | +| SYNC_CONDITION | GLenum | Yes | +| SYNC_STATUS | GLenum | Yes | +| SYNC_FLAGS | GLenum | Yes | +| SYNC_FENCE | GLenum | Yes | +| SYNC_GPU_COMMANDS_COMPLETE | GLenum | Yes | +| UNSIGNALED | GLenum | Yes | +| SIGNALED | GLenum | Yes | +| ALREADY_SIGNALED | GLenum | Yes | +| TIMEOUT_EXPIRED | GLenum | Yes | +| CONDITION_SATISFIED | GLenum | Yes | +| WAIT_FAILED | GLenum | Yes | +| SYNC_FLUSH_COMMANDS_BIT | GLenum | Yes | +| VERTEX_ATTRIB_ARRAY_DIVISOR | GLenum | Yes | +| ANY_SAMPLES_PASSED | GLenum | Yes | +| ANY_SAMPLES_PASSED_CONSERVATIVE | GLenum | Yes | +| SAMPLER_BINDING | GLenum | Yes | +| RGB10_A2UI | GLenum | Yes | +| INT_2_10_10_10_REV | GLenum | Yes | +| TRANSFORM_FEEDBACK | GLenum | Yes | +| TRANSFORM_FEEDBACK_PAUSED | GLenum | Yes | +| TRANSFORM_FEEDBACK_ACTIVE | GLenum | Yes | +| TRANSFORM_FEEDBACK_BINDING | GLenum | Yes | +| TEXTURE_IMMUTABLE_FORMAT | GLenum | Yes | +| MAX_ELEMENT_INDEX | GLenum | Yes | +| TEXTURE_IMMUTABLE_LEVELS | GLenum | Yes | +| TIMEOUT_IGNORED | GLint64 | Yes | +| MAX_CLIENT_WAIT_TIMEOUT_WEBGL | GLenum | Yes | ### Methods -| Method| Return Value Type| -| -------- | ---------- | -| copyBufferSubData(readTarget:  GLenum,  writeTarget:  GLenum,  readOffset:  GLintptr,  writeOffset:  GLintptr,  size:  GLsizeiptr) | void | -| getBufferSubData(target:  GLenum,  srcByteOffset:  GLintptr,  dstBuffer:  ArrayBufferView,  dstOffset?:  GLuint,  length?:  GLuint) | void | -| blitFramebuffer(srcX0:  GLint,  srcY0:  GLint,  srcX1:  GLint,  srcY1:  GLint,  dstX0:  GLint,  dstY0:  GLint,  dstX1:  GLint,  dstY1:  GLint,  mask:  GLbitfield,  filter:  GLenum) | void | -| framebufferTextureLayer(target:  GLenum,  attachment:  GLenum,  texture:  WebGLTexture \| null,  level:  GLint,  layer:  GLint) | void | -| invalidateFramebuffer(target:  GLenum,  attachments:  GLenum[]) | void | -| invalidateSubFramebuffer(target:  GLenum,  attachments:  GLenum[],  x:  GLint,  y:  GLint,  width:  GLsizei,  height:  GLsizei) | void | -| readBuffer(src:  GLenum) | void | -| getInternalformatParameter(target:  GLenum,  internalformat:  GLenum,  pname:  GLenum) | any | -| renderbufferStorageMultisample(target:  GLenum,  samples:  GLsizei,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei) | void | -| texStorage2D(target:  GLenum,  levels:  GLsizei,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei) | void | -| texStorage3D(target:  GLenum,  levels:  GLsizei,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei) | void | -| texImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  pboOffset:  GLintptr) | void | -| texImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  srcData:  ArrayBufferView \| null) | void | -| texImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  srcData:  ArrayBufferView,  srcOffset:  GLuint) | void | -| texSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  format:  GLenum,  type:  GLenum,  pboOffset:  GLintptr) | void | -| texSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  format:  GLenum,  type:  GLenum,  srcData:  ArrayBufferView \| null,  srcOffset?:  GLuint) | void | -| copyTexSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  x:  GLint,  y:  GLint,  width:  GLsizei,  height:  GLsizei) | void | -| compressedTexImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  imageSize:  GLsizei,  offset:  GLintptr) | void | -| compressedTexImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  srcData:  ArrayBufferView,  srcOffset?:  GLuint,  srcLengthOverride?:  GLuint) | void | -| compressedTexSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  format:  GLenum,  imageSize:  GLsizei,  offset:  GLintptr) | void | -| compressedTexSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  format:  GLenum,  srcData:  ArrayBufferView,  srcOffset?:  GLuint,  srcLengthOverride?:  GLuint) | void | -| getFragDataLocation(program:  WebGLProgram,  name:  string) | GLint | -| uniform1ui(location:  WebGLUniformLocation \| null,  v0:  GLuint) | void | -| uniform2ui(location:  WebGLUniformLocation \| null,  v0:  GLuint,  v1:  GLuint) | void | -| uniform3ui(location:  WebGLUniformLocation \| null,  v0:  GLuint,  v1:  GLuint,  v2:  GLuint) | void | -| uniform4ui(location:  WebGLUniformLocation \| null,  v0:  GLuint,  v1:  GLuint,  v2:  GLuint,  v3:  GLuint) | void | -| uniform1uiv(location:  WebGLUniformLocation \| null,  data:  Uint32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform2uiv(location:  WebGLUniformLocation \| null,  data:  Uint32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform3uiv(location:  WebGLUniformLocation \| null,  data:  Uint32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform4uiv(location:  WebGLUniformLocation \| null,  data:  Uint32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix3x2fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix4x2fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix2x3fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix4x3fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix2x4fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix3x4fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| vertexAttribI4i(index:  GLuint,  x:  GLint,  y:  GLint,  z:  GLint,  w:  GLint) | void | -| vertexAttribI4iv(index:  GLuint,  values:  Int32List) | void | -| vertexAttribI4ui(index:  GLuint,  x:  GLuint,  y:  GLuint,  z:  GLuint,  w:  GLuint) | void | -| vertexAttribI4uiv(index:  GLuint,  values:  Uint32List) | void | -| vertexAttribIPointer(index:  GLuint,  size:  GLint,  type:  GLenum,  stride:  GLsizei,  offset:  GLintptr) | void | -| vertexAttribDivisor(index:  GLuint,  divisor:  GLuint) | void | -| drawArraysInstanced(mode:  GLenum,  first:  GLint,  count:  GLsizei,  instanceCount:  GLsizei) | void | -| drawElementsInstanced(mode:  GLenum,  count:  GLsizei,  type:  GLenum,  offset:  GLintptr,  instanceCount:  GLsizei) | void | -| drawRangeElements(mode:  GLenum,  start:  GLuint,  end:  GLuint,  count:  GLsizei,  type:  GLenum,  offset:  GLintptr) | void | -| drawBuffers(buffers:  GLenum[]) | void | -| clearBufferfv(buffer:  GLenum,  drawbuffer:  GLint,  values:  Float32List,  srcOffset?:  GLuint) | void | -| clearBufferiv(buffer:  GLenum,  drawbuffer:  GLint,  values:  Int32List,  srcOffset?:  GLuint) | void | -| clearBufferuiv(buffer:  GLenum,  drawbuffer:  GLint,  values:  Uint32List,  srcOffset?:  GLuint) | void | -| clearBufferfi(buffer:  GLenum,  drawbuffer:  GLint,  depth:  GLfloat,  stencil:  GLint) | void | -| createQuery() | WebGLQuery \| null | -| deleteQuery(query:  WebGLQuery \| null) | void | -| isQuery(query:  WebGLQuery \| null) | GLboolean | -| beginQuery(target:  GLenum,  query:  WebGLQuery) | void | -| endQuery(target:  GLenum) | void | -| getQuery(target:  GLenum,  pname:  GLenum) | WebGLQuery \| null | -| getQueryParameter(query:  WebGLQuery,  pname:  GLenum) | any | -| createSampler() | WebGLSampler \| null | -| deleteSampler(sampler:  WebGLSampler \| null) | void | -| isSampler(sampler:  WebGLSampler \| null) | GLboolean | -| bindSampler(unit:  GLuint,  sampler:  WebGLSampler \| null) | void | -| samplerParameteri(sampler:  WebGLSampler,  pname:  GLenum,  param:  GLint) | void | -| samplerParameterf(sampler:  WebGLSampler,  pname:  GLenum,  param:  GLfloat) | void | -| getSamplerParameter(sampler:  WebGLSampler,  pname:  GLenum) | any | -| fenceSync(condition:  GLenum,  flags:  GLbitfield) | WebGLSync \| null | -| isSync(sync:  WebGLSync \| null) | GLboolean | -| deleteSync(sync:  WebGLSync \| null) | void | -| clientWaitSync(sync:  WebGLSync,  flags:  GLbitfield,  timeout:  GLuint64) | GLenum | -| waitSync(sync:  WebGLSync,  flags:  GLbitfield,  timeout:  GLint64) | void | -| getSyncParameter(sync:  WebGLSync,  pname:  GLenum) | any | -| createTransformFeedback() | WebGLTransformFeedback \| null | -| deleteTransformFeedback(tf:  WebGLTransformFeedback \| null) | void | -| isTransformFeedback(tf:  WebGLTransformFeedback \| null) | GLboolean | -| bindTransformFeedback(target:  GLenum,  tf:  WebGLTransformFeedback \| null) | void | -| beginTransformFeedback(primitiveMode:  GLenum) | void | -| endTransformFeedback() | void | -| transformFeedbackVaryings(program:  WebGLProgram,  varyings:  string[],  bufferMode:  GLenum) | void | -| getTransformFeedbackVarying(program:  WebGLProgram,  index:  GLuint) | WebGLActiveInfo \| null | -| pauseTransformFeedback() | void | -| resumeTransformFeedback() | void | -| bindBufferBase(target:  GLenum,  index:  GLuint,  buffer:  WebGLBuffer \| null) | void | -| bindBufferRange(target:  GLenum,  index:  GLuint,  buffer:  WebGLBuffer \| null,  offset:  GLintptr,  size:  GLsizeiptr) | void | -| getIndexedParameter(target:  GLenum,  index:  GLuint) | any | -| getUniformIndices(program:  WebGLProgram,  uniformNames:  string[]) | GLuint[] \| null | -| getActiveUniforms(program:  WebGLProgram,  uniformIndices:  GLuint[],  pname:  GLenum) | any | -| getUniformBlockIndex(program:  WebGLProgram,  uniformBlockName:  string) | GLuint | -| getActiveUniformBlockParameter(program:  WebGLProgram,  uniformBlockIndex:  GLuint,  pname:  GLenum) | any | -| getActiveUniformBlockName(program:  WebGLProgram,  uniformBlockIndex:  GLuint) | string \| null | -| uniformBlockBinding(program:  WebGLProgram,  uniformBlockIndex:  GLuint,  uniformBlockBinding:  GLuint) | void | -| createVertexArray() | WebGLVertexArrayObject \| null | -| deleteVertexArray(vertexArray:  WebGLVertexArrayObject \| null) | void | -| isVertexArray(vertexArray:  WebGLVertexArrayObject \| null) | GLboolean | -| bindVertexArray(array:  WebGLVertexArrayObject \| null) | void | - - -## webgl.WebGL2RenderingContextOverloads + | Method | Return Value Type | +| -------- | -------- | +| copyBufferSubData(readTarget: GLenum, writeTarget: GLenum, readOffset: GLintptr, writeOffset: GLintptr, size: GLsizeiptr) | void | +| getBufferSubData(target: GLenum, srcByteOffset: GLintptr, dstBuffer: ArrayBufferView, dstOffset?: GLuint, length?: GLuint) | void | +| blitFramebuffer(srcX0: GLint, srcY0: GLint, srcX1: GLint, srcY1: GLint, dstX0: GLint, dstY0: GLint, dstX1: GLint, dstY1: GLint, mask: GLbitfield, filter: GLenum) | void | +| framebufferTextureLayer(target: GLenum, attachment: GLenum, texture: WebGLTexture \| null, level: GLint, layer: GLint) | void | +| invalidateFramebuffer(target: GLenum, attachments: GLenum[]) | void | +| invalidateSubFramebuffer(target: GLenum, attachments: GLenum[], x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | +| readBuffer(src: GLenum) | void | +| getInternalformatParameter(target: GLenum, internalformat: GLenum, pname: GLenum) | any | +| renderbufferStorageMultisample(target: GLenum, samples: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | +| texStorage2D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | +| texStorage3D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView \| null) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | +| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView \| null, srcOffset?: GLuint) | void | +| copyTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | +| compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| getFragDataLocation(program: WebGLProgram, name: string) | GLint | +| uniform1ui(location: WebGLUniformLocation \| null, v0: GLuint) | void | +| uniform2ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint) | void | +| uniform3ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint, v2: GLuint) | void | +| uniform4ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint, v2: GLuint, v3: GLuint) | void | +| uniform1uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform2uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform3uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform4uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix3x2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix4x2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix2x3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix4x3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix2x4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix3x4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| vertexAttribI4i(index: GLuint, x: GLint, y: GLint, z: GLint, w: GLint) | void | +| vertexAttribI4iv(index: GLuint, values: Int32List) | void | +| vertexAttribI4ui(index: GLuint, x: GLuint, y: GLuint, z: GLuint, w: GLuint) | void | +| vertexAttribI4uiv(index: GLuint, values: Uint32List) | void | +| vertexAttribIPointer(index: GLuint, size: GLint, type: GLenum, stride: GLsizei, offset: GLintptr) | void | +| vertexAttribDivisor(index: GLuint, divisor: GLuint) | void | +| drawArraysInstanced(mode: GLenum, first: GLint, count: GLsizei, instanceCount: GLsizei) | void | +| drawElementsInstanced(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, instanceCount: GLsizei) | void | +| drawRangeElements(mode: GLenum, start: GLuint, end: GLuint, count: GLsizei, type: GLenum, offset: GLintptr) | void | +| drawBuffers(buffers: GLenum[]) | void | +| clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Float32List, srcOffset?: GLuint) | void | +| clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Int32List, srcOffset?: GLuint) | void | +| clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Uint32List, srcOffset?: GLuint) | void | +| clearBufferfi(buffer: GLenum, drawbuffer: GLint, depth: GLfloat, stencil: GLint) | void | +| createQuery() | WebGLQuery \| null | +| deleteQuery(query: WebGLQuery \| null) | void | +| isQuery(query: WebGLQuery \| null) | GLboolean | +| beginQuery(target: GLenum, query: WebGLQuery) | void | +| endQuery(target: GLenum) | void | +| getQuery(target: GLenum, pname: GLenum) | WebGLQuery \| null | +| getQueryParameter(query: WebGLQuery, pname: GLenum) | any | +| createSampler() | WebGLSampler \| null | +| deleteSampler(sampler: WebGLSampler \| null) | void | +| isSampler(sampler: WebGLSampler \| null) | GLboolean | +| bindSampler(unit: GLuint, sampler: WebGLSampler \| null) | void | +| samplerParameteri(sampler: WebGLSampler, pname: GLenum, param: GLint) | void | +| samplerParameterf(sampler: WebGLSampler, pname: GLenum, param: GLfloat) | void; | +| getSamplerParameter(sampler: WebGLSampler, pname: GLenum) | any | +| fenceSync(condition: GLenum, flags: GLbitfield) | WebGLSync \| null | +| isSync(sync: WebGLSync \| null) | GLboolean | +| deleteSync(sync: WebGLSync \| null) | void | +| clientWaitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLuint64) | GLenum | +| waitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLint64) | void | +| getSyncParameter(sync: WebGLSync, pname: GLenum) | any | +| createTransformFeedback() | WebGLTransformFeedback \| null | +| deleteTransformFeedback(tf: WebGLTransformFeedback \| null) | void | +| isTransformFeedback(tf: WebGLTransformFeedback \| null) | GLboolean | +| bindTransformFeedback(target: GLenum, tf: WebGLTransformFeedback \| null) | void | +| beginTransformFeedback(primitiveMode: GLenum) | void | +| endTransformFeedback() | void | +| transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: GLenum) | void | +| getTransformFeedbackVarying(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | +| pauseTransformFeedback() | void | +| resumeTransformFeedback() | void | +| bindBufferBase(target: GLenum, index: GLuint, buffer: WebGLBuffer \| null) | void | +| bindBufferRange(target: GLenum, index: GLuint, buffer: WebGLBuffer \| null, offset: GLintptr, size: GLsizeiptr) | void | +| getIndexedParameter(target: GLenum, index: GLuint) | any | +| getUniformIndices(program: WebGLProgram, uniformNames: string[]) | GLuint[] \| null | +| getActiveUniforms(program: WebGLProgram, uniformIndices: GLuint[], pname: GLenum) | any | +| getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string) | GLuint | +| getActiveUniformBlockParameter(program: WebGLProgram, uniformBlockIndex: GLuint, pname: GLenum) | any | +| getActiveUniformBlockName(program: WebGLProgram, uniformBlockIndex: GLuint) | string \| null | +| uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: GLuint, uniformBlockBinding: GLuint) | void | +| createVertexArray() | WebGLVertexArrayObject \| null | +| deleteVertexArray(vertexArray: WebGLVertexArrayObject \| null) | void | +| isVertexArray(vertexArray: WebGLVertexArrayObject \| null) | GLboolean | +| bindVertexArray(array: WebGLVertexArrayObject \| null) | void | + + +## WebGL2RenderingContextOverloads WebGL2RenderingContextOverloads -| Method| Return Value Type| -| -------- | ---------- | -| bufferData(target:  GLenum,  size:  GLsizeiptr,  usage:  GLenum) | void | -| bufferData(target:  GLenum,  srcData:  BufferSource \| null,  usage:  GLenum) | void | -| bufferSubData(target:  GLenum,  dstByteOffset:  GLintptr,  srcData:  BufferSource) | void | -| bufferData(target:  GLenum,  srcData:  ArrayBufferView,  usage:  GLenum,  srcOffset:  GLuint,  length?:  GLuint) | void | -| bufferSubData(target:  GLenum,  dstByteOffset:  GLintptr,  srcData:  ArrayBufferView,  srcOffset:  GLuint,  length?:  GLuint) | void | -| texImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  pixels:  ArrayBufferView \| null) | void | -| texImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  pixels:  ArrayBufferView \| null) | void | -| texSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  pboOffset:  GLintptr) | void | -| texImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  srcData:  ArrayBufferView,  srcOffset:  GLuint) | void | -| texSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  pboOffset:  GLintptr) | void | -| texSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  srcData:  ArrayBufferView,  srcOffset:  GLuint) | void | -| compressedTexImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  imageSize:  GLsizei,  offset:  GLintptr) | void | -| compressedTexImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  srcData:  ArrayBufferView,  srcOffset?:  GLuint,  srcLengthOverride?:  GLuint) | void | -| compressedTexSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  imageSize:  GLsizei,  offset:  GLintptr) | void | -| compressedTexSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  srcData:  ArrayBufferView,  srcOffset?:  GLuint,  srcLengthOverride?:  GLuint) | void | -| uniform1fv(location:  WebGLUniformLocation \| null,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform2fv(location:  WebGLUniformLocation \| null,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform3fv(location:  WebGLUniformLocation \| null,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform4fv(location:  WebGLUniformLocation \| null,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform1iv(location:  WebGLUniformLocation \| null,  data:  Int32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform2iv(location:  WebGLUniformLocation \| null,  data:  Int32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform3iv(location:  WebGLUniformLocation \| null,  data:  Int32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform4iv(location:  WebGLUniformLocation \| null,  data:  Int32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix2fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix3fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix4fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| readPixels(x:  GLint,  y:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  dstData:  ArrayBufferView \| null) | void | -| readPixels(x:  GLint,  y:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  offset:  GLintptr) | void | -| readPixels(x:  GLint,  y:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  dstData:  ArrayBufferView,  dstOffset:  GLuint) | void | - - -## webgl.WebGLQuery - -WebGLQuery - - -## webgl.WebGLSampler - -WebGLSampler - - -## webgl.WebGLSync - -WebGLSync - - -## webgl.WebGLTransformFeedback - -WebGLTransformFeedback - - -## webgl.WebGLVertexArrayObject - -WebGLVertexArrayObject + | Method | Return Value Type | +| -------- | -------- | +| bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum) | void | +| bufferData(target: GLenum, srcData: BufferSource \| null, usage: GLenum) | void | +| bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: BufferSource) | void | +| bufferData(target: GLenum, srcData: ArrayBufferView, usage: GLenum, srcOffset: GLuint, length?: GLuint) | void | +| bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: ArrayBufferView, srcOffset: GLuint, length?: GLuint) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | +| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| uniform1fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform2fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform3fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform4fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform1iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform2iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform3iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform4iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView \| null) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, offset: GLintptr) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView, dstOffset: GLuint) | void | diff --git a/en/application-dev/reference/arkui-js/Readme-EN.md b/en/application-dev/reference/arkui-js/Readme-EN.md index d9159c600a7471090dd7d1b510677651bc7c698f..02a9479f1d2ee3a71bd859a42b3f345e17e25109 100644 --- a/en/application-dev/reference/arkui-js/Readme-EN.md +++ b/en/application-dev/reference/arkui-js/Readme-EN.md @@ -64,7 +64,7 @@ - [Media Components](js-components-media.md) - [video](js-components-media-video.md) - - [Canvas Components ](js-components-canvas.md) + - [Canvas Components](js-components-canvas.md) - [canvas](js-components-canvas-canvas.md) - [CanvasRenderingContext2D](js-components-canvas-canvasrenderingcontext2d.md) - [Image](js-components-canvas-image.md) diff --git a/en/application-dev/reference/arkui-js/js-components-canvas-image.md b/en/application-dev/reference/arkui-js/js-components-canvas-image.md index 8ad046dea4f04309fca88e860adf17f3a561d6ad..32bd1bb59a4e3fe52150b32240a18c1b3ac049ea 100644 --- a/en/application-dev/reference/arkui-js/js-components-canvas-image.md +++ b/en/application-dev/reference/arkui-js/js-components-canvas-image.md @@ -89,7 +89,7 @@ export default { onShow(){ const el =this.$refs.canvas - var ctx = this.$element('drawImage').getContext('2d'); + var ctx =el.getContext('2d'); var img = new Image(); img.src = 'common/images/example.jpg'; img.onload = function() { diff --git a/en/application-dev/reference/arkui-js/js-components-common-methods.md b/en/application-dev/reference/arkui-js/js-components-common-methods.md index 221a5a9de52b56488cf80ad1de5e4dcbc8961db4..3ae0be9a4dde79476c16de605eb4b5cf5574e6a9 100644 --- a/en/application-dev/reference/arkui-js/js-components-common-methods.md +++ b/en/application-dev/reference/arkui-js/js-components-common-methods.md @@ -586,7 +586,7 @@ Obtains the size of the element and its position relative to the window. ## createIntersectionObserver -createIntersectionObserver\(param?: [ObserverParam](#table143341035121917)\):[Observer](#table4506633141711) +createIntersectionObserver\(param?: ObserverParam):Observer Gets notified of the visibility of an element on the current page. diff --git a/en/application-dev/reference/arkui-js/js-components-container-div.md b/en/application-dev/reference/arkui-js/js-components-container-div.md index d898cc4f90ecdb8bcc6cd70208017d033d05949e..75dce6325edf1a515693b4f39445e296a2111c02 100644 --- a/en/application-dev/reference/arkui-js/js-components-container-div.md +++ b/en/application-dev/reference/arkui-js/js-components-container-div.md @@ -290,7 +290,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods.

ScrollOffset

Obtains the scrolling offset of the element content.

-
NOTE:
  • To use this method, overflow must be set to scroll.
+
NOTE:
  • To use this method, overflow must be set to scroll. By default, the scrolling direction is the same as the container layout direction.
@@ -308,6 +308,7 @@ In addition to the methods in [Universal Methods](js-components-common-methods. + **Table 1** ScrollOffset6+ diff --git a/en/application-dev/reference/arkui-ts/Readme-EN.md b/en/application-dev/reference/arkui-ts/Readme-EN.md index 634f77c8f6ced5b6a05c0e23caf97c342da2ef0f..775bd3d067c466e6415a565eaefb15964956c61e 100644 --- a/en/application-dev/reference/arkui-ts/Readme-EN.md +++ b/en/application-dev/reference/arkui-ts/Readme-EN.md @@ -52,17 +52,20 @@ - [Gauge](ts-basic-components-gauge.md) - [Image](ts-basic-components-image.md) - [ImageAnimator](ts-basic-components-imageanimator.md) + - [LoadingProgress](ts-basic-components-loadingprogress.md) - [Marquee](ts-basic-components-marquee.md) - [Progress](ts-basic-components-progress.md) - [QRCode](ts-basic-components-qrcode.md) - [Rating](ts-basic-components-rating.md) - - [Span](ts-basic-components-span.md) + - [Select](ts-basic-components-select.md) - [Slider](ts-basic-components-slider.md) + - [Span](ts-basic-components-span.md) - [Text](ts-basic-components-text.md) - [TextArea](ts-basic-components-textarea.md) - [TextInput](ts-basic-components-textinput.md) - [Toggle](ts-basic-components-toggle.md) - + - [TextClock](ts-basic-components-textclock.md) + - [Container Components](ts-components-container.md) - [AlphabetIndexer](ts-container-alphabet-indexer.md) - [Badge](ts-container-badge.md) @@ -86,29 +89,28 @@ - [Swiper](ts-container-swiper.md) - [Tabs](ts-container-tabs.md) - [TabContent](ts-container-tabcontent.md) - - [Stepper](ts-container-stepper.md) - - [StepperItem](ts-container-stepperitem.md) - + + - [Refresh](ts-container-refresh.md) - [Drawing Components](ts-drawing-components.md) + - [Circle](ts-drawing-components-circle.md) - [Ellipse](ts-drawing-components-ellipse.md) - [Line](ts-drawing-components-line.md) - [Polyline](ts-drawing-components-polyline.md) - [Polygon](ts-drawing-components-polygon.md) - - [Path](ts-drawing-components-path.md) + - [Path](ts-drawing-components-path.md) - [Rect](ts-drawing-components-rect.md) - [Shape](ts-drawing-components-shape.md) - + - [Canvas Components](ts-components-canvas.md) - [Canvas](ts-components-canvas-canvas.md) - [CanvasRenderingContext2D](ts-canvasrenderingcontext2d.md) - [OffscreenCanvasRenderingConxt2D](ts-offscreencanvasrenderingcontext2d.md) - [Lottie](ts-components-canvas-lottie.md) - [Path2D](ts-components-canvas-path2d.md) - - [CanvasGradient](ts-components-canvas-canvasgradient.md) + - [CanvasGradient](ts-components-canvas-canvasgradient.md) - [ImageBitmap](ts-components-canvas-imagebitmap.md) - [ImageData](ts-components-canvas-imagedata.md) - - [Animation](ts-animation.md) - [Attribute Animation](ts-animatorproperty.md) - [Explicit Animation](ts-explicit-animation.md) @@ -126,8 +128,9 @@ - [Custom Dialog box](ts-methods-custom-dialog-box.md) - [Image Cache](ts-methods-image-cache.md) - [Media Query](ts-methods-media-query.md) - - [List Selection Dialog Box](ts-methods-custom-actionsheet.md) + - [List Selection Dialog Box](ts-methods-action-sheet.md) - [Appendix](ts-appendix.md) + - [Built-in Enums](ts-appendix-enums.md) diff --git a/en/application-dev/reference/arkui-ts/figures/refresh.gif b/en/application-dev/reference/arkui-ts/figures/refresh.gif new file mode 100644 index 0000000000000000000000000000000000000000..f7796bdc1286c55b3853d52cf0f81d84cec6e8d4 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/refresh.gif differ diff --git a/en/application-dev/reference/arkui-ts/figures/row.png b/en/application-dev/reference/arkui-ts/figures/row.png index 3b44b9a41cb0fa78afcde81f82e0ad63c90de58d..6bf426a5f019e76b7b3a0953643988690eb67b1e 100644 Binary files a/en/application-dev/reference/arkui-ts/figures/row.png and b/en/application-dev/reference/arkui-ts/figures/row.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/select.png b/en/application-dev/reference/arkui-ts/figures/select.png new file mode 100644 index 0000000000000000000000000000000000000000..2672d45f3ed5685aa6f350c2cade469c065a13af Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/select.png differ diff --git a/en/application-dev/reference/arkui-ts/figures/text_clock.png b/en/application-dev/reference/arkui-ts/figures/text_clock.png new file mode 100644 index 0000000000000000000000000000000000000000..85b17585ac7fbb72297c5757f1b1118c27e7d8c9 Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/text_clock.png differ diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-button.md b/en/application-dev/reference/arkui-ts/ts-basic-components-button.md index 0c017d6aff130f4a59c840646a083283294023cc..8f39a509ef8286766236ff37112df6a4db590729 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-button.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-button.md @@ -9,9 +9,9 @@ The **** component represents a component that can trigger actions. None -## Child Component +## Child Components -This component can contain child components. +This component can contain a single child component. ## APIs diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-select.md b/en/application-dev/reference/arkui-ts/ts-basic-components-select.md new file mode 100644 index 0000000000000000000000000000000000000000..25d73234a372a9e13f9a693e2e834e45d6bf9cda --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-select.md @@ -0,0 +1,72 @@ +# Select + +> ![](public_sys-resources/icon-note.gif) **NOTE** This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component provides a drop-down list box that allows users to select among multiple options. + +## Required Permissions + +None + +## Child Components + +None + +## APIs + +Select(options: Array) + +- `SelectOption` parameters + + | Name| Type| Mandatory| Default Value| Description| + | ------ | ----------------------------------------------- | ---- | ------ | -------------- | + | value | [ResourceStr](../../ui/ts-types.md#ResourceStr) | Yes| - | Value of an option in the drop-down list box.| + | icon | [ResourceStr](../../ui/ts-types.md#ResourceStr) | No| - | Icon of an option in the drop-down list box.| + +## Attributes + +| Name| Type| Default Value| Description| +| ----------------------- | --------------------------------------------------- | ------ | ----------------------------------------------- | +| selected | number | - | Index of the initial selected option in the drop-down list box. The index of the first option is **0**.| +| value | string | - | Text of the drop-down button.| +| font | [Font](../../ui/ts-types.md) | - | Text font of the drop-down button.| +| fontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of the drop-down button.| +| selectedOptionBgColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Background color of the selected option in the drop-down list box.| +| selectedOptionFont | [Font](../../ui/ts-types.md) | - | Text font of the selected option in the drop-down list box.| +| selectedOptionFontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of the selected option in the drop-down list box.| +| optionBgColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Background color of an option in the drop-down list box.| +| optionFont | [Font](../../ui/ts-types.md) | - | Text font of an option in the drop-down list box.| +| optionFontColor | [ResourceColor](../../ui/ts-types.md#ResourceColor) | - | Text color of an option in the drop-down list box.| + +## Events + +| Name| Description| +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| onSelected(callback: (index: number, value?:string) => void)| Invoked when an option in the drop-down list box is selected. **index** indicates the index of the selected option. **value** indicates the value of the selected option.| + +## Example + +``` +@Entry +@Component +struct SliderExample { + build() { + Column() { + Select([{value:'aaa',icon: "/common/1.png"}, + {value:'bbb',icon: "/common/2.png"}, + {value:'ccc',icon: "/common/3.png"}, + {value:'ddd',icon: "/common/4.png"}]) + .selected(2) + .value('TTT') + .font({size: 30, weight:400, family: 'serif', style: FontStyle.Normal }) + .selectedOptionFont({size: 40, weight: 500, family: 'serif', style: FontStyle.Normal }) + .optionFont({size: 30, weight: 400, family: 'serif', style: FontStyle.Normal }) + .onSelected((index:number)=>{ + console.info("Select:" + index) + }) + } + } +} +``` + +![](figures/select.png) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-textclock.md b/en/application-dev/reference/arkui-ts/ts-basic-components-textclock.md new file mode 100644 index 0000000000000000000000000000000000000000..6f23dd45ae12120f7dcec85d26d16383e2b464ab --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-textclock.md @@ -0,0 +1,83 @@ +# TextClock + +> ![](public_sys-resources/icon-note.gif) **NOTE** This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component displays the current system time in text format for different time zones. The time is accurate to seconds. + +## Required Permissions + +None + +## Child Components + +None + +## APIs + +TextClock(options?: {timeZoneOffset?: number, contorller?: TextClockController}) + +- Parameters + + | Name| Type| Mandatory| Default Value| Description| + | -------- | -------- | ---- | ------------------ | ------------------------------------------------------------ | + | timeZoneOffset | number | No| Time zone offset| Sets the time zone offset. The value range is [-14, 12], indicating UTC+12 to UTC-12. A negative value indicates Eastern Standard Time, and a positive value indicates Western Standard Time. For example, **-8** indicates UTC+8. For countries or regions crossing the International Date Line, use -13 (UTC+13) and -14 (UTC+14) to ensure consistent time within the entire country or region.| + | contorller | [TextClockContorller](#TextClockController) | No| null | Binds a controller to control the status of the **** component.| + +## Attributes + +| Name| Type| Default Value| Description| +| ------ | -------- | -------- | ------------------------------------------------------------ | +| format | string | 'hhmmss' | Time format, for example, **yyyy/mm/dd** or **yyyy-mm-dd**. Supported time format strings:
  • yyyy (year)
  • mm (two-letter abbreviated month name)
  • mmm (three-letter abbreviated month name)
  • mmmm (full month name)
  • dd (two-letter abbreviated day of the week)
  • ddd (three-letter abbreviated day of the week)
  • dddd (full day of the week)
  • HH (24-hour format)
  • hh (12-hour format)
  • MM/mm (minute)
  • SS/ss (second)
| + +## TextClockController + +Controller of the **** component, which can be bound to the component for status control. + +| API| Description| +| -------------------------------------------- | ------------------------------------------------------------ | +| start() | Starts the **** component.| +| stop() | Stops the **** component.| + + +## Events + +| Name| Description| +| -------------------------------------------- | ------------------------------------------------------------ | +| onDateChange(event: (value: number) => void) | Triggered when the time changes in seconds at minimum.
value: Unix time stamp, which is the number of milliseconds that have elapsed since the Unix epoch.| + +## Example + +``` +@Entry +@Component +struct Second { + @State accumulateTime: number = 0 + controller: TextClockController = new TextClockController() + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center}) { + Text('current milliseconds is' + this.accumulateTime) + .fontSize(20) + TextClock({timeZoneOffset: -8, controller: this.controller}) + .format('hhmmss') + .onDateChange((value: number) => { + this.accumulateTime = value + }) + .margin(20) + .fontSize(30) + Button("start TextClock") + .margin({ bottom: 10 }) + .onClick(()=>{ + this.controller.start() + }) + Button("stop TextClock") + .onClick(()=>{ + this.controller.stop() + }) + } + .width('100%') + .height('100%') + } +} +``` +![](figures/text_clock.png) diff --git a/en/application-dev/reference/arkui-ts/ts-container-column.md b/en/application-dev/reference/arkui-ts/ts-container-column.md index 5aebfdd7cac87423d8c1494108b354a22bd3c8ae..a1638e11f806aa2ee6291c034d6f96a3b10fac1a 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-column.md +++ b/en/application-dev/reference/arkui-ts/ts-container-column.md @@ -1,134 +1,89 @@ -# Column +# Column ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component lays out child components vertically. -## Required Permissions +The **** component lays out child components vertically. + + +## Required Permissions None -## Child Components - -This component can contain child components. - -## APIs - -Column\(value:\{space?: Length\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

space

-

Length

-

No

-

0

-

Space between any two adjacent child components in the vertical layout.

-
- - -## Attributes - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

alignItems

-

HorizontalAlign

-

Center

-

Alignment mode of child components in the horizontal direction.

-
- -- HorizontalAlign enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Start

-

Aligned with the start edge in the same direction as the language in use.

-

Center

-

Center alignment. This is the default alignment mode.

-

End

-

Aligned with the end edge in the same direction as the language in use.

-
- - -## Example + +## Child Components + +Supported + + +## APIs + +Column(value:{space?: Length}) + + +- Parameters + | Name| Type| Mandatory| Default Value| Description| + | -------- | -------- | -------- | -------- | -------- | + | space | Length | No| 0 | Space between two adjacent child components in the vertical layout.| + + +## Attributes + +| Name| Type| Default Value| Description| +| -------- | -------- | -------- | -------- | +| alignItems | HorizontalAlign | HorizontalAlign.Center | Alignment mode of the child components in the horizontal direction.| +| justifyContent8+ | [FlexAlign](ts-container-flex.md) | FlexAlign.Start | Alignment mode of the child components in the vertical direction.| + +- HorizontalAlign enums + | Name| Description| + | -------- | -------- | + | Start | Aligned with the start edge in the same direction as the language in use.| + | Center | Center aligned. This is the default alignment mode.| + | End | Aligned with the end edge in the same direction as the language in use.| + + + +## Example ``` @Entry @Component struct ColumnExample { build() { - Column({ space: 5 }) { - Text('space').fontSize(9).fontColor(0xCCCCCC).width('90%') - Column({ space: 5 }) { - Column().width('100%').height(50).backgroundColor(0xAFEEEE) - Column().width('100%').height(50).backgroundColor(0x00FFFF) - }.width('90%').height(107).border({ width: 1 }) - - Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Column() { - Column().width('50%').height(50).backgroundColor(0xAFEEEE) - Column().width('50%').height(50).backgroundColor(0x00FFFF) - }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 }) - - Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Column() { - Column().width('50%').height(50).backgroundColor(0xAFEEEE) - Column().width('50%').height(50).backgroundColor(0x00FFFF) - }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 }) + Column() { + Text('space').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column({ space: 5 }) { + Column().width('100%').height(30).backgroundColor(0xAFEEEE) + Column().width('100%').height(30).backgroundColor(0x00FFFF) + }.width('90%').height(100).border({ width: 1 }) + + Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(30).backgroundColor(0xAFEEEE) + Column().width('50%').height(30).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 }) + + Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(30).backgroundColor(0xAFEEEE) + Column().width('50%').height(30).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 }) + + Text('justifyContent(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('30%').height(30).backgroundColor(0xAFEEEE) + Column().width('30%').height(30).backgroundColor(0x00FFFF) + }.height('15%').border({ width: 1 }).justifyContent(FlexAlign.Center) + + Text('justifyContent(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('30%').height(30).backgroundColor(0xAFEEEE) + Column().width('30%').height(30).backgroundColor(0x00FFFF) + }.height('15%').border({ width: 1 }).justifyContent(FlexAlign.End) }.width('100%').padding({ top: 5 }) } } ``` -![](figures/column.gif) - +![zh-cn_image_0000001219982721](figures/Column.png) diff --git a/en/application-dev/reference/arkui-ts/ts-container-refresh.md b/en/application-dev/reference/arkui-ts/ts-container-refresh.md new file mode 100644 index 0000000000000000000000000000000000000000..fefd46e33b5f0f43fe4565882e288b10fa7952f9 --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-container-refresh.md @@ -0,0 +1,80 @@ +# Refresh + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **** component is used to refresh a page through a pull-down gesture. + +## Required Permissions + +None + +## Child Components + +This component supports only one child component. + +## APIs + +Refresh\(value: \{refreshing: boolean, offset?: Length, friction?: number\}\) + +- Parameters + + | Name| Value Type| Mandatory| Default Value| Description| + | -------- | -------- | -------- | -------- | -------- | + | refreshing | boolean | Yes| - | Whether the current component is being refreshed.| + | offset | Length | No| 16 | Distance to the top of the parent component from the **** component that comes to rest after a successful pull-down gesture.| + | friction | number | No| 62 | Coefficient of friction, which indicates the **** component's sensitivity to the pull-down gesture. The value ranges from 0 to 100.
- **0** indicates that the **** component is not sensitive to the pull-down gesture.
- **100** indicates that the **** component is highly sensitive to the pull-down gesture.
- A larger value indicates a more sensitive response of the **** component to the pull-down gesture.| + + + +## Events + + +| Name| Description| +| -------- | -------- | +| onStateChange(callback: (state: RefreshStatus) => void)| Triggered when the refresh status changes.
**state** indicates the refresh status.| +| onRefreshing(callback: () => void)| Triggered when the component enters the refresh state.| + +- RefreshStatus enums + + | Name| Description| + | -------- | -------- | + | Inactive | The component is not pulled down. This is the default value.| + | Drag | The component is being pulled down, but the pulled distance is shorter than the minimum length required to trigger the refresh.| + | OverDrag | The component is being pulled down, and the pulled distance exceeds the minimum length required to trigger the refresh.| + | Refresh | The pull-down ends, and the component rebounds to the minimum length required to trigger the refresh and enters the refresh state.| + | Done | The refresh is complete, and the component returns to the initial state (top).| + + +## Example + +``` +@Entry +@Component +struct RefreshExample { + @State isRefreshing: boolean = false + @State counter: number = 0 + + build() { + Column() { + Refresh({refreshing: this.isRefreshing, offset: 120, friction: 100}) { + Text('Pull Down and refresh: ' + this.counter) + .fontSize(30) + .margin(10) + } + .onStateChange((refreshStatus: RefreshStatus) => { + console.info('Refresh onStatueChange state is ' + refreshStatus) + }) + .onRefreshing(() => { + setTimeout(() => { + this.counter++ + this.isRefreshing = false + }, 1000) + console.log('onRefreshing test') + }) + } + } +} +``` + +![](figures/refresh.gif) diff --git a/en/application-dev/reference/arkui-ts/ts-container-row.md b/en/application-dev/reference/arkui-ts/ts-container-row.md index e25ea9b861af2897ea301d7e6eb2d6cb5055a639..628b9672084d28207535f29c32745d3f4eb23a06 100644 --- a/en/application-dev/reference/arkui-ts/ts-container-row.md +++ b/en/application-dev/reference/arkui-ts/ts-container-row.md @@ -1,106 +1,48 @@ -# Row +# Row ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. -The **** component lays out child components horizontally. -## Required Permissions +The **** component lays out child components horizontally. + + +## Required Permissions None -## Child Components - -This component can contain child components. - -## APIs - -Row\(value:\{space?: Length\}\) - -- Parameters - - - - - - - - - - - - - - - - -

Name

-

Type

-

Mandatory

-

Default Value

-

Description

-

space

-

Length

-

No

-

0

-

Space between any two adjacent child components in the horizontal layout.

-
- - -## Attributes - - - - - - - - - - - - - - -

Name

-

Type

-

Default Value

-

Description

-

alignItems

-

VerticalAlign

-

Center

-

Alignment mode of the child components in the vertical direction.

-
- -- VerticalAlign enums - - - - - - - - - - - - - - - - -

Name

-

Description

-

Top

-

Top aligned.

-

Center

-

Center alignment. This is the default alignment mode.

-

Bottom

-

Bottom aligned.

-
- - -## Example + +## Child Components + +Supported + + +## APIs + +Row(value:{space?: Length}) + +- Parameters + | Name| Type| Mandatory| Default Value| Description| + | -------- | -------- | -------- | -------- | -------- | + | space | Length | No| 0 | Space between two adjacent child components in the horizontal layout.| + + +## Attributes + +| Name| Type| Default Value| Description| +| -------- | -------- | -------- | -------- | +| alignItems | VerticalAlign | VerticalAlign.Center | Alignment mode of the child components in the vertical direction.| +| justifyContent8+ | [FlexAlign](ts-container-flex.md) | FlexAlign.Start | Alignment mode of the child components in the horizontal direction.| + +- VerticalAlign enums + | Name| Description| + | -------- | -------- | + | Top | Top aligned.| + | Center | Center aligned. This is the default alignment mode.| + | Bottom | Bottom aligned.| + + +## Example ``` @Entry @@ -109,26 +51,37 @@ struct RowExample { build() { Column({ space: 5 }) { Text('space').fontSize(9).fontColor(0xCCCCCC).width('90%') - Row({ space: 20 }) { - Row().width(150).height(50).backgroundColor(0xAFEEEE) - Row().width(150).height(50).backgroundColor(0x00FFFF) - }.width(321).height(52).border({ width: 1 }) - - Text('alignItems(Bottom)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Row() { - Row().width('50%').height(50).backgroundColor(0xAFEEEE) - Row().width('50%').height(50).backgroundColor(0x00FFFF) - }.alignItems(VerticalAlign.Bottom).width('90%').height(100).border({ width: 1 }) - - Text('alignItems(Top)').fontSize(9).fontColor(0xCCCCCC).width('90%') - Row() { - Row().width('50%').height(50).backgroundColor(0xAFEEEE) - Row().width('50%').height(50).backgroundColor(0x00FFFF) - }.alignItems(VerticalAlign.Top).width('90%').height(100).border({ width: 1 }) + Row({ space: 5 }) { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').height(107).border({ width: 1 }) + + Text('alignItems(Top)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.alignItems(VerticalAlign.Top).height('15%').border({ width: 1 }) + + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.alignItems(VerticalAlign.Center).height('15%').border({ width: 1 }) + + Text('justifyContent(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.End) + + Text('justifyContent(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.Center) }.width('100%') } } ``` -![](figures/row.png) - +![en_image_0000001174422908](figures/row.png) diff --git a/en/application-dev/reference/arkui-ts/ts-methods-custom-actionsheet.md b/en/application-dev/reference/arkui-ts/ts-methods-action-sheet.md similarity index 100% rename from en/application-dev/reference/arkui-ts/ts-methods-custom-actionsheet.md rename to en/application-dev/reference/arkui-ts/ts-methods-action-sheet.md diff --git a/en/application-dev/security/userauth-guidelines.md b/en/application-dev/security/userauth-guidelines.md index ede673ad7acadde4015c618b567f20ec0d4ddc12..38dc702198546d90925a3b02d2d2d330bdfd1de7 100644 --- a/en/application-dev/security/userauth-guidelines.md +++ b/en/application-dev/security/userauth-guidelines.md @@ -1,65 +1,27 @@ -# User Authentication Development +# User Authentication Development ->**NOTE:** ->This document applies to JS. +## When to Use -## When to Use +OpenHarmony supports 2D and 3D facial recognition that can be used for identity authentication during device unlocking, application login, and payment. -HarmonyOS supports 2D and 3D facial recognition that can be used for identity authentication during device unlocking, application login, and payment. - -## Available APIs +## Available APIs The **userIAM\_userAuth** module provides methods for checking the support for biometric authentication, and performing and canceling authentication. You can perform authentication based on biometric features such as facial characteristics. Before performing biometric authentication, check whether your device supports this capability, including the authentication type, security level, and whether local authentication is used. If biometric authentication is not supported, consider using another authentication type. The following table lists methods in the APIs available for biometric authentication. **Table 1** Methods available for biometric authentication - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Method

-

Description

-

getAuthenticator(): Authenticator

-

Obtains an Authenticator object for user authentication. 6+

-

Obtains an Authenticator object to check the device's capability of user authentication, perform or cancel user authentication, and obtain the tips generated in the authentication process. 7+

-

checkAvailability(type: AuthType, level: SecureLevel): number

-

Checks whether the device supports the specified authentication type and security level.

-

execute(type: AuthType, level: SecureLevel, callback: AsyncCallback<number>): void

-

Performs user authentication and returns the authentication result using an asynchronous callback.

-

execute(type: AuthType, level: SecureLevel): Promise<number>

-

Performs user authentication and returns the authentication result using a promise.

-

cancel(): void

-

Cancels the current authentication.

-

on(type: "tip", callback: Callback<Tip>): void

-

Subscribes to the events of the specified type.

-

off(type: "tip", callback?: Callback<Tip>): void

-

Unsubscribes from the events of the specified type.

-
- -## How to Develop +| Method | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| getAuthenticator(): Authenticator | Obtains an **Authenticator** object for user authentication. 6+
Obtains an **Authenticator** object to check the device's capability of user authentication, perform or cancel user authentication, and obtain the tips generated in the authentication process. 7+ | +| checkAvailability(type: AuthType, level: SecureLevel): number | Checks whether the device supports the specified authentication type and security level. | +| execute(type: AuthType, level: SecureLevel, callback: AsyncCallback\): void | Performs user authentication and returns the authentication result using an asynchronous callback. | +| execute(type: AuthType, level: SecureLevel): Promise\ | Performs user authentication and returns the authentication result using a promise. | +| cancel(): void | Cancels the current authentication. | +| on(type: "tip", callback: Callback\): void | Subscribes to the events of the specified type. | +| off(type: "tip", callback?: Callback\): void | Unsubscribes from the events of the specified type. | + + +## How to Develop Before starting the development, make the following preparations: @@ -88,7 +50,7 @@ The development procedure is as follows: } ``` -3. \(Optional\) Subscribe to tip information. The sample code is as follows: +3. \(Optional\) Subscribe to tip information. The sample code is as follows: ``` let authenticator = userIAM_userAuth.getAuthenticator(); @@ -112,7 +74,7 @@ The development procedure is as follows: }); ``` -5. \(Optional\) Unsubscribe from tip information if [you have subscribed to tip information](#li109311114115111)you have subscribed to tip information. +5. \(Optional\) Unsubscribe from tip information if you have subscribed to tip information you have subscribed to tip information. ``` let authenticator = userIAM_userAuth.getAuthenticator(); @@ -138,4 +100,3 @@ The development procedure is as follows: } ``` - diff --git a/en/application-dev/security/userauth-overview.md b/en/application-dev/security/userauth-overview.md index 5bd678a630115cdb26686ce75945e45f90cdca39..f3e6a9a9042ad36f0111f3679f0084be4c6fc352 100644 --- a/en/application-dev/security/userauth-overview.md +++ b/en/application-dev/security/userauth-overview.md @@ -1,22 +1,22 @@ -# User Authentication Overview +# User Authentication Overview OpenHarmony provides biometric recognition that can be used for identity authentication in device unlocking, application login, and payment. OpenHarmony provides both 2D and 3D facial recognition. You can provide either or both of them on your device based on the hardware and technology applied on the device. 3D facial recognition is superior to 2D facial recognition in terms of recognition rate and anti-counterfeiting capability. However, you can use 3D facial recognition only if your device supports capabilities such as 3D structured light and 3D Time of Flight \(TOF\). -## Basic Concepts +## Basic Concepts Biometric recognition \(also known as biometric authentication\) uses optical, acoustical, and biological sensors, as well as the biological statistics mechanism to identify individuals. Facial recognition is a biometric recognition technology that identifies individuals based on facial characteristics. A camera is used to collect images or video streams that contain human faces, and automatically detect, track, and recognize the human faces. -## Working Principles +## Working Principles Facial recognition establishes a secure channel between a camera and a trusted execution environment \(TEE\). Through this channel, face image data is transmitted to the TEE. This protects against any attack from the rich execution environment \(REE\) as the face image data cannot be obtained from the REE. The face image collection, characteristic extraction, alive human body detection, and characteristic comparison are all completed in the TEE. The TEE implements security isolation based on the trust zone. The external face framework only initiates face authentication and processes authentication results. It does not process the human face data. Facial characteristics are stored in the TEE, which uses strong cryptographic algorithms to encrypt and protect the integrity of facial characteristics. The collected and stored facial characteristics will not be transferred out of the TEE without user authorization. This ensures that system or third-party applications cannot obtain facial characteristics, or send or back them up to any external storage medium. -## Limitations and Constraints +## Limitations and Constraints - OpenHarmony only supports facial recognition and local authentication, and does not support an authentication UI. - To use biometric recognition, a device must have a camera with a face image pixel greater than 100x100. diff --git a/en/application-dev/ui/Readme-EN.md b/en/application-dev/ui/Readme-EN.md index 8f16c2a59a777fe617d85df75fca4900a263b630..2a353af88ae135779578dc78e4f79e77a1518114 100755 --- a/en/application-dev/ui/Readme-EN.md +++ b/en/application-dev/ui/Readme-EN.md @@ -1,142 +1,111 @@ # UI -- [ ArkUI](ui-arkui.md) - - [JavaScript-based Web-Like Development Paradigm](ui-arkui-js.md) - - [Overview](ui-js-overview.md) - - [Framework](js-framework.md) - - [File Organization](js-framework-file.md) - - ["js" Tag](js-framework-js-tag.md) - - [app.js](js-framework-js-file.md) - - [Syntax](js-framework-syntax.md) - - [HML](js-framework-syntax-hml.md) - - [CSS](js-framework-syntax-css.md) - - [JavaScript](js-framework-syntax-js.md) - - - [Lifecycle](js-framework-lifecycle.md) - - [Resource Limitations and Access](js-framework-resource-restriction.md) - - [Multi-Language Capability](js-framework-multiple-languages.md) - - - [Building the UI](ui-js-building-ui.md) - - [Component Overview](ui-js-building-ui-component.md) - - [Building the Layout](ui-js-building-ui-layout.md) - - [Layout Description](ui-js-building-ui-layout-intro.md) - - [Adding Title and Paragraph Text](ui-js-building-ui-layout-text.md) - - [Adding an Image](ui-js-building-ui-layout-image.md) - - [Adding a Comment](ui-js-building-ui-layout-comment.md) - - [Adding a Container](ui-js-building-ui-layout-external-container.md) - - - [Adding Interactions](ui-js-building-ui-interactions.md) - - [Developing Animations](ui-js-building-ui-animation.md) - - [Defining Events](ui-js-building-ui-event.md) - - [Defining Page Routes](ui-js-building-ui-routes.md) - - - [Common Component Development Guidelines](ui-js-common-components.md) - - [Text](ui-js-components-text.md) - - [Input](ui-js-components-input.md) - - [Button](ui-js-components-button.md) - - [List](ui-js-components-list.md) - - [Picker](ui-js-components-picker.md) - - [Dialog](ui-js-components-dialog.md) - - [Form](ui-js-components-form.md) - - [Stepper](ui-js-components-stepper.md) - - [Tabs](ui-js-component-tabs.md) - - [Image](ui-js-components-images.md) - - - [Animation Development Guidelines](ui-js-animate.md) - - [CSS Animation](ui-js-animate-css.md) - - [Defining Attribute Style Animations](ui-js-animate-attribute-style.md) - - [Defining Animations with the transform Attribute](ui-js-animate-transform.md) - - [Defining Animations with the background-position Attribute](ui-js-animate-background-position-style.md) - - - [JS Animation](ui-js-animate-javascript.md) - - [Component Animation](ui-js-animate-component.md) - - [Interpolator Animation](ui-js-animate-interpolator.md) - - [Animation Effect](ui-js-animate-dynamic-effects.md) - - [Animation Frame](ui-js-animate-frame.md) - - - [Custom Components](ui-js-custom-components.md) - - - [TypeScript-based Declarative Development Paradigm](ui-arkui-ts.md) - - [Overview](ui-ts-overview.md) - - [Framework Overview](ts-framework.md) - - [File Organization](ts-framework-file.md) - - [Directory Structure](ts-framework-directory.md) - - [Rules for Accessing Application Code Files](ts-framework-file-access-rules.md) - - - ["js" Tag](ts-framework-js-tag.md) - - [Resource Access](ts-resource-access.md) - - [Accessing Application Resources](ts-application-resource-access.md) +- JavaScript-based Web-Like Development Paradigm + - [Overview](ui-js-overview.md) + - Framework + - [File Organization](js-framework-file.md) + - ["js" Tag](js-framework-js-tag.md) + - [app.js](js-framework-js-file.md) + - Syntax + - [HML](js-framework-syntax-hml.md) + - [CSS](js-framework-syntax-css.md) + - [JavaScript](js-framework-syntax-js.md) + - [Lifecycle](js-framework-lifecycle.md) + - [Resource Limitations and Access](js-framework-resource-restriction.md) + - [Multi-Language Capability](js-framework-multiple-languages.md) + - Building the UI + - [Component Overview](ui-js-building-ui-component.md) + - Building the Layout + - [Layout Description](ui-js-building-ui-layout-intro.md) + - [Adding Title and Paragraph Text](ui-js-building-ui-layout-text.md) + - [Adding an Image](ui-js-building-ui-layout-image.md) + - [Adding a Comment](ui-js-building-ui-layout-comment.md) + - [Adding a Container](ui-js-building-ui-layout-external-container.md) + - [Adding Interactions](ui-js-building-ui-interactions.md) + - [Developing Animations](ui-js-building-ui-animation.md) + - [Defining Events](ui-js-building-ui-event.md) + - [Defining Page Routes](ui-js-building-ui-routes.md) + - Common Component Development Guidelines + - [Text](ui-js-components-text.md) + - [Input](ui-js-components-input.md) + - [Button](ui-js-components-button.md) + - [List](ui-js-components-list.md) + - [Picker](ui-js-components-picker.md) + - [Dialog](ui-js-components-dialog.md) + - [Form](ui-js-components-form.md) + - [Stepper](ui-js-components-stepper.md) + - [Tabs](ui-js-component-tabs.md) + - [Image](ui-js-components-images.md) + - Animation Development Guidelines + - CSS Animation + - [Defining Attribute Style Animations](ui-js-animate-attribute-style.md) + - [Defining Animations with the transform Attribute](ui-js-animate-transform.md) + - [Defining Animations with the background-position Attribute](ui-js-animate-background-position-style.md) + - JS Animation + - [Component Animation](ui-js-animate-component.md) + - Interpolator Animation + - [Animation Effect](ui-js-animate-dynamic-effects.md) + - [Animation Frame](ui-js-animate-frame.md) + - [Custom Components](ui-js-custom-components.md) +- TypeScript-based Declarative Development Paradigm + - [Overview](ui-ts-overview.md) + - Framework Overview + - File Organization + - [Directory Structure](ts-framework-directory.md) + - [Rules for Accessing Application Code Files](ts-framework-file-access-rules.md) + - ["js" Tag](ts-framework-js-tag.md) + - Resource Access - [Media Resource Types](ts-media-resource-type.md) - - - [Pixel Units](ts-pixel-units.md) - - [Types](ts-types.md) - - - [Declarative Syntax](ts-declarative-syntax.md) - - [Overview](ts-syntax-intro.md) - - [General UI Description Specifications](ts-general-ui-description-specifications.md) - - [Basic Concepts](ts-general-ui-concepts.md) - - [Declarative UI Description Specifications](ts-declarative-ui-description-specifications.md) - - [Parameterless Configuration](ts-parameterless-configuration.md) - - [Configuration with Mandatory Parameters](ts-configuration-with-mandatory-parameters.md) - - [Attribution Configuration](ts-attribution-configuration.md) - - [Event Configuration](ts-event-configuration.md) - - [Child Component Configuration](ts-child-component-configuration.md) - - - [Componentization](ts-component-based.md) - - [@Component](ts-component-based-component.md) - - [@Entry](ts-component-based-entry.md) - - [@Preview](ts-component-based-preview.md) - - [@Builder](ts-component-based-builder.md) - - [@Extend](ts-component-based-extend.md) - - [@CustomDialog](ts-component-based-customdialog.md) - - - [About UI State Management](ts-ui-state-management.md) - - [Basic Concepts](ts-ui-state-mgmt-concepts.md) - - [Managing Component States](ts-managing-component-states.md) - - [@State](ts-component-states-state.md) - - [@Prop](ts-component-states-prop.md) - - [@Link](ts-component-states-link.md) - - - [Managing Application States](ts-managing-application-states.md) - - [APIs](ts-managing-application-states-apis.md) - - [AppStorage](ts-application-states-appstorage.md) - - [PersistentStorage](ts-application-states-apis-persistentstorage.md) - - [Environment](ts-application-states-apis-environment.md) - - - [Synchronization Between AppStorage and Components](ts-application-states-storagelink-storageprop.md) - - - [Managing Other States](ts-managing-other-states.md) - - [@observed and @objectLink](ts-other-states-observed-objectlink.md) - - [@Consume and @Provide](ts-other-states-consume-provide.md) - - [@Watch](ts-other-states-watch.md) - - - [About Rendering Control Syntax](ts-rending-control-syntax.md) - - [if/else](ts-rending-control-syntax-if-else.md) - - [ForEach](ts-rending-control-syntax-foreach.md) - - [LazyForEach](ts-rending-control-syntax-lazyforeach.md) - - - [About @Component](ts-a-deep-dive-into-component.md) - - [build Function](ts-function-build.md) - - [Custom Component Initialization](ts-custom-component-initialization.md) - - [Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md) - - [Example: Component Creation and Re-Initialization](ts-component-creation-re-initialization.md) - - - [About Syntactic Sugar](ts-syntactic-sugar.md) - - [@Decorator](ts-syntactic-sugar-decorator.md) - - [Chain Call](ts-syntactic-sugar-chaining.md) - - [struct](ts-syntactic-sugar-struct.md) - - [Instantiating a struct Without the new Keyword](ts-instantiating-a-struct-without-new-keyword.md) - - [Using a Separate Line for New Component](ts-using-a-separate-line-for-new-component.md) - - [Restrictions on Using TypeScript for Generators](ts-restrictions-for-generators.md) - - - [Experiencing the Declarative UI](ui-ts-experiencing-declarative-ui.md) - - [Creating a Declarative UI Project](ui-ts-creating-project.md) - - [Getting to Know Components](ui-ts-components.md) - - [Creating a Simple Page](ui-ts-creating-simple-page.md) - - - [Defining Page Layout and Connection](ui-ts-page-layout-connections.md) - - [Building a Food Data Model](ui-ts-building-data-model.md) - - [Building a Food Category List Layout](ui-ts-building-category-list-layout.md) - - [Building a Food Category Grid Layout](ui-ts-building-category-grid-layout.md) - - [Implementing Page Redirection and Data Transmission](ui-ts-page-redirection-data-transmission.md) + - [Pixel Units](ts-pixel-units.md) + - [Types](ts-types.md) + - Declarative Syntax + - [Overview](ts-syntax-intro.md) + - General UI Description Specifications + - [Basic Concepts](ts-general-ui-concepts.md) + - Declarative UI Description Specifications + - [Parameterless Configuration](ts-parameterless-configuration.md) + - [Configuration with Mandatory Parameters](ts-configuration-with-mandatory-parameters.md) + - [Attribution Configuration](ts-attribution-configuration.md) + - [Event Configuration](ts-event-configuration.md) + - [Child Component Configuration](ts-child-component-configuration.md) + - Componentization + - [@Component](ts-component-based-component.md) + - [@Entry](ts-component-based-entry.md) + - [@Preview](ts-component-based-preview.md) + - [@Builder](ts-component-based-builder.md) + - [@Extend](ts-component-based-extend.md) + - [@CustomDialog](ts-component-based-customdialog.md) + - About UI State Management + - [Basic Concepts](ts-ui-state-mgmt-concepts.md) + - Managing Component States + - [@State](ts-component-states-state.md) + - [@Prop](ts-component-states-prop.md) + - [@Link](ts-component-states-link.md) + - Managing Application States + - [AppStorage](ts-application-states-appstorage.md) + - [PersistentStorage](ts-application-states-apis-persistentstorage.md) + - [Environment](ts-application-states-apis-environment.md) + - Managing Other States + - [@observed and @objectLink](ts-other-states-observed-objectlink.md) + - [@Consume and @Provide](ts-other-states-consume-provide.md) + - [@Watch](ts-other-states-watch.md) + - About Rendering Control Syntax + - [if/else](ts-rending-control-syntax-if-else.md) + - [ForEach](ts-rending-control-syntax-foreach.md) + - [LazyForEach](ts-rending-control-syntax-lazyforeach.md) + - About @Component + - [build Function](ts-function-build.md) + - [Custom Component Initialization](ts-custom-component-initialization.md) + - [Custom Component Lifecycle Callbacks](ts-custom-component-lifecycle-callbacks.md) + - [Example: Component Creation and Re-Initialization](ts-component-creation-re-initialization.md) + - [Syntactic Sugar](ts-syntactic-sugar.md) + - Experiencing the Declarative UI + - [Creating a Declarative UI Project](ui-ts-creating-project.md) + - [Getting to Know Components](ui-ts-components.md) + - [Creating a Simple Page](ui-ts-creating-simple-page.md) + - Defining Page Layout and Connection + - [Building a Food Data Model](ui-ts-building-data-model.md) + - [Building a Food Category List Layout](ui-ts-building-category-list-layout.md) + - [Building a Food Category Grid Layout](ui-ts-building-category-grid-layout.md) + - [Implementing Page Redirection and Data Transmission](ui-ts-page-redirection-data-transmission.md) diff --git a/en/application-dev/ui/ts-application-resource-access.md b/en/application-dev/ui/ts-application-resource-access.md deleted file mode 100644 index 15c34218bba34e782e278969adce902a9996bb7f..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-application-resource-access.md +++ /dev/null @@ -1,184 +0,0 @@ -# Accessing Application Resources - -## Resource Definition - -Application resources are defined by in the project's **resources** directory, which is organized as follows: - -- Level-1: **base** sub-directory, qualifiers sub-directories, and **rawfile** sub-directory - - The **base** sub-directory is a default directory. If no qualifiers sub-directories in the **resources** directory of the application match the device status, the resource file in the **base** sub-directory will be automatically referenced. - - You need to create qualifiers sub-directories on your own. The name of a qualifiers sub-directory consists of one or more qualifiers that represent the application scenarios or device characteristics, covering the mobile country code \(MCC\), mobile network code \(MNC\), language, script, country or region, screen orientation, device type, color mode, and screen density. The qualifiers are separated using underscores \(\_\) or hyphens \(-\). - - When the resources in the **rawfile** sub-directory are referenced, resource files will not be matched based on the device status. You can directly store resource files in the **rawfile** sub-directory. - -- Level-2: resource sub-directories - - Resource sub-directories store basic elements such as character strings, colors, and floating point numbers, and resource files such as media files. - - Supported files and resource types are listed in the table below: - - - - - - - - - - - - - - - - - - - - - - -

File Name

-

Resource Type

-

color.json

-

Color resource.

-

float.json

-

Resources such as spacing, rounded corners, and fonts.

-

string.json

-

String resource.

-

plural.json

-

String resource.

-

media directory

-

Image resource.

-
- - - -## Referencing Resources - -To reference an application resource in a project, use the **"$r\('app.type.name'\)"** format. **app** indicates the resource defined in the **resources** directory of the application. **type** indicates the resource type \(or the location where the resource is stored\). The value can be **color**, **float**, **string**, **plural**, or **media**. **name** indicates the resource name, which you set when defining the resource. - -When referencing resources in the **rawfile** sub-directory, use the **"$rawfile\('filename'\)"** format. Currently, **$rawfile** allows only the **** component to reference image resources. In the format, **filename** indicates the relative path of a file in the **rawfile** directory, and the file name must contain the file name extension. Note that the relative path cannot start with a slash \(/\). - -## Example - -Some custom resources in the **base** sub-directory are as follows: - -``` - resources - ├─ base - │ ├─ element - │ │ ├─ color.json - │ │ ├─ string.json - │ │ └─ float.json - │ └─ media - │ └─ my_background_image.png - └─ rawfile - ├─ test.png - └─ newDir - └─ newTest.png -``` - -The content of the **color.json** file is as follows: - -``` -{ - "color": [ - { - "name": "color_hello", - "value": "#ffff0000" - }, - { - "name": "color_world", - "value": "#ff0000ff" - } - ] -} -``` - -The content of the **float.json** file is as follows: - -``` -{ - "float":[ - { - "name":"font_hello", - "value":"28.0fp" - }, - { - "name":"font_world", - "value":"20.0fp" - } - ] -} -``` - -The content of the **string.json** file is as follows: - -``` -{ - "string":[ - { - "name":"string_hello", - "value":"Hello" - }, - { - "name":"string_world", - "value":"World" - }, - { - "name":"message_arrive", - "value":"We will arrive at %s." - } - ] -} -``` - -The content of the **plural.json** file is as follows: - -``` -{ - "plural":[ - { - "name":"eat_apple", - "value":[ - { - "quantity":"one", - "value":"%d apple" - }, - { - "quantity":"other", - "value":"%d apples" - } - ] - } - ] -} -``` - -In the **ets** file, you can use the resources defined in the **resources** directory. - -``` -Text($r('app.string.string_hello')) - .fontColor($r('app.color.color_hello')) - .fontSize($r('app.float.font_hello')) -} - -Text($r('app.string.string_world')) - .fontColor($r('app.color.color_world')) - .fontSize($r('app.float.font_world')) -} - -Text($r('app.string.message_arrive', "five of the clock")) // Reference string resources. The second parameter of $r is used to replace %s. - .fontColor($r('app.color.color_hello')) - .fontSize($r('app.float.font_hello')) -} - -Text($r('app.plural.eat_apple', 5, 5)) // Reference plural resources. The first parameter specifies the plural resource, and the second parameter specifies the number of plural resources. The third number indicates the substitute of %d. - .fontColor($r('app.color.color_world')) - .fontSize($r('app.float.font_world')) -} - -Image($r(?app.media.my_background_image creation)) // Reference media resources. - -Image($rawfile( Femaletest.png loaded)) // Reference an image in the rawfile directory. - -Image($rawfile(newDir/newTest.png loaded)) // Reference an image in the rawfile directory. -``` - diff --git a/en/application-dev/ui/ts-application-states-storagelink-storageprop.md b/en/application-dev/ui/ts-application-states-storagelink-storageprop.md deleted file mode 100644 index c2c4f351939e0e85e419bd666c4c781c5e4d28b3..0000000000000000000000000000000000000000 --- a/en/application-dev/ui/ts-application-states-storagelink-storageprop.md +++ /dev/null @@ -1,54 +0,0 @@ -# Synchronization Between AppStorage and Components - -In [Managing Component States](ts-component-states-state.md), we have defined how to synchronize the state variables of the child components with the **@State** decorated variables in the parent component or ancestor component, including **@Prop**, **@Link**, and **@Consume**. - -In this section, we'll describe how to synchronize component variables with the **AppStorage** through the **@StorageLink** and **@StorageProp** decorators. - -## @StorageLink Decorator - -Two-way data binding can be established between components and the **AppStorage** through state variables decorated by **@StorageLink\(_key_\)**. Wherein, **key** is the attribute key value in the **AppStorage**. When a component containing the **@StorageLink** decorated variable is created, the variable is initialized using the value in the **AppStorage**. Changes made to this variable in the component will be first synchronized to the **AppStorage**, and then to other bound instances, such as **PersistentStorage** or other bound UI components. - -## @StorageProp Decorator - -One-way data binding can be established between components and the **AppStorage** through state variables decorated by **@StorageProp\(_key_\)**. Wherein, **key** is the attribute key value in the **AppStorage**. When a component containing the **StorageProp** decorated variable is created, the variable is initialized using the value in the **AppStorage**. The change to the attribute value in the **AppStorage** will cause the bound UI component to update the state. - -## Example - -``` -let varA = AppStorage.Link('varA') -let envLang = AppStorage.Prop('languageCode') - -@Entry -@Component -struct ComponentA { - @StorageLink('varA') varA: number = 2 - @StorageProp('languageCode') lang: string = 'en' - private label: string = 'count' - - private aboutToAppear() { - this.label = (this.lang === 'en') ? 'Number' : 'Count' - } - - build() { - Row({ space: 20 }) { - - Button(`${this.label}: ${this.varA}`) - .onClick(() => { - AppStorage.Set('varA', AppStorage.Get('varA') + 1) - }) - Button(`lang: ${this.lang}`) - .onClick(() => { - if (this.lang === 'zh') { - AppStorage.Set('languageCode', 'en') - } else { - AppStorage.Set('languageCode', 'en') - } - this.label = (this.lang === 'en') ? 'Number' : 'Count' - }) - } - } -} -``` - -Each time the user clicks the **Count** button, the value of **this.varA** will increase by 1. This variable is synchronized with **varA** in the **AppStorage**. Each time the user clicks the language icon, the value of **languageCode** in the **AppStorage** will be changed, and the change will be synchronized to the **this.lang** variable. - diff --git a/en/application-dev/ui/ts-types.md b/en/application-dev/ui/ts-types.md index b9882c03421a34ac5196a24c54400d80baddf15c..3e428539f04bf0a9f122c76e02c41ce30d0916d2 100644 --- a/en/application-dev/ui/ts-types.md +++ b/en/application-dev/ui/ts-types.md @@ -2,58 +2,58 @@ ## Length Type -| Name| Type| Description| +| Name| Type| Description| | -------- | -------- | -------- | -| Length | string \| number | Length unit. If the input is a number, use **vp**. If the input is a string, explicitly specify the unit, for example, **'10px'**, or specify the length in percentage, for example, **'100%'**.| +| Length | string \| number | Length unit. If the input is a number, use **vp**. If the input is a string, explicitly specify the unit, for example, **'10px'**, or specify the length in percentage, for example, **'100%'**.| ## Angle Type -| Name| Type| Description| +| Name| Type| Description| | -------- | -------- | -------- | -| Angle | string \| number | Angle unit. If the input is a number, use **deg**. If the input is a string, explicitly specify the unit, which can be either of the following:
- deg, as in **'100deg'**
- rad, as in **'3.14rad'** | +| Angle | string \| number | Angle unit. If the input is a number, use **deg**. If the input is a string, explicitly specify the unit, which can be either of the following:
- deg, as in **'100deg'**
- rad, as in **'3.14rad'** | ## Point Type -| Name| Type| Description| +| Name| Type| Description| | -------- | -------- | -------- | -| Point | [Length, Length] | Coordinates of a point. The first value is the x-axis coordinate, and the second value is the y-axis coordinate.| +| Point | [Length, Length] | Coordinates of a point. The first value is the x-axis coordinate, and the second value is the y-axis coordinate.| ## Color Type The **Color** used by the component attribute method is described as follows: -| Name| Type| Description| +| Name| Type| Description| | -------- | -------- | -------- | -| Color | string \| number \| Color | Color information. If the input is a string, use **rgb** or **rgba** to specify the color. If the input is a number, use Hex format to specify the color. If the input is a **Color" enum, use a color value to specify the color.
- 'rgb(255, 255, 255)'
- 'rgba(255, 255, 255, 1.0)'
- Hex format: 0xrrggbb, 0xaarrggbb, '\#FFFFFF'
- Enum: Color.Black, Color.White| +| Color | string \| number \| Color | Color information. If the input is a string, use **rgb** or **rgba** to specify the color. If the input is a number, use Hex format to specify the color. If the input is a **Color" enum, use a color value to specify the color.
- 'rgb(255, 255, 255)'
- 'rgba(255, 255, 255, 1.0)'
- Hex format: 0xrrggbb, 0xaarrggbb, '\#FFFFFF'
- Enum: Color.Black, Color.White| The supported **Color** enums are described as follows: -| Color| Value| Illustration| +| Color| Value| Illustration| | -------- | -------- | -------- | -| Black | 0x000000 | ![en-us_image_0000001219864153](figures/en-us_image_0000001219864153.png) | -| Blue | 0x0000ff | ![en-us_image_0000001174104404](figures/en-us_image_0000001174104404.png) | -| Brown | 0xa52a2a | ![en-us_image_0000001219744201](figures/en-us_image_0000001219744201.png) | -| Gray | 0x808080 | ![en-us_image_0000001174264376](figures/en-us_image_0000001174264376.png) | -| Green | 0x008000 | ![en-us_image_0000001174422914](figures/en-us_image_0000001174422914.png) | -| Orange | 0xffa500 | ![en-us_image_0000001219662661](figures/en-us_image_0000001219662661.png) | -| Pink | 0xffc0cb | ![en-us_image_0000001219662663](figures/en-us_image_0000001219662663.png) | -| Red | 0xff0000 | ![en-us_image_0000001219662665](figures/en-us_image_0000001219662665.png) | -| White | 0xffffff | ![en-us_image_0000001174582866](figures/en-us_image_0000001174582866.png) | -| Yellow | 0xffff00 | ![en-us_image_0000001174582864](figures/en-us_image_0000001174582864.png) | +| Black | 0x000000 | ![en-us_image_0000001219864153](figures/en-us_image_0000001219864153.png) | +| Blue | 0x0000ff | ![en-us_image_0000001174104404](figures/en-us_image_0000001174104404.png) | +| Brown | 0xa52a2a | ![en-us_image_0000001219744201](figures/en-us_image_0000001219744201.png) | +| Gray | 0x808080 | ![en-us_image_0000001174264376](figures/en-us_image_0000001174264376.png) | +| Green | 0x008000 | ![en-us_image_0000001174422914](figures/en-us_image_0000001174422914.png) | +| Orange | 0xffa500 | ![en-us_image_0000001219662661](figures/en-us_image_0000001219662661.png) | +| Pink | 0xffc0cb | ![en-us_image_0000001219662663](figures/en-us_image_0000001219662663.png) | +| Red | 0xff0000 | ![en-us_image_0000001219662665](figures/en-us_image_0000001219662665.png) | +| White | 0xffffff | ![en-us_image_0000001174582866](figures/en-us_image_0000001174582866.png) | +| Yellow | 0xffff00 | ![en-us_image_0000001174582864](figures/en-us_image_0000001174582864.png) | ## ColorStop Type **ColorStop** is used to describe the progressive color stop. -| Name| Type| Description| +| Name| Type| Description| | -------- | -------- | -------- | -| ColorStop | [Color, number] | Type of the progressive color stop. The first parameter specifies the color value, and the second parameter specifies the ratio of 0 to 1.| +| ColorStop | [Color, number] | Type of the progressive color stop. The first parameter specifies the color value, and the second parameter specifies the ratio of 0 to 1.| ## Resource Type @@ -72,23 +72,23 @@ You can use **$r** or **$rawfile** to create a **Resource** object. For details, - $rawfile('filename') **filename**: name of the file in **resources/rawfile** of the project. -| Name| Type| Description| +| Name| Type| Description| | -------- | -------- | -------- | -| Resource | {
readonly id: [number];
readonly type: [number];
readonly params?: any[];
} | **id**: resource ID.
**type**: resource type (enumerated value).
**params**: optional parameters.
After a **Resource** object is created using **$r** or **$rawfile**, modifying attribute values of the object is prohibited.| +| Resource | {
readonly id: [number];
readonly type: [number];
readonly params?: any[];
} | **id**: resource ID.
**type**: resource type (enumerated value).
**params**: optional parameters.
After a **Resource** object is created using **$r** or **$rawfile**, modifying attribute values of the object is prohibited.| ## ResourceStr8+ -| Name| Type| Description| +| Name| Type| Description| | -------- | -------- | -------- | -| ResourceStr | string \| [Resource](#resource type)| Resource string.| +| ResourceStr | string \| [Resource](#ResourceType) | Resource string.| ## Resource Color8+ -| Name| Type| Description| +| Name| Type| Description| | -------- | -------- | -------- | -| ResourceColor | Color \| number \| string \| [Resource](#resource type)| Resource color.| +| ResourceColor | Color \| number \| string \| [Resource](#ResourceType) | Resource color.| ## Custom Builder8+ diff --git a/en/application-dev/ui/ui-ts-creating-project.md b/en/application-dev/ui/ui-ts-creating-project.md index 57482cce585951a02a62e25b765a38d2eac2de57..06eaa9f60525e7638535adc21a0239733e1eb557 100644 --- a/en/application-dev/ui/ui-ts-creating-project.md +++ b/en/application-dev/ui/ui-ts-creating-project.md @@ -61,8 +61,7 @@ Before creating a project, you need to install DevEco Studio. For details, see ![](figures/en-us_image_0000001148858818.png) - Before the installation, you must configure an application signature. For details, see [Configuring the OpenHarmony App Signature](https://gitee.com/openharmony/docs/blob/master/en/application-dev/quick-start/configuring-the-openharmony-app-signature.md). After the installation is complete, click the **Run** icon on the screen to open the application. **Hello World** is displayed in the center of the screen. + Before the installation, you must configure an application signature. For details, see [Configuring the OpenHarmony App Signature](../quick-start/configuring-openharmony-app-signature.md). After the installation is complete, click the **Run** icon on the screen to open the application. **Hello World** is displayed in the center of the screen. ![](figures/en-us_image_0000001158896538.png) - diff --git a/en/application-dev/usb/usb-guidelines.md b/en/application-dev/usb/usb-guidelines.md index caa2c920c7417ffd723dac3acfc43cc80430a2e8..1c7aa85a9c52a07e5761e1df52fc17c7eb15e05b 100644 --- a/en/application-dev/usb/usb-guidelines.md +++ b/en/application-dev/usb/usb-guidelines.md @@ -6,7 +6,7 @@ In Host mode, you can obtain the list of connected devices, enable or disable th ## APIs -The OpenHarmony USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management. +The USB service provides the following functions: query of USB device list, bulk data transfer, control transfer, and access permission management. The following table lists the USB APIs currently available. For details, see the _API Reference_. diff --git a/en/application-dev/usb/usb-overview.md b/en/application-dev/usb/usb-overview.md index f2304ed3b7d07d67642a49622a8769c8c9565e09..51636403c0d18197e2a59cc047eb38e2aaf95c7b 100644 --- a/en/application-dev/usb/usb-overview.md +++ b/en/application-dev/usb/usb-overview.md @@ -2,7 +2,7 @@ ## Basic Concepts -The USB service in OpenHarmony is an abstraction of underlying hardware-based USB devices. Your application can access the USB devices via the USB service. With the APIs provided by the USB service, you can obtain the list of connected USB devices, manage device access permissions, and perform data transfer or control transfer between the host and connected devices. +The USB service is an abstraction of underlying hardware-based USB devices. Your application can access the USB devices via the USB service. With the APIs provided by the USB service, you can obtain the list of connected USB devices, manage device access permissions, and perform data transfer or control transfer between the host and connected devices. ## Working Principles diff --git a/en/application-dev/webgl/figures/en-us_image_0000001238544451.png b/en/application-dev/webgl/figures/en-us_image_0000001238544451.png index 7e95598c6f204f9e9165ad183e2b33b7adcadca4..9d953fc57d179bd67edebd43c2a247585bad7bbe 100644 Binary files a/en/application-dev/webgl/figures/en-us_image_0000001238544451.png and b/en/application-dev/webgl/figures/en-us_image_0000001238544451.png differ diff --git a/en/contribute/template/js-template.md b/en/contribute/template/js-template.md index 4b1a5a913022a595fd16b25e36ac6249d1252972..146a6ae4240bd8bf518a12857a8e6f1ac5eac0cc 100644 --- a/en/contribute/template/js-template.md +++ b/en/contribute/template/js-template.md @@ -7,10 +7,8 @@ > 0.2 - Upload JS API reference documents to **docs/en/application-dev/reference/apis**. If these documents contain figures, upload the figures to the **figures** folder. > > 0.3 - Use a .d.ts file for a JS API reference document. **The file name must be in the following format: js-apis-.md**. Examples: -> -> ​ For @ohos.multimedia.audio in the Media subsystem, the file name is **js-apis-audio.md**. -> -> ​ For @ohos.telephony.sms in the Telephony subsystem, the file name is **js-apis-sms.md**. +> For @ohos.multimedia.audio in the Media subsystem, the file name is **js-apis-audio.md**. +> For @ohos.telephony.sms in the Telephony subsystem, the file name is **js-apis-sms.md**. > > 0.4 - After uploading a JS API reference document, update the **Readme-EN.md** file in **docs/en/application-dev/reference/apis**. > @@ -19,17 +17,15 @@ > 0.6 - Use the document title as the level-1 heading. Use the attributes, functions, classes, interfaces, enums, and types under the namespace as level-2 headings. Use the attributes and functions under classes as level-3 headings. > > 0.7 - **When introducing an API to an existing module, use the \ tag to mark its earliest version.** -> -> ​ Example: For an existing module of API 6, if an attribute is added in API 7, suffix the \ tag to the name of the new attribute, for example, **newAttribute7+**. -> -> ​ If a method is added, suffix the \ tag to the method name, for example, **sim.getSimIccId7+**. The processing of new interfaces, classes, and enums is similar. +> Example: For an existing module of API 6, if an attribute is added in API 7, suffix the \ tag to the name of the new attribute, for example, **newAttribute7+**. +> If a method is added, suffix the \ tag to the method name, for example, **sim.getSimIccId7+**. The processing of new interfaces, classes, and enums is similar. > > 0.8 - **Deprecated content**: Do not delete the deprecated content directly from the document. Instead, suffix **deprecated** as a superscript to the content, and use the greater-than symbol (>) to introduce the substitute method plus the corresponding link. -> -> ​ Example: abandonmentMethod(deprecated) +> Example: abandonmentMethod(deprecated) > > > Discarded. This change is effective since API version 7. You are advised to use [newMethod](#newMethod) instead. > +> 0.9 - **Required permissions and system capabilities**: Keep consistent with the code implementation. Provide them at the level of methods, enumerations, and attributes. > The following describes the instructions for writing a specific API. *** @@ -42,22 +38,25 @@ > 1.3 - Use the following sentence: "The initial APIs of this module are supported since API version ***x***. Newly added APIs will be marked with a superscript to indicate their earliest API version." Change ***x*** to the actual version. + > **Note** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. Describe the module from its functionalities, use cases, and use suggestions in this section. + + ## Modules to Import + > *Writing Instructions* > > 2.1 - Write the modules to import based on the actual conditions. Provide the **import** statement in the form of a code segment. > > 2.2 - If no module needs to be imported, change "Modules to Import" to "How to Use" and provide a usage description. +> Example of **How to Use**: +> Before using the **AbilityContext**, obtain the **Context** object through **[getContext()]**(***API-reference***.md). > -> ​ Example of **How to Use**: -> -> ​ Before using the **AbilityContext**, obtain the **Context** object through **[getContext()]**(***API-reference***.md). > ```js > import ability_featureAbility from '@ohos.ability.featureAbility'; > var context = ability_featureAbility.getContext(); @@ -67,12 +66,6 @@ Describe the module from its functionalities, use cases, and use suggestions in import call from '@ohos.telephony.call'; ``` -## System Capabilities -> *Writing Instructions* -> -> 3.1 - Mandatory. -> -Example: SystemCapability.BundleManager.BundleFramework ## Attributes @@ -87,9 +80,9 @@ Example: SystemCapability.BundleManager.BundleFramework > 4.4 - For a writable attribute, if only fixed fields are supported, describe them. | Name| Type| Readable| Writable| Description| -| ---------------- | ----------------------------------------- | ---- | ---- | ------------------------------------------ | -| pluggedType | [BatteryPluggedType](#BatteryPluggedType) | Yes| No| Charger type of the current device.| -| isBatteryPresent | boolean | Yes| No| Whether the battery is supported or present.| +| ---------------- | ----------------------------------------- | ---- | ---- | ------------------------------------------------------------ | +| pluggedType | [BatteryPluggedType](#BatteryPluggedType) | Yes| No| Charger type of the current device.
**System capabilities**: SystemCapability.xxx.xxx (mandatory)| +| isBatteryPresent | boolean | Yes| No| Whether the battery is supported or present.
**System capabilities**: SystemCapability.xxx.xxx (mandatory)| ## Enums @@ -102,8 +95,8 @@ Example: SystemCapability.BundleManager.BundleFramework Provide a brief description of the enum type. Example: Enumerates charger types. | Name| Value| Description| -| ---- | ---- | -------------------------- | -| NONE | 1 | Unknown type.| +| ---- | ---- | ------------------------------------------------------------ | +| NONE | 1 | Unknown type.
**System capabilities**: SystemCapability.xxx.xxx (mandatory)| ## Methods @@ -113,17 +106,17 @@ Provide a brief description of the enum type. Example: Enumerates charger types. > > 6.2 - Use the actual method name, in the format of ClassName.methodName, as the level-2 heading. For a subscription method, add the subscription event to the method name. > -> ​ Example of a common method: sim.getSimIccId -> -> ​ Example of a subscription method: sim.on('exampleEvent') +> Example of a common method: sim.getSimIccId +> +> Example of a subscription method: sim.on('exampleEvent') > > 6.3 - **Method calling mode**: The description must be the same as that in the .d.ts file. The description must include the parameter type, parameter name, and return value type. > -> ​ Example: getNetworkState(slotId: number, callback: AsyncCallback\): void -> -> ​ Note: The angle bracket (<>) may be identified as a label and not displayed. To ensure normal display, you can either add a backslash (\\) (in the format of "\\<>") or use escape characters \< and \>. +> Example: getNetworkState(slotId: number, callback: AsyncCallback\): void +> +> Note: The angle bracket (<>) may be identified as a label and not displayed. To ensure normal display, you can either add a backslash (\\) (in the format of "\\<>") or use escape characters \< and \>. > -> 6.4.1 - **Method description**: Describe the features implemented by the method and include the prerequisites for using the method, the impact of the method, and the permissions required to use the command. (*Example of prerequisites: The method can be called only after the xx method is called; you must ensure that the connection to the Internet is normal. Example of impact: xx does not take effect after this method is called.*) +> 6.4.1 - **Method description**: Describe the features implemented by the method and include the prerequisites for using the method, the impact of the method, and the permissions and system capabilities required to use the method. (*Example of prerequisites: This method can be called only after the xx method is called; you must ensure that the connection to the Internet is normal. Example of impact: xx does not take effect after this method is called.*) > > 6.4.2 - **Asynchronous method**: If there are asynchronous methods, describe their return type in the method description. The return type can be a callback function or a **Promise** instance. > @@ -133,7 +126,9 @@ Provide the method name in the following format: (**static** if it is a static m Describe the method. For details, see 6.4.1 and 6.4.2. -Required permission: ohos.permission.XXX (Delete this part if no permission is involved. If a system permission is required, describe it.) +**Required permission**: ohos.permission.xxx (Delete this part if no permission is involved. If a system permission is required, specify it.) + +**System capabilities**: SystemCapability.xxx.xxx (mandatory) **Parameters: ** (Optional. Delete this heading if there is no parameter.) @@ -171,7 +166,7 @@ Required permission: ohos.permission.XXX (Delete this part if no permission is i > > 7.3 - If the class or interface contains both attributes and methods, write the attributes above the methods. Write their actual names in separate level-3 headings. > -> ​ If the class of interface contains only attributes, you do not need to create a level-3 heading. Instead, use a table to display the attributes. For details, see [CustomType](#CustomType). +> If the class of interface contains only attributes, you do not need to create a level-3 heading. Instead, use a table to display the attributes. For details, see [CustomType](#CustomType). Describe the class or interface. If there are usage restrictions, describe them as well, for example, whether there is a prerequisite and whether an instance needs to be created by using any method. @@ -187,9 +182,9 @@ Describe the class or interface. If there are usage restrictions, describe them > > 7.4 - Use the actual method name as the level-3 heading. **Do not add a prefix**. For a subscription method, add the corresponding subscription event to the method name. > -> ​ Example of a common method: getSimIccId -> -> ​ Example of a subscription method: on('exampleEvent') +> Example of a common method: getSimIccId +> +> Example of a subscription method: on('exampleEvent') > > The other instructions are the same as those stipulated in [Methods](#Methods). @@ -197,7 +192,9 @@ Describe the method calling mode. For details, see 6.3. Describe the method. For details, see 6.4.1 and 6.4.2. -Required permission: ohos.permission.XXX (Delete this part if no permission is involved. If a system permission is required, describe it.) +**Required permission**: ohos.permission.xxx (Delete this part if no permission is involved. If a system permission is required, specify it.) + +**System capabilities**: SystemCapability.xxx.xxx (mandatory) **Parameters: ** (Optional. Delete this heading if there is no parameter.) @@ -229,7 +226,7 @@ Required permission: ohos.permission.XXX (Delete this part if no permission is i The following is an example of the custom type of a key-value pair. -| Name| Type| Readable|Writable| Description| -| ------------ | ---- | ---- | ---- | ---- | -| parameterUrl | string | Yes| Yes|Media output URI. The following types of URIs are supported:
1. Relative path whose protocol type is **internal**. Example:
Temporary directory: internal://cache/test.mp4

2. Absolute path. Example:
file:///data/data/ohos.xxx.xxx/files/test.mp4| -| parameterOne | [CustomEnum](#Enumeration)| Yes| Yes|Describe the attributes. The requirements are similar to those for the parameter description.| +| Name| Type| Readable| Writable| Description| +| ------------ | ------------------- | ---- | ---- | ------------------------------------------------------------ | +| parameterUrl | string | Yes| Yes| Media output URI. The following types of URIs are supported:
1. Relative path whose protocol type is **internal**. Example:
Temporary directory: internal://cache/test.mp4

2. Absolute path. Example:
file:///data/data/ohos.xxx.xxx/files/test.mp4
**System capabilities**: SystemCapability.xxx.xxx (mandatory)| +| parameterOne | [CustomEnum](#Enumeration)| Yes| Yes| Describe the attributes. The requirements are similar to those for the parameter description.
**System capabilities**: SystemCapability.xxx.xxx (mandatory)| diff --git a/en/device-dev/bundles/bundles-standard-rules.md b/en/device-dev/bundles/bundles-standard-rules.md index 559ff09b2190c8c98b705ec6ceea1f478d6597ad..edd766e0bde314cd32406c1ea32c47b133f835a4 100644 --- a/en/device-dev/bundles/bundles-standard-rules.md +++ b/en/device-dev/bundles/bundles-standard-rules.md @@ -161,7 +161,7 @@ Bundle dependencies are then stored in the **ohos\_bundles** folder in the roo username@server MINGW64 /f/showcase/demo/demo $ hpm list +--demo@1.0.0 -| +--@huawei/media@1.0.2 +| +--@example/media@1.0.2 | +--@demo/sport_hi3518ev300_liteos_a@1.0.0 | | +--@demo/app@4.0.1 | | | +--@demo/build@4.0.1 diff --git a/en/device-dev/driver/driver-hdf-manage.md b/en/device-dev/driver/driver-hdf-manage.md index 1481fec76a6eb1ef3391de5b665ff3c1a981557c..7acd765714a62973371c584a6f3e8c4708a1f9d6 100644 --- a/en/device-dev/driver/driver-hdf-manage.md +++ b/en/device-dev/driver/driver-hdf-manage.md @@ -6,7 +6,7 @@ HCS is the source code that describes the configuration of the HDF using key-val HDF Configuration Generator \(HC-GEN\) is a tool for converting a configuration file into a file that can be read by the target software. -- In a low-performance system on a chip \(SoC\), this tool can convert a configuration file into the source code of the configuration tree so that the driver can obtain the configuration by directly calling the C library code. +- In a low-performance system on a chip \(SoC\), this tool can convert a configuration file into the source code or macro definitions of the configuration tree so that the driver can obtain the configuration by calling the C library code or macro-based APIs. - In a high-performance SoC, this tool can convert an HCS configuration file into the HDF Configuration Binary \(HCB\) file, allowing the driver to obtain the configuration through the APIs provided by the HDF. The following figure shows the typical application scenario of the HCB mode. @@ -330,8 +330,17 @@ This syntax indicates that the **attribute** value is a reference to **node** node1 { attributes; } +node2 { + attr_1 = &root.node1; +} +``` +Or +``` node2 { + node1 { + attributes; + } attr_1 = &node1; } ``` @@ -392,6 +401,7 @@ options: -a hcb align with four bytes -b output binary output, default enable -t output config in C language source file style + -m output config in macro source file style -i output binary hex dump in C language source file style -p prefix of generated symbol name -d decompile hcb to hcs @@ -412,6 +422,12 @@ Generate an HCB file. hc-gen -o [OutputHcbFileName] -b [SourceHcsFileName] ``` +Generate a macro definition file. + +``` +hc-gen -o [OutputMacroFileName] -m [SourceHcsFileName] +``` + Compile an **HCB** file to an **HCS** file: ``` diff --git a/en/device-dev/driver/driver-peripherals.md b/en/device-dev/driver/driver-peripherals.md index 4b65137ea60186915ec84487a46d73e125b2b95c..e4137579577b8b5786fd5c45e7545617e29ece75 100644 --- a/en/device-dev/driver/driver-peripherals.md +++ b/en/device-dev/driver/driver-peripherals.md @@ -10,4 +10,7 @@ - **[Audio](driver-peripherals-audio-des.md)** +- **[USB](driver-peripherals-usb-des.md)** + +- **[Camera](driver-peripherals-camera-des.md)** diff --git a/en/device-dev/faqs/Readme-EN.md b/en/device-dev/faqs/Readme-EN.md index 56e61019cc1bdbd3fb182ede96fc71aed97b08cb..cc68918bdf7a24c2c3d59a1834cfe8053a0baf98 100644 --- a/en/device-dev/faqs/Readme-EN.md +++ b/en/device-dev/faqs/Readme-EN.md @@ -6,6 +6,6 @@ - [Burning](faqs-burning.md) - [Kernel](faqs-kernel.md) - [Porting](faqs-porting.md) -- [Startup and Recovery](faqs-startup-and-recovery.md) +- [Startup](faqs-startup.md) - [System Applications](faqs-system-applications.md) diff --git a/en/device-dev/faqs/faqs-startup-and-recovery.md b/en/device-dev/faqs/faqs-startup.md similarity index 97% rename from en/device-dev/faqs/faqs-startup-and-recovery.md rename to en/device-dev/faqs/faqs-startup.md index dec59820e73795b8be9428966db9a05bc46aca71..f3814ab7f9563ce24ec066e28bb864a972098344 100644 --- a/en/device-dev/faqs/faqs-startup-and-recovery.md +++ b/en/device-dev/faqs/faqs-startup.md @@ -1,4 +1,4 @@ -# Startup and Recovery +# Startup ## System startup interrupted due to "parse failed!" error diff --git a/en/device-dev/faqs/faqs-system-applications.md b/en/device-dev/faqs/faqs-system-applications.md index 8be8a965d7090a42f3f475d9d7dfdac838343c87..10f999d9f36131330be4a92153bd68480c25adab 100644 --- a/en/device-dev/faqs/faqs-system-applications.md +++ b/en/device-dev/faqs/faqs-system-applications.md @@ -17,7 +17,7 @@ The compiled executable program is run directly without being converted to an ap Call the **UtilsSetEnv** function of the KV store to set the data storage path. ``` -UtilsSetEnv("/storage/com.huawei.kv"); +UtilsSetEnv("/storage/com.example.kv"); ``` ## Visual Applications diff --git a/en/device-dev/get-code/gettools-acquire.md b/en/device-dev/get-code/gettools-acquire.md index 21e5bccc54e32782a1d0b39b2cd2b4101d6d67e1..6c06f41669bfdb21965dcfe7d4095613a676861b 100644 --- a/en/device-dev/get-code/gettools-acquire.md +++ b/en/device-dev/get-code/gettools-acquire.md @@ -30,16 +30,16 @@ OpenHarmony provides the following two types of Docker environments for you to q

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker

-

0.0.7

+

1.0.0

Standard system

Ubuntu

-

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard

+

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker

-

0.0.8

+

1.0.0

HPM-based Docker environment

@@ -62,6 +62,7 @@ OpenHarmony provides the following two types of Docker environments for you to q + ## Preparations Before using the Docker environment, perform the following operations: @@ -82,7 +83,7 @@ The Docker image of OpenHarmony is hosted on [HUAWEI CLOUD SWR](https://console 1. Obtain the Docker image. ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment: @@ -90,13 +91,13 @@ The Docker image of OpenHarmony is hosted on [HUAWEI CLOUD SWR](https://console Run the following command in Ubuntu: ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` Run the following command in Windows \(assuming that the source code directory is **D:\\OpenHarmony**\): ``` - docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` @@ -108,7 +109,6 @@ Set the build path to the current path. ``` hb set - . ``` **Figure 1** Setting page @@ -116,6 +116,7 @@ hb set >![](../public_sys-resources/icon-note.gif) **NOTE:** >The mapping between the development board and the building GUI: +> >- Hi3861: wifiiot\_hispark\_pegasus@hisilicon >- Hi3516: ipcamera\_hispark\_taurus@hisilicon >- Hi3518: ipcamera\_hispark\_aries@hisilicon @@ -137,13 +138,13 @@ hb set 1. Obtain the Docker image. ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:1.0.0 ``` 2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment: ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/en/device-dev/kernel/kernel-mini-basic-interrupt.md b/en/device-dev/kernel/kernel-mini-basic-interrupt.md index f1ac97b017c9ba569ad1ea7c465ee1cf181c67f7..6429771d8231598ddd039a6a6bee3bcbe0783d74 100644 --- a/en/device-dev/kernel/kernel-mini-basic-interrupt.md +++ b/en/device-dev/kernel/kernel-mini-basic-interrupt.md @@ -128,10 +128,12 @@ static UINT32 Example_Interrupt(VOID) UINT32 ret; HWI_PRIOR_T hwiPrio = 3; HWI_MODE_T mode = 0; - HWI_ARG_T arg = 0; + HwiIrqParam irqParam; + (void)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam)); + irqParam.pDevId = 0; /* Create an interrupt. */ - ret = HalHwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiUsrIrq, arg); + ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiUsrIrq, &irqParam); if(ret == LOS_OK){ printf("Hwi create success!\n"); } else { diff --git a/en/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md b/en/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md index a6752e9588f164f0e728b4e4ab49b9f23f597e42..0dd40f285677989a859a6b49b132aa74cf4cfa06 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md @@ -90,7 +90,6 @@ kill \[-l \[_signo_\] | _-s signo_ | _-signo_\] _pid..._ 6 1 6 0 Pending 0x688000 0x137000 0x11bca0 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa1cdf 0.88 wms_server 8 1 8 2 Pending 0x1f5000 0x48000 0x47dc2 0.2 mksh - 10 5 5 101 Pending 0x11ec000 0x2f9000 0x206047 0.93 com.huawei.launcher 12 1 12 0 Pending 0x4d4000 0x112000 0xe0882 0.0 deviceauth_service 13 1 13 0 Pending 0x34f000 0xbd000 0x51799 0.0 sensor_service 14 1 14 2 Pending 0x34e000 0xb3000 0x52184 0.0 ai_server @@ -116,7 +115,6 @@ kill \[-l \[_signo_\] | _-s signo_ | _-signo_\] _pid..._ 6 1 6 0 Pending 0x688000 0x137000 0x11c1ba 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa21f9 0.89 wms_server 8 1 8 2 Pending 0x1f5000 0x48000 0x482dc 0.2 mksh - 10 5 5 101 Pending 0x11ec000 0x2f9000 0x206561 0.93 com.huawei.launcher 12 1 12 0 Pending 0x4d4000 0x112000 0xe0d9c 0.0 deviceauth_service 13 1 13 0 Pending 0x34f000 0xbd000 0x51cb3 0.0 sensor_service 14 1 14 2 Pending 0x34e000 0xb3000 0x5269e 0.0 ai_server diff --git a/en/device-dev/kernel/kernel-small-debug-shell-cmd-task.md b/en/device-dev/kernel/kernel-small-debug-shell-cmd-task.md index 702530ad0a5439df2a4a3c1cc8c44f7640277b73..3eceba9af02fe37ab24ee34fe8282092a8e5a199 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-cmd-task.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-cmd-task.md @@ -62,7 +62,6 @@ OHOS # task 6 1 6 0 Pending 0x688000 0x137000 0x11c518 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa1ddf 0.89 wms_server 8 1 1 1000 Running 0x2bf000 0x8f000 0x2a8c6 0.0 shell - 9 5 5 101 Pending 0x11ea000 0x2f9000 0x20429d 0.97 com.huawei.launcher 11 1 11 0 Pending 0x4d4000 0x112000 0xe0ad7 0.0 deviceauth_service 12 1 12 0 Pending 0x34f000 0xbd000 0x519ee 0.0 sensor_service 13 1 13 2 Pending 0x34e000 0xb3000 0x523d9 0.0 ai_server diff --git a/en/device-dev/kernel/kernel-small-debug-shell-cmd-top.md b/en/device-dev/kernel/kernel-small-debug-shell-cmd-top.md index 9826e59c8eb87a6307db706289c4a55f275ce012..3f605a6d21a6e44ccaa8a3ab8d567313e381f2b7 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-cmd-top.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-cmd-top.md @@ -73,7 +73,6 @@ OHOS:/$ top 6 1 6 0 Pending 0x688000 0x137000 0x11c1ba 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa21f9 0.87 wms_server 8 1 8 2 Pending 0x1f5000 0x48000 0x462dc 0.0 mksh - 9 5 5 101 Pending 0x11ea000 0x2f9000 0x204561 0.94 com.huawei.launcher 11 1 11 0 Pending 0x4d4000 0x112000 0xe0d9c 0.0 deviceauth_service 12 1 12 0 Pending 0x34f000 0xbd000 0x51cb3 0.0 sensor_service 13 1 13 2 Pending 0x34e000 0xb3000 0x5269e 0.0 ai_server diff --git a/en/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md b/en/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md index 78cb1416ad05af2d3474c360a398fbbb9d3b2e3b..781a427e634db8e478120f7ab6cb2ca1fde324e2 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md @@ -84,7 +84,7 @@ Example 1: all information of the operating system ``` OHOS:/$ uname -a -Huawei LiteOS hisilicon 2.0.0.37 Huawei LiteOS 2.0.0.37 Oct 21 2021 17:39:32 Cortex-A7 +LiteOS hisilicon 2.0.0.37 Huawei LiteOS 2.0.0.37 Oct 21 2021 17:39:32 Cortex-A7 OHOS:/$ ``` @@ -92,7 +92,7 @@ Example 2: operating system name and architecture ``` OHOS:/$ uname -ms -Huawei LiteOS Cortex-A7 +LiteOS Cortex-A7 OHOS:/$ ``` diff --git a/en/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md b/en/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md index 65d163661af9a504cd2f63016c5558b7b9844203..df743e04bb4b8628338bedf864b9616374a11a96 100644 --- a/en/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md +++ b/en/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md @@ -105,7 +105,6 @@ OHOS # 6 1 6 0 Pending 0x688000 0x137000 0x11c518 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa1ddf 0.95 wms_server 8 1 1 1000 Running 0x2bf000 0x8f000 0x2a8c6 0.0 shell - 9 5 5 101 Pending 0x11ea000 0x2f9000 0x20429d 1.2 com.huawei.launcher 11 1 11 0 Pending 0x4d4000 0x112000 0xe0ad7 0.0 deviceauth_service 12 1 12 0 Pending 0x34f000 0xbd000 0x519ee 0.0 sensor_service 13 1 13 2 Pending 0x34e000 0xb3000 0x523d9 0.0 ai_server diff --git a/en/device-dev/kernel/kernel-small-debug-user.md b/en/device-dev/kernel/kernel-small-debug-user.md index 14f7c5097c529f46841a3b0a9592463b59ec3a81..e9add7160c36bf17c152f406cf65e18b978fc76a 100644 --- a/en/device-dev/kernel/kernel-small-debug-user.md +++ b/en/device-dev/kernel/kernel-small-debug-user.md @@ -8,10 +8,4 @@ - **[Typical Memory Problems](kernel-small-debug-user-faqs.md)** -- **[Linux Kernel Overview](kernel-standard-overview.md)** - -- **[Guidelines for Using Patches on OpenHarmony Development Boards](kernel-standard-patch.md)** - -- **[Guidelines for Compiling and Building the Linux Kernel](kernel-standard-build.md)** - diff --git a/en/device-dev/quick-start/quickstart-standard-docker-environment.md b/en/device-dev/quick-start/quickstart-standard-docker-environment.md index 4f61ac051f71146760d4c23e29f6a0a540de3432..ab1534cdd01ad90681fd2f1d5cbc0f274d170147 100644 --- a/en/device-dev/quick-start/quickstart-standard-docker-environment.md +++ b/en/device-dev/quick-start/quickstart-standard-docker-environment.md @@ -64,13 +64,13 @@ By default, the downloaded prebuilts binary file is stored in **OpenHarmony\_2. 1. Obtain the Docker image. ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. Go to the root directory of source code and run the following command to access the Docker build environment: ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/en/device-dev/subsystems/Readme-EN.md b/en/device-dev/subsystems/Readme-EN.md index 020980c386ebedf7b781776d02748a7339a0231e..517ef499726670d8c6bff0705c03080c828f0796 100644 --- a/en/device-dev/subsystems/Readme-EN.md +++ b/en/device-dev/subsystems/Readme-EN.md @@ -47,10 +47,10 @@ - [Lightweight Data Store](subsys-data-storage.md) - [Lightweight Data Store Overview](subsys-data-storage-overview.md) - [Lightweight Data Store Development](subsys-data-storage-guide.md) -- [Sensors](subsys-sensor.md) - - [Sensors Overview](subsys-sensor-overview.md) - - [Sensors Usage Guidelines](subsys-sensor-guide.md) - - [Sensors Usage Example](subsys-sensor-demo.md) +- [Sensor](subsys-sensor.md) + - [Sensor Overview](subsys-sensor-overview.md) + - [Sensor Usage Guidelines](subsys-sensor-guide.md) + - [Sensor Usage Example](subsys-sensor-demo.md) - [USB](subsys-usbservice.md) - [[USB Overview](subsys-usbservice-overview.md) - [USB Usage Guidelines](subsys-usbservice-guide.md) @@ -80,12 +80,12 @@ - [Testing](subsys-testguide-test.md) - [DFX](subsys-dfx.md) - [DFX](subsys-dfx-overview.md) - - [Development Guidelines on HiLog ](subsys-dfx-hilog-rich.md) - - [Development Guidelines on HiLog\_Lite](subsys-dfx-hilog-lite.md) + - [HiLog Development](subsys-dfx-hilog-rich.md) + - [HiLog\_Lite Development](subsys-dfx-hilog-lite.md) - [HiTrace Development](subsys-dfx-hitrace.md) - [HiCollie Development](subsys-dfx-hicollie.md) - - [Development Guidelines on HiSysEvent](subsys-dfx-hisysevent.md) - [HiSysEvent Development](subsys-dfx-hisysevent.md) + - [HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md) - [HiSysEvent Logging](subsys-dfx-hisysevent-logging.md) - [HiSysEvent Listening](subsys-dfx-hisysevent-listening.md) - [HiSysEvent Query](subsys-dfx-hisysevent-query.md) diff --git a/en/device-dev/subsystems/figure/ohos_device_security_level.png b/en/device-dev/subsystems/figure/ohos_device_security_level.png new file mode 100644 index 0000000000000000000000000000000000000000..5431ff80c7d601113b2c767655165859ef1316cf Binary files /dev/null and b/en/device-dev/subsystems/figure/ohos_device_security_level.png differ diff --git a/en/device-dev/subsystems/figure/ohos_system_security_architecture.png b/en/device-dev/subsystems/figure/ohos_system_security_architecture.png new file mode 100644 index 0000000000000000000000000000000000000000..5d9105f6e4ac4bd9d9f0628c061d560fabf2979d Binary files /dev/null and b/en/device-dev/subsystems/figure/ohos_system_security_architecture.png differ diff --git a/en/device-dev/subsystems/subsys-build.md b/en/device-dev/subsystems/subsys-build.md index 8af635290fe343c07c8da6e6d902a1218ed5207f..b8aa6b81f76ee323182ed22af9ad3db1afb6114f 100644 --- a/en/device-dev/subsystems/subsys-build.md +++ b/en/device-dev/subsystems/subsys-build.md @@ -4,4 +4,6 @@ - **[Building Guidelines for Standard Systems](subsys-build-standard-large.md)** +- **[Build System Coding Specifications and Best Practices](subsys-build-gn-coding-style-and-best-practice.md)** + diff --git a/en/device-dev/subsystems/subsys-dfx-hilog-lite.md b/en/device-dev/subsystems/subsys-dfx-hilog-lite.md index 432bb0d18f9e77e13fa7b448bda75c486b07d5a5..6f65a7c76ec6a1e2e2798883ec3fd4550c4255b5 100644 --- a/en/device-dev/subsystems/subsys-dfx-hilog-lite.md +++ b/en/device-dev/subsystems/subsys-dfx-hilog-lite.md @@ -1,4 +1,4 @@ -# Development Guidelines on HiLog\_Lite +# HiLog\_Lite Development ## Overview diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md index f36ae618c2045e592f208f64a8fd35e4d6ea91a2..5df286d2676a52bb60d097feb926e00b2f2525b2 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md @@ -1,146 +1,124 @@ # HiSysEvent Listening +- [Overview](#section315316685112) + - [Introduction](#section123181433335224) + - [Constraints](#section123181433375224) +- [Development Guidelines](#section315316685113) + - [Available APIs](#section0342191810519) + - [Development Example](#section123181432175110) + ## Overview -HiSysEvent supports listening for events across processes. You can register a listener to listen for concerned events on a real-time basis. For example, you can enable the battery module to listen for power consumption event for power usage analysis. - -## Available APIs - -**Table 1** HiSysEvent listener APIs - - - - - - - - - - - - - -

API

-

Description

-

bool HiSysEventManager::AddEventListener(std::shared_ptr<HiSysEventSubscribeCallBack> listener, std::vector<struct ListenerRule>& rules)

-

Registers a listener for system events. You can listen for certain events by specifying rules.

-

Input arguments:

-
  • listener: callback object for system events.
  • rules: rules for event listening.
-

Return values

-
  • 0: Repeated registration is successful.
  • 1: Initial registration is successful.
  • Other values: Registration has failed.
-

bool HiSysEventManager::RemoveListener(std::shared_ptr<HiSysEventSubscribeCallBack> listener)

-

Removes the listener for system events.

-

Input arguments:

-
  • listener: callback object for system events.
-

Return value: none

-
- -**Table 2** HiSysEvent listener rules - - - - - - - - - - - - - - - - -

Attribute

-

Description

-

uint32_t ruleType

-

Rule type. The matching scope includes domain and eventName. The value can be any of the following:

-
  • 1: whole word matching.
  • 2: prefix matching.
  • 3: regular expression matching.
  • Other values: invalid matching mode.
-

std::string domain

-
  • domain: domain to which the event belongs. By default, an empty string indicates that the domain is successfully matched.
-

std::string eventName

-
  • eventName: event name. By default, an empty string indicates that the event name is successfully matched.
-
- -**Table 3** HiSysEvent callback object - - - - - - - - - - -

API

-

Description

-

void HiSysEventSubscribeCallBack::OnHandle(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail)

-

Callback object for system events.

-

Input arguments:

-
  • domain: domain to which the event belongs.
  • eventName: event name.
  • eventType: event type.
  • eventDetail: JSON string containing event information.
-

Return value: none

-
- -## How to Develop - -### **C++** - -In this example, you'll be instructed to register a listener for all system events that belong to the **HIVIEWDFX** domain. +### Introduction + +HiSysEvent supports listening for events across processes. You can register a listener to listen for concerned events on a real-time basis. For example, you can enable the battery module to listen for power consumption events for power usage analysis. + +### Constraints + +Before subscribing to system events, you need to configure HiSysEvent logging. For details, see [HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md). + +## Development Guidelines + +### Available APIs + +**Table 1** Description of EventListener APIs + +| Name| Description | +| -------- | --------- | +|bool HiSysEventManager::AddEventListener(std::shared_ptr<HiSysEventSubscribeCallBack> listener, std::vector<ListenerRule>& rules)|Registers a listener for system events. You can listen for certain events by specifying rules.

Input arguments:
  • **listener**: callback object for system events.
  • **rules**: rules for event listening.
Return value:
  • **0**: Repeated registration is successful.
  • **1**: Initial registration is successful.
  • Other values: Registration has failed.
| +|bool HiSysEventManager::RemoveListener(std::shared_ptr<HiSysEventSubscribeCallBack> listener)|Removes the listener for system events.

Input arguments:
  • **listener**: callback object for system events.
Return value:
None.| + +**Table 2** Description of ListenerRule + +| API| Description | +| -------- | --------- | +|ListenerRule(const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event tag.

Input arguments:
  • **tag**: indicates the event tag for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, lowercase letters, and digits.
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| +|ListenerRule(const std::string& domain, const std::string& eventName, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain and event name.

Input arguments:
  • **domain**: indicates the event domain for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, digits, and underscores (_).
  • **eventName**: indicates the event name for the **ListenerRule** object. The value is a string of 1 to 32 characters, including uppercase letters, digits, and underscores (_).
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| +|ListenerRule(const std::string& domain, const std::string& eventName, const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain, event name, and event tag.

Input arguments:
  • **tag**: indicates the event tag for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, lowercase letters, and digits.
  • **domain**: indicates the event domain for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, digits, and underscores (_).
  • **eventName**: indicates the event name for the **ListenerRule** object. The value is a string of 1 to 32 characters, including uppercase letters, digits, and underscores (_).
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| + +**Table 3** Description of RuleType + +| Value | Description | +| ------------ | ------------- | +| WHOLE_WORD | Whole word matching | +| PREFIX | Prefix matching | +| REGULAR | Regular expression matching | + +**Table 4** Description of HiSysEventSubscribeCallBack + +| API| Description | +| -------- | --------- | +|void HiSysEventSubscribeCallBack::OnHandle(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail)|Provides the callback of system events.

Input arguments:
  • **domain**: indicates the domain to which the event belongs.
  • **eventName**: indicates the event name.
  • **eventType**: indicates the event type.
  • **eventDetail**: indicates the event information, in JSON format.
Return value:
None.| + +### Development Example + +C++ 1. Develop the source code. - - Import the corresponding header file: + Import the **DemoListener.h** header file, which contains the **DemoListener** class for implementing the custom event callback. - hisysevent\_manager.h + ``` + #ifndef DEMO_LISTENER_H + #define DEMO_LISTENER_H - - Implement the callback API. + #include "hisysevent_subscribe_callback.h" - HiSysEventSubscribeCallBack::OnHandle\(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail\) + #include - - Register a callback object. + class DemoListener : public OHOS::HiviewDFX::HiSysEventSubscribeCallBack { + public: + explicit DemoListener() : HiSysEventSubscribeCallBack() {} + void OnHandle(const std::string& domain, const std::string& eventName, const int eventType, + const std::string& eventDetail); + virtual ~DemoListener() {} + void OnServiceDied(); + }; - HiSysEventManager::AddEventListener\(std::shared\_ptr listener, std::vector& rules\) + #endif // DEMO_LISTENER_H + ``` + Create the **DemoListener.cpp** file, and add the implementation logic of the custom event callback API in the **DemoListener** class. ``` - // Register a listener for all system events that belong to the HIVIEWDFX domain. - #include "hisysevent_manager.h" + #include "demo_listener.h" + #include - namespace OHOS { - namespace HiviewDFX { - // Implement the API for registering a listener for callback objects. - void HiSysEventToolListener::OnHandle(const std::string& domain, const std::string& eventName, + + void DemoListener::OnHandle(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail) { std::cout << eventDetail << std::endl; } - - void HiSysEventToolListener::OnServiceDied() + + void DemoListener::OnServiceDied() { std::cout << std::string("service disconnect, exit") << std::endl; exit(0); } - } // namespace HiviewDFX - } // namespace OHOS - - // Register a listener for callback objects. - auto toolListener = std::make_shared(); - struct ListenerRule rule; - rule.ruleType = 1; // 1: default type - rule.domain = "HIVIEWDFX"; - std::vector sysRules; - sysRules.push_back(rule); - HiSysEventManager::AddEventListener(toolListener, sysRules); ``` -2. Modify the **BUILD.gn** file. - - In the **BUILD.gn** file, add the **libhisyseventmanager** library that depends on the** hisysevent\_native** component. + Call the **AddEventListener** API of the **HiSysEventManager** class to add a listener for system events. ``` - external_deps = [ "hisysevent_native:libhisyseventmanager", ] + auto demoListener = std::make_shared(); + // Add a ListenerRule object based on the event tag, with RuleType left unspecified (in this case, ruleType is defaulted to WHOLE_WORD). + ListenerRule tagRule("dfx"); + // Add a ListenerRule object based on the event tag, with RuleType set as REGULAR. + ListenerRule regRule("dfx.*", RuleType::REGULAR); + // Add a ListenerRule object based on the event domain and event name, with RuleType set as PREFIX. + ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX); + std::vector sysRules; + sysRules.push_back(tagRule); + sysRules.push_back(regRule); + sysRules.push_back(domainNameRule); + HiSysEventManager::AddEventListener(demoListener, sysRules); ``` +2. Configure the **BUILD.gn** file. + In the **BUILD.gn** file, add the **libhisyseventmanager** library that depends on the **hisysevent\_native** component. + + ``` + external_deps = [ "hisysevent_native:libhisyseventmanager", ] + ``` diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md new file mode 100644 index 0000000000000000000000000000000000000000..eb960a33ba16b806f286d11608922c637b6b7653 --- /dev/null +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md @@ -0,0 +1,186 @@ +# HiSysEvent Logging Configuration + +- [Overview](#section315316685115) + - [Basic Concepts](#section123181432175143) + - [Constraints](#section123181432175114) +- [Writing a YAML File](#section123181432175113) + - [Writing Rules](#section123181432175133) + - [Example](#section123181432175123) +- [Verifying the YAML File](#section123181432175115) + - [Configuring the YAML File Path](#section123181432175135) + - [Compiling the YAML File](#section123181432175137) + - [Logging and Querying Events](#section123181432175139) + +## Overview + +If HiSysEvent logging is required for a component, you need to define a YAML file and [configure the YAML file path](#section123181432175135) in the **bundle.js** file. During compilation, the OpenHarmony compilation framework will use the Python compilation script to parse and verify all the YAML files configured in the **bundle.js** file. On completion, the compilation framework will summarize the configuration information in the YAML files and convert the information into a JSON file named **hisysevent.def**. After that, the compilation framework will put the JSON file to a specified path as the basis for the system to determine whether to log system events. + +### Basic Concepts + +Understanding the following concepts would be helpful for you in configuring HiSysEvent logging. + +- Event domain + Represents the domain to which an event belongs. It is specified by the **domain** field in the YAML file. For details, see [domain](#section123181432175123) in the example YAML file. + +- Event name + Indicates the events in an event domain. For details, see [EVENT\_NAMEA/EVENT\_NAMEB](#section123181432175123) in the example YAML file. + +- Parameter + Defines the key values in an event name. For details, see [__BASE/NAME1/NAME2](#section123181432175123) in the example YAML file. + + +### Constraints + +- Each YAML file can contain only one event domain, and the domain name cannot be the same as that defined in other YAML files. + +- Zero or more event names can be defined for one event domain. The event names in the same event domain must be unique. + +- Multiple parameters can be defined for one event name. The parameters in the same event name must be unique. There must be one and only one parameter named **\__BASE** in each event name. See Table 1 for the fields of this parameter and Table 2 for the fields of other custom parameters. + + **Table 1** Fields in the \__BASE parameter + + | Field| Description| + | ----- | ----- | + | type | Indicates the type of the event. This field is mandatory.

Value:
  • **FAULT**: fault
  • **STATISTIC**: statistics
  • **SECURITY**: security
  • **BEHAVIOR**: user behavior
| + | level | Indicates the level of the event. This field is mandatory.

Value:
  • **CRITICAL**: critical
  • **MINOR**: minor
| + | tag | Indicates the tag of the event. This field is mandatory.

Rule:
  • You can define a maximum of five tags,separated with a space.
  • A single tag can contain a maximum of 16 characters, including a to z, A to Z, and 0 to 9.
| + | desc | Describes the event name. This field is mandatory.

Rule:
  • The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).
| + + **Table 2** Description of custom parameters + + | Field| Description| + | ----- | ----- | + | type | Indicates the type of a parameter. This field is mandatory.

Value:
  • BOOL
  • UINT8
  • UINT16
  • INT32
  • UINT32
  • UINT64
  • FLOAT
  • DOUBLE
  • STRING
| + | arrsize | Specifies the length of the parameter of the array type. This field is optional.

Value range:
  • 1-100
| + | desc | Describes the parameter. This field is mandatory.

Rule:
  • The description contains 3 to 128 characters, including a to z, A to Z, 0 to 9, and underscores (_).
| + +## Writing a YAML File + +### Writing Rules + +- Event domain naming rules: + - The name must start with a letter and can contain only uppercase letters, digits, and underscores (_). + - The name contains 1 to 16 characters. +- Event naming rules: + - The name must start with a letter and can contain only uppercase letters, digits, and underscores (_). + - The name contains 1 to 32 characters. + - The number of internal event names in an event domain cannot exceed 4096. +- Parameter naming rules: + - The name must start with a letter and can contain only uppercase letters, digits, and underscores (_). + - The name contains 1 to 32 characters. + - The number of parameters in an event domain cannot exceed 128. + +### Example + +- In the example YAML file, the event domain name is **MODULEA**. The event domain contains two events named **EVENT\_NAMEA** and **EVENT\_NAMEB**. +- **EVENT\_NAMEA** is defined as a critical event of the fault type. The event contains the **NAME1** parameter of the string type, the **NAME2** parameter of the string type, and the **NAME3** parameter of the unsigned short integer type. Therefore, you can perform [real-time subscription](subsys-dfx-hisysevent-listening.md) to the event based on the event domain **MODULEA** and event name **EVENT\_NAMEA**. +- **EVENT\_NAMEB** is defined as a general event of the statistics type. The event contains the **NAME1** parameter of the unsigned short integer type and the **NAME2** parameter of the integer type. Because two event tags named **tag1** and **tag2** are defined for **EVENT\_NAMEB** in the **\__BASE** parameter, you can perform [real-time subscription](subsys-dfx-hisysevent-read.md) to the event based on the event domain **MODULEA** and event name **EVENT\_NAMEB**, or based on the event tag. + + ``` + ########################################## + # HiSysEvent definition for MODULEA + ########################################## + + domain: MODULEA + + EVENT_NAMEA: + __BASE: {type: FAULT, level: CRITICAL, desc: event name a} + NAME1: {type: STRING, desc: name1} + NAME2: {type: STRING, desc: name2} + NAME3: {type: UINT16, desc: name3} + + EVENT_NAMEB: + __BASE: {type: STATISTIC, level: MINOR, tag: tag1 tag2, desc: event name b} + NAME1: {type: UINT16, desc: name1} + NAME2: {type: INT32, desc: name2} + ``` + +## Verifying the YAML File + +### Configuring the YAML File Path + +In the **bundle.js** file, use the ```hisysevent_config``` attribute to specify the YAML file path. + +``` +{ + "name": "@ohos/moduel_a", + "description": "module a", + "version": "3.1", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "moduel_a_path" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "hisysevent_native", + "subsystem": "hiviewdfx", + "adapted_system_type": [ + "standard" + ], + "rom": "", + "ram": "", + "hisysevent_config": [ + "//moduel_a_path/yaml_file1.yaml", + "//moduel_a_path/yaml_file2.yaml" + ], + "deps": { + "components": [ + "hilog_native", + "hitrace_native", + "ipc", + "safwk", + "samgr_standard", + "utils_base" + ], + "third_party": [] + }, + "build": { + } + } +} +``` + +>![](../public_sys-resources/icon-note.gif) **Note:** +>The YAML file can be placed in any directory of the component project as needed. You only need to specify the path in the **bundle.js** file. + +### Compiling the YAML File + +- Perform full compilation. + + - During full compilation of the system, the configuration in the YAML files of all components are summarized. After the compilation is complete, the **hisysevent.def** file will be generated in the specified directory. + + ``` + cd absolute path of the project's root directory + ./build --product-name + ``` + + - To obtain the **hisysevent.def** file generated after full compilation, run the following command: + + ``` + cd absolute path of the project's root directory + find out -name hisysevent.def -type f + ``` + +- Single-file compilation: + + You can also compile the YAML file of a single component by running the following commands: + + ``` + cd absolute path of the project's root directory + ./build/ohos/hisysevent/gen_def_from_all_yaml.py --yaml-list --def-path + ``` + + **Table 3** Parameters for single-file compilation + + | Parameter| Description| + | ------ | ------ | + | --yaml-list | Specifies the paths of the YAML files to be compiled. If there are multiple YAML file paths, separate each of them with a space.| + | --def-path | Specifies the path of the **hisysevent.def** file generated after compilation.| + +### Logging and Querying Events + +1. Push the **hisysevent.def** file to the **/system/etc/hiview/** directory of the device by using the [hdc_std tool](subsys-toolchain-hdc-guide.md). + +2. Trigger logging of the custom system events in the YAML file. Then, run [hisysevent -l](subsys-dfx-hisysevent-tool.md) to query historical system events to find out if the logging of the custom system events is successful. diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md index feadce49bca7de61ce03a2a922bf18785b71b0e0..e0c70f789d5991a8b54760a90f54d3fe6edc65bd 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-logging.md @@ -1,281 +1,106 @@ # HiSysEvent Logging -## Overview - -HiSysEvent provides event logging APIs for OpenHarmony to record important information of key processes during system running, helping you locate faults. In addition, you can upload the log data to the cloud for big data analytics. - -## Available APIs - -The following table lists the C++ APIs provided by the **HiSysEvent** class. - -For details about the **HiSysEvent** class, see the API reference. - -**Table 1** C++ APIs provided by HiSysEvent +- [Overview](#section77571101789) + - [Introduction](#section123133332175224) + - [Constraints](#section123181432175224) +- [Development Guidelines](#section314416685113) + - [Available APIs](#section13480315886) + - [Development Example](#section112771171317) - - - - - - - - - -

API

-

Description

-

template<typename... Types> static int Write(const std::string &domain, const std::string &eventName, EventType type, Types... keyValues)

-

Logs system events.

-

Input arguments:

-
  • domain: Indicates the domain related to the event. You can use a preconfigured domain or customize a domain as needed. The name of a custom domain can contain a maximum of 16 characters, including digits (0-9) and uppercase letters (A-Z). It must start with a letter.
  • eventName: Indicates the event name. The value contains a maximum of 32 characters, including digits (0 to 9), letters (A-Z), and underscore (_). It must start with a letter and cannot end with an underscore (_).
  • type: Indicates the event type. For details, see EventType.
  • keyValues: Indicates the key-value pairs of event parameters. It can be in the format of the basic data type, std::string, std::vector<basic data type>, or std:vector<std::string>. The value contains a maximum of 48 characters, including digits (0 to 9), letters (A-Z), and underscore (_). It must start with a letter and cannot end with an underscore (_). The number of parameter names cannot exceed 32.
-

Return value: Returns 0 if the operation is successful; returns a value less than 0 otherwise.

-
- -**Table 2** Description of HiSysEvent::Domain APIs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

API

-

Description

-

static const std::string AAFWK

-

Ability management framework

-

static const std::string APPEXECFWK

-

Application framework

-

static const std::string ACCOUNT

-

Account subsystem

-

static const std::string ACE

-

ACE subsystem

-

static const std::string AI

-

AI subsystem

-

static const std::string BARRIER_FREE

-

Accessibility subsystem

-

static const std::string BIOMETRICS

-

Biometric recognition subsystem

-

static const std::string CCRUNTIME

-

C/C++ operating environment subsystem

-

static const std::string COMMUNICATION

-

Communication subsystem

-

static const std::string DEVELOPTOOLS

-

Development toolchain subsystem

-

static const std::string DISTRIBUTED_DATAMGR

-

Distributed data management subsystem

-

static const std::string DISTRIBUTED_SCHEDULE

-

Distributed scheduler subsystem

-

static const std::string GLOBAL

-

Globalization subsystem

-

static const std::string GRAPHIC

-

Graphics subsystem

-

static const std::string HIVIEWDFX

-

DFX subsystem

-

static const std::string IAWARE

-

Scheduling and resource management subsystem

-

static const std::string INTELLI_ACCESSORIES

-

Smart accessory subsystem

-

static const std::string INTELLI_TV

-

Smart TV subsystem

-

static const std::string IVI_HARDWARE

-

IVI-dedicated hardware subsystem

-

static const std::string LOCATION

-

Location subsystem

-

static const std::string MSDP

-

MSDP subsystem

-

static const std::string MULTI_MEDIA

-

Multimedia subsystem

-

static const std::string MULTI_MODAL_INPUT

-

Multimodal input subsystem

-

static const std::string NOTIFICATION

-

Common event and notification subsystem

-

static const std::string POWERMGR

-

Power management subsystem

-

static const std::string ROUTER

-

Router subsystem

-

static const std::string SECURITY

-

Security subsystem

-

static const std::string SENSORS

-

Pan-sensor subsystem

-

static const std::string SOURCE_CODE_TRANSFORMER

-

Application porting subsystem

-

static const std::string STARTUP

-

Startup subsystem

-

static const std::string TELEPHONY

-

Telephony subsystem

-

static const std::string UPDATE

-

Update subsystem

-

static const std::string USB

-

USB subsystem

-

static const std::string WEARABLE_HARDWARE

-

Wearable-dedicated hardware subsystem

-

static const std::string WEARABLE

-

Wearable-dedicated service subsystem

-

static const std::string OTHERS

-

Others

-
- -**Table 3** Description of HiSysEvent::EventType APIs +## Overview - - - - - - - - - - - - - - - - - - -

API

-

Description

-

FAULT

-

Fault event

-

STATISTIC

-

Statistical event

-

SECURITY

-

Security event

-

BEHAVIOR

-

System behavior event

-
+### Introduction -## How to Develop +HiSysEvent provides event logging APIs for OpenHarmony to record important information of key processes during system running, helping you locate faults. In addition, you can upload the log data to the cloud for big data analytics. -**C++** +### Constraints + +Before logging system events, you need to configure HiSysEvent logging. For details, see [HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md). + +## Development Guidelines + +### Available APIs + +The following table lists the C++ APIs provided by the HiSysEvent class. + +For details about the HiSysEvent class, see the API reference. + +**Table 1** C++ APIs provided by HiSysEvent + +| API| Description| +| -------- | --------- | +| template<typename... Types> static int Write(const std::string &domain, const std::string &eventName, EventType type, Types... keyValues) | Logs system events.

Input arguments:
  • **domain**: Indicates the domain related to the event. You can use a preconfigured domain or customize a domain as needed. The name of a custom domain can contain a maximum of 16 characters, including digits (0-9) and uppercase letters (A-Z). It must start with a letter.
  • **eventName**: Indicates the event name. The value contains a maximum of 32 characters, including digits (0 to 9), letters (A-Z), and underscores (_). It must start with a letter and cannot end with an underscore.
  • **type**: Indicates the event type. For details, see EventType.
  • **keyValues**: Indicates the key-value pairs of event parameters. It can be in the format of the basic data type, std::string, std::vector<basic data type>, or std:vector<std::string>. The value contains a maximum of 48 characters, including digits (0 to 9), letters (A-Z), and underscores (_). It must start with a letter and cannot end with an underscore. The number of parameter names cannot exceed 32.
Return value:
  • **0**: The logging is successful.
  • Negative value: The logging has failed.
| + +**Table 2** Description of HiSysEvent::Domain APIs + +| API| Description| +| -------- | --------- | +| static const std::string AAFWK | Atomic ability subsystem| +| static const std::string APPEXECFWK | User program framework subsystem| +| static const std::string ACCOUNT | Account subsystem| +| static const std::string ACE | JS application framework| +| static const std::string AI | AI subsystem| +| static const std::string BARRIER_FREE | Accessibility subsystem| +| static const std::string BIOMETRICS | Biometric recognition subsystem| +| static const std::string CCRUNTIME |C/C++ operating environment subsystem| +| static const std::string COMMUNICATION | Public communication subsystem| +| static const std::string DEVELOPTOOLS | Development toolchain subsystem| +| static const std::string DISTRIBUTED_DATAMGR | Distributed data management subsystem| +| static const std::string DISTRIBUTED_SCHEDULE | Distributed Scheduler subsystem| +| static const std::string GLOBAL | Globalization subsystem| +| static const std::string GRAPHIC | Graphics subsystem| +| static const std::string HIVIEWDFX | DFX subsystem| +| static const std::string IAWARE | Scheduling and resource management subsystem| +| static const std::string INTELLI_ACCESSORIES | Smart accessory subsystem| +| static const std::string INTELLI_TV | Smart TV subsystem| +| static const std::string IVI_HARDWARE | IVI-dedicated hardware subsystem| +| static const std::string LOCATION | LBS subsystem| +| static const std::string MSDP | MSDP subsystem| +| static const std::string MULTI_MEDIA | Media subsystem| +| static const std::string MULTI_MODAL_INPUT | Multimode input subsystem| +| static const std::string NOTIFICATION | Common event and notification subsystem| +| static const std::string POWERMGR | Power management subsystem| +| static const std::string ROUTER | Router subsystem| +| static const std::string SECURITY | Security subsystem| +| static const std::string SENSORS | Pan-sensor subsystem| +| static const std::string SOURCE_CODE_TRANSFORMER | Application porting subsystem| +| static const std::string STARTUP | Startup subsystem| +| static const std::string TELEPHONY | Telephony subsystem| +| static const std::string UPDATE | Update subsystem| +| static const std::string USB | USB subsystem| +| static const std::string WEARABLE_HARDWARE | Wearable-dedicated hardware subsystem| +| static const std::string WEARABLE_HARDWARE | Wearable-dedicated service subsystem| +| static const std::string OTHERS | Others| + +**Table 3** Description of HiSysEvent::EventType + +| Name| Description| +| -------- | --------- | +| FAULT | Fault event| +| STATISTIC | Statistical event| +| SECURITY | Security event| +| BEHAVIOR | System behavior event| + +### Development Example + +C++ 1. Develop the source code. - Include the **HiSysEvent** header file in the class definition header file or class implementation source file. For example: + Include the HiSysEvent header file in the class definition header file or class implementation source file. For example: ``` #include "hisysevent.h" ``` - Add the event logging code. For example, if you want to log events specific to the app start time \(**start\_app**\), then add the following code to the service implementation source file: + Add the event logging code. For example, if you want to log events specific to the app start time (start\_app), then add the following code to the service implementation source file: ``` HiSysEvent::Write(HiSysEvent::Domain::AAFWK, "start_app", HiSysEvent::EventType::FAULT, "app_name", "com.demo"); ``` -2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. +2. Configure compilation information. Specifically, add the subsystem SDK dependency to **BUILD.gn**. ``` external_deps = [ "hisysevent_native:libhisysevent" ] ``` - - diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md new file mode 100644 index 0000000000000000000000000000000000000000..8401862dae6b3bcdf4824334889bb9f6d28a37b6 --- /dev/null +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md @@ -0,0 +1,101 @@ +# HiSysEvent Query + +- [Overview](#section279684125212) +- [Development Guidelines](#section315316761113) + - [Available APIs](#section03869128521) + - [Development Example](#section14286111855212) + +## Overview + +HiSysEvent provides an API for you to query system events. You can query concerned events by specifying search criteria. For example, for a power consumption module, you can query required system events for analysis. + +## Development Guidelines + +### Available APIs + +**Table 1** Description of the HiSysEvent query API + +| Name| Description | +| -------- | --------- | +| bool HiSysEventManager::QueryHiSysEvent(struct QueryArg& queryArg, std::vector<QueryRule>& queryRules, std::shared_ptr<HiSysEventQueryCallBack> queryCallBack) | Queries system events by specifying search criteria such as the time segment, event domain, and event name.

Input arguments:
  • **queryArg**: event query parameter.
  • **queryRules**: event filtering rules.
  • **queryRules**: callback object for query results.
Return value:
  • **true**: The query is successful.
  • **false**: The query has failed.
| + + +**Table 2** Description of QueryArg + +| Attribute| Description | +| -------- | --------- | +| beginTime | Start time, in the **long long int** format.| +| endTime | End time, in the **long long int** format.| +| maxEvents | Maximum number of returned events, in the **int** format.| + +**Table 3** Description of QueryRule + +| API| Description | +| -------- | --------- | +| QueryRule(const std::string& domain, const std::vector<std::string>& eventList) | Constructor used to create a **QueryRule** object.

Input arguments:
  • **domain: domain to which the event of the **QueryRule** object belongs, in the **string** format. By default, an empty string indicates that the domain is successfully matched.
  • **eventList**: event name list, in the **std::vector<std::string>** format. By default, an empty string indicates that the event names on the list are successfully matched.
| + +**Table 4** Description of HiSysEventQueryCallBack + +| API| Description | +| -------- | --------- | +| void HiSysEventQueryCallBack::OnQuery(const ::std::vector<std::string>& sysEvent, const ::std::vector<int64_t>& seq) | Callback object for event query.

Input arguments:
  • **sysEvent**: event set.
  • **seq**: event sequence set.
Return value:
None.| +| void HiSysEventQueryCallBack::OnComplete(int32_t reason, int32_t total) | Callback object for completion of event query.

Input arguments:
  • **reason**: reason for completion of event query. The default value is **0**.
  • **total**: total number of events returned in this query.
Return value:
None.| + +### Development Example + +C++ + +1. Develop the source code. + + - Import the corresponding header file: + + hisysevent\_manager.h + + - Implement the callback API. + + void HiSysEventQueryCallBack::OnQuery\(const ::std::vector<std::string>& sysEvent, const ::std::vector& seq\) + + void HiSysEventQueryCallBack::OnComplete\(int32\_t reason, int32\_t total\) + + - Invoke the query API in the corresponding service logic. + + HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector& queryRules, std::shared\_ptr queryCallBack\) + + + ``` + // In this example, you'll query all system events. + #include "hisysevent_manager.h" + #include + + namespace OHOS { + namespace HiviewDFX { + // Implement the query callback API. + void HiSysEventToolQuery::OnQuery(const ::std::vector& sysEvent, + const ::std::vector& seq) + { + for_each(sysEvent.cbegin(), sysEvent.cend(), [](const std::string &tmp) { + std::cout << tmp << std::endl; + }); + } + + void HiSysEventToolQuery::OnComplete(int32_t reason, int32_t total) + { + return; + } + } // namespace HiviewDFX + } // namespace OHOS + + // Invoke the query callback API to obtain system events. + auto queryCallBack = std::make_shared(); + struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents); + std::vector mRules; + HiSysEventManager::QueryHiSysEvent(args, mRules, queryCallBack); + ``` + +2. Modify the **BUILD.gn** file. + + In the **BUILD.gn** file, add the **libhisyseventmanager** library that depends on the **hisysevent\_native** component. + + ``` + external_deps = [ "hisysevent_native:libhisyseventmanager", ] + ``` diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-querying.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-querying.md deleted file mode 100644 index ba64df110c2db87e2c3aa35bb5824d7d6bc82fcc..0000000000000000000000000000000000000000 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-querying.md +++ /dev/null @@ -1,173 +0,0 @@ -# HiSysEvent Query - -## Overview - -HiSysEvent provides an API for you to query system events. You can query concerned events by specifying search criteria. For example, for a power consumption module, you can query required system events for analysis. - -## Available APIs - -**Table 1** HiSysEvent query API - - - - - - - - - - -

API

-

Description

-

bool HiSysEventManager::QueryHiSysEvent(struct QueryArg& queryArg, std::vector<struct QueryRule>& queryRules, std::shared_ptr<HiSysEventQueryCallBack> queryCallBack)

-

Queries system events by specifying search criteria such as the time segment, event domain, and event name.

-

Input arguments:

-
  • queryArg: event query parameter.
  • queryRules: event filtering rules.
  • queryCallBack: callback object for query results.
-

Return values

-
  • true: Operation successful.
  • false: Operation failed.
-
- -**Table 2** HiSysEvent query parameters - - - - - - - - - - - - - - - - -

Attribute

-

Description

-

long long beginTime

-

Start time.

-

long long endTime

-

End time.

-

int maxEvents

-

Maximum number of query records.

-
- -**Table 3** HiSysEvent query rules - - - - - - - - - - - - - - - - -

Attribute

-

Description

-

uint32_t ruleType

-

Rule type. The default value is 0.

-

std::string domain;

-
  • domain: domain to which the event belongs. By default, an empty string indicates that the domain is successfully matched.
-

std::vector<std::string> eventList

-
  • eventList: event name list. By default, an empty string indicates that the event names on the list are successfully matched.
-
- -**Table 4** HiSysEvent query callback objects - - - - - - - - - - - - - -

API

-

Description

-

void HiSysEventQueryCallBack::OnQuery(const ::std::vector<std::string>& sysEvent, const ::std::vector<int64_t>& seq)

-

Callback object for event query.

-

Input arguments:

-
  • sysEvent: event set.
  • seq: event sequence set.
-

Return value: none

-

void HiSysEventQueryCallBack::OnComplete(int32_t reason, int32_t total)

-

Callback object for completion of event query.

-

Input arguments:

-
  • reason: reason for completion of event query. The default value is 0.
  • total: total number of events returned in this query.
-

Return value: none

-
- -## How to Develop - -### **C++** - -In this example, you'll be instructed to query all system events. - -1. Develop the source code. - - - Import the corresponding header file: - - hisysevent\_manager.h - - - Implement the callback API. - - void HiSysEventQueryCallBack::OnQuery\(const ::std::vector& sysEvent, const ::std::vector& seq\) - - void HiSysEventQueryCallBack::OnComplete\(int32\_t reason, int32\_t total\) - - - Invoke the query API in the corresponding service logic. - - HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector& queryRules, std::shared\_ptr queryCallBack\) - - - ``` - // In this example, you'll query all system events. - #include "hisysevent_manager.h" - #include - - namespace OHOS { - namespace HiviewDFX { - // Implement the query callback API. - void HiSysEventToolQuery::OnQuery(const ::std::vector& sysEvent, - const ::std::vector& seq) - { - for_each(sysEvent.cbegin(), sysEvent.cend(), [](const std::string &tmp) { - std::cout << tmp << std::endl; - }); - } - - void HiSysEventToolQuery::OnComplete(int32_t reason, int32_t total) - { - return; - } - } // namespace HiviewDFX - } // namespace OHOS - - // Invoke the query callback API to obtain system events. - auto queryCallBack = std::make_shared(); - struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents); - std::vector mRules; - HiSysEventManager::QueryHiSysEvent(args, mRules, queryCallBack); - ``` - -2. Modify the **BUILD.gn** file. - - In the **BUILD.gn** file, add the **libhisyseventmanager** library that depends on the** hisysevent\_native** component. - - ``` - external_deps = [ "hisysevent_native:libhisyseventmanager", ] - ``` - - diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md index af83b877ff99c161c69fcc8c6bf3d9221d885ee5..eeb5bd0068ac6935f49862a3e55b3c6c8a652480 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md @@ -37,7 +37,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** - Command for subscribing to real-time system events by event tag: ``` - hisysevnet -r -t [-c [WHOLE_WORD|PREFIX|REGULAR]] + hisysevent -r -t [-c [WHOLE_WORD|PREFIX|REGULAR]] ``` Description of command options: @@ -47,18 +47,47 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | -t  | Event tag used to filter subscribed real-time system events.| | -c  | Matching rule for event tags. The options can be **WHOLE_WORD**, **PREFIX**, or **REGULAR**.| + Example commands: + + ``` + # hisysevent -r -t "TAG" -c PREFIX + {"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""} + # hisysevent -r -t "TA\w{0,1}" -c REGULAR + {"domain_":"WINDOWMANAGER","name_":"NO_FOCUS_WINDOW","type_":1,"time_":1501940269802,"tz_":"+0000","tag_":"TAG","pid_":1428,"tid_":1433,"uid_":10001,"level_":"CRITICAL","info_":""} + {"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""} + # hisysevent -r -t "TA\w+" -c REGULAR + {"domain_":"WINDOWMANAGER","name_":"NO_FOCUS_WINDOW","type_":1,"time_":1501940269802,"tz_":"+0000","tag_":"TAG","pid_":1428,"tid_":1433,"uid_":10001,"level_":"CRITICAL","info_":""} + {"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""} + ``` + - Command for subscribing to real-time system events by event domain and event name: ``` hisysevent -r -o -n [-c [WHOLE_WORD|PREFIX|REGULAR]] ``` + Description of command options: + | Option| Description| | -------- | --------- | | -o | Event domain used to filter subscribed real-time system events.| | -n | Event name used to filter subscribed real-time system events.| | -c | Matching rule for event domains and event names. The options can be **WHOLE_WORD**, **PREFIX**, or **REGULAR**.| + Example commands: + + ``` + # hisysevent -r -o "DOMAINA" -n "EVENTNAMEA" + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + # hisysevent -r -o "DOMA\w{0,10}" -n "EVENT\w+" -c REULAR + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINABC","name_":"EVENTNAMEABC","type_":1,"time_":1501940269938,"tz_":"+0000","pid_":1428,"tid_":1336,"uid_":10002,"level_":"CRITICAL","info_":""} + # hisysevent -r -o "DOMA\w{0,10}" -c REGULAR + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINABC","name_":"EVENTNAMEABC","type_":1,"time_":1501940269938,"tz_":"+0000","pid_":1428,"tid_":1336,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINABC","name_":"EVENTNAMEB","type_":1,"time_":1501940279938,"tz_":"+0000","pid_":1428,"tid_":1344,"uid_":10002,"level_":"CRITICAL","info_":""} + ``` + >![](../public_sys-resources/icon-note.gif) **NOTE:** >If **-t**, **-o**, and **-n** are specified, the system checks whether the configured event tag is null. If the event tag is not null, the system filters system events based on the matching rules for the event tag. Otherwise, the system filters system events based on the matching rules for the event domain and event name. @@ -89,6 +118,16 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | -s | Start time for querying historical system events. Only system events generated after the start time are returned.| | -e | End time for querying historical system events. Only system events generated before the end time are returned.| + Example commands: + + ``` + # hisysevent -l -s 20207388633 -e 20207389000 + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388633,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388900,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207389000,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + ``` + - Command for setting the maximum number of historical events that can be queried: ``` @@ -100,3 +139,16 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | Option| Description| | -------- | --------- | | -m | Maximum number of historical system events that can be queried. The value ranges from **0** to **1000**. The number of returned system events is not more than the value of this parameter.| + + Example commands: + + ``` + # hisysevent -l -s 20207388633 -e 20207389000 -m 3 + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388900,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207389000,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + # hisysevent -l -m 2 + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388633,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + ``` + diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent.md b/en/device-dev/subsystems/subsys-dfx-hisysevent.md index 38fe0b8f890fd05ed7a00ec15a5b5c538af49646..aba11496ba72484a72f37b2c3f424156e52085c5 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent.md @@ -1,10 +1,12 @@ # HiSysEvent Development +- **[HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md)** + - **[HiSysEvent Logging](subsys-dfx-hisysevent-logging.md)** - **[HiSysEvent Listening](subsys-dfx-hisysevent-listening.md)** -- **[HiSysEvent Query](subsys-dfx-hisysevent-querying.md)** +- **[HiSysEvent Query](subsys-dfx-hisysevent-query.md)** - **[HiSysEvent Tool Usage](subsys-dfx-hisysevent-tool.md)** diff --git a/en/device-dev/subsystems/subsys-dfx.md b/en/device-dev/subsystems/subsys-dfx.md index 75fff2b955f65ce1d2105a4bbb61a46fcc52fd76..cce0e6ee8c57ea413f3df4b1f3c08306b6dc24ce 100644 --- a/en/device-dev/subsystems/subsys-dfx.md +++ b/en/device-dev/subsystems/subsys-dfx.md @@ -1,11 +1,14 @@ # DFX Development Guide -- [DFX Overview](subsys-dfx-overview.md) -- [HiLog Development](subsys-dfx-hilog-rich.md) -- [HiLog_Lite Development](subsys-dfx-hilog-lite.md) -- [HiSysEvent Development](subsys-dfx-hisysevent.md) - - [HiSysEvent Logging](subsys-dfx-hisysevent-logging.md) - - [HiSysEvent Listening](subsys-dfx-hisysevent-listening.md) - - [HiSysEvent Query](subsys-dfx-hisysevent-query.md) - - [HiSysEvent Tool Usage](subsys-dfx-hisysevent-tool.md) +- [DFX Overview](subsys-dfx-overview.md) +- [HiLog Development](subsys-dfx-hilog-rich.md) +- [HiLog_Lite Development](subsys-dfx-hilog-lite.md) +- [HiTrace Development](subsys-dfx-hitrace.md) +- [HiCollie Development](subsys-dfx-hicollie.md) +- [HiSysEvent Development](subsys-dfx-hisysevent.md) + - [HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md) + - [HiSysEvent Logging](subsys-dfx-hisysevent-logging.md) + - [HiSysEvent Listening](subsys-dfx-hisysevent-listening.md) + - [HiSysEvent Query](subsys-dfx-hisysevent-query.md) + - [HiSysEvent Tool Usage](subsys-dfx-hisysevent-tool.md) diff --git a/en/device-dev/subsystems/subsys-security-communicationverify.md b/en/device-dev/subsystems/subsys-security-communicationverify.md index ae5dfa0636e5a995588143f97a2864e373aadb6b..c991dec8f5d517d6f131c90fc777caec4758a6f5 100644 --- a/en/device-dev/subsystems/subsys-security-communicationverify.md +++ b/en/device-dev/subsystems/subsys-security-communicationverify.md @@ -1,4 +1,4 @@ -# Development Guidelines on IPC Authentication +# Development on IPC Authentication ## When to Use diff --git a/en/device-dev/subsystems/subsys-security-devicesecuritylevel.md b/en/device-dev/subsystems/subsys-security-devicesecuritylevel.md new file mode 100644 index 0000000000000000000000000000000000000000..28d25ab429d0d5bcabd48cc8026bd7889e66c8de --- /dev/null +++ b/en/device-dev/subsystems/subsys-security-devicesecuritylevel.md @@ -0,0 +1,481 @@ +# Development on Device Security Level Management + +## Overview + +### DSLM + +The OpenHarmony distributed technology can converge resources from different devices to form a Super Device. Poor security capabilities of any device may threaten the security of the Super Device. + +The Device Security Level Management (DSLM) module is introduced to manage the security levels of OpenHarmony devices. When different types of user data are hopped or processed in OpenHarmony distributed services, the DSLM APIs can be called to obtain the security levels of related devices for subsequent processing. + +### Basic Concepts + +- Device security level + + The security level of an OpenHarmony device depends on the system security capabilities of the device. The OpenHarmony system security capabilities are based on the root of trust (RoT) for boot, RoT for storage, and RoT for compute on the hardware. Security technologies and capabilities focus on device integrity protection, data confidentiality protection, and vulnerability defense. + + The following figure shows the OpenHarmony security architecture. + + ![OpenHarmony system security architecture](figure/ohos_system_security_architecture.png) + + The above figure shows the typical security architecture for a single device. The architecture may vary depending on the risk level as well as the software and hardware resources of the device. The security capabilities of OpenHarmony devices are classified into five levels from SL1 to SL5, based on an industry standard security classification model and actual OpenHarmony service scenarios and device types. In the OpenHarmony ecosystem, higher security levels include all the capabilities of lower security levels by default. The figure below shows the security levels of OpenHarmony devices. + + ![OpenHarmony device security levels](figure/ohos_device_security_level.png) + + - SL1: SL1 is the lowest security level of OpenHarmony devices. Usually equipped with a lightweight operating system and low-end microprocessors, such devices implement simple services and do not need to process sensitive data. SL1 devices are required to support software integrity protection and eliminate common errors. Devices that cannot meet the requirements of SL1 can only be controlled by OpenHarmony devices. They cannot control OpenHarmony devices for more complex service collaboration. + + - SL2: OpenHarmony devices of SL2 can label their own data and define access control rules to implement discretionary access control (DAC). These devices must have basic anti-penetration capabilities. Devices of this level support a lightweight, secure, and isolated environment for deploying a small number of necessary security services. + + - SL3: OpenHarmony devices of SL3 have comprehensive security protection capabilities, and their operating systems have relatively complete security semantics and support mandatory access control (MAC). The system data can be structured as critical elements and non-critical elements. The critical elements are protected by a well-defined security policy model. Devices of this level must have certain anti-penetration capabilities to defend against common vulnerability exploits. + + - SL4: OpenHarmony devices of SL4 must have simplified trusted computing base (TCB) and come with anti-tampering capabilities. The implementation of SL4 should be concise and secure enough. Adequate authentication and arbitration are required for any access to critical elements. Devices of this level have considerable anti-penetration capabilities and can defend against most software attacks. + + - SL5: SL5 indicates the highest security protection capabilities for OpenHarmony devices. The system core software modules must have passed formal verification. Key hardware modules, such as the RoT and cryptographic computing engine, must be able to defend against physical attacks and attacks simulated in labs. Devices at this level must have high-security units, such as dedicated security chips, to enhance the boot, storage, and running of the root of trust (RoT). + +- DSLM + + DSLM is a module to manage the security levels of OpenHarmony devices. It verifies and updates device security level information for OpenHarmony devices in collaboration. It also provides an interface for querying the security level of each device. + +### Working Principles + +The security level of each device in a Super Device provides the decision-making criteria for processing or hopping various user data. For example, the distributed file storage service does not allow sensitive data to be stored on devices with security level lower than SL3. + +### Constraints + +The default security level of OpenHarmony devices is SL1. Device manufacturers can customize a higher security level based on service requirements. For details, see [Customizing Device Security Levels](#Customizing_Device_Security_Levels). + +## Development Guidelines + +### When to Use + +When processing or hopping various user data, a subsystem can invoke the APIs provided by the DSLM module to obtain the security level information of related devices. Then, the subsystems determine the subsequent processing based on the security level and data to be processed. + +### Available APIs + +All the APIs are native C interfaces for implementing underlying capabilities and are not open to apps. The APIs are described as follows: +| API| Description| +| :----------------------------------------------------------- | :------------------------------------------- | +| int32_t RequestDeviceSecurityInfo(const DeviceIdentify \*identify, const RequestOption \*option, DeviceSecurityInfo \*\*info); | Requests the security level information of a device synchronously.| +| int32_t RequestDeviceSecurityInfoAsync(const DeviceIdentify \*identify, const RequestOption \*option, DeviceSecurityInfoCallback callback); | Requests the security level information of a device asynchronously.| +| void FreeDeviceSecurityInfo(DeviceSecurityInfo \*info); | Releases the device security level information.| +| int32\_t GetDeviceSecurityLevelValue(const DeviceSecurityInfo \*info, int32_t \*level); | Obtains the device security level from the security level information.| + +### How to Develop + +1. Add the dependencies for compilation. + + ```undefined + external_deps += [ "device_security_level:dslm_sdk" ] + ``` + +2. Add the header files of dependencies. + + ```cpp + #include "device_security_defines.h" // Header file for defining critical data structures. + #include "device_security_info.h" // Header file for defining APIs. + ``` + +3. Call APIs. + + ```cpp + // Obtain the unique device identifier (UDID) of the device of which the security level is to be queried. + const DeviceIdentify *device = GetDestDeviceUdid(); + + // Obtain the RequestOption. + const RequestOption *option = DEFAULT_OPTION; + + // Define a pointer to the device security level obtained. + DeviceSecurityInfo *info = NULL; + + // Call RequestDeviceSecurityInfo to obtain the device security level information of the peer device. + int32_t ret = RequestDeviceSecurityInfo(device, DEFAULT_OPTION, &info); + + int32_t level = 0; + // Obtain the device security level from the device security level information. + ret = GetDeviceSecurityLevelValue(info, &level); + if (ret == SUCCESS) { + // The operation is successful. + return; + } + // Release the memory before the processing is complete. + FreeDeviceSecurityInfo(info); + ``` + +### Development Example + +A service with the file sharing function needs to be developed. To prevent sensitive files from being shared unintentionally, the following judgments must be performed before any file is sent: + +- If the security level of the destination device is SL3 or higher, the service sends the file. +- If the security level of the destination device is lower than SL3, the service denies the file transfer and display a dialog box to notify the user. + +**Example of synchronously obtaining the device security level** + +```cpp +void CheckDestDeviceSecurityLevel(const DeviceIdentify *device, RequestOption *option) +{ + // Pointer to the device security level information. + DeviceSecurityInfo *info = NULL; + // Obtain the security level information of the device. + int32_t ret = RequestDeviceSecurityInfo(device, option, &info); + if (ret != SUCCESS) { + // Failed to obtain the information. You can develop a retry process as required. + return; + } + int32_t level = 0; + // Obtain the device security level from the device security level information. + ret = GetDeviceSecurityLevelValue(info, &level); + if (ret != SUCCESS) { + // Failed to obtain the security level. You can develop a retry process as required. + return; + } + // After the device security level is successfully obtained, check the lowest security level required for the current operation. + // The lowest device security level required for the current operation is 3. + if (level >= 3) { + // The security level of the target device meets the requirements. Services are processed properly. + } else { + // The security level of the target device does not meet the requirements. An alert or dialog box is displayed as required. + } + // Release the memory before the processing is complete. + FreeDeviceSecurityInfo(info); +} +``` + +**Example of asynchronously obtaining the device security level** + +```cpp +// Callback +void DeviceSecurityInfoCallback(const DeviceIdentify *identify, struct DeviceSecurityInfo *info) +{ + int32_t level = 0; + // Obtain the device security level from the device security level information. + int32_t ret = GetDeviceSecurityLevelValue(info, &level); + if (ret != SUCCESS) { + // Failed to obtain the information. You can develop a retry process as required. + return; + } + // After the device security level is successfully obtained, check the lowest security level required for the current operation. + // The lowest device security level required for the current operation is 3. + if (level >= 3) { + // The security level of the target device meets the requirements. Services are processed properly. + } else { + // The security level of the target device does not meet the requirements. An alert or dialog box is displayed as required. + } + // Release the memory before the processing is complete. + FreeDeviceSecurityInfo(info); +} + +void CheckDestDeviceSecurityLevelAsync(const DeviceIdentify *device, RequestOption *option) +{ + // Invoke the asynchronous callback to return the device security level obtained. + int ret = RequestDeviceSecurityInfoAsync(device, option, DeviceSecurityInfoCallback); + if (ret != SUCCESS) { + // Failed to obtain the security level. You can develop a retry process as required. + // In this case, the callback will not be invoked. + return; + } + // The callback is invoked. Wait for the callback to return the device security level. +} +``` + +## Customizing Device Security Levels + +### Device Security Level Credential + +To ensure its integrity and non-repudiation, the security level information must be encapsulated in a "device security level credential" (credential for short) file for transmission between devices. In addition to the security level information of the device, the credential may include device attributes, such as the device model and version. Moreover, the credential must be signed using the public key infrastructure (PKI) technology. Other basic security capabilities of OpenHarmony, such as [Device Authentication](https://gitee.com/openharmony/security_deviceauth) and [HUKS](https://gitee.com/openharmony/security_huks), are used to ensure secure transmission of credentials. + +### Default Implementation + +The DSLM module provides default implementation of security level information synchronization and verification. It is assumed that the security level of all OpenHarmony devices is SL1, and a loose verification scheme is used. For details, see the [source code](https://gitee.com/openharmony/security_device_security_level/tree/master/oem_property/ohos). + +You can change the device security level as required. For details about the OpenHarmony device security levels, see [Basic Concepts](#Basic_Concepts). You can also use more severe verification schemes, including but are not limited to using device-specific credential, periodically downloading updated credentials from a server and strictly authenticating the issuer and validity period of the credentials, and using Trusted Execution Environment (TEE) or even Secure Element (SE) to sign credential files. + +### Generating a Credential File + +The credential file consists of four Base64-encoded strings, separated by periods (.). The following is an example: + +```undefined +... +``` + +#### 1. Construct the `header`. + +The header is a fixed JSON string in the following format: + +``` json +{ + "typ": "DSL" +} +``` + +Encode the header string to Base64 format to obtain ``. + +```undefined +eyJ0eXAiOiAiRFNMIn0= +``` + +#### 2. Construct the `payload`. + +Construct the payload in a JSON string. The following is an example: + +``` json +{ + "type": "debug", + "manufacture": "ohos", + "brand": "rk3568", + "model": "rk3568", + "softwareVersion": "3.2.2", + "securityLevel": "SL1", + "signTime": "20220209150259", + "version": "1.0.1" +} +``` + +Encode the payload string to Base64 format to obtain ``. + +```undefined +eyJ0eXBlIjogImRlYnVnIiwgIm1hbnVmYWN0dXJlIjogIm9ob3MiLCAiYnJhbmQiOiAicmszNTY4IiwgIm1vZGVsIjogInJrMzU2OCIsICJzb2Z0d2FyZVZlcnNpb24iOiAiMy4yLjIiLCAic2VjdXJpdHlMZXZlbCI6ICJTTDEiLCAic2lnblRpbWUiOiAiMjAyMjAyMDkxNTAyNTkiLCAidmVyc2lvbiI6ICIxLjAuMSJ9 +``` + +The fields in the `payload` are described as follows: + +| Field| Description| Mandatory| Value Range| +| :-------------- | :----------------- | :----------- | :-------------------- | +| type | Credential type.| Yes| [debug release] | +| manufacture | Device manufacturer information.| Yes| string [0..128] | +| brand | Device brand.| Yes| string [0..128] | +| model | Device model.| Yes| string [0..128] | +| softwareVersion | Device software version.| Yes| string [0..128] | +| securityLevel | Device security level.| Yes| [SL1 SL2 SL3 SL4 SL5] | +| signTime | Time when the credential was signed.| Yes| string [0..128] | +| version | Credential version.| Yes| string [0..32] | +| sn | Device SN.| No| string [0..128] | +| udid | Device UDID.| No| string [0..128] | + +#### 3. Construct the `signature`. + +Construct the signature of the header and payload. + +##### 3.1 Construct the raw data to be signed. + +Combine the Base64-encoded header and payload with a period (.) in between to obtain `.`. +Example: + +```undefined +eyJ0eXAiOiAiRFNMIn0=.eyJ0eXBlIjogImRlYnVnIiwgIm1hbnVmYWN0dXJlIjogIm9ob3MiLCAiYnJhbmQiOiAicmszNTY4IiwgIm1vZGVsIjogInJrMzU2OCIsICJzb2Z0d2FyZVZlcnNpb24iOiAiMy4yLjIiLCAic2VjdXJpdHlMZXZlbCI6ICJTTDEiLCAic2lnblRpbWUiOiAiMjAyMjAyMDkxNTAyNTkiLCAidmVyc2lvbiI6ICIxLjAuMSJ9 +``` + +##### 3.2 Generate a private key for signature. + +The Elliptic Curve Digital Signature algorithm (ECDSA) is used to sign the raw data in the credential file. Generate an ECDSA key pair `` and `` first. + +> ![notice](../public_sys-resources/icon-notice.gif)**NOTICE** +> +> This step must be performed in a secure and reliable environment, for example, a cryptographic machine that meets related security requirements, to ensure that the key used for signature is not disclosed. + +##### 3.3 Sign the raw data. + +Use the ECC private key `` to sign `.`, and encode the signature to Base64 format to obtain ``. + +```undefined +MGUCMDb9xoiFzTWVkHDU3VWSVQ59gLyw4TchZ0+eQ3vUfQsLt3Hkg0r7a/PmhkNr3X/mTgIxAIywIRE6vRTRs0xk6xKp8A0XwMMiIyjZlujPJfasCvFonpsvXLAqCAIYbe1J0k4Zfg== +``` + +#### 4. Construct the `attestation`. + +> ![notice](../public_sys-resources/icon-notice.gif)**NOTICE** +> +> This step must be performed in a secure and reliable environment, for example, a cryptographic machine that meets related security requirements, to ensure that the key used for signature is not disclosed. +> The key pairs involved in this step do not need to be generated each time. Secure key pairs can be reused. + +##### 4.1 Generate level-3 signature verification information. + +1. Generate an ECDSA key pair `` and `` for a level-2 signature. +2. Use `` to sign `` (generated in step 3.2) to obtain ``. +3. Combine `` and `` into a JSON string. The following is an example: + +``` json +{ + "userPublicKey": "", + "signature": "" +} +``` + +##### 4.2 Generate level-2 signature verification information. + +1. Generate an ECDSA key pair `` and `` for a level-1 signature. +2. Use `` to sign `` (generated in step 4.1) to obtain ``. +3. Combine `` and `` into a JSON string. The following is an example: + +``` json +{ + "userPublicKey": "", + "signature": "" +} +``` + +##### 4.3 Generate root signature verification information. + +1. Use `` to sign the `` (generated in step 4.2) to obtain `` (a self-signature). +2. Combine `` and `` into a JSON string. The following is an example: + +``` json +{ + "userPublicKey": "", + "signature": "" +} +``` + +##### 4.4 Generate the `attestation`. + +1. Combine the preceding three pieces of signature information into a JSON array. + + ```json + [ + { + "userPublicKey": "", + "signature": "" + }, + { + "userPublicKey": "", + "signature": "" + }, + { + "userPublicKey": "", + "signature": "" + } + ] + ``` + +2. Encode the JSON array to Base64 format to obtain ``. + + ```undefined + W3sidXNlclB1YmxpY0tleSI6ICJNSG93RkFZSEtvWkl6ajBDQVFZSkt5UURBd0lJQVFFTEEySUFCREdOMU9xYWZrWFc2a0l1SEZrMVQ0TS84RVJUY3p0eWRDaGtramFROEkzNEc2Q3E1aTNJcnczVnRhQS9KTTF2a0lHOUZDVWRUaHZFUlJFUTFUdG9xemdxZW9SUzVwQW1EYUUyalEwYzdDem8rOHVUWTRIYW1weXZ1TENtenlYUXFnPT0iLCAic2lnbmF0dXJlIjogIk1HTUNMeHVjUnoyZndKZ092QkxyU1U3K1hlVTA3R0EyVXhZbDFMbEJLUnVIUS9wZlNWVHBEd0ZHSTNTb3h5ODR3NThIQWpBeGRtNEY3b3YvYUtEL0NFZi9QZlZDWHVlbE1mQys1L3pkUExXUUJEVnlGdWQrNVdYL3g4U083VXM5UGFhRW1mZz0ifSwgeyJ1c2VyUHVibGljS2V5IjogIk1Ib3dGQVlIS29aSXpqMENBUVlKS3lRREF3SUlBUUVMQTJJQUJHMWU3TDJVd1AyWWxTajB2RWViUGJpNVpLMDh5NS9UeHRWb3VrRFpIUGtSNlRtb2JoVGpyMVRVNzZpUkU4bDlWQlhuU1h1QVB6cjBuSHdKVkdVZVJMdmp4MVh0YUZReE9QNjhjNlIvRTdFWkZ2STdRUFg1N0tvRkhYdkEvVlJaNnc9PSIsICJzaWduYXR1cmUiOiAiTUdRQ01FUVdFNnk0Rm42SFg1ekFvTzNkYzl5cG1Sd2lBclplc2o5aVBROTZEaEhuNXJkRTdNaGFMdWNRZ0MvaXhjSWJsZ0l3QkN5aFBvRUg2RjFITFlwM2xqbWVncVlZQ1E5NHEyZm1kbDB6dHhrWEVTOVpPOVRNSUZQRVpKYlpmUnU5ZHcyOSJ9LCB7InVzZXJQdWJsaWNLZXkiOiAiTUhvd0ZBWUhLb1pJemowQ0FRWUpLeVFEQXdJSUFRRUxBMklBQkZRUUlDWmpWUTV4bkE0c2RMbUJzUmVaMzRJeWdkSmZhanA3SnRReFBzU2RwWTJXV0FneXp6Rm40OFFRRWhoU1BtdzhJYUU3VlJKRENBT3FYRnhGektJbFBFTDFvcFJDUmhhWmJrRzc5Y3ZrWC9HVVhlaFVYc2V2ZGhyb2VRVERFdz09IiwgInNpZ25hdHVyZSI6ICJNR1FDTUdQRndvSDJLbHhwbVZhWXRWV1ViMHpDSUJxYXFXY2F6czFqOVp4YklLUmVkR2tJY0VJdHN0UFoxdnVTanYvNDJnSXdSeGZPcTRoQTdNMHlGV2ZPSndqRTlTc2JsYXhvRDNiRTZCYzN2QjUyMmsyQ0ZJNWJqelpkeUFTVW04d2J2TW5WIn1d + ``` + +#### 5. Construct a complete credential. + +Put the four pieces of data together with a period (.) in between to obtain `...`. The following is an example: + +```undefined +eyJ0eXAiOiAiRFNMIn0=.eyJ0eXBlIjogImRlYnVnIiwgIm1hbnVmYWN0dXJlIjogIm9ob3MiLCAiYnJhbmQiOiAicmszNTY4IiwgIm1vZGVsIjogInJrMzU2OCIsICJzb2Z0d2FyZVZlcnNpb24iOiAiMy4yLjIiLCAic2VjdXJpdHlMZXZlbCI6ICJTTDEiLCAic2lnblRpbWUiOiAiMjAyMjAyMDkxNTAyNTkiLCAidmVyc2lvbiI6ICIxLjAuMSJ9.MGUCMDb9xoiFzTWVkHDU3VWSVQ59gLyw4TchZ0+eQ3vUfQsLt3Hkg0r7a/PmhkNr3X/mTgIxAIywIRE6vRTRs0xk6xKp8A0XwMMiIyjZlujPJfasCvFonpsvXLAqCAIYbe1J0k4Zfg==.W3sidXNlclB1YmxpY0tleSI6ICJNSG93RkFZSEtvWkl6ajBDQVFZSkt5UURBd0lJQVFFTEEySUFCREdOMU9xYWZrWFc2a0l1SEZrMVQ0TS84RVJUY3p0eWRDaGtramFROEkzNEc2Q3E1aTNJcnczVnRhQS9KTTF2a0lHOUZDVWRUaHZFUlJFUTFUdG9xemdxZW9SUzVwQW1EYUUyalEwYzdDem8rOHVUWTRIYW1weXZ1TENtenlYUXFnPT0iLCAic2lnbmF0dXJlIjogIk1HTUNMeHVjUnoyZndKZ092QkxyU1U3K1hlVTA3R0EyVXhZbDFMbEJLUnVIUS9wZlNWVHBEd0ZHSTNTb3h5ODR3NThIQWpBeGRtNEY3b3YvYUtEL0NFZi9QZlZDWHVlbE1mQys1L3pkUExXUUJEVnlGdWQrNVdYL3g4U083VXM5UGFhRW1mZz0ifSwgeyJ1c2VyUHVibGljS2V5IjogIk1Ib3dGQVlIS29aSXpqMENBUVlKS3lRREF3SUlBUUVMQTJJQUJHMWU3TDJVd1AyWWxTajB2RWViUGJpNVpLMDh5NS9UeHRWb3VrRFpIUGtSNlRtb2JoVGpyMVRVNzZpUkU4bDlWQlhuU1h1QVB6cjBuSHdKVkdVZVJMdmp4MVh0YUZReE9QNjhjNlIvRTdFWkZ2STdRUFg1N0tvRkhYdkEvVlJaNnc9PSIsICJzaWduYXR1cmUiOiAiTUdRQ01FUVdFNnk0Rm42SFg1ekFvTzNkYzl5cG1Sd2lBclplc2o5aVBROTZEaEhuNXJkRTdNaGFMdWNRZ0MvaXhjSWJsZ0l3QkN5aFBvRUg2RjFITFlwM2xqbWVncVlZQ1E5NHEyZm1kbDB6dHhrWEVTOVpPOVRNSUZQRVpKYlpmUnU5ZHcyOSJ9LCB7InVzZXJQdWJsaWNLZXkiOiAiTUhvd0ZBWUhLb1pJemowQ0FRWUpLeVFEQXdJSUFRRUxBMklBQkZRUUlDWmpWUTV4bkE0c2RMbUJzUmVaMzRJeWdkSmZhanA3SnRReFBzU2RwWTJXV0FneXp6Rm40OFFRRWhoU1BtdzhJYUU3VlJKRENBT3FYRnhGektJbFBFTDFvcFJDUmhhWmJrRzc5Y3ZrWC9HVVhlaFVYc2V2ZGhyb2VRVERFdz09IiwgInNpZ25hdHVyZSI6ICJNR1FDTUdQRndvSDJLbHhwbVZhWXRWV1ViMHpDSUJxYXFXY2F6czFqOVp4YklLUmVkR2tJY0VJdHN0UFoxdnVTanYvNDJnSXdSeGZPcTRoQTdNMHlGV2ZPSndqRTlTc2JsYXhvRDNiRTZCYzN2QjUyMmsyQ0ZJNWJqelpkeUFTVW04d2J2TW5WIn1d +``` + +### Credential Exchange Protocol + +When detecting a device goes online, the DSLM module requests the device security level credential from the device through the channel provided by [DSoftBus](https://gitee.com/openharmony/communication_dsoftbus). + +The packet for requesting the credential is in the following format: + +``` json +{ + "message": 1, + "payload": { + "version": 196608, + "challenge": "0102030405060708", + "support": [ + 300 + ] + } +} +``` + +The fields in the request message are described as follows: + +| Field| Description| +| :-------- | :------------------------------------ | +| message | Message header. The value **1** indicates a request for the device security level credential.| +| payload | Message payload, which is the specific request information.| +| version | Version of the protocol used by the requester.| +| challenge | Challenge value corresponding to this request.| +| support | List of credential formats supported by the requester.| + +After receiving the request, the peer device returns a response in the following format: + +``` json +{ + "message": 2, + "payload": { + "version": 196608, + "type": 300, + "challenge": "0102030405060708", + "info": "YWJjZAEDBQcJ..." + } +} +``` + +The fields in the response message are described as follows: +| Field| Description| +| :-------- | :--------------------------------------------------------- | +| message | Message header. The value **2** indicates a response to the request for the device security level credential.| +| payload | Message payload, which is the specific response information.| +| version | Version of the protocol used by the responder. | +| type | Format of the credential returned, which describes how to parse the **info** field.| +| challenge | Challenge value corresponding to this response message.| +| info | Signed credential information, which also includes the device information and challenge value verification information.| + +### Tool + +The DSLM module provides a [credential tool](https://gitee.com/openharmony/security_device_security_level/blob/master/oem_property/ohos/dslm_cred_tool.py) to help you better understand the issuing and verification of credentials. This tool is a Python script encapsulated with OpenSSL commands. +You can use the tool as follows: + +1. Initialize the signature key. + + ``` undefined + ./dslm_cred_tool.py init + ``` + +2. Generate a credential. + + For example, to generate a credential file **cred.txt** with the device model of **rk3568**, device version of **3.0.0**, and device security level of **SL3**, run the following command: + + ``` undefined + ./dslm_cred_tool.py create --field-manufacture OHOS --field-brand rk3568 --field-model rk3568 --field-software-version 3.0.0 --field-security-level SL3 --cred-file cred.txt + ``` + + A credential file is generated as follows: + + ``` undefined + cat cred.txt + eyJ0eXAiOiAiRFNMIn0=.eyJ0eXBlIjogImRlYnVnIiwgIm1hbnVmYWN0dXJlIjogIk9IT1MiLCAiYnJhbmQiOiAicmszNTY4IiwgIm1vZGVsIjogInJrMzU2OCIsICJzb2Z0d2FyZVZlcnNpb24iOiAiMy4wLjAiLCAic2VjdXJpdHlMZXZlbCI6ICJTTDMiLCAic2lnblRpbWUiOiAiMjAyMjAyMDkxNTUzMDMiLCAidmVyc2lvbiI6ICIxLjAuMSJ9.MGQCMEqZy/snsRyjMupnEvTpQfhQn+IcdCc5Q3NGxllNQVhoZX8PNyw6ATTgyx+26ghmtQIwVH5KwQ4/VejxckeHmtkBVhofhgmRapzvyVnyiB3PdsU7nvHk8A/zC7PFy1CWBG3z.W3sidXNlclB1YmxpY0tleSI6ICJNSG93RkFZSEtvWkl6ajBDQVFZSkt5UURBd0lJQVFFTEEySUFCQzFXRUxSVlU1NGp1U1ZXWlUrT29CM3hacFd5MWg3QW5uSFdKWm5QbTB3S2l0ZlJZelJKZ3FiUGQyZ3ltVXBUWVl1cmhyRDQxbFdPbUNzcmt0VWdaNTFXdGNCTmc5SG1GODkzc2ZHVFM5eUJNS0JoMGcxSHZaSVFSN1k0S3FXaWpnPT0iLCAic2lnbmF0dXJlIjogIk1HUUNNRFVicTZ2Z2R1YVF0bFVwOTR0azd4VjRJcEx2WVZWY3Y4aFNOTkw0azdPRHhmbEVGTHJFaUdPRWhwMUcweGFGYlFJd1pUbTk1cWx4OTBFZnptV3VIOGlEY2ZWYVlQS2N5SEYwR2ZFcEUzb1NESzQwZEFOZ0FJMWVQY09rTzBPOTdnTFAifSwgeyJ1c2VyUHVibGljS2V5IjogIk1Ib3dGQVlIS29aSXpqMENBUVlKS3lRREF3SUlBUUVMQTJJQUJGKzY1a0lSYTM2dkE4QVZWNXFrcUozYXpXTkdGQy9oaVdPL0tFNHR0S1pMOUsyNlhzQ2hQbjVNc3BlT2F3b1dqSU02bTVLOFZTcU1DYlZNN0svY0VRU0tYdDJTeVJGZERVZU9TaFZmQm9YVmxqaXRUU2puN0V5Q2pERVZiWjFRNEE9PSIsICJzaWduYXR1cmUiOiAiTUdRQ01HanF2cnZ5VW1YNVZLVVc1UkFkUTNkZ2hBYmNBazBRQnppQlFWMVFZUTNQMVFPSzdMckM1b0RObXh6T2Y0QUtmd0l3SzVWU2x3ZG5JSUR6Zm9PUXBEUVAycGhTVGgxSGVjbXJRK1F4VGxWelo0aHJsdnJyd2xCNnp0T3pWRFdNblRELyJ9LCB7InVzZXJQdWJsaWNLZXkiOiAiTUhvd0ZBWUhLb1pJemowQ0FRWUpLeVFEQXdJSUFRRUxBMklBQkZCa2FDNE9mc2VTREt2cW8vbU5VaUtXQ3JtK1VDNGFQcjVsODRNM2tMVCtDdkd3OWhqOGJ6d2I1MzNtVVlFZVhWWWtUdFlRYWRURkRJZXV1dGIzNU1QZDlEKytNMFRFWnZvcTY4NFhoYTVQMzBUbVRhK0ZvOG02UWliZWc3TmFQdz09IiwgInNpZ25hdHVyZSI6ICJNR1FDTURJcmpNYzhvODVPRHFZT0R4c05PcmpYdUhvWjM5endpZlhVTkdDc0lkN2xjU2FWcnhCVlNqRjRyaWg5Y1R6T3dRSXdWQXA3RUF5c1pucEI5REJWVWczQzlMeGQ3eTQxWEMwYVVPcGZUKzI3REVvWmM1WVVldDFGa1FwdmFQckduaFhVIn1d + ``` + +3. Verify a credential. + + ``` undefined + ./dslm_cred_tool.py verify --cred-file cred.txt + ``` + + The command output is as follows: + + ``` undefined + head: + { + "typ": "DSL" + } + payload: + { + "type": "debug", + "manufacture": "OHOS", + "brand": "rk3568", + "model": "rk3568", + "softwareVersion": "3.0.0", + "securityLevel": "SL3", + "signTime": "20220209155303", + "version": "1.0.1" + } + verify success! + ``` + +## FAQs + +- Q: How can I use the credential tool in a production environment? + + A: The credential tool cannot be directly used in the production environment. It is used to demonstrate the format and generation process of credentials. In the production environment, you are advised to generate credentials and save related keys in a cryptographic machine that meets related security requirements. + +- Q: How do I verify a credential in a production environment? + + A: You are advised to use a properly kept private key to sign the credential and use more severe signature verification process instead of the default verification process provided by the DSLM module. For example, allow only the credentials issued by trusted certification authorities (CAs), and bind the credential and device ID to enhance the security. + +## References + +None diff --git a/en/device-dev/subsystems/subsys-security-overview.md b/en/device-dev/subsystems/subsys-security-overview.md index 9119937fb2e626fe4b2a178ca63879b06be1a10d..52a022fdfc2d138c84b46aca02648d7e9f8c6039 100644 --- a/en/device-dev/subsystems/subsys-security-overview.md +++ b/en/device-dev/subsystems/subsys-security-overview.md @@ -1,18 +1,23 @@ # Overview + The OpenHarmony security subsystem provides security capabilities that make your applications and devices more secure and help you manage permissions. This subsystem has the following modules: - Application signature verification - To ensure the content integrity of applications, the system controls sources of the applications through application signatures and profiles. For a debugging application, the system uses the signature verification API to check whether the Unique Device Identifier \(UDID\) of the application matches that of the device, so as to ensure that the application is installed on the right device. + To ensure the content integrity of applications, the system controls sources of the applications through application signatures and profiles. For a debugging application, the system uses the signature verification API to check whether the Unique Device Identifier (UDID) of the application matches that of the device, so as to ensure that the application is installed on the right device. - Application permission management - Application permissions determine what system resources and capabilities an application can access. During application development, you need to declare the permissions that the application may require in the **profile.json** file. Static permissions need to be registered during application installation, while dynamic permissions usually involve sensitive information and need users' dynamic authorization. + Application permissions determine what system resources and capabilities an application can access. During application development, you need to declare the permissions that the application may require in the **profile.json** file. Static permissions need to be registered during application installation, while dynamic permissions usually involve sensitive information and need users' dynamic authorization. - Trusted device group management - You can create and query a group of trusted devices that use the same ID or a peer-to-peer group created by scanning a QR code or using OneHop. With this capability, distributed applications can perform trusted authentication between devices and request from the distributed virtual bus for secure sessions between devices. + You can create and query a group of trusted devices that use the same HUAWEI ID or a peer-to-peer group created by scanning a QR code or using OneHop. With this capability, distributed applications can perform trusted authentication between devices and request from the distributed virtual bus for secure sessions between devices. + +- DSLM + + The OpenHarmony Device Security Level Management (DSLM) module manages the security levels of OpenHarmony devices. When different types of user data are hopped or processed in OpenHarmony distributed services, the DSLM APIs can be called to obtain the security levels of related devices for subsequent processing. ## Basic Concepts @@ -21,22 +26,22 @@ Before developing an application that depends on the signature verification comp - Samgr - System Ability Manager \(Samgr\) is a module of OpenHarmony for managing system capabilities. For details, see the Application Framework development guidelines. + System Ability Manager (Samgr) is a module of OpenHarmony for managing system capabilities. For details, see the Application Framework development guidelines. - BMS - Bundle Manager Service \(BMS\) manages application installation, uninstallation, and data on OpenHarmony. + Bundle Manager Service (BMS) manages application installation, uninstallation, and data on OpenHarmony. - Profile - The profile in this document refers to HarmonyAppProvision \(profile for short\). HarmonyAppProvision is in JSON format. + The profile in this document refers to HarmonyAppProvision (profile for short). HarmonyAppProvision is in JSON format. - Debugging application - A debugging application is a HAP that is signed with a debugging certificate and profile obtained from the application market. + A debugging application is a HarmonyOS Ability Package (HAP) that is signed with a debugging certificate and profile obtained from the application market. - Released application @@ -46,11 +51,10 @@ Before developing an application that depends on the signature verification comp - OpenHarmony self-signed application - A self-signed application is one that has been signed with the signing certificate and profile issued by OpenHarmony's open-source root CA, which is comprised of a certificate and a key. + A self-signed application is one that has been signed with the signing certificate and profile issued by OpenHarmony's open-source root CA, which consists of a certificate and a key. -## Limitations and Constraints +## Constraints - Only signatures of debugging, released, and OpenHarmony self-signed applications can be verified. - To verify the signature of a debugging application, the UDID of the device on which the debugging application is installed must be in the UDID list contained in the profile. - diff --git a/en/device-dev/subsystems/subsys-security-rightmanagement.md b/en/device-dev/subsystems/subsys-security-rightmanagement.md index 4505ed49f0c1cb706d53a53c711820af4479a56b..38a63afd8bdf38dd2037057273d5705e3b2b7ac2 100644 --- a/en/device-dev/subsystems/subsys-security-rightmanagement.md +++ b/en/device-dev/subsystems/subsys-security-rightmanagement.md @@ -1,4 +1,4 @@ -# Development Guidelines on Application Permission Management +# Development on Application Permission Management ## How Application Permission Management Works diff --git a/en/device-dev/subsystems/subsys-security-sigverify.md b/en/device-dev/subsystems/subsys-security-sigverify.md index 482e70032b22dbe70ab90949c362e21b2434e9f4..66ec4fba0f6f38fcd95b26eebe52e19040a61cf5 100644 --- a/en/device-dev/subsystems/subsys-security-sigverify.md +++ b/en/device-dev/subsystems/subsys-security-sigverify.md @@ -1,4 +1,4 @@ -# Development Guidelines on Application Signature Verification +# Development on Application Signature Verification ## When to Use diff --git a/en/device-dev/subsystems/subsys-security.md b/en/device-dev/subsystems/subsys-security.md index b4ac9422314e3dcc450be62ed8ad0a2b1328bff5..bcd80d87f4995b81168b330709973e0a687c1c61 100644 --- a/en/device-dev/subsystems/subsys-security.md +++ b/en/device-dev/subsystems/subsys-security.md @@ -1,11 +1,13 @@ # Security -- **[Overview](subsys-security-overview.md)** +- **[Overview](subsys-security-overview.md)** -- **[Development Guidelines on Application Signature Verification](subsys-security-sigverify.md)** +- **[Development on Application Signature Verification] (subsys-security-sigverify.md)** -- **[Development Guidelines on Application Permission Management](subsys-security-rightmanagement.md)** +- **[Development on Application Permission Management](subsys-security-rightmanagement.md)** -- **[Development Guidelines on IPC Authentication](subsys-security-communicationverify.md)** +- **[Development on IPC Authentication](subsys-security-communicationverify.md)** +- **[Development on Device Security Level Management](subsys-security-devicesecuritylevel.md)** +- **[Development on Key Management](subsys-security-huks.md)** diff --git a/en/device-dev/subsystems/subsys-sensor-demo.md b/en/device-dev/subsystems/subsys-sensor-demo.md index 6a243c21fc0cc6607283e5b31e4ab9633fefb539..f914d045a59f36cb5bb14972987c8e755a41f363 100644 --- a/en/device-dev/subsystems/subsys-sensor-demo.md +++ b/en/device-dev/subsystems/subsys-sensor-demo.md @@ -1,4 +1,4 @@ -# Sensors Usage Example +# Sensor Usage Example The following sample code uses the sensor whose **sensorTypeId** is **0** as an example. The code for other sensor types is similar. diff --git a/en/device-dev/subsystems/subsys-sensor-guide.md b/en/device-dev/subsystems/subsys-sensor-guide.md index dc4cfb878fd568a18507f6d2c5a6bdbb6a783867..4f65a3d5005b8e771329202364d3c32f120e7440 100644 --- a/en/device-dev/subsystems/subsys-sensor-guide.md +++ b/en/device-dev/subsystems/subsys-sensor-guide.md @@ -1,4 +1,4 @@ -# Sensors Usage Guidelines +# Sensor Usage Guidelines The following steps use the sensor whose **sensorTypeId** is **0** as an example. The guidelines for other sensor types are similar. diff --git a/en/device-dev/subsystems/subsys-sensor-overview.md b/en/device-dev/subsystems/subsys-sensor-overview.md index ffd7478fe93bbbe3aad455652c810cbf5a1cfaf7..baaa934fe1e2b498a5c3668ae2bc6b6b53601a9d 100644 --- a/en/device-dev/subsystems/subsys-sensor-overview.md +++ b/en/device-dev/subsystems/subsys-sensor-overview.md @@ -1,4 +1,4 @@ -# Sensors Overview +# Sensor Overview ## Introduction diff --git a/en/device-dev/subsystems/subsys-sensor.md b/en/device-dev/subsystems/subsys-sensor.md index 937d03221f56bff810edbf42b2697710d1df131f..86091571411176655cfb29452781d01ee5e70c32 100644 --- a/en/device-dev/subsystems/subsys-sensor.md +++ b/en/device-dev/subsystems/subsys-sensor.md @@ -1,9 +1,9 @@ -# Sensors +# Sensor -- **[Sensors Overview](subsys-sensor-overview.md)** +- **[Sensor Overview](subsys-sensor-overview.md)** -- **[Sensors Usage Guidelines](subsys-sensor-guide.md)** +- **[Sensor Usage Guidelines](subsys-sensor-guide.md)** -- **[Sensors Usage Example](subsys-sensor-demo.md)** +- **[Sensor Usage Example](subsys-sensor-demo.md)** diff --git a/en/device-dev/subsystems/subsys-utils-guide.md b/en/device-dev/subsystems/subsys-utils-guide.md index 1988c6b9c43fb96ab6cd04a24fb5148dc8a3648e..6a6a786790f00aed60848586b64bb4861eb1738f 100644 --- a/en/device-dev/subsystems/subsys-utils-guide.md +++ b/en/device-dev/subsystems/subsys-utils-guide.md @@ -165,8 +165,8 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); ``` { "app": { - "bundleName": "com.huawei.launcher", - "vendor": "huawei", + "bundleName": "com.example.launcher", + "vendor": "example, "version": { "code": 1, "name": "1.0" @@ -189,7 +189,7 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); } }, "module": { - "package": "com.huawei.launcher", + "package": "com.example.launcher", "name": ".MyHarmonyAbilityPackage", "deviceType": [ "phone", "tv","tablet", "pc","car","smartWatch","sportsWatch","smartCamera" @@ -242,7 +242,7 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); 3. Send the command for running the native KV store application to the board through the serial port. ``` - ./nfs/dev_tools/bin/aa start -p com.huawei.launcher -n ServiceAbility + ./nfs/dev_tools/bin/aa start -p com.example.launcher -n ServiceAbility ``` diff --git a/en/readme/ARK-Runtime-Subsystem.md b/en/readme/ark-runtime.md similarity index 100% rename from en/readme/ARK-Runtime-Subsystem.md rename to en/readme/ark-runtime.md diff --git a/en/readme/figures/dms-architecture.png b/en/readme/figures/dms-architecture.png index e16d44ad783fc68a6a18a22ec497e360ff7dcab9..826d579fdce32aa57080e14141153f7dda7035f7 100644 Binary files a/en/readme/figures/dms-architecture.png and b/en/readme/figures/dms-architecture.png differ diff --git a/en/readme/figures/en-us_architecture-of-telephony-subsystem.png b/en/readme/figures/en-us_architecture-of-telephony-subsystem.png index a86a2dfe63a87487f3874fe7389a366fcef3c2cb..5a79ea900765c63116a2bcecfe33ac7eb7d9c24a 100755 Binary files a/en/readme/figures/en-us_architecture-of-telephony-subsystem.png and b/en/readme/figures/en-us_architecture-of-telephony-subsystem.png differ diff --git a/en/readme/globalization.md b/en/readme/globalization.md index 8879c928bbf1fe37d567799e8d6b5ed50ea15af1..6fc2c3fa69e1d42d94290ad6b8103cad00842328 100755 --- a/en/readme/globalization.md +++ b/en/readme/globalization.md @@ -45,13 +45,6 @@ The directory structure of the Globalization subsystem for the mini and small sy │ │ │ └── src # Implementation code │ ├── interfaces # APIs │ │ └── innerkits # APIs for internal subsystems -├── cust_lite # Code repository for the Cust framework -│ ├── frameworks # Core code of the Cust framework -│ │ ├── cust_lite # Cust framework -│ │ │ ├── src # Implementation code -│ │ │ └── test # Test code -│ ├── interfaces # APIs -│ │ └── innerkits # APIs for internal subsystems ``` The directory structure of the Globalization subsystem for the standard system is as follows: @@ -78,8 +71,6 @@ The directory structure of the Globalization subsystem for the standard system i **Globalization subsystem** -global\_cust\_lite - global\_i18n\_lite global\_i18n\_standard diff --git a/en/readme/kernel-subsystem.md b/en/readme/kernel.md similarity index 100% rename from en/readme/kernel-subsystem.md rename to en/readme/kernel.md diff --git a/en/readme/telephony.md b/en/readme/telephony.md index fc9c61caf189ba04613d9658ae1050b7b69f043a..6c53664a7cadf9765683544cc5de08f72588290c 100755 --- a/en/readme/telephony.md +++ b/en/readme/telephony.md @@ -1,18 +1,30 @@ # Telephony +- [Introduction](#section104mcpsimp) +- [Directory Structure](#section119mcpsimp) +- [Constraints](#section123mcpsimp) +- [Usage](#section128mcpsimp) + - [Obtaining the Current Cellular Network Signal Information](#section1458213210369) + - [Observing Changes to the Cellular Network Status](#section750135512369) + +- [Repositories Involved](#section152mcpsimp) + ## Introduction The Telephony subsystem provides APIs for obtaining information about the wireless cellular network and SIM card. Applications can call these APIs to obtain information such as the name of the currently registered network, network service status, signal strength, and SIM card information. The Telephony subsystem consists of the following modules: -- Telephony core service: initializes the RIL Manager, SIM card module, and network search module. +- Telephony core service: initializes the Radio Interface Layer (RIL) Manager, SIM card module, and radio module. - Call Manager module: manages three types of calls – circuit switched \(CS\), IP multimedia subsystem \(IMS\), and over the top \(OTT\) calls. It is responsible for applying for the audio and video resources required for a call and resolving conflicts in a multi-channel call. - Cellular call module: implements basic calls over carrier networks. +- Cellular data module: implements cellular data services over carrier networks. - SMS & MMS module: provides the capabilities of sending and receiving short message service \(SMS\) messages and encoding and decoding multimedia messaging service \(MMS\) messages. - State registry module: provides APIs to register and deregister an observer that listens for various callback events of the telephony subsystem. +- Data storage module: stores persistent data and provides **DataAbility** access APIs. +- RIL Adapter module: implements adaptation of the modem communication interfaces. -**Figure 1** Telephony subsystem architecture +**Figure 1** Telephony subsystem architecture ![](figures/en-us_architecture-of-telephony-subsystem.png) @@ -20,55 +32,61 @@ The Telephony subsystem consists of the following modules: ``` base/telephony/ -├── core_service # Core service +├── core_service # Telephony core service ├── call_manager # Call Manager module ├── cellular_call # Cellular call module +├── cellular_data # Cellular data module ├── sms_mms # SMS & MMS module -└── state_registry # State registry module +├── state_registry # State registry module +├── data_storage # Data storage module +└── ril_adapter # RIL Adapter module ``` ## Constraints -1. The open-source version currently supports only the CS call and SMS services. Cellular data and dual-SIM card are not supported. +1. The open-source version currently provides the cellular call (CS call only), SMS & MMS, and cellular data services and supports the dual-SIM framework. +2. The Hardware Device Interface (HDI) support is subject to the chip vendors' adaptation capability. For details, see [Telephony Service Development](https://gitee.com/openharmony/docs/blob/master/en/device-dev/subsystems/subsys-tel.md). ## Usage Guidelines -### Obtaining Current Cellular Network Signal Information +To learn more about the usage of each subsystem module, refer to the respective README. The following illustrates API usage by exemplifying how to obtain the current cellular network signal information and observe the cellular network status changes. + +### Obtaining the Current Cellular Network Signal Information -1. Import the **radio** namespace from **@ohos.telephony.radio.d.ts**. -2. Call the **getSignalInformation\(slotId: number\)** method in callback or Promise mode. This method works in asynchronous mode. -3. Obtain the result from the **SignalInformation** array in the callback. -4. Traverse the **SignalInformation** array to obtain the **signalLevel** \(signal strength\) for each **signalType** \(radio access technology\). +1. Import the **radio** namespace from **@ohos.telephony.radio.d.ts**. +2. Call the **getSignalInformation\(slotId: number\)** function via callback or promise. This function works in asynchronous mode. +3. Obtain the result from the **SignalInformation** array in the callback. +4. Traverse the **SignalInformation** array to obtain the **signalLevel** (signal strength) for each **signalType** (radio access technology). ``` // Import the radio package. import radio from "@ohos.telephony.radio"; // Set the value of slotId. - let slotId = 1; + let slotId = 0; // Call the API in callback mode. radio.getSignalInformation(slotId, (err, value) => { if (err) { - // If the API call failed, err is not empty. + // If the API call fails, err is not empty. console.error(`failed to getSignalInformation because ${err.message}`); return; } - // If the API call succeeded, err is empty. + // If the API call is successful, err is empty. for (let i = 0; i < value.length; i++) { console.log(`success to getSignalInformation: type is ${value[i].signalType}, level is ${value[i].signalLevel}`); } }); - // Call the API in Promise mode. + // Call the API in promise mode. let promise = radio.getSignalInformation(slotId); promise.then((value) => { - // The API call succeeded. + // The API call is successful. for (let i = 0; i < value.length; i++) { console.log(`success to getSignalInformation: type is ${value[i].signalType}, level is ${value[i].signalLevel}`); } }).catch((err) => { - // The API call failed. + // The API call fails. console.error(`failed to getSignalInformation because ${err.message}`); }); ``` @@ -76,62 +94,53 @@ base/telephony/ ### Observing Cellular Network Status Changes -**Adding an Observer** +Adding an Observer -1. Import the **observer** namespace from **@ohos.telephony.observer.d.ts**. -2. Call the **on\(type: 'networkStateChange'\)** method with **slotId** \(slot ID, optional\) and **callback** \(callback processing function\) passed in. -3. Register an **observer** instance for callback events of network status changes. +1. Import the **observer** namespace from **@ohos.telephony.observer.d.ts**. +2. Call the **on\(type:'networkStateChange'\)** function with **slotId** (slot ID, optional) and **callback** (callback processing function) passed in. +3. Register an **observer** instance for callback events of network status changes. ``` // Import the observer package. import observer from '@ohos.telephony.observer'; // Registers an observer. - observer.on('networkStateChange', {slotId: 1}, (err, value) => { - if (err) { - // If the API call failed, err is not empty. - console.error(`failed, because ${err.message}`); - return; - } - // If the API call succeeded, err is empty. - console.log(`success on. network state is ` + value); + observer.on('networkStateChange', {slotId: 0}, (value) => { + console.log(`network state is ` + value); }); ``` -**Removing the Observer** +Removing the Observer -1. Import the **observer** namespace from **@ohos.telephony.observer.d.ts**. -2. Call the **off\(type: 'networkStateChange'\)** method with the **callback** object passed to the **observer**. +1. Import the **observer** namespace from **@ohos.telephony.observer.d.ts**. +2. Call the **off\(type: 'networkStateChange'\)** function with the **callback** object passed to **observer**. ``` // Import the observer package. import observer from '@ohos.telephony.observer'; - // Deregister the observer. - observer.off('networkStateChange', (err, value) => { - if (err) { - // If the API call failed, err is not empty. - console.error(`failed, because ${err.message}`); - return; - } - // If the API call succeeded, err is empty. - console.log(`success off`); - }); + // Unregister the observer. + observer.off('networkStateChange'); ``` ## Repositories Involved -**Telephony subsystem** +**Telephony Subsystem** + +[telephony\_core\_service](https://gitee.com/openharmony/telephony_core_service/blob/master/README.md) + +[telephony\_call\_manager](https://gitee.com/openharmony/telephony_call_manager/blob/master/README.md) -[telephony_core_service](https://gitee.com/openharmony/telephony_core_service/blob/master/README.md) +[telephony\_cellular\_call](https://gitee.com/openharmony/telephony_cellular_call/blob/master/README.md) -[telephony_call_manager](https://gitee.com/openharmony/telephony_call_manager/blob/master/README.md) +[telephony\_cellular\_data](https://gitee.com/openharmony/telephony_cellular_data/blob/master/README.md) -[telephony_cellular_call](https://gitee.com/openharmony/telephony_cellular_call/blob/master/README.md) +[telephony\_sms\_mms](https://gitee.com/openharmony/telephony_sms_mms/blob/master/README.md) -[telephony_sms_mms](https://gitee.com/openharmony/telephony_sms_mms/blob/master/README.md) +[telephony\_state\_registry](https://gitee.com/openharmony/telephony_state_registry/blob/master/README.md) -[telephony_state_registry](https://gitee.com/openharmony/telephony_state_registry/blob/master/README.md) +telephony\_data\_storage +[telephony\_ril\_adapter](https://gitee.com/openharmony/telephony_ril_adapter/blob/master/README.md) diff --git a/en/readme/test_subsystem.md b/en/readme/test.md similarity index 100% rename from en/readme/test_subsystem.md rename to en/readme/test.md diff --git a/en/readme/testing.md b/en/readme/testing.md deleted file mode 100755 index e4f0f517b816bb896436a300a0a7bb50172493da..0000000000000000000000000000000000000000 --- a/en/readme/testing.md +++ /dev/null @@ -1,513 +0,0 @@ -# Testing - -## Overview - -The test-driven development mode is used during the development process. You can develop new cases or modify existing cases to test new or enhanced system features. The test helps you develop high-quality code in the development phase. - -## Directory Structure - -``` -test/ -├── developertest # Developers test framework -│ ├── aw # Static library of the test framework -│ ├── config # Test framework configuration -│ ├── examples # Test case examples -│ ├── src # Source code of the test framework -│ ├── third_party # Adaptation code for third-party modules on which the test framework depends -│ ├── start.bat # Developers test entry for Windows -│ ├── start.sh # Developers test entry for Linux -│ └── BUILD.gn # Build entry of the test framework -├── xdevice # Basic component of the test framework -│ ├── config # Framework configuration file -│ ├── extension # Extension for the basic component -│ ├── resource # Test resources of the basic component -│ └── src # Source code of the basic component -└── xts # X test suite -``` - -## Constraints - -The test tool environment must meet the following requirements: - -1. Python version: 3.7.5 or later -2. Paramiko version: 2.7.1 or later -3. Setuptools version: 40.8.0 or later -4. RSA version: 4.0 or later -5. NFS version: V4 or later \(required when device supports connection using the serial port but not the hdc\) -6. pySerial version: 3.3 or later \(required when the device supports connection using the serial port but not the hdc\) -7. OS version: Windows 10 or later; Ubuntu 18.04 - -## Installation - -The Python environment is required. - -1. Run the following command to install the Linux extension component Readline: - - ``` - sudo apt-get install libreadline-dev - ``` - - If the installation is successful, the following prompts are displayed: - - ``` - Reading package lists... Done - Building dependency tree - Reading state information... Done - libreadline-dev is already the newest version (7.0-3). - 0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded. - ``` - -2. Run the following command to install the plug-in Setuptools: - - ``` - pip3 install setuptools - ``` - - If the installation is successful, the following prompts are displayed: - - ``` - Requirement already satisfied: setuptools in d:\programs\python37\lib\site-packages (41.2.0) - ``` - -3. Run the following command to install the plug-in Paramiko: - - ``` - pip3 install paramiko - ``` - - If the installation is successful, the following prompts are displayed: - - ``` - Installing collected packages: pycparser, cffi, pynacl, bcrypt, cryptography, paramiko - Successfully installed bcrypt-3.2.0 cffi-1.14.4 cryptography-3.3.1 paramiko-2.7.2 pycparser-2.20 pynacl-1.4.0 - ``` - -4. Run the following command to install the Python plug-in RSA: - - ``` - pip3 install rsa - ``` - - If the installation is successful, the following prompts are displayed: - - ``` - Installing collected packages: pyasn1, rsa - Successfully installed pyasn1-0.4.8 rsa-4.7 - ``` - -5. Run the following command to install the serial port plug-in pySerial for Python on the local PC: - - ``` - pip3 install pyserial - ``` - - If the installation is successful, the following prompts are displayed: - - ``` - Requirement already satisfied: pyserial in d:\programs\python37\lib\site-packages\pyserial-3.4-py3.7.egg (3.4) - ``` - -6. If the device supports test result output only using the serial port, install the NFS server. - - For example, to install haneWIN NFS Server 1.2.50 for Windows, download the installation package from https://www.hanewin.net/nfs-e.htm. - - For Linux, run the following command: - - ``` - sudo apt install nfs-kernel-server - ``` - - If the installation is successful, the following prompts are displayed: - - ``` - Reading package lists... Done - Building dependency tree - Reading state information... Done - nfs-kernel-server is already the newest version (1:1.3.4-2.1ubuntu5.3). - 0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded. - ``` - - -## Test Cases - -- Test case specifications - - Naming rules - - The source file name of the test case must be consistent with the test suite content. A test suite can contain multiple test cases and has only one test source file that is globally unique. Source files are named in the \[Feature\]\_\[Function\]\_\[Subfunction 1\]\_\[Subfunction 1.1\] format. Subfunctions can be further divided. - - A source file name consists of lowercase letters and underscores \(\_\), and must end with **test**, for example, **developertest/examples/calculator**. - - - Test case coding specifications - - The test cases must comply with the feature code coding specifications. In addition, necessary case description information must be added. For details, see [Test case template](#li2069415903917). - - - Test case compilation and configuration specifications - - The test cases are compiled in GN mode. The configuration must comply with the compilation guide of the open-source project. - - -- Test case template - - For details, see the test case **developertest/examples/calculator/test/unittest/common/calculator\_add\_test.cpp**. - -- Directories planned for test cases - - ``` - subsystem # Subsystem and system module - ├── parts # Components - │ └── test # Module test - │ └── unittest # Unit test - │ ├── common # Common test cases - │ ├── phone # Test case of the smartphone form - │ └── ivi # Test case of the head unit form - │ └── liteos-a # Test case of the IP camera form - │ └── moduletest # Module test - │ ├── common - │ ├── phone - │ └── ivi - │ └── liteos-a - └── test # Subsystem test - └── resource # Test resources - ├── module - ├── common - ├── phone - ├── ivi - ├── liteos-a - └── systemtest # System test - ├── common - ├── phone - ├── ivi - ├── liteos-a - ``` - - >![](public_sys-resources/icon-note.gif) **NOTE:** - >The **phone**, **ivi**, **liteos-a** test cases are used as examples only for different device forms. For the same feature on different development boards, if the test cases are the same, they are stored in the **common** directory. For the same feature, if the test cases are used to distinguish different device forms and may include kernel differences and chip platform differences, the test cases are distinguished by directory. - -- Writing a test case - 1. Add comments to the test case header file. - 2. Reference the **gtest** header file and **ext** namespace. - 3. Add the header file to test. - 4. Define test suites \(test classes\). - 5. Implement specific test cases of the test suite, including test case comments and logic implementation. - 6. Set the test case compilation configuration. - - >![](public_sys-resources/icon-note.gif) **NOTE:** - >The following examples are provided for reference: - >For devices supporting the serial port only: **developertest/examples/lite/cxx\_demo/test/unittest/common/calc\_subtraction\_test.cpp**. - >For devices supporting the hdc: **developertest/examples/calculator/test/unittest/common/calculator\_add\_test.cpp**. - >- **SetUp** and **TearDown** are the processing logic before and after each test case in the test suite is executed. - >- **SetUpTestCase** and **TearDownTestCase** are the processing logic before and after all cases in the test suite are executed. - >- HWTEST usage: This method is applicable only to simple tests \(not depending on **Setup** and **Teardown**\). This method is not applicable to the scenario where multiple test scenarios require the same data configuration. The test cases may affect each other and are not independent. - >- Use the **printf** function to print logs. - - -- Writing a test case compilation file - - Define test case compilation and building objectives. - 1. Add comments to the test case compilation header file. - 2. Import the test case compilation template file. - 3. Specify the output path of the test case file. - 4. Configure the directory contained in the test case compilation dependency. - 5. Specify the file name generated by the test case compilation target. - 6. Write a specific test case compilation script and add the source files, configurations, and dependencies involved in the compilation. - 7. Group the target test case files by condition. The group name is fixed to **unittest/moduletest**. - - - If there are multiple test suites, define the common compilation configuration. - - Add test cases to the build system. - - >![](public_sys-resources/icon-note.gif) **NOTE:** - >The following examples are provided for reference: - >- Devices supporting serial port connection only - >Test case compilation configuration: **developertest/examples/lite/cxx\_demo/test/unittest/common/BUILD.gn** - >Compilation entry configuration: **developertest/examples/lite/BUILD.gn** - >- Devices supporting the hdc connection - >Test case compilation configuration: **developertest/examples/calculator/test/unittest/common/BUILD.gn** - >Compilation entry configuration: **developertest/examples/ohos.build** - - -- Writing a test case resource file - 1. Create the **resource** directory in the **test** directory of a component or module. - 2. Create a directory for a device form, for example, **phone**, in the **resource** directory. - 3. Create a folder named after the module in the device form directory, for example, **testmodule**. - 4. Create the **ohos\_test.xml** file in the folder named after the module. The file content is in the following format: - - ``` - - - - - - - - ``` - - 5. Define **resource\_config\_file** in the compilation configuration file of the test case to specify the resource file **ohos\_test.xml**. - - >![](public_sys-resources/icon-note.gif) **NOTE:** - >The resource file is used to push the **test.txt** file in the **resource** directory to the **/data/test/resource** directory of the device to test. To do so, run the **hdc push** command. - - 6. Configure the **ohos\_test.xml** file, which contains the following tags: - - >![](public_sys-resources/icon-note.gif) **NOTE:** - >**target\_name**: name of the test unit, which is usually defined in the **BUILD.gn** file in the test directory - >**preparer**: action to take before the test unit is executed - >**cleaner**: action to take after the test unit is executed - >**src="res"** indicates that test resources are stored in the **resource** directory under the root directory of the subsystem. **src="out"** indicates that test resources are in the **out/release/$**_subsystem name_ directory. - - -- Test case levels - - Basic \(level 1\) - - Major \(level 2\) - - Minor \(level 3\) - - Uncommon \(level 4\) - - -## Test Framework Usage - -- \(Optional\) Install the XDevice module. - 1. Open the **xdevice** installation directory, for example, **test/xdevice** in Windows. - 2. Open the console and run the following command: - - ``` - python setup.py install - ``` - - The following figure is displayed when the installation is complete. - - ``` - Installed d:\programs\python37\lib\site-packages\xdevice-0.0.0-py3.7.egg - Processing dependencies for xdevice==0.0.0 - Finished processing dependencies for xdevice==0.0.0 - ``` - - -- Configure the developers test module. - - Configuration file: **developertest/config/user\_config.xml** - - 1. Modify basic configuration parameters. - - \[build\] \# Set build parameters of the test case. - - ``` - - false - false - true - ... ... - - ``` - - >![](public_sys-resources/icon-note.gif) **NOTE:** - >**example**: whether to build the test case example. The default value is **false**. - >**version**: whether to build the test version. The default value is **false**. - >**testcase**: whether to build the test case. The default value is **true**. - - 2. For devices that support the Harmony device connector \(hdc\), modify the configuration file as follows: - - \[device\] \# Configure the device information with the **"usb-hdc"** attribute, including the test device IP address and the matched hdc port. - - ``` - - 192.168.1.1 - 9111 - - - ``` - - 3. For devices that support serial port connection only, modify the configuration file as follows: - - \[board\_info\] \# Configure development board information. - - ``` - - hispark - taurus - ipcamera - hb build - - ``` - - >![](public_sys-resources/icon-note.gif) **NOTE:** - >**board\_series**: development board series. The default value is **hispark**. - >**board\_type**: development board type. The default value is **taurus**. - >**board\_product**: target product. The default value is **ipcamera**. - >**build\_command**: command used for building the test version and test case. The default value is **hb build**. - - \[device\] \# Configure the serial port information with the **"ipcamera"** attribute, including the COM port and baud rate. For example: - - ``` - - - COM1 - cmd - 115200 - 8 - 1 - 1 - - - ``` - - -- Modify the configuration of the **developertest** component. - - \(Optional\) If a test case has been compiled, specify the compilation output path of the test case. In this case, the test platform will not recompile the test case. - - Configuration file: **config/user\_config.xml** - - 1. Specify the output path of the test case and the compilation output directory. Example: - - ``` - - /home/source_code/out/release/tests - - ``` - - 2. For devices that support serial port connection only, specify the NFS directory for the PC \(**host\_dir**\) and the corresponding directory for the development board \(**board\_dir**\) inside the **** tags. For example: - - ``` - - D:\nfs - user - - ``` - - -- Prepare the test environment. Check that the test environment meets the following conditions if the tested device supports only serial ports: - - The system image and file system have been burnt into a development board and are running properly on the development board. For example, in system mode, the device prompt **OHOS\#** is displayed during shell login, indicating that the system is running properly. - - The development host has been connected to the serial port of the development board and the network port. - - The IP addresses of the development host and development board are in the same network segment and can ping each other. - - An empty directory is created on the development host for mounting test cases through NFS, and the NFS service is started properly. - -- Run test suites. - - Start the test framework and go to the **test/developertest** directory. - 1. Run the following command to start the test framework in Windows. - - ``` - start.bat - ``` - - 2. Run the following command to start the test framework in Linux. - - ``` - ./strat.sh - ``` - - - - Select a device form. - - Configure device forms based on the actual development board, for example, **developertest/config/framework\_config.xml**. - - - Run the test command. - 1. To query the subsystems, modules, product forms, and test types supported by test cases, run the **show** commands. - - ``` - usage: - show productlist Querying supported product forms - show typelist Querying the supported test type - show subsystemlist Querying supported subsystems - show modulelist Querying supported modules - ``` - - 2. Run the following command to execute the test \(**-t** is mandatory, and **-ss** and **-tm** are optional\): - - ``` - run -t ut -ss test -tm example - ``` - - 3. Specify the parameters that can be used to execute the test suite specific to a specified feature or module. - - ``` - usage: run [-h] [-p PRODUCTFORM] [-t [TESTTYPE [TESTTYPE ...]]] - [-ss SUBSYSTEM] [-tm TESTMODULE] [-ts TESTSUIT] - [-tc TESTCASE] [-tl TESTLEVEL] - - optional arguments: - -h, --help show this help message and exit - -p PRODUCTFORM, --productform PRODUCTFORM Specified product form - -t [TESTTYPE [TESTTYPE ...]], --testtype [TESTTYPE [TESTTYPE ...]] - Specify test type(UT,MST,ST,PERF,ALL) - -ss SUBSYSTEM, --subsystem SUBSYSTEM Specify test subsystem - -tm TESTMODULE, --testmodule TESTMODULE Specified test module - -ts TESTSUIT, --testsuite TESTSUIT Specify test suite - -tc TESTCASE, --testcase TESTCASE Specify test case - -tl TESTLEVEL, --testlevel TESTLEVEL Specify test level - ``` - - - -- View test framework help if needed. - - Run the following command to query commands supported by the test platform: - - ``` - help - ``` - - -- Run the following command to exit the self-test platform: - - ``` - quit - ``` - - -## Test Result and Logs - -- Test logs and test reports are generated after you execute the test commands. -- Test result - - Reports are displayed on the console. The root directory of the test result is as follows: - - ``` - reports/xxxx-xx-xx-xx-xx-xx - ``` - - - Test case formatting result - - ``` - result/ - ``` - - - Test case logs - - ``` - log/plan_log_xxxx-xx-xx-xx-xx-xx.log - ``` - - - Report summary - - ``` - summary_report.html - ``` - - - Report details - - ``` - details_report.html - ``` - - -- Test framework logs - - ``` - reports/platform_log_xxxx-xx-xx-xx-xx-xx.log - ``` - -- Latest test reports - - ``` - reports/latest - ``` - - -## Repositories Involved - -**Testing subsystem** - -test\_developertest - -test\_xdevice - -test\_xdevice\_extension - diff --git a/en/readme/subsys-user-iam.md b/en/readme/user-iam.md similarity index 100% rename from en/readme/subsys-user-iam.md rename to en/readme/user-iam.md diff --git a/en/readme/x-test-suite.md b/en/readme/xts.md old mode 100755 new mode 100644 similarity index 100% rename from en/readme/x-test-suite.md rename to en/readme/xts.md diff --git a/en/release-notes/OpenHarmony-2-0-Canary.md b/en/release-notes/OpenHarmony-2-0-Canary.md index 4b366d447874c9623d2a9c9251df4ea5fdc2070d..b8b23c579d2136cf61b3c4ec15c60f2af303ce5a 100644 --- a/en/release-notes/OpenHarmony-2-0-Canary.md +++ b/en/release-notes/OpenHarmony-2-0-Canary.md @@ -1,4 +1,4 @@ -# OpenHarmony 2.0 Canary \(2021-06-02\) +# OpenHarmony 2.0 Canary \(2021-06-01\) ## Version Description @@ -78,7 +78,7 @@ repo forall -c'git lfs pull' | Source Code | Version | Mirror | SHA-256 Checksum | | -------- | -------- | -------- | -------- | | Full code base | 2.0 | [Download](https://repo.huaweicloud.com/harmonyos/os/2.0/code-2.0-canary_20210601.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/2.0/code-2.0-canary_20210601.tar.gz.sha256) | -| Release Notes | 2.0 | [Download](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-2-0-canary.md) | - | +| Release Notes | 2.0 | [Download](https://gitee.com/openharmony/docs/blob/master/en/release-notes/OpenHarmony-2-0-Canary.md) | - | ## What's New diff --git a/en/release-notes/Readme.md b/en/release-notes/Readme.md index 3d7db33edefe2a101b45ed1c50ce4ee37ac5b872..38c48debb7aa5779a46baa4d62170d8f12d7296c 100644 --- a/en/release-notes/Readme.md +++ b/en/release-notes/Readme.md @@ -6,7 +6,7 @@ ## OpenHarmony 2.x Releases - [OpenHarmony v2.2 beta2 (2021-08-04)](OpenHarmony-v2.2-beta2.md) -- [OpenHarmony 2.0 Canary (2021-06-02)](OpenHarmony-2-0-Canary.md) +- [OpenHarmony 2.0 Canary (2021-06-01)](OpenHarmony-2-0-Canary.md) ## OpenHarmony 1.x Releases - [OpenHarmony v1.1.4 LTS (2022-02-11)](OpenHarmony-v1-1-4-LTS.md) - [OpenHarmony v1.1.3 LTS (2021-09-30)](OpenHarmony-v1-1-3-LTS.md) diff --git a/en/website-directory.md b/en/website-directory.md new file mode 100644 index 0000000000000000000000000000000000000000..408d2993c0ee0e25806818ee36f4e1ec95dd842e --- /dev/null +++ b/en/website-directory.md @@ -0,0 +1,1869 @@ +# OpenHarmony + +——>——> Learn About the OpenHarmony Community + +——>——>——> [OpenHarmony](OpenHarmony-Overview.md) + +——>——>——> Learn About the OpenHarmony OS + +——>——>——>——>[Kernel](readme/kernel.md) + +——>——>——>——>[Driver](readme/driver.md) + +——>——>——>——>[ARK Runtime](readme/ark-runtime.md) + +——>——>——>——>[DFX](readme/dfx-subsystem.md) + +——>——>——>——>[JS UI Framework](readme/js-ui-framework.md) + +——>——>——>——>[Misc Services](readme/misc-services.md) + +——>——>——>——>[XTS](readme/xts.md) + +——>——>——>——>[Common Event and Notification](readme/common-event-notification.md) + +——>——>——>——>[Globalization](readme/globalization.md) + +——>——>——>——>[utils](readme/utils.md) + +——>——>——>——>[Distributed Scheduler](readme/distributed-scheduler.md) + +——>——>——>——>[Distributed Data Management](readme/distributed-data-management.md) + +——>——>——>——>[Distributed File](readme/distributed-file.md) + +——>——>——>——>[DSoftBus](readme/dsoftbus.md) + +——>——>——>——>[Update](readme/update.md) + +——>——>——>——>[Startup](readme/startup.md) + +——>——>——>——>[Graphics](readme/graphics.md) + +——>——>——>——>[Multimodal Input](readme/multimodal-input.md) + +——>——>——>——>[Multimedia](readme/multimedia.md) + +——>——>——>——>[Account](readme/account.md) + +——>——>——>——>[Pan-Sensor](readme/pan-sensor.md) + +——>——>——>——>[Test](readme/test.md) + +——>——>——>——>[Power Management](readme/power-management.md) + +——>——>——>——>[Telephony](readme/telephony.md) + +——>——>——>——>[System Apps](readme/system-apps.md) + +——>——>——>——>[Programming Language Runtime](readme/programming-language-runtime.md) + +——>——>——>——>[AI](readme/ai.md) + +——>——>——> [Glossary](device-dev/glossary/glossary.md) + +——>——>——> [OpenHarmony Release Notes](release-notes/Readme.md) + +——>——> Quick Start + +——>——>——>[Mini and Small Systems](device-dev/quick-start/quickstart-lite.md) + +——>——>——>——>[Overview of Mini and Small Systems](device-dev/quick-start/quickstart-lite-overview.md) + +——>——>——>——>[Environment Setup for Mini and Small Systems](device-dev/quick-start/quickstart-lite-env-setup.md) + +——>——>——>——>——>[Environment Setup Overview](device-dev/quick-start/quickstart-lite-env-setup-overview.md) + +——>——>——>——>——>[Environment Setup FAQs](device-dev/quick-start/quickstart-lite-env-setup-faqs.md) + +——>——>——>——>[Running Hello World](device-dev/quick-start/quickstart-lite-steps.md) + +——>——>——>——>——>[Hi3861 Development Board](device-dev/quick-start/quickstart-lite-steps-hi3861.md) + +——>——>——>——>——>——>[Setting Up the Environment](device-dev/quick-start/quickstart-lite-steps-hi3861-setting.md) + +——>——>——>——>——>——>[Running a Hello World Program](device-dev/quick-start/quickstart-lite-steps-hi3816-running.md) + +——>——>——>——>——>——>[FAQs](device-dev/quick-start/quickstart-lite-steps-hi3861-faqs.md) + +——>——>——>——>——>[Hi3516 Development Board](device-dev/quick-start/quickstart-lite-steps-hi3516.md) + +——>——>——>——>——>——>[Setting Up the Environment](device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md) + +——>——>——>——>——>——>[Running a Hello OHOS Program](device-dev/quick-start/quickstart-lite-steps-hi3516-running.md) + +——>——>——>——>——>——>[FAQs](device-dev/quick-start/quickstart-lite-steps-hi3516-faqs.md) + +——>——>——>——>——>[Hi3518 Development Board](device-dev/quick-start/quickstart-lite-steps-hi3518.md) + +——>——>——>——>——>——>[Setting Up the Environment](device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md) + +——>——>——>——>——>——>[Running a Hello OHOS Program](device-dev/quick-start/quickstart-lite-steps-hi3518-running.md) + +——>——>——>——>——>——>[FAQs](device-dev/quick-start/quickstart-lite-steps-hi3518-faqs.md) + +——>——>——>——>[Introduction](device-dev/quick-start/quickstart-lite-introduction.md) + +——>——>——>——>——>[Hi3861 Development Board](device-dev/quick-start/quickstart-lite-introduction-hi3861.md) + +——>——>——>——>——>[Hi3516 Development Board](device-dev/quick-start/quickstart-lite-introduction-hi3516.md) + +——>——>——>——>——>[Hi3518 Development Board](device-dev/quick-start/quickstart-lite-introduction-hi3518.md) + +——>——>——>[Standard System](device-dev/quick-start/quickstart-standard.md) + +——>——>——>——>[Standard System Introduction](device-dev/quick-start/quickstart-standard-overview.md) + +——>——>——>——>[Running an Image](device-dev/quick-start/quickstart-standard-running.md) + +——>——>——>——>[FAQs](device-dev/quick-start/quickstart-standard-faqs.md) + +——>——> Compatibility and Security + +——>——>——> [Privacy and Security](device-dev/security/security.md) + +——>——>——>——> [Privacy Protection](device-dev/security/security-privacy-protection.md) + +——>——>——>——> [Security Guidelines](device-dev/security/security-guidelines-overall.md) + +——>——> Porting + +——>——>——>[Mini System SoC Porting Guide](device-dev/porting/porting-minichip.md) + +——>——>——>——>[Porting Preparations](device-dev/porting/porting-chip-prepare.md) + +——>——>——>——>——>[Before You Start](device-dev/porting/oem_transplant_chip_prepare_knows.md) + +——>——>——>——>——>[Building Adaptation Process](device-dev/porting/porting-chip-prepare-process.md) + +——>——>——>——>[Kernel Porting](device-dev/porting/porting-chip-kernel.md) + +——>——>——>——>——>[Overview](device-dev/porting/porting-chip-kernel-overview.md) + +——>——>——>——>——>[Basic Kernel Adaptation](device-dev/porting/porting-chip-kernel-adjustment.md) + +——>——>——>——>——>[Kernel Porting Verification](device-dev/porting/porting-chip-kernel-verify.md) + +——>——>——>——>[Board-Level OS Porting](device-dev/porting/porting-chip-board.md) + +——>——>——>——>——>[Overview](device-dev/porting/porting-chip-board-overview.md) + +——>——>——>——>——>[Board-Level Driver Adaptation](device-dev/porting/porting-chip-board-driver.md) + +——>——>——>——>——>[Implementation of APIs at the HAL](device-dev/porting/porting-chip-board-hal.md) + +——>——>——>——>——>[System Modules](device-dev/porting/porting-chip-board-component.md) + +——>——>——>——>——>[lwIP Module Adaptation](device-dev/porting/porting-chip-board-lwip.md) + +——>——>——>——>——>[Third-party Module Adaptation](device-dev/porting/porting-chip-board-bundle.md) + +——>——>——>——>——>[XTS](device-dev/porting/porting-chip-board-xts.md) + +——>——>——>——>[FAQs](device-dev/porting/porting-chip-faqs.md) + +——>——>——>[Small System SoC Porting Guide](device-dev/porting/porting-smallchip.md) + +——>——>——>——>[Porting Preparations](device-dev/porting/porting-smallchip-prepare.md) + +——>——>——>——>——>[Before You Start](device-dev/porting/porting-smallchip-prepare-needs.md) + +——>——>——>——>——>[Compilation and Building](device-dev/porting/porting-smallchip-prepare-building.md) + +——>——>——>——>[Kernel Porting](device-dev/porting/porting-smallchip-kernel.md) + +——>——>——>——>——>[LiteOS Cortex-A](device-dev/porting/porting-smallchip-kernel-a.md) + +——>——>——>——>——>[Linux Kernel](device-dev/porting/porting-smallchip-kernel-linux.md) + +——>——>——>——>[Driver Porting](device-dev/porting/porting-smallchip-driver.md) + +——>——>——>——>——>[Overview](device-dev/porting/porting-smallchip-driver-overview.md) + +——>——>——>——>——>[Platform Driver Porting](device-dev/porting/porting-smallchip-driver-plat.md) + +——>——>——>——>——>[Device Driver Porting](device-dev/porting/porting-smallchip-driver-oom.md) + +——>——>——>[Standard System Porting Guide](device-dev/porting/standard-system-porting-guide.md) + +——>——>——>——>[Standard System Porting Guide](device-dev/porting/standard-system-porting-guide.md) + +——>——>——>——>[A Method for Rapidly Porting the OpenHarmony Linux Kernel](device-dev/porting/porting-linux-kernel.md) + +——>——>——>[Third-Party Library Porting Guide for Mini and Small Systems](device-dev/porting/porting-thirdparty.md) + +——>——>——>——>[Overview](device-dev/porting/porting-thirdparty-overview.md) + +——>——>——>——>[Porting a Library Built Using CMake](device-dev/porting/porting-thirdparty-cmake.md) + +——>——>——>——>[Porting a Library Built Using Makefile](device-dev/porting/porting-thirdparty-makefile.md) + +——>——> Subsystem Development + +——>——>——> [Kernel](device-dev/kernel/kernel.md) + +——>——>——>——> [Kernel for the Mini System](device-dev/kernel/kernel-mini.md) + +——>——>——>——>——> [Kernel Overview](device-dev/kernel/kernel-mini-overview.md) + +——>——>——>——>——> [Basic Kernel](device-dev/kernel/kernel-mini-basic.md) + +——>——>——>——>——>——> [Interrupt Management](device-dev/kernel/kernel-mini-basic-interrupt.md) + +——>——>——>——>——>——> [Task Management](device-dev/kernel/kernel-mini-basic-task.md) + +——>——>——>——>——>——> [Memory Management](device-dev/kernel/kernel-mini-basic-memory.md) + +——>——>——>——>——>——>——> [Basic Concepts](device-dev/kernel/kernel-mini-basic-memory-basic.md) + +——>——>——>——>——>——>——> [Static Memory](device-dev/kernel/kernel-mini-basic-memory-static.md) + +——>——>——>——>——>——>——> [Dynamic Memory](device-dev/kernel/kernel-mini-basic-memory-dynamic.md) + +——>——>——>——>——>——> [Kernel Communication Mechanisms](device-dev/kernel/kernel-mini-basic-ipc.md) + +——>——>——>——>——>——>——> [Event](device-dev/kernel/kernel-mini-basic-ipc-event.md) + +——>——>——>——>——>——>——> [Mutex](device-dev/kernel/kernel-mini-basic-ipc-mutex.md) + +——>——>——>——>——>——>——> [Queue](device-dev/kernel/kernel-mini-basic-ipc-queue.md) + +——>——>——>——>——>——>——> [Semaphore](device-dev/kernel/kernel-mini-basic-ipc-sem.md) + +——>——>——>——>——>——> [Time Management](device-dev/kernel/kernel-basic-mini-time.md) + +——>——>——>——>——>——> [Software Timer](device-dev/kernel/kernel-mini-basic-soft.md) + +——>——>——>——>——> [Extended Components](device-dev/kernel/kernel-mini-extend.md) + +——>——>——>——>——>——> [C++ Support](device-dev/kernel/kernel-mini-extend-support.md) + +——>——>——>——>——>——> [CPUP](device-dev/kernel/kernel-mini-extend-cpup.md) + +——>——>——>——>——>——> [Dynamic Loading](kernel-mini-extend-dynamic-loading.md) + +——>——>——>——>——>——> [File System](device-dev/kernel/kernel-mini-extend-file.md) + +——>——>——>——>——>——>——> [FAT](device-dev/kernel/kernel-mini-extend-file-fat.md) + +——>——>——>——>——>——>——> [LittleFS](device-dev/kernel/kernel-mini-extend-file-lit.md) + +——>——>——>——>——> [Kernel Debugging](device-dev/kernel/kernel-memory-inner.md) + +——>——>——>——>——>——> [Memory Debugging](device-dev/kernel/kernel-mini-memory-debug.md) + +——>——>——>——>——>——>——> [Memory Information Statistics](device-dev/kernel/kernel-mini-memory-debug-mes.md) + +——>——>——>——>——>——>——> [Memory Leak Check](device-dev/kernel/kernel-mini-imemory-debug-det.md) + +——>——>——>——>——>——>——> [Memory Corruption Check](device-dev/kernel/kernel-mini-memory-debug-cet.md) + +——>——>——>——>——>——> [Exception Debugging](device-dev/kernel/kernel-mini-memory-exception.md) + +——>——>——>——>——>——> [Trace](device-dev/kernel/kernel-mini-memory-trace.md) + +——>——>——>——>——>——> [LMS](device-dev/kernel/kernel-mini-debug-lms.md) + +——>——>——>——>——> [Appendix](device-dev/kernel/kernel-mini-app.md) + +——>——>——>——>——>——> [Kernel Coding Specification](device-dev/kernel/kernel-mini-appx-code.md) + +——>——>——>——>——>——> [Basic Data Structure](device-dev/kernel/kernel-mini-appx-data.md) + +——>——>——>——>——>——>——> [Doubly Linked List](device-dev/kernel/kernel-mini-appx-data-list.md) + +——>——>——>——>——>——> [Standard Libraries](device-dev/kernel/kernel-mini-appx-lib.md) + +——>——>——>——>——>——>——> [CMSIS Support](device-dev/kernel/kernel-mini-appx-lib-cmsis.md) + +——>——>——>——>——>——>——> [POSIX Support](device-dev/kernel/kernel-mini-appx-lib-posix.md) + +——>——>——>——> [Kernel for the Small System](device-dev/kernel/kernel-small.md) + +——>——>——>——>——> [Kernel Overview](device-dev/kernel/kernel-small-overview.md) + +——>——>——>——>——> [Kernel Startup](device-dev/kernel/kernel-small-start.md) + +——>——>——>——>——>——> [Startup in Kernel Mode](device-dev/kernel/kernel-small-start-kernel.md) + +——>——>——>——>——>——> [Startup in User Mode](device-dev/kernel/kernel-small-start-user.md) + +——>——>——>——>——> [Basic Kernel](device-dev/kernel/kernel-small-basics.md) + +——>——>——>——>——>——> [Interrupt and Exception Handling](device-dev/kernel/kernel-small-basic-interrupt.md) + +——>——>——>——>——>——> [Process Management](device-dev/kernel/kernel-small-basic-process.md) + +——>——>——>——>——>——>——> [Process](device-dev/kernel/kernel-small-basic-process-process.md) + +——>——>——>——>——>——>——> [Task](device-dev/kernel/kernel-small-basic-process-thread.md) + +——>——>——>——>——>——>——> [Scheduler](device-dev/kernel/kernel-small-basic-process-scheduler.md) + +——>——>——>——>——>——> [Memory Management](device-dev/kernel/kernel-small-basic-memory.md) + +——>——>——>——>——>——>——> [Heap Memory Management](device-dev/kernel/kernel-small-basic-memory-heap.md) + +——>——>——>——>——>——>——> [Physical Memory Management](device-dev/kernel/kernel-small-basic-memory-physical.md) + +——>——>——>——>——>——>——> [Virtual Memory Management](device-dev/kernel/kernel-small-basic-memory-virtual.md) + +——>——>——>——>——>——>——> [Virtual-to-Physical Mapping](device-dev/kernel/kernel-small-basic-inner-reflect.md) + +——>——>——>——>——>——> [Kernel Communication Mechanisms](device-dev/kernel/kernel-small-basic-trans.md) + +——>——>——>——>——>——>——> [Event](device-dev/kernel/kernel-small-basic-trans-event.md) + +——>——>——>——>——>——>——> [Semaphore](device-dev/kernel/kernel-small-basic-trans-semaphore.md) + +——>——>——>——>——>——>——> [Mutex](device-dev/kernel/kernel-small-basic-trans-mutex.md) + +——>——>——>——>——>——>——> [Queue](device-dev/kernel/kernel-small-basic-trans-queue.md) + +——>——>——>——>——>——>——> [RW Lock](device-dev/kernel/kernel-small-basic-trans-rwlock.md) + +——>——>——>——>——>——>——> [Futex](device-dev/kernel/kernel-small-basic-trans-user-mutex.md) + +——>——>——>——>——>——>——> [Signal](device-dev/kernel/kernel-small-basic-trans-user-signal.md) + +——>——>——>——>——>——> [Time Management](device-dev/kernel/kernel-small-basic-time.md) + +——>——>——>——>——>——> [Software Timer](device-dev/kernel/kernel-small-basic-softtimer.md) + +——>——>——>——>——>——> [Atomic Operation](device-dev/kernel/kernel-small-basic-atomic.md) + +——>——>——>——>——> [Extended Components](device-dev/kernel/kernel-small-bundles.md) + +——>——>——>——>——>——> [System Call](device-dev/kernel/kernel-small-bundles-system.md) + +——>——>——>——>——>——> [Dynamic Loading and Linking](device-dev/kernel/kernel-small-bundles-linking.md) + +——>——>——>——>——>——> [Virtual Dynamic Shared Object](device-dev/kernel/kernel-small-bundles-share.md) + +——>——>——>——>——>——> [LiteIPC](device-dev/kernel/kernel-small-bundles-ipc.md) + +——>——>——>——>——>——> [File Systems](device-dev/kernel/kernel-small-bundles-fs.md) + +——>——>——>——>——>——>——> [Virtual File System](device-dev/kernel/kernel-small-bundles-fs-virtual.md) + +——>——>——>——>——>——>——> [Supported File Systems](device-dev/kernel/kernel-small-bundles-fs-support.md) + +——>——>——>——>——>——>——>——> [FAT](device-dev/kernel/kernel-small-bundles-fs-support-fat.md) + +——>——>——>——>——>——>——>——> [JFFS2](device-dev/kernel/kernel-small-bundles-fs-support-jffs2.md) + +——>——>——>——>——>——>——>——> [NFS](device-dev/kernel/kernel-small-bundles-fs-support-nfs.md) + +——>——>——>——>——>——>——>——> [Ramfs](device-dev/kernel/kernel-small-bundles-fs-support-ramfs.md) + +——>——>——>——>——>——>——>——> [procfs](device-dev/kernel/kernel-small-bundles-fs-support-procfs.md) + +——>——>——>——>——>——>——> [File System Adaptation](device-dev/kernel/kernel-small-bundles-fs-new.md) + +——>——>——>——>——> [Debugging and Tools](device-dev/kernel/kernel-small-debug.md) + +——>——>——>——>——>——> [Shell](device-dev/kernel/kernel-small-debug-shell.md) + +——>——>——>——>——>——>——> [Introduction to the Shell](device-dev/kernel/kernel-small-debug-shell-overview.md) + +——>——>——>——>——>——>——> [Shell Command Development Guidelines](device-dev/kernel/kernel-small-debug-shell-guide.md) + +——>——>——>——>——>——>——> [Shell Command Programming Example](device-dev/kernel/kernel-small-debug-shell-build.md) + +——>——>——>——>——>——>——> [Shell Command Reference](device-dev/kernel/kernel-small-debug-shell-details.md) + +——>——>——>——>——>——>——>——> [System Commands](device-dev/kernel/kernel-small-debug-shell-cmd.md) + +——>——>——>——>——>——>——>——>——> [cpup](device-dev/kernel/kernel-small-debug-shell-cmd-cpup.md) + +——>——>——>——>——>——>——>——>——> [date](device-dev/kernel/kernel-small-debug-shell-cmd-date.md) + +——>——>——>——>——>——>——>——>——> [dmesg](device-dev/kernel/kernel-small-debug-shell-cmd-dmesg.md) + +——>——>——>——>——>——>——>——>——> [exec](device-dev/kernel/kernel-small-debug-shell-cmd-exec.md) + +——>——>——>——>——>——>——>——>——> [free](device-dev/kernel/kernel-small-debug-shell-cmd-free.md) + +——>——>——>——>——>——>——>——>——> [help](device-dev/kernel/kernel-small-debug-shell-cmd-help.md) + +——>——>——>——>——>——>——>——>——> [hwi](device-dev/kernel/kernel-small-debug-shell-cmd-hwi.md) + +——>——>——>——>——>——>——>——>——> [kill](device-dev/kernel/kernel-small-debug-shell-cmd-kill.md) + +——>——>——>——>——>——>——>——>——> [log](device-dev/kernel/kernel-small-debug-shell-cmd-log.md) + +——>——>——>——>——>——>——>——>——> [memcheck](device-dev/kernel/kernel-small-debug-shell-cmd-memcheck.md) + +——>——>——>——>——>——>——>——>——> [oom](device-dev/kernel/kernel-small-debug-shell-cmd-oom.md) + +——>——>——>——>——>——>——>——>——> [pmm](device-dev/kernel/kernel-small-debug-shell-cmd-pmm.md) + +——>——>——>——>——>——>——>——>——> [reset](device-dev/kernel/kernel-small-debug-shell-cmd-reset.md) + +——>——>——>——>——>——>——>——>——> [sem](device-dev/kernel/kernel-small-debug-shell-cmd-sem.md) + +——>——>——>——>——>——>——>——>——> [stack](device-dev/kernel/kernel-small-debug-shell-cmd-stack.md) + +——>——>——>——>——>——>——>——>——> [su](device-dev/kernel/kernel-small-debug-shell-cmd-su.md) + +——>——>——>——>——>——>——>——>——> [swtmr](device-dev/kernel/kernel-small-debug-shell-cmd-swtmr.md) + +——>——>——>——>——>——>——>——>——> [systeminfo](device-dev/kernel/kernel-small-debug-shell-cmd-sysinfo.md) + +——>——>——>——>——>——>——>——>——> [task](device-dev/kernel/kernel-small-debug-shell-cmd-task.md) + +——>——>——>——>——>——>——>——>——> [uname](device-dev/kernel/kernel-small-debug-shell-cmd-uname.md) + +——>——>——>——>——>——>——>——>——> [vmm](device-dev/kernel/kernel-small-debug-shell-cmd-vmm.md) + +——>——>——>——>——>——>——>——>——> [watch](device-dev/kernel/kernel-small-debug-shell-cmd-watch.md) + +——>——>——>——>——>——>——>——>——>[reboot](device-dev/kernel/kernel-small-debug-shell-cmd-reboot.md) + +——>——>——>——>——>——>——>——>——>[top](device-dev/kernel/kernel-small-debug-shell-cmd-top.md) + +——>——>——>——>——>——>——>——> [File Commands](device-dev/kernel/kernel-small-debug-shell-file.md) + +——>——>——>——>——>——>——>——>——> [cat](device-dev/kernel/kernel-small-debug-shell-file-cat.md) + +——>——>——>——>——>——>——>——>——> [cd](device-dev/kernel/kernel-small-debug-shell-file-cd.md) + +——>——>——>——>——>——>——>——>——> [chgrp](device-dev/kernel/kernel-small-debug-shell-file-chgrp.md) + +——>——>——>——>——>——>——>——>——> [chmod](device-dev/kernel/kernel-small-debug-shell-file-chmod.md) + +——>——>——>——>——>——>——>——>——> [chown](device-dev/kernel/kernel-small-debug-shell-file-chown.md) + +——>——>——>——>——>——>——>——>——> [cp](device-dev/kernel/kernel-small-debug-shell-file-cp.md) + +——>——>——>——>——>——>——>——>——> [format](device-dev/kernel/kernel-small-debug-shell-file-format.md) + +——>——>——>——>——>——>——>——>——> [ls](device-dev/kernel/kernel-small-debug-shell-file-ls.md) + +——>——>——>——>——>——>——>——>——> [lsfd](device-dev/kernel/kernel-small-debug-shell-file-lsfd.md) + +——>——>——>——>——>——>——>——>——> [mkdir](device-dev/kernel/kernel-small-debug-shell-file-mkdir.md) + +——>——>——>——>——>——>——>——>——> [mount](device-dev/kernel/kernel-small-debug-shell-file-mount.md) + +——>——>——>——>——>——>——>——>——> [partinfo](device-dev/kernel/kernel-small-debug-shell-file-partinfo.md) + +——>——>——>——>——>——>——>——>——> [partition](device-dev/kernel/kernel-small-debug-shell-file-partition.md) + +——>——>——>——>——>——>——>——>——> [pwd](device-dev/kernel/kernel-small-debug-shell-file-pwd.md) + +——>——>——>——>——>——>——>——>——> [rm](device-dev/kernel/kernel-small-debug-shell-file-rm.md) + +——>——>——>——>——>——>——>——>——> [rmdir](device-dev/kernel/kernel-small-debug-shell-file-rmdir.md) + +——>——>——>——>——>——>——>——>——> [statfs](device-dev/kernel/kernel-small-debug-shell-file-statfs.md) + +——>——>——>——>——>——>——>——>——> [sync](device-dev/kernel/kernel-small-debug-shell-file-sync.md) + +——>——>——>——>——>——>——>——>——> [touch](device-dev/kernel/kernel-small-debug-shell-file-touch.md) + +——>——>——>——>——>——>——>——>——> [writeproc](device-dev/kernel/kernel-small-debug-shell-file-write.md) + +——>——>——>——>——>——>——>——>——> [umount](device-dev/kernel/kernel-small-debug-shell-file-umount.md) + +——>——>——>——>——>——>——>——>——>[du](device-dev/kernel/kernel-small-debug-shell-file-du.md) + +——>——>——>——>——>——>——>——>——>[mv](device-dev/kernel/kernel-small-debug-shell-file-mv.md) + +——>——>——>——>——>——>——>——> [Network Commands](device-dev/kernel/kernel-small-debug-shell-net.md) + +——>——>——>——>——>——>——>——>——> [arp](device-dev/kernel/kernel-small-debug-shell-net-arp.md) + +——>——>——>——>——>——>——>——>——> [dhclient](device-dev/kernel/kernel-small-debug-shell-net-dhclient.md) + +——>——>——>——>——>——>——>——>——> [ifconfig](device-dev/kernel/kernel-small-debug-shell-net-ifconfig.md) + +——>——>——>——>——>——>——>——>——> [ipdebug](device-dev/kernel/kernel-small-debug-shell-net-ipdebug.md) + +——>——>——>——>——>——>——>——>——> [netstat](device-dev/kernel/kernel-small-debug-shell-net-netstat.md) + +——>——>——>——>——>——>——>——>——> [ntpdate](device-dev/kernel/kernel-small-debug-shell-net-ntpdate.md) + +——>——>——>——>——>——>——>——>——> [ping](device-dev/kernel/kernel-small-debug-shell-net-ping.md) + +——>——>——>——>——>——>——>——>——> [ping6](device-dev/kernel/kernel-small-debug-shell-net-ping6.md) + +——>——>——>——>——>——>——>——>——> [telnet](device-dev/kernel/kernel-small-debug-shell-net-telnet.md) + +——>——>——>——>——>——>——>——>——> [tftp](device-dev/kernel/kernel-small-debug-shell-net-tftp.md) + +——>——>——>——>——>——>——> [Magic Key](device-dev/kernel/kernel-small-debug-shell-magickey.md) + +——>——>——>——>——>——>——> [User-Mode Exception Information](device-dev/kernel/kernel-small-debug-shell-error.md) + +——>——>——>——>——>——> [Trace](device-dev/kernel/kernel-small-debug-trace.md) + +——>——>——>——>——>——> [Process Commissioning](device-dev/kernel/kernel-small-debug-process.md) + +——>——>——>——>——>——>——> [CPUP](device-dev/kernel/kernel-small-debug-process-cpu.md) + +——>——>——>——>——>——> [Kernel-Mode Memory Debugging](device-dev/kernel/kernel-small-debug-memory.md) + +——>——>——>——>——>——>——> [Memory Information Statistics](device-dev/kernel/kernel-small-debug-memory-info.md) + +——>——>——>——>——>——>——> [Memory Leak Check](device-dev/kernel/kernel-small-debug-memory-leak.md) + +——>——>——>——>——>——>——> [Memory Corruption Check](device-dev/kernel/kernel-small-debug-memory-corrupt.md) + +——>——>——>——>——>——>[User-Mode Memory Debugging](device-dev/kernel/kernel-small-debug-user.md) + +——>——>——>——>——>——>——>[Basic Concepts](device-dev/kernel/kernel-small-debug-user-concept.md) + +——>——>——>——>——>——>——>[Working Principles](device-dev/kernel/kernel-small-debug-user-function.md) + +——>——>——>——>——>——>——>[Usage](device-dev/kernel/kernel-small-debug-user-guide.md) + +——>——>——>——>——>——>——>——>[API Description](device-dev/kernel/kernel-small-debug-user-guide-api.md) + +——>——>——>——>——>——>——>——>[How to Use](device-dev/kernel/kernel-small-debug-user-guide-use.md) + +——>——>——>——>——>——>——>——>——>[Calling APIs](device-dev/kernel/kernel-small-debug-user-guide-use-api.md) + +——>——>——>——>——>——>——>——>——>[Using the CLI](device-dev/kernel/kernel-small-debug-user-guide-use-cli.md) + +——>——>——>——>——>——>——>[Typical Memory Problems](device-dev/kernel/kernel-small-debug-user-faqs.md) + +——>——>——>——>——>——> [Other Kernel Debugging Methods](device-dev/kernel/kernel-small-debug-other.md) + +——>——>——>——>——>——>——> [Dying Gasp](device-dev/kernel/kernel-small-debug-trace-other-lastwords.md) + +——>——>——>——>——>——>——> [Common Fault Locating Methods](device-dev/kernel/kernel-small-debug-trace-other-faqs.md) + +——>——>——>——>——> [Appendix](device-dev/kernel/kernel-small-apx.md) + +——>——>——>——>——>——> [Basic Data Structure](device-dev/kernel/kernel-small-apx-structure.md) + +——>——>——>——>——>——>——> [Doubly Linked List](device-dev/kernel/kernel-small-apx-dll.md) + +——>——>——>——>——>——>——> [Bitwise Operation](device-dev/kernel/kernel-small-apx-bitwise.md) + +——>——>——>——>——>——> [Standard Library](device-dev/kernel/kernel-small-apx-library.md) + +——>——>——>——> [Kernel for Standard System](device-dev/kernel/kernel-standard.md) + +——>——>——>——>——> [Linux Kernel Overview](device-dev/kernel/kernel-standard-overview.md) + +——>——>——>——>——> [Guidelines for Using Patches on OpenHarmony Development Boards](device-dev/kernel/kernel-standard-patch.md) + +——>——>——>——>——> [Guidelines for Compiling and Building the Linux Kernel](device-dev/kernel/kernel-standard-build.md) + +——>——>——> [Driver](device-dev/driver/driver.md) + +——>——>——>——>[HDF](device-dev/driver/driver-hdf.md) + +——>——>——>——>——>[HDF Overview](device-dev/driver/driver-hdf-overview.md) + +——>——>——>——>——>[Driver Development](device-dev/driver/driver-hdf-development.md) + +——>——>——>——>——>[Driver Service Management](device-dev/driver/driver-hdf-servicemanage.md) + +——>——>——>——>——>[Driver Message Mechanism Management](device-dev/driver/driver-hdf-message-management.md) + +——>——>——>——>——>[Driver Configuration Management](device-dev/driver/driver-hdf-manage.md) + +——>——>——>——>——>[HDF Development Example](device-dev/driver/driver-hdf-sample.md) + +——>——>——>——>[Platform Driver Development](device-dev/driver/driver-develop.md) + +——>——>——>——>——>[ADC](device-dev/driver/driver-platform-adc-develop.md) + +——>——>——>——>——>[GPIO](device-dev/driver/driver-platform-gpio-develop.md) + +——>——>——>——>——>[HDMI](device-dev/driver/driver-platform-hdmi-develop.md) + +——>——>——>——>——>[I2C](device-dev/driver/driver-platform-i2c-develop.md) + +——>——>——>——>——>[I3C](device-dev/driver/driver-platform-i3c-develop.md) + +——>——>——>——>——>[MIPI CSI](device-dev/driver/driver-platform-mipicsi-develop.md) + +——>——>——>——>——>[MIPI DSI](device-dev/driver/driver-platform-mipidsi-develop.md) + +——>——>——>——>——>[MMC](device-dev/driver/driver-platform-mmc-develop.md) + +——>——>——>——>——>[PWM](device-dev/driver/driver-platform-pwm-develop.md) + +——>——>——>——>——>[RTC](device-dev/driver/driver-platform-rtc-develop.md) + +——>——>——>——>——>[SDIO](device-dev/driver/driver-platform-sdio-develop.md) + +——>——>——>——>——>[SPI](device-dev/driver/driver-platform-spi-develop.md) + +——>——>——>——>——>[UART](device-dev/driver/driver-platform-uart-develop.md) + +——>——>——>——>——>[Watchdog](device-dev/driver/driver-platform-watchdog-develop.md) + +——>——>——>——>[Driver Platform Usage](device-dev/driver/driver-platform.md) + +——>——>——>——>——>[ADC](device-dev/driver/driver-platform-adc-des.md) + +——>——>——>——>——>[GPIO](device-dev/driver/driver-platform-gpio-des.md) + +——>——>——>——>——>[HDMI](device-dev/driver/driver-platform-hdmi-des.md) + +——>——>——>——>——>[I2C](device-dev/driver/driver-platform-i2c-des.md) + +——>——>——>——>——>[I3C](device-dev/driver/driver-platform-i3c-des.md) + +——>——>——>——>——>[MIPI CSI](device-dev/driver/driver-platform-mipicsi-des.md) + +——>——>——>——>——>[MIPI DSI](device-dev/driver/driver-platform-mipidsi-des.md) + +——>——>——>——>——>[PWM](device-dev/driver/driver-platform-pwm-des.md) + +——>——>——>——>——>[RTC](device-dev/driver/driver-platform-rtc-des.md) + +——>——>——>——>——>[SDIO](device-dev/driver/driver-platform-sdio-des.md) + +——>——>——>——>——>[SPI](device-dev/driver/driver-platform-spi-des.md) + +——>——>——>——>——>[UART](device-dev/driver/driver-platform-uart-des.md) + +——>——>——>——>——>[Watchdog](device-dev/driver/driver-platform-watchdog-des.md) + +——>——>——>——>[Peripheral Driver Usage](device-dev/driver/driver-peripherals.md) + +——>——>——>——>——>[LCD](device-dev/driver/driver-peripherals-lcd-des.md) + +——>——>——>——>——>[Touchscreen](device-dev/driver/driver-peripherals-touch-des.md) + +——>——>——>——>——>[Sensor](device-dev/driver/driver-peripherals-sensor-des.md) + +——>——>——>——>——>[WLAN](device-dev/driver/driver-peripherals-external-des.md) + +——>——>——>——>——>[Audio](device-dev/driver/driver-peripherals-audio-des.md) + +——>——>——>——>——>[USB](device-dev/driver/driver-peripherals-usb-des.md) + +——>——>——>——>——>[Camera](device-dev/driver/driver-peripherals-camera-des.md) + +——>——>——> [Compilation and Building](device-dev/subsystems/subsys-build.md) + +——>——>——>——> [Building Guidelines for Mini and Small Systems](device-dev/subsystems/subsys-build-mini-lite.md) + +——>——>——>——> [Building Guidelines for Standard Systems](device-dev/subsystems/subsys-build-standard-large.md) + +——>——>——>——>[Build System Coding Specifications and Best Practices](device-dev/subsystems/subsys-build-gn-coding-style-and-best-practice.md) + +——>——>——> [Distributed Remote Startup](device-dev/subsystems/subsys-remote-start.md) + +——>——>——> [Graphics](device-dev/subsystems/subsys-graphics.md) + +——>——>——>——> [Graphics](device-dev/subsystems/subsys-graphics-overview.md) + +——>——>——>——> [Development Guidelines on Container Components](device-dev/subsystems/subsys-graphics-container-guide.md) + +——>——>——>——> [Development Guidelines on Layout Container Components](device-dev/subsystems/subsys-graphics-layout-guide.md) + +——>——>——>——> [Development Guidelines on Common Components](device-dev/subsystems/subsys-graphics-common-guide.md) + +——>——>——>——> [Development Guidelines on Animators](device-dev/subsystems/subsys-graphics-animation-guide.md) + +——>——>——> [Multimedia](device-dev/subsystems/subsys-multimedia.md) + +——>——>——>——> [Camera](device-dev/subsystems/subsys-multimedia-camera.md) + +——>——>——>——>——> [Overview](device-dev/subsystems/subsys-multimedia-camera-overview.md) + +——>——>——>——>——> [Development Guidelines on Photographing](device-dev/subsystems/subsys-multimedia-camera-photo-guide.md) + +——>——>——>——>——> [Development Guidelines on Video Recording](device-dev/subsystems/subsys-multimedia-camera-record-guide.md) + +——>——>——>——>——> [Development Guidelines on Previewing](device-dev/subsystems/subsys-multimedia-camera-preview-guide.md) + +——>——>——>——> [Audio/Video](device-dev/subsystems/subsys-multimedia-video.md) + +——>——>——>——>——> [Overview](device-dev/subsystems/subsys-multimedia-video-overview.md) + +——>——>——>——>——> [Development Guidelines on Media Playback](device-dev/subsystems/subsys-multimedia-video-play-guide.md) + +——>——>——>——>——> [Development Guidelines on Media Recording](device-dev/subsystems/subsys-multimedia-video-record-guide.md) + +——>——>——> [Utils](device-dev/subsystems/subsys-utils.md) + +——>——>——>——> [Utils Overview](device-dev/subsystems/subsys-utils-overview.md) + +——>——>——>——> [Utils Development Guidelines](device-dev/subsystems/subsys-utils-guide.md) + +——>——>——>——> [Utils FAQ](device-dev/subsystems/subsys-utils-faqs.md) + +——>——>——> [AI Framework](device-dev/subsystems/subsys-aiframework.md) + +——>——>——>——> [AI Engine Framework](device-dev/subsystems/subsys-aiframework-guide.md) + +——>——>——>——> [Development Environment](device-dev/subsystems/subsys-aiframework-envbuild.md) + +——>——>——>——> [Technical Specifications](device-dev/subsystems/subsys-aiframework-tech.md) + +——>——>——>——>——> [Code Management](device-dev/subsystems/subsys-aiframework-tech-codemanage.md) + +——>——>——>——>——> [Naming](device-dev/subsystems/subsys-aiframework-tech-name.md) + +——>——>——>——>——> [API Development](device-dev/subsystems/subsys-aiframework-tech-interface.md) + +——>——>——>——> [Development Guidelines](device-dev/subsystems/subsys-aiframework-devguide.md) + +——>——>——>——>——> [SDK](device-dev/subsystems/subsys-aiframework-devguide-sdk.md) + +——>——>——>——>——> [Plug-in](device-dev/subsystems/subsys-aiframework-devguide-plugin.md) + +——>——>——>——>——> [Configuration File](device-dev/subsystems/subsys-aiframework-devguide-conf.md) + +——>——>——>——> [Development Examples](device-dev/subsystems/subsys-aiframework-demo.md) + +——>——>——>——>——> [KWS SDK](device-dev/subsystems/subsys-aiframework-demo-sdk.md) + +——>——>——>——>——> [KWS Plug-in](device-dev/subsystems/subsys-aiframework-demo-plugin.md) + +——>——>——>——>——> [KWS Configuration File](device-dev/subsystems/subsys-aiframework-demo-conf.md) + +——>——>——> [Sensor](device-dev/subsystems/subsys-sensor.md) + +——>——>——>——> [Sensor Overview](device-dev/subsystems/subsys-sensor-overview.md) + +——>——>——>——> [Sensor Usage Guidelines](device-dev/subsystems/subsys-sensor-guide.md) + +——>——>——>——> [Sensor Usage Example](device-dev/subsystems/subsys-sensor-demo.md) + +——>——>——> [Application Framework](device-dev/subsystems/subsys-application-framework.md) + +——>——>——>——> [Overview](device-dev/subsystems/subsys-application-framework-overview.md) + +——>——>——>——> [Setting Up a Development Environment](device-dev/subsystems/subsys-application-framework-envbuild.md) + +——>——>——>——> [Development Guidelines](device-dev/subsystems/subsys-application-framework-guide.md) + +——>——>——>——> [Development Example](device-dev/subsystems/subsys-application-framework-demo.md) + +——>——>——> [OTA Update](device-dev/subsystems/subsys-ota-guide.md) + +——>——>——>[Telephony Service](device-dev/subsystems/subsys-tel.md) + +——>——>——> [Security](device-dev/subsystems/subsys-security.md) + +——>——>——>——> [Overview](device-dev/subsystems/subsys-security-overview.md) + +——>——>——>——> [Development Guidelines on Application Signature Verification](device-dev/subsystems/subsys-security-sigverify.md) + +——>——>——>——> [Development Guidelines on Application Permission Management](device-dev/subsystems/subsys-security-rightmanagement.md) + +——>——>——>——> [Development Guidelines on IPC Authentication](device-dev/subsystems/subsys-security-communicationverify.md) + +——>——>——> [Startup](device-dev/subsystems/subsys-boot.md) + +——>——>——>——> [Startup](device-dev/subsystems/subsys-boot-overview.md) + +——>——>——>——> [init Module](device-dev/subsystems/subsys-boot-init.md) + +——>——>——>——> [appspawn Module](device-dev/subsystems/subsys-boot-appspawn.md) + +——>——>——>——> [bootstrap Module](device-dev/subsystems/subsys-boot-bootstrap.md) + +——>——>——>——> [syspara Module](device-dev/subsystems/subsys-boot-syspara.md) + +——>——>——>——> [FAQs](device-dev/subsystems/subsys-boot-faqs.md) + +——>——>——>——> [Reference](device-dev/subsystems/subsys-boot-ref.md) + +——>——>——> [DFX](device-dev/subsystems/subsys-dfx.md) + +——>——>——>——>[DFX Overview](device-dev/subsystems/subsys-dfx-overview.md) + +——>——>——>——>[HiLog Development](device-dev/subsystems/subsys-dfx-hilog-rich.md) + +——>——>——>——>[HiLog_Lite Development](device-dev/subsystems/subsys-dfx-hilog-lite.md) + +——>——>——>——>[HiTrace Development](device-dev/subsystems/subsys-dfx-hitrace.md) + +——>——>——>——>[HiCollie Development](device-dev/subsystems/subsys-dfx-hicollie.md) + +——>——>——>——>[HiSysEvent Development](device-dev/subsystems/subsys-dfx-hisysevent.md) + +——>——>——>——>——>[HiSysEvent Logging Configuration](device-dev/subsystems/subsys-dfx-hisysevent-logging-config.md) + +——>——>——>——>——>[HiSysEvent Logging](device-dev/subsystems/subsys-dfx-hisysevent-logging.md) + +——>——>——>——>——>[HiSysEvent Listening](device-dev/subsystems/subsys-dfx-hisysevent-listening.md) + +——>——>——>——>——>[HiSysEvent Query](device-dev/subsystems/subsys-dfx-hisysevent-query.md) + +——>——>——>——>——>[HiSysEvent Tool Usage](device-dev/subsystems/subsys-dfx-hisysevent-tool.md) + +——>——> Featured Topics + +——>——>——> [Bundle Development](device-dev/bundles/bundles.md) + +——>——>——>——> [Bundle Development Specifications](device-dev/bundles/oem_bundle_standard_des.md) + +——>——>——>——> [Development Guidelines](device-dev/bundles/bundles-guide.md) + +——>——>——>——>——> [Overview](device-dev/bundles/bundles-guide-overview.md) + +——>——>——>——>——> [Installing hpm-cli Tool](device-dev/bundles/bundles-guide-prepare.md) + +——>——>——>——>——> [Developing Bundles](device-dev/bundles/bundles-guide-develop.md) + +——>——>——>——> [HPM User Guide](device-dev/bundles/bundles-demo.md) + +——>——>——>——>——> [Introduction](device-dev/bundles/bundles-demo-hpmdescription.md) + +——>——>——>——>——> [Configuring the Compilation Environment](device-dev/bundles/bundles-demo-environment.md) + +——>——>——>——>——> [Development Example](device-dev/bundles/bundles-demo-devsample.md) + +——>——> Device Development Examples + +——>——>——> [Mini- and Small-System Devices](device-dev/guide/device-lite.md) + +——>——>——>——> [WLAN-connected Products](device-dev/guide/device-wlan.md) + +——>——>——>——>——> [LED Peripheral Control](device-dev/guide/device-wlan-led-control.md) + +——>——>——>——>——> [Third-Party SDK Integration](device-dev/guide/device-wlan-sdk.md) + +——>——>——>——> [Cameras Without a Screen](device-dev/guide/device-iotcamera.md) + +——>——>——>——>——> [Camera Control](device-dev/guide/device-iotcamera-control.md) + +——>——>——>——>——>——> [Overview](device-dev/guide/device-iotcamera-control-overview.md) + +——>——>——>——>——>——> [Development Guidelines](device-dev/guide/device-iotcamera-control-demo.md) + +——>——>——>——>——>——>——> [Photographing](device-dev/guide/device-iotcamera-control-demo-photodevguide.md) + +——>——>——>——>——>——>——> [Video Recording](device-dev/guide/device-iotcamera-control-demo-videodevguide.md) + +——>——>——>——>——>——> [Use Case](device-dev/guide/device-iotcamera-control-example.md) + +——>——>——>——> [Cameras with a Screen](device-dev/guide/device-camera.md) + +——>——>——>——>——> [Screen and Camera Control](device-dev/guide/device-camera-control.md) + +——>——>——>——>——>——> [Overview](device-dev/guide/device-camera-control-overview.md) + +——>——>——>——>——>——> [Development Guidelines](device-dev/guide/device-camera-control-demo.md) + +——>——>——>——>——>——>——> [Photographing](device-dev/guide/device-camera-control-demo-photoguide.md) + +——>——>——>——>——>——>——> [Video Recording](device-dev/guide/device-camera-control-demo-videoguide.md) + +——>——>——>——>——>——>——> [Previewing](device-dev/guide/device-camera-control-demo-previewguide.md) + +——>——>——>——>——>——> [Use Case](device-dev/guide/device-camera-control-example.md) + +——>——>——>——>——> [Visual Application Development](device-dev/guide/device-camera-visual.md) + +——>——>——>——>——>——> [Overview](device-dev/guide/device-camera-visual-overview.md) + +——>——>——>——>——>——> [Preparations](device-dev/guide/device-camera-visual-prepare.md) + +——>——>——>——>——>——> [Adding Pages](device-dev/guide/device-camera-visual-addpage.md) + +——>——>——>——>——>——> [Building the Home Page](device-dev/guide/device-camera-visual-firstpage.md) + +——>——>——>——>——>——> [Building the Details Page](device-dev/guide/device-camera-visual-details.md) + +——>——>——>——>——>——> [Debugging and Packaging](device-dev/guide/device-camera-visual-debug.md) + +——>——>——>——>——>——> [Running on the Device](device-dev/guide/device-camera-visual-run.md) + +——>——>——>——>——>——> [FAQs]](device-dev/guide/device-camera-visual-faqs.md) + +——>——>——> [Standard-System Devices](device-dev/guide/device-standard.md) + +——>——>——>——> [Development Guidelines on Clock Apps](device-dev/guide/device-clock-guide.md) + +——>——>——>——> [Development Example for Platform Drivers](device-dev/guide/device-driver-demo.md) + +——>——>——>——> [Development Example for Peripheral Drivers](device-dev/guide/device-outerdriver-demo.md) + +——>——> Application Development + +——>——>——> [Getting Started](application-dev/quick-start) + +——>——>——>——> [Preparations](application-dev/quick-start/start-overview.md) + +——>——>——>——> [Getting Started with JavaScript](application-dev/quick-start/start-with-js.md) + +——>——>——> ArkUI + +——>——>——>——> JavaScript-based Web-like Development Paradigm + +——>——>——>——>——> [Overview](application-dev/ui/ui-js-overview.md) + +——>——>——>——>——> Framework + +——>——>——>——>——>——> [File Organization](application-dev/ui/js-framework-file.md) + +——>——>——>——>——>——> ["js" Tag](application-dev/ui/js-framework-js-tag.md) + +——>——>——>——>——>——> [app.js](application-dev/ui/js-framework-js-file.md) + +——>——>——>——>——>——> Syntax + +——>——>——>——>——>——>——> [HML](application-dev/ui/js-framework-syntax-hml.md) + +——>——>——>——>——>——>——> [CSS](application-dev/ui/js-framework-syntax-css.md) + +——>——>——>——>——>——>——> [JavaScript](application-dev/ui/js-framework-syntax-js.md) + +——>——>——>——>——>——> [Lifecycle](application-dev/ui/js-framework-lifecycle.md) + +——>——>——>——>——>——> [Resource Limitations and Access](application-dev/ui/js-framework-resource-restriction.md) + +——>——>——>——>——>——> [Multi-Language Capability](application-dev/ui/js-framework-multiple-languages.md) + +——>——>——>——>——> Building the UI + +——>——>——>——>——>——> [Component Overview](application-dev/ui/ui-js-building-ui-component.md) + +——>——>——>——>——>——> Building the Layout + +——>——>——>——>——>——>——> [Layout Description](application-dev/ui/ui-js-building-ui-layout-intro.md) + +——>——>——>——>——>——>——> [Adding Title and Paragraph Text](application-dev/ui/ui-js-building-ui-layout-text.md) + +——>——>——>——>——>——>——> [Adding an Image](application-dev/ui/ui-js-building-ui-layout-image.md) + +——>——>——>——>——>——>——> [Adding a Comment](application-dev/ui/ui-js-building-ui-layout-comment.md) + +——>——>——>——>——>——>——> [Adding a Container](application-dev/ui/ui-js-building-ui-layout-external-container.md) + +——>——>——>——>——>——> [Adding Interactions](application-dev/ui/ui-js-building-ui-interactions.md) + +——>——>——>——>——>——> [Developing Animations](application-dev/ui/ui-js-building-ui-animation.md) + +——>——>——>——>——>——> [Defining Events](application-dev/ui/ui-js-building-ui-event.md) + +——>——>——>——>——>——> [Defining Page Routes](application-dev/ui/ui-js-building-ui-routes.md) + +——>——>——>——>——> Common Component Development Guidelines + +——>——>——>——>——>——> [Text](application-dev/ui/ui-js-components-text.md) + +——>——>——>——>——>——> [Input](application-dev/ui/ui-js-components-input.md) + +——>——>——>——>——>——> [Button](application-dev/ui/ui-js-components-button.md) + +——>——>——>——>——>——> [List](application-dev/ui/ui-js-components-list.md) + +——>——>——>——>——>——> [Picker](application-dev/ui/ui-js-components-picker.md) + +——>——>——>——>——>——> [Dialog](application-dev/ui/ui-js-components-dialog.md) + +——>——>——>——>——>——> [Form](application-dev/ui/ui-js-components-form.md) + +——>——>——>——>——>——> [Stepper](application-dev/ui/ui-js-components-stepper.md) + +——>——>——>——>——>——> [Tabs](application-dev/ui/ui-js-component-tabs.md) + +——>——>——>——>——>——> [Image](application-dev/ui/ui-js-components-images.md) + +——>——>——>——>——> Animation Development Guidelines + +——>——>——>——>——>——> CSS Animation + +——>——>——>——>——>——>——> [Defining Attribute Style Animations](application-dev/ui/ui-js-animate-attribute-style.md) + +——>——>——>——>——>——>——> [Defining Animations with the transform Attribute](application-dev/ui/ui-js-animate-transform.md) + +——>——>——>——>——>——>——> [Defining Animations with the background-position Attribute](application-dev/ui/ui-js-animate-background-position-style.md) + +——>——>——>——>——>——> JS Animation + +——>——>——>——>——>——>——> [Component Animation](application-dev/ui/ui-js-animate-component.md) + +——>——>——>——>——>——>——> Interpolator Animation + +——>——>——>——>——>——>——>——> [Animation Effect](application-dev/ui/ui-js-animate-dynamic-effects.md) + +——>——>——>——>——>——>——>——> [Animation Frame](application-dev/ui/ui-js-animate-frame.md) + +——>——>——>——>——> [Custom Components](application-dev/ui/ui-js-custom-components.md) + +——>——>——>——> TypeScript-based Declarative Development Paradigm + +——>——>——>——>——> [Overview](application-dev/ui/ui-ts-overview.md) + +——>——>——>——>——> Framework Overview + +——>——>——>——>——>——> File Organization + +——>——>——>——>——>——>——> [Directory Structure](application-dev/ui/ts-framework-directory.md) + +——>——>——>——>——>——>——> [Rules for Accessing Application Code Files](application-dev/ui/ts-framework-file-access-rules.md) + +——>——>——>——>——>——> ["js" Tag](application-dev/ui/ts-framework-js-tag.md) + +——>——>——>——>——>——> Resource Access + +——>——>——>——>——>——>——> [Media Resource Types](application-dev/ui/ts-media-resource-type.md) + +——>——>——>——>——>——> [Pixel Units](application-dev/ui/ts-pixel-units.md) + +——>——>——>——>——>——> [Types](application-dev/ui/ts-types.md) + +——>——>——>——>——> Declarative Syntax + +——>——>——>——>——>——> [Overview](application-dev/ui/ts-syntax-intro.md) + +——>——>——>——>——>——> General UI Description Specifications + +——>——>——>——>——>——>——> [Basic Concepts](application-dev/ui/ts-general-ui-concepts.md) + +——>——>——>——>——>——>——> Declarative UI Description Specifications + +——>——>——>——>——>——>——>——> [Configuration Without Parameters](application-dev/ui/ts-parameterless-configuration.md) + +——>——>——>——>——>——>——>——> [Configuration with Mandatory Parameters](application-dev/ui/ts-configuration-with-mandatory-parameters.md) + +——>——>——>——>——>——>——>——> [Attribute Configuration](application-dev/ui/ts-attribution-configuration.md) + +——>——>——>——>——>——>——>——> [Event Configuration](application-dev/ui/ts-event-configuration.md) + +——>——>——>——>——>——>——>——> [Child Component Configuration](application-dev/ui/ts-child-component-configuration.md) + +——>——>——>——>——>——>——> Componentization + +——>——>——>——>——>——>——>——> [@Component](application-dev/ui/ts-component-based-component.md) + +——>——>——>——>——>——>——>——> [@Entry](application-dev/ui/ts-component-based-entry.md) + +——>——>——>——>——>——>——>——> [@Preview](application-dev/ui/ts-component-based-preview.md) + +——>——>——>——>——>——>——>——> [@Builder](application-dev/ui/ts-component-based-builder.md) + +——>——>——>——>——>——>——>——> [@Extend](application-dev/ui/ts-component-based-extend.md) + +——>——>——>——>——>——>——>——> [@CustomDialog](application-dev/ui/ts-component-based-customdialog.md) + +——>——>——>——>——>——> About UI State Management + +——>——>——>——>——>——>——> [Basic Concepts](application-dev/ui/ts-ui-state-mgmt-concepts.md) + +——>——>——>——>——>——>——> Managing Component States + +——>——>——>——>——>——>——>——> [@State](application-dev/ui/ts-component-states-state.md) + +——>——>——>——>——>——>——>——> [@Prop](application-dev/ui/ts-component-states-prop.md) + +——>——>——>——>——>——>——>——> [@Link](application-dev/ui/ts-component-states-link.md) + +——>——>——>——>——>——>——> Managing Application States + +——>——>——>——>——>——>——>——> Interfaces + +——>——>——>——>——>——>——>——>——> [AppStorage](application-dev/ui/ts-application-states-appstorage.md) + +——>——>——>——>——>——>——>——>——> [PersistentStorage](application-dev/ui/ts-application-states-apis-persistentstorage.md) + +——>——>——>——>——>——>——>——>——> [Environment](application-dev/ui/ts-application-states-apis-environment.md) + +——>——>——>——>——>——>——>——> [Synchronization Between AppStorage and Components](application-dev/ui/ts-application-states-storagelink-storageprop.md) + +——>——>——>——>——>——>——> Managing Other States + +——>——>——>——>——>——>——>——> [@Observed and @ObjectLink](application-dev/ui/ts-other-states-observed-objectlink.md) + +——>——>——>——>——>——>——>——> [@Consume and @Provide](application-dev/ui/ts-other-states-consume-provide.md) + +——>——>——>——>——>——>——>——> [@Watch](application-dev/ui/ts-other-states-watch.md) + +——>——>——>——>——>——> About Rendering Control Syntax + +——>——>——>——>——>——>——> [if/else](application-dev/ui/ts-rending-control-syntax-if-else.md) + +——>——>——>——>——>——>——> [ForEach](application-dev/ui/ts-rending-control-syntax-foreach.md) + +——>——>——>——>——>——>——> [LazyForEach](application-dev/ui/ts-rending-control-syntax-lazyforeach.md) + +——>——>——>——>——>——> About @Component + +——>——>——>——>——>——>——> [build Function](application-dev/ui/ts-function-build.md) + +——>——>——>——>——>——>——> [Initialization of Custom Components' Member Variables](application-dev/ui/ts-custom-component-initialization.md) + +——>——>——>——>——>——>——> [Custom Component Lifecycle Callbacks](application-dev/ui/ts-custom-component-lifecycle-callbacks.md) + +——>——>——>——>——>——>——> [Component Creation and Re-initialization](application-dev/ui/ts-component-creation-re-initialization.md) + +——>——>——>——>——>——> About Syntactic Sugar + +——>——>——>——>——>——>——> [@Decorator](application-dev/ui/ts-syntactic-sugar-decorator.md) + +——>——>——>——>——>——>——> [Chain Call](application-dev/ui/ts-syntactic-sugar-chaining.md) + +——>——>——>——>——>——>——> [struct](application-dev/ui/ts-syntactic-sugar-struct.md) + +——>——>——>——>——>——>——> [Instantiating a struct Without the new Keyword](application-dev/ui/ts-instantiating-a-struct-without-new-keyword.md) + +——>——>——>——>——>——>——> [Using a Separate Line for New Component](application-dev/ui/ts-using-a-separate-line-for-new-component.md) + +——>——>——>——>——>——>——> [Restrictions on Using TypeScript for Generators](application-dev/ui/ts-restrictions-for-generators.md) + +——>——>——>——>——> Experiencing the Declarative UI + +——>——>——>——>——>——> [Creating a Declarative UI Project](application-dev/ui/ui-ts-creating-project.md) + +——>——>——>——>——>——> [Getting to Know Components](application-dev/ui/ui-ts-components.md) + +——>——>——>——>——>——> [Creating a Simple Page](application-dev/ui/ui-ts-creating-simple-page.md) + +——>——>——>——>——> Defining Page Layout and Connection + +——>——>——>——>——>——> [Building a Food Data Model](application-dev/ui/ui-ts-building-data-model.md) + +——>——>——>——>——>——> [Building a Food Category List Layout](application-dev/ui/ui-ts-building-category-list-layout.md) + +——>——>——>——>——>——> [Building a Food Category Grid Layout](application-dev/ui/ui-ts-building-category-grid-layout.md) + +——>——>——>——>——>——> [Implementing Page Redirection and Data Transmission](application-dev/ui/ui-ts-page-redirection-data-transmission.md) + +——>——>——> Media + +——>——>——>——> Audio + +——>——>——>——>——> [Audio Overview](application-dev/media/audio-overview.md) + +——>——>——>——>——> [Audio Playback Development](application-dev/media/audio-playback.md) + +——>——>——>——>——> [Audio Management Development](application-dev/media/audio-management.md) + +——>——>——>——>——> [Audio Recording Development](application-dev/media/audio-recorder.md) + +——>——>——>——>——> [Audio Playback Development Using AudioRenderer](application-dev/media/audio-renderer.md) + +——>——>——>——>——> [Audio Recorder Development Using AudioCapturer](application-dev/media/audio-capturer.md) + +——>——>——> User Authentication + +——>——>——>——> [User Authentication Overview](application-dev/security/userauth-overview.md) + +——>——>——>——> [User Authentication Development](application-dev/security/userauth-guidelines.md) + +——>——>——> IPC & RPC + +——>——>——>——> [IPC & RPC Overview](application-dev/connectivity/ipc-rpc-overview.md) + +——>——>——>——> [IPC & RPC Development Guidelines](application-dev/connectivity/ipc-rpc-development-guideline.md) + +——>——>——>——> [Subscribing to State Changes of a Remote Object](application-dev/connectivity/subscribe-remote-state.md) + +——>——>——> Data Management + +——>——>——>——> Distributed Data Service + +——>——>——>——> [Distributed Data Service Overview](application-dev/database/database-mdds-overview.md) + +——>——>——>——> [Distributed Data Service Development](application-dev/database/database-mdds-guidelines.md) + +——>——>——>——> Relational Database Overview + +——>——>——>——> [RDB Overview](application-dev/database/database-relational-overview.md) + +——>——>——>——> [RDB Development](application-dev/database/database-relational-guidelines.md) + +——>——>——>——> Lightweight Data Store + +——>——>——>——> [Lightweight Data Store Overview](application-dev/database/database-preference-overview.md) + +——>——>——>——> [Lightweight Data Store Development](application-dev/database/database-preference-guidelines.md) + +——>——>——> USB Service + +——>——>——>——> [USB Service Overview](application-dev/usb/usb-overview.md) + +——>——>——>——> [USB Service Development](application-dev/usb/usb-guidelines.md) + +——>——>——> DFX + +——>——>——>——> [Overview of Application Event Logging](application-dev/dfx/hiappevent-overview.md) + +——>——>——>——> [Development Guidelines on Application Event Logging](application-dev/dfx/hiappevent-guidelines.md) + +——>——>——> [DevEco Studio \(OpenHarmony\) User Guide](application-dev/quick-start/deveco-studio-user-guide-for-openharmony.md) + +——>——>——>——> [Overview](application-dev/quick-start/deveco-studio-overview.md) + +——>——>——>——> [Version Change History](application-dev/quick-start/deveco-studio-release-notes.md) + +——>——>——>——> [Configuring the OpenHarmony SDK](application-dev/quick-start/configuring-openharmony-sdk.md) + +——>——>——>——> [Creating an OpenHarmony Project](application-dev/quick-start/create-openharmony-project.md) + +——>——>——>——>——> [Using the Project Wizard to Create a Project](application-dev/quick-start/use-wizard-to-create-project.md) + +——>——>——>——>——> [Importing a Sample to Create a Project](application-dev/quick-start/import-sample-to-create-project.md) + +——>——>——>——> [Configuring the OpenHarmony App Signature](application-dev/quick-start/configuring-openharmony-app-signature.md) + +——>——>——>——> [Installing and Running Your OpenHarmony App](application-dev/quick-start/installing-openharmony-app.md) + +——>——> Debugging + +——>——>——> [Test Subsystem](device-dev/subsystems/subsys-testguide-test.md) + +——>——>——> [R&D Tools](device-dev/subsystems/subsys-toolchain.md) + +——>——>——>——> [bytrace Usage Guidelines](device-dev/subsystems/subsys-toolchain-bytrace-guide.md) + +——>——>——>——> [hdc\_std Usage Guidelines](device-dev/subsystems/subsys-toolchain-hdc-guide.md) + +——>——> XTS Certification + +——>——>——> [XTS](device-dev/subsystems/subsys-xts-guide.md) + +——>——> Tools + +——>——>——> [Docker Environment](device-dev/get-code/gettools-acquire.md) + +——>——>——> [IDE](device-dev/get-code/gettools-ide.md) + +——>——> References + +——>——>——> [JS APIs](application-dev/reference/apis/Readme-EN.md) + +——>——>——>——> Ability Framework + +——>——>——>——>——> [FeatureAbility Module](application-dev/reference/apis/js-apis-featureAbility.md) + +——>——>——>——>——> [ParticleAbility Module](application-dev/reference/apis/js-apis-particleAbility.md) + +——>——>——>——>——> [DataAbilityHelper Module](application-dev/reference/apis/js-apis-dataAbilityHelper.md) + +——>——>——>——>——> [DataUriUtils Module](application-dev/reference/apis/js-apis-DataUriUtils.md) + +——>——>——>——>——> [Bundle Module](application-dev/reference/apis/js-apis-Bundle.md) + +——>——>——>——>——> [CommonEvent Module](application-dev/reference/apis/js-apis-commonEvent.md) + +——>——>——>——>——> [Notification Module](application-dev/reference/apis/js-apis-notification.md) + +——>——>——>——>——> [Context Module](application-dev/reference/apis/js-apis-Context.md) + +——>——>——>——> Resource Management + +——>——>——>——>——> [Resource Manager](application-dev/reference/apis/js-apis-resource-manager.md) + +——>——>——>——>——> [Internationalization \(i18n\) ](application-dev/reference/apis/js-apis-i18n.md) + +——>——>——>——>——> [Internationalization \(intl\) ](application-dev/reference/apis/js-apis-intl.md) + +——>——>——>——> Media + +——>——>——>——>——> [Audio Management](application-dev/reference/apis/js-apis-audio.md) + +——>——>——>——>——> [Media](application-dev/reference/apis/js-apis-media.md) + +——>——>——>——> Security + +——>——>——>——>——> [User Authentication](application-dev/reference/apis/js-apis-useriam-userauth.md) + +——>——>——>——>——> [Access Control](application-dev/reference/apis/js-apis-abilityAccessCtrl.md) + +——>——>——>——> Data Management + +——>——>——>——>——> [Lightweight Storage (deprecated since 8)](application-dev/reference/apis/js-apis-data-storage.md) + +——>——>——>——>——> [Distributed Data Management](application-dev/reference/apis/js-apis-distributed-data.md) + +——>——>——>——>——> [Relational Database](application-dev/reference/apis/js-apis-data-rdb.md) + +——>——>——>——>——> [Result Set](application-dev/reference/apis/js-apis-data-resultset.md) + +——>——>——>——>——> [DataAbilityPredicates](application-dev/reference/apis/js-apis-data-ability.md) + +——>——>——>——>——> [Settings](application-dev/reference/apis/js-apis-settings.md) + +——>——>——>——> File Management + +——>——>——>——>——> [File Management](application-dev/reference/apis/js-apis-fileio.md) + +——>——>——>——>——> [Statfs](application-dev/reference/apis/js-apis-statfs.md) + +——>——>——>——>——> [Environment](application-dev/reference/apis/js-apis-environment.md) + +——>——>——>——>——> [Public File Access and Management](application-dev/reference/apis/js-apis-filemanager.md) + +——>——>——>——>——> [App Storage Statistics](application-dev/reference/apis/js-apis-storage-statistics.md) + +——>——>——>——>——> [Volume Management](application-dev/reference/apis/js-apis-volumemanager.md) + +——>——>——>——> Account Management + +——>——>——>——>——> [Distributed Account Management](application-dev/reference/apis/js-apis-distributed-account.md) + +——>——>——>——>——> [Application Account Management](application-dev/reference/apis/js-apis-appAccount.md) + +——>——>——>——> Telephony Service + +——>——>——>——>——> [Call](application-dev/reference/apis/js-apis-call.md) + +——>——>——>——>——> [SMS](application-dev/reference/apis/js-apis-sms.md) + +——>——>——>——>——> [SIM Management](application-dev/reference/apis/js-apis-sim.md) + +——>——>——>——>——> [Radio](application-dev/reference/apis/js-apis-radio.md) + +——>——>——>——> Network and Connectivity + +——>——>——>——>——> [WLAN](application-dev/reference/apis/js-apis-wifi.md) + +——>——>——>——>——> [Bluetooth](application-dev/reference/apis/js-apis-bluetooth.md) + +——>——>——>——> Device Management + +——>——>——>——>——> [Sensor](application-dev/reference/apis/js-apis-sensor.md) + +——>——>——>——>——> [Vibrator](application-dev/reference/apis/js-apis-vibrator.md) + +——>——>——>——>——> [Brightness](application-dev/reference/apis/js-apis-brightness.md) + +——>——>——>——>——> [Battery Info](application-dev/reference/apis/js-apis-battery-info.md) + +——>——>——>——>——> [Power Management](application-dev/reference/apis/js-apis-power.md) + +——>——>——>——>——> [Running Lock](application-dev/reference/apis/js-apis-runninglock.md) + +——>——>——>——>——> [Device Info](application-dev/reference/apis/js-apis-device-info.md) + +——>——>——>——>——> [systemParameter](application-dev/reference/apis/js-apis-system-parameter.md) + +——>——>——>——>——> [Device Management](application-dev/reference/apis/js-apis-device-manager.md) + +——>——>——>——>——> [Window](application-dev/reference/apis/js-apis-window.md) + +——>——>——>——>——> [Display](application-dev/reference/apis/js-apis-display.md) + +——>——>——>——>——> [Update](application-dev/reference/apis/js-apis-update.md) + +——>——>——>——>——> [USB](application-dev/reference/apis/js-apis-usb.md) + +——>——>——>——> Basic Features + +——>——>——>——>——> [Application Context](application-dev/reference/apis/js-apis-basic-features-app-context.md) + +——>——>——>——>——> [Console Logs](application-dev/reference/apis/js-apis-basic-features-logs.md) + +——>——>——>——>——> [Page Routing](application-dev/reference/apis/js-apis-basic-features-routes.md) + +——>——>——>——>——> [Pop-up Window](application-dev/reference/apis/js-apis-basic-features-pop-up.md) + +——>——>——>——>——> [Application Configuration](application-dev/reference/apis/js-apis-basic-features-configuration.md) + +——>——>——>——>——> [Timer](application-dev/reference/apis/js-apis-basic-features-timer.md) + +——>——>——>——>——> [Setting the System Time](application-dev/reference/apis/js-apis-system-time.md) + +——>——>——>——>——> [Animation](application-dev/reference/apis/js-apis-basic-features-animator.md) + +——>——>——>——>——> [WebGL](application-dev/reference/apis/js-apis-webgl.md) + +——>——>——>——>——> [WebGL2](application-dev/reference/apis/js-apis-webgl2.md) + +——>——>——>——> DFX + +——>——>——>——>——> [HiAppEvent](application-dev/reference/apis/js-apis-hiappevent.md) + +——>——>——>——>——> [Performance Tracing](application-dev/reference/apis/js-apis-hitracemeter.md) + +——>——>——>——>——> [Fault Logger](application-dev/reference/apis/js-apis-faultLogger.md) + +——>——>——>——>——> [Distributed Call Chain Tracing](application-dev/reference/apis/js-apis-hitracechain.md) + +——>——>——>——>——> [HiLog](application-dev/reference/apis/js-apis-hilog.md) + +——>——>——>——>——> [HiChecker](application-dev/reference/apis/js-apis-hichecker.md) + +——>——>——>——>——> [HiDebug](application-dev/reference/apis/js-apis-hidebug.md) + +——>——>——>——> Language Base Class Library + +——>——>——>——>——> [Obtaining Process Information](application-dev/reference/apis/js-apis-process.md) + +——>——>——>——>——> [URL String Parsing](application-dev/reference/apis/js-apis-url.md) + +——>——>——>——>——> [URI String Parsing](application-dev/reference/apis/js-apis-uri.md) + +——>——>——>——>——> [Util](application-dev/reference/apis/js-apis-util.md) + +——>——>——>——>——> [XML Parsing and Generation](application-dev/reference/apis/js-apis-xml.md) + +——>——>——>——>——> [XML-to-JavaScript Conversion](application-dev/reference/apis/js-apis-convertxml.md) + +——>——>——>——>——> [Worker Startup](application-dev/reference/apis/js-apis-worker.md) + +——>——>——> ArkUI Component References + +——>——>——>——> [TypeScript-based Declarative Development Paradigm](application-dev/reference/arkui-js/Readme-EN.md) + +——>——>——>——>——> Components + +——>——>——>——>——>——> Common + +——>——>——>——>——>——>——> [Universal Attributes](application-dev/reference/arkui-js/js-components-common-attributes.md) + +——>——>——>——>——>——>——> [Universal Styles](application-dev/reference/arkui-js/js-components-common-styles.md) + +——>——>——>——>——>——>——> [Universal Events](application-dev/reference/arkui-js/js-components-common-events.md) + +——>——>——>——>——>——>——> [Universal Methods](application-dev/reference/arkui-js/js-components-common-methods.md) + +——>——>——>——>——>——>——> [Animation Styles](application-dev/reference/arkui-js/js-components-common-animation.md) + +——>——>——>——>——>——>——> [Gradient Styles](application-dev/reference/arkui-js/js-components-common-gradient.md) + +——>——>——>——>——>——>——> [Transition Styles](application-dev/reference/arkui-js/js-components-common-transition.md) + +——>——>——>——>——>——>——> [Media Query](application-dev/reference/arkui-js/js-components-common-mediaquery.md) + +——>——>——>——>——>——>——> [Custom Font Styles](application-dev/reference/arkui-js/js-components-common-customizing-font.md) + +——>——>——>——>——>——>——> [Atomic Layout](application-dev/reference/arkui-js/js-components-common-atomic-layout.md) + +——>——>——>——>——>——> Container Component + +——>——>——>——>——>——>——> [badge](application-dev/reference/arkui-js/js-components-container-badge.md) + +——>——>——>——>——>——>——> [dialog](application-dev/reference/arkui-js/js-components-container-dialog.md) + +——>——>——>——>——>——>——> [div](application-dev/reference/arkui-js/js-components-container-div.md) + +——>——>——>——>——>——>——> [form](application-dev/reference/arkui-js/js-components-container-form.md) + +——>——>——>——>——>——>——> [list](application-dev/reference/arkui-js/js-components-container-list.md) + +——>——>——>——>——>——>——> [list-item](application-dev/reference/arkui-js/js-components-container-list-item.md) + +——>——>——>——>——>——>——> [list-item-group](application-dev/reference/arkui-js/js-components-container-list-item-group.md) + +——>——>——>——>——>——>——> [panel](application-dev/reference/arkui-js/js-components-container-panel.md) + +——>——>——>——>——>——>——> [popup](application-dev/reference/arkui-js/js-components-container-popup.md) + +——>——>——>——>——>——>——> [refresh](application-dev/reference/arkui-js/js-components-container-refresh.md) + +——>——>——>——>——>——>——> [stack](application-dev/reference/arkui-js/js-components-container-stack.md) + +——>——>——>——>——>——>——> [stepper](application-dev/reference/arkui-js/js-components-container-stepper.md) + +——>——>——>——>——>——>——> [stepper-item](application-dev/reference/arkui-js/js-components-container-stepper-item.md) + +——>——>——>——>——>——>——> [swiper](application-dev/reference/arkui-js/js-components-container-swiper.md) + +——>——>——>——>——>——>——> [tabs](application-dev/reference/arkui-js/js-components-container-tabs.md) + +——>——>——>——>——>——>——> [tab-bar](application-dev/reference/arkui-js/js-components-container-tab-bar.md) + +——>——>——>——>——>——>——> [tab-content](application-dev/reference/arkui-js/js-components-container-tab-content.md) + +——>——>——>——>——>——> Basic Components + +——>——>——>——>——>——>——> [button](application-dev/reference/arkui-js/js-components-basic-button.md) + +——>——>——>——>——>——>——> [chart](application-dev/reference/arkui-js/js-components-basic-chart.md) + +——>——>——>——>——>——>——> [divider](application-dev/reference/arkui-js/js-components-basic-divider.md) + +——>——>——>——>——>——>——> [image](application-dev/reference/arkui-js/js-components-basic-image.md) + +——>——>——>——>——>——>——> [image-animator](application-dev/reference/arkui-js/js-components-basic-image-animator.md) + +——>——>——>——>——>——>——> [input](application-dev/reference/arkui-js/js-components-basic-input.md) + +——>——>——>——>——>——>——> [label](application-dev/reference/arkui-js/js-components-basic-label.md) + +——>——>——>——>——>——>——> [marquee](application-dev/reference/arkui-js/js-components-basic-marquee.md) + +——>——>——>——>——>——>——> [menu](application-dev/reference/arkui-js/js-components-basic-menu.md) + +——>——>——>——>——>——>——> [option](application-dev/reference/arkui-js/js-components-basic-option.md) + +——>——>——>——>——>——>——> [picker](application-dev/reference/arkui-js/js-components-basic-picker.md) + +——>——>——>——>——>——>——> [picker-view](application-dev/reference/arkui-js/js-components-basic-picker-view.md) + +——>——>——>——>——>——>——> [piece](application-dev/reference/arkui-js/js-components-basic-piece.md) + +——>——>——>——>——>——>——> [progress](application-dev/reference/arkui-js/js-components-basic-progress.md) + +——>——>——>——>——>——>——> [qrcode](application-dev/reference/arkui-js/js-components-basic-qrcode.md) + +——>——>——>——>——>——>——> [rating](application-dev/reference/arkui-js/js-components-basic-rating.md) + +——>——>——>——>——>——>——> [richtext](application-dev/reference/arkui-js/js-components-basic-richtext.md) + +——>——>——>——>——>——>——> [search](application-dev/reference/arkui-js/js-components-basic-search.md) + +——>——>——>——>——>——>——> [select](application-dev/reference/arkui-js/js-components-basic-select.md) + +——>——>——>——>——>——>——> [slider](application-dev/reference/arkui-js/js-components-basic-slider.md) + +——>——>——>——>——>——>——> [span](application-dev/reference/arkui-js/js-components-basic-span.md) + +——>——>——>——>——>——>——> [switch](application-dev/reference/arkui-js/js-components-basic-switch.md) + +——>——>——>——>——>——>——> [text](application-dev/reference/arkui-js/js-components-basic-text.md) + +——>——>——>——>——>——>——> [textarea](application-dev/reference/arkui-js/js-components-basic-textarea.md) + +——>——>——>——>——>——>——> [toolbar](application-dev/reference/arkui-js/js-components-basic-toolbar.md) + +——>——>——>——>——>——>——> [toolbar-item](application-dev/reference/arkui-js/js-components-basic-toolbar-item.md) + +——>——>——>——>——>——>——> [toggle](application-dev/reference/arkui-js/js-components-basic-toggle.md) + +——>——>——>——>——>——> Media Components + +——>——>——>——>——>——>——> [video](application-dev/reference/arkui-js/js-components-media-video.md) + +——>——>——>——>——>——> Canvas Components + +——>——>——>——>——>——>——> [canvas](application-dev/reference/arkui-js/js-components-canvas-canvas.md) + +——>——>——>——>——>——>——> [CanvasRenderingContext2D](application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md) + +——>——>——>——>——>——>——> [Image](application-dev/reference/arkui-js/js-components-canvas-image.md) + +——>——>——>——>——>——>——> [CanvasGradient](application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md) + +——>——>——>——>——>——>——> [ImageData](application-dev/reference/arkui-js/js-components-canvas-imagedata.md) + +——>——>——>——>——>——>——> [Path2D](application-dev/reference/arkui-js/js-components-canvas-path2d.md) + +——>——>——>——>——>——>——> [ImageBitmap](application-dev/reference/arkui-js/js-components-canvas-imagebitmap.md) + +——>——>——>——>——>——>——> [OffscreenCanvas](application-dev/reference/arkui-js/js-components-canvas-offscreencanvas.md) + +——>——>——>——>——>——>——> [OffscreenCanvasRenderingContext2D](application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md) + +——>——>——>——>——>——> Grid + +——>——>——>——>——>——>——> [Basic Concepts](application-dev/reference/arkui-js/js-components-grid-basic-concepts.md) + +——>——>——>——>——>——>——> [grid-container](application-dev/reference/arkui-js/js-components-grid-container.md) + +——>——>——>——>——>——>——> [grid-row](application-dev/reference/arkui-js/js-components-grid-row.md) + +——>——>——>——>——>——>——> [grid-col](application-dev/reference/arkui-js/js-components-grid-col.md) + +——>——>——>——>——>——> SVG Components + +——>——>——>——>——>——>——> [Universal Attributes](application-dev/reference/arkui-js/js-components-svg-common-attributes.md) + +——>——>——>——>——>——>——> [svg](application-dev/reference/arkui-js/js-components-svg.md) + +——>——>——>——>——>——>——> [rect](application-dev/reference/arkui-js/js-components-svg-rect.md) + +——>——>——>——>——>——>——> [circle](application-dev/reference/arkui-js/js-components-svg-circle.md) + +——>——>——>——>——>——>——> [ellipse](application-dev/reference/arkui-js/js-components-svg-ellipse.md) + +——>——>——>——>——>——>——> [path](application-dev/reference/arkui-js/js-components-svg-path.md) + +——>——>——>——>——>——>——> [line](application-dev/reference/arkui-js/js-components-svg-line.md) + +——>——>——>——>——>——>——> [polyline](application-dev/reference/arkui-js/js-components-svg-polyline.md) + +——>——>——>——>——>——>——> [polygon](application-dev/reference/arkui-js/js-components-svg-polygon.md) + +——>——>——>——>——>——>——> [text](application-dev/reference/arkui-js/js-components-svg-text.md) + +——>——>——>——>——>——>——> [tspan](application-dev/reference/arkui-js/js-components-svg-tspan.md) + +——>——>——>——>——>——>——> [textPath](application-dev/reference/arkui-js/js-components-svg-textpath.md) + +——>——>——>——>——>——>——> [animate](application-dev/reference/arkui-js/js-components-svg-animate.md) + +——>——>——>——>——>——>——> [animateMotion](application-dev/reference/arkui-js/js-components-svg-animatemotion.md) + +——>——>——>——>——>——>——> [animateTransform](application-dev/reference/arkui-js/js-components-svg-animatetransform.md) + +——>——>——>——>——> Custom Components + +——>——>——>——>——>——> [Basic Usage](application-dev/reference/arkui-js/js-components-custom-basic-usage.md) + +——>——>——>——>——>——> [Custom Events](application-dev/reference/arkui-js/js-components-custom-events.md) + +——>——>——>——>——>——> [props](application-dev/reference/arkui-js/js-components-custom-props.md) + +——>——>——>——>——>——> [Event Parameter](application-dev/reference/arkui-js/js-components-custom-event-parameter.md) + +——>——>——>——>——>——> [slot](application-dev/reference/arkui-js/js-components-custom-slot.md) + +——>——>——>——>——>——> [Lifecycle Definition](application-dev/reference/arkui-js/js-components-custom-lifecycle.md) + +——>——>——>——>——> [Appendix](application-dev/reference/arkui-js/js-appendix.md) + +——>——>——>——>——>——> [Type Attributes](application-dev/reference/arkui-js/js-appendix-types.md) + +——>——>——>——> [TypeScript-based Declarative Development Paradigm](application-dev/reference/arkui-ts/Readme-EN.md) + +——>——>——>——>——> Components + +——>——>——>——>——>——> Universal Components + +——>——>——>——>——>——>——> [Universal Events](application-dev/reference/arkui-ts/ts-universal-events.md) + +——>——>——>——>——>——>——>——> [Click Event](application-dev/reference/arkui-ts/ts-universal-events-click.md) + +——>——>——>——>——>——>——>——> [Touch](application-dev/reference/arkui-ts/ts-universal-events-touch.md) + +——>——>——>——>——>——>——>——> [Show/Hide Event](application-dev/reference/arkui-ts/ts-universal-events-show-hide.md) + +——>——>——>——>——>——>——>——> [Key Event](application-dev/reference/arkui-ts/ts-universal-events-key.md) + +——>——>——>——>——>——>——>——>[Component Area Change Event](application-dev/reference/arkui-ts/ts-universal-events-component-area-change.md) + +——>——>——>——>——>——>——> Universal Attributes + +——>——>——>——>——>——>——>——> [Size](application-dev/reference/arkui-ts/ts-universal-attributes-size.md) + +——>——>——>——>——>——>——>——> [Location](application-dev/reference/arkui-ts/ts-universal-attributes-location.md) + +——>——>——>——>——>——>——>——> [Layout Constraints](application-dev/reference/arkui-ts/ts-universal-attributes-layout-constraints.md) + +——>——>——>——>——>——>——>——> [Flex Layout](application-dev/reference/arkui-ts/ts-universal-attributes-flex-layout.md) + +——>——>——>——>——>——>——>——> [Border Configuration](application-dev/reference/arkui-ts/ts-universal-attributes-border.md) + +——>——>——>——>——>——>——>——> [Background](application-dev/reference/arkui-ts/ts-universal-attributes-background.md) + +——>——>——>——>——>——>——>——> [Opacity](application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md) + +——>——>——>——>——>——>——>——> [Visibility](application-dev/reference/arkui-ts/ts-universal-attributes-visibility.md) + +——>——>——>——>——>——>——>——> [Enable/Disable](application-dev/reference/arkui-ts/ts-universal-attributes-enable.md) + +——>——>——>——>——>——>——>——> [Overlay](application-dev/reference/arkui-ts/ts-universal-attributes-overlay.md) + +——>——>——>——>——>——>——>——> [Z-order Control](application-dev/reference/arkui-ts/ts-universal-attributes-z-order.md) + +——>——>——>——>——>——>——>——> [Transformation](application-dev/reference/arkui-ts/ts-universal-attributes-transformation.md) + +——>——>——>——>——>——>——>——> [Image Effect Configuration](application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md) + +——>——>——>——>——>——>——>——> [Shape Clipping](application-dev/reference/arkui-ts/ts-universal-attributes-sharp-clipping.md) + +——>——>——>——>——>——>——>——> [Text Style](application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md) + +——>——>——>——>——>——>——>——> [Grid](application-dev/reference/arkui-ts/ts-universal-attributes-grid.md) + +——>——>——>——>——>——>——>——> [Gradient Color](application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md) + +——>——>——>——>——>——>——>——> [Popup Control](application-dev/reference/arkui-ts/ts-universal-attributes-popup.md) + +——>——>——>——>——>——>——>——> [Menu Control](application-dev/reference/arkui-ts/ts-universal-attributes-menu.md) + +——>——>——>——>——>——>——>——>[Click Control](application-dev/reference/arkui-ts/ts-universal-attributes-touchable.md) + +——>——>——>——>——>——>——>——>[Touch Target](application-dev/reference/arkui-ts/ts-universal-attributes-response-region.md) + +——>——>——>——>——>——>——> Gesture Processing + +——>——>——>——>——>——>——>——> [Gesture Binding Methods](application-dev/reference/arkui-ts/ts-gesture-settings.md) + +——>——>——>——>——>——>——>——> Basic Gestures + +——>——>——>——>——>——>——>——>——> [TapGesture](application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md) + +——>——>——>——>——>——>——>——>——> [LongPressGesture](application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md) + +——>——>——>——>——>——>——>——>——> [PanGesture](application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md) + +——>——>——>——>——>——>——>——>——> [PinchGesture](application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md) + +——>——>——>——>——>——>——>——>——> [RotationGesture](application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md) + +——>——>——>——>——>——>——>——>——> [SwipeGesture](application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md) + +——>——>——>——>——>——>——>——> [Combined Gestures](application-dev/reference/arkui-ts/ts-combined-gestures.md) + +——>——>——>——>——>——> Basic Components + +——>——>——>——>——>——>——> [Blank](application-dev/reference/arkui-ts/ts-basic-components-blank.md) + +——>——>——>——>——>——>——> [Button](application-dev/reference/arkui-ts/ts-basic-components-button.md) + +——>——>——>——>——>——>——> [DataPanel](application-dev/reference/arkui-ts/ts-basic-components-datapanel.md) + +——>——>——>——>——>——>——> [Divider](application-dev/reference/arkui-ts/ts-basic-components-divider.md) + +——>——>——>——>——>——>——>[Gauge](application-dev/reference/arkui-ts/ts-basic-components-gauge.md) + +——>——>——>——>——>——>——> [Image](application-dev/reference/arkui-ts/ts-basic-components-image.md) + +——>——>——>——>——>——>——> [ImageAnimator](application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md) + +——>——>——>——>——>——>——> [Progress](application-dev/reference/arkui-ts/ts-basic-components-progress.md) + +——>——>——>——>——>——>——> [QRCode](application-dev/reference/arkui-ts/ts-basic-components-qrcode.md) + +——>——>——>——>——>——>——> [Rating](application-dev/reference/arkui-ts/ts-basic-components-rating.md) + +——>——>——>——>——>——>——> [Span](application-dev/reference/arkui-ts/ts-basic-components-span.md) + +——>——>——>——>——>——>——> [Slider](application-dev/reference/arkui-ts/ts-basic-components-slider.md) + +——>——>——>——>——>——>——> [Text](application-dev/reference/arkui-ts/ts-basic-components-text.md) + +——>——>——>——>——>——>——> [TextArea](application-dev/reference/arkui-ts/ts-basic-components-textarea.md) + +——>——>——>——>——>——>——> [TextInput](application-dev/reference/arkui-ts/ts-basic-components-textinput.md) + +——>——>——>——>——>——>——> [Toggle](application-dev/reference/arkui-ts/ts-basic-components-toggle.md) + +——>——>——>——>——>——> Container Components + +——>——>——>——>——>——>——> [AlphabetIndexer](application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md) + +——>——>——>——>——>——>——> [Badge](application-dev/reference/arkui-ts/ts-container-badge.md) + +——>——>——>——>——>——>——> [Column](application-dev/reference/arkui-ts/ts-container-column.md) + +——>——>——>——>——>——>——> [ColumnSplit](application-dev/reference/arkui-ts/ts-container-columnsplit.md) + +——>——>——>——>——>——>——> [Counter](application-dev/reference/arkui-ts/ts-container-counter.md) + +——>——>——>——>——>——>——> [Flex](application-dev/reference/arkui-ts/ts-container-flex.md) + +——>——>——>——>——>——>——> [GridContainer](application-dev/reference/arkui-ts/ts-container-gridcontainer.md) + +——>——>——>——>——>——>——> [Grid](application-dev/reference/arkui-ts/ts-container-grid.md) + +——>——>——>——>——>——>——> [GridItem](application-dev/reference/arkui-ts/ts-container-griditem.md) + +——>——>——>——>——>——>——> [List](application-dev/reference/arkui-ts/ts-container-list.md) + +——>——>——>——>——>——>——> [ListItem](application-dev/reference/arkui-ts/ts-container-listitem.md) + +——>——>——>——>——>——>——> [Navigator](application-dev/reference/arkui-ts/ts-container-navigator.md) + +——>——>——>——>——>——>——> [Navigation](application-dev/reference/arkui-ts/ts-container-navigation.md) + +——>——>——>——>——>——>——> [Panel](application-dev/reference/arkui-ts/ts-container-panel.md) + +——>——>——>——>——>——>——> [Row](application-dev/reference/arkui-ts/ts-container-row.md) + +——>——>——>——>——>——>——> [RowSplit](application-dev/reference/arkui-ts/ts-container-rowsplit.md) + +——>——>——>——>——>——>——> [Scroll](application-dev/reference/arkui-ts/ts-container-scroll.md) + +——>——>——>——>——>——>——> [ScrollBar](application-dev/reference/arkui-ts/ts-container-scrollbar.md) + +——>——>——>——>——>——>——> [Stack](application-dev/reference/arkui-ts/ts-container-stack.md) + +——>——>——>——>——>——>——> [Swiper](application-dev/reference/arkui-ts/ts-container-swiper.md) + +——>——>——>——>——>——>——> [Tabs](application-dev/reference/arkui-ts/ts-container-tabs.md) + +——>——>——>——>——>——>——> [TabContent](application-dev/reference/arkui-ts/ts-container-tabcontent.md) + +——>——>——>——>——>——>——> [Stepper](application-dev/reference/arkui-ts/ts-container-stepper.md) + +——>——>——>——>——>——>——> [StepperItem](application-dev/reference/arkui-ts/ts-container-stepperitem.md) + +——>——>——>——>——>——> Drawing Components + +——>——>——>——>——>——>——> [Circle](application-dev/reference/arkui-ts/ts-drawing-components-circle.md) + +——>——>——>——>——>——>——> [Ellipse](application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md) + +——>——>——>——>——>——>——> [Line](application-dev/reference/arkui-ts/ts-drawing-components-line.md) + +——>——>——>——>——>——>——> [Polyline](application-dev/reference/arkui-ts/ts-drawing-components-polyline.md) + +——>——>——>——>——>——>——> [Polygon](application-dev/reference/arkui-ts/ts-drawing-components-polygon.md) + +——>——>——>——>——>——>——> [Path](application-dev/reference/arkui-ts/ts-drawing-components-path.md) + +——>——>——>——>——>——>——> [Rect](application-dev/reference/arkui-ts/ts-drawing-components-rect.md) + +——>——>——>——>——>——>——> [Shape](application-dev/reference/arkui-ts/ts-drawing-components-shape.md)‘ + +——>——>——>——>——>——> Canvas Components + +——>——>——>——>——>——>——>[Canvas](application-dev/reference/arkui-ts/ts-components-canvas-canvas.md) + +——>——>——>——>——>——>——>[Lottie](application-dev/reference/arkui-ts/ts-components-canvas-lottie.md) + +——>——>——>——>——> Animation + +——>——>——>——>——>——> [Attribute Animation](application-dev/reference/arkui-ts/ts-animatorproperty.md) + +——>——>——>——>——>——> [Explicit Animation](application-dev/reference/arkui-ts/ts-explicit-animation.md) + +——>——>——>——>——>——> Transition Animation + +——>——>——>——>——>——>——> [Page Transition](application-dev/reference/arkui-ts/ts-page-transition-animation.md) + +——>——>——>——>——>——>——> [Component Transition](application-dev/reference/arkui-ts/ts-transition-animation-component.md) + +——>——>——>——>——>——>——> [Transition of Shared Elements](application-dev/reference/arkui-ts/ts-transition-animation-shared-elements.md) + +——>——>——>——>——>——> [Motion Path Animation](application-dev/reference/arkui-ts/ts-motion-path-animation.md) + +——>——>——>——>——>——> [Matrix Transformation](application-dev/reference/arkui-ts/ts-matrix-transformation.md) + +——>——>——>——>——>——> [Interpolation Calculation](application-dev/reference/arkui-ts/ts-interpolation-calculation.md) + +——>——>——>——>——> Global UI Methods + +——>——>——>——>——>——> [Alert Dialog Box](application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md) + +——>——>——>——>——>——> [Custom Dialog box](application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md) + +——>——>——>——>——>——> [Image Cache](application-dev/reference/arkui-ts/ts-methods-image-cache.md) + +——>——>——>——>——>——> [Media Query](application-dev/reference/arkui-ts/ts-methods-media-query.md) + +——>——>——>——>——>——> [List Selection Dialog Box](application-dev/reference/arkui-ts/ts-methods-action-sheet.md) + +——>——>——>——>——> Appendix + +——>——>——>——>——>——> [Built-in Enums](application-dev/reference/arkui-ts/ts-appendix-enums.md) + +——>——>——>[Directory Structure](application-dev/quick-start/package-structure.md) + +——>——>——> FAQs-Device Management + +——>——>——>——>[Overview of FAQs](device-dev/faqs/faqs-overview.md) + +——>——>——>——>[Environment Setup](device-dev/faqs/faqs-environment-setup.md) + +——>——>——>——>[Compilation and Building Subsystem](device-dev/faqs/faqs-building.md) + +——>——>——>——>[Burning](device-dev/faqs/faqs-burning.md) + +——>——>——>——>[Kernel](device-dev/faqs/faqs-kernel.md) + +——>——>——>——>[Porting](device-dev/faqs/faqs-porting.md) + +——>——>——>——>[Startup](device-dev/faqs/faqs-startup.md) + +——>——>——>——>[System Applications](device-dev/faqs/faqs-system-applications.md) + +——>——> Contribution + +——>——>——>[Contribution](contribute/contribution.md) + +——>——>——> [Code of Conduct](contribute/code-of-conduct.md) + +——>——>——>[Code Contribution](contribute/code-contribution.md) + +——>——>——>[Contribution Process](contribute/contribution-process.md) + +——>——>——> [Documentation Contribution](contribute/documentation-contribution.md) + +——>——>——>——>[Writing Instructions](contribute/writing-instructions.md) + +——>——>——>——>[Writing Documents for a Release](contribute/docs-release-process.md) + +——>——>——>[Communication in Community](contribute/communication-in-community.md) + +——>——>——>[FAQ](contribute/FAQ.md) diff --git a/zh-cn/OpenHarmony-Overview_zh.md b/zh-cn/OpenHarmony-Overview_zh.md index 0364f1359d181f39221e2b048e667e0fb63b06c8..f7e698c5051ce34b1848af423eb8c80805284e07 100644 --- a/zh-cn/OpenHarmony-Overview_zh.md +++ b/zh-cn/OpenHarmony-Overview_zh.md @@ -23,7 +23,7 @@ OpenHarmony是由开放原子开源基金会(OpenAtom Foundation)孵化及 OpenHarmony整体遵从分层设计,从下向上依次为:内核层、系统服务层、框架层和应用层。系统功能按照“系统 \> 子系统 \> 组件”逐级展开,在多设备部署场景下,支持根据实际需求裁剪某些非必要的组件。OpenHarmony技术架构如下所示: -![](https://gitee.com/openharmony/docs/raw/master/zh-cn/figures/1.png) +![](figures/1.png) **内核层** @@ -42,14 +42,14 @@ OpenHarmony整体遵从分层设计,从下向上依次为:内核层、系统 - 增强软件服务子系统集:提供针对不同设备的、差异化的能力增强型软件服务,由智慧屏专有业务、穿戴专有业务、IoT专有业务等子系统组成。 -- 硬件服务子系统集:提供硬件服务,由位置服务、生物特征识别、穿戴专有硬件服务、IoT专有硬件服务等子系统组成。 +- 硬件服务子系统集:提供硬件服务,由位置服务、用户IAM、穿戴专有硬件服务、IoT专有硬件服务等子系统组成。 根据不同设备形态的部署环境,基础软件服务子系统集、增强软件服务子系统集、硬件服务子系统集内部可以按子系统粒度裁剪,每个子系统内部又可以按功能粒度裁剪。 **框架层** -框架层为应用开发提供了C/C++/JS等多语言的用户程序框架和Ability框架,适用于JS语言的JS UI框架,以及各种软硬件服务对外开放的多语言框架API。根据系统的组件化裁剪程度,设备支持的API也会有所不同。 +框架层为应用开发提供了C/C++/JS等多语言的用户程序框架和Ability框架,适用于JS语言的ArkUI框架,以及各种软硬件服务对外开放的多语言框架API。根据系统的组件化裁剪程度,设备支持的API也会有所不同。 **应用层** diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index e91b5d97f37a5254720235875d1a4d78b9bf29d6..562b3b8779e67a26e251526f88fe6e0cfdf03900 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -3,7 +3,6 @@ - [应用开发导读](application-dev-guide.md) - [DevEco Studio(OpenHarmony)使用指南](quick-start/deveco-studio-user-guide-for-openharmony.md) - [包结构说明](quick-start/package-structure.md) -- [快速入门](quick-start/start.md) - [Ability框架](ability/Readme-CN.md) - 方舟开发框架(ArkUI) - [基于JS扩展的类Web开发范式](ui/ui-arkui-js.md) diff --git a/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md b/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md index e1b2b4c62a663e7e916e67baf3245ca4240f48a8..9e5045eacc2aa30e24daaee38966acb7002820ba 100644 --- a/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md +++ b/zh-cn/application-dev/background-agent-scheduled-reminder/background-agent-scheduled-reminder-guide.md @@ -87,15 +87,15 @@ interface ReminderRequest: 需要发布的提醒实例的信息 interface ReminderRequestCalendar extends ReminderRequest: 日历类提醒实例。 -第一次指定的目标时间必须大于当前时间。 +如果没有指定重复的月或天,那么第一次指定的目标时间必须大于当前时间,否则应用将异常退出。 **表8** ReminderRequestCalendar | 参数名 | 类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -| dateTime | LocalDataTime | 是 | 设置目标时间 | -| repeatMonths | Array<number> | 否 | 设置重复提醒的月份 | -| repeatDays | Array<number> | 否 | 设置重复提醒的日期 | +| dateTime | LocalDataTime | 是 | 设置目标时间(精确到分钟级别) | +| repeatMonths | Array<number> | 否 | 设置重复提醒的月份,范围从 1 到 12 | +| repeatDays | Array<number> | 否 | 设置重复提醒的日期,范围从 1 到 31 | interface ReminderRequestAlarm extends ReminderRequest: 闹钟类提醒实例。 @@ -103,9 +103,9 @@ interface ReminderRequestAlarm extends ReminderRequest: 闹钟类提醒实例。 | 参数名 | 类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -| hour | number | 是 | 设置目标时间(小时) | -| minute | number | 是 | 设置目标时间(分钟) | -| daysOfWeek | Array<number> | 否 | 设置每个星期哪一天重复提醒 | +| hour | number | 是 | 设置目标时间(小时),范围从 0 到 23 | +| minute | number | 是 | 设置目标时间(分钟),范围从 0 到 59 | +| daysOfWeek | Array<number> | 否 | 设置每个星期哪一天重复提醒,范围从 1 到 7 | interface ReminderRequestTimer extends ReminderRequest:倒计时提醒实例 @@ -196,8 +196,8 @@ calendar: { minute: 14, second: 30 }, - repeatMonths: [0], - repeatDays: [0], + repeatMonths: [1], + repeatDays: [1], actionButton: [ { title: "close", diff --git a/zh-cn/application-dev/background-task-management/background-task-dev-guide.md b/zh-cn/application-dev/background-task-management/background-task-dev-guide.md index 2047780916748df3d73dabb48f13df84c9960e32..526670f34b77c05b51f9d146fe08330c51b3b48b 100644 --- a/zh-cn/application-dev/background-task-management/background-task-dev-guide.md +++ b/zh-cn/application-dev/background-task-management/background-task-dev-guide.md @@ -13,7 +13,7 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager'; ## 短时任务 -**表1** backgroundTaskManager主要接口 +**表1** 短时任务主要接口 | 接口名 | 描述 | | -------- | -------- | @@ -106,7 +106,7 @@ ohos.permission.KEEP_BACKGROUND_RUNNING | function stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void;
function stopBackgroundRunning(context: Context): Promise<void>; | 停止后台长时任务的运行 | -其中,wantAgent的信息详见([WantAgent](#zh-cn/application-dev/reference/apis/js-apis-notification.md#WantAgent接口)) +其中,wantAgent的信息详见([WantAgent](../reference/apis/js-apis-notification.md#WantAgent接口) **表4** 后台模式类型 diff --git a/zh-cn/application-dev/background-task-management/background-task-overview.md b/zh-cn/application-dev/background-task-management/background-task-overview.md index fa4c7330628333de635df896851dbb1c04b5cf6f..403126992ae84827af546d4d6acc32f70d1fd020 100644 --- a/zh-cn/application-dev/background-task-management/background-task-overview.md +++ b/zh-cn/application-dev/background-task-management/background-task-overview.md @@ -57,6 +57,6 @@ OpenHarmony提供了九种后台模式,供需要在后台做长时任务的业 ### 长时任务使用约束 - 如果用户选择可感知业务(如播音、导航、上传下载等),触发对应后台模式,在任务启动时,系统会强制弹出通知提醒用户。 - 如果任务结束,应用应主动退出后台模式。若在后台运行期间,系统检测到应用并未使用对应后台模式的资源,则会被挂起(Suspend)。 -- 避免不合理地申请后台长时任务,长时任务类型要与应用的业务类型匹配。如表1所示。如果执行的任务和申请的类型不匹配,也会被系统检测到并被挂起(Suspend)。 +- 避免不合理地申请后台长时任务,长时任务类型要与应用的业务类型匹配。如果执行的任务和申请的类型不匹配,也会被系统检测到并被挂起(Suspend)。 - 长时任务是为了真正在后台长时间执行某个任务,如果一个应用申请了长时任务,但在实际运行过程中,并未真正运行或执行此类任务时,也会被系统检测到并被挂起(Suspend)。 -- 每个Ability同一时刻只能申请运行一个长时任务。 \ No newline at end of file +- 一个Ability同一时刻只能申请运行一个长时任务。 \ No newline at end of file diff --git a/zh-cn/application-dev/database/Readme-CN.md b/zh-cn/application-dev/database/Readme-CN.md index 12b66f04eb2154faf8542704213628927871e67c..ab2703c93e686776ff8c3a85f06ce6859624f55b 100644 --- a/zh-cn/application-dev/database/Readme-CN.md +++ b/zh-cn/application-dev/database/Readme-CN.md @@ -5,7 +5,7 @@ - [分布式数据服务开发指导](database-mdds-guidelines.md) - 关系型数据库 - [关系型数据库概述](database-relational-overview.md) - - [分布式数据服务开发指导](database-relational-guidelines.md) + - [关系型数据库开发指导](database-relational-guidelines.md) - 轻量级数据存储 - [轻量级数据存储概述](database-preference-overview.md) - [轻量级数据存储开发指导](database-preference-guidelines.md) diff --git a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md index 3afd163afdff4f9780ae87250586ac40d637dd4e..5cc72d56f4fe05ca70ba36492e5e61c696dac9f4 100644 --- a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md +++ b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md @@ -8,7 +8,7 @@ ## 接口说明 注册相关接口包导入: ```js -import stats from '@ohos.usagestatskit'; +import stats from '@ohos.bundleState'; ``` **表1** 设备使用信息统计主要接口 @@ -38,188 +38,170 @@ import stats from '@ohos.usagestatskit'; } ``` -2. 通过指定起始和结束时间查询所有应用的事件集合。 +2. 通过指定起始和结束时间查询所有应用的事件集合,config.json中需要配置权限:ohos.permission.BUNDLE_ACTIVE_INFO。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.queryBundleActiveStates(0, 20000000000000).then( res => { - console.log('queryBundleActiveStates promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleActiveStates, promise bundleName = " + res[i].bundleName) - console.log("queryBundleActiveStates, promise stateType = " + res[i].stateType) - console.log("queryBundleActiveStates, promise stateOccurredTime = " + res[i].stateOccurredTime) + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryBundleActiveStates promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.queryBundleActiveStates(0, 20000000000000, (err, res) => { - console.log('queryBundleActiveStates callback succeeded, data number: ' + res.length); - if(err.data == 0) { - for (let i = 0; i < res.length; i++) { - console.log("queryBundleActiveStates, callback bundleName = " + res[i].bundleName) - console.log("queryBundleActiveStates, callback stateType = " + res[i].stateType) - console.log("queryBundleActiveStates, callback stateOccurredTime = " + res[i].stateOccurredTime) - } - } else { - console.log('queryBundleActiveStates callback failed, because: ' + err.data); + stats.queryBundleActiveStates(0, 20000000000000, (err, res) => { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback result ' + JSON.stringify(res[i])); } - }) - }, 500); + } else { + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code); + } + }); ``` -3. 通过指定起始和结束时间查询应用使用时长统计信息。 +3. 通过指定起始和结束时间查询应用使用时长统计信息,config.json中需要配置权限:ohos.permission.BUNDLE_ACTIVE_INFO。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.queryBundleStateInfos(0, 20000000000000).then( res => { - console.log('queryBundleStateInfos promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.'); + let i = 1; for(let key in res){ - console.log("queryBundleStateInfos promise key = " + key) - console.log("queryBundleStateInfos promise bundleName = " + res[key].bundleName) - console.log("queryBundleStateInfos promise abilityPrevAccessTime = " + res[key].abilityPrevAccessTime) - console.log("queryBundleStateInfos promise abilityInFgTotalTime = " + res[key].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise number : ' + i); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise result ' + JSON.stringify(res[key])); + i++; } }).catch( err => { - console.log('queryBundleStateInfos promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.queryBundleStateInfos(0, 20000000000000,(err, res) => { - console.log('queryBundleStateInfos callback succeeded, data number: ' + res.length); - if(err.data == 0) { - for(let key in res){ - console.log("queryBundleStateInfos callback key = " + key) - console.log("queryBundleStateInfos callback bundleName = " + res[key].bundleName) - console.log("queryBundleStateInfos callback abilityPrevAccessTime = " + res[key].abilityPrevAccessTime) - console.log("queryBundleStateInfos callback abilityInFgTotalTime = " + res[key].abilityInFgTotalTime) - } - } else { - console.log('queryBundleStateInfos callback failed, because: ' + err.data); + stats.queryBundleStateInfos(0, 20000000000000, (err, res) => { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback success.'); + let i = 1; + for(let key in res){ + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback number : ' + i); + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback result ' + JSON.stringify(res[key])); + i++; } - }) - }, 500); + } else { + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code); + } + }); ``` -4. 通过指定起始和结束时间查询当前应用的事件集合。 +4. 通过指定起始和结束时间查询当前应用的事件集合,config.json中不需要配置权限。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.queryCurrentBundleActiveStates(0, 20000000000000).then( res => { - console.log('queryCurrentBundleActiveStates promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryCurrentBundleActiveStates, promise bundleName = " + res[i].bundleName) - console.log("queryCurrentBundleActiveStates, promise stateType = " + res[i].stateType) - console.log("queryCurrentBundleActiveStates, promise stateOccurredTime = " + res[i].stateOccurredTime) + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryCurrentBundleActiveStates promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.queryCurrentBundleActiveStates(0, 20000000000000,(err, res) => { - console.log('queryCurrentBundleActiveStates callback succeeded, data number: ' + res.length); - if(err.data == 0) { - for (let i = 0; i < res.length; i++) { - console.log("queryCurrentBundleActiveStates, callback bundleName = " + res[i].bundleName) - console.log("queryCurrentBundleActiveStates, callback stateType = " + res[i].stateType) - console.log("queryCurrentBundleActiveStates, callback stateOccurredTime = " + res[i].stateOccurredTime) - } - } else { - console.log('queryCurrentBundleActiveStates callback failed, because: ' + err.data); - } - }) - }, 500); + stats.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback result ' + JSON.stringify(res[i])); + } + } else { + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code); + } + }); ``` -5. 通过指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。 +5. 通过指定时间段间隔(天、周、月、年)查询应用使用时长统计信息,config.json中需要配置权限:ohos.permission.BUNDLE_ACTIVE_INFO。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => { - console.log('queryBundleStateInfoByInterval promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleStateInfoByInterval, promise bundleName = " + res[i].bundleName) - console.log("queryBundleStateInfoByInterval, promise abilityPrevAccessTime = " + res[i].abilityPrevAccessTime) - console.log("queryBundleStateInfoByInterval, promise abilityInFgTotalTime = " + res[i].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryBundleStateInfoByiInterval promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.queryBundleStateInfoByInterval(0, 0, 20000000000000,(err, res) => { - console.log('queryBundleStateInfoByInterval callback succeeded, data number: ' + res.length); - if(err.data == 0) { - for (let i = 0; i < res.length; i++) { - console.log("queryBundleStateInfoByInterval, callback bundleName = " + res[i].bundleName) - console.log("queryBundleStateInfoByInterval, callback abilityPrevAccessTime = " + res[i].abilityPrevAccessTime) - console.log("queryBundleStateInfoByInterval, callback abilityInFgTotalTime = " + res[i].abilityInFgTotalTime) - } - } else { - console.log('queryBundleStateInfoByInterval callback failed, because: ' + err.data); + stats.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback success.'); + for (let i = 0; i < res.length; i++) { + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback result ' + JSON.stringify(res[i])); } - }) - }, 500); + } else { + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code); + } + }); ``` -6. 查询(返回)当前调用者应用的使用优先级群组。 +6. 查询(返回)当前调用者应用的使用优先级群组,config.json中不需要配置权限。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.queryAppUsagePriorityGroup().then( res => { - console.log('queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); }).catch( err => { - console.log('queryAppUsagePriorityGroup promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.queryAppUsagePriorityGroup((err, res) => { - if(err.data === 0) { - console.log('queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); - } else { - console.log('queryAppUsagePriorityGroup callback failed, because: ' + err.data); - } - }) - }, 500); + stats.queryAppUsagePriorityGroup((err, res) => { + if(err.code === 0) { + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); + } else { + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code); + } + }); ``` -7. 判断指定Bundle Name的应用当前是否是空闲状态。 +7. 判断指定Bundle Name的应用当前是否是空闲状态,config.json中不需要配置权限。 ```js - import stats from '@ohos.usagestatskit' + import stats from '@ohos.bundleState' // 异步方法promise方式 stats.isIdleState("com.ohos.camera").then( res => { - console.log('isIdleState promise succeeded. result: ' + JSON.stringify(res)); + console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res)); }).catch( err => { - console.log('isIdleState promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code); }); // 异步方法callback方式 - setTimeout(()=>{ - stats.isIdleState("com.ohos.camera", (err, res) => { - if(err.data === 0) { - console.log('isIdleState callback succeeded. result: ' + JSON.stringify(res)); - } else { - console.log('isIdleState callback failed, because: ' + err.data); - } - }) - }, 500); + stats.isIdleState("com.ohos.camera", (err, res) => { + if(err.code === 0) { + console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res)); + } else { + console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code); + } + }); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-overview.md b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-overview.md index 2044ec8683c6b9c2b7c9e5b81daa9ce3248aa285..66c2ea874ae4a1a8edf2403db20f81d53045835f 100644 --- a/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-overview.md +++ b/zh-cn/application-dev/device-usage-statistics/device-usage-statistics-overview.md @@ -20,5 +20,5 @@ >6. 判断指定应用当前是否是空闲状态; ### 设备使用信息统计使用权限 -- 设备使用信息统计接口只对系统应用开放,三方应用不可调用。 -- 系统应用调用设备使用信息统计接口前,必须申请ohos.permission.BUNDLE_ACTIVE_INFO权限。 \ No newline at end of file +- 设备使用信息统计的queryBundleActiveStates、queryBundleStateInfos、queryBundleStateInfoByInterval接口为系统api,调用前需要申请ohos.permission.BUNDLE_ACTIVE_INFO权限。 +- 设备使用信息统计的queryCurrentBundleActiveStates、queryAppUsagePriorityGroup、isIdleState接口为三方api,调用时不需要申请权限。 \ No newline at end of file diff --git a/zh-cn/application-dev/media/audio-playback.md b/zh-cn/application-dev/media/audio-playback.md index 757d99fdc6ca84fc2aab9acf1d36531a5a46df70..a142a8b010630fa19349c78e8b40bfd956042695 100644 --- a/zh-cn/application-dev/media/audio-playback.md +++ b/zh-cn/application-dev/media/audio-playback.md @@ -25,6 +25,9 @@ AudioPlayer支持的src媒体源输入类型可参考:[src属性说明](../reference/apis/js-apis-media.md#audioplayer_属性) ```js +import media from '@ohos.multimedia.media' +import fileIO from '@ohos.fileio' + function SetCallBack(audioPlayer) { audioPlayer.on('dataLoad', () => { //设置'dataLoad'事件回调,src属性设置成功后,触发此回调 console.info('audio set source success'); @@ -80,7 +83,18 @@ function printfDescription(obj) { let audioPlayer = media.createAudioPlayer(); SetCallBack(audioPlayer); //设置事件回调 //2、用户选择音频,设置uri -audioPlayer.src = 'file:///data/data/ohos.xxx.xxx/files/test.mp3'; //设置src属性,并触发'dataLoad'事件回调 +let fdPath = 'fd://' +let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; +await fileIO.open(path).then(fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); + +audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调 //3、播放音频 audioPlayer.play(); //需等待'dataLoad'事件回调完成后,才可调用play进行播放,触发'play'事件回调 //4、跳转播放位置 @@ -111,6 +125,9 @@ audioPlayer = undefined; ### 正常播放场景 ```js +import media from '@ohos.multimedia.media' +import fileIO from '@ohos.fileio' + function SetCallBack(audioPlayer) { audioPlayer.on('dataLoad', () => { //设置'dataLoad'事件回调,src属性设置成功后,触发此回调 console.info('audio set source success'); @@ -128,13 +145,27 @@ function SetCallBack(audioPlayer) { let audioPlayer = media.createAudioPlayer(); //创建一个音频播放实例 SetCallBack(audioPlayer); //设置事件回调 -/* 用户选择音频,设置uri */ -audioPlayer.src = 'file:///data/data/ohos.xxx.xxx/files/test.mp3'; //设置src属性,并触发'dataLoad'事件回调 +/* 用户选择视频设置fd(本地播放) */ +let fdPath = 'fd://' +let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; +await fileIO.open(path).then(fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); + +audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调 ``` ### 切歌场景 ```js +import media from '@ohos.multimedia.media' +import fileIO from '@ohos.fileio' + function SetCallBack(audioPlayer) { audioPlayer.on('dataLoad', () => { //设置'dataLoad'事件回调,src属性设置成功后,触发此回调 console.info('audio set source success'); @@ -152,16 +183,42 @@ function SetCallBack(audioPlayer) { let audioPlayer = media.createAudioPlayer(); //创建一个音频播放实例 SetCallBack(audioPlayer); //设置事件回调 -/* 用户选择音频,设置uri */ -audioPlayer.src = 'file:///data/data/ohos.xxx.xxx/files/test.mp3'; //设置src属性,并触发'dataLoad'事件回调 +/* 用户选择视频设置fd(本地播放) */ +let fdPath = 'fd://' +let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; +await fileIO.open(path).then(fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); + +audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调 /* 播放一段时间后,下发切歌指令 */ audioPlayer.reset(); -audioPlayer.src = 'file:///data/data/ohos.xxx.xxx/files/next.mp3'; + +/* 用户选择视频设置fd(本地播放) */ +let fdNextPath = 'fd://' +let nextPath = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; +await fileIO.open(nextPath).then(fdNumber) => { + fdNextPath = fdNextPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdNextPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); +audioPlayer.src = fdNextPath; ``` ### 单曲循环场景 ```js +import media from '@ohos.multimedia.media' +import fileIO from '@ohos.fileio' + function SetCallBack(audioPlayer) { audioPlayer.on('dataLoad', () => { //设置'dataLoad'事件回调,src属性设置成功后,触发此回调 console.info('audio set source success'); @@ -179,7 +236,19 @@ function SetCallBack(audioPlayer) { let audioPlayer = media.createAudioPlayer(); //创建一个音频播放实例 SetCallBack(audioPlayer); //设置事件回调 -/* 用户选择音频,设置uri */ -audioPlayer.src = 'file:///data/data/ohos.xxx.xxx/files/test.mp3'; //设置src属性,并触发'dataLoad'事件回调 -audioPlayer.loop = true; //设置循环播放属性 + +/* 用户选择视频设置fd(本地播放) */ +let fdPath = 'fd://' +let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; +await fileIO.open(path).then(fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); + +audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调 +audioPlayer.loop = true; //设置循环播放属性 ``` \ No newline at end of file diff --git a/zh-cn/application-dev/media/audio-recorder.md b/zh-cn/application-dev/media/audio-recorder.md index 0d1acf4df17b871b3d390e83469c411adde046c6..7e52686c95eb380bbb58d468b764f8eafbbc2d41 100644 --- a/zh-cn/application-dev/media/audio-recorder.md +++ b/zh-cn/application-dev/media/audio-recorder.md @@ -23,6 +23,11 @@ 包含流程:创建实例,设置录制参数,录制音频,暂停录制,恢复录制,停止录制,释放资源等流程。 ```js +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' + +let testFdNumber; + function SetCallBack(audioRecorder) { audioRecorder.on('prepare', () => { // 设置'prepare'事件回调 console.log('prepare success'); @@ -57,6 +62,31 @@ function SetCallBack(audioRecorder) { }); } +// pathName是传入的录制文件名,例如:01.mp3,生成后的文件地址:/storage/media/100/local/files/Movies/01.mp3 +// 使用mediaLibrary需要添加以下权限, ohos.permission.MEDIA_LOCATION、ohos.permission.WRITE_MEDIA、ohos.permission.READ_MEDIA +async function getFd(pathName) { + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections : fileKeyObj.ID + "=?", + selectionArgs : [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + let fileAsset = await fetchFileResult.getAllObject(); + let fdNumber = await fileAsset[0].open('Rw'); + fdNumber = "fd://" + fdNumber.toString(); + testFdNumber = fdNumber; + } +} + +await getFd('01.mp3'); + // 1.创建实例 let audioRecorder = media.createAudioRecorder(); // 2.设置回调 @@ -68,7 +98,7 @@ let audioRecorderConfig = { audioSampleRate : 22050, numberOfChannels : 2, format : media.AudioOutputFormat.AAC_ADTS, - uri : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.m4a', // 文件需先由调用者创建,并给予适当的权限 + uri : testFdNumber, // testFdNumber由getFd生成 location : { latitude : 30, longitude : 130}, } audioRecorder.prepare(audioRecorderConfig); @@ -92,6 +122,11 @@ audioRecorder = undefined; 与全流程场景不同,不包括暂停录制,恢复录制的过程。 ```js +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' + +let testFdNumber; + function SetCallBack(audioPlayer) { audioRecorder.on('prepare', () => { // 设置'prepare'事件回调 console.log('prepare success'); @@ -108,6 +143,32 @@ function SetCallBack(audioPlayer) { console.log('audio recorder release success'); }); } + +// pathName是传入的录制文件名,例如:01.mp3,生成后的文件地址:/storage/media/100/local/files/Movies/01.mp3 +// 使用mediaLibrary需要添加以下权限, ohos.permission.MEDIA_LOCATION、ohos.permission.WRITE_MEDIA、ohos.permission.READ_MEDIA +async function getFd(pathName) { + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections : fileKeyObj.ID + "=?", + selectionArgs : [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + let fileAsset = await fetchFileResult.getAllObject(); + let fdNumber = await fileAsset[0].open('Rw'); + fdNumber = "fd://" + fdNumber.toString(); + testFdNumber = fdNumber; + } +} + +await getFd('01.mp3'); + // 1.创建实例 let audioRecorder = media.createAudioRecorder(); // 2.设置回调 @@ -119,7 +180,7 @@ let audioRecorderConfig = { audioSampleRate : 22050, numberOfChannels : 2, format : media.AudioOutputFormat.AAC_ADTS, - uri : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.m4a', // 文件需先由调用者创建,并给予适当的权限 + uri : testFdNumber, // testFdNumber由getFd生成 location : { latitude : 30, longitude : 130}, } audioRecorder.prepare(audioRecorderConfig) diff --git a/zh-cn/application-dev/media/video-playback.md b/zh-cn/application-dev/media/video-playback.md index 5fe625c1dfb1e1b29f3f009fdb42ea96ab9a5c30..708a3e20e8d1423ed8d92abab6f4c6b0e1019a76 100644 --- a/zh-cn/application-dev/media/video-playback.md +++ b/zh-cn/application-dev/media/video-playback.md @@ -30,10 +30,21 @@ VideoPlayer支持的url媒体源输入类型可参考:[url属性说明](../reference/apis/js-apis-media.md#videoplayer_属性) +Xcomponent创建方法可参考:[Xcomponent创建方法](#Xcomponent创建方法) + ```js +import media from '@ohos.multimedia.media' +import fileIO from '@ohos.fileio' + let videoPlayer = undefined; // 用于保存createVideoPlayer创建的对象 let surfaceID = undefined; // 用于保存Xcomponent接口返回的surfaceID +// 调用Xcomponent的接口用于获取surfaceID,并保存在surfaceID变量中,该接口由XComponent组件默认加载,非主动调用 +LoadXcomponent() { + surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); + console.info('LoadXcomponent surfaceID is' + surfaceID); +} + // 函数调用发生错误时用于上报错误信息 function failureCallback(error) { console.info(`error happened,error Name is ${error.name}`); @@ -67,10 +78,19 @@ await media.createVideoPlayer().then((video) => { } }, failureCallback).catch(catchCallback); -// 用户选择视频设置url -videoPlayer.url = 'file:///data/data/ohos.xxx.xxx/files/test.mp4'; +// 用户选择视频设置fd(本地播放) +let fdPath = 'fd://' +let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; +await fileIO.open(path).then(fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); -// 该处需要调用Xcomponent的接口用于获取surfaceID,并保存在surfaceID变量中 +videoPlayer.url = fdPath; // 设置surfaceID用于显示视频画面 await videoPlayer.setDisplaySurface(surfaceID).then(() => { @@ -147,9 +167,18 @@ surfaceID = undefined; ### 正常播放场景 ```js +import media from '@ohos.multimedia.media' +import fileIO from '@ohos.fileio' + let videoPlayer = undefined; // 用于保存createVideoPlayer创建的对象 let surfaceID = undefined; // 用于保存Xcomponent接口返回的surfaceID +// 调用Xcomponent的接口用于获取surfaceID,并保存在surfaceID变量中,该接口由XComponent组件默认加载,非主动调用 +LoadXcomponent() { + surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); + console.info('LoadXcomponent surfaceID is' + surfaceID); +} + // 函数调用发生错误时用于上报错误信息 function failureCallback(error) { console.info(`error happened,error Name is ${error.name}`); @@ -191,10 +220,19 @@ await media.createVideoPlayer().then((video) => { // 设置事件回调 SetCallBack(videoPlayer); -// 用户选择视频设置url -videoPlayer.url = 'file:///data/data/ohos.xxx.xxx/files/test.mp4'; +// 用户选择视频设置fd(本地播放) +let fdPath = 'fd://' +let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; +await fileIO.open(path).then(fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); -// 该处需要调用Xcomponent的接口用于获取surfaceID,并保存在surfaceID变量中 +videoPlayer.url = fdPath; // 设置surfaceID用于显示视频画面 await videoPlayer.setDisplaySurface(surfaceID).then(() => { @@ -215,9 +253,18 @@ await videoPlayer.play().then(() => { ### 切视频场景 ```js +import media from '@ohos.multimedia.media' +import fileIO from '@ohos.fileio' + let videoPlayer = undefined; // 用于保存createVideoPlayer创建的对象 let surfaceID = undefined; // 用于保存Xcomponent接口返回的surfaceID +// 调用Xcomponent的接口用于获取surfaceID,并保存在surfaceID变量中,该接口由XComponent组件默认加载,非主动调用 +LoadXcomponent() { + surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); + console.info('LoadXcomponent surfaceID is' + surfaceID); +} + // 函数调用发生错误时用于上报错误信息 function failureCallback(error) { console.info(`error happened,error Name is ${error.name}`); @@ -259,10 +306,19 @@ await media.createVideoPlayer().then((video) => { // 设置事件回调 SetCallBack(videoPlayer); -// 用户选择视频设置url -videoPlayer.url = 'file:///data/data/ohos.xxx.xxx/files/test.mp4'; +// 用户选择视频设置fd(本地播放) +let fdPath = 'fd://' +let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; +await fileIO.open(path).then(fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); -// 该处需要调用Xcomponent的接口用于获取surfaceID,并保存在surfaceID变量中 +videoPlayer.url = fdPath; // 设置surfaceID用于显示视频画面 await videoPlayer.setDisplaySurface(surfaceID).then(() => { @@ -285,7 +341,19 @@ await videoPlayer.reset().then(() => { console.info('reset success'); }, failureCallback).catch(catchCallback); -videoPlayer.url = 'file:///data/data/ohos.xxx.xxx/files/next.mp4'; +// 用户选择视频设置fd(本地播放) +let fdNextPath = 'fd://' +let nextPath = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/02.mp4'; +await fileIO.open(nextPath).then(fdNumber) => { + fdNextPath = fdNextPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdNextPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); + +videoPlayer.url = fdNextPath; // 设置surfaceID用于显示视频画面 await videoPlayer.setDisplaySurface(surfaceID).then(() => { @@ -306,9 +374,18 @@ await videoPlayer.play().then(() => { ### 单个视频循环场景 ```js +import media from '@ohos.multimedia.media' +import fileIO from '@ohos.fileio' + let videoPlayer = undefined; // 用于保存createVideoPlayer创建的对象 let surfaceID = undefined; // 用于保存Xcomponent接口返回的surfaceID +// 调用Xcomponent的接口用于获取surfaceID,并保存在surfaceID变量中,该接口由XComponent组件默认加载,非主动调用 +LoadXcomponent() { + surfaceID = this.$element('Xcomponent').getXComponentSurfaceId(); + console.info('LoadXcomponent surfaceID is' + surfaceID); +} + // 函数调用发生错误时用于上报错误信息 function failureCallback(error) { console.info(`error happened,error Name is ${error.name}`); @@ -350,10 +427,19 @@ await media.createVideoPlayer().then((video) => { // 设置事件回调 SetCallBack(videoPlayer); -// 用户选择视频设置url -videoPlayer.url = 'file:///data/data/ohos.xxx.xxx/files/test.mp4'; +// 用户选择视频设置fd(本地播放) +let fdPath = 'fd://' +let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp4'; +await fileIO.open(path).then(fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); -// 该处需要调用Xcomponent的接口用于获取surfaceID,并保存在surfaceID变量中 +videoPlayer.url = fdPath; // 设置surfaceID用于显示视频画面 await videoPlayer.setDisplaySurface(surfaceID).then(() => { @@ -372,4 +458,16 @@ videoPlayer.loop = true; await videoPlayer.play().then(() => { console.info('play success'); }, failureCallback).catch(catchCallback); -``` \ No newline at end of file +``` + +### Xcomponent创建方法 + +```js +播放视频中获取surfaceID依赖了Xcomponent,需要创建一个和xxx.js同名的xxx.hml文件,xxx.hml里面需要添加如下代码: + // 设置窗口宽高等属性 + +``` diff --git a/zh-cn/application-dev/media/video-recorder.md b/zh-cn/application-dev/media/video-recorder.md index 0537f4f1da61bb8da57e65c20104ddf336aa362b..e684b2230ad3c9f839a1be48badcd0b40d0c55a6 100644 --- a/zh-cn/application-dev/media/video-recorder.md +++ b/zh-cn/application-dev/media/video-recorder.md @@ -23,6 +23,36 @@ 包含流程:创建实例,设置录制参数,录制视频,暂停录制,恢复录制,停止录制,释放资源等流程。 ```js +import media from '@ohos.multimedia.media' +import mediaLibrary from '@ohos.multimedia.mediaLibrary' + +let testFdNumber; + +// pathName是传入的录制文件名,例如:01.mp4,生成后的文件地址:/storage/media/100/local/files/Movies/01.mp4 +// 使用mediaLibrary需要添加以下权限, ohos.permission.MEDIA_LOCATION、ohos.permission.WRITE_MEDIA、ohos.permission.READ_MEDIA +async function getFd(pathName) { + let displayName = pathName; + const mediaTest = mediaLibrary.getMediaLibrary(); + let fileKeyObj = mediaLibrary.FileKey; + let mediaType = mediaLibrary.MediaType.VIDEO; + let publicPath = await mediaTest.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + let dataUri = await mediaTest.createAsset(mediaType, displayName, publicPath); + if (dataUri != undefined) { + let args = dataUri.id.toString(); + let fetchOp = { + selections : fileKeyObj.ID + "=?", + selectionArgs : [args], + } + let fetchFileResult = await mediaTest.getFileAssets(fetchOp); + let fileAsset = await fetchFileResult.getAllObject(); + let fdNumber = await fileAsset[0].open('Rw'); + fdNumber = "fd://" + fdNumber.toString(); + testFdNumber = fdNumber; + } +} + +await getFd('01.mp4'); + let videoProfile = { audioBitrate : 48000, audioChannels : 2, @@ -40,7 +70,7 @@ let videoConfig = { audioSourceType : 1, videoSourceType : 0, profile : videoProfile, - url : 'file:///data/media/01.mp4', + url : testFdNumber, // testFdNumber由getFd生成 orientationHint : 0, location : { latitude : 30, longitude : 130 }, } @@ -61,6 +91,7 @@ function catchCallback(error) { let videoRecorder = null; // videoRecorder空对象在createVideoRecorder成功后赋值 let surfaceID = null; // 用于保存getInputSurface返回的surfaceID + // 创建videoRecorder对象 await media.createVideoRecorder().then((recorder) => { console.info('case createVideoRecorder called'); diff --git a/zh-cn/application-dev/quick-start/Readme-CN.md b/zh-cn/application-dev/quick-start/Readme-CN.md index 510edabac9fd8b92be1fe7ee59e343a63766fe2b..e530b16bc6e1c2794e9a13a95ad0b41dad140fee 100755 --- a/zh-cn/application-dev/quick-start/Readme-CN.md +++ b/zh-cn/application-dev/quick-start/Readme-CN.md @@ -10,7 +10,3 @@ - [配置OpenHarmony应用签名信息](configuring-openharmony-app-signature.md) - [安装运行OpenHarmony应用](installing-openharmony-app.md) - [包结构说明](package-structure.md) -- 快速入门 - - [开发准备](start-overview.md) - - [使用JS语言开发](start-with-js.md) - - [使用eTS语言开发](start-with-ets.md) diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001089359413.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001089359413.png deleted file mode 100644 index 85345789b60927729e9243798fe122c64ca92687..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001089359413.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001167690688.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001167690688.png deleted file mode 100644 index cb05a7cb0fa33a9d9074f4424a3851478935ff33..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001167690688.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001167850660.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001167850660.png deleted file mode 100644 index 469ca774dde99530329d5e7bd62a5a40fb16237b..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001167850660.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001168898456.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001168898456.png deleted file mode 100644 index b62a4291cbe98e250fd9dcc65e9f91ba67445575..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001168898456.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001169221404.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001169221404.png deleted file mode 100644 index c44bd561803aa0dc4cafcf0db68bf38f5ba43013..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001169221404.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001213130527.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001213130527.png deleted file mode 100644 index afdab82267fcd7d5eacae76eba500baa3bbecd40..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001213130527.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001213883165.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001213883165.png deleted file mode 100644 index 7f99945dc6e30516a6084896b3f146af89dc2f23..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001213883165.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001214043107.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001214043107.png deleted file mode 100644 index 2d8dd786a91b784794a19f8b2975616912586286..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001214043107.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001238733799.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001238733799.png deleted file mode 100644 index 37736ed10ff7cd16907684dfe2c1d6bb19c61d50..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001238733799.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001238853759.png b/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001238853759.png deleted file mode 100644 index 6bf1ed8cb6d6b6d88b57e533f9efe840afee95b5..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/quick-start/figures/zh-cn_image_0000001238853759.png and /dev/null differ diff --git a/zh-cn/application-dev/quick-start/package-structure.md b/zh-cn/application-dev/quick-start/package-structure.md index ec612e6e390a83481a4f3332f368baa742183e25..43a78f2056ea1384f1774aa853937b671a428078 100644 --- a/zh-cn/application-dev/quick-start/package-structure.md +++ b/zh-cn/application-dev/quick-start/package-structure.md @@ -355,7 +355,7 @@ metaData示例: | launchType | 表示Ability的启动模式,支持“standard”、“singleMission”和“singleton”三种模式:
standard:表示该Ability可以有多实例。
“standard”模式适用于大多数应用场景。
singleMission:表示此Ability在每个任务栈中只能有一个实例。
singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用“singleton”模式。该标签仅适用于手机、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为“standard”。 | | visible | 表示Ability是否可以被其他应用调用。
true:可以被其他应用调用。
false:不能被其他应用调用。 | 布尔类型 | 可缺省,缺省值为“false”。 | | permissions | 表示其他应用的Ability调用此Ability时需要申请的权限。通常采用反向域名格式,取值可以是系统预定义的权限,也可以是开发者自定义的权限。 | 字符串数组 | 可缺省,缺省值为空。 | -| skills | 表示Ability能够接收的Intent的特征。 | 对象数组 | 可缺省,缺省值为空。 | +| skills | 表示Ability能够接收的want的特征。 | 对象数组 | 可缺省,缺省值为空。 | | deviceCapability | 表示Ability运行时要求设备具有的能力,采用字符串数组的格式表示。 | 字符串数组 | 可缺省,缺省值为空。 | | metaData | 元数据,参考表13。 | 对象 | 可缺省,缺省值为空。 | | type | 表示Ability的类型。取值范围如下:
page:表示基于Page模板开发的FA,用于提供与用户交互的能力。
service:表示基于Service模板开发的PA,用于提供后台运行任务的能力。
data:表示基于Data模板开发的PA,用于对外部提供统一的数据访问抽象。
CA:表示支持其他应用以窗口方式调起该Ability。 | 字符串 | 否 | @@ -451,9 +451,9 @@ abilities示例: | 属性名称 | 含义 | 数据类型 | 是否可缺省 | | -------- | ------------------------------------------------------------ | ---------- | -------------------- | -| actions | 表示能够接收的Intent的action值,可以包含一个或多个action。取值通常为系统预定义的action值。 | 字符串数组 | 可缺省,缺省值为空。 | -| entities | 表示能够接收的Intent的Ability的类别(如视频、桌面应用等),可以包含一个或多个entity。 | 字符串数组 | 可缺省,缺省值为空。 | -| uris | 表示能够接收的Intent的uri,可以包含一个或者多个uri。参考表20。 | 对象数组 | 可缺省,缺省值为空。 | +| actions | 表示能够接收的want的action值,可以包含一个或多个action。取值通常为系统预定义的action值。 | 字符串数组 | 可缺省,缺省值为空。 | +| entities | 表示能够接收的want的Ability的类别(如视频、桌面应用等),可以包含一个或多个entity。 | 字符串数组 | 可缺省,缺省值为空。 | +| uris | 表示能够接收的want的uri,可以包含一个或者多个uri。参考表20。 | 对象数组 | 可缺省,缺省值为空。 | 表20 uris对象的内部结构说明 diff --git a/zh-cn/application-dev/quick-start/start-overview.md b/zh-cn/application-dev/quick-start/start-overview.md deleted file mode 100644 index d60bf43b85ccf5327e5aed20b5c2dc0b1715df70..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/start-overview.md +++ /dev/null @@ -1,35 +0,0 @@ -# 开发准备 - -## 任务说明 - -本文档适用于应用开发的初学者。通过构建一个简单的具有页面跳转功能的应用(如下图[预览器](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/previewer-0000001054328973#ZH-CN_TOPIC_0000001056725592__section16523172216252)运行效果所示),熟悉应用开发流程。 - -为确保运行效果,本文以使用**DevEco Studio 3.0 Beta2**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)获取下载链接。 - -![zh-cn_image_0000001089359413](figures/zh-cn_image_0000001089359413.png) - -**表1** 方舟开发框架的对比 - -| 比较项 | 基于JS扩展的类Web开发范式 | 基于TS扩展的声明式开发范式 | -| -------- | -------- | -------- | -| 语言生态 | JS | eTS | -| 接口方式 | 类Web范式 | 声明式 | -| 执行方式 | 框架层处理,基于数据驱动的UI自动变更 | 框架层处理,基于数据驱动的UI自动变更 | -| 相对优势 | 轻量化,开发更简便 | 极简开发,内存占用更少、运行性能更高 | - -接下来,分别使用JS语言、eTS语言实现上述两个页面跳转的功能。 - - -## 开发准备 - -1. 开始前请参考[配置OpenHarmony SDK](../quick-start/configuring-openharmony-sdk.md),完成**DevEco Studio**的安装和开发环境配置。 - -2. 开发环境配置完成后,请参考[创建OpenHarmony工程](../quick-start/use-wizard-to-create-project.md)创建工程。 - - 使用JS语言开发,模板选择Empty Ability,Language选择JS。 - - - 使用eTS语言开发,模板选择Empty Ability,Language选择eTS。 - -3. 工程创建完成后,使用[预览器](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/previewer-0000001054328973#ZH-CN_TOPIC_0000001056725592__section16523172216252)运行该工程。 - -完成上述操作后,请参考[使用JS语言开发](../quick-start/start-with-js.md)、[使用eTS语言开发](../quick-start/start-with-ets.md)继续下一步的学习。 - diff --git a/zh-cn/application-dev/quick-start/start-with-ets.md b/zh-cn/application-dev/quick-start/start-with-ets.md deleted file mode 100644 index d2f32af4929d40f60bfc6fc96b979804b1c4f9bc..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/start-with-ets.md +++ /dev/null @@ -1,118 +0,0 @@ -# 使用eTS语言开发 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 请使用DevEco Studio V3.0.0.601 Beta1及更高版本。本文以使用**DevEco Studio 3.0 Beta2**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)获取下载链接。 - - -## 创建eTS工程 - -1. 打开DevEco Studio,创建一个新工程,选择模板,如Empty Ability: - - ![zh-cn_image_0000001238733799](figures/zh-cn_image_0000001238733799.png) - -2. 进入配置工程界面,Project Type选择Application,Language选择eTS,其他参数根据实际需要设置即可。 - - ![zh-cn_image_0000001238853759](figures/zh-cn_image_0000001238853759.png) - - -## 编写第一个页面 - -1. 工程创建完成后,在"Project"窗口,点击entry > src > main > ets > default > pages,打开index.ets文件。 - - ![zh-cn_image_0000001213883165](figures/zh-cn_image_0000001213883165.png) - -2. 第一个页面由Flex容器组件、Text组件和Button组件构成。在index.ets中编写并设置页面组件的属性和样式,示例代码如下所示: - ``` - @Entry - @Component - struct Index { - build() { - //Flex容器组件 - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - //Text组件 - Text('Hello World') - .fontSize(60) - .fontWeight(500) - //Button组件 - Button('Next') - .fontSize(40) - .fontWeight(500) - .width(280) - .height(60) - } - //容器整体宽高 - .width('100%') - .height('100%') - } - } - ``` - -3. 使用[预览器](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/previewer-0000001054328973#ZH-CN_TOPIC_0000001056725592__section16523172216252)运行项目,效果如下图所示: - - ![zh-cn_image_0000001168898456](figures/zh-cn_image_0000001168898456.png) - - -## 创建第二个页面 - -1. 在"Project"窗口,打开entry > src > main > ets > default,右键点击pages文件夹,选择NeweTS Page,命名为details,单击回车键。创建完成后,可以看到pages文件夹下的文件目录结构如下: - - ![zh-cn_image_0000001214043107](figures/zh-cn_image_0000001214043107.png) - -2. 第二个页面由Flex容器组件、Text组件构成。在details.ets中编写并设置页面组件的属性和样式,示例代码如下所示: - ``` - @Entry - @Component - struct Details { - build() { - //Flex容器组件 - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - //Text组件 - Text('Hi there') - .fontSize(60) - .fontWeight(500) - } - //容器整体宽高 - .width('100%') - .height('100%') - } - } - ``` - - -## 实现页面跳转 - -1. 打开第一个页面的index.ets文件,导入router模块,页面路由router根据页面的uri来找到目标页面,从而实现跳转。示例代码如下: - ``` - //导入router模块 - import router from '@system.router'; - @Entry - @Component - struct Index { - build() { - //Flex容器组件 - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - //Text组件 - Text('Hello World') - .fontSize(60) - .fontWeight(500) - //Button组件 - Button('Next') - .fontSize(40) - .fontWeight(500) - .width(280) - .height(60) - //点击Button实现页面跳转 - .onClick(() => { router.push({ uri: 'pages/details' }) }) - } - //容器整体宽高 - .width('100%') - .height('100%') - } - } - ``` - -2. 再次使用[预览器](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/previewer-0000001054328973#ZH-CN_TOPIC_0000001056725592__section16523172216252)运行项目,效果如下图所示: - - ![zh-cn_image_0000001169221404](figures/zh-cn_image_0000001169221404.png) - -恭喜你,至此已成功完成快速入门-使用eTS语言开发。 diff --git a/zh-cn/application-dev/quick-start/start-with-js.md b/zh-cn/application-dev/quick-start/start-with-js.md deleted file mode 100644 index e7661253f7433707cf81719e740369d22835cceb..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/start-with-js.md +++ /dev/null @@ -1,105 +0,0 @@ -# 使用JS语言开发(传统代码方式) - -为确保运行效果,本文以使用**DevEco Studio 3.0 Beta2**版本为例,点击[此处](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta)获取下载链接。 - -## 编写第一个页面 - -1. 第一个页面内有一个文本和一个按钮,通过text和button组件来实现。 - 在"Project"窗口,选择entry > src > main > js > default > pages > index,打开index.hml文件,添加一个文本和一个按钮,示例代码如下: - ``` - -
- - - Hello World - - - -
- ``` - -2. 打开index.css文件,设置文本和按钮的样式,示例代码如下: - ``` - /* index.css */ - .container { - flex-direction: column; /* 设置容器内的项目纵向排列 */ - justify-content: center; /* 设置项目位于容器主轴的中心 */ - align-items: center; /* 项目在交叉轴居中 */ - width:100%; - height:100%; - } - /* 对class="text"的组件设置样式 */ - .text{ - font-size: 42px; - } - /* 对class="button"的组件设置样式 */ - .button { - width: 240px; - height: 60px; - background-color: #007dff; - font-size: 30px; - text-color: white; - margin-top: 20px; - } - ``` - -3. 使用[预览器](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/previewer-0000001054328973#ZH-CN_TOPIC_0000001056725592__section16523172216252)运行项目,效果如下图所示: - - ![zh-cn_image_0000001167690688](figures/zh-cn_image_0000001167690688.png) - - -## 创建另一个页面 - -1. 在"Project"窗口,打开entry > src > main > js > default,右键点击pages文件夹,选择NewJS Page,命名为details,单击回车键。 - 创建完成后,可以看到pages文件夹下的文件目录结构如下: - - ![zh-cn_image_0000001167850660](figures/zh-cn_image_0000001167850660.png) - -2. 打开details.hml文件,添加一个文本,示例代码如下: - ``` - -
- - Hi there - -
- ``` - -3. 打开details.css文件,设置文本的样式,示例代码如下: - ``` - /* details.css */ - .container { - flex-direction: column; - justify-content: center; - align-items: center; - width:100%; - height:100%; - } - .text { - font-size: 42px; - text-align: center; - } - ``` - - -## 实现页面跳转 - -1. 打开第一个页面的index.js文件,导入router模块,页面路由router根据页面的uri来找到目标页面,从而实现跳转。示例代码如下: - ``` - // index.js - import router from '@system.router'; - - export default { - launch() { - router.push ({ - uri:'pages/details/details', // 指定要跳转的页面 - }) - } - } - ``` - -2. 再次使用[预览器](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/previewer-0000001054328973#ZH-CN_TOPIC_0000001056725592__section16523172216252)运行项目,效果如下图所示: - - ![zh-cn_image_0000001213130527](figures/zh-cn_image_0000001213130527.png) - -恭喜你,至此已成功完成快速入门-使用JS语言开发。 diff --git a/zh-cn/application-dev/quick-start/start.md b/zh-cn/application-dev/quick-start/start.md deleted file mode 100644 index 6123c3612898bc1579a80a8465ccf2f0702e19cc..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/quick-start/start.md +++ /dev/null @@ -1,8 +0,0 @@ -# 快速入门 - - -- **[开发准备](start-overview.md)** - -- **[使用JS语言开发](start-with-js.md)** - -- **[使用eTS语言开发](start-with-ets.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index 837523f1a20f18fed4ab7fb79c4aa21929dda1e5..e612643dbce7170b96970b50732e06aa0e48aa8e 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -19,13 +19,13 @@ - [音频管理](js-apis-audio.md) - [媒体服务](js-apis-media.md) - [图片处理](js-apis-image.md) + - [相机管理](js-apis-camera.md) - 安全 - [用户认证](js-apis-useriam-userauth.md) - [访问控制](js-apis-abilityAccessCtrl.md) - [通用密钥库系统](js-apis-huks.md) - 数据管理 - [轻量级存储](js-apis-data-preferences.md) - - [轻量级存储(废弃 since 8)](js-apis-data-storage.md) - [分布式数据管理](js-apis-distributed-data.md) - [关系型数据库](js-apis-data-rdb.md) - [结果集](js-apis-data-resultset.md) @@ -49,7 +49,9 @@ - [网络搜索](js-apis-radio.md) - [observer](js-apis-observer.md) - [蜂窝数据](js-apis-telephony-data.md) -- 网络与连接 +- 网络管理 + - [网络连接管理](js-apis-net-connection.md) +- 通信与连接 - [WLAN](js-apis-wifi.md) - [Bluetooth](js-apis-bluetooth.md) - 设备管理 @@ -79,6 +81,9 @@ - [WebGL](js-apis-webgl.md) - [WebGL2](js-apis-webgl2.md) - [屏幕截图](js-apis-screenshot.md) + - [输入法框架](js-apis-inputmethod.md) + - [输入法服务](js-apis-inputmethodengine.md) + - [辅助功能](js-apis-accessibility.md) - DFX - [应用打点](js-apis-hiappevent.md) - [性能打点](js-apis-hitracemeter.md) diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001164217678.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001164217678.png deleted file mode 100644 index 1e2cc34bf20dcd27dc9dff6a3eb6eb56dd4809c4..0000000000000000000000000000000000000000 Binary files a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_0000001164217678.png and /dev/null differ diff --git a/zh-cn/application-dev/reference/apis/figures/zh-cn_image_url.png b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_url.png new file mode 100644 index 0000000000000000000000000000000000000000..aa3175e145cfce399bef43bf5c7a2ac7feb0a576 Binary files /dev/null and b/zh-cn/application-dev/reference/apis/figures/zh-cn_image_url.png differ diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md index 636c52056e20eee7ddf0079d8f4865be050df6c8..dd04004618e463d69d8d185210418fa3c0d748ee 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md @@ -490,66 +490,6 @@ bundle.queryAbilityByWant(want, bundleFlags, (err, data) => { }) ``` -## bundle.getBundleArchiveInfo - -getBundleArchiveInfo(hapFilePath: string, bundleFlags: number): Promise\ - -以异步方法从给定的HAP中获取BundleInfo,使用Promise形式返回结果。 - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| ----------- | ------ | ---- | ------------------------------------------------------------ | -| hapFilePath | string | 是 | HAP文件路径 | -| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。 | - -**返回值:** - -| 类型 | 说明 | -| -------------------- | ------------------------------------------ | -| Promise\ | 返回值为Promise对象,Promise中包含包信息。 | - -**示例:** - -```js -let hapFilePath = "/data/test.hap"; -let bundleFlags = 1; -bundle.getBundleArchiveInfo(hapFilePath, bundleFlags) -.then((data) => { - console.info('Operation successful. Data: ' + JSON.stringify(data)); -}).catch((error) => { - console.error('Operation failed. Cause: ' + JSON.stringify(error)); -}) -``` - -## bundle.getBundleArchiveInfo - -getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback\): void - -以异步方法从给定的HAP中获取BundleInfo,使用callback形式返回结果。 - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| ----------- | ------------------------- | ---- | ------------------------------------------------------------ | -| hapFilePath | string | 是 | HAP文件路径 | -| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:大于等于0。 | -| callback | AsyncCallback | 是 | 程序启动作为入参的回调函数,返回包信息。 | - -**示例:** - -```js -let hapFilePath = "/data/test.hap"; -let bundleFlags = 1; -bundle.getBundleArchiveInfo(hapFilePath, bundleFlags, (err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + JSON.stringify(err)); - return; - } - console.info('Operation successful. Data:' + JSON.stringify(data)); -}) -``` - ## bundle.getBundleInstaller getBundleInstaller(): Promise @@ -635,6 +575,10 @@ getLaunchWantForBundle(bundleName: string): Promise\ 以异步方法查询拉起指定应用的want对象,使用Promise形式返回结果。 +**需要权限:** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -664,6 +608,10 @@ getLaunchWantForBundle(bundleName: string, callback: AsyncCallback): void; 以异步方法查询拉起指定应用的want对象,使用callback形式返回结果。 +**需要权限:** + +ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -748,13 +696,14 @@ bundle.getNameForUid(uid, (err, data) => { | deviceId | 只读 | string | 否 | 表示运行指定Ability的设备ID。 | | bundleName | 只读 | string | 是 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | | abilityName | 只读 | string | 是 | 表示待启动的Ability名称。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | +| uri | 只读 | string | 否 | 资源标识符。 | +| shortName | 只读 | string | 否 | ElementName的简名。 | ## InstallStatus | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ------------- | -------- | ---------------- | ---- | ------------------------------------------------------------ | -| status | 只读 | InstallErrorCode | 是 | 安装结果code
SUCCESS = 0
STATUS_INSTALL_FAILURE = 1
STATUS_INSTALL_FAILURE_ABORTED = 2,
STATUS_INSTALL_FAILURE_INVALID = 3
STATUS_INSTALL_FAILURE_CONFLICT = 4
STATUS_INSTALL_FAILURE_STORAGE = 5
STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6
STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B
STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C
STATUS_ABILITY_NOT_FOUND = 0x40
STATUS_BMS_SERVICE_ERROR = 0x41 | -| statusMessage | 只读 | string | 是 | 安装结果Message | +| status | 只读 | InstallErrorCode | 是 | 安装结果code
SUCCESS = 0
STATUS_INSTALL_FAILURE = 1
STATUS_INSTALL_FAILURE_ABORTED = 2,
STATUS_INSTALL_FAILURE_INVALID = 3
STATUS_INSTALL_FAILURE_CONFLICT = 4
STATUS_INSTALL_FAILURE_STORAGE = 5
STATUS_INSTALL_FAILURE_INCOMPATIBLE = 6
STATUS_UNINSTALL_FAILURE = 7
STATUS_UNINSTALL_FAILURE_BLOCKED = 8
STATUS_UNINSTALL_FAILURE_ABORTED = 9
STATUS_UNINSTALL_FAILURE_CONFLICT = 10
STATUS_INSTALL_FAILURE_DOWNLOAD_TIMEOUT = 0x0B
STATUS_INSTALL_FAILURE_DOWNLOAD_FAILED = 0x0C
STATUS_RECOVER_FAILURE_INVALID = 0x0D
STATUS_ABILITY_NOT_FOUND = 0x40
STATUS_BMS_SERVICE_ERROR = 0x41
STATUS_FAILED_NO_SPACE_LEFT = 0x42
STATUS_GRANT_REQUEST_PERMISSIONS_FAILED = 0x43
STATUS_INSTALL_PERMISSION_DENIED = 0x44
STATUS_UNINSTALL_PERMISSION_DENIED = 0x45 | ## BundleFlag @@ -773,6 +722,7 @@ bundle.getNameForUid(uid, (err, data) => { | GET_ABILITY_INFO_SYSTEMAPP_ONLY | 0x00000080 | 获取仅包括系统应用的ability信息 | | GET_ABILITY_INFO_WITH_DISABLE | 0x00000100 | 获取包括被禁用的ability信息 | | GET_APPLICATION_INFO_WITH_DISABLE | 0x00000200 | 获取包括被禁用的应用信息 | +| GET_ALL_APPLICATION_INFO | 0xFFFF0000 | 获取应用所有的信息 | ## BundleOptions @@ -785,7 +735,7 @@ bundle.getNameForUid(uid, (err, data) => { ## BundleInfo -应用包的信息。 +应用包的信息 | 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ------ | ------ | ------ | @@ -815,7 +765,7 @@ bundle.getNameForUid(uid, (err, data) => { ## ApplicationInfo -应用程序信息。 +应用程序信息 | 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ------ | ------ | ------ | @@ -843,7 +793,7 @@ bundle.getNameForUid(uid, (err, data) => { ## ModuleInfo -应用程序的模块信息。 +应用程序的模块信息 | 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ------ | ------ | ------ | @@ -852,7 +802,7 @@ bundle.getNameForUid(uid, (err, data) => { ## CustomizeData -自定义元数据。 +自定义元数据 | 名称 | 类型 | 可读 | 可写 | 说明 | | ----- | ------ | ---- | ---- | ---------------- | @@ -863,6 +813,8 @@ bundle.getNameForUid(uid, (err, data) => { ## HapModuleInfo +Hap模块信息 + | 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ------ | ------ | ------ | | name | string | 是 | 否 | 模块名称 | @@ -884,6 +836,8 @@ bundle.getNameForUid(uid, (err, data) => { ## ReqPermissionDetail +应用运行时需向系统申请的权限集合的详细信息 + | 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ------ | ------ | ------ | | name | string | 是 | 是 | 需要使用的权限名称 | @@ -892,6 +846,8 @@ bundle.getNameForUid(uid, (err, data) => { ## UsedScene +描述权限使用的场景和时机 + | 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ------ | ------ | ------ | | abilities | Array | 是 | 是 | 使用到该权限的Ability集合 | @@ -900,6 +856,8 @@ bundle.getNameForUid(uid, (err, data) => { ## AbilityInfo +Ability信息 + | 名称 | 类型 | 可读 | 可写 | 说明 | | ------ | ------ | ------ | ------ | ------ | | bundleName | string | 是 | 否 | 应用包名 | @@ -938,6 +896,8 @@ bundle.getNameForUid(uid, (err, data) => { ## AbilityType +Ability类型 + | 名称 | 类型 | 说明 | | ------- | ---- | --------------------------- | | UNKNOWN | 无 | 未知Ability类型 | @@ -947,6 +907,8 @@ bundle.getNameForUid(uid, (err, data) => { ## DisplayOrientation +屏幕显示方向 + | 名称 | 类型 | 说明 | | ------------- | ---- | ------------------------ | | UNSPECIFIED | 无 | 屏幕方向--不指定 | @@ -956,7 +918,18 @@ bundle.getNameForUid(uid, (err, data) => { ## LaunchMode +启动模式 + | 名称 | 类型 | 说明 | | ----------- | ---- | ------------------- | | UNSPECIFIED | 0 | Ability只有一个示例 | | STANDARD | 1 | Ability有多个示例 | + +## AbilitySubType + +Ability的子类型 + +| 名称 | 类型 | 说明 | +| ----------- | ---- | ----------------------------- | +| UNSPECIFIED | 0 | 未定义Ability子类型 | +| CA | 1 | Ability子类型是带有 UI 的服务 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-Context.md b/zh-cn/application-dev/reference/apis/js-apis-Context.md index 1d16cea627dddfdf1ce83449b5939dafe2f42823..a2126d2e0593480ebdbfb8de388204ee5c8bac97 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-Context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Context.md @@ -25,6 +25,10 @@ getOrCreateLocalDir(callback: AsyncCallback\): void 如果是第一次调用,将创建目录。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **参数:** @@ -52,6 +56,10 @@ getOrCreateLocalDir(): Promise\ 如果是第一次调用,将创建目录。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **返回值:** | 类型 | 说明 | @@ -76,6 +84,10 @@ verifyPermission(permission: string, options: PermissionOptions, callback: Async 验证系统中运行的特定pid和uid是否允许指定的权限(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **参数:** @@ -126,6 +138,10 @@ verifyPermission(permission: string, options?: PermissionOptions): Promise\, requestCode: number, res 从系统请求某些权限(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **参数:** @@ -194,6 +214,10 @@ getApplicationInfo(callback: AsyncCallback\) 获取有关当前应用程序的信息(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -216,6 +240,10 @@ getApplicationInfo(): Promise\ 获取有关当前应用程序的信息(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **返回值:** | 类型 | 说明 | @@ -241,6 +269,10 @@ getBundleName(callback: AsyncCallback\): void 获取当前ability的捆绑包名称(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -263,6 +295,10 @@ getBundleName(): Promise\ 获取当前ability的捆绑包名称(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **返回值:** | 类型 | 说明 | @@ -288,6 +324,10 @@ getProcessInfo(callback: AsyncCallback\) 获取有关当前进程的信息,包括进程ID和名称(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -310,6 +350,10 @@ getProcessInfo(): Promise\ 获取有关当前进程的信息,包括进程id和名称(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **返回值:** | 类型 | 说明 | @@ -337,6 +381,10 @@ getElementName(callback: AsyncCallback\): void 此方法仅适用于页面功能。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -361,6 +409,10 @@ getElementName(): Promise\ 此方法仅适用于页面功能。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **返回值:** | 类型 | 说明 | @@ -384,6 +436,10 @@ getProcessName(callback: AsyncCallback\): void 获取当前进程的名称(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + | 名称 | 类型 | 必填 | 描述 | | -------- | ---------------------- | ---- | -------------------- | | callback | AsyncCallback\ | 是 | 返回当前进程的名称。 | @@ -404,6 +460,10 @@ getProcessName(): Promise\ 获取当前进程的名称(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **返回值:** | 类型 | 说明 | @@ -429,6 +489,10 @@ getCallingBundle(callback: AsyncCallback\): void 获取调用ability的包名称(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -451,6 +515,10 @@ getCallingBundle(): Promise\ 获取调用ability的包名称(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + **返回值:** | 类型 | 说明 | @@ -472,13 +540,13 @@ context.getCallingBundle().then((data) => { | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ---- | -------- | ------ | ---- | ------ | -| pid | 只读 | number | 否 | 进程id | -| uid | 只读 | number | 否 | 用户id | +| pid | 只读 | number | 否 | 进程id
系统能力:SystemCapability.Ability.AbilityRuntime.Core| +| uid | 只读 | number | 否 | 用户id
系统能力:SystemCapability.Ability.AbilityRuntime.Core | ## PermissionRequestResult | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ----------- | -------- | -------------- | ---- | ------------------ | -| requestCode | 只读 | number | 是 | 用户传入的请求代码 | -| permissions | 只读 | Array\ | 是 | 用户传入的权限 | -| authResults | 只读 | Array\ | 是 | 求权限的结果 | +| requestCode | 只读 | number | 是 | 用户传入的请求代码
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| permissions | 只读 | Array\ | 是 | 用户传入的权限
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| authResults | 只读 | Array\ | 是 | 求权限的结果
系统能力:SystemCapability.Ability.AbilityRuntime.Core | diff --git a/zh-cn/application-dev/reference/apis/js-apis-workSchedulerExtension.md b/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md similarity index 57% rename from zh-cn/application-dev/reference/apis/js-apis-workSchedulerExtension.md rename to zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md index 335929c07c3daaf45ebd61f1ca80e6a52b15ca4d..99af6cd9045c0cf8cc220d30cd230a24579e97a4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-workSchedulerExtension.md +++ b/zh-cn/application-dev/reference/apis/js-apis-WorkSchedulerExtensionAbility.md @@ -7,10 +7,10 @@ ## 导入模块 ``` -import workSchedulerExtension from '@ohos.WorkSchedulerExtension' +import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility' ``` -## WorkSchedulerExtension.onWorkStart +## WorkSchedulerExtensionAbility.onWorkStart - **系统能力**: SystemCapability.ResourceSchedule.WorkScheduler @@ -23,14 +23,14 @@ onWorkStart(workInfo: WorkInfo); - **示例**: ``` - export default class MyWorkSchedulerExtension extends WorkSchedulerExtension { + export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { onWorkStart(workInfo) { - console.log('MyWorkSchedulerExtension onWorkStart' + JSON.stringify(workInfo)); + console.log('MyWorkSchedulerExtensionAbility onWorkStart' + JSON.stringify(workInfo)); } } ``` -## WorkSchedulerExtension.onWorkStop +## WorkSchedulerExtensionAbility.onWorkStop - **系统能力**: SystemCapability.ResourceSchedule.WorkScheduler @@ -43,9 +43,9 @@ onWorkStop(workInfo: WorkInfo); - **示例**: ``` - export default class MyWorkSchedulerExtension extends WorkSchedulerExtension { + export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { onWorkStop(workInfo) { - console.log('MyWorkSchedulerExtension onWorkStop' + JSON.stringify(workInfo)); + console.log('MyWorkSchedulerExtensionAbility onWorkStop' + JSON.stringify(workInfo)); } } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md index e55c684dc866fad4c8df94b1229cae6301b72f94..4f4ad5eda2fcb02b0199f5cd02e881a7051c4f37 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-ability-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-ability-context.md @@ -1,24 +1,5 @@ # AbilityContext -- [使用说明](#使用说明) -- [属性](#属性) -- [startAbility](#startAbility) -- [startAbility](#startAbility) -- [startAbility](#startAbility) -- [startAbilityForResult](#startAbilityForResult) -- [startAbilityForResult](#startAbilityForResult) -- [startAbilityForResult](#startAbilityForResult) -- [terminateSelf](#terminateSelf) -- [terminateSelf](#terminateSelf) -- [terminateSelfWithResult](#terminateSelfWithResult) -- [terminateSelfWithResult](#terminateSelfWithResult) -- [startAbilityByCall](#startAbilityByCall) -- [requestPermissionsFromUser](#requestPermissionsFromUser) -- [requestPermissionsFromUser](#requestPermissionsFromUser) -- [setMissionLabel](#setMissionLabel) -- [setMissionLabel](#setMissionLabel) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 @@ -57,6 +38,10 @@ startAbility(want: Want, callback: AsyncCallback<void>): void 启动Ability。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -82,6 +67,10 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void& 启动Ability。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -112,6 +101,10 @@ startAbility(want: Want, options: StartOptions): Promise<void>; 启动Ability。通过Promise返回结果。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -148,6 +141,10 @@ startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): 启动Ability并在结束的时候返回执行结果。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -172,6 +169,10 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback 启动Ability并在结束的时候返回执行结果。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -201,6 +202,10 @@ startAbilityForResult(want: Want, options: StartOptions): Promise<AbilityResu 启动Ability并在结束的时候返回执行结果。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -232,6 +237,10 @@ terminateSelf(callback: AsyncCallback<void>): void; 停止Ability自身。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -251,6 +260,10 @@ terminateSelf(): Promise<void>; 停止Ability自身。通过Promise返回结果。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -272,6 +285,10 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<voi 停止Ability,并返回给调用startAbilityForResult 接口调用方的相关信息。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -297,6 +314,10 @@ terminateSelfWithResult(parameter: AbilityResult): Promise<void>; 停止Ability,并返回给调用startAbilityForResult 接口相关信息。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -326,6 +347,10 @@ startAbilityByCall(want: Want): Promise<Caller>; 获取指定通用组件服务端的caller通信接口, 并且将指定通用组件服务端拉起并切换到后台。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -364,6 +389,10 @@ requestPermissionsFromUser(permissions: Array<string>, requestCallback: As 拉起弹窗请求用户授权。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -385,6 +414,10 @@ requestPermissionsFromUser(permissions: Array<string>) : Promise<Permis 拉起弹窗请求用户授权。通过Promise返回结果。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -412,6 +445,10 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void; 设置ability在任务中显示的名称。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -429,10 +466,14 @@ setMissionLabel(label: string, callback:AsyncCallback<void>): void; ## setMissionLabel -setMissionLabel(label: string, callback:AsyncCallback<void>): void; +setMissionLabel(label: string): Promise<void> 设置ability在任务中显示的名称。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 2e0ff9bc5d3ad5f19ca8cf9dbfecf4604ba0725a..d5351e156e3b78d23ea5e5a333ff08566f183198 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -9,15 +9,15 @@ import abilityAccessCtrl from '@ohos.abilityAccessCtrl' ``` -## 系统能力 -SystemCapability.Security.AccessToken - ## abilityAccessCtrl.createAtManager createAtManager(): AtManager 访问控制管理:获取访问控制模块对象。 +**系统能力:** SystemCapability.Security.AccessToken + + **返回值:** | 类型 | 说明 | @@ -40,6 +40,8 @@ verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStat 校验应用是否授予权限,使用Promise方式异步返回结果。 +**系统能力:** SystemCapability.Security.AccessToken + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -56,7 +58,7 @@ verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStat **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; let promise = AtManager.verifyAccessToken(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); promise.then(data => { @@ -70,7 +72,9 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl 授予应用user grant权限,使用Promise方式异步返回结果。 -需要权限:ohos.permission.GRANT_SENSITIVE_PERMISSIONS。 +**需要权限:** ohos.permission.GRANT_SENSITIVE_PERMISSIONS + +**系统能力:** SystemCapability.Security.AccessToken **参数:** @@ -89,7 +93,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); promise.then(data => { @@ -105,7 +109,9 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl 授予应用user grant权限,使用callback回调异步返回结果。 -需要权限:ohos.permission.GRANT_SENSITIVE_PERMISSIONS。 +**需要权限:** ohos.permission.GRANT_SENSITIVE_PERMISSIONS + +**系统能力:** SystemCapability.Security.AccessToken **参数:** @@ -119,7 +125,7 @@ grantUserGrantedPermission(tokenID: number, permissionName: string, permissionFl **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; let permissionFlag = 1; AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => { @@ -133,7 +139,9 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF 撤销应用user grant权限,使用Promise方式异步返回结果。 -需要权限:ohos.permission.REVOKE_SENSITIVE_PERMISSIONS。 +**需要权限:** ohos.permission.REVOKE_SENSITIVE_PERMISSIONS + +**系统能力:** SystemCapability.Security.AccessToken **参数:** @@ -152,7 +160,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; let permissionFlag = 1; let promise = AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS", permissionFlag); @@ -167,7 +175,9 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF 撤销应用user grant权限,使用callback回调异步返回结果。 -需要权限:ohos.permission.REVOKE_SENSITIVE_PERMISSIONS。 +**需要权限:** ohos.permission.REVOKE_SENSITIVE_PERMISSIONS + +**系统能力:** SystemCapability.Security.AccessToken **参数:** @@ -181,7 +191,7 @@ revokeUserGrantedPermission(tokenID: number, permissionName: string, permissionF **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => { console.log(`callback: data->${JSON.stringify(data)}`); @@ -194,6 +204,8 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise<number&g 获取指定应用的指定权限的flag,使用Promise方式异步返回结果。 +**系统能力:** SystemCapability.Security.AccessToken + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -210,10 +222,21 @@ getPermissionFlags(tokenID: number, permissionName: string): Promise<number&g **示例:** ``` -const AtManager = abilityAccessCtrl.createAtManager(); +var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; let promise = AtManager.getPermissionFlags(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); promise.then(data => { console.log(`promise: data->${JSON.stringify(data)}`); }); -``` \ No newline at end of file +``` + +### GrantStatus + +表示授权状态的枚举。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Security.AccessToken + +| 名称 | 默认值 | 描述 | +| ----------------------------- | ---------------------- | ----------------------- | +| PERMISSION_DENIED | -1 | 表示未授权。 | +| PERMISSION_GRANTED | 0 | 表示已授权。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md index d355f7b81a9450453072645310d519758b3a1ac3..07db08c7cb0b0bba5adc3a62a456b3fdebbc9ac7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilityrunninginfo.md @@ -1,12 +1,7 @@ # AbilityRunningInfo -- [使用说明](#使用说明) -- [属性](#属性) -- [abilityManager.AbilityState](#abilityManagerAbilityState) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 8开始支持。 +> 本模块首批接口从API 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 Ability运行相关信息。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md b/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md index 8018f3b36e3f696d2de71ac4f1b2ce7486cadfe0..493ab4c9691944ffea3d50e017072d689c1d70bf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md +++ b/zh-cn/application-dev/reference/apis/js-apis-abilitystagecontext.md @@ -1,11 +1,7 @@ # AbilityStageContext -- [使用说明](#使用说明) -- [属性](#属性) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。 +> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 AbilityStage的上下文环境,继承自[Context](js-apis-application-context.md)。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-accessibility.md b/zh-cn/application-dev/reference/apis/js-apis-accessibility.md new file mode 100644 index 0000000000000000000000000000000000000000..7d3076a1c53ab8f84d5aac56cf6677ba774a155f --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-accessibility.md @@ -0,0 +1,629 @@ +# 辅助功能 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从 API version 7 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```typescript +import accessibility from '@ohos.accessibility'; +``` + +## AbilityState + +辅助应用状态类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| enable | 辅助应用已启用。 | +| disable | 辅助应用已禁用。 | +| install | 辅助应用已安装。 | + +## AbilityType + +无障碍辅助应用类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| audible | 表示具有听觉反馈。 | +| generic | 表示具有通用反馈。 | +| haptic | 表示具有触觉反馈。 | +| spoken | 表示具有语音反馈。 | +| visual | 表示具有视觉反馈。 | + +## AccessibilityAbilityInfo + +辅助应用信息。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +### 属性 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| id | number | 是 | 否 | ability id。 | +| name | string | 是 | 否 | ability 名。 | +| bundleName | string | 是 | 否 | 包名。 | +| abilityTypes | Array<[AbilityType](#abilitytype)> | 是 | 否 | 辅助应用类型。 | +| capabilities | Array<[Capability](#capability)> | 是 | 否 | 辅助应用能力列表。 | +| description | string | 是 | 否 | 辅助应用描述。 | +| eventTypes | Array<[EventType](#eventtype)> | 是 | 否 | 辅助应用关注的无障碍事件列表。 | + +## Action + +应用所支持的目标动作。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| click | 表示点击操作。 | +| longClick | 表示长按操作。 | +| scrollForward | 表示向前滚动操作。 | +| scrollBackward | 表示向后滚动操作。 | +| focus | 表示获得焦点操作。 | +| clearFocus | 表示清除焦点操作。 | +| clearSelection | 表示清除选择操作。 | +| accessibilityFocus | 表示获得无障碍焦点操作。 | +| clearAccessibilityFocus | 表示清除无障碍焦点操作。 | +| cut | 表示剪切操作。 | +| copy | 表示复制操作。 | +| paste | 表示粘贴操作。 | +| select | 表示选择操作。 | +| setText | 表示设置文本操作。 | +| delete | 表示删除操作。 | +| setSelection | 表示选择操作。 | + +## Capability + +辅助应用能力类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| retrieve | 具有检索窗口内容的能力。 | +| touchGuide | 具有触摸探索模式的能力。 | +| keyEventObserver | 具有过滤按键事件的能力。 | +| zoom | 具有控制显示放大的能力。 | +| gesture | 具有执行手势动作的能力。 | + +## CaptionsFontEdgeType8+ + +字幕字体边缘类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Hearing + +| 名称 | 描述 | +| -------- | -------- | +| none | 无效果。 | +| raised | 凸起效果。 | +| depressed | 凹陷效果。 | +| uniform | 轮廓效果。 | +| dropShadow | 阴影效果。 | + +## CaptionsFontFamily8+ + +字幕字体。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Hearing + +| 名称 | 描述 | +| -------- | -------- | +| default | 默认字体。 | +| monospacedSerif | 等宽 Serif 字体。 | +| serif | Serif 字体。 | +| monospacedSansSerif | 等宽 Sans Serif 字体。 | +| sansSerif | Sans Serif 字体。 | +| casual | 非正式字体。 | +| cursive | 手写字体。 | +| smallCapitals | 小型大写字母字体。 | + +## CaptionsStyle8+ + +字幕风格。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Hearing + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| fontFamily | [CaptionsFontFamily](#captionsfontfamily8) | 是 | 否 | 描述字幕字体。 | +| fontScale | number | 是 | 否 | 描述字幕字体缩放系数。 | +| fontColor | number \| string | 是 | 否 | 描述字幕字体颜色。 | +| fontEdgeType | [CaptionsFontEdgeType](#captionsfontedgetype8) | 是 | 否 | 描述字幕字体边缘。 | +| backgroundColor | number \| string | 是 | 否 | 描述字幕背景颜色。 | +| windowColor | number \| string | 是 | 否 | 描述字幕窗口颜色。 | + +## CaptionsManager8+ + +字幕配置。 + +### 属性 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| enabled | boolean | 是 | 否 | 表示是否启用字幕配置。 | +| style | [CaptionsStyle](#captionsstyle8) | 是 | 否 | 表示字幕风格。 | + +### 方法 + +下列 API 示例中都需要使用 [accessibility.getCaptionsManager()](#accessibilitygetcaptionsmanager8) 获取 captionsManager 实例,再通过此实例调用对应的方法。 + +#### on('enableChange') + +on(type: 'enableChange', callback: Callback<boolean>): void; + +注册字幕配置启用的监听函数。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 监听字幕配置启用状态。 | + | callback | Callback<boolean> | 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 | + +- 示例 + + ```typescript + captionsManager.on('enableChange',(data) => { + console.info('success data:subscribeStateObserver : ' + JSON.stringify(data)) + }) + ``` + +#### on('styleChange') + +on(type: 'styleChange', callback: Callback<CaptionsStyle>): void; + +注册字幕风格变化的监听函数。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 监听字幕风格变化。 | + | callback | Callback<[CaptionsStyle](#captionsstyle8)> | 是 | 回调函数,在字幕风格变化时通过此函数进行通知。 | + +- 示例 + + ```typescript + captionsManager.on('styleChange',(data) => { + console.info('success data:subscribeStateObserver : ' + JSON.stringify(data)) + }) + ``` + +#### off('enableChange') + +off(type: 'enableChange', callback?: Callback<boolean>): void; + +移除字幕配置启用的监听函数。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 监听字幕配置启用状态。 | + | callback | Callback<boolean> | 否 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 | + +- 示例 + + ```typescript + captionsManager.off('enableChange') + ``` + +#### off('styleChange') + +off(type: 'styleChange', callback?: Callback<CaptionsStyle>): void; + +移除字幕风格变化的监听函数。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 字幕风格变化。 | + | callback | Callback<[CaptionsStyle](#captionsstyle8)> | 否 | 回调函数,在字幕风格变化时通过此函数进行通知。 | + +- 示例 + + ```typescript + captionsManager.off('styleChange') + ``` + +## EventInfo + +界面变更事件。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +### 属性 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| type | [EventType](#eventtype) | 是 | 是 | 无障碍事件类型。 | +| windowUpdateType | [WindowUpdateType](#windowupdatetype) | 是 | 是 | 窗口变化类型。 | +| bundleName | string | 是 | 是 | 目标应用名。 | +| componentType | string | 是 | 是 | 事件源组件类型,如按钮、图表。 | +| pageId | number | 是 | 是 | 事件源的页面 ID。 | +| description | string | 是 | 是 | 事件描述。 | +| triggerAction | [Action](#action) | 是 | 是 | 触发事件的 Action。 | +| textMoveUnit | [TextMoveUnit](#textmoveunit) | 是 | 是 | 文本移动粒度。 | +| contents | Array<string> | 是 | 是 | 内容列表。 | +| lastContent | string | 是 | 是 | 最新内容。 | +| beginIndex | number | 是 | 是 | 画面显示条目的开始序号。 | +| currentIndex | number | 是 | 是 | 当前条目序号。 | +| endIndex | number | 是 | 是 | 画面显示条目的结束序号。 | +| itemCount | number | 是 | 是 | 条目总数。 | + +## EventType + +无障碍事件类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| click | 描述点击组件的事件。 | +| longClick | 描述长按组件的事件。 | +| select | 描述选择组件的事件。 | +| focus | 描述组件获得焦点的事件。 | +| textUpdate | 描述组件文本已更改的事件。 | +| hoverEnter | 描述悬停进入组件的事件。 | +| hoverExit | 描述悬停离开组件的事件。 | +| scroll | 描述滚动视图的事件。 | +| textSelectionUpdate | 描述选定文本已更改的事件。 | +| accessibilityFocus | 描述获得无障碍焦点的事件。 | +| accessibilityFocusClear | 描述清除无障碍焦点的事件。 | + +## TextMoveUnit + +文本无障碍导航移动粒度。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| char | 以字符为移动粒度遍历节点文本。 | +| word | 以词为移动粒度遍历节点文本。 | +| line | 以行为移动粒度遍历节点文本。 | +| page | 以页为移动粒度遍历节点文本。 | +| paragraph | 以段落为移动粒度遍历节点文本。 | + +## WindowUpdateType + +窗口变化类型。 + +**系统能力**:以下各项对应的系统能力均为 SystemCapability.Barrierfree.Accessibility.Core + +| 名称 | 描述 | +| -------- | -------- | +| add | 添加窗口的窗口变化事件。 | +| remove | 一个窗口被删除的窗口变化事件。 | +| title | 窗口标题已更改的窗口变化事件。 | +| bounds | 窗口边界已更改的窗口变化事件。 | +| layer | 窗口层级发生变化的窗口变化事件。 | +| active | 窗口变为活动或不活动的窗口变化事件。 | +| focus | 窗口焦点发生变化的窗口变化事件。 | +| accessibilityFocus | 窗口无障碍焦点发生变化的窗口更改事件。 | +| parent | 父窗口已更改的窗口变化事件。 | +| children | 子窗口已更改的窗口变化事件。 | +| pip | 窗口进入或退出画中画(PIP)模式的窗口变化事件。 | + +## accessibility.getAbilityLists + +getAbilityLists(abilityType: AbilityType, stateType: AbilityState): Promise<Array<AccessibilityAbilityInfo>> + +查询辅助应用列表。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | + | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | + +- 返回值: + + | 类型 | 说明 | + | -------- | -------- | + | Promise<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | 返回辅助应用信息列表。 | + +- 示例 + + ```typescript + accessibility.getAbilityLists("spoken", "enable") + .then((data) => { + console.info('success data:getAbilityList1 : ' + JSON.stringify(data)); + for (let item of data) { + console.info(item.id); + console.info(item.name); + console.info(item.description); + console.info(item.abilityTypes); + console.info(item.eventTypes); + console.info(item.capabilities); + console.info(item.packageName); + console.info(item.filterBundleNames); + console.info(item.bundleName); + } + }).catch((error) => { + console.error('failed to getAbilityList1 because ' + JSON.stringify(error)); + }) + ``` + +## accessibility.getAbilityLists + +getAbilityLists(abilityType: AbilityType, stateType: AbilityState,callback: AsyncCallback<Array<AccessibilityAbilityInfo>>): void + +查询辅助应用列表。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | abilityType | [AbilityType](#abilitytype) | 是 | 辅助应用的类型。 | + | stateType | [AbilityState](#abilitystate) | 是 | 辅助应用的状态。 | + | callback | AsyncCallback<Array<[AccessibilityAbilityInfo](#accessibilityabilityinfo)>> | 是 | 回调函数,返回辅助应用信息列表。 | + +- 示例 + + ```typescript + accessibility.getAbilityLists("visual", "enable", (err, data) => { + if (err) { + console.error('failed to getAbilityList2 because ' + JSON.stringify(err)); + return; + } + console.info('success data:getAbilityList2 : ' + JSON.stringify(data)); + for (let item of data) { + console.info(item.id); + console.info(item.name); + console.info(item.description); + console.info(item.abilityTypes); + console.info(item.eventTypes); + console.info(item.capabilities); + console.info(item.packageName); + console.info(item.filterBundleNames); + console.info(item.bundleName); + } + }) + ``` + +## accessibility.getCaptionsManager8+ + +getCaptionsManager(): CaptionsManager + +获取无障碍字幕配置。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Hearing + +- 返回值: + + | 类型 | 说明 | + | -------- | -------- | + | [CaptionsManager](#captionsmanager8) | 无障碍字幕配置管理。 | + +- 示例 + + ```typescript + captionsManager = accessibility.getCaptionsManager() + ``` + +## accessibility.on('accessibilityStateChange' | 'touchGuideStateChange') + +on(type: 'accessibilityStateChange' | 'touchGuideStateChange', callback: Callback<boolean>): void + +启用辅助应用和触摸浏览功能的状态变化监听。 + +**系统能力**:以下各项对应的系统能力有所不同,详见下表。 + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 监听的事件类型。
- type 为'accessibilityStateChange'时表示监听类型为辅助功能启用状态变化监听;
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core
- type 为'touchGuideStateChange'时表示监听类型为触摸浏览启用状态变化监听。
**系统能力**:SystemCapability.Barrierfree.Accessibility.Vision | + | callback | Callback<boolean> | 是 | 回调函数,在启用状态变化时将状态通过此函数进行通知。 | + +- 示例 + + ```typescript + accessibility.on('accessibilityStateChange',(data) => { + console.info('success data:subscribeStateObserver : ' + JSON.stringify(data)) + }) + ``` + +## accessibility.off('accessibilityStateChange' | 'touchGuideStateChange') + +off(type: ‘accessibilityStateChange ’ | ‘touchGuideStateChange’, callback?: Callback<boolean>): void + +关闭辅助应用和触摸浏览功能的状态变化监听。 + +**系统能力**:以下各项对应的系统能力有所不同,详见下表。 + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | type | string | 否 | 监听的事件类型。
- type 为'accessibilityStateChange'时表示监听类型为辅助功能启用状态变化监听;
**系统能力**:SystemCapability.Barrierfree.Accessibility.Core
- type 为'touchGuideStateChange'时表示监听类型为触摸浏览启用状态变化监听。
**系统能力**:SystemCapability.Barrierfree.Accessibility.Vision | + | callback | Callback<boolean> | 否 | 要取消的监听回调函数。 | + +- 示例 + + ```typescript + accessibility.off('accessibilityStateChange',(data) => { + console.info('success data:unSubscribeStateObserver : ' + JSON.stringify(data)) + }) + ``` + +## accessibility.isOpenAccessibility + +isOpenAccessibility(): Promise<boolean> + +判断是否启用了辅助功能。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 返回值: + + | 类型 | 说明 | + | -------- | -------- | + | Promise<boolean> | 如果辅助功能已启用,则返回 true;否则返回 false。 | + +- 示例 + + ```typescript + accessibility.isOpenAccessibility() + .then((data) => { + console.info('success data:isOpenAccessibility : ' + JSON.stringify(data)) + }).catch((error) => { + console.error('failed to isOpenAccessibility because ' + JSON.stringify(error)); + }) + ``` + +## accessibility.isOpenAccessibility + +isOpenAccessibility(callback: AsyncCallback<boolean>): void + +判断是否启用了辅助功能。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数 + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | 是 | 回调函数,如果辅助功能已启用,则返回 true;否则返回 false。 | + +- 示例 + + ```typescript + accessibility.isOpenAccessibility((err, data) => { + if (err) { + console.error('failed to isOpenAccessibility because ' + JSON.stringify(err)); + return; + } + console.info('success data:isOpenAccessibility : ' + JSON.stringify(data)) + }) + ``` + +## accessibility.isOpenTouchGuide + +isOpenTouchGuide(): Promise<boolean> + +判断触摸浏览模式是否开启。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 返回值: + + | 类型 | 说明 | + | -------- | -------- | + | Promise<boolean> | 如果触摸浏览模式已开启,则返回 true;否则返回 false。 | + +- 示例 + + ```typescript + accessibility.isOpenTouchGuide() + .then((data) => { + console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data)) + }).catch((error) => { + console.error('failed to isOpenTouchGuide because ' + JSON.stringify(error)); + }) + ``` + +## accessibility.isOpenTouchGuide + +isOpenTouchGuide(callback: AsyncCallback<boolean>): void + +判断触摸浏览模式是否开启。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数 + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | 是 | 回调函数,如果触摸浏览模式已开启,则返回 true;否则返回 false。 | + +- 示例 + + ```typescript + accessibility.isOpenTouchGuide((err, data) => { + if (err) { + console.error('failed to isOpenTouchGuide because ' + JSON.stringify(err)); + return; + } + console.info('success data:isOpenTouchGuide : ' + JSON.stringify(data)) + }) + ``` + +## accessibility.sendEvent + +sendEvent(event: EventInfo): Promise<void> + +发送无障碍事件。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | event | [EventInfo](#eventinfo) | 是 | 无障碍事件对象。 | + +- 返回值: + + | 类型 | 说明 | + | -------- | -------- | + | Promise<void> | 以 Promise 形式返回结果,如果发送无障碍事件成功,则 data 有数据返回;如果发送无障碍事件失败,则 err 有数据返回。 | + +- 示例 + + ```typescript + accessibility.sendEvent(this.eventInfo) + .then((data) => { + console.info('success data:sendEvent : ' + JSON.stringify(data)) + }).catch((error) => { + console.error('failed to sendEvent because ' + JSON.stringify(error)); + }) + ``` + +## accessibility.sendEvent + +sendEvent(event: EventInfo, callback: AsyncCallback<void>): void + +发送无障碍事件。 + +**系统能力**:SystemCapability.Barrierfree.Accessibility.Core + +- 参数: + + | 参数名 | 参数类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | event | [EventInfo](#eventinfo) | 是 | 辅助事件对象。 | + | callback | AsyncCallback<void> | 是 | 回调函数,如果发送无障碍事件成功,则 AsyncCallback 中 data 有数据返回;如果发送无障碍事件失败,则 AsyncCallback 中 err 有数据返回。 | + +- 示例 + + ```typescript + accessibility.sendEvent(this.eventInfo,(err, data) => { + if (err) { + console.error('failed to sendEvent because ' + JSON.stringify(err)); + return; + } + console.info('success data:sendEvent : ' + JSON.stringify(data)) + }) + ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md index 02f6373ad19beb503e915562a2ac976ac54275eb..4ba79871ddaee154612e5fb8d2f46fc9ae8b00ee 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-ability.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-ability.md @@ -1,29 +1,7 @@ # Ability -- [导入模块](#导入模块) -- [属性](#属性) -- [onCreate](#onCreate) -- [onWindowStageCreate](#onWindowStageCreate) -- [onWindowStageDestroy](#onWindowStageDestroy) -- [onWindowStageRestore](#onWindowStageRestore) -- [onDestroy](#onDestroy) -- [onForeground](#onForeground) -- [onBackground](#onBackground) -- [onContinue](#onContinue) -- [onNewWant](#onNewWant) -- [onConfigurationUpdated](#onConfigurationUpdated) -- [Caller](#Caller) - - [call](#call) - - [callWithResult](#callWithResult) - - [release](#release) - - [onRelease](#onRelease) -- [Callee](#Callee) - - [on](#on) - - [off](#off) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 从API Version 8 开始支持。 +> 从API Version 8 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 Ability模块,提供对Ability生命周期、上下文环境等调用管理。 @@ -43,7 +21,7 @@ import Ability from '@ohos.application.Ability'; | -------- | -------- | -------- | -------- | -------- | | context | [AbilityContext](js-apis-ability-context.md) | 是 | 否 | 上下文。 | | launchWant | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 否 | Ability启动时的参数。 | -| lastRequestWant | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 否 | Ability最后请求时的参数。 | +| lastRequestWant | [Want](js-apis-featureAbility.md#Want类型说明) | 是 | 否 | 上一次请求Ability启动时的参数。 | ## onCreate diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md b/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md index 81409eb8908b0b0eb474c448bc3c706c42bc0b8e..a35ebe09eefd899ece8444cc75ea588c57a202a9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-abilitystage.md @@ -1,13 +1,7 @@ # AbilityStage -- [导入模块](#导入模块) -- [onCreate](#onCreate) -- [onAcceptWant](#onAcceptWant) -- [onConfigurationUpdated](#onConfigurationUpdated) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。 +> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 AbilityStage是HAP包的运行时类。在HAP加载的时候,通知开发者,开发者可以在此进行该HAP的初始化(如资源预加载,线程创建等)。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-application-context.md b/zh-cn/application-dev/reference/apis/js-apis-application-context.md index ab48a6906570fd1a53415ae5e0add91269c97f85..83c984acf5877bfddd2f34eef6dce518e74b6093 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-application-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-application-context.md @@ -1,13 +1,7 @@ # Context -- [使用说明](#使用说明) -- [属性](#属性) -- [createBundleContext](#createBundleContext) -- [getApplicationContext](#getApplicationContext) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 9开始支持。 +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 提供开发者运行代码的上下文环境,包括应用信息、ResourceManager等信息。 @@ -16,7 +10,7 @@ ## 使用说明 -通过AbilityContext等集成实现。 +通过AbilityContext等继承实现。 ## 属性 diff --git a/zh-cn/application-dev/reference/apis/js-apis-appmanager.md b/zh-cn/application-dev/reference/apis/js-apis-appmanager.md index 795b19aa7713cb4479302563edbfe85e1e0c2ad9..5d920d5660bd38b59c9d8aaa139f532f0cdc81a9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appmanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appmanager.md @@ -1,15 +1,10 @@ # appManager -- [导入模块](#导入模块) -- [isRunningInStabilityTest](#isRunningInStabilityTest) -- [isRunningInStabilityTest](#isRunningInStabilityTest) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 8开始支持。 +> 本模块首批接口从API 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -App运行相关信息。 +App管理。 ## 导入模块 @@ -24,7 +19,7 @@ import app from '@ohos.application.appManager'; static isRunningInStabilityTest(callback: AsyncCallback<boolean>): void -查询当前用户是否是一个稳定性测试。 +查询当前是否处于稳定性测试场景。 - 参数: | 参数名 | 类型 | 必填 | 说明 | @@ -35,7 +30,7 @@ static isRunningInStabilityTest(callback: AsyncCallback<boolean>): void ``` import app from '@ohos.application.appManager'; - app.isRunningInStabilityTest((err, flag) => { + app.isRunningInStabilityTest((err, flag) => { console.log('startAbility result:' + JSON.stringfy(err); } ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md index 79d8e65485b7b8d5e76a10de8b30c9b7ba31fff2..7435c4bd4aad33fb8e261a1a7b3368e94091a011 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md @@ -55,15 +55,15 @@ add(element: T): boolean **示例:** -``` -let arrayList = new ArrayList(); -arrayList.add("a"); -arrayList.add(1); -let b = [1, 2, 3]; -arrayList.add(b); -let c = {name: "lala", age: "13"}; -arrayList.add(false); -``` + ``` + let arrayList = new ArrayList(); + let result = arrayList.add("a"); + let result1 = arrayList.add(1); + let b = [1, 2, 3]; + let result2 = arrayList.add(b); + let c = {name: "lala", age: "13"}; + let result3 = arrayList.add(false); + ``` ### insert @@ -109,9 +109,9 @@ has(element: T): boolean ``` let arrayList = new ArrayList(); -arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); arrayList.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result1 = arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); ``` ### getIndexOf @@ -143,7 +143,7 @@ arrayList.add(2); arrayList.add(1); arrayList.add(2); arrayList.add(4); -arrayList.getIndexOf(2); +let result = arrayList.getIndexOf(2); ``` ### getLastIndexOf @@ -175,7 +175,7 @@ arrayList.add(2); arrayList.add(1); arrayList.add(2); arrayList.add(4); -arrayList.getLastIndexOf(2); +let result = arrayList.getLastIndexOf(2); ``` ### removeByIndex @@ -205,7 +205,7 @@ arrayList.add(4); arrayList.add(5); arrayList.add(2); arrayList.add(4); -arrayList.removeByIndex(2); +let result = arrayList.removeByIndex(2); ``` ### remove @@ -234,7 +234,7 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.remove(2); +let result = arrayList.remove(2); ``` ### removeByRange @@ -264,7 +264,7 @@ arrayList.removeByRange(2, 6); ``` ### replaceAllElements -replaceAllElements(callbackfn: (value: T, index?: number, arraylist?: ArrayList<T>) => T, +replaceAllElements(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => T, thisArg?: Object): void 用户操作ArrayList中的元素,用操作后的元素替换原元素并返回操作后的元素。 @@ -280,9 +280,9 @@ callbackfn的参数说明: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | T | 是 | 当前遍历到的元素 | -| index | number | 否 | 当前遍历到的下标值 | -| arraylist | ArrayList<T> | 否 | 当前调用replaceAllElements方法的实例对象 | +| value | T | 是 | 当前遍历到的元素。 | +| index | number | 否 | 当前遍历到的下标值。 | +| arrlist | ArrayList<T> | 否 | 当前调用replaceAllElements方法的实例对象。 | **示例:** @@ -301,7 +301,7 @@ arrayList.replaceAllElements((value, index) => { ``` ### forEach -forEach(callbackfn: (value: T, index?: number, arraylist?: ArrayList<T>) => void, +forEach(callbackfn: (value: T, index?: number, arrlist?: ArrayList<T>) => void, thisArg?: Object): void 通过回调函数来遍历ArrayList实例对象上的元素以及元素对应的下标。 @@ -319,7 +319,7 @@ callbackfn的参数说明: | -------- | -------- | -------- | -------- | | value | T | 是 | 当前遍历到的元素。 | | index | number | 否 | 当前遍历到的下标值。 | -| arraylist | ArrayList<T> | 否 | 当前调用forEach方法的实例对象。 | +| arrlist | ArrayList<T> | 否 | 当前调用forEach方法的实例对象。 | **示例:** @@ -391,9 +391,9 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.subArrayList(2, 4); -arrayList.subArrayList(4, 3); -arrayList.subArrayList(2, 6); +let result1 = arrayList.subArrayList(2, 4); +let result2 = arrayList.subArrayList(4, 3); +let result3 = arrayList.subArrayList(2, 6); ``` ### clear @@ -415,7 +415,8 @@ arrayList.clear(); ### clone clone(): ArrayList<T> -克隆一个与ArrayList一模一样的实例,并返回克隆后的实例,修改克隆后的实例并不会影响原实例。 +克隆一个与ArrayList相同的实例,并返回克隆后的实例。修改克隆后的实例并不会影响原实例。 + **返回值:** @@ -431,7 +432,7 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.clone(); +let result = arrayList.clone(); ``` ### getCapacity @@ -453,7 +454,7 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.getCapacity(); +let result = arrayList.getCapacity(); ``` ### convertToArray @@ -475,7 +476,7 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.convertToArray(); +let result = arrayList.convertToArray(); ``` ### isEmpty @@ -497,7 +498,7 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.isEmpty(); +let result = arrayList.isEmpty(); ``` ### increaseCapacityTo @@ -536,7 +537,7 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.trimToCurrentLength(2); +arrayList.trimToCurrentLength(); ``` ### [Symbol.iterator] diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index 4369e06d5710ff9b4fcefec08576015c83ebba7b..e7e1b3a06ea3d9895f2aafae031f2e15c499a78f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -1,5 +1,13 @@ # 音频管理 +> **说明:** +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +该模块提供以下音频相关的常用功能: + +- [AudioManager](#audiomanager):音频管理。 +- [AudioRenderer](#audiorenderer8):音频播放,用于播放PCM(Pulse Code Modulation)音频数据。 + ## 导入模块 ``` @@ -7,15 +15,17 @@ import audio from '@ohos.multimedia.audio'; ``` -## getAudioManager +## audio.getAudioManager getAudioManager(): AudioManager 获取音频管理器。 +**系统能力:** SystemCapability.Multimedia.Audio.Core + **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ----------------------------- | ------------ | | [AudioManager](#audiomanager) | 音频管理类。 | **示例:** @@ -23,89 +33,356 @@ getAudioManager(): AudioManager var audioManager = audio.getAudioManager(); ``` +## audio.createAudioRenderer8+ + +createAudioRenderer(options: AudioRendererOptions): AudioRenderer + +获取音频播放器。 + +**系统能力:** SystemCapability.Multimedia.Audio.Renderer + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------------- | ---- | ----------- | +| options | [AudioRendererOptions](#audiorendereroptions8) | 是 | 配置播放器. | + +**返回值**: + +| 类型 | 说明 | +| -------------------------------- | ---------------- | +| [AudioRenderer](#audiorenderer8) | 音频播放器对象。 | + +**示例:** + +``` +var audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW +} + +var audioRendererInfo = { + content: audio.ContentType.CONTENT_TYPE_SPEECH, + usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION, + rendererFlags: 1 +} + +var audioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo +} + +let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); +``` ## AudioVolumeType 枚举,音频流类型。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| RINGTONE | 2 | 表示铃声。 | -| MEDIA | 3 | 表示媒体。 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Volume + +| 名称 | 默认值 | 描述 | +| ---------------------------- | ------ | ---------- | +| VOICE_CALL8+ | 0 | 语音电话。 | +| RINGTONE | 2 | 铃声。 | +| MEDIA | 3 | 媒体。 | +| VOICE_ASSISTANT8+ | 9 | 语音助手。 | ## DeviceFlag 枚举,可获取的设备种类。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| OUTPUT_DEVICES_FLAG | 1 | 表示输出设备种类。 | -| INPUT_DEVICES_FLAG | 2 | 表示输入设备种类。 | -| ALL_DEVICES_FLAG | 3 | 表示所有设备种类。 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device + +| 名称 | 默认值 | 描述 | +| ------------------- | ------ | ---------- | +| OUTPUT_DEVICES_FLAG | 1 | 输出设备。 | +| INPUT_DEVICES_FLAG | 2 | 输入设备。 | +| ALL_DEVICES_FLAG | 3 | 所有设备。 | ## DeviceRole 枚举,设备角色。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| INPUT_DEVICE | 1 | 输入设备角色。 | -| OUTPUT_DEVICE | 2 | 输出设备角色。 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device + +| 名称 | 默认值 | 描述 | +| ------------- | ------ | -------------- | +| INPUT_DEVICE | 1 | 输入设备角色。 | +| OUTPUT_DEVICE | 2 | 输出设备角色。 | ## DeviceType 枚举,设备类型。 -| 名称 | 默认值 | 描述 | -| -------------- | ------ | ------------------------------------------------------- | -| INVALID | 0 | 无效设备。 | -| EARPIECE | 1 | 听筒。 | -| SPEAKER | 2 | 扬声器。 | -| WIRED_HEADSET | 3 | 有线耳机。 | -| BLUETOOTH_SCO | 7 | 蓝牙设备SCO连接(Synchronous Connection Oriented)。 | -| BLUETOOTH_A2DP | 8 | 蓝牙设备A2DP连接(Advanced Audio Distribution Profile)。 | -| MIC | 15 | 麦克风。 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device -## ActiveDeviceType7+ +| 名称 | 默认值 | 描述 | +| -------------- | ------ | --------------------------------------------------------- | +| INVALID | 0 | 无效设备。 | +| EARPIECE | 1 | 听筒。 | +| SPEAKER | 2 | 扬声器。 | +| WIRED_HEADSET | 3 | 有线耳机。 | +| BLUETOOTH_SCO | 7 | 蓝牙设备SCO(Synchronous Connection Oriented)连接。 | +| BLUETOOTH_A2DP | 8 | 蓝牙设备A2DP(Advanced Audio Distribution Profile)连接。 | +| MIC | 15 | 麦克风。 | + +## ActiveDeviceType 枚举,活跃设备类型。 -| 名称 | 默认值 | 描述 | -| ------------- | ------ | -------------------------------------------------- | -| SPEAKER | 2 | 扬声器。 | -| BLUETOOTH_SCO | 7 | 蓝牙设备SCO连接(Synchronous Connection Oriented)。 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device + +| 名称 | 默认值 | 描述 | +| ------------- | ------ | ---------------------------------------------------- | +| SPEAKER | 2 | 扬声器。 | +| BLUETOOTH_SCO | 7 | 蓝牙设备SCO(Synchronous Connection Oriented)连接。 | -## AudioRingMode7+ +## AudioRingMode 枚举,铃声模式。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| RINGER_MODE_SILENT | 0 | 静音模式 | -| RINGER_MODE_VIBRATE | 1 | 震动模式 | -| RINGER_MODE_NORMAL | 2 | 响铃模式 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Communication + +| 名称 | 默认值 | 描述 | +| ------------------- | ------ | ---------- | +| RINGER_MODE_SILENT | 0 | 静音模式。 | +| RINGER_MODE_VIBRATE | 1 | 震动模式。 | +| RINGER_MODE_NORMAL | 2 | 响铃模式。 | + +## AudioSampleFormat8+ + +枚举,音频采样格式。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| --------------------- | ------ | -------------------------- | +| SAMPLE_FORMAT_INVALID | -1 | 无效格式。 | +| SAMPLE_FORMAT_U8 | 0 | 无符号8位整数。 | +| SAMPLE_FORMAT_S16LE | 1 | 带符号的16位整数,小尾数。 | +| SAMPLE_FORMAT_S24LE | 2 | 带符号的24位整数,小尾数。 | +| SAMPLE_FORMAT_S32LE | 3 | 带符号的32位整数,小尾数。 | + +## AudioChannel8+ + +枚举, 音频声道。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| --------- | -------- | -------- | +| CHANNEL_1 | 0x1 << 0 | 单声道。 | +| CHANNEL_2 | 0x1 << 1 | 双声道。 | + +## AudioSamplingRate8+ + +枚举,音频采样率。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| ----------------- | ------ | --------------- | +| SAMPLE_RATE_8000 | 8000 | 采样率为8000。 | +| SAMPLE_RATE_11025 | 11025 | 采样率为11025。 | +| SAMPLE_RATE_12000 | 12000 | 采样率为12000。 | +| SAMPLE_RATE_16000 | 16000 | 采样率为16000。 | +| SAMPLE_RATE_22050 | 22050 | 采样率为22050。 | +| SAMPLE_RATE_24000 | 24000 | 采样率为24000。 | +| SAMPLE_RATE_32000 | 32000 | 采样率为32000。 | +| SAMPLE_RATE_44100 | 44100 | 采样率为44100。 | +| SAMPLE_RATE_48000 | 48000 | 采样率为48000。 | +| SAMPLE_RATE_64000 | 64000 | 采样率为64000。 | +| SAMPLE_RATE_96000 | 96000 | 采样率为96000。 | + +## AudioEncodingType8+ + +枚举,音频编码类型。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| --------------------- | ------ | --------- | +| ENCODING_TYPE_INVALID | -1 | 无效。 | +| ENCODING_TYPE_RAW | 0 | PCM编码。 | + +## ContentType8+ + +枚举,音频内容类型。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| ------------------------- | ------ | ---------- | +| CONTENT_TYPE_UNKNOWN | 0 | 未知类型。 | +| CONTENT_TYPE_SPEECH | 1 | 语音。 | +| CONTENT_TYPE_MUSIC | 2 | 音乐。 | +| CONTENT_TYPE_MOVIE | 3 | 电影。 | +| CONTENT_TYPE_SONIFICATION | 4 | 加密类型。 | +| CONTENT_TYPE_RINGTONE | 5 | 铃声。 | + +## StreamUsage8+ + +枚举,音频流使用类型。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| ---------------------------------- | ------ | ---------- | +| STREAM_USAGE_UNKNOWN | 0 | 未知类型。 | +| STREAM_USAGE_MEDIA | 1 | 音频。 | +| STREAM_USAGE_VOICE_COMMUNICATION | 2 | 语音通信。 | +| STREAM_USAGE_NOTIFICATION_RINGTONE | 3 | 通知铃声。 | + +## AudioState8+ + +枚举,音频状态。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 默认值 | 描述 | +| -------------- | ------ | ---------------- | +| STATE_INVALID | -1 | 无效状态。 | +| STATE_NEW | 0 | 创建新实例状态。 | +| STATE_PREPARED | 1 | 准备状态。 | +| STATE_RUNNING | 2 | 可运行状态。 | +| STATE_STOPPED | 3 | 停止状态。 | +| STATE_RELEASED | 4 | 释放状态。 | +| STATE_PAUSED | 5 | 暂停状态。 | + +## AudioRendererRate8+ + +枚举,播放速度。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer + +| 名称 | 默认值 | 描述 | +| ------------------ | ------ | ---------- | +| RENDER_RATE_NORMAL | 0 | 正常速度。 | +| RENDER_RATE_DOUBLE | 1 | 2倍速。 | +| RENDER_RATE_HALF | 2 | 0.5倍数。 | + +## InterruptType8+ + +枚举,中断类型。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer + +| 名称 | 默认值 | 描述 | +| -------------------- | ------ | ---------------------- | +| INTERRUPT_TYPE_BEGIN | 1 | 音频播放中断事件开始。 | +| INTERRUPT_TYPE_END | 2 | 音频播放中断事件结束。 | + +## InterruptForceType8+ +枚举,强制打断类型。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer + +| 名称 | 默认值 | 描述 | +| --------------- | ------ | ------------------------------------ | +| INTERRUPT_FORCE | 0 | 由系统进行操作,强制打断音频播放。 | +| INTERRUPT_SHARE | 1 | 由应用进行操作,可以选择打断或忽略。 | + +## InterruptHint8+ + +枚举,中断提示。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer + +| 名称 | 默认值 | 描述 | +| --------------------- | ------ | -------------------------------------------- | +| INTERRUPT_HINT_NONE | 0 | 无提示。 | +| INTERRUPT_HINT_RESUME | 1 | 提示音频恢复。 | +| INTERRUPT_HINT_PAUSE | 2 | 提示音频暂停。 | +| INTERRUPT_HINT_STOP | 3 | 提示音频停止。 | +| INTERRUPT_HINT_DUCK | 4 | 提示音频躲避。(躲避:音量减弱,而不会停止) | +| INTERRUPT_HINT_UNDUCK | 5 | 提示音量恢复。 | + +## AudioStreamInfo8+ + +音频流信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 类型 | 必填 | 说明 | +| ------------ | ---------------------------------------- | ---- | ------------------ | +| samplingRate | [AudioSamplingRate](#audiosamplingrate8) | 是 | 音频文件的采样率。 | +| channels | [AudioChannel](#audiochannel8) | 是 | 音频文件的通道数。 | +| sampleFormat | [AudioSampleFormat](#audiosampleformat8) | 是 | 音频采样格式。 | +| encodingType | [AudioEncodingType](#audioencodingtype8) | 是 | 音频编码格式。 | + +## AudioRendererInfo8+ + +音频播放器信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Core + +| 名称 | 类型 | 必填 | 说明 | +| ------------- | ---------------------------- | ---- | ---------------- | +| contentType | [ContentType](#contenttype8) | 是 | 媒体类型。 | +| usage | [StreamUsage](#streamusage8) | 是 | 音频流使用类型。 | +| rendererFlags | number | 是 | 音频播放器标志。 | + +## AudioRendererOptions8+ + +音频播放器选项信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer + +| 名称 | 类型 | 必填 | 说明 | +| ------------ | ---------------------------------------- | ---- | ---------------- | +| streamInfo | [AudioStreamInfo](#audiostreaminfo8) | 是 | 表示音频流信息。 | +| rendererInfo | [AudioRendererInfo](#audiorendererinfo8) | 是 | 表示播放器信息。 | + +## InterruptEvent8+ + +播放中断时,应用接收的中断事件。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Renderer + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ------------------------------------------ | ---- | ------------------------------------ | +| eventType | [InterruptType](#interrupttype8) | 是 | 中断事件类型,开始或是结束。 | +| forceType | [InterruptForceType](#interruptforcetype8) | 是 | 操作是由系统执行或是由应用程序执行。 | +| hintType | [InterruptHint](#interrupthint8) | 是 | 中断提示。 | + +## VolumeEvent8+ + +音量改变时,应用接收的事件。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Volume + +| 名称 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | +| updateUi | boolean | 是 | 在UI中显示音量变化。 | ## AudioManager -管理音频音量和音频设备。 +管理音频音量和音频设备。在调用AudioManager的接口前,需要先通过[getAudioManager](#audiogetaudiomanager)创建实例。 ### setVolume setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback<void>): void -设置指定流的音量,使用callback方式返回异步结果。 +设置指定流的音量,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | -| callback | AsyncCallback<void> | 是 | 回调表示成功还是失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | +| callback | AsyncCallback<void> | 是 | 回调表示成功还是失败。 | **示例:** @@ -124,19 +401,21 @@ audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err)=>{ setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> -设置指定流的音量,使用promise方式返回异步结果。 +设置指定流的音量,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | -------------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| volume | number | 是 | 音量等级,可设置范围通过getMinVolume和getMaxVolume获取。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ----------------------------- | | Promise<void> | Promise回调表示成功还是失败。 | **示例:** @@ -152,14 +431,16 @@ audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(()=> getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -获取指定流的音量,使用callback方式返回异步结果。 +获取指定流的音量,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| callback | AsyncCallback<number> | 是 | 回调返回音量大小。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<number> | 是 | 回调返回音量大小。 | **示例:** @@ -178,18 +459,20 @@ audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { getVolume(volumeType: AudioVolumeType): Promise<number> -获取指定流的音量,使用promise方式返回异步结果。 +获取指定流的音量,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| --------------------- | ------------------------- | | Promise<number> | Promise回调返回音量大小。 | **示例:** @@ -205,14 +488,16 @@ audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -获取指定流的最小音量,使用callback方式返回异步结果。 +获取指定流的最小音量,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| callback | AsyncCallback<number> | 是 | 回调返回最小音量。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<number> | 是 | 回调返回最小音量。 | **示例:** @@ -231,18 +516,20 @@ audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { getMinVolume(volumeType: AudioVolumeType): Promise<number> -获取指定流的最小音量,使用promise方式返回异步结果。 +获取指定流的最小音量,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| --------------------- | ------------------------- | | Promise<number> | Promise回调返回最小音量。 | **示例:** @@ -258,14 +545,16 @@ audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void -获取指定流的最大音量,使用callback方式返回异步结果。 +获取指定流的最大音量,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| callback | AsyncCallback<number> | 是 | 回调返回最大音量大小。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ---------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<number> | 是 | 回调返回最大音量大小。 | **示例:** @@ -284,18 +573,20 @@ audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { getMaxVolume(volumeType: AudioVolumeType): Promise<number> -获取指定流的最大音量,使用promise方式返回异步结果。 +获取指定流的最大音量,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| --------------------- | ----------------------------- | | Promise<number> | Promise回调返回最大音量大小。 | **示例:** @@ -307,19 +598,21 @@ audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data)=> ) ``` -### mute7+ +### mute mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void>): void -设置指定音量流静音,使用callback方式返回异步结果。 +设置指定音量流静音,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| mute | boolean | 是 | 静音状态,true为静音,false为非静音。 | -| callback | AsyncCallback<void> | 是 | 回调表示成功还是失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| mute | boolean | 是 | 静音状态,true为静音,false为非静音。 | +| callback | AsyncCallback<void> | 是 | 回调表示成功还是失败。 | **示例:** @@ -334,23 +627,25 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { }) ``` -### mute7+ +### mute mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> -设置指定音量流静音,使用promise方式返回异步结果。 +设置指定音量流静音,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| mute | boolean | 是 | 静音状态,true为静音,false为非静音。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| mute | boolean | 是 | 静音状态,true为静音,false为非静音。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ----------------------------- | | Promise<void> | Promise回调表示成功还是失败。 | **示例:** @@ -364,18 +659,20 @@ audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => ``` -### isMute7+ +### isMute isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void -获取指定音量流是否被静音,使用callback方式返回异步结果。 +获取指定音量流是否被静音,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| callback | AsyncCallback<boolean> | 是 | 回调返回流静音状态,true为静音,false为非静音。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ----------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<boolean> | 是 | 回调返回流静音状态,true为静音,false为非静音。 | **示例:** @@ -391,22 +688,24 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { ``` -### isMute7+ +### isMute isMute(volumeType: AudioVolumeType): Promise<boolean> -获取指定音量流是否被静音,使用promise方式返回异步结果。 +获取指定音量流是否被静音,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------ | | Promise<boolean> | Promise回调返回流静音状态,true为静音,false为非静音。 | **示例:** @@ -418,18 +717,20 @@ audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => ) ``` -### isActive7+ +### isActive isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void -获取指定音量流是否为活跃状态,使用callback方式返回异步结果。 +获取指定音量流是否为活跃状态,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | -| callback | AsyncCallback<boolean> | 是 | 回调返回流的活跃状态,true为活跃,false为不活跃。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------------------------------------------- | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| callback | AsyncCallback<boolean> | 是 | 回调返回流的活跃状态,true为活跃,false为不活跃。 | **示例:** @@ -444,22 +745,24 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => { }) ``` -### isActive7+ +### isActive isActive(volumeType: AudioVolumeType): Promise<boolean> -获取指定音量流是否为活跃状态,使用promise方式返回异步结果。 +获取指定音量流是否为活跃状态,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ----------------------------------- | ---- | ------------ | +| volumeType | [AudioVolumeType](#audiovolumetype) | 是 | 音量流类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------- | -------------------------------------------------------- | | Promise<boolean> | Promise回调返回流的活跃状态,true为活跃,false为不活跃。 | **示例:** @@ -471,18 +774,20 @@ audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) => ) ``` -### setRingerMode7+ +### setRingerMode setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void -设置铃声模式,使用callback方式返回异步结果。 +设置铃声模式,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Communication **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| mode | [AudioRingMode](#audioringmode) | 是 | 音频铃声模式。 | -| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------- | ---- | ------------------------ | +| mode | [AudioRingMode](#audioringmode) | 是 | 音频铃声模式。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | **示例:** @@ -490,29 +795,31 @@ setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void var audioManager = audio.getAudioManager(); audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => { if (err) { - console.error('Failed to set the ringer mode.​ ${err.message}'); + console.error('Failed to set the ringer mode. ${err.message}'); return; } console.log('Callback invoked to indicate a successful setting of the ringer mode.'); }) ``` -### setRingerMode7+ +### setRingerMode setRingerMode(mode: AudioRingMode): Promise<void> -设置铃声模式,使用promise方式返回异步结果。 +设置铃声模式,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Communication **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| mode | [AudioRingMode](#audioringmode) | 是 | 音频铃声模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------------- | ---- | -------------- | +| mode | [AudioRingMode](#audioringmode) | 是 | 音频铃声模式。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ------------------------------- | | Promise<void> | Promise回调返回设置成功或失败。 | **示例:** @@ -525,17 +832,19 @@ audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() => ``` -### getRingerMode7+ +### getRingerMode getRingerMode(callback: AsyncCallback<AudioRingMode>): void -获取铃声模式,使用callback方式返回异步结果。 +获取铃声模式,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Communication **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<[AudioRingMode](#audioringmode)> | 是 | 回调返回系统的铃声模式。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ------------------------ | +| callback | AsyncCallback<[AudioRingMode](#audioringmode)> | 是 | 回调返回系统的铃声模式。 | **示例:** @@ -543,7 +852,7 @@ getRingerMode(callback: AsyncCallback<AudioRingMode>): void var audioManager = audio.getAudioManager(); audioManager.getRingerMode((err, value) => { if (err) { - console.error('Failed to obtain the ringer mode.​ ${err.message}'); + console.error('Failed to obtain the ringer mode. ${err.message}'); return; } console.log('Callback invoked to indicate that the ringer mode is obtained.' + value); @@ -551,16 +860,18 @@ audioManager.getRingerMode((err, value) => { ``` -### getRingerMode7+ +### getRingerMode getRingerMode(): Promise<AudioRingMode> -获取铃声模式,使用promise方式返回异步结果。 +获取铃声模式,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Communication **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------------------------------- | ------------------------------- | | Promise<[AudioRingMode](#audioringmode)> | Promise回调返回系统的铃声模式。 | **示例:** @@ -572,19 +883,21 @@ audioManager.getRingerMode().then((value) => ) ``` -### setAudioParameter7+ +### setAudioParameter setAudioParameter(key: string, value: string, callback: AsyncCallback<void>): void -音频参数设置,使用callback方式返回异步结果。 +音频参数设置,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| key | string | 是 | 被设置的音频参数的键。 | -| value | string | 是 | 被设置的音频参数的值。 | -| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------ | +| key | string | 是 | 被设置的音频参数的键。 | +| value | string | 是 | 被设置的音频参数的值。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | **示例:** @@ -599,23 +912,25 @@ audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => { }) ``` -### setAudioParameter7+ +### setAudioParameter setAudioParameter(key: string, value: string): Promise<void> -音频参数设置,使用promise方式返回异步结果。 +音频参数设置,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| key | string | 是 | 被设置的音频参数的键。 | -| value | string | 是 | 被设置的音频参数的值。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| key | string | 是 | 被设置的音频参数的键。 | +| value | string | 是 | 被设置的音频参数的值。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ------------------------------- | | Promise<void> | Promise回调返回设置成功或失败。 | **示例:** @@ -627,18 +942,20 @@ audioManager.setAudioParameter('PBits per sample', '8 bit').then(() => ) ``` -### getAudioParameter7+ +### getAudioParameter getAudioParameter(key: string, callback: AsyncCallback<string>): void -获取指定音频参数值,使用callback方式返回异步结果。 +获取指定音频参数值,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| key | string | 是 | 待获取的音频参数的键。 | -| callback | AsyncCallback<string> | 是 | 回调返回获取的音频参数的值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ---------------------------- | +| key | string | 是 | 待获取的音频参数的键。 | +| callback | AsyncCallback<string> | 是 | 回调返回获取的音频参数的值。 | **示例:** @@ -653,22 +970,24 @@ audioManager.getAudioParameter('PBits per sample', (err, value) => { }) ``` -### getAudioParameter7+ +### getAudioParameter getAudioParameter(key: string): Promise<string> -获取指定音频参数值,使用promise方式返回异步结果。 +获取指定音频参数值,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| key | string | 是 | 待获取的音频参数的键。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| key | string | 是 | 待获取的音频参数的键。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| --------------------- | ----------------------------------- | | Promise<string> | Promise回调返回获取的音频参数的值。 | **示例:** @@ -684,14 +1003,16 @@ audioManager.getAudioParameter('PBits per sample').then((value) => getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescriptors>): void -获取音频设备列表,使用callback方式返回异步结果。 +获取音频设备列表,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceFlag | [DeviceFlag](#deviceflag) | 是 | 设备类型的flag。 | -| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | 是 | 回调,返回设备列表。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------------------------------------------ | ---- | -------------------- | +| deviceFlag | [DeviceFlag](#deviceflag) | 是 | 设备类型的flag。 | +| callback | AsyncCallback<[AudioDeviceDescriptors](#audiodevicedescriptors)> | 是 | 回调,返回设备列表。 | **示例:** ``` @@ -709,18 +1030,20 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{ (deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors> -获取音频设备列表,使用promise方式返回异步结果。 +获取音频设备列表,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceFlag | [DeviceFlag](#deviceflag) | 是 | 设备类型的flag。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ---------------- | +| deviceFlag | [DeviceFlag](#deviceflag) | 是 | 设备类型的flag。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------------------------------------------------ | ------------------------- | | Promise<[AudioDeviceDescriptors](#audiodevicedescriptors)> | Promise回调返回设备列表。 | **示例:** @@ -732,19 +1055,21 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=> ) ``` -### setDeviceActive7+ +### setDeviceActive setDeviceActive(deviceType: DeviceType, active: boolean, callback: AsyncCallback<void>): void -设置设备激活状态,使用callback方式返回异步结果。 +设置设备激活状态,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | -| active | boolean | 是 | 设备激活状态。 | -| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------------------ | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | +| active | boolean | 是 | 设备激活状态。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | **示例:** @@ -759,23 +1084,25 @@ audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err)=> { }) ``` -### setDeviceActive7+ +### setDeviceActive setDeviceActive(deviceType: DeviceType, active: boolean): Promise<void> -设置设备激活状态,使用promise方式返回异步结果。 +设置设备激活状态,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | -| active | boolean | 是 | 设备激活状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | -------------- | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | +| active | boolean | 是 | 设备激活状态。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ------------------------------- | | Promise<void> | Promise回调返回设置成功或失败。 | **示例:** @@ -788,18 +1115,20 @@ audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(()=> ) ``` -### isDeviceActive7+ +### isDeviceActive isDeviceActive(deviceType: DeviceType, callback: AsyncCallback<boolean>): void -获取指定设备的激活状态,使用callback方式返回异步结果。 +获取指定设备的激活状态,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | -| callback | AsyncCallback<boolean> | 是 | 回调返回设备的激活状态。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ---------------------------- | ---- | ------------------------ | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | +| callback | AsyncCallback<boolean> | 是 | 回调返回设备的激活状态。 | **示例:** @@ -815,22 +1144,24 @@ audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => { ``` -### isDeviceActive7+ +### isDeviceActive isDeviceActive(deviceType: DeviceType): Promise<boolean> -获取指定设备的激活状态,使用promise方式返回异步结果。 +获取指定设备的激活状态,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | -------------- | +| deviceType | [DeviceType](#devicetype) | 是 | 音频设备类型。 | **返回值:** -| Type | Description | -| -------- | -------- | +| Type | Description | +| ---------------------- | ------------------------------- | | Promise<boolean> | Promise回调返回设备的激活状态。 | **示例:** @@ -842,18 +1173,20 @@ audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => ) ``` -### setMicrophoneMute7+ +### setMicrophoneMute setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void -设置麦克风静音状态,使用callback方式返回异步结果。 +设置麦克风静音状态,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| mute | boolean | 是 | 待设置的静音状态,true为静音,false为非静音。 | -| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | --------------------------------------------- | +| mute | boolean | 是 | 待设置的静音状态,true为静音,false为非静音。 | +| callback | AsyncCallback<void> | 是 | 回调返回设置成功或失败。 | **示例:** @@ -868,22 +1201,24 @@ audioManager.setMicrophoneMute(true, (err) => { }) ``` -### setMicrophoneMute7+ +### setMicrophoneMute setMicrophoneMute(mute: boolean): Promise<void> -设置麦克风静音状态,使用promise方式返回异步结果。 +设置麦克风静音状态,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| mute | boolean | 是 | 待设置的静音状态,true为静音,false为非静音。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------- | ---- | --------------------------------------------- | +| mute | boolean | 是 | 待设置的静音状态,true为静音,false为非静音。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------------- | ------------------------------- | | Promise<void> | Promise回调返回设置成功或失败。 | **示例:** @@ -895,17 +1230,19 @@ audioManager.setMicrophoneMute(true).then(() => ) ``` -### isMicrophoneMute7+ +### isMicrophoneMute isMicrophoneMute(callback: AsyncCallback<boolean>): void -获取麦克风静音状态,使用callback方式返回异步结果。 +获取麦克风静音状态,使用callback方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | 是 | 回调返回系统麦克风静音状态,true为静音,false为非静音。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调返回系统麦克风静音状态,true为静音,false为非静音。 | **示例:** @@ -920,16 +1257,18 @@ audioManager.isMicrophoneMute((err, value) => { }) ``` -### isMicrophoneMute7+ +### isMicrophoneMute isMicrophoneMute(): Promise<boolean> -获取麦克风静音状态,使用promise方式返回异步结果。 +获取麦克风静音状态,使用Promise方式异步返回结果。 + +**系统能力:** SystemCapability.Multimedia.Audio.Device **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------- | ------------------------------------------------------------ | | Promise<boolean> | Promise回调返回系统麦克风静音状态,true为静音,false为非静音。 | **示例:** @@ -942,19 +1281,729 @@ audioManager.isMicrophoneMute().then((value) => ) ``` +### on('volumeChange') + +on(type: 'volumeChange', callback: Callback\): void + +监听系统音量变化事件。 + +**系统能力:** SystemCapability.Multimedia.Audio.Volume + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 事件回调类型,支持的事件为:'volumeChange'(系统音量变化事件,检测到系统音量改变时,触发该事件)。 | +| callback | Callback<[VolumeEvent](#volumeevent8)> | 是 | 回调方法。 | + +**示例:** + +``` +audioManager.on('volumeChange', (volumeEvent) => { + console.log('VolumeType of stream: ' + volumeEvent.volumeType); + console.log('Volume level: ' + volumeEvent.volume); + console.log('Whether to updateUI: ' + volumeEvent.updateUi); +}) +``` + +### on('ringerModeChange') + +on(type: 'ringerModeChange', callback: Callback\): void + +监听铃声模式变化事件。 + +**系统能力:** SystemCapability.Multimedia.Audio.Communication + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 事件回调类型,支持的事件为:'ringerModeChange'(铃声模式变化事件,检测到铃声模式改变时,触发该事件)。 | +| callback | Callback<[AudioRingMode](#audioringmode)> | 是 | 回调方法。 | ## AudioDeviceDescriptor 描述音频设备。 -| 名称 | 参数型 | 可读 | 可写 | 说明 | -| -------- | -------- | -------- | -------- | -------- | -| deviceRole | [DeviceRole](#devicerole) | 是 | 否 | 设备角色。 | -| deviceType | [DeviceType](#devicetype) | 是 | 否 | 设备类型。 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device +| 名称 | 参数型 | 可读 | 可写 | 说明 | +| ---------- | ------------------------- | ---- | ---- | ---------- | +| deviceRole | [DeviceRole](#devicerole) | 是 | 否 | 设备角色。 | +| deviceType | [DeviceType](#devicetype) | 是 | 否 | 设备类型。 | ## AudioDeviceDescriptors -| 名称 | 描述 | -| -------- | -------- | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Multimedia.Audio.Device + +| 名称 | 描述 | +| ------------ | ----------------------------------- | | 设备属性数组 | AudioDeviceDescriptor的数组,只读。 | + +**示例:** + +``` +function deviceProp(audioDeviceDescriptor, index, array) { + deviceRoleValue = audioDeviceDescriptor.deviceRole; + deviceTypeValue = audioDeviceDescriptor.deviceType; +} + +deviceRoleValue = null; +deviceTypeValue = null; +const promise = audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG); +promise.then(async function (audioDeviceDescriptors) { + console.info('getDevices OUTPUT_DEVICES_FLAG'); + audioDeviceDescriptors.forEach(deviceProp); + if (deviceTypeValue != null && deviceRoleValue != null){ + console.info('OUTPUT_DEVICES_FLAG : Pass'); + expect(true).assertTrue(); + } + else{ + console.error('OUTPUT_DEVICES_FLAG : fail'); + expect(false).assertTrue(); + } + }); + await promise; + done(); +}) +``` + +## AudioRenderer8+ + +提供音频播放的相关接口。在调用AudioRenderer的接口前,需要先通过[createAudioRenderer](#audiocreateaudiorenderer8)创建实例。 + +### 属性 + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | -------------------------- | ---- | ---- | ------------------ | +| state | [AudioState](#audiostate8) | 是 | 否 | 当前播放器的状态。 | + +**示例:** + +``` +var state = audioRenderer.state; +``` + +### getRendererInfo8+ + +getRendererInfo(callback: AsyncCallback): void + +获取当前被创建的音频播放器的信息,使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :------- | :------------------------------------------------------- | :--- | :------------------------- | +| callback | AsyncCallback<[AudioRendererInfo](#audiorendererinfo8)\> | 是 | 回调返回音频播放器的信息。 | + +**示例:** + +``` +audioRenderer.getRendererInfo((err, rendererInfo)=>{ + console.log('Renderer GetRendererInfo:'); + console.log('Renderer content:' + rendererInfo.content); + console.log('Renderer usage:' + rendererInfo.usage); + console.log('Renderer flags:' + rendererInfo.rendererFlags); +}) +``` + +### getRendererInfo8+ + +getRendererInfo(): Promise + +获取当前被创建的音频播放器的信息,使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------------------------------------------- | ------------------------------- | +| Promise<[AudioRendererInfo](#audiorendererinfo8)\> | Promise用于返回音频播放器信息。 | + +**示例:** + +``` +let streamInfo = await audioRenderer.getStreamInfo(); +console.log('Renderer GetStreamInfo:'); +console.log('Renderer sampling rate:' + streamInfo.samplingRate); +console.log('Renderer channel:' + streamInfo.AudioChannel); +console.log('Renderer format:' + streamInfo.AudioSampleFormat); +console.log('Renderer encoding type:' + streamInfo.AudioEncodingType); +``` + +### getStreamInfo8+ + +getStreamInfo(callback: AsyncCallback): void + +获取音频流信息,使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :------- | :--------------------------------------------------- | :--- | :------------------- | +| callback | AsyncCallback<[AudioStreamInfo](#audiostreaminfo8)\> | 是 | 回调返回音频流信息。 | + +**示例:** + +``` +audioRenderer.getStreamInfo((err, streamInfo)=>{ + console.log('Renderer GetStreamInfo:'); + console.log('Renderer sampling rate:' + streamInfo.samplingRate); + console.log('Renderer channel:' + streamInfo.AudioChannel); + console.log('Renderer format:' + streamInfo.AudioSampleFormat); + console.log('Renderer encoding type:' + streamInfo.AudioEncodingType); +}) +``` + +### getStreamInfo8+ + +getStreamInfo(): Promise + +获取音频流信息,使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| :--------------------------------------------- | :--------------------- | +| Promise<[AudioStreamInfo](#audiostreaminfo8)\> | Promise返回音频流信息. | + +**示例:** + +``` +let streamInfo = await audioRenderer.getStreamInfo(); +console.log('Renderer GetStreamInfo:'); +console.log('Renderer sampling rate:' + streamInfo.samplingRate); +console.log('Renderer channel:' + streamInfo.AudioChannel); +console.log('Renderer format:' + streamInfo.AudioSampleFormat); +console.log('Renderer encoding type:' + streamInfo.AudioEncodingType); +``` + +### start8+ + +start(callback: AsyncCallback): void + +启动音频播放器。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------- | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +audioRenderer.start((err)=>{ + if (err) { + console.error('Renderer start failed.'); + } else { + console.info('Renderer start success.'); + } +}) +``` + +### start8+ + +start(): Promise + +启动音频播放器。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise方式异步返回结果。 | + +**示例:** + +``` +await audioRenderer.start(); +``` + +### pause8+ + +pause(callback: AsyncCallback\): void + +暂停音频播放器。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------- | +| callback | AsyncCallback\ | 是 | 返回回调的结果。 | + +**示例:** + +``` +audioRenderer.pause((err)=>{ + if (err) { + console.error('Renderer pause failed'); + } else { + console.log('Renderer paused.'); + } +}) +``` + +### pause8+ + +pause(): Promise\ + +暂停音频播放器。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise方式异步返回结果。 | + +**示例:** + +``` +await audioRenderer.pause(); +``` + +### drain8+ + +drain(callback: AsyncCallback\): void + +检查播放缓冲区是否已被耗尽。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------- | +| callback | AsyncCallback\ | 是 | 返回回调的结果。 | + +**示例:** + +``` +audioRenderer.drain((err)=>{ + if (err) { + console.error('Renderer drain failed'); + } else { + console.log('Renderer drained.'); + } +}) +``` + +### drain8+ + +drain(): Promise\ + +检查播放缓冲区是否已被耗尽。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise方式异步返回结果。 | + +**示例:** + +``` +await audioRenderer.drain(); +``` + +### stop8+ + +stop(callback: AsyncCallback\): void + +停止播放。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------- | +| callback | AsyncCallback\ | 是 | 返回回调的结果。 | + +**示例:** + +``` +audioRenderer.stop((err)=>{ + if (err) { + console.error('Renderer stop failed'); + } else { + console.log('Renderer stopped.'); + } +}) +``` + +### stop8+ + +stop(): Promise\ + +停止播放。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise方式异步返回结果。 | + +**示例:** + +``` +await audioRenderer.stop(); +``` + +### release8+ + +release(callback: AsyncCallback\): void + +释放音频播放器。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------------- | +| callback | AsyncCallback\ | 是 | 返回回调的结果。 | + +**示例:** + +``` +audioRenderer.release((err)=>{ + if (err) { + console.error('Renderer release failed'); + } else { + console.log('Renderer released.'); + } +}) +``` + +### release8+ + +release(): Promise\ + +释放渲染器。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise方式异步返回结果。 | + +**示例:** + +``` +await audioRenderer.release(); +``` + +### write8+ + +write(buffer: ArrayBuffer, callback: AsyncCallback\): void + +写入缓冲区。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | --------------------------------------------------- | +| buffer | ArrayBuffer | 是 | 要写入缓冲区的数据。 | +| callback | AsyncCallback\ | 是 | 回调如果成功,返回写入的字节数,否则返回errorcode。 | + +**示例:** + +``` +let ss = fileio.createStreamSync(filePath, 'r'); +let buf = new ArrayBuffer(bufferSize); +ss.readSync(buf); +audioRenderer.write(buf, (err, writtenbytes)=>{ + if (writtenbytes < 0) { + console.error('write failed.'); + } else { + console.log('Actual written bytes: ' + writtenbytes); + } +}) +``` + +### write8+ + +write(buffer: ArrayBuffer): Promise\ + +写入缓冲区。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------------------------------------------------ | +| Promise\ | Promise返回结果,如果成功,返回写入的字节数,否则返回errorcode。 | + +**示例:** + +``` +let ss = fileio.createStreamSync(filePath, 'r'); +let buf = new ArrayBuffer(bufferSize); +ss.readSync(buf); +let writtenbytes = await audioRenderer.write(buf); +if (writtenbytes < 0) { + console.error('write failed.'); +} else { + console.log('Actual written bytes: ' + writtenbytes); +} +``` + +### getAudioTime8+ + +getAudioTime(callback: AsyncCallback\): void + +获取时间戳。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ---------------- | +| callback | AsyncCallback\ | 是 | 回调返回时间戳。 | + +**示例:** + +``` +audioRenderer.getAudioTime((err, timestamp)=>{ + console.log('Current timestamp: ' + timestamp); +}) +``` + +### getAudioTime8+ + +getAudioTime(): Promise\ + +获取时间戳。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 描述 | +| ---------------- | ----------------------- | +| Promise\ | Promise回调返回时间戳。 | + +**示例:** + +``` +let timestamp = await audioRenderer.getAudioTime(); +console.log('Current timestamp: ' + timestamp); +``` + +### getBufferSize8+ + +getBufferSize(callback: AsyncCallback\): void + +获取音频播放器的最小缓冲区大小。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | -------------------- | +| callback | AsyncCallback\ | 是 | 回调返回缓冲区大小。 | + +**示例:** + +``` +audioRenderer.getBufferSize((err, bufferSize)=>{ + if (err) { + console.error('getBufferSize error'); + } +}) +let buf = new ArrayBuffer(bufferSize); +ss.readSync(buf); +``` + +### getBufferSize8+ + +getBufferSize(): Promise\ + +获取音频播放器的最小缓冲区大小。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| ---------------- | --------------------------- | +| Promise\ | promise回调返回缓冲区大小。 | + +**示例:** + +``` +var bufferSize = await audioRenderer.getBufferSize(); +let buf = new ArrayBuffer(bufferSize); +ss.readSync(buf); +``` + +### setRenderRate8+ + +setRenderRate(rate: AudioRendererRate, callback: AsyncCallback\): void + +设置音频播放速率。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------ | +| rate | [AudioRendererRate](#audiorendererrate8) | 是 | 播放的速率。 | +| callback | AsyncCallback\ | 是 | 用于返回执行结果的回调。 | + +**示例:** + +``` +audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err)=> { + if (err) { + console.error('Failed to set params'); + } else { + console.log('Callback invoked to indicate a successful render rate setting.'); + } +}) +``` + +### setRenderRate8+ + +setRenderRate(rate: AudioRendererRate): Promise\ + +设置音频播放速率。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------------------------------------- | ---- | ------------ | +| rate | [AudioRendererRate](#audiorendererrate8) | 是 | 播放的速率。 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------- | +| Promise\ | Promise用于返回执行结果。 | + +**示例:** + +``` +await audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL); +``` + +### getRenderRate8+ + +getRenderRate(callback: AsyncCallback\): void + +获取当前播放速率。使用callback方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------ | +| callback | AsyncCallback<[AudioRendererRate](#audiorendererrate8)> | 是 | 回调返回播放速率。 | + +**示例:** + +``` +audioRenderer.getRenderRate((err, renderrate)=>{ + console.log('getRenderRate: ' + renderrate); +}) +``` + +### getRenderRate8+ + +getRenderRate(): Promise\ + +获取当前播放速率。使用Promise方式异步返回结果。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------- | ------------------------- | +| Promise<[AudioRendererRate](#audiorendererrate8)> | Promise回调返回播放速率。 | + +**示例:** + +``` +let renderRate = await audioRenderer.getRenderRate(); +console.log('getRenderRate: ' + renderrate); +``` + +### on('interrupt')8+ + +on(type: 'interrupt', callback: Callback\): void + +监听音频中断事件。使用callback获取中断事件。 + +**系统能力**: SystemCapability.Multimedia.Audio.Renderer + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 事件回调类型,支持的事件为:'interrupt'(中断事件被触发,音频播放被中断。) | +| callback | Callback<[InterruptEvent](#interruptevent8)> | 是 | 被监听的中断事件的回调。 | + +**示例:** + +``` +audioRenderer.on('interrupt', (interruptEvent) => { + if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { + switch (interruptEvent.hintType) { + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.log('Force paused. Stop writing'); + isPlay = false; + break; + case audio.InterruptHint.INTERRUPT_HINT_STOP: + console.log('Force stopped. Stop writing'); + isPlay = false; + break; + } + } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { + switch (interruptEvent.hintType) { + case audio.InterruptHint.INTERRUPT_HINT_RESUME: + console.log('Resume force paused renderer or ignore'); + startRenderer(); + break; + case audio.InterruptHint.INTERRUPT_HINT_PAUSE: + console.log('Choose to pause or ignore'); + pauseRenderer(); + break; + } + } +}) +``` + + + diff --git a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md index fb4a41f4bbd0ba63a5088ad0a75c2c6677a1ee81..7e0470b09ba94fb61061c1b60851664db87c5f2f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -10,10 +10,6 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager'; ``` -## 系统能力 -SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask - ## 权限列表 长时任务需要申请如下权限: @@ -29,6 +25,8 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen 延迟挂起时间一般情况下默认值为180000,低电量(依据系统低电量广播)时默认值为60000。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -55,6 +53,8 @@ getRemainingDelayTime(requestId: number, callback: AsyncCallback<number>): 获取应用程序进入挂起状态前的剩余时间,使用callback形式返回。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -80,6 +80,8 @@ getRemainingDelayTime(requestId: number): Promise<number> 获取应用程序进入挂起状态前的剩余时间,使用Promise形式返回。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -107,6 +109,8 @@ cancelSuspendDelay(requestId: number): void 取消延迟挂起。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -122,6 +126,8 @@ cancelSuspendDelay(requestId: number): void 延迟挂起信息。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask + | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | requestId | number | 是 | 延迟挂起的请求ID。 | @@ -129,16 +135,18 @@ cancelSuspendDelay(requestId: number): void ## backgroundTaskManager.startBackgroundRunning -[8] startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void; +startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void; 8+ 向系统申请长时任务,使用callback形式返回结果。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | context | Context | 是 | 应用运行的上下文 | | bgMode | BackgroundMode | 是 | 向系统申请的后台模式 | - | wantAgent | WantAgent | 是 | 通知参数,用于指定长时任务通知点击跳转的界面。使用方式参考:[8] | + | wantAgent | [WantAgent](js-apis-notification.md#WantAgent接口) | 是 | 通知参数,用于指定长时任务通知点击后跳转的界面。 | | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果 | - **示例**: @@ -176,16 +184,18 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { ## backgroundTaskManager.startBackgroundRunning -[8] startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void> +startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void>; 8+ 向系统申请长时任务,使用promise形式返回结果。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | context | Context | 是 | 应用运行的上下文 | | bgMode | BackgroundMode | 是 | 向系统申请的后台模式 | - | wantAgent | WantAgent | 是 | 通知参数,用于指定长时任务通知点击跳转的界面 | + | wantAgent | [WantAgent](js-apis-notification.md#WantAgent接口) | 是 | 通知参数,用于指定长时任务通知点击跳转的界面 | - **返回值** | 类型 | 说明 | @@ -223,10 +233,12 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { ## backgroundTaskManager.stopBackgroundRunning -[8] stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void; +stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void; 8+ 向系统申请取消长时任务,使用callback形式返回结果。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -252,10 +264,12 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext(), callbac ## backgroundTaskManager.stopBackgroundRunning -[8] stopBackgroundRunning(context: Context): Promise<void>; +stopBackgroundRunning(context: Context): Promise<void>; 8+ 向系统申请取消长时任务,使用promise形式返回结果。 +**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -279,16 +293,16 @@ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() ``` -## [8] BackgroundMode +## BackgroundMode 8+ -| 参数名 | 参数 | 描述 | +| 参数名 | 参数值 | 描述 | | ----------------------- | -------- | -------- | -| DATA_TRANSFER | 1 | 数据传输 | -| AUDIO_PLAYBACK | 2 | 音频播放 | -| AUDIO_RECORDING | 3 | 录音 | -| LOCATION | 4 | 定位导航 | -| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 | -| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 | -| WIFI_INTERACTION | 7 | WLAN相关(系统保留) | -| VOIP | 8 | 音视频通话(系统保留) | -| TASK_KEEPING | 9 | 计算任务(仅供PC使用) | \ No newline at end of file +| DATA_TRANSFER | 1 | 数据传输
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| AUDIO_PLAYBACK | 2 | 音频播放
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| AUDIO_RECORDING | 3 | 录音
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| LOCATION | 4 | 定位导航
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| BLUETOOTH_INTERACTION | 5 | 蓝牙相关
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| MULTI_DEVICE_CONNECTION | 6 | 多设备互联
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| WIFI_INTERACTION | 7 | WLAN相关(系统保留)
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| VOIP | 8 | 音视频通话(系统保留)
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | +| TASK_KEEPING | 9 | 计算任务(仅供PC使用)
**系统能力:** SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-battery-info.md b/zh-cn/application-dev/reference/apis/js-apis-battery-info.md index 0bed039fe933b4679bb14facf48238d5114a226f..d627fed783604e6d04c6568c79038137e1ebb465 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-battery-info.md +++ b/zh-cn/application-dev/reference/apis/js-apis-battery-info.md @@ -3,6 +3,8 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +该模块主要提供电池状态和充放电状态的查询接口。 + ## 导入模块 @@ -12,22 +14,22 @@ import batteryInfo from '@ohos.batteryInfo'; ## 系统能力 -SystemCapability.PowerManager.BatteryManager +SystemCapability.PowerManager.BatteryManager.Core ## 属性 描述电池信息。 -| 名称 | 类型 | 可读 | 可写 | 描述 | -| -------- | -------- | -------- | -------- | -------- | -| batterySOC | number | 是 | 否 | 表示当前设备剩余电池电量百分比。 | -| chargingStatus | [BatteryChargeState](#batterychargestate) | 是 | 否 | 表示当前设备电池的充电状态。 | -| healthStatus | [BatteryHealthState](#batteryhealthstate) | 是 | 否 | 表示当前设备电池的健康状态。 | -| pluggedType | [BatteryPluggedType](#batterypluggedtype) | 是 | 否 | 表示当前设备连接的充电器类型。 | -| voltage | number | 是 | 否 | 表示当前设备电池的电压,单位微伏。 | -| technology | string | 是 | 否 | 表示当前设备电池的技术型号。 | -| batteryTemperature | number | 是 | 否 | 表示当前设备电池的温度,单位0.1摄氏度。 | -| isBatteryPresent7+ | boolean | 是 | 否 | 表示当前设备是否支持电池或者电池是否在位。 | +| 名称 | 类型 | 可读 | 可写 | 描述 | +| ----------------------------- | ---------------------------------------- | ---- | ---- | --------------------- | +| batterySOC | number | 是 | 否 | 表示当前设备剩余电池电量百分比。 | +| chargingStatus | [BatteryChargeState](#batterychargestate) | 是 | 否 | 表示当前设备电池的充电状态。 | +| healthStatus | [BatteryHealthState](#batteryhealthstate) | 是 | 否 | 表示当前设备电池的健康状态。 | +| pluggedType | [BatteryPluggedType](#batterypluggedtype) | 是 | 否 | 表示当前设备连接的充电器类型。 | +| voltage | number | 是 | 否 | 表示当前设备电池的电压,单位微伏。 | +| technology | string | 是 | 否 | 表示当前设备电池的技术型号。 | +| batteryTemperature | number | 是 | 否 | 表示当前设备电池的温度,单位0.1摄氏度。 | +| isBatteryPresent7+ | boolean | 是 | 否 | 表示当前设备是否支持电池或者电池是否在位。 | - 示例: ``` @@ -41,12 +43,12 @@ SystemCapability.PowerManager.BatteryManager 表示连接的充电器类型的枚举。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| NONE | 0 | 表示连接充电器类型未知。 | -| AC | 1 | 表示连接的充电器类型为交流充电器。 | -| USB | 2 | 表示连接的充电器类型为USB。 | -| WIRELESS | 3 | 表示连接的充电器类型为无线充电器。 | +| 名称 | 默认值 | 描述 | +| -------- | ---- | ----------------- | +| NONE | 0 | 表示连接充电器类型未知。 | +| AC | 1 | 表示连接的充电器类型为交流充电器。 | +| USB | 2 | 表示连接的充电器类型为USB。 | +| WIRELESS | 3 | 表示连接的充电器类型为无线充电器。 | ## BatteryChargeState @@ -54,12 +56,12 @@ SystemCapability.PowerManager.BatteryManager 表示电池充电状态的枚举。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| NONE | 0 | 表示电池充电状态未知。 | -| ENABLE | 1 | 表示电池充电状态为使能状态。 | -| DISABLE | 2 | 表示电池充电状态为停止状态。 | -| FULL | 3 | 表示电池充电状态为已充满状态。 | +| 名称 | 默认值 | 描述 | +| ------- | ---- | --------------- | +| NONE | 0 | 表示电池充电状态未知。 | +| ENABLE | 1 | 表示电池充电状态为使能状态。 | +| DISABLE | 2 | 表示电池充电状态为停止状态。 | +| FULL | 3 | 表示电池充电状态为已充满状态。 | ## BatteryHealthState @@ -67,11 +69,11 @@ SystemCapability.PowerManager.BatteryManager 表示电池的健康状态的枚举。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| UNKNOWN | 0 | 表示电池健康状态未知。 | -| GOOD | 1 | 表示电池健康状态为正常。 | -| OVERHEAT | 2 | 表示电池健康状态为过热。 | -| OVERVOLTAGE | 3 | 表示电池健康状态为过压。 | -| COLD | 4 | 表示电池健康状态为低温。 | -| DEAD | 5 | 表示电池健康状态为僵死状态。 | +| 名称 | 默认值 | 描述 | +| ----------- | ---- | -------------- | +| UNKNOWN | 0 | 表示电池健康状态未知。 | +| GOOD | 1 | 表示电池健康状态为正常。 | +| OVERHEAT | 2 | 表示电池健康状态为过热。 | +| OVERVOLTAGE | 3 | 表示电池健康状态为过压。 | +| COLD | 4 | 表示电池健康状态为低温。 | +| DEAD | 5 | 表示电池健康状态为僵死状态。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md b/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md index 631329ebb3228fbb8a60293c7714fdd794bfee77..4a21a3d900e1eceb345860e4e3e27bd1566f49bd 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bluetooth.md @@ -239,7 +239,7 @@ getRemoteDeviceClass(deviceId: string): DeviceClass | 类型 | 说明 | | -------- | -------- | -| [DeviceClass](#DeviceClass) | 远程设备的类别。 | +| [DeviceClass](#deviceclass) | 远程设备的类别。 | **示例:** @@ -1982,7 +1982,7 @@ if (retWriteDesc) { setBLEMtuSize(mtu: number): boolean -client协商远端蓝牙低功耗设备的最大传输单元(Maximum Transmission Unit, MTU),调用connect接口连接成功后才能使用。 +client协商远端蓝牙低功耗设备的最大传输单元(Maximum Transmission Unit, MTU),调用[connect](#connect)接口连接成功后才能使用。 **参数:** @@ -2196,7 +2196,7 @@ let deviceName = gattClient.getDeviceName().then((data) => { getRssiValue(callback: AsyncCallback<number>): void -client获取远端蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI),调用[connect](#connect-boolean)接口连接成功后才能使用。 +client获取远端蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI),调用[connect](#connect)接口连接成功后才能使用。 **参数:** @@ -2225,7 +2225,7 @@ let rssi = gattClient.getRssiValue((err, data)=> { getRssiValue(): Promise<number> -client获取远端蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI),调用[connect](#connect-boolean)接口连接成功后才能使用。 +client获取远端蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI),调用[connect](#connect)接口连接成功后才能使用。 **返回值:** @@ -2277,7 +2277,7 @@ let rssi = gattClient.getRssiValue().then((data) => { | -------- | -------- | -------- | -------- | -------- | | uuid | string | 是 | 是 | spp单据的uuid。 | | isPrimary | boolean | 是 | 是 | 是否是安全通道。 | -| type | [SppType](#SppType) | 是 | 是 | Spp链路类型。 | +| type | [SppType](#spptype) | 是 | 是 | Spp链路类型。 | ## SppType @@ -2297,8 +2297,8 @@ let rssi = gattClient.getRssiValue().then((data) => { | -------- | -------- | -------- | -------- | -------- | | serviceUuid | string | 是 | 是 | 特定服务(service)的UUID,例如:00001888-0000-1000-8000-00805f9b34fb。 | | isPrimary | boolean | 是 | 是 | 如果是主服务设置为true,否则设置为false。 | -| characteristics | Array<[BLECharacteristic](#BLECharacteristic)> | 是 | 是 | 当前服务包含的特征列表。 | -| includeServices | Array<[GattService](#GattService)> | 是 | 是 | 当前服务依赖的其它服务。 | +| characteristics | Array<[BLECharacteristic](#blecharacteristic)> | 是 | 是 | 当前服务包含的特征列表。 | +| includeServices | Array<[GattService](#gattservice)> | 是 | 是 | 当前服务依赖的其它服务。 | ## BLECharacteristic @@ -2310,7 +2310,7 @@ let rssi = gattClient.getRssiValue().then((data) => { | serviceUuid | string | 是 | 是 | 特定服务(service)的UUID,例如:00001888-0000-1000-8000-00805f9b34fb。 | | characteristicUuid | string | 是 | 是 | 特定特征(characteristic)的UUID,例如:00002a11-0000-1000-8000-00805f9b34fb。 | | characteristicValue | ArrayBuffer | 是 | 是 | 特征对应的二进制值。 | -| descriptors | Array<[BLEDescriptor](#BLEDescriptor)> | 是 | 是 | 特定特征的描述符列表。 | +| descriptors | Array<[BLEDescriptor](#bledescriptor)> | 是 | 是 | 特定特征的描述符列表。 | ## BLEDescriptor @@ -2415,7 +2415,7 @@ let rssi = gattClient.getRssiValue().then((data) => { | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | deviceId | string | 是 | 否 | 表示远端设备地址,例如:"XX:XX:XX:XX:XX:XX"。 | -| state | [ProfileConnectionState](#ProfileConnectionState) | 是 | 是 | 表示BLE连接状态的枚举。 | +| state | [ProfileConnectionState](#profileconnectionState) | 是 | 是 | 表示BLE连接状态的枚举。 | ## ProfileConnectionState @@ -2448,8 +2448,8 @@ let rssi = gattClient.getRssiValue().then((data) => { | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | interval | number | 是 | 是 | 表示扫描结果上报延迟时间,默认值为0。 | -| dutyMode | [ScanDuty](#ScanDuty) | 是 | 是 | 表示扫描模式,默认值为SCAN_MODE_LOW_POWER。 | -| matchMode | [MatchMode](#MatchMode) | 是 | 是 | 表示硬件的过滤匹配模式,默认值为MATCH_MODE_AGGRESSIVE。 | +| dutyMode | [ScanDuty](#scanduty) | 是 | 是 | 表示扫描模式,默认值为SCAN_MODE_LOW_POWER。 | +| matchMode | [MatchMode](#matchmode) | 是 | 是 | 表示硬件的过滤匹配模式,默认值为MATCH_MODE_AGGRESSIVE。 | ## ScanDuty @@ -2517,8 +2517,8 @@ let rssi = gattClient.getRssiValue().then((data) => { | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | serviceUuids | Array<string> | 是 | 是 | 表示要广播的服务 UUID 列表。 | -| manufactureData | Array<[ManufactureData](#ManufactureData)> | 是 | 是 | 表示要广播的广播的制造商信息列表。 | -| serviceData | Array<[ServiceData](#ServiceData)> | 是 | 是 | 表示要广播的服务数据列表。 | +| manufactureData | Array<[ManufactureData](#manufacturedata)> | 是 | 是 | 表示要广播的广播的制造商信息列表。 | +| serviceData | Array<[ServiceData](#servicedata)> | 是 | 是 | 表示要广播的服务数据列表。 | ## ManufactureData @@ -2557,8 +2557,8 @@ let rssi = gattClient.getRssiValue().then((data) => { | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| majorClass | [MajorClass](#MajorClass) | 是 | 否 | 表示蓝牙设备主要类别的枚举。 | -| majorMinorClass | [MajorMinorClass](#MajorMinorClass) | 是 | 否 | 表示主要次要蓝牙设备类别的枚举。 | +| majorClass | [MajorClass](#majorclass) | 是 | 否 | 表示蓝牙设备主要类别的枚举。 | +| majorMinorClass | [MajorMinorClass](#majorminorclass) | 是 | 否 | 表示主要次要蓝牙设备类别的枚举。 | | classOfDevice | number | 是 | 否 | 表示设备类别。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-brightness.md b/zh-cn/application-dev/reference/apis/js-apis-brightness.md index 9692cb136f5ac05ef9fe2152f8ce73297994a074..2398385699fc110af31de75c474e1d4a370b8977 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-brightness.md +++ b/zh-cn/application-dev/reference/apis/js-apis-brightness.md @@ -3,6 +3,8 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +该模块提供屏幕亮度的设置接口。 + ## 导入模块 @@ -10,23 +12,24 @@ import brightness from '@ohos.brightness'; ``` -## 系统能力 - -SystemCapability.PowerManager.DisplayPowerManager - ## brightness.setValue setValue(value: number) 设置系统的屏幕亮度。 -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------- | -------- | -------- | - | value | number | 是 | 亮度的值(0~255) | +**系统能力:** SystemCapability.PowerManager.DisplayPowerManager + +**补充说明:** 该接口为system api,仅供系统应用使用。 + +**参数:** -- 示例: - ``` - import brightness from '@ohos.brightness.d.ts'; - brightness.setValue(128); - ``` +| 参数名 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | ----------- | +| value | number | 是 | 亮度的值(0~255) | + +**示例:** + +``` +brightness.setValue(128); +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-bytrace.md b/zh-cn/application-dev/reference/apis/js-apis-bytrace.md index 9276e557f6419e68cfd7c32c49870a99dff7880a..22baa86785ce06e33a6eedb72656e56aad7a49a7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-bytrace.md +++ b/zh-cn/application-dev/reference/apis/js-apis-bytrace.md @@ -1,7 +1,7 @@ # 性能打点 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> - 从API Version 8开始,该接口不再维护,推荐使用新接口[hiTraceMeter](js-apis-hitracemeter.md)。具体新接口在接口描述中说明。 +> - 从API Version 8开始,该接口不再维护,推荐使用新接口[hiTraceMeter](js-apis-hitracemeter.md)。 > - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-call.md b/zh-cn/application-dev/reference/apis/js-apis-call.md index 2319264154c907ca625343e05a9478a3321886b5..1bf0985bda96fba12aac0deb8ec4d0c490b50125 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-call.md +++ b/zh-cn/application-dev/reference/apis/js-apis-call.md @@ -102,6 +102,61 @@ promise.then(data => { }); ``` +## call.makeCall7+ + +makeCall(phoneNumber: string, callback: AsyncCallback): void + +跳转到拨号界面,并显示拨号的号码,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Telephony.CallManager + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | ------------------------------------------ | +| phoneNumber | string | 是 | 电话号码。 | +| callback | AsyncCallback<void> | 是 | 以callback形式异步返回跳转拨号界面的结果。 | + +**示例:** + +``` +call.makeCall("138xxxxxxxx", err => { + console.log(`makeCall callback: err->${JSON.stringify(err)}`); +}); +``` + + +## call.makeCall7+ + +makeCall(phoneNumber: string): Promise + +跳转到拨号界面,并显示拨号的号码,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Telephony.CallManager + +**参数:** + +| 参数 | 类型 | 必填 | 说明 | +| ----------- | ------ | ---- | ---------- | +| phoneNumber | string | 是 | 电话号码。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------- | --------------------------------- | +| Promise<void> | 以Promise形式异步返回拨号的结果。 | + +**示例:** + +``` +let promise = call.makeCall("138xxxxxxxx"); +promise.then(() => { + console.log(`makeCall success`); +}).catch(err => { + console.error(`makeCall fail, promise: err->${JSON.stringify(err)}`); +}); +``` + ## call.hasCall hasCall\(callback: AsyncCallback\): void @@ -199,6 +254,25 @@ promise.then(data => { }); ``` +## call.hasVoiceCapability7+ + +hasVoiceCapability(): boolean + +检查当前设备是否具备语音通话能力,该方法是同步方法。 + +**系统能力**:SystemCapability.Telephony.CallManager + +**返回值:** + +| 类型 | 说明 | +| ------- | ------------------------------------------------------------ | +| boolean | - true:设备具备语音通话能力
- false:设备不具备语音通话能力 | + +``` +let result = call.hasVoiceCapability(); +console.log(`hasVoiceCapability: ${JSON.stringify(result)}`); +``` + ## call.isEmergencyPhoneNumber7+ isEmergencyPhoneNumber\(phoneNumber: string, callback: AsyncCallback\): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-camera.md b/zh-cn/application-dev/reference/apis/js-apis-camera.md index cb34f90715f3f769607381a01ca39862ba0409ed..ed5e53a56efcb451f35a7ac7c08c13956282d473 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-camera.md +++ b/zh-cn/application-dev/reference/apis/js-apis-camera.md @@ -1,4 +1,7 @@ -# 相机管理 +# 相机管理 + +> **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -8,30 +11,22 @@ import camera from '@ohos.multimedia.camera'; ## 权限 -``` ohos.permission.CAMERA -``` -## getCameraManager(context: Context, callback: AsyncCallback): void; -**系统能力:** +## camera.getCameraManager -SystemCapability.Multimedia.Camera.Core +getCameraManager(context: Context, callback: AsyncCallback): void -**说明:** +获取相机管理器实例,通过注册回调函数获取结果。 -获取**相机管理器**,使用callback方式获取一个异步的实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|-------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | 应用环境 | -| callback | AsyncCallback | Yes | 使用callback方式获取**相机管理器**实例
| - - -**返回值:** - -none +| context | Context | 是 | 应用上下文。 | +| callback | AsyncCallback<[CameraManager](#cameramanager)\> | 是 | 回调函数,用于获取相机管理器实例。 | **示例:** @@ -45,27 +40,25 @@ camera.getCameraManager(context, (err, cameraManager) => { }); ``` -## getCameraManager(context: Context): Promise; - -**系统能力:** +## camera.getCameraManager -SystemCapability.Multimedia.Camera.Core +getCameraManager(context: Context): Promise -**说明:** +获取相机管理器实例,通过Promise获取结果。 -获取**相机管理器**,使用promise的方式获取一个实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------| -| context | Context | Yes | 应用环境 | +| context | Context | 是 | 应用上下文。 | **返回值:** | 类型 | 说明 | |-------------------------|--------------------------------------------------------| -| Promise | 使用Promise的方式获取一个**相机管理器** 实例 | +| Promise<[CameraManager](#cameramanager)\> | 使用Promise的方式获取一个相机管理器实例。 | **示例:** @@ -75,87 +68,81 @@ camera.getCameraManager(context).then((cameraManger) => { }) ``` -## CameraStatus +## CameraStatus -枚举相机状态类型。 +枚举,相机状态。 | 名称 | 默认值 | 说明 | |---------------------------|---------------|--------------------| -| CAMERA_STATUS_APPEAR | 0 | Camera appear
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_STATUS_DISAPPEAR | 1 | Camera disappear
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_STATUS_AVAILABLE | 2 | 相机就绪
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_STATUS_UNAVAILABLE | 3 | 相机未就绪
系统能力 : SystemCapability.Multimedia.Camera.Core | +| CAMERA_STATUS_APPEAR | 0 | 相机存在。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_STATUS_DISAPPEAR | 1 | 相机不存在。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_STATUS_AVAILABLE | 2 | 相机就绪。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_STATUS_UNAVAILABLE | 3 | 相机未就绪。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## CameraPosition +## CameraPosition -枚举相机位置。 +枚举,相机方向。 | 名称 | 默认值 | 说明 | |-----------------------------|---------------|-----------------------| -| CAMERA_POSITION_UNSPECIFIED | 0 | 未指定方向相机
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_POSITION_BACK | 1 | 后置相机
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_POSITION_FRONT | 2 | 前置相机
系统能力 : SystemCapability.Multimedia.Camera.Core | +| CAMERA_POSITION_UNSPECIFIED | 0 | 未指定方向相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_POSITION_BACK | 1 | 后置相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_POSITION_FRONT | 2 | 前置相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## CameraType +## CameraType -枚举相机类型。 +枚举,相机类型。 | 名称 | 默认值 | 说明 | |-------------------------|---------------|-------------------------| -| CAMERA_TYPE_UNSPECIFIED | 0 | 未指定相机类型
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_TYPE_ULTRA_WIDE | 2 | 超级广角相机
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_TYPE_TELEPHOTO | 3 | 电话相机
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_TYPE_TRUE_DEPTH | 4 | 深度相机
系统能力 : SystemCapability.Multimedia.Camera.Core | +| CAMERA_TYPE_UNSPECIFIED | 0 | 未指定相机类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_TYPE_WIDE_ANGLE | 1 | 广角相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_TYPE_ULTRA_WIDE | 2 | 超级广角相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_TYPE_TELEPHOTO | 3 | 长焦相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_TYPE_TRUE_DEPTH | 4 | 深度相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## ConnectionType +## ConnectionType -枚举相机连接类型。 +枚举,相机连接类型。 | 名称 | 默认值 | 说明 | |------------------------------|---------------|----------------------------| -| CAMERA_CONNECTION_BUILT_IN | 0 | 内置相机
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_CONNECTION_USB_PLUGIN | 1 | USB外连相机
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_CONNECTION_REMOTE | 2 | 分布式相机
系统能力 : SystemCapability.Multimedia.Camera.Core | +| CAMERA_CONNECTION_BUILT_IN | 0 | 内置相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_CONNECTION_USB_PLUGIN | 1 | 外置USB相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_CONNECTION_REMOTE | 2 | 分布式相机。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## CameraFormat +## CameraFormat -枚举相机格式。 +枚举,照片格式。 | 名称 | 默认值 | 说明 | |----------------------------|---------------|---------------------| -| CAMERA_FORMAT_YCRCb_420_SP | 1003 | YCRCb格式
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_FORMAT_JPEG | 2000 | JPEG格式
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_FORMAT_AVC | 3000 | AVC 格式
系统能力 : SystemCapability.Multimedia.Camera.Core | -| CAMERA_FORMAT_HEVC | 3001 | HEVC 格式
系统能力 : SystemCapability.Multimedia.Camera.Core | - +| CAMERA_FORMAT_YCRCb_420_SP | 1003 | YCRCb格式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_FORMAT_JPEG | 2000 | JPEG格式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_FORMAT_AVC | 3000 | AVC格式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| CAMERA_FORMAT_HEVC | 3001 | HEVC格式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## CameraManager -相机管理器类, 包含获取相机并创建“相机输入”实例。 +## CameraManager -### getCameras(callback: AsyncCallback\>): void; +相机管理器类,使用前需要通过getCameraManager获取相机管理实例。 -**系统能力:** +### getCameras -SystemCapability.Multimedia.Camera.Core +getCameras(callback: AsyncCallback\>): void -**说明:** +异步获取设备支持的相机列表,通过注册回调函数获取结果。 -获取设备支持的所有相机,使用callback方式获取异步的支持相机列表。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|--------------------------------|-----------|---------------------------------------------------------| -| callback | AsyncCallback\> | Yes | 使用callback方式获取支持的相机列表 | - -**返回值:** - -none +| callback | AsyncCallback\> | 是 | 使用callback方式获取支持的相机列表。 | **示例:** @@ -169,25 +156,19 @@ cameraManager.getCameras((err, cameras) => { }) ``` -### getCameras(): Promise\>; +### getCameras -**系统能力:** +getCameras(): Promise\> -SystemCapability.Multimedia.Camera.Core +异步获取设备支持的相机列表,通过Promise获取结果。 -**说明:** - -获取设备支持的所有相机,使用promise方式获取支持相机列表。 - -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |------------------------|--------------------------------------------------------| -| Promise\> | 使用promise方获取支持相机列表 | +| Promise\> | 使用promise获取支持相机列表。 | **示例:** @@ -198,26 +179,20 @@ cameraManager.getCameras().then((cameraArray) => { }) ``` -### createCameraInput(cameraId: string, callback: AsyncCallback): void; - -**系统能力:** +### createCameraInput -SystemCapability.Multimedia.Camera.Core +createCameraInput(cameraId: string, callback: AsyncCallback): void -**说明:** +使用相机ID异步创建CameraInput实例,通过注册回调函数获取结果。 -使用相机ID创建 **相机输入** 实例,使用callback方式获取一个异步的实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 默认值 | 必填 | 说明 | |----------|------------------------------|-----------|--------------------------------------------------| -| cameraId | string | Yes | 使用 相机ID 来创建一个实例 | -| callback | AsyncCallback | Yes | 使用Callback方式来获取一个 CameraInput 实例 | - -**返回值:** - -none +| cameraId | string | 是 | 指定相机ID。 | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 | **示例:** @@ -231,27 +206,25 @@ cameraManager.createCameraInput(cameraId, (err, cameraInput) => { }) ``` -### createCameraInput(cameraId: string): Promise; - -**系统能力:** +### createCameraInput -SystemCapability.Multimedia.Camera.Core +createCameraInput(cameraId: string): Promise -**说明:** +使用相机ID异步创建CameraInput实例,通过Promise获取结果。 -使用相机ID创建 **相机输入** 实例,使用promise方式获取一个实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 默认值 | 必填 | 说明 | |----------|-----------------------------|-----------|------------------------------------------| -| cameraId | string | Yes | 使用 相机ID 来创建一个实例 | +| cameraId | string | 是 | 指定相机ID。 | **返回值:** | 类型 | 说明 | |-------------------------|-------------------------------------------------| -| Promise | 使用Promise的方式获取一个 CameraInput 的实例 | +| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | **示例:** @@ -261,29 +234,23 @@ cameraManager.createCameraInput(cameraId).then((cameraInput) => { }) ``` -### createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void; +### createCameraInput -**系统能力:** +createCameraInput(position: CameraPosition, type: CameraType, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +使用相机位置和相机类型异步创建CameraInput实例,通过注册回调函数获取结果。 -**说明:** - -使用相机位置和相机类型创建 **相机输入** 实例, 使用callback方式获取一个异步的实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------------|----------------------------|-----------|---------------------------------------------------| -| cameraPosition | CameraPosition | Yes | 相机位置 | -| cameraType | CameraType | Yes | 相机类型 | -| callback | AsyncCallback | Yes | 使用callback方式获取一个异步的实例 | - -**返回值:** - -none +| cameraPosition | [CameraPosition](#cameraposition) | 是 | 相机位置。 | +| cameraType | [CameraType](#cameratype) | 是 | 相机类型。 | +| callback | AsyncCallback<[CameraInput](#camerainput)\> | 是 | 回调函数,用于获取CameraInput实例。 | -**实例:** +**示例:** ``` cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) => { @@ -295,28 +262,26 @@ cameraManager.createCameraInput(cameraPosition, cameraType, (err, cameraInput) = }) ``` -### createCameraInput(position: CameraPosition, type: CameraType): Promise; +### createCameraInput -**系统能力:** +createCameraInput(position: CameraPosition, type: CameraType): Promise -SystemCapability.Multimedia.Camera.Core +使用相机位置和相机类型异步创建CameraInput实例,通过Promise获取结果。 -**说明:** - -使用相机位置和相机类型创建 **相机输入** 实例, 使用promise的方式获取一个实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------------|----------------------------|-----------|----------------------------------------| -| cameraPosition | CameraPosition | Yes | 相机位置 | -| cameraType | CameraType | Yes | 相机类型 | +| cameraPosition | [CameraPosition](#cameraposition) | 是 | 相机位置。 | +| cameraType | [CameraType](#cameratype) | 是 | 相机类型。 | **返回值:** | 类型 | 说明 | |-------------------------|-------------------------------------------------| -| Promise | 使用promise的方式获取一个**相机输入**实例 | +| Promise<[CameraInput](#camerainput)\> | 使用Promise的方式获取CameraInput的实例。 | **示例:** @@ -326,26 +291,20 @@ cameraManager.createCameraInput(cameraPosition, cameraType).then((cameraInput) = }) ``` -### on(type: 'cameraStatus', callback: Callback): void; - -**系统能力:** +### on('cameraStatus') -SystemCapability.Multimedia.Camera.Core +on(type: 'cameraStatus', callback: AsyncCallback): void -**说明:** +监听相机的状态变化,通过注册回调函数获取相机的状态变化。 -监听相机的状态变化,使用callback的方式获取相机的状态变化 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :--------------------------------------------------- | -| type | string | Yes | 监听项的名称 | -| callback | Callback | Yes | 使用callback的方式获取相机状态变化 | - -**返回值:** - -None +| type | string | 是 | 监听事件。 | +| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | 是 | 回调函数,用于获取相机状态变化信息。 | **示例:** @@ -356,18 +315,18 @@ cameraManager.on('cameraStatus', (cameraStatusInfo) => { }) ``` -## Camera - -**相机**类。 +## Camera -**字段:** +相机实例。 -| 名称 | 类型 | 访问权限 | 说明 | +| 名称 | 类型 | 只读 | 说明 | |----------------|----------------|----------|------------------------| -| cameraId | string | readonly | 相机ID
系统能力 : SystemCapability.Multimedia.Camera.Core | -| cameraPosition | cameraPosition | readonly | 相机位置
系统能力 : SystemCapability.Multimedia.Camera.Core | -| cameraType | cameraType | readonly | 相机类型
系统能力 : SystemCapability.Multimedia.Camera.Core | -| connectionType | connectionType | readonly | 相机连接类型
系统能力 : SystemCapability.Multimedia.Camera.Core | +| cameraId | string | 是 | 相机ID。
**系统能力:** SystemCapability.Multimedia.Camera.Core| +| cameraPosition | [CameraPosition](#cameraposition) | 是 | 相机位置。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| cameraType | [CameraType](#cameratype) | 是 | 相机类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| connectionType | [ConnectionType](#connectiontype) | 是 | 相机连接类型。
**系统能力:** SystemCapability.Multimedia.Camera.Core | + +**示例:** ``` var cameraManager = await camera.getCameraManager(); @@ -380,41 +339,35 @@ var cameraId = cameraObj.connectionType; ``` -## CameraStatusInfo - -**相机状态信息**类。 +## CameraStatusInfo -**字段:** +相机状态信息。 | 名称 | 类型 | 说明 | |----------------|----------------|------------------| -| camera | Camera | 相机类
系统能力 : SystemCapability.Multimedia.Camera.Core | -| status | CameraStatus | 相机状态
系统能力 : SystemCapability.Multimedia.Camera.Core | +| camera | [Camera](#camera) | 相机信息。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| status | [CameraStatus](#camerastatus) | 相机状态。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## CameraInput +## CameraInput -**相机输入** 类。 +相机输入类。在使用该类的方法前,需要先构建一个CameraInput实例。 -### getCameraId(callback: AsyncCallback\): void; +### getCameraId -**系统能力:** +getCameraId(callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +异步获取该CameraInput实例的相机ID,通过注册回调函数获取结果。 -**说明:** - -获取该**相机输入** 实例的相机ID, 使用callback的方式获取一个异步的实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|------------------------|-----------|---------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取 相机ID | - -**返回值:** +| callback | AsyncCallback | 是 | 回调函数,用于获取相机ID。 | -none +**示例:** ``` cameraInput.getCameraId((err, cameraId) => { @@ -426,25 +379,19 @@ cameraInput.getCameraId((err, cameraId) => { }) ``` -### getCameraId(): Promise; - -**系统能力:** +### getCameraId -SystemCapability.Multimedia.Camera.Core +getCameraId(): Promise -**说明:** +异步获取该CameraInput实例的相机ID,通过Promise获取结果。 -获取该**相机输入** 实例的相机ID, 使用promise的方式获取相机ID。 - -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |------------------------|--------------------------------------| -| Promise | 使用promise的方式获取相机ID | +| Promise | 使用Promise的方式获取相机ID。 | **示例:** @@ -454,27 +401,20 @@ cameraInput.getCameraId().then((cameraId) => { }) ``` -### getSupportedSizes\(format: CameraFormat, callback: AsyncCallback\>\): void; - -**系统能力:** +### getSupportedSizes -SystemCapability.Multimedia.Camera.Core +getSupportedSizes\(format: CameraFormat, callback: AsyncCallback\>\): void -**说明:** +根据指定格式,获取相机支持的分辨率,通过注册回调函数获取结果。 -根据格式查询相机支持的分辨率,使用callback的方式获取一个异步的支持分辨率。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|------------------------------|-----------|---------------------------------------------| -| format | CameraFormat | Yes | 使用CameraFormat来获取支持分辨率 | -| callback | AsyncCallback\> | Yes | 使用callback的方式来获取支持分辨率 | - - -**返回值:** - -none +| format | [CameraFormat](#cameraformat) | 是 | 指定照片格式。 | +| callback | AsyncCallback\> | 是 | 回调函数,用于获取相机支持分辨率。 | **示例:** @@ -488,27 +428,25 @@ cameraInput.getSupportedSizes(format, (err, sizes) => { }) ``` -### getSupportedSizes\(format: CameraFormat\): Promise\>; - -**系统能力:** +### getSupportedSizes -SystemCapability.Multimedia.Camera.Core +getSupportedSizes\(format: CameraFormat\): Promise\> -**说明:** +根据指定格式,获取相机支持的分辨率,通过Promise获取结果。 -获取CameraFormat的支持分辨率,使用promise的方式获取支持分辨率。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -|----------|----------------------------|-----------|-----------------------------------------------| -| format | CameraFormat | Yes | 使用Camera format 获取支持分辨率 | +| 名称 | 类型 | 必填 | 说明 | +| ------ | ----------------------------- | ---- | -------------- | +| format | [CameraFormat](#cameraformat) | 是 | 指定照片格式。 | **返回值:** | 类型 | 说明 | |------------------------|---------------------------------------------| -| Promise\> | 使用promise的方式获取支持分辨率. | +| Promise\> | 使用Promise的方式获取相机支持的分辨率。 | **示例:** @@ -518,26 +456,19 @@ cameraInput.getSupportedSizes(format).then((sizes) => { }) ``` -### getSupportedPreviewFormats\(callback: AsyncCallback\>\): void; +### getSupportedPreviewFormats -**系统能力:** +getSupportedPreviewFormats\(callback: AsyncCallback\>\): void -SystemCapability.Multimedia.Camera.Core +获取相机预览图片的支持格式,通过注册回调函数获取结果。 -**说明:** - -获取预览的支持格式,使用callback的方式获取一个异步的支持格式. +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -|----------|--------------------------------------|-----------|---------------------------------------------------| -| callback | AsyncCallback\> | Yes | 使用callback的方式获取支持的预览格式. | - - -**返回值:** - -none +| 名称 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\> | 是 | 回调函数,用于获取预览图片的支持格式。 | **示例:** @@ -551,26 +482,19 @@ cameraInput.getSupportedPreviewFormats((err, previewFormats) => { }) ``` +### getSupportedPreviewFormats -### getSupportedPreviewFormats\(\): Promise\>; - -**系统能力:** +getSupportedPreviewFormats\(\): Promise\> -SystemCapability.Multimedia.Camera.Core +获取相机预览图片的支持格式,通过注册回调函数获取结果。 -**说明:** - -获取预览的 supported formats,使用promise的方式获取supported formats. - -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |--------------------------------|-------------------------------------------------------| -| Promise\> | 使用promise的方式获取supported preview formats | +| Promise\> | 使用Promise的方式获取预览图片的支持格式。 | **示例:** @@ -580,25 +504,19 @@ cameraInput.getSupportedPreviewFormats().then((previewFormats) => { }) ``` -### getSupportedPhotoFormats\(callback: AsyncCallback\>\): void; - -**系统能力:** +### getSupportedPhotoFormats -SystemCapability.Multimedia.Camera.Core +getSupportedPhotoFormats\(callback: AsyncCallback\>\): void -**说明:** +获取照片的支持格式,通过注册回调函数获取结果。 -获取 photographing的supported formats,使用callback的方式获取一个异步的supported formats. +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|--------------------------------------|-----------|-------------------------------------------------| -| callback | AsyncCallback\> | Yes | 使用callback的方式获取支持的照片格式 | - -**返回值:** - -none +| callback | AsyncCallback\> | 是 | 回调函数,用于获取支持的照片格式。 | **示例:** @@ -612,25 +530,19 @@ cameraInput.getSupportedPhotoFormats((err, photoFormats) => { }) ``` -### getSupportedPhotoFormats\(\): Promise\>; - -**系统能力:** +### getSupportedPhotoFormats -SystemCapability.Multimedia.Camera.Core +getSupportedPhotoFormats\(\): Promise\> -**说明:** +获取照片的支持格式,通过Promise获取结果。 -获取 photographing的supported formats,使用promise的方式获取supported formats. - -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |--------------------------------|---------------------------------------------------| -| Promise\> | 使用promise的方式获取支持的照片格式 | +| Promise\> | 使用Promise的方式获取支持的照片格式。 | **示例:** @@ -640,25 +552,19 @@ cameraInput.getSupportedPhotoFormats().then((photoFormats) => { }) ``` -### getSupportedVideoFormats\(callback: AsyncCallback\>\): void; +### getSupportedVideoFormats -**系统能力:** +getSupportedVideoFormats\(callback: AsyncCallback\>\): void -SystemCapability.Multimedia.Camera.Core +获取录制视频的支持格式,通过注册回调函数获取结果。 -**说明:** - -获取录制视频的supported formats,使用callback的方式获取一个异步的支持的录像格式。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|--------------------------------------|-----------|-------------------------------------------------| -| callback | AsyncCallback\> | Yes | 使用callback的方式获取支持的录像格式 | - -**返回值:** - -none +| callback | AsyncCallback\> | 是 | 回调函数,用于获取支持的视频格式。 | **示例:** @@ -672,25 +578,19 @@ cameraInput.getSupportedVideoFormats((err, videoFormats) => { }) ``` -### getSupportedVideoFormats\(\): Promise\>; - -**系统能力:** +### getSupportedVideoFormats -SystemCapability.Multimedia.Camera.Core +getSupportedVideoFormats\(\): Promise\> -**说明:** - -获取录制视频的supported formats,使用promise的方式获取支持的录像格式。 - -**参数:** +获取录制视频的支持格式,通过Promise获取结果。 -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |--------------------------------|---------------------------------------------------| -| Promise\> | 使用promise的方式获取支持的录像格式 | +| Promise\> | 使用Promise的方式获取支持的视频格式。 | **示例:** @@ -700,25 +600,19 @@ cameraInput.getSupportedVideoFormats().then((videoFormats) => { }) ``` -### hasFlash(callback: AsyncCallback): void; +### hasFlash -**系统能力:** +hasFlash(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +判断设备是否支持闪光灯,通过注册回调函数获取结果。 -**说明:** - -检查设备是否支持闪光灯,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|-------------------------|-----------|----------------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取支持闪光灯的状态 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,返回true表示设备支持闪光灯。 | **示例:** @@ -732,25 +626,19 @@ cameraInput.hasFlash((err, status) => { }) ``` -### hasFlash(): Promise; - -**系统能力:** +### hasFlash -SystemCapability.Multimedia.Camera.Core +hasFlash(): Promise -**说明:** +判断设备是否支持闪光灯,通过Promise获取结果。 -检查设备是否支持闪光灯,使用promise的方式获取结果。 - -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |-----------------------|--------------------------------------------------------| -| Promise | 使用promise的方式获取支持闪光灯的状态。 | +| Promise | 使用Promise的方式获取结果,返回true表示设备支持闪光灯。 | **示例:** @@ -760,26 +648,20 @@ cameraInput.hasFlash().then((status) => { }) ``` -### isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void; - -**系统能力:** +### isFlashModeSupported -SystemCapability.Multimedia.Camera.Core +isFlashModeSupported(flashMode: FlashMode, callback: AsyncCallback): void -**说明:** +判断设备是否支持指定闪光灯模式,通过注册回调函数获取结果。 -检查设备是否支持闪光灯模式,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | 闪光灯模式 | -| callback | AsyncCallback | Yes | 使用callback的方式获取设备支持闪光灯模式 | - -**返回值:** - -none +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | +| callback | AsyncCallback | 是 | 回调函数,返回true表示支持该闪光灯模式。 | **示例:** @@ -793,27 +675,25 @@ cameraInput.isFlashModeSupported(flashMode, (err, status) => { }) ``` -### isFlashModeSupported(flashMode: FlashMode): Promise; +### isFlashModeSupported -**系统能力:** +isFlashModeSupported(flashMode: FlashMode): Promise -SystemCapability.Multimedia.Camera.Core +判断设备是否支持指定闪光灯模式,通过Promise获取结果。 -**说明:** - -检查设备是否支持闪光灯模式,使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | 闪光灯模式 | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | **返回值:** | 类型 | 说明 | |-----------------------|---------------------------------------------------| -| Promise | 使用promise的方式获取支持的闪光灯模式 | +| Promise | 使用Promise的方式获取结果,返回true表示设备支持该闪光灯模式。 | **示例:** @@ -823,28 +703,25 @@ cameraInput.isFlashModeSupported(flashMode).then((status) => { }) ``` -### setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void; +### setFlashMode -**系统能力:** +setFlashMode(flashMode: FlashMode, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +设置闪光灯模式,通过注册回调函数获取结果。 -**说明:** +进行设置之前,需要先检查: -设置闪光灯模式,使用callback的方式获取一个异步的结果。 +1. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash)。 +2. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported)。 -说明: 设置闪光灯模式之前, 检查支持的闪光灯 (hasFlash method) 以及支持的闪光灯模式 (isFlashModeSupported method); +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | 闪光灯模式 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -858,29 +735,30 @@ cameraInput.setFlashMode(flashMode, (err) => { }) ``` -### setFlashMode(flashMode: FlashMode): Promise; +### setFlashMode -**系统能力:** +setFlashMode(flashMode: FlashMode): Promise -SystemCapability.Multimedia.Camera.Core +设置闪光灯模式,通过Promise获取结果。 -**说明:** +进行设置之前,需要先检查: -设置闪光灯模式,使用promise的方式获取结果。 +1. 设备是否支持闪光灯,可使用方法[hasFlash](#hasflash)。 +2. 设备是否支持指定的闪光灯模式,可使用方法[isFlashModeSupported](#isflashmodesupported)。 -说明: 设置闪光灯模式之前, 检查支持的闪光灯 (hasFlash method) 以及支持的闪光灯模式 (isFlashModeSupported method); +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|----------------------------------------------------| -| flashMode | FlashMode | Yes | 闪光灯模式 | +| flashMode | [FlashMode](#flashmode) | 是 | 指定闪光灯模式。 | **返回值:** | 类型 | 说明 | |-----------------------|-----------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -890,25 +768,19 @@ cameraInput.setFlashMode(flashMode).then() => { }) ``` -### getFlashMode(callback: AsyncCallback): void; - -**系统能力:** +### getFlashMode -SystemCapability.Multimedia.Camera.Core +getFlashMode(callback: AsyncCallback): void -**说明:** +获取当前设备的闪光灯模式,通过注册回调函数获取结果。 -获取当前闪光灯模式,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|---------------------------|-----------|------------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取当前闪光灯模式 | - -**返回值:** - -none +| callback | AsyncCallback<[FlashMode](#flashmode)\> | 是 | 回调函数,用于获取当前设备的闪光灯模式。 | **示例:** @@ -922,25 +794,19 @@ cameraInput.getFlashMode((err, flashMode) => { }) ``` -### getFlashMode(): Promise; - -**系统能力:** - -SystemCapability.Multimedia.Camera.Core - -**说明:** +### getFlashMode -获取当前闪光灯模式,使用promise的方式获取结果。 +getFlashMode(): Promise -**参数:** +获取当前设备的闪光灯模式,通过Promise获取结果。 -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |-----------------------|---------------------------------------------------| -| Promise | 使用promise的方式获取当前闪光灯模式 | +| Promise<[FlashMode](#flashmode)\> | 使用Promise的方式获取当前的闪光灯模式。 | **示例:** @@ -950,26 +816,20 @@ cameraInput.getFlashMode().then(flashMode) => { }) ``` -### isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void; - -**系统能力:** +### isFocusModeSupported -SystemCapability.Multimedia.Camera.Core +isFocusModeSupported(afMode: FocusMode, callback: AsyncCallback): void -**说明:** +判断设备是否支持指定的焦距模式,通过注册回调函数获取结果。 -检查支持的焦距模式,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|----------------------------------------------------| -| afMode | FocusMode | Yes | 焦距模式 | -| callback | AsyncCallback | Yes | 使用callback的方式获取设备支持的焦距模式 | - -**返回值:** - -none +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | +| callback | AsyncCallback | 是 | 回调函数,返回true表示支持该焦距模式。 | **示例:** @@ -983,27 +843,25 @@ cameraInput.isFocusModeSupported(afMode, (err, status) => { }) ``` -### isFocusModeSupported(afMode: FocusMode): Promise; - -**系统能力:** +### isFocusModeSupported -SystemCapability.Multimedia.Camera.Core +isFocusModeSupported(afMode: FocusMode): Promise -**说明:** +判断设备是否支持指定的焦距模式,通过Promise获取结果。 -检查支持的焦距模式,使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|----------------------------------------|-----------|-------------| -| afMode | FocusMode | Yes | 焦距模式 | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | **返回值:** | 类型 | 说明 | |-----------------------|---------------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果,返回true表示设备支持该焦距模式。 | **示例:** @@ -1013,28 +871,22 @@ cameraInput.isFocusModeSupported(afMode).then((status) => { }) ``` -### setFocusMode(afMode: FocusMode, callback: AsyncCallback): void; +### setFocusMode -**系统能力:** +setFocusMode(afMode: FocusMode, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +设置焦距模式,通过注册回调函数获取结果。 -**说明:** +进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)。 -设置焦距模式,使用callback的方式获取一个异步的结果。 - -说明:使用设置焦距模式之前,检查设备支持的焦距模式 (isFocusModeSupported method); +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|------------------------------------| -| afMode | FocusMode | Yes | 焦距模式 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1048,29 +900,27 @@ cameraInput.setFocusMode(afMode, (err) => { }) ``` -### setFocusMode(afMode: FocusMode): Promise; - -**系统能力:** +### setFocusMode -SystemCapability.Multimedia.Camera.Core +setFocusMode(afMode: FocusMode): Promise -**说明:** +设置焦距模式,通过Promise获取结果。 -设置焦距模式,使用promise的方式获取结果。 +进行设置之前,需要先检查设备是否支持指定的焦距模式,可使用方法[isFocusModeSupported](#isfocusmodesupported)。 -说明:使用设置焦距模式之前,检查设备支持的焦距模式 (isFocusModeSupported method); +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|-----------------------------------------|-----------|-------------| -| afMode | FocusMode | Yes | 焦距模式 | +| afMode | [FocusMode](#focusmode) | 是 | 指定的焦距模式。 | **返回值:** | 类型 | 说明 | |-----------------------|-----------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -1080,25 +930,19 @@ cameraInput.setFocusMode(afMode).then() => { }) ``` -### getFocusMode(callback: AsyncCallback): void; - -**系统能力:** +### getFocusMode -SystemCapability.Multimedia.Camera.Core +getFocusMode(callback: AsyncCallback): void -**说明:** +获取当前设备的焦距模式,通过注册回调函数获取结果。 -获取当前的焦距模式,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|---------------------------|-----------|------------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback<[FocusMode](#focusmode)\> | 是 | 回调函数,用于获取当前设备的焦距模式。 | **示例:** @@ -1112,25 +956,19 @@ cameraInput.getFocusMode((err, afMode) => { }) ``` -### getFocusMode(): Promise; - -**系统能力:** - -SystemCapability.Multimedia.Camera.Core +### getFocusMode -**说明:** +getFocusMode(): Promise -获取当前的焦距模式,使用promise的方式获取结果。 +获取当前设备的焦距模式,通过Promise获取结果。 -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -|-----------------------|---------------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| 类型 | 说明 | +| ------------------- | ------------------------------------- | +| Promise | 使用Promise的方式获取当前的焦距模式。 | **示例:** @@ -1140,26 +978,19 @@ cameraInput.getFocusMode().then(afMode) => { }) ``` -### getZoomRatioRange\(callback: AsyncCallback\>\): void; +### getZoomRatioRange -**系统能力:** +getZoomRatioRange\(callback: AsyncCallback\>\): void -SystemCapability.Multimedia.Camera.Core +获取可变焦距比范围,通过注册回调函数获取结果。 -**说明:** - -获取变焦比率的范围,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|--------------------------------|-----------|-------------------------------------------------| -| callback | AsyncCallback\> | Yes | 使用callback的方式获取变焦比率的范围 | - - -**返回值:** - -none +| callback | AsyncCallback\> | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1173,25 +1004,19 @@ cameraInput.getZoomRatioRange(err, zoomRatioRange) => { }) ``` -### getZoomRatioRange\(\): Promise\>; - -**系统能力:** +### getZoomRatioRange -SystemCapability.Multimedia.Camera.Core +getZoomRatioRange\(\): Promise\> -**说明:** - -获取变焦比率的范围,使用promise的方式获取结果。 - -**参数:** +获取可变焦距比范围,通过Promise获取结果。 -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |------------------------|---------------------------------------------| -| Promise\> | 使用promise的方式获取变焦比率的范围 | +| Promise\> | 使用Promise的方式获取当前的可变焦距比范围。 | **示例:** @@ -1201,26 +1026,20 @@ cameraInput.getZoomRatioRange().then((zoomRatioRange) => { }) ``` -### setZoomRatio(zoomRatio: number, callback: AsyncCallback): void; +### setZoomRatio -**系统能力:** +setZoomRatio(zoomRatio: number, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +设置可变焦距比,通过注册回调函数获取结果。 -**说明:** - -设置变焦比率,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|------------------------|-----------|------------------------------------| -| zoomRatio | number | Yes | 变焦比率 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| zoomRatio | number | 是 | 可变焦距比。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1234,27 +1053,25 @@ cameraInput.setZoomRatio(zoomRatio, (err) => { }) ``` -### setZoomRatio(zoomRatio: number): Promise; - -**系统能力:** +### setZoomRatio -SystemCapability.Multimedia.Camera.Core +setZoomRatio(zoomRatio: number): Promise -**说明:** +设置可变焦距比,通过Promise获取结果。 -设置变焦比率,使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|----------|-----------|-------------| -| zoomRatio | number | Yes | 变焦比率 | +| zoomRatio | number | 是 | 可变焦距比。 | **返回值:** | 类型 | 说明 | |-----------------------|-----------------------------------------| -| Promise | Promise used to return the result | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -1264,25 +1081,19 @@ cameraInput.setZoomRatio(zoomRatio).then() => { }) ``` -### getZoomRatio(callback: AsyncCallback): void; - -**系统能力:** +### getZoomRatio -SystemCapability.Multimedia.Camera.Core +getZoomRatio(callback: AsyncCallback): void -**说明:** +获取当前的可变焦距比,通过注册回调函数获取结果。 -获取当前的变焦比率,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-----------|---------------------------|-----------|------------------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1296,25 +1107,19 @@ cameraInput.getZoomRatio((err, zoomRatio) => { }) ``` -### getZoomRatio(): Promise; +### getZoomRatio -**系统能力:** +getZoomRatio(): Promise -SystemCapability.Multimedia.Camera.Core +获取当前的可变焦距比,通过Promise获取结果。 -**说明:** - -Gets current zoom ratio value. This method uses a promise to return the result. - -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** -| 类型 | 说明 | -|-----------------------|---------------------------------------------------| -| Promise | Promise used to return the zoom ratio vaule | +| 类型 | 说明 | +| ---------------- | --------------------------- | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -1324,25 +1129,19 @@ cameraInput.getZoomRatio().then(zoomRatio) => { }) ``` -### release\(callback: AsyncCallback\): void; +### release -**系统能力:** +release\(callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +释放相机实例,通过注册回调函数获取结果。 -**说明:** - -释放这个 **相机输入** 实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | 使用异步的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1356,25 +1155,19 @@ camera.release((err) => { }); ``` -### release(): Promise; - -**系统能力:** - -SystemCapability.Multimedia.Camera.Core +### release -**说明:** +release(): Promise -释放这个 **相机输入** 实例,使用promise的方式获取结果。 +释放相机实例,通过Promise获取结果。 -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -1384,26 +1177,20 @@ cameraInput.release().then(() => { }) ``` -### on(type: 'focusStateChange', callback: Callback): void; - -**系统能力:** +### on('focusStateChange') -SystemCapability.Multimedia.Camera.Core +on(type: 'focusStateChange', callback: AsyncCallback): void -**说明:** +监听焦距的状态变化,通过注册回调函数获取结果。 -监听焦距的状态变化,使用callback的方式获取焦距的状态变化。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | 监听项的名称 | -| callback | Callback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'focusStateChange',即焦距状态变化事件。 | +| callback | AsyncCallback<[FocusState](#focusstate)\> | 是 | 回调函数,用于获取焦距状态。 | **示例:** @@ -1413,26 +1200,20 @@ cameraInput.on('focusStateChange', (focusState) => { }) ``` -### on(type: 'error', callback: Callback): void; +### on('error') -**系统能力:** +on('error', callback: ErrorCallback): void -SystemCapability.Multimedia.Camera.Core +监听CameraInput的错误事件,通过注册回调函数获取结果。 -**说明:** - -监听**相机输入**的报错,使用callback的方式获取错误信息。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | 监听项的名称 | -| callback | Callback | Yes | 使用callback的方式获取**相机输入**的错误信息 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'error'。 | +| callback | ErrorCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1443,49 +1224,52 @@ cameraInput.on('error', (cameraInputError) => { ``` -## FlashMode +## FlashMode -枚举闪光灯模式。 +枚举,闪光灯模式。 | 名称 | 默认值 | 说明 | |------------------------|---------------|------------------------| -| FLASH_MODE_CLOSE | 0 | 闪光灯关闭模式
系统能力 : SystemCapability.Multimedia.Camera.Core | -| FLASH_MODE_OPEN | 1 | 闪光灯开启模式
系统能力 : SystemCapability.Multimedia.Camera.Core | -| FLASH_MODE_AUTO | 2 | 闪光灯自动模式
系统能力 : SystemCapability.Multimedia.Camera.Core | -| FLASH_MODE_ALWAYS_OPEN | 3 | 闪光灯常亮模式
系统能力 : SystemCapability.Multimedia.Camera.Core | +| FLASH_MODE_CLOSE | 0 | 闪光灯关闭。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FLASH_MODE_OPEN | 1 | 闪光灯开启。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FLASH_MODE_AUTO | 2 | 自动闪光灯。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FLASH_MODE_ALWAYS_OPEN | 3 | 闪光灯常亮。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## FocusMode +## FocusMode -枚举焦距模式。 +枚举,焦距模式。 | 名称 | 默认值 | 说明 | |----------------------------|---------------|----------------------------| -| FOCUS_MODE_MANUAL | 0 | 手动变焦模式
系统能力 : SystemCapability.Multimedia.Camera.Core | -| FOCUS_MODE_CONTINUOUS_AUTO | 1 | 连续自动变焦模式
系统能力 : SystemCapability.Multimedia.Camera.Core | -| FOCUS_MODE_AUTO | 2 | 自动变焦模式
系统能力 : SystemCapability.Multimedia.Camera.Core | -| FOCUS_MODE_LOCKED | 3 | 焦距锁定模式
系统能力 : SystemCapability.Multimedia.Camera.Core | +| FOCUS_MODE_MANUAL | 0 | 手动变焦模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FOCUS_MODE_CONTINUOUS_AUTO | 1 | 连续自动变焦模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FOCUS_MODE_AUTO | 2 | 自动变焦模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| FOCUS_MODE_LOCKED | 3 | 定焦模式。
**系统能力:** SystemCapability.Multimedia.Camera.Core | + +## FocusState +枚举,焦距状态。 -## createCaptureSession\(context: Context, callback: AsyncCallback\): void; +| 名称 | 默认值 | 说明 | +| --------------------- | ------ | ------------------------------------------------------------ | +| FOCUS_STATE_SCAN | 0 | 扫描状态。
系统能力 : SystemCapability.Multimedia.Camera.Core | +| FOCUS_STATE_FOCUSED | 1 | 相机已对焦。
系统能力 : SystemCapability.Multimedia.Camera.Core | +| FOCUS_STATE_UNFOCUSED | 2 | 相机未对焦。
系统能力 : SystemCapability.Multimedia.Camera.Core | -**系统能力:** +## camera.createCaptureSession -SystemCapability.Multimedia.Camera.Core +createCaptureSession\(context: Context, callback: AsyncCallback\): void -**说明:** +获取CaptureSession实例,通过注册回调函数获取结果。 -创建 **拍照会话** 实例,使用callback的方式获取一个异步的实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|--------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | 应用环境 | -| callback | AsyncCallback | Yes | 使用callback的方式获取 **拍照会话** 实例 | - -**返回值:** - -none +| context | Context | 是 | 应用上下文。 | +| callback | AsyncCallback<[CaptureSession](#capturesession)\> | 是 | 回调函数,用于获取CaptureSession实例。 | **示例:** @@ -1499,27 +1283,25 @@ camera.createCaptureSession(context), (err, captureSession) => { }); ``` -## createCaptureSession(context: Context\): Promise; +## camera.createCaptureSession -**系统能力:** +createCaptureSession(context: Context\): Promise; -SystemCapability.Multimedia.Camera.Core +获取CaptureSession实例,通过Promise获取结果。 -**说明:** - -创建 **拍照会话** 实例,使用promise方式获取一个实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|-------------------------------|-----------|-----------------------------------------------------| -| context | Context | Yes | 应用环境 | +| context | Context | 是 | 应用上下文。 | **返回值:** | 类型 | 说明 | |---------------------------|---------------------------------------------------| -| Promise | 使用promise的方式获取**拍照会话**的实例 | +| Promise<[CaptureSession](#capturesession)\> | 使用Promise的方式获取CaptureSession实例。 | **示例:** @@ -1529,30 +1311,23 @@ camera.createCaptureSession(context).then((captureSession) => { }) ``` -## CaptureSession - -**拍照会话**类。 +## CaptureSession -### beginConfig\(callback: AsyncCallback\): void; +拍照会话类。 -**系统能力:** +### beginConfig -SystemCapability.Multimedia.Camera.Core +beginConfig\(callback: AsyncCallback\): void -**说明:** +开始配置会话,通过注册回调函数获取结果。 -设置此**拍照会话**实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1566,25 +1341,19 @@ captureSession.beginConfig((err) => { }); ``` -### beginConfig\(\): Promise; +### beginConfig -**系统能力:** +beginConfig\(\): Promise -SystemCapability.Multimedia.Camera.Core +开始配置会话,通过Promise获取结果。 -**说明:** - -设置此**拍照会话**实例,使用promise的方式获取结果。 - -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |---------------|---------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -1595,25 +1364,19 @@ captureSession.beginConfig().then(() => { }) ``` -### commitConfig\(callback: AsyncCallback\): void; - -**系统能力:** +### commitConfig -SystemCapability.Multimedia.Camera.Core +commitConfig\(callback: AsyncCallback\): void -**说明:** +提交会话配置,通过注册回调函数获取结果。 -提交此**拍照会话**实例的设置,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|---------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取一个异步的结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1627,26 +1390,19 @@ captureSession.commitConfig((err) => { }); ``` +### commitConfig -### commitConfig\(\): Promise; +commitConfig\(\): Promise -**系统能力:** +提交会话配置,通过Promise获取结果。 -SystemCapability.Multimedia.Camera.Core - -**说明:** - -提交此**拍照会话**实例的设置,使用promise的方式获取结果。 - -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |---------------|---------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -1656,27 +1412,20 @@ captureSession.commitConfig().then(() => { }) ``` -### addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; - -**系统能力:** +### addInput -SystemCapability.Multimedia.Camera.Core +addInput\(cameraInput: CameraInput, callback: AsyncCallback\): void -**说明:** +在当前会话中,添加一个CameraInput实例,通过注册回调函数获取结果。 -为此**拍照会话**实例添加一个**相机输入**,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-------------|----------------------|-----------|---------------------------------------------| -| cameraInput | CameraInput | Yes | 需要添加的**相机输入**实例 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - - -**返回值:** - -none +| cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1690,27 +1439,25 @@ captureSession.addInput(cameraInput, (err) => { }); ``` -### addInput\(cameraInput: CameraInput\): Promise; - -**系统能力:** +### addInput -SystemCapability.Multimedia.Camera.Core +addInput\(cameraInput: CameraInput\): Promise -**说明:** +在当前会话中,添加一个CameraInput实例,通过Promise获取结果。 -为此**拍照会话**实例添加一个**相机输入**,使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-------------|---------------------|-----------|-------------------------------| -| cameraInput | CameraInput | Yes | 需要添加的**相机输入**实例 | +| cameraInput | [CameraInput](#camerainput) | 是 | 需要添加的CameraInput实例。 | **返回值:** | 类型 | 说明 | |----------------|------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -1720,27 +1467,20 @@ captureSession.addInput(cameraInput).then(() => { }) ``` -### addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; +### addOutput -**系统能力:** +addOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +在当前会话中,添加一个PreviewOutput实例,通过注册回调函数获取结果。 -**说明:** - -为此**拍照会话**实例添加一个**预览输出**实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |---------------|----------------------|-----------|-------------------------------------| -| previewOutput | PreviewOutput | Yes | 需要添加的**预览输出**实例 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - - -**返回值:** - -none +| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的PreviewOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1754,27 +1494,25 @@ captureSession.addOutput(previewOutput, (err) => { }); ``` -### addOutput\(previewOutput: PreviewOutput\): Promise; - -**系统能力:** +### addOutput -SystemCapability.Multimedia.Camera.Core +addOutput\(previewOutput: PreviewOutput\): Promise -**说明:** +在当前会话中,添加一个PreviewOutput实例,通过Promise获取结果。 -为此**拍照会话**实例添加一个**预览输出**实例,使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|--------------------------------| -| previewOutput | PreviewOutput | Yes | 需要添加的**预览输出**实例 | +| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要添加的PreviewOutput实例。 | **返回值:** | 类型 | 说明 | |----------------|-----------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -1784,26 +1522,20 @@ captureSession.addOutput(previewOutput).then(() => { }) ``` -### addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void; +### addOutput -**系统能力:** +addOutput\(photoOutput: PhotoOutput, callback: AsyncCallback\): void -SystemCapability.Multimedia.Camera.Core +在当前会话中,添加一个PhotoOutput实例,通过注册回调函数获取结果。 -**说明:** - -为此**拍照会话**实例添加一个**照片输出**实例, 使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|-------------------------------------| -| photoOutput | PhotoOutput | Yes | 需要添加的**照片输出**实例 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1817,27 +1549,25 @@ captureSession.addOutput(photoOutput, (err) => { }); ``` -### addOutput\(photoOutput: PhotoOutput\): Promise; - -**系统能力:** +### addOutput -SystemCapability.Multimedia.Camera.Core +addOutput\(photoOutput: PhotoOutput\): Promise -**说明:** +在当前会话中,添加一个PreviewOutput实例,通过Promise获取结果。 -为此**拍照会话**实例添加一个**照片输出**实例,使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|--------------------------------| -| photoOutput | PhotoOutput | Yes | 需要添加的**照片输出**实例 | +| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | **返回值:** | 类型 | 说明 | |---------------|-----------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise\ | 使用Promise的方式获取结果。 | **示例:** @@ -1847,26 +1577,20 @@ captureSession.addOutput(photoOutput).then(() => { }) ``` -### addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void; - -**系统能力:** +### addOutput -SystemCapability.Multimedia.Camera.Core +addOutput\(videoOutput: VideoOutput, callback: AsyncCallback\): void -**说明:** +在当前会话中,添加一个VideoOutput实例,通过注册回调函数获取结果。 -为此**拍照会话**实例添加一个**视频输出**实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|-------------------------------------| -| videoOutput | VideoOutput | Yes | 需要添加的**视频输出**实例 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1880,27 +1604,25 @@ captureSession.addOutput(videoOutput, (err) => { }); ``` -### addOutput\(videoOutput: VideoOutput\): Promise; +### addOutput -**系统能力:** +addOutput\(videoOutput: VideoOutput\): Promise -SystemCapability.Multimedia.Camera.Core +在当前会话中,添加一个VideoOutput实例,通过Promise获取结果。 -**说明:** - -为此**拍照会话**实例添加一个**视频输出**实例, 使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -| 名称 | 类型 | 必填 | 说明 | -|---------------|---------------------|-----------|--------------------------------| -| videoOutput | VideoOutput | Yes | 需要添加的**视频输出**实例 | +| 名称 | 类型 | 必填 | 说明 | +| ----------- | --------------------------- | ---- | --------------------------- | +| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | **返回值:** -| 类型 | 说明 | -|----------------|-----------------------------------| -| Promise | 使用promise的方式获取结果 | +| 类型 | 说明 | +| -------------- | --------------------------- | +| Promise\ | 使用Promise的方式获取结果。 | **示例:** @@ -1910,27 +1632,20 @@ captureSession.addOutput(videoOutput).then(() => { }) ``` -### removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void; - -**系统能力:** +### removeInput -SystemCapability.Multimedia.Camera.Core +removeInput\(cameraInput: CameraInput, callback: AsyncCallback\): void -**说明:** +在当前会话中,移除一个CameraInput实例,通过注册回调函数获取结果。 -为此**拍照会话**实例移除一个**相机输入**实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-------------|----------------------|-----------|------------------------------------| -| cameraInput | CameraInput | Yes | 需要移除的**相机输入**实例 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - - -**返回值:** - -none +| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -1944,27 +1659,25 @@ captureSession.removeInput(cameraInput, (err) => { }); ``` -### removeInput\(cameraInput: CameraInput\): Promise; - -**系统能力:** +### removeInput -SystemCapability.Multimedia.Camera.Core +removeInput\(cameraInput: CameraInput\): Promise -**说明:** +在当前会话中,移除一个CameraInput实例,通过Promise获取结果。 -为此**拍照会话**实例移除一个**相机输入**实例,使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |-------------|---------------------|-----------|---------------------------------| -| cameraInput | CameraInput | Yes | 需要移除的**相机输入**实例 | +| cameraInput | [CameraInput](#camerainput) | 是 | 需要移除的CameraInput实例。 | **返回值:** | 类型 | 说明 | |----------------|-----------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise\ | 使用Promise的方式获取结果。 | **示例:** @@ -1974,26 +1687,20 @@ captureSession.removeInput(cameraInput).then(() => { }) ``` -### removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void; - -**系统能力:** +### removeOutput -SystemCapability.Multimedia.Camera.Core +removeOutput\(previewOutput: PreviewOutput, callback: AsyncCallback\): void -**说明:** +在当前会话中,移除一个PreviewOutput实例,通过注册回调函数获取结果。 -为此**拍照会话**实例移除一个**预览输出**实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |---------------|----------------------|-----------|------------------------------------| -| previewOutput | PreviewOutput | Yes | 需要移除的**预览输出**实例 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的PreviewOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2007,28 +1714,26 @@ captureSession.removeOutput(previewOutput, (err) => { }); ``` -### removeOutput(previewOutput: PreviewOutput): Promise; +### removeOutput -**系统能力:** +removeOutput(previewOutput: PreviewOutput): Promise -SystemCapability.Multimedia.Camera.Core +在当前会话中,移除一个PreviewOutput实例,通过Promise获取结果。 -**说明:** - -为此**拍照会话**实例移除一个**预览输出**实例,使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|-----------------------------------| -| previewOutput | PreviewOutput | Yes | 需要移除的**预览输出**实例 | +| previewOutput | [PreviewOutput](#previewoutput) | 是 | 需要移除的PreviewOutput实例。 | **返回值:** | 类型 | 说明 | |---------------|---------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -2039,26 +1744,20 @@ captureSession.removeOutput(previewOutput).then(() => { }) ``` -### removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void; - -**系统能力:** +### removeOutput -SystemCapability.Multimedia.Camera.Core +removeOutput(photoOutput: PhotoOutput, callback: AsyncCallback): void -**说明:** +在当前会话中,移除一个PhotoOutput实例,通过注册回调函数获取结果。 -为此**拍照会话**实例移除一个**照片输出**实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |---------------|----------------------|-----------|------------------------------------| -| photoOutput | PhotoOutput | Yes | 需要移除的**照片输出**实例 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2072,28 +1771,26 @@ captureSession.removeOutput(photoOutput, (err) => { }); ``` -### removeOutput(photoOutput: PhotoOutput): Promise; - -**系统能力:** +### removeOutput -SystemCapability.Multimedia.Camera.Core +removeOutput(photoOutput: PhotoOutput): Promise -**说明:** +在当前会话中,移除一个PhotoOutput实例,通过Promise获取结果。 -为此**拍照会话**实例移除一个**照片输出**实例,使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|---------------------------------| -| photoOutput | PhotoOutput | Yes | 需要移除的**照片输出**实例 | +| photoOutput | [PhotoOutput](#photooutput) | 是 | 需要添加的PhotoOutput实例。 | **返回值:** | 类型 | 说明 | |---------------|------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -2104,26 +1801,20 @@ captureSession.removeOutput(photoOutput).then(() => { }) ``` -### removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void; +### removeOutput -**系统能力:** +removeOutput(videoOutput: VideoOutput, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +在当前会话中,移除一个VideoOutput实例,通过注册回调函数获取结果。 -**说明:** - -为此**拍照会话**实例移除一个**视频输出**实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |---------------|----------------------|-----------|------------------------------------| -| videoOutput | VideoOutput | Yes | 需要移除的**视频输出**实例 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2137,28 +1828,26 @@ captureSession.removeOutput(videoOutput, (err) => { }); ``` -### removeOutput(videoOutput: VideoOutput): Promise; - -**系统能力:** +### removeOutput -SystemCapability.Multimedia.Camera.Core +removeOutput(videoOutput: VideoOutput): Promise -**说明:** +在当前会话中,移除一个VideoOutput实例,通过Promise获取结果。 -为此**拍照会话**实例移除一个**视频输出**实例,使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |---------------|---------------------|-----------|---------------------------------| -| videoOutput | VideoOutput | Yes | 需要移除的**照片输出**实例 | +| videoOutput | [VideoOutput](#videooutput) | 是 | 需要添加的VideoOutput实例。 | **返回值:** | 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -2169,25 +1858,19 @@ captureSession.removeOutput(videoOutput).then(() => { }) ``` -### start\(callback: AsyncCallback\): void; - -**系统能力:** +### start -SystemCapability.Multimedia.Camera.Core +start\(callback: AsyncCallback\): void -**说明:** +启动拍照会话,通过注册回调函数获取结果。 -开启**拍照会话** 实例, 使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2201,25 +1884,19 @@ captureSession.start((err) => { }); ``` -### start\(\): Promise; - -**系统能力:** - -SystemCapability.Multimedia.Camera.Core +### start -**说明:** +start\(\): Promise -开启**拍照会话** 实例,使用promise的方式获取结果。 +启动拍照会话,通过Promise获取结果。 -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |----------------|-----------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -2229,26 +1906,20 @@ captureSession.start().then(() => { }) ``` -### stop\(callback: AsyncCallback\): void; - -**系统能力:** +### stop -SystemCapability.Multimedia.Camera.Core +stop\(callback: AsyncCallback\): void -**说明:** +停止拍照会话,通过注册回调函数获取结果。 -关闭**拍照会话** 实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2262,26 +1933,19 @@ captureSession.stop((err) => { }); ``` +### stop -### stop(): Promise; +stop(): Promise -**系统能力:** +停止拍照会话,通过Promise获取结果。 -SystemCapability.Multimedia.Camera.Core - -**说明:** - -关闭**拍照会话** 实例,使用promise的方式获取结果。 - -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |----------------|-----------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -2291,25 +1955,19 @@ captureSession.stop().then(() => { }) ``` -### release\(callback: AsyncCallback\): void; - -**系统能力:** +### release -SystemCapability.Multimedia.Camera.Core +release\(callback: AsyncCallback\): void -**说明:** +释放CaptureSession实例,通过注册回调函数获取结果。 -释放**拍照会话**实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -示例里 + | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2323,25 +1981,19 @@ captureSession.release((err) => { }); ``` -### release(): Promise; - -**系统能力:** - -SystemCapability.Multimedia.Camera.Core +### release -**说明:** +release(): Promise -释放**拍照会话**实例,使用promise的方式获取结果。 - -**参数:** +释放CaptureSession实例,通过Promise获取结果。 -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -2351,26 +2003,20 @@ captureSession.release().then(() => { }) ``` -### on(type: 'error', callback: Callback): void; +### on('error') -**系统能力:** +on(type: 'error', callback: ErrorCallback): void -SystemCapability.Multimedia.Camera.Core +监听拍照会话的错误事件,通过注册回调函数获取结果。 -**说明:** - -监听**拍照会话** 的报错,使用callback的方式获取错误信息。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | 监听项的名称 | -| callback | Callback | Yes | 使用callback的方式获取**拍照会话**的错误信息 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'error'。 | +| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。 | **示例:** @@ -2380,26 +2026,20 @@ captureSession.on('error', (captureSessionError) => { }) ``` -## createPreviewOutput(surfaceId: string, callback: AsyncCallback): void; - -**系统能力:** +## camera.createPreviewOutput -SystemCapability.Multimedia.Camera.Core +createPreviewOutput(surfaceId: string, callback: AsyncCallback): void -**说明:** +获取PreviewOutput实例,通过注册回调函数获取结果。 -创建**预览输出**实例,使用callback的方式获取一个异步的实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | 从XComponent组件获取的Surface ID | -| callback | AsyncCallback | Yes | 使用callback的方式获取的实例 | - -**返回值:** - -none +| surfaceId | string | 是 | 从XComponent组件获取的Surface ID。 | +| callback | AsyncCallback<[PreviewOutput](#previewoutput)\> | 是 | 回调函数,用于获取PreviewOutput实例。 | **示例:** @@ -2411,29 +2051,27 @@ camera.createPreviewOutput(surfaceId), (err, previewOutput) => { } console.log('Callback returned with previewOutput instance'); }); -``` - -## createPreviewOutput(surfaceId: string): Promise; +``` -**系统能力:** +## camera.createPreviewOutput -SystemCapability.Multimedia.Camera.Core +createPreviewOutput(surfaceId: string): Promise\ -**说明:** +获取PreviewOutput实例,通过Promise获取结果。 -创建**预览输出**实例, 使用promise方式获取一个实例。. +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | 从XComponent组件获取的Surface ID | +| surfaceId | string | 是 | 从XComponent组件获取的Surface ID。 | **返回值:** | 类型 | 说明 | |-------------------------|---------------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise<[PreviewOutput](#previewoutput)\> | 使用Promise的方式获取结果。 | **示例:** @@ -2445,27 +2083,21 @@ camera.createPreviewOutput(surfaceId).then((previewOutput) => { ## PreviewOutput -**预览输出**类。 - -### release(callback: AsyncCallback): void; +预览输出类。 -**系统能力:** +### release -SystemCapability.Multimedia.Camera.Core +release(callback: AsyncCallback): void -**说明:** +释放PreviewOutput实例,通过注册回调函数获取结果。 -释放**预览输出**实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2479,24 +2111,19 @@ previewOutput.release((err) => { }); ``` -### release(): Promise; +### release -**系统能力:** +release(): Promise -SystemCapability.Multimedia.Camera.Core +释放PreviewOutput实例,通过Promise获取结果。 -**说明:** - -释放**预览输出**实例,使用promise的方式获取结果。 - -**参数:** -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |----------------|-----------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -2507,26 +2134,20 @@ previewOutput.release().then(() => { }) ``` -### on(type: 'frameStart', callback: Callback): void; +### on('frameStart') -**系统能力:** +on(type: 'frameStart', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +监听预览帧启动,通过注册回调函数获取结果。 -**说明:** - -监听一项预览帧的开启,使用callback的方式获取预览帧开启项。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | 监听项的名称 | -| callback | Callback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'frameStart',即帧启动事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2536,26 +2157,20 @@ previewOutput.on('frameStart', () => { }) ``` -### on(type: 'frameEnd', callback: Callback): void; - -**系统能力:** +### on('frameEnd') -SystemCapability.Multimedia.Camera.Core +on(type: 'frameEnd', callback: AsyncCallback): void -**说明:** +监听预览帧结束,通过注册回调函数获取结果。 -监听一项预览帧的关闭,使用callback的方式获取预览帧关闭项。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | 监听项的名称 | -| callback | Callback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'frameEnd',即帧结束事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2565,26 +2180,20 @@ previewOutput.on('frameEnd', () => { }) ``` -### on(type: 'error', callback: Callback): void; +### on('error') -**系统能力:** +on(type: 'error', callback: ErrorCallback): void -SystemCapability.Multimedia.Camera.Core +监听预览输出的错误事件,通过注册回调函数获取结果。 -**说明:** - -监听**预览输出**的报错,使用callback的方式获取错误信息。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of event to listen for. | -| callback | Callback | Yes | 使用callback的方式获取**预览输出**的错误信息 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'error'。 | +| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。 | **示例:** @@ -2594,26 +2203,20 @@ previewOutput.on('error', (previewOutputError) => { }) ``` -## createPhotoOutput(surfaceId: string, callback: AsyncCallback): void; - -**系统能力:** +## camera.createPhotoOutput -SystemCapability.Multimedia.Camera.Core +createPhotoOutput(surfaceId: string, callback: AsyncCallback): void -**说明:** +获取PhotoOutput实例,通过注册回调函数获取结果。 -创建**照片输出**实例,使用callback的方式获取一个异步的实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | 从ImageReceiver获取的Surfack ID | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| surfaceId | string | 是 | 从ImageReceiver获取的Surface ID。 | +| callback | AsyncCallback<[PhotoOutput](#photooutput)\> | 是 | 回调函数,用于获取PhotoOutput实例。 | **示例:** @@ -2625,29 +2228,27 @@ camera.createPhotoOutput(surfaceId), (err, photoOutput) => { } console.log('Callback returned with the PhotoOutput instance.'); }); -``` - -## createPhotoOutput(surfaceId: string): Promise; +``` -**系统能力:** +## camera.createPhotoOutput -SystemCapability.Multimedia.Camera.Core +createPhotoOutput(surfaceId: string): Promise -**说明:** +获取PhotoOutput实例,通过Promise获取结果。 -创建**照片输出**实例,使用promise的方式获取实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | 从ImageReceiver获取的Surfack ID | +| surfaceId | string | 是 | 从ImageReceiver获取的Surface ID。 | **返回值:** | 类型 | 说明 | |-------------------------|--------------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise<[PhotoOutput](#photooutput)\> | 使用Promise的方式获取PhotoOutput实例。 | **示例:** @@ -2656,71 +2257,55 @@ camera.createPhotoOutput(surfaceId).then((photoOutput) => { console.log('Promise returned with PhotoOutput instance'); }) ``` -## 图片旋转 +## ImageRotation -枚举图片旋转角度。 +枚举,图片旋转角度。 | 名称 | 默认值 | 说明 | |--------------|---------------|----------------------------------------| -| ROTATION_0 | 0 | 图片旋转0度
系统能力 : SystemCapability.Multimedia.Camera.Core | -| ROTATION_90 | 90 | 图片旋转90度
系统能力 : SystemCapability.Multimedia.Camera.Core | -| ROTATION_180 | 180 | 图片旋转180度
系统能力 : SystemCapability.Multimedia.Camera.Core | -| ROTATION_270 | 270 | 图片旋转270度
系统能力 : SystemCapability.Multimedia.Camera.Core | - - -## 拍摄地点 +| ROTATION_0 | 0 | 图片旋转0度。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| ROTATION_90 | 90 | 图片旋转90度。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| ROTATION_180 | 180 | 图片旋转180度。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| ROTATION_270 | 270 | 图片旋转270度。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -拍摄的照片的地点。 +## QualityLevel -| 名称 | 类型 | 权限 | 说明 | -|-----------|--------|--------------|-------------| -| latitude | number | read / write | 纬度
系统能力 : SystemCapability.Multimedia.Camera.Core | -| longitude | number | read / write | 经度
系统能力 : SystemCapability.Multimedia.Camera.Core | - -## 图片质量 - -枚举图片质量。 +枚举,图片质量。 | 名称 | 默认值 | 说明 | |----------------------|---------------|----------------------| -| QUALITY_LEVEL_HIGH | 0 | 高图片质量
系统能力 : SystemCapability.Multimedia.Camera.Core | -| QUALITY_LEVEL_MEDIUM | 1 | 中图片质量
系统能力 : SystemCapability.Multimedia.Camera.Core | -| QUALITY_LEVEL_LOW | 2 | 低图片质量
系统能力 : SystemCapability.Multimedia.Camera.Core | +| QUALITY_LEVEL_HIGH | 0 | 图片质量高。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| QUALITY_LEVEL_MEDIUM | 1 | 图片质量中等。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| QUALITY_LEVEL_LOW | 2 | 图片质量差。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## 拍照设置 +## PhotoCaptureSetting -拍摄的照片的设置。 +拍摄照片的设置。 | 名称 | 类型 | 必填 | 说明 | |----------|---------------|-----------|---------------------| -| quality | QualityLevel | Optional | 图片质量
系统能力 : SystemCapability.Multimedia.Camera.Core | -| rotation | ImageRotation | Optional | 图片旋转角度
系统能力 : SystemCapability.Multimedia.Camera.Core | - +| quality | [QualityLevel](#qualitylevel) | 否 | 图片质量。
**系统能力:** SystemCapability.Multimedia.Camera.Core | +| rotation | [ImageRotation](#imagerotation) | 否 | 图片旋转角度。
**系统能力:** SystemCapability.Multimedia.Camera.Core | -## 照片输出 -**照片输出**类。 +## PhotoOutput -### capture(callback: AsyncCallback): void; +照片输出类。 -**系统能力:** +### capture -SystemCapability.Multimedia.Camera.Core +capture(callback: AsyncCallback): void -**说明:** +拍照,通过注册回调函数获取结果。 -拍照,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|---------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2734,26 +2319,20 @@ photoOutput.capture((err) => { }); ``` -### capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void; +### capture -**系统能力:** +capture(setting: PhotoCaptureSetting, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +根据拍照设置拍照,通过注册回调函数获取结果。 -**说明:** - -使用拍照设置拍照, 使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| setting | PhotoCaptureSetting | Yes | 拍照设置 | -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| setting | [PhotoCaptureSetting](#photocapturesetting) | 是 | 拍照设置。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2767,27 +2346,25 @@ photoOutput.capture(settings, (err) => { }); ``` -### capture(setting?: PhotoCaptureSetting): Promise; - -**系统能力:** +### capture -SystemCapability.Multimedia.Camera.Core +capture(setting?: PhotoCaptureSetting): Promise -**说明:** +根据拍照设置拍照,通过Promise获取结果。 -使用拍照设置拍照, 使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|---------------------|-----------|----------------------------------------------| -| setting | PhotoCaptureSetting | No | 拍照设置 | +| setting | [PhotoCaptureSetting](#photocapturesetting) | 否 | 拍照设置。 | **返回值:** | 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -2798,25 +2375,19 @@ photoOutput.capture().then(() => { }) ``` -### release(callback: AsyncCallback): void; +### release -**系统能力:** +release(callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +释放PhotoOutput实例,通过注册回调函数获取结果。 -**说明:** - -释放**拍照输出**实例,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -2830,24 +2401,19 @@ photoOutput.release((err) => { }); ``` -### release(): Promise; - -**系统能力:** - -SystemCapability.Multimedia.Camera.Core +### release -**说明:** +release(): Promise -释放**拍照输出**实例,使用promise的方式获取结果。 +释放PhotoOutput实例,通过Promise获取结果。 -**参数:** -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -2858,26 +2424,20 @@ photoOutput.release().then(() => { }) ``` -### on(type: 'captureStart', callback: Callback): void; - -**系统能力:** +### on('captureStart') -SystemCapability.Multimedia.Camera.Core +on(type: 'captureStart', callback: AsyncCallback): void -**说明:** +监听拍照启动,通过注册回调函数获取Capture ID。 -监听拍照项的启动,使用callback的方式获取一个拍照项的启动结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of event to listen for. | -| callback | Callback | Yes | 使用callback的方式获取captureID | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'captureStart',即拍照启动事件。 | +| callback | AsyncCallback | 是 | 使用callback的方式获取Capture ID。 | **示例:** @@ -2887,26 +2447,20 @@ photoOutput.on('captureStart', (captureId) => { }) ``` -### on(type: 'frameShutter', callback: Callback): void; - -**系统能力:** +### on('frameShutter') -SystemCapability.Multimedia.Camera.Core +on(type: 'frameShutter', callback: AsyncCallback): void -**说明:** +监听帧刷新,通过注册回调函数获取结果。 -监听一项帧刷新,使用callback的方式获取帧的刷新项。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | 监听项的名称 | -| callback | Callback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'frameShutter',即帧刷新事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取相关信息。 | **示例:** @@ -2917,26 +2471,20 @@ photoOutput.on('frameShutter', (frameShutterInfo) => { }) ``` -### on(type: 'captureEnd', callback: Callback): void; +### on('captureEnd') -**系统能力:** +on(type: 'captureEnd', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +监听拍照停止,通过注册回调函数获取结果。 -**说明:** - -监听拍照项的关闭,使用callback的方式获取一个拍照项的关闭结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | 监听项的名称 | -| callback | Callback | Yes | 使用callback的方式获取拍照结束的信息 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'captureEnd',即拍照停止事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取相关信息。 | **示例:** @@ -2947,26 +2495,20 @@ photoOutput.on('captureEnd', (captureEndInfo) => { }) ``` -### on(type: 'error', callback: Callback): void; - -**系统能力:** +### on('error') -SystemCapability.Multimedia.Camera.Core +on(type: 'error', callback: ErrorCallback): void -**说明:** +监听拍照的错误事件,通过注册回调函数获取结果。 -监听**照片输出**的报错,使用callback的方式获取错误信息。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | Name of event to listen for. | -| callback | Callback | Yes | 使用callback的方式获取**照片输出**的错误信息 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'error'。 | +| callback | ErrorCallback | 是 | 回调函数,用于获取错误信息。 | **示例:** @@ -2976,26 +2518,20 @@ photoOutput.on('error', (photoOutputError) => { }) ``` -## createVideoOutput(surfaceId: string, callback: AsyncCallback): void; +## camera.createVideoOutput -**系统能力:** +createVideoOutput(surfaceId: string, callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +获取VideoOutput实例,通过注册回调函数获取结果。 -**说明:** - -创建**视频输出**实例,使用callback的方式获取一个异步的实例。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |------------|-------------------------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | 从VideoRecorder获取的Surfack ID | -| callback | AsyncCallback | Yes | 用callback的方式获取结果 | - -**返回值:** - -none +| surfaceId | string | 是 | 从VideoRecorder获取的Surface ID。 | +| callback | AsyncCallback<[VideoOutput](#videootput)\> | 是 | 回调函数,用于获取VideoOutput实例。 | **示例:** @@ -3007,29 +2543,27 @@ camera.createVideoOutput(surfaceId), (err, videoOutput) => { } console.log('Callback returned with the VideoOutput instance'); }); -``` - -## createVideoOutput(surfaceId: string): Promise; +``` -**系统能力:** +## camera.createVideoOutput -SystemCapability.Multimedia.Camera.Core +createVideoOutput(surfaceId: string): Promise -**说明:** +获取VideoOutput实例,通过Promise获取结果。 -创建**视频输出**实例,使用promise的方式获取结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |------------|-----------------|-----------|----------------------------------------------------| -| surfaceId | string | Yes | 从VideoRecorder获取的Surfack ID | +| surfaceId | string | 是 | 从VideoRecorder获取的Surface ID。 | **返回值:** -| 类型 | 说明 | -|-------------------------|-------------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| 类型 | 说明 | +| --------------------- | -------------------------------------- | +| Promise | 使用Promise的方式获取VideoOutput实例。 | **示例:** @@ -3041,27 +2575,21 @@ camera.createVideoOutput(surfaceId).then((videoOutput) => { ## VideoOutput -实现视频输出。 - -### start(callback: AsyncCallback): void; +视频输出类。 -**系统能力:** +### start -SystemCapability.Multimedia.Camera.Core +start(callback: AsyncCallback): void -**说明:** +开始拍摄视频,通过注册回调函数获取结果。 -开启**视频输出**实例, 使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -3075,24 +2603,19 @@ videoOutput.start((err) => { }); ``` -### start(): Promise; - -**系统能力:** +### start -SystemCapability.Multimedia.Camera.Core +start(): Promise -**说明:** +开始拍摄视频,通过Promise获取结果。 -开启**视频输出**实例, 使用promise的方式获取结果。 - -**参数:** -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -3103,25 +2626,19 @@ videoOutput.start().then(() => { }) ``` -### stop(callback: AsyncCallback): void; - -**系统能力:** +### stop -SystemCapability.Multimedia.Camera.Core +stop(callback: AsyncCallback): void -**说明:** +停止拍摄视频,通过注册回调函数获取结果。 -关闭视频输出,使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -3135,24 +2652,19 @@ videoOutput.stop((err) => { }); ``` -### stop(): Promise; +### stop -**系统能力:** +stop(): Promise -SystemCapability.Multimedia.Camera.Core +停止拍摄视频,通过Promise获取结果。 -**说明:** - -关闭视频输出,使用promise的方式获取结果。 - -**参数:** -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -3162,25 +2674,19 @@ videoOutput.start().then(() => { }) ``` -### release(callback: AsyncCallback): void; - -**系统能力:** +### release -SystemCapability.Multimedia.Camera.Core +release(callback: AsyncCallback): void -**说明:** +释放VideoOutput实例,通过注册回调函数获取结果。 -释放**视频输出**实例, 使用callback的方式获取一个异步的结果。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** -Camera appear + | 名称 | 类型 | 必填 | 说明 | |----------|----------------------|-----------|----------------------------------------------| -| callback | AsyncCallback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -none +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -3194,25 +2700,19 @@ videoOutput.release((err) => { }); ``` -### release(): Promise; +### release -**系统能力:** +release(): Promise -SystemCapability.Multimedia.Camera.Core +释放VideoOutput实例,通过Promise获取结果。 -**说明:** - -释放**视频输出**实例,使用promise的方式获取结果。 - -**参数:** - -none +**系统能力:** SystemCapability.Multimedia.Camera.Core **返回值:** | 类型 | 说明 | |----------------|---------------------------------------------| -| Promise | 使用promise的方式获取结果 | +| Promise | 使用Promise的方式获取结果。 | **示例:** @@ -3223,26 +2723,20 @@ videoOutput.release().then(() => { }) ``` -### on(type: 'frameStart', callback: Callback): void; - -**系统能力:** +### on('frameStart') -SystemCapability.Multimedia.Camera.Core +on(type: 'frameStart', callback: AsyncCallback): void -**说明:** +监听视频帧开启,通过注册回调函数获取结果。 -监听一项视频帧的开启,使用callback的方式获取视频帧的开启项。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | 监听项的名称 | -| callback | Callback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'frameStart',即视频帧开启事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -3252,26 +2746,20 @@ videoOutput.on('frameStart', () => { }) ``` -### on(type: 'frameEnd', callback: Callback): void; +### on('frameEnd') -**系统能力:** +on(type: 'frameEnd', callback: AsyncCallback): void -SystemCapability.Multimedia.Camera.Core +监听视频帧结束,通过注册回调函数获取结果。 -**说明:** - -监听一项视频帧的关闭,使用callback的方式获取视频帧的开启项。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :---------------- | :-------- | :----------------------------------| -| type | string | Yes | 监听项的名称 | -| callback | Callback | Yes | 使用callback的方式获取结果 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'frameEnd',即视频帧结束事件。 | +| callback | AsyncCallback | 是 | 回调函数,用于获取结果。 | **示例:** @@ -3281,26 +2769,20 @@ videoOutput.on('frameEnd', () => { }) ``` -### on(type: 'error', callback: Callback): void; - -**系统能力:** +### on('error') -SystemCapability.Multimedia.Camera.Core +on(type: 'error', callback: ErrorCallback): void -**说明:** +监听视频输出的错误事件,通过注册回调函数获取结果。 -监听 **视频输出** 的报错,使用callback的方式获取错误信息。 +**系统能力:** SystemCapability.Multimedia.Camera.Core **参数:** | 名称 | 类型 | 必填 | 说明 | | :------- | :--------------------- | :-------- | :-----------------------------------------------| -| type | string | Yes | 监听项的名称 | -| callback | Callback | Yes | 使用callback的方式获取**视频输出**的错误信息 | - -**返回值:** - -None +| type | string | 是 | 监听事件,固定为'error'。 | +| callback | Callback | 是 | 回调函数,用于获取错误信息。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md index a1d5811928270b8cd10be1d09e53d878006d3343..09fa471f41b6d6e78803364275a2ccbbb3fa2d09 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md +++ b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md @@ -116,18 +116,14 @@ import CommonEvent from '@ohos.commonEvent'; ``` -## 系统能力 - -```js -SystemCapability.Notification.CommonEvent -``` - ## CommonEvent.publish publish(event: string, callback: AsyncCallback\): void 发布公共事件(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -140,11 +136,15 @@ publish(event: string, callback: AsyncCallback\): void ```js //发布公共事件回调 function PublishCallBack(err) { - console.info("==========================>PublishCallBack=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("publish failed " + JSON.stringify(err)); + } else { + console.info("publish"); + } } + //发布公共事件 -CommonEvent.publish("publish_event", PublishCallBack); +CommonEvent.publish("event", PublishCallBack); ``` @@ -155,6 +155,8 @@ publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\ 发布公共事件指定发布信息(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -173,12 +175,18 @@ var options = { data: "initial data",//公共事件的初始数据 isOrdered: true //有序公共事件 } + //发布公共事件回调 function PublishCallBack(err) { - console.info("==========================>PublishCallBack=======================>"); + if (err.code) { + console.error("publish failed " + JSON.stringify(err)); + } else { + console.info("publish"); + } } + //发布公共事件 -CommonEvent.publish("publish_event", options, PublishCallBack); +CommonEvent.publish("event", options, PublishCallBack); ``` @@ -189,6 +197,8 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\): vo 向指定用户发布公共事件(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -203,15 +213,17 @@ publishAsUser(event: string, userId: number, callback: AsyncCallback\): vo //发布公共事件回调 function PublishAsUserCallBack(err) { if (err.code) { - console.info("publishAsUser failed " + JSON.stringify(err)); + console.error("publishAsUser failed " + JSON.stringify(err)); } else { console.info("publishAsUser"); } } + //指定发送的用户 var userId = 100; + //发布公共事件 -CommonEvent.publish("publish_event", userId, PublishAsUserCallBack); +CommonEvent.publishAsUser("event", userId, PublishAsUserCallBack); ``` @@ -222,6 +234,8 @@ publishAsUser(event: string, userId: number, options: CommonEventPublishData, ca 向指定用户发布公共事件并指定发布信息(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -240,18 +254,21 @@ var options = { code: 0; //公共事件的初始代码 data: "initial data";//公共事件的初始数据 } + //发布公共事件回调 function PublishAsUserCallBack(err) { if (err.code) { - console.info("publishAsUser failed " + JSON.stringify(err)); + console.error("publishAsUser failed " + JSON.stringify(err)); } else { console.info("publishAsUser"); } } + //指定发送的用户 var userId = 100; + //发布公共事件 -CommonEvent.publish("publish_event", userId, options, PublishAsUserCallBack); +CommonEvent.publishAsUser("event", userId, options, PublishAsUserCallBack); ``` @@ -262,6 +279,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac 创建订阅者(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -274,15 +293,22 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallbac ```js var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 + //订阅者信息 var subscribeInfo = { events: ["event"] }; + //创建订阅者回调 -function CreateSubscriberCallBack(err, data) { - console.info("==========================>CreateSubscriberCallBack=======================>"); - subscriber = data; +function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.error("createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("createSubscriber"); + subscriber = commonEventSubscriber; + } } + //创建订阅者 CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ``` @@ -295,6 +321,8 @@ createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\ { - console.info("==========================>createSubscriberPromise=======================>"); - subscriber = data; +CommonEvent.createSubscriber(subscribeInfo).then((commonEventSubscriber) => { + console.info("createSubscriber"); + subscriber = commonEventSubscriber; +}).catch((err) => { + console.error("createSubscriber failed " + JSON.stringify(err)); }); ``` @@ -329,6 +361,8 @@ subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\SubscribeCallBack=======================>"); + if (err.code) { + console.error("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribe " + JSON.stringify(data)); + } } + //创建订阅者回调 -function CreateSubscriberCallBack(err, data) { - console.info("==========================>CreateSubscriberCallBack=======================>"); - subscriber = data; - //订阅公共事件 - CommonEvent.subscribe(subscriber, SubscribeCallBack); +function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.error("createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("createSubscriber"); + subscriber = commonEventSubscriber; + //订阅公共事件 + CommonEvent.subscribe(subscriber, SubscribeCallBack); + } } + //创建订阅者 CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ``` @@ -365,6 +411,7 @@ CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ```js var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 + //订阅者信息 var subscribeInfo = { events: ["event"] @@ -372,40 +419,63 @@ var subscribeInfo = { //设置有序公共事件的结果代码回调 function SetCodeCallBack(err) { - console.info("==========================>SetCodeCallBack=======================>"); + if (err.code) { + console.error("setCode failed " + JSON.stringify(err)); + } else { + console.info("setCode"); + } } + //设置有序公共事件的结果数据回调 function SetDataCallBack(err) { - console.info("==========================>SetDataCallBack=======================>"); + if (err.code) { + console.error("setData failed " + JSON.stringify(err)); + } else { + console.info("setData"); + } } + //完成本次有序公共事件处理回调 function FinishCommonEventCallBack(err) { - console.info("==========================>FinishCommonEventCallBack=======================>"); + if (err.code) { + console.error("finishCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("finishCommonEvent"); + } } + //订阅公共事件回调 function SubscribeCallBack(err, data) { - console.info("==========================>SubscribeCallBack=======================>"); - //设置有序公共事件的结果代码 - subscriber.setCode(0, SetCodeCallBack); - //设置有序公共事件的结果数据 - subscriber.setData("publish_data_changed", SetDataCallBack); - //完成本次有序公共事件处理 - subscriber.finishCommonEvent(FinishCommonEventCallBack) + if (err.code) { + console.error("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribe " + JSON.stringify(data)); + //设置有序公共事件的结果代码 + subscriber.setCode(0, SetCodeCallBack); + //设置有序公共事件的结果数据 + subscriber.setData("publish_data_changed", SetDataCallBack); + //完成本次有序公共事件处理 + subscriber.finishCommonEvent(FinishCommonEventCallBack) + } } //创建订阅者回调 -function CreateSubscriberCallBack(err, data) { - console.info("==========================>CreateSubscriberCallBack=======================>"); - subscriber = data; - //订阅公共事件 - CommonEvent.subscribe(subscriber, SubscribeCallBack); +function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.error("createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("createSubscriber"); + subscriber = commonEventSubscriber; + //订阅公共事件 + CommonEvent.subscribe(subscriber, SubscribeCallBack); + } } //创建订阅者 CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ``` - + ## CommonEvent.unsubscribe @@ -413,6 +483,8 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\): 取消订阅公共事件(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | @@ -424,61 +496,79 @@ unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\): ```js var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 + //订阅者信息 var subscribeInfo = { events: ["event"] }; + //订阅公共事件回调 function SubscribeCallBack(err, data) { - console.info("==========================>SubscribeCallBack=======================>"); + if (err.code) { + console.info("subscribe failed " + JSON.stringify(err)); + } else { + console.info("subscribe " + JSON.stringify(data)); + } } + //创建订阅者回调 -function CreateSubscriberCallBack(err, data) { - console.info("==========================>CreateSubscriberCallBack=======================>"); - subscriber = data; - //订阅公共事件 - CommonEvent.subscribe(subscriber, SubscribeCallBack); +function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.info("createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("createSubscriber"); + subscriber = commonEventSubscriber; + //订阅公共事件 + CommonEvent.subscribe(subscriber, SubscribeCallBack); + } } + //取消订阅公共事件回调 function UnsubscribeCallBack(err) { - console.info("==========================>UnsubscribeCallBack=======================>"); + if (err.code) { + console.info("unsubscribe failed " + JSON.stringify(err)); + } else { + console.info("unsubscribe"); + } } + //创建订阅者 CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); + //取消订阅公共事件 CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); ``` ## CommonEventPublishData -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| --------------------- | -------- | -------------------- | ---- | ---------------------------- | -| bundleName | 只读 | string | 否 | 表示包名称 | -| code | 只读 | number | 否 | 表示公共事件的结果代码 | -| data | 只读 | string | 否 | 表示公共事件的自定义结果数据 | -| subscriberPermissions | 只读 | Array\ | 否 | 表示订阅者的权限 | -| isOrdered | 只读 | boolean | 否 | 表示是否是有序事件 | -| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息 | +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| --------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| bundleName | 只读 | string | 否 | 表示包名称
**系统能力**:SystemCapability.Notification.CommonEvent | +| code | 只读 | number | 否 | 表示公共事件的结果代码
**系统能力**:SystemCapability.Notification.CommonEvent | +| data | 只读 | string | 否 | 表示公共事件的自定义结果数据
**系统能力**:SystemCapability.Notification.CommonEvent | +| subscriberPermissions | 只读 | Array\ | 否 | 表示订阅者的权限
**系统能力**:SystemCapability.Notification.CommonEvent | +| isOrdered | 只读 | boolean | 否 | 表示是否是有序事件
**系统能力**:SystemCapability.Notification.CommonEvent | +| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息
**系统能力**:SystemCapability.Notification.CommonEvent | ## CommonEventSubscribeInfo | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ | -| events | 只读 | Array\ | 是 | 表示要发送的公共事件 | -| publisherPermission | 只读 | string | 否 | 表示发布者的权限 | -| publisherDeviceId | 只读 | string | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID | -| userId | 只读 | number | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。 | -| priority | 只读 | number | 否 | 表示订阅者的优先级。值的范围是-100到1000 | +| events | 只读 | Array\ | 是 | 表示要发送的公共事件
**系统能力**:SystemCapability.Notification.CommonEvent | +| publisherPermission | 只读 | string | 否 | 表示发布者的权限
**系统能力**:SystemCapability.Notification.CommonEvent | +| publisherDeviceId | 只读 | string | 否 | 表示设备ID,该值必须是同一ohos网络上的现有设备ID
**系统能力**:SystemCapability.Notification.CommonEvent | +| userId | 只读 | number | 否 | 表示用户ID。此参数是可选的,默认值当前用户的ID。如果指定了此参数,则该值必须是系统中现有的用户ID。
**系统能力**:SystemCapability.Notification.CommonEvent | +| priority | 只读 | number | 否 | 表示订阅者的优先级。值的范围是-100到1000
**系统能力**:SystemCapability.Notification.CommonEvent | ## CommonEventData -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| ---------- | -------- | -------------------- | ---- | ------------------------------------------------------ | -| event | 只读 | string | 是 | 表示当前接收的公共事件名称 | -| bundleName | 只读 | string | 否 | 表示包名称 | -| code | 只读 | number | 否 | 表示公共事件的结果代码,用于传递int类型的数据 | -| data | 只读 | string | 否 | 表示公共事件的自定义结果数据,用于传递string类型的数据 | -| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息 | +| 名称 | 读写属性 | 类型 | 必填 | 描述 | +| ---------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | +| event | 只读 | string | 是 | 表示当前接收的公共事件名称
**系统能力**:SystemCapability.Notification.CommonEvent | +| bundleName | 只读 | string | 否 | 表示包名称
**系统能力**:SystemCapability.Notification.CommonEvent | +| code | 只读 | number | 否 | 表示公共事件的结果代码,用于传递int类型的数据
**系统能力**:SystemCapability.Notification.CommonEvent | +| data | 只读 | string | 否 | 表示公共事件的自定义结果数据,用于传递string类型的数据
**系统能力**:SystemCapability.Notification.CommonEvent | +| parameters | 只读 | {[key: string]: any} | 否 | 表示公共事件的附加信息
**系统能力**:SystemCapability.Notification.CommonEvent | ## CommonEventSubscriber @@ -488,6 +578,8 @@ getCode(callback: AsyncCallback\): void 获取公共事件的结果代码(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -497,12 +589,16 @@ getCode(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 -function getCodeCallback(err, data) { - console.info("==========================>getCodeCallback=======================>"); - console.info("==========================>err:=======================>", err.code); - console.info("==========================>code:=======================>", data); +getCode() { +function getCodeCallback(err, Code) { + if (err.code) { + console.error("getCode failed " + JSON.stringify(err)); + } else { + console.info("getCode " + JSON.stringify(Code)); + } } subscriber.getCode(getCodeCallback); ``` @@ -513,6 +609,8 @@ getCode(): Promise\ 获取公共事件的结果代码(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **返回值:** | 类型 | 说明 | @@ -522,10 +620,12 @@ getCode(): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 -subscriber.getCode().then((data) => { - console.info("==========================>getCodePromise=======================>"); - console.info("==========================>code:=======================>", data); +var subscriber; //创建成功的订阅者对象 + +subscriber.getCode().then((Code) => { + console.info("getCode " + JSON.stringify(Code)); +}).catch((err) => { + console.error("getCode failed " + JSON.stringify(err)); }); ``` @@ -535,6 +635,8 @@ setCode(code: number, callback: AsyncCallback\): void 设置公共事件的结果代码(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -545,11 +647,15 @@ setCode(code: number, callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 function setCodeCallback(err) { - console.info("==========================>setCodeCallback=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("setCode failed " + JSON.stringify(err)); + } else { + console.info("setCode"); + } } subscriber.setCode(1, setCodeCallback); ``` @@ -560,6 +666,8 @@ setCode(code: number): Promise\ 设置公共事件的结果代码(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -569,9 +677,12 @@ setCode(code: number): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + subscriber.setCode(1).then(() => { - console.info("==========================>setCodePromise=======================>"); + console.info("setCode"); +}).catch((err) => { + console.error("setCode failed " + JSON.stringify(err)); }); ``` @@ -581,6 +692,8 @@ getData(callback: AsyncCallback\): void 获取公共事件的结果数据(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -590,12 +703,15 @@ getData(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 -function getDataCallback(err, data) { - console.info("==========================>getDataCallback=======================>"); - console.info("==========================>err:=======================>", err.code); - console.info("==========================>data:=======================>", data); +function getDataCallback(err, Data) { + if (err.code) { + console.error("getData failed " + JSON.stringify(err)); + } else { + console.info("getData " + JSON.stringify(Data)); + } } subscriber.getData(getDataCallback); ``` @@ -606,6 +722,8 @@ getData(): Promise\ 获取公共事件的结果数据(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **返回值:** | 类型 | 说明 | @@ -615,10 +733,12 @@ getData(): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 -subscriber.getData().then((data) => { - console.info("==========================>getDataPromise=======================>"); - console.info("==========================>data:=======================>", data); +var subscriber; //创建成功的订阅者对象 + +subscriber.getData().then((Data) => { + console.info("getData " + JSON.stringify(Data)); +}).catch((err) => { + console.error("getData failed " + JSON.stringify(err)); }); ``` @@ -628,6 +748,8 @@ setData(data: string, callback: AsyncCallback\): void 设置公共事件的结果数据(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -638,11 +760,15 @@ setData(data: string, callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 function setDataCallback(err) { - console.info("==========================>setDataCallback=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("setData failed " + JSON.stringify(err)); + } else { + console.info("setData"); + } } subscriber.setData("publish_data_changed", setDataCallback); ``` @@ -653,6 +779,8 @@ setData(data: string): Promise\ 设置公共事件的结果数据(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -662,9 +790,12 @@ setData(data: string): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + subscriber.setData("publish_data_changed").then(() => { - console.info("==========================>setDataPromise=======================>"); + console.info("setData"); +}).catch((err) => { + console.error("setData failed " + JSON.stringify(err)); }); ``` @@ -674,6 +805,8 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback\): void 设置公共事件的结果代码和结果数据(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -685,11 +818,15 @@ setCodeAndData(code: number, data: string, callback:AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 function setCodeDataCallback(err) { - console.info("==========================>setCodeDataCallback=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("setCodeAndData failed " + JSON.stringify(err)); + } else { + console.info("setCodeDataCallback"); + } } subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback); ``` @@ -700,6 +837,8 @@ setCodeAndData(code: number, data: string): Promise\ 设置公共事件的结果代码和结果数据(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -710,9 +849,12 @@ setCodeAndData(code: number, data: string): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + subscriber.setCodeAndData(1, "publish_data_changed").then(() => { - console.info("==========================>setCodeAndData=======================>"); + console.info("setCodeAndData"); +}).catch((err) => { + console.info("setCodeAndData failed " + JSON.stringify(err)); }); ``` @@ -724,6 +866,8 @@ isOrderedCommonEvent(callback: AsyncCallback\): void 返回true代表是有序公共事件,false代表不是有序公共事件。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -733,12 +877,15 @@ isOrderedCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 -function isOrderedCallback(err, data) { - console.info("==========================>isOrderedCallback=======================>"); - console.info("==========================>err:=======================>", err.code); - console.info("==========================>isOrdered:=======================>", data); +function isOrderedCallback(err, isOrdered) { + if (err.code) { + console.error("isOrderedCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("isOrdered " + JSON.stringify(isOrdered)); + } } subscriber.isOrderedCommonEvent(isOrderedCallback); ``` @@ -751,6 +898,8 @@ isOrderedCommonEvent(): Promise\ 返回true代表是有序公共事件,false代表不是有序公共事件。 +**系统能力**:SystemCapability.Notification.CommonEvent + **返回值:** | 类型 | 说明 | @@ -760,9 +909,12 @@ isOrderedCommonEvent(): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 -subscriber.isOrderedCommonEvent().then((data) => { - console.info("==========================>isOrdered:=======================>", data); +var subscriber; //创建成功的订阅者对象 + +subscriber.isOrderedCommonEvent().then((isOrdered) => { + console.info("isOrdered " + JSON.stringify(isOrdered)); +}).catch((err) => { + console.error("isOrdered failed " + JSON.stringify(err)); }); ``` @@ -772,6 +924,8 @@ abortCommonEvent(callback: AsyncCallback\): void 取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -781,11 +935,15 @@ abortCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 function abortCallback(err) { - console.info("==========================>abortCallback=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("abortCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("abortCommonEvent"); + } } subscriber.abortCommonEvent(abortCallback); ``` @@ -796,12 +954,17 @@ abortCommonEvent(): Promise\ 取消当前的公共事件,仅对有序公共事件有效,取消后,公共事件不再向下一个订阅者传递(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + subscriber.abortCommonEvent().then(() => { - console.info("==========================>abortCommonEvent:=======================>"); + console.info("abortCommonEvent"); +}).catch((err) => { + console.error("abortCommonEvent failed " + JSON.stringify(err)); }); ``` @@ -811,6 +974,8 @@ clearAbortCommonEvent(callback: AsyncCallback\): void 清除当前公共事件的取消状态,仅对有序公共事件有效(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -820,11 +985,15 @@ clearAbortCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 function clearAbortCallback(err) { - console.info("==========================>clearAbortCallback=======================>"); - console.info("==========================>err:=======================>", err.code); + if (err.code) { + console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("clearAbortCommonEvent"); + } } subscriber.clearAbortCommonEvent(clearAbortCallback); ``` @@ -835,12 +1004,17 @@ clearAbortCommonEvent(): Promise\ 清除当前公共事件的取消状态,仅对有序公共事件有效(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + subscriber.clearAbortCommonEvent().then(() => { - console.info("==========================>clearAbortCommonEvent:=======================>"); + console.info("clearAbortCommonEvent"); +}).catch((err) => { + console.error("clearAbortCommonEvent failed " + JSON.stringify(err)); }); ``` @@ -850,6 +1024,8 @@ getAbortCommonEvent(callback: AsyncCallback\): void 获取当前有序公共事件是否取消的状态(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -859,12 +1035,15 @@ getAbortCommonEvent(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 -function getAbortCallback(err, data) { - console.info("==========================>getAbortCallback=======================>"); - console.info("==========================>err:=======================>", err.code); - console.info("==========================>abort:=======================>", data); +function getAbortCallback(err, AbortCommonEvent) { + if (err.code) { + console.error("getAbortCommonEvent failed " + JSON.stringify(err)); + } else { + console.info("AbortCommonEvent " + AbortCommonEvent) + } } subscriber.getAbortCommonEvent(getAbortCallback); ``` @@ -875,6 +1054,8 @@ getAbortCommonEvent(): Promise\ 获取当前有序公共事件是否取消的状态(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **返回值:** | 类型 | 说明 | @@ -884,10 +1065,12 @@ getAbortCommonEvent(): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 -subscriber.getAbortCommonEvent().then((data) => { - console.info("==========================>getAbortCommonEvent:=======================>"); - console.info("==========================>abort:=======================>", data); +var subscriber; //创建成功的订阅者对象 + +subscriber.getAbortCommonEvent().then((AbortCommonEvent) => { + console.info("AbortCommonEvent " + JSON.stringify(AbortCommonEvent)); +}).catch((err) => { + console.error("getAbortCommonEvent failed " + JSON.stringify(err)); }); ``` @@ -897,6 +1080,8 @@ getSubscribeInfo(callback: AsyncCallback\): void 获取订阅者的订阅信息(callback形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **参数:** | 参数名 | 类型 | 必填 | 描述 | @@ -906,12 +1091,15 @@ getSubscribeInfo(callback: AsyncCallback\): void **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 +var subscriber; //创建成功的订阅者对象 + //设置有序公共事件的结果数据回调 -function getSubscribeInfoCallback(err, data) { - console.info("==========================>getSubscribeInfoCallback=======================>"); - console.info("==========================>err:=======================>", err.code); - console.info("==========================>priority:=======================>", data.priority); +function getSubscribeInfoCallback(err, SubscribeInfo) { + if (err.code) { + console.error("getSubscribeInfo failed " + JSON.stringify(err)); + } else { + console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); + } } subscriber.getSubscribeInfo(getSubscribeInfoCallback); ``` @@ -922,6 +1110,8 @@ getSubscribeInfo(): Promise\ 获取订阅者的订阅信息(Promise形式)。 +**系统能力**:SystemCapability.Notification.CommonEvent + **返回值:** | 类型 | 说明 | @@ -931,9 +1121,12 @@ getSubscribeInfo(): Promise\ **示例:** ```js -var subscriber; //用于保存创建成功的订阅者对象,后续使用其完成订阅及退订的动作 -subscriber.getSubscribeInfo().then((data) => { - console.info("==========================>getSubscribeInfo:=======================>"); - console.info("==========================>priority:=======================>", data.priority); +var subscriber; //创建成功的订阅者对象 + +subscriber.getSubscribeInfo().then((SubscribeInfo) => { + console.info("SubscribeInfo " + JSON.stringify(SubscribeInfo)); +}).catch((err) => { + console.error("getSubscribeInfo failed " + JSON.stringify(err)); }); -``` \ No newline at end of file +``` + diff --git a/zh-cn/application-dev/reference/apis/js-apis-configuration.md b/zh-cn/application-dev/reference/apis/js-apis-configuration.md index d35dfa4b321e40d8c028f07b78eb179f0cfb2291..efd704780a950ef60dae1ecb5d7b4d2d8c93c789 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-configuration.md +++ b/zh-cn/application-dev/reference/apis/js-apis-configuration.md @@ -1,11 +1,7 @@ # Configuration -- [导入模块](#导入模块) -- [属性](#属性) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 8开始支持。 +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 环境变化信息。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md b/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md index 41a55a9f52860d13b74d0eac845ec499864848ac..f59e65444d09dfe4975337b2f31f2021c5f4a0a9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md +++ b/zh-cn/application-dev/reference/apis/js-apis-configurationconstant.md @@ -1,13 +1,7 @@ # ConfigurationConstant -- [导入模块](#导入模块) -- [ColorMode](#ColorMode) -- [Direction](#Direction) -- [ScreenDensity](#ScreenDensity) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 8开始支持。 +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 配置信息枚举值定义。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md index 543b429ce1ace53f963f89f2bf36a599690d8696..d7fad75e68111100e32c4fc02cd4c0a2ddc05c3e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @@ -4,7 +4,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 ## 导入模块 @@ -23,13 +23,13 @@ import data_Preferences from '@ohos.data.preferences' ## data_Preferences.getPreferences -### 系统能力 -SystemCapability.DistributedDataManager.Preferences.Core - getPreferences(context: Context, name: string, callback: AsyncCallback<Preferences>): void 读取指定文件,将数据加载到Preferences实例,用于数据操作,使用callback形式返回结果。 + +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -41,7 +41,7 @@ getPreferences(context: Context, name: string, callback: AsyncCallback<Prefer ``` import Ability from '@ohos.application.Ability' import data_Preferences from '@ohos.data.preferences' - var path = await this.context.getDataBaseDir() + var path = this.context.getDataBaseDir() data_Preferences.getPreferences(this.context, 'mystore', function (err, preferences) { if (err) { console.info("Get the preferences failed, path: " + path + '/mystore') @@ -55,13 +55,12 @@ getPreferences(context: Context, name: string, callback: AsyncCallback<Prefer ## data_Preferences.getPreferences -### 系统能力 -SystemCapability.DistributedDataManager.Preferences.Core - getPreferences(context: Context, name: string): Promise<Preferences> 读取指定文件,将数据加载到Preferences实例,用于数据操作,使用Promise方式作为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -77,7 +76,7 @@ getPreferences(context: Context, name: string): Promise<Preferences> ``` import Ability from '@ohos.application.Ability' import data_Preferences from '@ohos.data.preferences' - var path = await this.context.getDataBaseDir() + var path = this.context.getDataBaseDir() let promise = data_Preferences.getPreferences(this.context, 'mystore') promise.then((preferences) => { preferences.putSync('startup', 'auto') @@ -90,13 +89,12 @@ getPreferences(context: Context, name: string): Promise<Preferences> ## data_Preferences.deletePreferences -### 系统能力 -SystemCapability.DistributedDataManager.Preferences.Core - deletePreferences(context: Context, name: string, callback: AsyncCallback<void>) 从内存中移除指定文件对应的Preferences单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用callback方式作为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -120,13 +118,12 @@ deletePreferences(context: Context, name: string, callback: AsyncCallback<voi ## data_Preferences.deletePreferences -### 系统能力 -SystemCapability.DistributedDataManager.Preferences.Core - deletePreferences(context: Context, name: string): Promise<void> 从内存中移除指定文件对应的Preferences单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题,使用promise方式作为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -153,15 +150,14 @@ deletePreferences(context: Context, name: string): Promise<void> ## data_Preferences.removePreferencesFromCache -### 系统能力 -SystemCapability.DistributedDataManager.Preferences.Core - removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback<Preferences>): void 从内存中移除指定文件对应的Preferences单实例。移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -185,14 +181,14 @@ removePreferencesFromCache(context: Context, name: string, callback: AsyncCallba ## data_Preferences.removePreferencesFromCache -### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - removePreferencesFromCache(context: Context, name: string): Promise<void> 从内存中移除指定文件对应的Preferences单实例。移除Preferences单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -224,14 +220,14 @@ removePreferencesFromCache(context: Context, name: string): Promise<void> ### get -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): void 获取键对应的值,如果值为null或者非默认值类型,返回默认数据。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -253,14 +249,14 @@ get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): ### get -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - get(key: string, defValue: ValueType): Promise<ValueType> 获取键对应的值,如果值为null或者非默认值类型,返默认数据。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -285,14 +281,14 @@ get(key: string, defValue: ValueType): Promise<ValueType> ### put -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - put(key: string, value: ValueType, callback: AsyncCallback<void>): void 首先获取指定文件对应的Preferences实例,然后借助Preferences API将数据写入Preferences实例,通过flush或者flushSync将Preferences实例持久化。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -314,14 +310,14 @@ put(key: string, value: ValueType, callback: AsyncCallback<void>): void ### put -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - put(key: string, value: ValueType): Promise<void> 首先获取指定文件对应的Preferences实例,然后借助Preferences API将数据写入Preferences实例,通过flush或者flushSync将Preferences实例持久化。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -346,14 +342,14 @@ put(key: string, value: ValueType): Promise<void> ### has -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - has(key: string, callback: AsyncCallback<boolean>): boolean 检查存储对象是否包含名为给定key的存储。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -381,14 +377,14 @@ has(key: string, callback: AsyncCallback<boolean>): boolean ### has -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - has(key: string): Promise<boolean> 检查存储对象是否包含名为给定key的存储。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -414,14 +410,14 @@ has(key: string): Promise<boolean> ### delete -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - delete(key: string, callback: AsyncCallback<void>): void 从存储对象中删除名为给定key的存储。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -442,14 +438,14 @@ delete(key: string, callback: AsyncCallback<void>): void ### delete -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - delete(key: string): Promise<void> 从存储对象删除名为给定key的存储。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -473,14 +469,14 @@ delete(key: string): Promise<void> ### flush -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - flush(callback: AsyncCallback<void>): void 将当前preferences对象中的修改保存到当前的preferences,并异步存储到文件中。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -500,14 +496,14 @@ flush(callback: AsyncCallback<void>): void ### flush -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - flush(): Promise<void> 将当前preferences对象中的修改保存到当前的preferences,并异步存储到文件中。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -526,14 +522,14 @@ flush(): Promise<void> ### clear -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - clear(callback: AsyncCallback<void>): void 清除此存储对象中的所有存储。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -553,14 +549,14 @@ clear(callback: AsyncCallback<void>): void ### clear -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - clear(): Promise<void> 清除此存储对象中的所有存储。 此方法为异步方法。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -579,12 +575,12 @@ clear(): Promise<void> ### on('change') -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - on(type: 'change', callback: Callback<{ key : string }>): void 订阅数据变更者类,订阅的key的值发生变更后,在执行flush方法后,callback方法会被回调。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 说明 | | -------- | -------- | -------- | @@ -604,12 +600,12 @@ on(type: 'change', callback: Callback<{ key : string }>): void ### off('change') -#### 系统能力 SystemCapability.DistributedDataManager.Preferences.Core - off(type: 'change', callback: Callback<{ key : string }>): void 当不再进行订阅数据变更时,使用此接口取消订阅。 +**系统能力**:SystemCapability.DistributedDataManager.Preferences.Core + - 参数: | 参数名 | 类型 | 说明 | | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md index 8c47d4e3531f3e22994791e2b625bfde70566387..8bfce043074d777f72856870b995d8d508dcfbe9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md @@ -4,7 +4,7 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 从API Version 8开始,该接口不再维护,推荐使用新接口 [@ohos.data.preferences](js-apis-data-preferences.md) +> 从API Version 9开始,该接口不再维护,推荐使用新接口 [@ohos.data.preferences](js-apis-data-preferences.md) ## 导入模块 diff --git a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md index 3c0e4627e4c8d0a1fabf9498df7eee99ebb4355e..b8137840e02a6159e15c886386c95ecbf4c5d7e4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -16,6 +16,10 @@ openFile(uri: string, mode: string, callback: AsyncCallback\): void 在指定的远程路径中打开文件(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -44,6 +48,12 @@ DAHelper.openFile( openFile(uri: string, mode: string): Promise\ +在指定的远程路径中打开文件(promise形式)。 + +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -77,6 +87,10 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback\): void 注册观察者以观察给定uri指定的数据callback通知。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -108,6 +122,10 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback\): void 注消观察者以停止观察给定uri指定的数据callback通知。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -143,6 +161,10 @@ getType(uri: string, callback: AsyncCallback\): void 获取给定URI指定数据的MIME类型(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -170,6 +192,10 @@ getType(uri: string): Promise\ 获取给定URI指定数据的MIME类型(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -201,6 +227,10 @@ getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback> 获取支持的文件的MIME类型(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -265,12 +299,16 @@ normalizeUri(uri: string, callback: AsyncCallback\): void 将引用数据功能的给定uri转换为规范化uri(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | | -------- | ---------------------- | ---- | ------------------------------------------------------------ | | uri | string | 是 | 指示要规范化的uri对象。 | -| callback | AsyncCallback\ | 是 | 回调方法。如果数据功能支持uri规范化或null,则返回规范化uri对象。 | +| callback | AsyncCallback\ | 是 | 回调方法。如果数据功能支持uri规范化,则返回规范化uri对象;否则返回null。 | **示例:** @@ -292,6 +330,10 @@ normalizeUri(uri: string): Promise\ 将引用数据功能的给定uri转换为规范化uri(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -301,7 +343,7 @@ normalizeUri(uri: string): Promise\ **返回值:** | 类型 | 说明 | | ---------------- | ------------------------------------------------------ | -| Promise\ | 如果数据功能支持uri规范化或null,则返回规范化uri对象。 | +| Promise\ | 如果数据功能支持uri规范化,则返回规范化uri对象;否则返回null。 | **示例:** @@ -323,6 +365,10 @@ denormalizeUri(uri: string, callback: AsyncCallback\): void 将由normalizeUri(uri)生成的给定规范化uri转换为非规范化uri(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -352,6 +398,10 @@ denormalizeUri(uri: string): Promise\ 将由normalizeUri(uri)生成的给定规范化uri转换为非规范化uri(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -383,6 +433,10 @@ notifyChange(uri: string, callback: AsyncCallback\): void 通知已注册的观察者uri指定的数据资源的更改(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -410,6 +464,10 @@ notifyChange(uri: string): Promise\ 通知已注册的观察者uri指定的数据资源的更改(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -441,6 +499,10 @@ insert(uri: string, valuesBucket: rdb.ValuesBucket, callback: AsyncCallback\ 将单个数据记录插入数据库(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -515,6 +581,10 @@ batchInsert(uri: string, valuesBuckets: Array, callback: Async 插入数据库(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -547,6 +617,10 @@ batchInsert(uri: string, valuesBuckets: Array): Promise\ | 返回值为Promise对象,Promise中包含应用信息。 | +| Promise\ | Promise中包含更新的数据记录数。 。 | **示例:** @@ -730,6 +820,10 @@ query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityP 查询数据库中的数据(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -766,6 +860,10 @@ query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityP 查询数据库中的数据(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-deque.md b/zh-cn/application-dev/reference/apis/js-apis-deque.md index 222bf5f5150abbfc4eeb7765f0b6b8a44c2a0fc0..96440fe9281dd472232c783b28c2fe8e548ba431 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-deque.md +++ b/zh-cn/application-dev/reference/apis/js-apis-deque.md @@ -104,9 +104,9 @@ has(element: T): boolean ``` let deque = new Deque(); -deque.has("Ahfbrgrbgnutfodgorrogorg"); +let result = deque.has("Ahfbrgrbgnutfodgorrogorg"); deque.insertFront("Ahfbrgrbgnutfodgorrogorg"); -deque.has("Ahfbrgrbgnutfodgorrogorg"); +let result1 = deque.has("Ahfbrgrbgnutfodgorrogorg"); ``` ### popFirst @@ -130,7 +130,7 @@ deque.insertFront(4); deque.insertEnd(5); deque.insertFront(2); deque.insertFront(4); -deque.popFirst(); +let result = deque.popFirst(); ``` ### popLast @@ -155,6 +155,7 @@ deque.insertFront(5); deque.insertFront(2); deque.insertFront(4); deque.popLast(); +let result = deque.popLast(); ``` ### forEach @@ -211,7 +212,7 @@ deque.insertEnd(2); deque.insertEnd(4); deque.insertFront(5); deque.insertFront(4); -deque.getFirst(); +let result = deque.getFirst(); ``` ### getLast @@ -234,7 +235,7 @@ deque.insertFront(2); deque.insertFront(4); deque.insertFront(5); deque.insertFront(4); -deque.getLast(); +let result = deque.getLast(); ``` ### [Symbol.iterator] diff --git a/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md b/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md index 0ff74ddd4019ca2b8bf558c5da2034ec35682199..8a8634363b7ed99e777444ce9c95a747951cd49b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md @@ -7,10 +7,10 @@ ## 导入模块 ``` -import stats from '@ohos.usagestatskit' +import stats from '@ohos.bundleState' ``` -## usagestatskit.isIdleState +## bundleState.isIdleState isIdleState(bundleName: string, callback: AsyncCallback): void - **系统能力**: @@ -26,20 +26,22 @@ SystemCapability.ResourceSchedule.UsageStatistics.AppGroup | bundleName | string | 是 | 应用的bundleName。| | callback | AsyncCallback | 是 | 指定的callback回调方法。如果指定的bundleName有效,则返回指定bundleName的应用当前是否是空闲状态;否则返回null。 | +- **权限**: +无权限 - **示例**: ``` stats.isIdleState("com.ohos.camera", (err, res) => { - if(err.data === 0) { - console.log('isIdleState callback succeeded, result: ' + JSON.stringify(res)); + if(err.code === 0) { + console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res)); } else { - console.log('isIdleState callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code); } }); ``` -## usagestatskit.isIdleState +## bundleState.isIdleState isIdleState(bundleName: string): Promise; - **系统能力**: @@ -60,17 +62,20 @@ SystemCapability.ResourceSchedule.UsageStatistics.AppGroup | -------- | -------- | | Promise | 指定的Promise回调方法。如果指定的bundleName有效,则返回指定bundleName的应用当前是否是空闲状态;否则返回null。 | +- **权限**: +无权限 + - **示例**: ``` stats.isIdleState("com.ohos.camera").then( res => { - console.log('isIdleState callback succeeded, result: ' + JSON.stringify(res)); + console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res)); }).catch( err => { - console.log('isIdleState callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code); }); ``` -## usagestatskit.queryAppUsagePriorityGroup +## bundleState.queryAppUsagePriorityGroup queryAppUsagePriorityGroup(callback: AsyncCallback): void - **系统能力**: @@ -85,19 +90,22 @@ SystemCapability.ResourceSchedule.UsageStatistics.AppGroup | -------- | -------- | -------- | -------- | | callback | AsyncCallback | 是 | 指定的callback回调方法。返回当前调用者应用的使用优先级群组。| +- **权限**: +无权限 + - **示例**: ``` stats.queryAppUsagePriorityGroup((err, res) => { - if(err.data === 0) { - console.log('queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); + if(err.code === 0) { + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); } else { - console.log('queryAppUsagePriorityGroup callback failed. because: ' + err.data); + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code); } }); ``` -## usagestatskit.queryAppUsagePriorityGroup +## bundleState.queryAppUsagePriorityGroup queryAppUsagePriorityGroup(): Promise - **系统能力**: @@ -112,17 +120,20 @@ SystemCapability.ResourceSchedule.UsageStatistics.AppGroup | -------- | -------- | | Promise | 指定的Promise回调方法。查询(返回)当前调用者应用的使用优先级群组。| +- **权限**: +无权限 + - **示例**: ``` stats.queryAppUsagePriorityGroup().then( res => { - console.log('queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); }).catch( err => { - console.log('queryAppUsagePriorityGroup promise failed. because: ' + err.data); + console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code); }); ``` -## usagestatskit.queryBundleStateInfos +## bundleState.queryBundleStateInfos queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback): void - **系统能力**: @@ -139,25 +150,28 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | end | number | 是 | 结束时间。| | callback | AsyncCallback | 是 | 指定的callback回调方法。返回指定起始和结束时间内应用使用时长统计信息。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleStateInfos(0, 20000000000000, (err, res) => { - console.log('queryBundleStateInfos callback succeeded, data number: ' + res.length); - if(err.data == 0) { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback success.'); + let i = 1; for(let key in res){ - console.log("queryBundleStateInfos callback key = " + key) - console.log("queryBundleStateInfos callback bundleName = " + res[key].bundleName) - console.log("queryBundleStateInfos callback abilityPrevAccessTime = " + res[key].abilityPrevAccessTime) - console.log("queryBundleStateInfos callback abilityInFgTotalTime = " + res[key].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback number : ' + i); + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback result ' + JSON.stringify(res[key])); + i++; } } else { - console.log('queryBundleStateInfos callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code); } }); ``` -## usagestatskit.queryBundleStateInfos +## bundleState.queryBundleStateInfos queryBundleStateInfos(begin: number, end: number): Promise - **系统能力**: @@ -179,23 +193,26 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | -------- | -------- | | Promise | 指定的Promise回调方法。返回指定起始和结束时间内应用使用时长统计信息。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleStateInfos(0, 20000000000000).then( res => { - console.log('queryBundleStateInfos promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.'); + let i = 1; for(let key in res){ - console.log("queryBundleStateInfos promise key = " + key) - console.log("queryBundleStateInfos promise bundleName = " + res[key].bundleName) - console.log("queryBundleStateInfos promise abilityPrevAccessTime = " + res[key].abilityPrevAccessTime) - console.log("queryBundleStateInfos promise abilityInFgTotalTime = " + res[key].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise number : ' + i); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise result ' + JSON.stringify(res[key])); + i++; } }).catch( err => { - console.log('queryBundleStateInfos promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code); }); ``` -## usagestatskit.queryBundleStateInfoByInterval +## bundleState.queryBundleStateInfoByInterval queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback>): void - **系统能力**: @@ -213,24 +230,26 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | end | number | 是 | 结束时间。| | callback | AsyncCallback> | 是 | 指定的callback回调方法。返回指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => { - console.log('queryBundleStateInfoByInterval callback succeeded, data number: ' + res.length); - if(err.data == 0) { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleStateInfoByInterval, callback bundleName = " + res[i].bundleName) - console.log("queryBundleStateInfoByInterval, callback abilityPrevAccessTime = " + res[i].abilityPrevAccessTime) - console.log("queryBundleStateInfoByInterval, callback abilityInFgTotalTime = " + res[i].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback result ' + JSON.stringify(res[i])); } } else { - console.log('queryBundleStateInfoByInterval callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code); } }); ``` -## usagestatskit.queryBundleStateInfoByInterval +## bundleState.queryBundleStateInfoByInterval queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number): Promise> - **系统能力**: @@ -253,22 +272,24 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | -------- | -------- | | Promise> | 指定的Promise回调方法。返回指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => { - console.log('queryBundleStateInfoByInterval promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleStateInfoByInterval, promise bundleName = " + res[i].bundleName) - console.log("queryBundleStateInfoByInterval, promise abilityPrevAccessTime = " + res[i].abilityPrevAccessTime) - console.log("queryBundleStateInfoByInterval, promise abilityInFgTotalTime = " + res[i].abilityInFgTotalTime) + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryBundleStateInfoByiInterval promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code); }); ``` -## usagestatskit.queryBundleActiveStates +## bundleState.queryBundleActiveStates queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void - **系统能力**: @@ -285,24 +306,26 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | end | number | 是 | 结束时间。| | callback | AsyncCallback> | 是 | 指定的callback回调方法。返回指定起始和结束时间查询所有应用的事件集合。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleActiveStates(0, 20000000000000, (err, res) => { - console.log('queryBundleActiveStates callback succeeded, data number: ' + res.length); - if(err.data == 0) { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleActiveStates, callback bundleName = " + res[i].bundleName) - console.log("queryBundleActiveStates, callback stateType = " + res[i].stateType) - console.log("queryBundleActiveStates, callback stateOccurredTime = " + res[i].stateOccurredTime) + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback result ' + JSON.stringify(res[i])); } } else { - console.log('queryBundleActiveStates callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code); } }); ``` -## usagestatskit.queryBundleActiveStates +## bundleState.queryBundleActiveStates queryBundleActiveStates(begin: number, end: number): Promise> - **系统能力**: @@ -324,22 +347,24 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | -------- | -------- | | Promise> | 指定的Promise回调方法。返回指定起始和结束时间查询所有应用的事件集合。| +- **权限**: +ohos.permission.BUNDLE_ACTIVE_INFO + - **示例**: ``` stats.queryBundleActiveStates(0, 20000000000000).then( res => { - console.log('queryBundleActiveStates promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryBundleActiveStates, promise bundleName = " + res[i].bundleName) - console.log("queryBundleActiveStates, promise stateType = " + res[i].stateType) - console.log("queryBundleActiveStates, promise stateOccurredTime = " + res[i].stateOccurredTime) + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryBundleActiveStates promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code); }); ``` -## usagestatskit.queryCurrentBundleActiveStates +## bundleState.queryCurrentBundleActiveStates queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback>): void - **系统能力**: @@ -356,24 +381,26 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | end | number | 是 | 结束时间。| | callback | AsyncCallback> | 是 | 指定的callback回调方法。返回指定起始和结束时间查询当前应用的事件集合。| +- **权限**: +无权限 + - **示例**: ``` - stats.queryCurrentBundleActiveStates(0, 20000000000000,(err, res) => { - console.log('queryCurrentBundleActiveStates callback succeeded, data number: ' + res.length); - if(err.data == 0) { + stats.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => { + if(err.code == 0) { + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback success.'); for (let i = 0; i < res.length; i++) { - console.log("queryCurrentBundleActiveStates, callback bundleName = " + res[i].bundleName) - console.log("queryCurrentBundleActiveStates, callback stateType = " + res[i].stateType) - console.log("queryCurrentBundleActiveStates, callback stateOccurredTime = " + res[i].stateOccurredTime) - } + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback result ' + JSON.stringify(res[i])); + } } else { - console.log('queryCurrentBundleActiveStates callback failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code); } }); ``` -## usagestatskit.queryCurrentBundleActiveStates +## bundleState.queryCurrentBundleActiveStates queryCurrentBundleActiveStates(begin: number, end: number): Promise> - **系统能力**: @@ -395,26 +422,30 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | -------- | -------- | | Promise> | 指定的Promise回调方法。返回指定起始和结束时间查询当前应用的事件集合。| +- **权限**: +无权限 + - **示例**: ``` stats.queryCurrentBundleActiveStates(0, 20000000000000).then( res => { - console.log('queryCurrentBundleActiveStates promise succeeded, data number: ' + res.length); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.'); for (let i = 0; i < res.length; i++) { - console.log("queryCurrentBundleActiveStates, promise bundleName = " + res[i].bundleName) - console.log("queryCurrentBundleActiveStates, promise stateType = " + res[i].stateType) - console.log("queryCurrentBundleActiveStates, promise stateOccurredTime = " + res[i].stateOccurredTime) + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise number : ' + (i + 1)); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise result ' + JSON.stringify(res[i])); } }).catch( err => { - console.log('queryCurrentBundleActiveStates promise failed, because: ' + err.data); + console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code); }); ``` -## usagestatskit.BundleStateInfo +## bundleState.BundleStateInfo - **系统能力**: SystemCapability.ResourceSchedule.UsageStatistics.App -提供应用使用时长的具体信息。 +- **参数**: + + 提供应用使用时长的具体信息。 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -422,11 +453,13 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | abilityPrevAccessTime | number | 是 | 应用最后一次使用的时间。| | abilityInFgTotalTime | number | 是 | 应用在前台使用的总时间。| -## usagestatskit.BundleActiveState +## bundleState.BundleActiveState - **系统能力**: SystemCapability.ResourceSchedule.UsageStatistics.App -提供应用事件的具体信息。 +- **参数**: + + 提供应用事件的具体信息。 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -434,21 +467,25 @@ SystemCapability.ResourceSchedule.UsageStatistics.App | stateType | number | 是 | 应用事件类型。| | stateOccurredTime | number | 是 | 应用事件发生的时间戳。| -## usagestatskit.BundleActiveInfoResponse +## bundleState.BundleActiveInfoResponse - **系统能力**: SystemCapability.ResourceSchedule.UsageStatistics.App -提供应用使用时长的具体信息。 +- **参数**: + + 提供应用使用时长的具体信息。 | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | [key: string]: BundleStateInfo | BundleStateInfo | 是 | 不同应用的使用时长统计信息。| -## usagestatskit.IntervalType +## bundleState.IntervalType - **系统能力**: SystemCapability.ResourceSchedule.UsageStatistics.App -触发工作的网络类型。 +- **参数**: + + 提供查询的类型 |名称 |默认值 |说明| | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md b/zh-cn/application-dev/reference/apis/js-apis-eventhub.md index 265e5f01827e5b0b9a74747fcae4f6e1027396a3..073acbb3c5b2c76248ea5a36ee98175df4a76473 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-eventhub.md +++ b/zh-cn/application-dev/reference/apis/js-apis-eventhub.md @@ -1,16 +1,10 @@ # EventHub -- [使用说明](#使用说明) -- [on](#on) -- [off](#off) -- [emit](#emit) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。 +> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 -事件中心。提供订阅、取消订阅、触发事件能力。 +事件中心,提供订阅、取消订阅、触发事件能力。 ## 使用说明 @@ -36,6 +30,10 @@ on(event: string, callback: Function): void; 订阅指定事件。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -71,6 +69,10 @@ off(event: string, callback?: Function): void; 取消订阅指定事件。当callback传值时,取消订阅指定的callback;未传值时,取消订阅该事件下所有callback。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -106,6 +108,10 @@ emit(event: string, ...args: Object[]): void; 触发指定事件。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-extension-context.md index 356b5605583fd2ea4cb9f108aa4f51901dd5b974..19ef7b6ee3dd7f51163024b94f2cf36c51991b5b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-extension-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-extension-context.md @@ -11,4 +11,4 @@ Extension的上下文环境,继承自Context。 | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| currentHapModuleInfo | HapModuleInfo | 是 | 否 | 当前Hap包的信息。 | +| currentHapModuleInfo | HapModuleInfo | 是 | 否 | 当前Hap包的信息。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | diff --git a/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md index aede4031e5fad55e705dc0f382bf10387c18dd3e..19ed0e0bc21061498f088df2ad6eb659bd16a948 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-extensionrunninginfo.md @@ -1,12 +1,7 @@ # ExtensionRunningInfo -- [使用说明](#使用说明) - - [属性](#属性) -- [bundle.ExtensionAbilityType](#bundleExtensionAbilityType) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 8开始支持。 +> 本模块首批接口从API 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 Extension运行相关信息。 @@ -31,13 +26,13 @@ abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => { | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| extension | ElementName | 是 | 否 | Extension匹配信息。 | -| pid | number | 是 | 否 | 进程ID。 | -| uid | number | 是 | 否 | 用户ID。 | -| processName | string | 是 | 否 | 进程名称。 | -| startTime | number | 是 | 否 | Extension启动时间。 | -| clientPackage | Array<String> | 是 | 否 | 连接客户端包名。 | -| type | [bundle.ExtensionAbilityType](#bundle-extensionabilitytype) | 是 | 否 | Extension类型。 | +| extension | ElementName | 是 | 否 | Extension匹配信息。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| pid | number | 是 | 否 | 进程ID。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| uid | number | 是 | 否 | 用户ID。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| processName | string | 是 | 否 | 进程名称。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| startTime | number | 是 | 否 | Extension启动时间。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| clientPackage | Array<String> | 是 | 否 | 表示当期进程下的所有包名。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| type | [bundle.ExtensionAbilityType](#bundle-extensionabilitytype) | 是 | 否 | Extension类型。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | ## bundle.ExtensionAbilityType @@ -46,13 +41,13 @@ Extension类型。 | 名称 | 值 | 说明 | | -------- | -------- | -------- | -| FORM | 0 | 表示带有form类型的扩展信息。 | -| WORK_SCHEDULER | 1 | 表示带有work schedule类型的扩展信息。 | -| INPUT_METHOD | 2 | 表示用输入法类型的扩展信息。 | -| SERVICE | 3 | 表示带有service类型的扩展信息。 | -| ACCESSIBILITY | 4 | 表示具有可访问性类型的扩展信息。 | -| DATA_SHARE | 5 | 表示带有datashare类型的扩展信息。 | -| FILE_SHARE | 6 | 表示带有fileshare类型的扩展信息。 | -| STATIC_SUBSCRIBER | 7 | 表示带有静态订阅者类型的扩展信息。 | -| WALLPAPER | 8 | 表示带有wallpaper类型的扩展信息。 | -| UNSPECIFIED | 9 | 表示未指定类型信息。 | +| FORM | 0 | 表示带有form类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | +| WORK_SCHEDULER | 1 | 表示带有work scheduler类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | +| INPUT_METHOD | 2 | 表示用输入法类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | +| SERVICE | 3 | 表示带有service类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | +| ACCESSIBILITY | 4 | 表示具有可访问性类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | +| DATA_SHARE | 5 | 表示带有datashare类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | +| FILE_SHARE | 6 | 表示带有fileshare类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | +| STATIC_SUBSCRIBER | 7 | 表示带有静态订阅者类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | +| WALLPAPER | 8 | 表示带有wallpaper类型的扩展信息。
系统能力:SystemCapability.BundleManager.BundleFramework | +| UNSPECIFIED | 9 | 表示未指定类型信息。
系统能力:SystemCapability.BundleManager.BundleFramework | diff --git a/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md b/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md index f27debab52af246072586d603dc599801b065e03..9ea0cbac0f5e00ae9f4dffacabb88256580d59fc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md +++ b/zh-cn/application-dev/reference/apis/js-apis-faultLogger.md @@ -73,7 +73,7 @@ function queryFaultLogCallback(error, value) { } } } -faultLogger.querySelfFaultLog(faultlogger.FaultType.JS_CRASH, queryFaultLogCallback); +faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH, queryFaultLogCallback); ``` ## faultLogger.querySelfFaultLog @@ -97,20 +97,22 @@ querySelfFaultLog(faultType: FaultType) : Promise<Array<FaultLogInfo>&g **示例:** ``` -let value = await faultLogger.querySelfFaultLog(faultlogger.FaultType.JS_CRASH); -if (value) { - console.info("value length is " + value.length); - let len = value.length; - for (let i = 0; i < len; i++) { - console.info("log: " + i); - console.info("Log pid: " + value[i].pid); - console.info("Log uid: " + value[i].uid); - console.info("Log type: " + value[i].type); - console.info("Log ts: " + value[i].ts); - console.info("Log reason: " + value[i].reason); - console.info("Log module: " + value[i].module); - console.info("Log summary: " + value[i].summary); - console.info("Log text: " + value[i].fullLog); +async function getLog() { + let value = await faultLogger.querySelfFaultLog(faultLogger.FaultType.JS_CRASH); + if (value) { + console.info("value length is " + value.length); + let len = value.length; + for (let i = 0; i < len; i++) { + console.info("log: " + i); + console.info("Log pid: " + value[i].pid); + console.info("Log uid: " + value[i].uid); + console.info("Log type: " + value[i].type); + console.info("Log ts: " + value[i].ts); + console.info("Log reason: " + value[i].reason); + console.info("Log module: " + value[i].module); + console.info("Log summary: " + value[i].summary); + console.info("Log text: " + value[i].fullLog); + } } } -``` \ No newline at end of file +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md b/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md index a2fb9c0522e8711b967f0545f08298a99bdbb005..8a6528d5fd6033379e230df975097250dd204662 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-featureAbility.md @@ -16,6 +16,10 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\) 启动新的ability(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -53,6 +57,10 @@ startAbility(parameter: StartAbilityParameter): Promise\ 启动新的ability(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -89,6 +97,10 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper 获取dataAbilityHelper。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -116,6 +128,10 @@ startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\ 启动一个ability,并在该ability被销毁时返回执行结果(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -151,6 +167,10 @@ startAbilityForResult(parameter: StartAbilityParameter): Promise\ 启动一个ability,并在该ability被销毁时返回执行结果(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -204,6 +224,10 @@ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\ 设置此Page Ability将返回给调用者的结果代码和数据并破坏此Page Ability(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -250,6 +274,10 @@ terminateSelfWithResult(parameter: AbilityResult): Promise\ 设置此Page Ability将返回给调用者的结果代码和数据并破坏此Page Ability(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -304,6 +332,10 @@ hasWindowFocus(callback: AsyncCallback\): void 检查Ability的主窗口是否具有窗口焦点(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -325,6 +357,10 @@ hasWindowFocus(): Promise\ 检查Ability的主窗口是否具有窗口焦点(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **返回值:** | 类型 | 说明 | @@ -348,6 +384,10 @@ getWant(callback: AsyncCallback\): void 获取从Ability发送的Want(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -369,6 +409,10 @@ getWant(): Promise\ 获取从Ability发送的Want(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **返回值:** | 类型 | 说明 | | ----------------------- | ------------------------- | @@ -389,6 +433,10 @@ getContext(): Context 获取应用上下文。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **返回值:** | 类型 | 说明 | | ------- | -------------------- | @@ -410,6 +458,10 @@ terminateSelf(callback: AsyncCallback\): void 设置Page Ability返回给被调用方的结果代码和数据,并销毁此Page Ability(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -431,6 +483,10 @@ terminateSelf(): Promise\ 设置Page Ability返回给被调用方的结果代码和数据,并销毁此Page Ability(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **返回值:** | 类型 | 说明 | | -------------- | ------------------------- | @@ -450,6 +506,10 @@ connectAbility(request: Want, options:ConnectOptions): number 将当前ability连接到指定ServiceAbility(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -461,17 +521,17 @@ connectAbility(request: Want, options:ConnectOptions): number | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ------------ | -------- | -------- | ---- | ---------------------------------- | -| deviceId | 只读 | string | 否 | 表示被连接的ServiceAbility的设备id,缺省表示连接本地的ServiceAbility | -| bundleName | 只读 | string | 是 | 表示被连接的ServiceAbility的包名 | -| abilityName | 只读 | string | 是 | 表示被连接的ServiceAbility的类名 | +| deviceId | 只读 | string | 否 | 表示被连接的ServiceAbility的设备id,缺省表示连接本地的ServiceAbility
系统能力:SystemCapability.Ability.AbilityBase | +| bundleName | 只读 | string | 是 | 表示被连接的ServiceAbility的包名
系统能力:SystemCapability.Ability.AbilityBase | +| abilityName | 只读 | string | 是 | 表示被连接的ServiceAbility的类名
系统能力:SystemCapability.Ability.AbilityBase | **ConnectOptions类型说明:** | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ------------ | -------- | -------- | ---- | ---------------------------------- | -| onConnect | 只读 | function | 是 | 连接成功时的回调函数 | -| onDisconnect | 只读 | function | 是 | 连接失败时的回调函数 | -| onFailed | 只读 | function | 是 | ConnectAbility调用失败时的回调函数 | +| onConnect | 只读 | function | 是 | 连接成功时的回调函数
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| onDisconnect | 只读 | function | 是 | 连接失败时的回调函数
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| onFailed | 只读 | function | 是 | ConnectAbility调用失败时的回调函数
系统能力:SystemCapability.Ability.AbilityRuntime.Core | **返回值:** | 类型 | 说明 | @@ -512,6 +572,10 @@ disconnectAbility(connection: number, callback:AsyncCallback\): void 断开与指定ServiceAbility的连接(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -557,6 +621,10 @@ disconnectAbility(connection: number): Promise\ 断开与指定ServiceAbility的连接(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -596,227 +664,52 @@ var connId = featureAbility.connectAbility( var result = await featureAbility.disconnectAbility(connId); ``` -## featureAbility.continueAbility - -continueAbility(options: ContinueAbilityOptions, callback: AsyncCallback\): void - -迁移一个ability到目标设备,并返回执行结果(callback形式)。 - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| -------- | ---------------------- | ---- | ------------------- | -| options | ContinueAbilityOptions | 是 | 表示被启动的Ability | -| callback | AsyncCallback\ | 是 | 被指定的回调方法 | - -**ContinueAbilityOptions类型说明:** - -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| ---------- | -------- | ------- | ---- | ------------------------------------------------------------ | -| deviceId | 只读 | string | 是 | 表示需要包含有关目标启动能力的信息。 | -| reversible | 只读 | boolean | 是 | 是否支持回迁的标志,目前不支持该功能,为保留字段,可填false。 | - -**示例:** - -```javascript -import device from '@system.device' -import ability from '@ohos.ability.featureability' - -var DEVICE_LIST_LOCALHOST -export default { - data: { - title: "", - deviceId: '', - deviceList: [], - remoteDeviceModel : new RemoteDeviceModel() - }, - onInit() { - DEVICE_LIST_LOCALHOST = { - id: 'localhost', - }; - this.deviceList = [DEVICE_LIST_LOCALHOST]; - }, - onShow() { - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.init() - const configService = core.getDefaultService('config') - configService.setConfig(this) - core.execute() - }, - onReady() { - }, - GetNetWorkId(){ - let self = this; - this.remoteDeviceModel.registerDeviceListCallback(() => { - var list = []; - list[0] = DEVICE_LIST_LOCALHOST; - var deviceList = self.remoteDeviceModel.deviceList; - for (var i = 0; i < deviceList.length; i++) { - list[i] = { - id: deviceList[i].deviceId, - }; - } - self.deviceList = list; - }); - }, - ShowNetWorkId(){ - this.deviceId = this.deviceList[0].id; - }, - - async ContinueAbility(){ - function ContinueAbilityCallback(err) { - console.info("=============>ContinueAbilityCallback============>"); - } - var continueAbilityOptions = { - reversible: false, - deviceId: this.deviceId, - } - //continueAbility callback - await ability.continueAbility(continueAbilityOptions, ContinueAbilityCallback); - }, -} -``` - -## featureAbility.continueAbility - -continueAbility(options: ContinueAbilityOptions): Promise\; - -迁移一个ability到目标设备,并返回执行结果(Promise形式)。 - -**参数:** - -| 名称 | 类型 | 必填 | 描述 | -| ------- | ---------------------- | ---- | ------------------- | -| options | ContinueAbilityOptions | 是 | 表示被启动的Ability | - -**ContinueAbilityOptions类型说明:** - -| 名称 | 读写属性 | 类型 | 必填 | 描述 | -| ---------- | -------- | ------- | ---- | ------------------------------------------------------------ | -| deviceId | 只读 | string | 是 | 表示需要包含有关目标启动能力的信息。 | -| reversible | 只读 | boolean | 是 | 是否支持回迁的标志,目前不支持该功能,为保留字段,可填false。 | - -**示例:** - -```javascript -import device from '@system.device' -import ability from '@ohos.ability.featureability' - -var DEVICE_LIST_LOCALHOST -export default { - data: { - title: "", - deviceId: '', - deviceList: [], - remoteDeviceModel : new RemoteDeviceModel() - }, - onInit() { - DEVICE_LIST_LOCALHOST = { - id: 'localhost', - }; - this.deviceList = [DEVICE_LIST_LOCALHOST]; - }, - onShow() { - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.init() - const configService = core.getDefaultService('config') - configService.setConfig(this) - core.execute() - }, - onReady() { - }, - GetNetWorkId(){ - let self = this; - this.remoteDeviceModel.registerDeviceListCallback(() => { - var list = []; - list[0] = DEVICE_LIST_LOCALHOST; - var deviceList = self.remoteDeviceModel.deviceList; - for (var i = 0; i < deviceList.length; i++) { - list[i] = { - id: deviceList[i].deviceId, - }; - } - self.deviceList = list; - }); - }, - ShowNetWorkId(){ - this.deviceId = this.deviceList[0].id; - }, - - async ContinueAbility(){ - function ContinueAbilityCallback(err) { - console.info("=============>ContinueAbilityCallback============>"); - } - var continueAbilityOptions = { - reversible: false, - deviceId: this.deviceId, - } - //continueAbility promise - await ability.continueAbility(continueAbilityOptions).then(() => { - console.info("=======>continueAbilityCallback=========>"); - }); - }, -} -``` - ## AbilityResult | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ---------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | -| resultCode | 只读 | number | 是 | 指示销毁该能力后返回的结果代码。您可以定义结果代码来识别错误(暂不支持) | -| want | 只读 | [Want](#want) | 否 | 指示销毁该能力后返回的数据。您可以定义返回的数据。此参数可以为null。 | +| resultCode | 只读 | number | 是 | 指示销毁该能力后返回的结果代码。您可以定义结果代码来识别错误(暂不支持)
系统能力:SystemCapability.Ability.AbilityBase | +| want | 只读 | [Want](#want) | 否 | 指示销毁该能力后返回的数据。您可以定义返回的数据。此参数可以为null。
系统能力:SystemCapability.Ability.AbilityBase | ## StartAbilityParameter | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| want | 只读 | [Want](#want) | 是 | 表示需要包含有关目标启动能力的信息。 | -| abilityStartSetting | 只读 | {[key: string]: any} | 否 | 表示能力的特殊属性,当开发者启动能力时,该属性可以作为调用中的输入参数传递。 | +| want | 只读 | [Want](#want) | 是 | 表示需要包含有关目标启动能力的信息。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | +| abilityStartSetting | 只读 | {[key: string]: any} | 否 | 表示能力的特殊属性,当开发者启动能力时,该属性可以作为调用中的输入参数传递。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | ## Want | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| deviceId | 只读 | string | 否 | 表示运行指定Ability的设备ID。 | -| bundleName | 只读 | string | 否 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | -| abilityName | 只读 | string | 否 | 表示待启动的Ability名称。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | -| uri | 只读 | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 | -| type | 只读 | string | 否 | 表示MIME type类型描述,比如:"text/plain" 、 "image/*"等。 | -| flags | 只读 | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](#flags说明)。 | -| action | 只读 | string | 否 | 表示action选项描述。 | -| parameters | 只读 | {[key: string]: any} | 否 | 表示WantParams描述。 | -| entities | 只读 | Array\ | 否 | 表示entities相关描述。 | +| deviceId | 只读 | string | 否 | 表示运行指定Ability的设备ID。
系统能力:SystemCapability.Ability.AbilityBase | +| bundleName | 只读 | string | 否 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。
系统能力:SystemCapability.Ability.AbilityBase | +| abilityName | 只读 | string | 否 | 表示待启动的Ability名称。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。
系统能力:SystemCapability.Ability.AbilityBase | +| uri | 只读 | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。
系统能力:SystemCapability.Ability.AbilityBase | +| type | 只读 | string | 否 | 表示MIME type类型描述,比如:"text/plain" 、 "image/*"等。
系统能力:SystemCapability.Ability.AbilityBase | +| flags | 只读 | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](#flags说明)。
系统能力:SystemCapability.Ability.AbilityBase | +| action | 只读 | string | 否 | 表示action选项描述。
系统能力:SystemCapability.Ability.AbilityBase | +| parameters | 只读 | {[key: string]: any} | 否 | 表示WantParams描述。
系统能力:SystemCapability.Ability.AbilityBase | +| entities | 只读 | Array\ | 否 | 表示entities相关描述。
系统能力:SystemCapability.Ability.AbilityBase | ## flags说明 | 名称 | 参数 | 描述 | | ------------------------------------ | ---------- | ------------------------------------------------------------ | -| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | 指示对URI执行读取操作的授权 | -| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | 指示对URI执行写入操作的授权 | -| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | 将结果返回给元能力 | -| FLAG_ABILITY_CONTINUATION | 0x00000008 | 确定是否可以将本地设备上的功能迁移到远程设备 | -| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | 指定组件是否属于OHOS | -| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | 指定是否启动某个能力 | -| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上可能持久化的授权 | -| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 按照前缀匹配的方式验证URI权限 | -| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支持分布式调度系统中的多设备启动 | -| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | 指示无论主机应用程序是否已启动,都将启动使用服务模板的功能 | -| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示迁移是可拉回的。 | -| FLAG_INSTALL_ON_DEMAND | 0x00000800 | 如果未安装指定的功能,请安装该功能 | -| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | 如果未安装,使用后台模式安装该功能。 | -| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | 指示清除其他任务的操作。可以为传递给**ohos.app.Context#startAbility**的**Want**设置此标志,并且必须与**flag_ABILITY_NEW_MISSION**一起使用 | -| FLAG_ABILITY_NEW_MISSION | 0x10000000 | 指示在历史任务堆栈上创建任务的操作。 | -| FLAG_ABILITY_MISSION_TOP | 0x20000000 | 指示如果启动能力的现有实例已位于任务堆栈的顶部,则将重用该实例。否则,将创建一个新的能力实例。 | +| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | 指示对URI执行读取操作的授权
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | 指示对URI执行写入操作的授权
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | 将结果返回给元能力
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION | 0x00000008 | 确定是否可以将本地设备上的功能迁移到远程设备
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | 指定组件是否属于OHOS
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | 指定是否启动某个能力
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上可能持久化的授权
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 按照前缀匹配的方式验证URI权限
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支持分布式调度系统中的多设备启动
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | 指示无论主机应用程序是否已启动,都将启动使用服务模板的功能
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示迁移是可拉回的。
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_ON_DEMAND | 0x00000800 | 如果未安装指定的功能,请安装该功能
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | 如果未安装,使用后台模式安装该功能。
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | 指示清除其他任务的操作。可以为传递给**ohos.app.Context#startAbility**的**Want**设置此标志,并且必须与**flag_ABILITY_NEW_MISSION**一起使用
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_NEW_MISSION | 0x10000000 | 指示在历史任务堆栈上创建任务的操作。
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_MISSION_TOP | 0x20000000 | 指示如果启动能力的现有实例已位于任务堆栈的顶部,则将重用该实例。否则,将创建一个新的能力实例。
系统能力:SystemCapability.Ability.AbilityBase | diff --git a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md index 5c520aef02ef740eb995f5deaaf250815dd969c6..28aacbace59ca9b96e5eb76d9cbdef16c839be89 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md @@ -4,7 +4,7 @@ ## 导入模块 ```js -import filemanager from 'ohos.filemanager'; +import filemanager from '@ohos.fileManager'; ``` ## 系统能力 @@ -71,7 +71,7 @@ filemanager.getRoot((err, fileInfo) => { listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}) : Promise<FileInfo[]> -以异步方法获取获取第二层相册,文件信息。使用promise形式返回结果。 +以异步方法获取第二层相册,文件信息。使用promise形式返回结果。 - 参数 | 参数名 | 类型 | 必填 | 说明 | @@ -106,8 +106,7 @@ filemanager.listFile(media_path, "file") console.log(JSON.Stringify(fileInfo)) } } -}) -.catch((err) => { +}).catch((err) => { console.log(err) }) ``` @@ -115,7 +114,7 @@ filemanager.listFile(media_path, "file") listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : number, count? : number}, callback : AsyncCallback<FileInfo[]>) : void -以异步方法获取获取第二层相册,文件信息。使用callback形式返回结果。 +以异步方法获取第二层相册,文件信息。使用callback形式返回结果。 - 参数 diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md index b2c3bd80907fdaff2143f0ef29e2855b587d3119..004c08485c77990b80c00b78192ce033e1a0f27d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md @@ -53,7 +53,7 @@ isEmpty(): boolean ``` const hashMap = new HashMap(); -hashMap.isEmpty(); +let result = hashMap.isEmpty(); ``` @@ -79,9 +79,9 @@ hasKey(key: K): boolean ``` let hashMap = new HashMap(); -hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result1 = hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); ``` @@ -107,9 +107,9 @@ hasValue(value: V): boolean ``` let hashMap = new HashMap(); -hashMap.hasValue(123); +let result = hashMap.hasValue(123); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -hashMap.hasValue(123); +let result1 = hashMap.hasValue(123); ``` @@ -137,7 +137,7 @@ get(key: K): V let hashMap = new HashMap(); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("sdfs", 356); -hashMap.get("sdfs"); +let result = hashMap.get("sdfs"); ``` @@ -145,13 +145,13 @@ hashMap.get("sdfs"); setAll(map: HashMap): void -将一个HashMap中的所有元素组添加到另一个hashmap中。 +将一个HashMap中的所有元素组添加到另一个hashMap中。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| map | HashMap | 是 | 被添加元素的hashmap。 | +| map | HashMap | 是 | 被添加元素的hashMap。 | **示例:** @@ -181,13 +181,13 @@ set(key: K, value: V): Object | 类型 | 说明 | | -------- | -------- | -| Object | 返回添加后的hashmap。 | +| Object | 返回添加后的hashMap。 | **示例:** ``` let hashMap = new HashMap(); -hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +let result = hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); ``` @@ -195,13 +195,13 @@ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); remove(key: K): V -删除指定的元素。 +删除指定key所对应元素。。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | K | 是 | 依据key指定删除的元素。 | +| key | K | 是 | 指定key。 | **返回值:** @@ -215,7 +215,7 @@ remove(key: K): V let hashMap = new HashMap(); hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); hashMap.set("sdfs", 356); -hashMap.remove("sdfs"); +let result = hashMap.remove("sdfs"); ``` @@ -239,7 +239,7 @@ hashMap.clear(); keys(): IterableIterator<K> -返回包含此映射中包含的键的新迭代器对象。 +返回包含此映射中包含的键名的新迭代器对象。 **返回值:** @@ -291,7 +291,7 @@ while(temp != undefined) { ### replace -replace(key: K, value: V): boolean +replace(key: K, newValue: V): boolean 对HashMap中一组数据进行更新(替换)。 @@ -300,7 +300,7 @@ replace(key: K, value: V): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | key | K | 是 | 依据key指定替换的元素。 | -| value | V | 是 | 成员数据的新值。 | +| newValue | V | 是 | 替换成员数据的值。 | **返回值:** @@ -313,13 +313,13 @@ replace(key: K, value: V): boolean ``` let hashMap = new HashMap(); hashMap.set("sdfs", 123); -hashMap.replace("sdfs", 357); +let result = hashMap.replace("sdfs", 357); ``` ### forEach -forEach(callbackfn: (value: V, key?: K, hashMap?: HashMap) => void, thisArg?: Object): void +forEach(callbackfn: (value: V, key?: K, map?: HashMap) => void, thisArg?: Object): void 通过回调函数来遍历HashMap实例对象上的元素以及元素对应的下标。 @@ -335,7 +335,7 @@ callbackfn的参数说明: | -------- | -------- | -------- | -------- | | value | V | 是 | 当前遍历到的元素键值对的值。 | | key | K | 是 | 当前遍历到的元素键值对的键。 | -| hashMap | HashMap | 否 | 当前调用forEach方法的实例对象。 | +| map | HashMap | 否 | 当前调用forEach方法的实例对象。 | **示例:** @@ -353,7 +353,7 @@ hashMap.forEach((value, key) => { entries(): IterableIterator<[K, V]> -返回包含此映射中包含的元素的新迭代器对象。 +返回包含此映射中包含的键值对的新迭代器对象。 **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashset.md b/zh-cn/application-dev/reference/apis/js-apis-hashset.md index 5dd797f1c6e122e776b7702f7710f0da98e8ee66..8a0556e94cd954f73906bc690db303a03544b2b4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hashset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hashset.md @@ -79,9 +79,9 @@ has(value: T): boolean ``` let hashSet = new HashSet(); -hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result1 = hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); ``` @@ -107,7 +107,7 @@ add(value: T): boolean ``` let hashSet = new HashSet(); -hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); ``` @@ -135,7 +135,7 @@ remove(value: T): boolean let hashSet = new HashSet(); hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); hashSet.add("sdfs"); -hashSet.remove("sdfs"); +let result = hashSet.remove("sdfs"); ``` @@ -184,7 +184,7 @@ while(temp != undefined) { ### forEach -forEach(callbackfn: (value: T, key?: T, hashSet?: HashSet<T>) => void, thisArg?: Object): void +forEach(callbackfn: (value: T, key?: T, set?: HashSet<T>) => void, thisArg?: Object): void 通过回调函数来遍历实例对象上的元素以及元素对应的下标。 @@ -200,7 +200,7 @@ callbackfn的参数说明: | -------- | -------- | -------- | -------- | | value | T | 是 | 当前遍历到的元素键值对的值。 | | key | T | 否 | 当前遍历到的元素键值对的值(和value相同)。 | -| hashSet | HashSet<T> | 否 | 当前调用forEach方法的实例对象。 | +| set | HashSet<T> | 否 | 当前调用forEach方法的实例对象。 | **示例:** @@ -217,13 +217,13 @@ hashSet.forEach((value, key) => { ### entries entries(): IterableIterator<[T, T]> -返回包含此映射中包含的元素的新迭代器对象。 +返回包含此映射中包含的键值对的新迭代器对象。 **返回值:** | 类型 | 说明 | | -------- | -------- | -| IterableIterator<[T, T]> | 返回一个迭代器 | +| IterableIterator<[T, T]> | 返回一个迭代器。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-hidebug.md b/zh-cn/application-dev/reference/apis/js-apis-hidebug.md index 26465fc22356ad95f4a12170c2db7c388730b278..a1afa0de30574b69604c64c2c36ee2c746ed29a1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hidebug.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hidebug.md @@ -107,7 +107,7 @@ getSharedDirty(): bigint - 示例: ``` - let sharedDirty = hidebug.getSharedDirty()); + let sharedDirty = hidebug.getSharedDirty(); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md b/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md index be311c04091759a71f028810d802ab6d50a82917..78d3e21d8b0170012c399610cca5c05fd1c394d7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hitracechain.md @@ -58,7 +58,7 @@ SystemCapability.HiviewDFX.HiTrace | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | chainId | bigint | 是 | 跟踪链标识。 | -| spandId | number | 否 | 分支标识。 | +| spanId | number | 否 | 分支标识。 | | parentSpanId | number | 否 | 父分支标识。 | | flags | number | 否 | 跟踪标志组合。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-hitracemeter.md b/zh-cn/application-dev/reference/apis/js-apis-hitracemeter.md index d2bf527c44cba236d0073226ba569c4b40d040bd..0af8413c1b2848944df2a1e83c3f931193b63241 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hitracemeter.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hitracemeter.md @@ -18,7 +18,7 @@ SystemCapability.HiviewDFX.HiTrace ## hiTraceMeter.startTrace -startTrace(name: string, taskId: number, expectedTime?: number): void +startTrace(name: string, taskId: number): void 标记一个预追踪耗时任务的开始,expectedTime是可选参数,标识该任务的期望耗时。 @@ -32,7 +32,6 @@ startTrace(name: string, taskId: number, expectedTime?: number): void | -------- | -------- | -------- | -------- | | name | string | 是 | 要追踪的任务名称 | | taskId | number | 是 | 任务id | -| expectedTime | number | 否 | 期望的耗时时间,单位:ms | **示例:** @@ -88,7 +87,7 @@ hiTraceMeter.finishTrace("myTestFunc", 1); ## hiTraceMeter.traceByValue -traceByValue(name: string, value: number): void +traceByValue(name: string, count: number): void 用来标记一个预追踪的数值变量,该变量的数值会不断变化。 @@ -97,7 +96,7 @@ traceByValue(name: string, value: number): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | name | string | 是 | 要追踪的数值变量名称 | -| value | number | 是 | 变量的值 | +| count | number | 是 | 变量的值 | **示例:** ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-http.md b/zh-cn/application-dev/reference/apis/js-apis-http.md new file mode 100644 index 0000000000000000000000000000000000000000..23b7eb543c2bf16fe372381abbb53fd19590916f --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-http.md @@ -0,0 +1,431 @@ +# 数据请求 + +>![](public_sys-resources/icon-note.gif) **说明:** +> +>本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +>本模块所有接口需要设备具有系统能力:SystemCapability.Communication.NetStack + +## 导入模块 + +``` +import http from '@ohos.net.http'; +``` + +## 完整示例 + +``` +import http from '@ohos.net.http'; + +// 每一个httpRequest对应一个http请求任务,不可复用 +let httpRequest = http.createHttp(); +// 用于订阅http响应头,此接口会比request请求先返回。可以根据业务需要订阅此消息 +// 从API 8开始,使用on('headersReceive', Callback)替代on('headerReceive', AsyncCallback)。 8+ +httpRequest.on('headersReceive', (data) => { + console.info('header: ' + data.header); +}); +httpRequest.request( + // 填写http请求的url地址,可以带参数也可以不带参数。URL地址需要开发者自定义。GET请求的参数可以在extraData中指定 + "EXAMPLE_URL", + { + method: 'POST', // 可选,默认为“GET” + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json' + }, + // 当使用POST请求时此字段用于传递内容 + + extraData: { + "data": "data to send", + }, + connectTimeout: 60000, // 可选,默认为60s + readTimeout: 60000, // 可选,默认为60s + },(err, data) => { + if (!err) { + // data.result为http响应内容,可根据业务需要进行解析 + console.info('Result:' + data.result); + console.info('code:' + data.responseCode); + // data.header为http响应头,可根据业务需要进行解析 + console.info('header:' + data.header); + console.info('cookies:' + data.cookies); // 8+ + } else { + console.info('error:' + err); + // 当该请求使用完毕时,调用destroy方法主动销毁。 + httpRequest.destroy(); + } + } +); +``` + +## http.createHttp + +createHttp\(\): HttpRequest + +创建一个http,里面包括发起请求、中断请求、订阅/取消订阅HTTP Response Header 事件。每一个HttpRequest对象对应一个Http请求。如需发起多个Http请求,须为每个Http请求创建对应HttpRequest对象。 + +**返回值:** + +| 类型 | 说明 | +| :---------- | :----------------------------------------------------------- | +| HttpRequest | 返回一个HttpRequest对象,里面包括request、destroy、on和off方法。 | + +**示例:** + +``` +import http from '@ohos.net.http'; +let httpRequest = http.createHttp(); +``` + + +## HttpRequest + +http请求任务。在调用HttpRequest的方法前,需要先通过[createHttp\(\)](#httpcreatehttp)创建一个任务。 + +### request + +request\(url: string, callback: AsyncCallback\\):void + +根据URL地址,发起HTTP网络请求,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ----------------------- | +| url | string | 是 | 发起网络请求的URL地址。 | +| callback | AsyncCallback\<[HttpResponse](#httpresponse)\> | 是 | 回调函数。 | + +**示例:** + +``` +let httpRequest = http.createHttp(); +httpRequest.request("EXAMPLE_URL", (err, data) => { + if (!err) { + console.info('Result:' + data.result); + console.info('code:' + data.responseCode); + console.info('header:' + data.header); + console.info('cookies:' + data.cookies); // 8+ + } else { + console.info('error:' + err.data); + } +}); +``` + +### request + +request\(url: string, options: HttpRequestOptions, callback: AsyncCallback\):void + +根据URL地址和相关配置项,发起HTTP网络请求,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------- | ---- | ----------------------------------------------- | +| url | string | 是 | 发起网络请求的URL地址。 | +| options | HttpRequestOptions | 是 | 参考[HttpRequestOptions](#httprequestoptions)。 | +| callback | AsyncCallback\<[HttpResponse](#httpresponse)\> | 是 | 回调函数。 | + +**示例:** + +``` +let httpRequest= http.createHttp(); +httpRequest.request("EXAMPLE_URL", +{ + method: 'GET', + header: { + 'Content-Type': 'application/json' + }, + readTimeout: 60000, + connectTimeout: 60000 +},(err, data) => { + if (!err) { + console.info('Result:' + data.result); + console.info('code:' + data.responseCode); + console.info('header:' + data.header); + console.info('cookies:' + data.cookies); // 8+ + console.info('header['Content-Type']:' + data.header['Content-Type']); + console.info('header['Status-Line']:' + data.header['Status-Line']); + console.info('header.Date:' + data.header.Date); + console.info('header.Server:' + data.header.Server); + } else { + console.info('error:' + err.data); + } +}); +``` + + +### request + +request\(url: string, options? : HttpRequestOptions\): Promise + +根据URL地址,发起HTTP网络请求,使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------------------ | ---- | -------------------------------------------------- | +| url | string | 是 | 发起网络请求的URL地址。 | +| options | HttpRequestOptions | 是 | 参考[HttpRequestOptions](#httprequestoptions)。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :-------------------------------- | +| Promise<[HttpResponse](#httpresponse)> | 以Promise形式返回发起请求的结果。 | + + +**示例:** + +``` +let httpRequest= http.createHttp(); +let promise = httpRequest.request("EXAMPLE_URL", { + method: "GET", + connectTimeout: 60000, + readTimeout: 60000, + header: { + 'Content-Type': 'application/json' + } +}); +promise.then((value) => { + console.info('Result:' + value.result); + console.info('code:' + value.responseCode); + console.info('header:' + value.header); + console.info('cookies:' + value.cookies); // 8+ + console.info('header['Content-Type']:' + value.header['Content-Type']); + console.info('header['Status-Line']:' + value.header['Status-Line']); + console.info('header.Date:' + value.header.Date); + console.info('header.Server:' + value.header.Server); +}).catch((err) => { + console.error(`errCode:${err.code}, errMessage:${err.data}`); +}); +``` + +### destroy + +destroy\(\): void + +中断请求任务。 + +**示例:** + +``` +let httpRequest= http.createHttp(); +httpRequest.destroy(); +``` + +### on\('headerReceive'\) + +on\(type: 'headerReceive', callback: AsyncCallback\):void + +订阅HTTP Response Header 事件。 + +>![](public_sys-resources/icon-note.gif) **说明:** +> 此接口已废弃,建议使用[on\('headersReceive'\)8+](#onheadersreceive8)替代。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | --------------------------------- | +| type | string | 是 | 订阅的事件类型,'headerReceive'。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +let httpRequest= http.createHttp(); +httpRequest.on('headerReceive', (err, data) => { + if (!err) { + console.info('header: ' + data.header); + } else { + console.info('error:' + err.data); + } +}); +``` + + +### off\('headerReceive'\) + +off\(type: 'headerReceive', callback?: AsyncCallback\):void + +取消订阅HTTP Response Header 事件。 + +>![](public_sys-resources/icon-note.gif) **说明:** +> +>1. 此接口已废弃,建议使用[off\('headersReceive'\)8+](#offheadersreceive8)替代。 +> +>2. 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ------------------------------------- | +| type | string | 是 | 取消订阅的事件类型,'headerReceive'。 | +| callback | AsyncCallback\ | 否 | 回调函数。 | + +**示例:** + +``` +let httpRequest= http.createHttp(); +httpRequest.on('headerReceive', (err, data) => { + if (!err) { + console.info('header: ' + data.header); + } else { + console.info('error:' + err.data); + } +}); +httpRequest.off('headerReceive'); +``` + +### on\('headersReceive'\)8+ + +on\(type: 'headersReceive', callback: Callback\):void + +订阅HTTP Response Header 事件。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------ | ---- | ---------------------------------- | +| type | string | 是 | 订阅的事件类型:'headersReceive'。 | +| callback | Callback\ | 是 | 回调函数。 | + +**示例:** + +``` +let httpRequest= http.createHttp(); +httpRequest.on('headersReceive', (data) => { + console.info('header: ' + data.header); +}); +``` + + +### off\('headersReceive'\)8+ + +off\(type: 'headersReceive', callback?: Callback\):void + +取消订阅HTTP Response Header 事件。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------ | ---- | -------------------------------------- | +| type | string | 是 | 取消订阅的事件类型:'headersReceive'。 | +| callback | Callback\ | 否 | 回调函数。 | + +**示例:** + +``` +let httpRequest= http.createHttp(); +httpRequest.off('headersReceive'); +``` + +### once\('headersReceive'\)8+ + +once\(type: "headersReceive", callback: Callback\): void + +订阅HTTP Response Header 事件,但是只触发一次。一旦触发之后,订阅器就会被移除。使用callback方式作为异步方法。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------ | ---- | ---------------------------------- | +| type | string | 是 | 订阅的事件类型:'headersReceive'。 | +| callback | Callback\ | 是 | 回调函数。 | + +**示例:** + +``` +let httpRequest= http.createHttp(); +httpRequest.once('headersReceive', (data) => { + console.info('header: ' + data.header); +}); +``` + +## HttpRequestOptions + +发起请求可选参数的类型和取值范围。 + +| 参数 | 类型 | 必填 | 说明 | +| -------------- | ------------------------------------ | ---- | ---------------------------------------------------------- | +| method | [RequestMethod](#requestmethod) | 否 | 请求方式。 | +| extraData | string \| Object \| ArrayBuffer8+ | 否 | 发送请求的额外数据。
- 当HTTP请求为POST、PUT等方法时,此字段为HTTP请求的content。
- 当HTTP请求为GET、OPTIONS、DELETE、TRACE、CONNECT等方法时,此字段为HTTP请求的参数补充,参数内容会拼接到URL中进行发送。8+
- 开发者传入string对象,开发者需要自行编码,将编码后的string传入。8+ | +| header | Object | 否 | HTTP请求头字段。默认{'Content-Type': 'application/json'}。 | +| readTimeout | number | 否 | 读取超时时间。单位为毫秒(ms),默认为60000ms。 | +| connectTimeout | number | 否 | 连接超时时间。单位为毫秒(ms),默认为60000ms。 | + +## RequestMethod + +HTTP 请求方法。 + +| **method 的合法值** | 说明 | +| :------------------ | :------------------ | +| OPTIONS | HTTP 请求 OPTIONS。 | +| GET | HTTP 请求 GET。 | +| HEAD | HTTP 请求 HEAD。 | +| POST | HTTP 请求 POST。 | +| PUT | HTTP 请求 PUT。 | +| DELETE | HTTP 请求 DELETE。 | +| TRACE | HTTP 请求 TRACE。 | +| CONNECT | HTTP 请求 CONNECT。 | + +## ResponseCode + +发起请求返回的响应码。 + +| 变量 | 值 | 说明 | +| ----------------- | ---- | ------------------------------------------------------------ | +| OK | 200 | 请求成功。一般用于GET与POST请求。 | +| CREATED | 201 | 已创建。成功请求并创建了新的资源。 | +| ACCEPTED | 202 | 已接受。已经接受请求,但未处理完成。 | +| NOT_AUTHORITATIVE | 203 | 非授权信息。请求成功。 | +| NO_CONTENT | 204 | 无内容。服务器成功处理,但未返回内容。 | +| RESET | 205 | 重置内容。 | +| PARTIAL | 206 | 部分内容。服务器成功处理了部分GET请求。 | +| MULT_CHOICE | 300 | 多种选择。 | +| MOVED_PERM | 301 | 永久移动。请求的资源已被永久的移动到新URI,返回信息会包括新的URI,浏览器会自动定向到新URI。 | +| MOVED_TEMP | 302 | 临时移动。 | +| SEE_OTHER | 303 | 查看其它地址。 | +| NOT_MODIFIED | 304 | 未修改。 | +| USE_PROXY | 305 | 使用代理。 | +| BAD_REQUEST | 400 | 客户端请求的语法错误,服务器无法理解。 | +| UNAUTHORIZED | 401 | 请求要求用户的身份认证。 | +| PAYMENT_REQUIRED | 402 | 保留,将来使用。 | +| FORBIDDEN | 403 | 服务器理解请求客户端的请求,但是拒绝执行此请求。 | +| NOT_FOUND | 404 | 服务器无法根据客户端的请求找到资源(网页)。 | +| BAD_METHOD | 405 | 客户端请求中的方法被禁止。 | +| NOT_ACCEPTABLE | 406 | 服务器无法根据客户端请求的内容特性完成请求。 | +| PROXY_AUTH | 407 | 请求要求代理的身份认证。 | +| CLIENT_TIMEOUT | 408 | 请求时间过长,超时。 | +| CONFLICT | 409 | 服务器完成客户端的PUT请求是可能返回此代码,服务器处理请求时发生了冲突。 | +| GONE | 410 | 客户端请求的资源已经不存在。 | +| LENGTH_REQUIRED | 411 | 服务器无法处理客户端发送的不带Content-Length的请求信息。 | +| PRECON_FAILED | 412 | 客户端请求信息的先决条件错误。 | +| ENTITY_TOO_LARGE | 413 | 由于请求的实体过大,服务器无法处理,因此拒绝请求。 | +| REQ_TOO_LONG | 414 | 请求的URI过长(URI通常为网址),服务器无法处理。 | +| UNSUPPORTED_TYPE | 415 | 服务器无法处理请求的格式。 | +| INTERNAL_ERROR | 500 | 服务器内部错误,无法完成请求。 | +| NOT_IMPLEMENTED | 501 | 服务器不支持请求的功能,无法完成请求。 | +| BAD_GATEWAY | 502 | 充当网关或代理的服务器,从远端服务器接收到了一个无效的请求。 | +| UNAVAILABLE | 503 | 由于超载或系统维护,服务器暂时的无法处理客户端的请求。 | +| GATEWAY_TIMEOUT | 504 | 充当网关或代理的服务器,未及时从远端服务器获取请求。 | +| VERSION | 505 | 服务器请求的HTTP协议的版本。 | + +## HttpResponse + +request方法回调函数的返回值类型。 + +| 参数名 | 类型 | 必填 | 说明 | +| -------------------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | +| result | string \| Object \| ArrayBuffer8+ | 是 | Http请求根据响应头中Content-type类型返回对应的响应格式内容:
- application/json:返回JSON格式的字符串,如需Http响应具体内容,需开发者自行解析
- application/octet-stream:ArrayBuffer
- 其他:string | +| responseCode | [ResponseCode](#responsecode) \| number | 是 | 回调函数执行成功时,此字段为[ResponseCode](#responsecode)。若执行失败,错误码将会从AsyncCallback中的err字段返回。错误码如下:
- 200:通用错误
- 202:参数错误
- 300:I/O错误 | +| header | Object | 是 | 发起http请求返回来的响应头。当前返回的是JSON格式字符串,如需具体字段内容,需开发者自行解析。常见字段及解析方式如下:
- Content-Type:header['Content-Type'];
- Status-Line:header['Status-Line'];
- Date:header.Date/header['Date'];
- Server:header.Server/header['Server']; | +| cookies8+ | Array\ | 是 | 服务器返回的 cookies。 | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-i18n.md b/zh-cn/application-dev/reference/apis/js-apis-i18n.md index 5d636d4ef4af3c33a6a604684aee859028ded636..e7d49645e542163fb2aa87724abd6d100fdb0d0b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-i18n.md +++ b/zh-cn/application-dev/reference/apis/js-apis-i18n.md @@ -13,17 +13,14 @@ import i18n from '@ohos.i18n'; ``` -## 权限 - -无 - - ## i18n.getDisplayLanguage getDisplayLanguage(language: string, locale: string, sentenceCase?: boolean): string 获取指定语言的本地化显示文本。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -49,6 +46,8 @@ getDisplayCountry(country: string, locale: string, sentenceCase?: boolean): stri 获取指定国家的本地化显示文本。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -74,6 +73,8 @@ isRTL(locale: string): boolean 获取是否为从右至左显示语言。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 说明 | | -------- | -------- | -------- | @@ -97,6 +98,8 @@ getSystemLanguage(): string 获取系统语言。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -108,12 +111,71 @@ getSystemLanguage(): string ``` +## i18n.setSystemLanguage + +setSystemLanguage(): boolean + +设置系统语言。 + +**系统能力**:SystemCapability.Global.I18n + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回true,表示系统语言设置成功;返回false,表示系统语言设置失败。 | + +- 示例: + ``` + i18n.setSystemLanguage(); + ``` + + +## i18n.getSystemLanguages + +getSystemLanguages(): Array + +获取系统支持的语言列表。 + +**系统能力**:SystemCapability.Global.I18n + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Array | 系统支持的语言ID列表。 | + +- 示例: + ``` + i18n.getSystemLanguages(); + ``` + + +## i18n.getSystemCountries + +getSystemCountries(): Array + +获取系统支持的区域列表。 + +**系统能力**:SystemCapability.Global.I18n + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | Array | 系统支持的区域ID列表。 | + +- 示例: + ``` + i18n.getSystemCountries(); + ``` + + ## i18n.getSystemRegion getSystemRegion(): string 获取系统地区。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -125,12 +187,33 @@ getSystemRegion(): string ``` +## i18n.setSystemRegion + +setSystemRegion(): boolean + +设置系统区域。 + +**系统能力**:SystemCapability.Global.I18n + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回true,表示系统区域设置成功;返回false,表示系统区域设置失败。 | + +- 示例: + ``` + i18n.setSystemRegion(); + ``` + + ## i18n.getSystemLocale getSystemLocale(): string 获取系统区域。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -142,12 +225,63 @@ getSystemLocale(): string ``` +## i18n.setSystemLocale + +setSystemLocale(locale: string): boolean + +设置系统Locale。 + +**系统能力**:SystemCapability.Global.I18n + +- 参数: + | 参数名 | 类型 | 说明 | + | -------- | -------- | -------- | + | locale | string | 指定区域ID,例如zh-CN。 | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回true,表示系统Locale设置成功;返回false,表示系统Locale设置失败。 | + +- 示例: + ``` + i18n.setSystemLocale('zh-CN'); + ``` + + +## i18n.isSuggested + +isSuggested(language: string, region?: string): boolean + +判断当前语言和区域是否匹配。 + +**系统能力**:SystemCapability.Global.I18n + +- 参数: + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | language | string | 是 | 合法的语言ID,例如zh。 | + | region | string | 否 | 合法的地区ID,例如CN | + +- 返回值: + | 类型 | 说明 | + | -------- | -------- | + | boolean | 返回true,表示当前语言和地区匹配;返回false,表示当前语言和地区不匹配。 | + +- 示例: + ``` + i18n.isSuggested('zh', 'CN'); + ``` + + ## i18n.getCalendar8+ getCalendar(locale: string, type? : string): Calendar 获取日历对象。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -174,6 +308,8 @@ setTime(date: Date): void 设置日历对象内部的时间日期。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -193,6 +329,8 @@ setTime(time: number): void 设置日历对象内部的时间日期, time为从1970.1.1 00:00:00 GMT逝去的毫秒数。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -211,6 +349,8 @@ set(year: number, month: number, date:number, hour?: number, minute?: number, se 设置日历对象的年、月、日、时、分、秒。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -234,6 +374,8 @@ setTimeZone(timezone: string): void 设置日历对象的时区。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -252,6 +394,8 @@ getTimeZone(): string 获取日历对象的时区。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -271,6 +415,8 @@ getFirstDayOfWeek(): number 获取日历对象的一周起始日。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -289,6 +435,8 @@ setFirstDayOfWeek(value: number): void 设置每一周的起始日。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -307,6 +455,8 @@ getMinimalDaysInFirstWeek(): number 获取一年中第一周的最小天数。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -325,6 +475,8 @@ setMinimalDaysInFirstWeek(value: number): void 设置一年中第一周的最小天数。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -343,6 +495,8 @@ get(field: string): number 获取日历对象中与field相关联的值。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -367,6 +521,8 @@ getDisplayName(locale: string): string 获取日历对象在locale所指定的区域的名字。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -390,6 +546,8 @@ isWeekend(date?: Date): boolean 判断给定的日期是否在日历中是周末。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -419,6 +577,8 @@ constructor(country: string, options?: PhoneNumberFormatOptions) 创建电话号码格式化对象。 +**系统能力**:SystemCapability.Global.I18n + 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -437,6 +597,8 @@ isValidNumber(number: string): boolean 判断传入的电话号码格式是否正确。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -460,6 +622,8 @@ format(number: string): string 对电话号码进行格式化。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -484,7 +648,7 @@ format(number: string): string | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| type | string | 是 | 是 | 表示对电话号码格式化的类型,取值范围:"E164", "INTERNATIONAL", "NATIONAL", "RFC3966"。 | +| type | string | 是 | 是 | 表示对电话号码格式化的类型,取值范围:"E164", "INTERNATIONAL", "NATIONAL", "RFC3966"。
**系统能力**:SystemCapability.Global.I18n | ## UnitInfo8+ @@ -495,7 +659,7 @@ format(number: string): string | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | | unit | string | 是 | 是 | 单位的名称,如:"meter", "inch", "cup"等。 | -| measureSystem | string | 是 | 是 | 单位的度量体系,取值包括:"SI", "US", "UK"。 | +| measureSystem | string | 是 | 是 | 单位的度量体系,取值包括:"SI", "US", "UK"。
**系统能力**:SystemCapability.Global.I18n | ## Util8+ @@ -507,6 +671,8 @@ unitConvert(fromUnit: UnitInfo, toUnit: UnitInfo, value: number, locale: string, 将fromUnit的单位转换为toUnit的单位,并根据区域与风格进行格式化。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -536,6 +702,8 @@ getInstance(): IndexUtil 创建并返回IndexUtil对象。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -558,6 +726,8 @@ getIndexList(): Array<string> 获取当前locale对应的索引列表。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -576,6 +746,8 @@ addLocale(locale: string) 将新的locale对应的索引加入当前索引列表。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -594,6 +766,8 @@ getIndex(text: string): string 获取text对应的索引。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -620,6 +794,8 @@ isDigit(char: string): boolean 判断字符串char是否是数字。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -642,6 +818,8 @@ isSpaceChar(char: string): boolean 判断字符串char是否是空格符。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -664,6 +842,8 @@ isWhitespace(char: string): boolean 判断字符串char是否是空白符。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -686,6 +866,8 @@ isRTL(char: string): boolean 判断字符串char是否是从右到左语言的字符。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -708,6 +890,8 @@ isIdeograph(char: string): boolean 判断字符串char是否是表意文字。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -730,6 +914,8 @@ isLetter(char: string): boolean 判断字符串char是否是字母。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -752,6 +938,8 @@ isLowerCase(char: string): boolean 判断字符串char是否是小写字母。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -774,6 +962,8 @@ isUpperCase(char: string): boolean 判断字符串char是否是大写字母。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -796,6 +986,8 @@ getType(char: string): string 获取输入字符串的一般类别值。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -818,6 +1010,8 @@ getLineInstance(locale: string): BreakIterator 获取一个用于断句的[BreakIterator](#breakiterator8)对象。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -843,6 +1037,8 @@ setLineBreakText(text: string): void 设置[BreakIterator](#breakiterator8)要处理的文本。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -861,6 +1057,8 @@ getLineBreakText(): string 获取[BreakIterator](#breakiterator8)当前处理的文本。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -880,6 +1078,8 @@ current(): number 获取[BreakIterator](#breakiterator8)对象在当前处理的文本中的位置。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -899,6 +1099,8 @@ first(): number 将[BreakIterator](#breakiterator8)对象设置到第一个可断句的分割点。第一个分割点总是被处理的文本的起始位置。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -918,6 +1120,8 @@ last(): number 将[BreakIterator](#breakiterator8)对象的位置设置到最后一个可断句的分割点。最后一个分割点总是被处理文本末尾的下一个位置。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -937,6 +1141,8 @@ next(index?: number): number 如果index给出,并且index是一个正数将[BreakIterator](#breakiterator8)向后移动number个可断句的分割点,如果n是一个负数,向前移动相应个分割点。若index没有给出,则相当于index = 1。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -963,6 +1169,8 @@ previous(): number 将[BreakIterator](#breakiterator8)移动到前一个分割点处。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -984,6 +1192,8 @@ following(offset: number): number 将[BreakIterator](#breakiterator8)设置到由offset指定的位置的后面一个分割点。返回移动后[BreakIterator](#breakiterator8)的位置。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1010,6 +1220,8 @@ isBoundary(offset: number): boolean 如果offset所指定的文本位置是一个分割点,那么返回true,否则返回false。如果返回true, 将[BreakIterator](#breakiterator8)对象设置到offset所指定的位置, 否则相当于调用[following](#following8)(offset)。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1029,12 +1241,14 @@ isBoundary(offset: number): boolean ``` -## i18n.is24HourClock +## i18n.is24HourClock8+ is24HourClock(): boolean 判断系统时间是否为24小时制。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -1046,12 +1260,14 @@ is24HourClock(): boolean ``` -## i18n.set24HourClock +## i18n.set24HourClock8+ set24HourClock(option: boolean): boolean 修改系统时间的24小时制设置。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1069,12 +1285,14 @@ set24HourClock(option: boolean): boolean ``` -## i18n.addPreferredLanguage +## i18n.addPreferredLanguage8+ addPreferredLanguage(language: string, index?: number): boolean 在系统偏好语言列表中的指定位置添加偏好语言。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1095,12 +1313,14 @@ addPreferredLanguage(language: string, index?: number): boolean ``` -## i18n.removeDisplayLanguage +## i18n.removeDisplayLanguage8+ removeDisplayLanguage(index: number): boolean 删除系统偏好语言列表中指定位置的偏好语言。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -1119,12 +1339,14 @@ removeDisplayLanguage(index: number): boolean ``` -## i18n.getPreferredLanguageList +## i18n.getPreferredLanguageList8+ getPreferredLanguageList(): Array 获取系统偏好语言列表。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -1136,12 +1358,14 @@ getPreferredLanguageList(): Array ``` -## i18n.getFirstPreferredLanguage +## i18n.getFirstPreferredLanguage8+ getFirstPreferredLanguage(): string 获取与Hap资源最佳匹配的偏好语言。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index 6795829a272ad08c3d072ed2db9dd6b4c2ca9c87..9dbb932ac72f046b8c5ebe056bb2b74b17534007 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -1,6 +1,9 @@ 图片处理 ========== +> **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + 导入模块 --------- diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md new file mode 100644 index 0000000000000000000000000000000000000000..239cbad0772af4984e9e6179f836d22ab557e728 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethod.md @@ -0,0 +1,202 @@ +# 输入法框架 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +## 导入模块 + +``` +import inputMethod from '@ohos.inputMethod'; +``` + +## inputMethod8+ + +常量值。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| MAX_TYPE_NUM | number | 是 | 否 | 可支持的最大输入法个数。
**系统能力**: SystemCapability.MiscServices.InputMethod | + + +## InputMethodProperty8+ + +输入法应用属性。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| packageName | string | 是 | 否 | 包名。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| methodId | string | 是 | 否 | Ability名。
**系统能力**: SystemCapability.MiscServices.InputMethod | + +## inputMethod.getInputMethodController + +getInputMethodController(): InputMethodController + +获取客户端实例[InputMethodController](#InputMethodController)。 + +**系统能力**:SystemCapability.MiscServices.InputMethod + +- 返回值 + + | 类型 | 说明 | + | -------- | -------- | + | [InputMethodController](#InputMethodController) | 回调返回当前客户端实例。 | + +- 示例 + ``` + var InputMethodController = inputMethod.getInputMethodController(); + ``` +## inputMethod.getInputMethodSetting8+ + +getInputMethodSetting(): InputMethodSetting + +获取客户端设置实例[InputMethodSetting](#InputMethodSetting)。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 返回值 + + | 类型 | 说明 | + | ----------------------------------------- | ---------------------------- | + | [InputMethodSetting](#InputMethodSetting) | 回调返回当前客户端设置实例。 | + + +- 示例 + ``` + var InputMethodSetting = inputMethod.getInputMethodSetting(); + ``` + +## InputMethodController + +下列API示例中都需使用[getInputMethodController](#getInputMethodController)回调获取到InputMethodController实例,再通过此实例调用对应方法。 + +### stopInput + +stopInput(callback: AsyncCallback<boolean>): void + +隐藏输入法。 + +**系统能力**:SystemCapability.MiscServices.InputMethod + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<boolean> | 是 | 返回输入法隐藏是否成功。 | + +- 示例 + +``` + InputMethodController.stopInput((error)=>{ + console.info('stopInput'); + }); +``` + +### stopInput + +stopInput(): Promise<boolean> + +隐藏输入法。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 返回值 + + | 类型 | 说明 | + | -------- | -------- | + | Promise<boolean> | 返回输入法隐藏是否成功。 | + +- 示例 + + +``` + var isSuccess = InputMethodController.stopInput(); + console.info('stopInput isSuccess = ' + isSuccess); +``` + +## InputMethodSetting8+ + +下列API示例中都需使用[getInputMethodSetting](#getInputMethodSetting)回调获取到InputMethodSetting实例,再通过此实例调用对应方法。 + +### listInputMethod + +listInputMethod(callback: AsyncCallback<Array<InputMethodProperty>>): void + +查询已安装的输入法列表。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------------------------------------- | ---- | ---------------------- | + | callback | Array<[InputMethodProperty](#InputMethodProperty)> | 是 | 返回已安装输入法列表。 | + +- 示例 + ``` + InputMethodSetting.listInputMethod((properties)=>{ + var property = properties[i]; + console.info(property.packageName + "/" + property.methodId); + }); + ``` + +### listInputMethod + +listInputMethod(): Promise<Array<InputMethodProperty>> + +查询已安装的输入法列表。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 返回值 + | 类型 | 说明 | + | ----------------------------------------------------------- | ---------------------- | + | Promise> | 返回已安装输入法列表。 | + +- 示例 + ``` + var properties = InputMethodSetting.listInputMethod(); + for (var i = 0;i < properties.length; i++) { + var property = properties[i]; + console.info(property.packageName + "/" + property.methodId); + } + ``` + +### displayOptionalInputMethod + +displayOptionalInputMethod(callback: AsyncCallback<void>): void + +显示输入法选择对话框。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + ``` + InputMethodSetting.displayOptionalInputMethod(()=>{ + console.info('displayOptionalInputMethod is called'); + }); + ``` + +### displayOptionalInputMethod + + displayOptionalInputMethod(): Promise<void> + + 显示输入法选择对话框。 + + **系统能力**: SystemCapability.MiscServices.InputMethod + +- 返回值 + +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 回调函数。 | + + - 示例 + ``` + InputMethodSetting.displayOptionalInputMethod(); + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md new file mode 100644 index 0000000000000000000000000000000000000000..fdd75255cd61ab6f562a66f68edcfaef26f0a236 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmethodengine.md @@ -0,0 +1,751 @@ +# 输入法服务 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +``` +import inputMethodEngine from '@ohos.inputMethodEngine'; +``` + +## inputMethodEngine + +常量值。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| -------- | -------- | -------- | -------- | -------- | +| ENTER_KEY_TYPE_UNSPECIFIED | number | 是 | 否 | 无功能键。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| ENTER_KEY_TYPE_GO | number | 是 | 否 | “前往”功能键。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| ENTER_KEY_TYPE_SEARCH | number | 是 | 否 | “搜索”功能键。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| ENTER_KEY_TYPE_SEND | number | 是 | 否 | “发送”功能键。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| ENTER_KEY_TYPE_NEXT | number | 是 | 否 | “下一个”功能键。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| ENTER_KEY_TYPE_DONE | number | 是 | 否 | “回车”功能键。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| ENTER_KEY_TYPE_PREVIOUS | number | 是 | 否 | “前一个”功能键。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| PATTERN_NULL | number | 是 | 否 | 无特殊性编辑框。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| PATTERN_TEXT | number | 是 | 否 | 文本编辑框。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| PATTERN_NUMBER | number | 是 | 否 | 数字编辑框。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| PATTERN_PHONE | number | 是 | 否 | 电话编辑框。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| PATTERN_DATETIME | number | 是 | 否 | 日期编辑框。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| PATTERN_EMAIL | number | 是 | 否 | 邮件编辑框。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| PATTERN_URI | number | 是 | 否 | 超链接编辑框。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| PATTERN_PASSWORD | number | 是 | 否 | 密码编辑框。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| OPTION_ASCII | number | 是 | 否 | 允许输入ASCII值。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| OPTION_NONE | number | 是 | 否 | 不指定编辑框输入属性。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| OPTION_AUTO_CAP_CHARACTERS | number | 是 | 否 | 允许输入字符。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| OPTION_AUTO_CAP_SENTENCES | number | 是 | 否 | 允许输入句子。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| OPTION_AUTO_WORDS | number | 是 | 否 | 允许输入单词。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| OPTION_MULTI_LINE | number | 是 | 否 | 允许输入多行。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| OPTION_NO_FULLSCREEN | number | 是 | 否 | 半屏样式。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| FLAG_SELECTING | number | 是 | 否 | 编辑框处于选择状态。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| FLAG_SINGLE_LINE | number | 是 | 否 | 编辑框为单行。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| DISPLAY_MODE_PART | number | 是 | 否 | 编辑框显示为半屏。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| DISPLAY_MODE_FULL | number | 是 | 否 | 编辑框显示为全屏。
**系统能力**: SystemCapability.MiscServices.InputMethod | + +## inputMethodEngine.getInputMethodEngine + +getInputMethodEngine(): InputMethodEngine + +获取服务端实例。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 返回值 + + | 类型 | 说明 | + | --------------------------------------- | ------------ | + | [InputMethodEngine](#InputMethodEngine) | 服务端实例。 | + +- 示例 + + ``` + var InputMethodEngine = inputMethodEngine.getInputMethodEngine(); + ``` + +## inputMethodEngine.createKeyboardDelegate + +createKeyboardDelegate(): KeyboardDelegate + +获取客户端监听实例。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 返回值 + + | 类型 | 说明 | + | ------------------------------------- | ---------------- | + | [KeyboardDelegate](#KeyboardDelegate) | 客户端监听实例。 | + +- 示例 + + ``` + var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); + ``` + +## InputMethodEngine + +下列API示例中都需使用[getInputMethodEngine](#getInputMethodEngine)回调获取到InputMethodEngine实例,再通过此实例调用对应方法。 + +### on('inputStart') + +on(type: 'inputStart', callback: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; + +订阅输入法绑定成功事件,使用callback回调返回输入法操作相关实例。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 设置监听类型。
-type为‘inputStart’时表示订阅输入法绑定。 | +| callback | [KeyboardController](#KeyboardController), [TextInputClient](#TextInputClient) | 是 | 回调返回输入法操作相关实例。 | + +- 示例: + + ``` + InputMethodEngine.on('inputStart', (kbController, textInputClient) => { + KeyboardController = kbController; + TextInputClient = textInputClient; + }); + ``` + +### off('inputStart') + +off(type: 'inputStart', callback?: (kbController: KeyboardController, textInputClient: TextInputClient) => void): void; + +取消订阅输入法绑定成功事件。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------- | ---- | ------------------------ | + | type | string | 是 | 设置监听类型。
-type为‘inputStart’时表示订阅输入法绑定。 | + | callback | [KeyboardController](#KeyboardController), [TextInputClient](#TextInputClient) | 否 | 回调返回输入法操作相关实例。 | + + + +- 示例: + + ``` + InputMethodEngine.off('inputStart'); + ``` + +### on('keyboardShow'|'keyboardHide') + +on(type: 'keyboardShow'|'keyboardHide', callback: () => void): void; + +订阅输入法事件。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------ | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | + | callback | void | 否 | 回调函数。 | + +- 示例: + + ``` + InputMethodEngine.on('keyboardShow', (err) => { + console.info('keyboardShow'); + }); + ``` + +### off('keyboardShow'|'keyboardHide') + +off(type: 'keyboardShow'|'keyboardHide', callback?: () => void): void; + +取消订阅输入法事件。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------ | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'keyboardShow',表示订阅输入法显示。
- type为'keyboardHide',表示订阅输入法隐藏。 | + | callback | void | 否 | 回调函数。 | + +- 示例: + + ``` + InputMethodEngine.off('keyboardShow'); + ``` + + +## KeyboardDelegate + +下列API示例中都需使用[createKeyboardDelegate](#createKeyboardDelegate)回调获取到KeyboardDelegate实例,再通过此实例调用对应方法。 + +### on('keyDown'|'keyUp') + +on(type: 'keyDown'|'keyUp', callback: (event: KeyEvent) => boolean): void; + +订阅硬键盘事件,使用callback回调返回按键信息。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'keyDown',表示订阅硬键盘按下。
- type为'keyUp',表示订阅硬键盘抬起。 | + | callback | [KeyEvent](#KeyEvent) | 是 | 回调返回按键信息。 | + + + +- 示例: + + ``` + KeyboardDelegate.on('keyDown', (event) => { + console.info('keyDown'); + }); + ``` + +### off('keyDown'|'keyUp') + +off(type: 'keyDown'|'keyUp', callback?: (event: KeyEvent) => boolean): void; + +取消订阅硬键盘事件。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'keyDown',表示订阅硬键盘按下。
- type为'keyUp',表示订阅硬键盘抬起。 | + | callback | [KeyEvent](#KeyEvent) | 否 | 回调返回按键信息。 | + +- 示例: + + ``` + KeyboardDelegate.off('keyDown'); + ``` + +### on('cursorContextChange') + +on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) => void): void; + +订阅光标变化事件,使用callback回调返回光标信息。 + + **系统能力**: SystemCapability.MiscServices.InputMethod + + - 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------ | ---- | ------------------------------------------------------------ | + | type | string | 是 | 光标变化事件。
-type为’cursorContextChange‘时,表示光标变化。 | + | callback | number | 是 | 回调返回光标信息。 | + + + + - 示例: + + ``` + KeyboardDelegate.on('cursorContextChange', (x, y, height) => { + console.info('cursorContextChange'); + }); + ``` + +### off('cursorContextChange') + +off(type: 'cursorContextChange', callback?: (x: number, y:number, height:number) => void): void; + +取消订阅光标变化事件。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + + - 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------- | ---- | ------------------------ | + | type | string | 是 | 光标变化事件。
-type为’cursorContextChange‘时,表示光标变化。 | + | callback | number | 否 | 回调返回光标信息。 | + + + - 示例: + + ``` + KeyboardDelegate.off('cursorContextChange'); + ``` +### on('selectionChange') + +on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void; + +订阅文本选择变化事件,使用callback回调返回文本选择信息。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + + - 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------ | ---- | ------------------------------------------------------------ | + | type | string | 是 | 文本选择变化事件。
-type为’selectionChange‘时,表示选择文本变化。 | + | callback | number | 是 | 回调返回文本选择信息。 | + + - 示例: + + ``` + KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { + console.info('selectionChange'); + }); + ``` + +### off('selectionChange') + +off(type: 'selectionChange', callback?: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void; + +取消订阅文本选择变化事件。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + + - 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------- | ---- | ------------------------ | + | type | string | 是 | 文本选择变化事件。
-type为’selectionChange‘时,表示选择文本变化。 | + | callback | number | 否 | 回调返回文本选择信息。 | + + - 示例: + + ``` + KeyboardDelegate.off('selectionChange'); + ``` + + +### on('textChange') + +on(type: 'textChange', callback: (text: string) => void): void; + +订阅文本变化事件,使用callback回调返回当前文本内容。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + + - 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 文本变化事件。
-type为’textChange‘时,表示当前文本变化。 | + | callback | string | 是 | 回调返回当前文本内容。 | + + - 示例: + + ``` + KeyboardDelegate.on('textChange', (text) => { + console.info('textChange'); + }); + ``` + +### off('textChange') + +off(type: 'textChange', callback?: (text: string) => void): void; + +取消订阅文本变化事件。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + + - 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------------------- | ---- | ------------------------ | + | type | string | 是 | 文本变化事件。
-type为’textChange‘时,表示当前文本变化。 | + | callback | string | 否 | 回调返回当前文本内容。 | + + - 示例: + + ``` + KeyboardDelegate.off('textChange'); + ``` + +## KeyboardController + +下列API示例中都需使用[inputStart](#inputStart)回调获取到KeyboardController实例,再通过此实例调用对应方法。 + +### hideKeyboard + +hideKeyboard(callback: AsyncCallback<void>): void + +隐藏输入法。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数: + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------- | ---- | -------- | + | callback | AsyncCallback<void> | 否 | 回调函数 | + +- 示例 + + +``` + KeyboardController.hideKeyboard(()=>{ + }); +``` + +### hideKeyboard + +hideKeyboard(): Promise<void> + +隐藏输入法。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 返回值 + + | 类型 | 说明 | + | ---------------- | -------- | + | Promise<void> | 回调函数 | + +- 示例 + + +``` + KeyboardController.hideKeyboard(); +``` + +## TextInputClient + +下列API示例中都需使用[inputStart](#inputStart)回调获取到TextInputClient实例,再通过此实例调用对应方法。 + +### getForward + +getForward(length:number, callback: AsyncCallback<string>): void + +获取光标前固定长度的文本。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | length | number | 是 | 文本长度。 | + | callback | AsyncCallback<string> | 是 | 返回文本。 | + +- 示例 + ``` + TextInputClient.getForward(5,(text) =>{ + console.info("text = " + text); + }); + ``` + +### getForward + +getForward(length:number): Promise<string> + +获取光标前固定长度的文本。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | length | number | 是 | 文本长度。 | + +- 返回值 + | 类型 | 说明 | + | ------------------------------- | ------------------------------------------------------------ | + | Promise<string> | 返回文本。 | + +- 示例 + ``` + var text = TextInputClient.getForward(5); + console.info("text = " + text); + ``` + +### getBackward + +getBackward(length:number, callback: AsyncCallback<string>): void + +获取光标后固定长度的文本。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | length | number | 是 | 文本长度。 | + | callback | AsyncCallback<string> | 是 | 返回文本。 | + +- 示例 + ``` + TextInputClient.getBackward(5,(text)=>{ + console.info("text = " + text); + }); + ``` + +### getBackward + +getBackward(length:number): Promise<string> + +获取光标后固定长度的文本。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | length | number | 是 | 文本长度。 | + +- 返回值 + | 类型 | 说明 | + | ------------------------------- | ------------------------------------------------------------ | + | Promise<string> | 返回文本。 | + +- 示例 + ``` + var text = TextInputClient.getBackward(5); + console.info("text = " + text); + ``` + +### deleteForward + +deleteForward(length:number, callback: AsyncCallback<boolean>): void + +删除光标前固定长度的文本。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | length | number | 是 | 文本长度。 | + | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | + +- 示例 + ``` + TextInputClient.deleteForward(5,(isSuccess)=>{ + console.info("isSuccess = " + isSuccess); + }); + ``` +### deleteForward + +deleteForward(length:number): Promise<boolean> + +删除光标前固定长度的文本。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | length | number | 是 | 文本长度。 | + +- 返回值 + | 类型 | 说明 | + | ------------------------------- | ------------------------------------------------------------ | + | Promise<boolean> | 操作成功与否。 | + + - 示例 + ``` + var isSuccess = TextInputClient.deleteForward(5); + console.info("isSuccess = " + isSuccess); + ``` + +### deleteBackward + +deleteBackward(length:number, callback: AsyncCallback<boolean>): void + +删除光标后固定长度的文本。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + + - 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | length | number | 是 | 文本长度。 | + | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | + + - 示例 + ``` + TextInputClient.deleteBackward(5, (isSuccess)=>{ + console.info("isSuccess = " + isSuccess); + }); + ``` + +### deleteBackward + +deleteBackward(length:number): Promise<boolean> + +删除光标后固定长度的文本。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | length | number | 是 | 文本长度。 | + +- 返回值 + | 类型 | 说明 | + | ------------------------------- | ------------------------------------------------------------ | + | Promise<boolean> | 操作成功与否。 | + +- 示例 + + ``` + var isSuccess = TextInputClient.deleteBackward(5); + console.info("isSuccess = " + isSuccess); + ``` +### sendKeyFunction + +sendKeyFunction(action:number, callback: AsyncCallback<boolean>): void + +发送功能键。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + + - 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | action | number | 是 | 编辑框属性。 | + | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | + + - 示例 + ``` + TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{ + console.info("isSuccess = " + isSuccess); + }); + ``` + +### sendKeyFunction + +sendKeyFunction(action:number): Promise<boolean> + +发送功能键。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | action | number | 是 | 编辑框属性。 | + +- 返回值 + | 类型 | 说明 | + | ------------------------------- | ------------------------------------------------------------ | + | Promise<boolean> | 操作成功与否。 | + +- 示例 + + ``` + var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT); + console.info("isSuccess = " + isSuccess); + ``` + +### insertText + +insertText(text:string, callback: AsyncCallback<boolean>): void + +插入文本。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | text | string | 是 | 文本。 | + | callback | AsyncCallback<boolean> | 是 | 操作成功与否。 | + +- 示例 + ``` + TextInputClient.insertText("test", (isSuccess)=>{ + console.info("isSuccess = " + isSuccess); + }); + ``` + +### insertText + +insertText(text:string): Promise<boolean> + +插入文本。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | text | string | 是 | 文本。 | + +- 返回值 + | 类型 | 说明 | + | ------------------------------- | ------------------------------------------------------------ | + | Promise<boolean> | 操作成功与否。 | + +- 示例 + + ``` + var isSuccess = TextInputClient.insertText("test"); + console.info("isSuccess = " + isSuccess); + ``` + +### getEditorAttribute + +getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void + +获取编辑框属性值。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 参数 + | 参数名 | 类型 | 必填 | 说明 | + | ------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | + | callback | AsyncCallback<[EditorAttribute](#EditorAttribute)> | 是 | 编辑框属性值。 | + +- 示例 + ``` + TextInputClient.getEditorAttribute((EditorAttribute)=>{ + }); + ``` + +### getEditorAttribute + +getEditorAttribute(): Promise<EditorAttribute> + +获取编辑框属性值。 + +**系统能力**: SystemCapability.MiscServices.InputMethod + +- 返回值 + | 类型 | 说明 | + | ------------------------------- | ------------------------------------------------------------ | + | Promise<[EditorAttribute](#EditorAttribute)> | 返回编辑框属性值。 | + +- 示例 + ``` + var EditorAttribute = TextInputClient.getEditorAttribute(); + ``` + +## EditorAttribute + +编辑框属性值。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------------ | -------- | ---- | ---- | ------------------------------------------------------------ | +| enterKeyType | number | 是 | 否 | 编辑框的功能属性。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| inputPattern | number | 是 | 否 | 编辑框的文本属性。
**系统能力**: SystemCapability.MiscServices.InputMethod | + +## KeyEvent + +按键属性值。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| --------- | -------- | ---- | ---- | ------------------------------------------------------------ | +| keyCode | number | 是 | 否 | 按键的键值。
**系统能力**: SystemCapability.MiscServices.InputMethod | +| keyAction | number | 是 | 否 | 按键的状态。
**系统能力**: SystemCapability.MiscServices.InputMethod | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-intl.md b/zh-cn/application-dev/reference/apis/js-apis-intl.md index acc6e97ba97a8415fa81580c2ea9a2aae6c96f79..9d847a9f13111ef1b14e128f185eb1519f268831 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-intl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-intl.md @@ -13,11 +13,6 @@ import Intl from '@ohos.intl'; ``` -## 权限列表 - -无 - - ## Locale @@ -25,16 +20,30 @@ import Intl from '@ohos.intl'; | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| language | string | 是 | 否 | 与区域设置关联的语, 如:zh。 | -| script | string | 是 | 否 | 语言的书写方式,如:Hans。 | -| region | string | 是 | 否 | 与区域设置相关的地区,如:CN。 | -| baseName | string | 是 | 否 | Locale的基本核心信息(由语言脚本与地区组成),如:zh-Hans-CN。 | -| caseFirst | string | 是 | 否 | 区域的整理规则是否考虑大小写,取值包括:"upper", "lower", "false"。 | -| calendar | string | 是 | 否 | 区域的日历信息,取值包括:"buddhist", "chinese", "coptic","dangi", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamic-umalqura", "islamic-tbla", "islamic-civil", "islamic-rgsa", "iso8601", "japanese", "persian", "roc", "islamicc"。 | -| collation | string | 是 | 否 | 区域的排序规则,取值包括:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。 | -| hourCycle | string | 是 | 否 | 区域的时制信息,取值包括:"h12", "h23", "h11", "h24"。 | -| numberingSystem | string | 是 | 否 | 区域使用的数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。 | -| numeric | boolean | 是 | 否 | 是否对数字字符具有特殊的排序规则处理。 | +| language | string | 是 | 否 | 与区域设置关联的语, 如:zh。
**系统能力**:SystemCapability.Global.I18n | +| script | string | 是 | 否 | 语言的书写方式,如:Hans。
**系统能力**:SystemCapability.Global.I18n | +| region | string | 是 | 否 | 与区域设置相关的地区,如:CN。
**系统能力**:SystemCapability.Global.I18n | +| baseName | string | 是 | 否 | Locale的基本核心信息(由语言脚本与地区组成),如:zh-Hans-CN。
**系统能力**:SystemCapability.Global.I18n | +| caseFirst | string | 是 | 否 | 区域的整理规则是否考虑大小写,取值包括:"upper", "lower", "false"。
**系统能力**:SystemCapability.Global.I18n | +| calendar | string | 是 | 否 | 区域的日历信息,取值包括:"buddhist", "chinese", "coptic","dangi", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamic-umalqura", "islamic-tbla", "islamic-civil", "islamic-rgsa", "iso8601", "japanese", "persian", "roc", "islamicc"。
**系统能力**:SystemCapability.Global.I18n | +| collation | string | 是 | 否 | 区域的排序规则,取值包括:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。
**系统能力**:SystemCapability.Global.I18n | +| hourCycle | string | 是 | 否 | 区域的时制信息,取值包括:"h12", "h23", "h11", "h24"。
**系统能力**:SystemCapability.Global.I18n | +| numberingSystem | string | 是 | 否 | 区域使用的数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。
**系统能力**:SystemCapability.Global.I18n | +| numeric | boolean | 是 | 否 | 是否对数字字符具有特殊的排序规则处理。
**系统能力**:SystemCapability.Global.I18n | + + +### constructor + +constructor() + +创建区域对象 + +**系统能力**:SystemCapability.Global.I18n + +- 示例: + ``` + var locale = new Intl.Locale(); + ``` ### constructor @@ -43,6 +52,8 @@ constructor(locale: string, options?: options) 创建区域对象 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -61,6 +72,8 @@ toString(): string 将区域信息转换为字符串 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -79,6 +92,8 @@ maximize(): Locale 最大化区域信息,若缺少脚本与地区信息,则补齐。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -97,6 +112,8 @@ minimize(): Locale 最小化区域信息,若包含脚本与地区信息,则去除。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -112,12 +129,28 @@ minimize(): Locale ## DateTimeFormat +### constructor + +constructor() + +创建时间日期格式化对象。 + +**系统能力**:SystemCapability.Global.I18n + +- 示例: + ``` + var datefmt= new Intl.DateTimeFormat(); + ``` + + ### constructor constructor(locale: string, options?: DateTimeOptions) 创建时间日期格式化对象。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -136,6 +169,8 @@ constructor(locales: Array<string>, options?: DateTimeOptions) 创建时间日期格式化对象。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -154,6 +189,8 @@ format(date: Date): string 格式化时间日期字符串。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -178,6 +215,8 @@ formatRange(fromDate: Date, toDate: Date): string 格式化时间日期段字符串。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -204,6 +243,8 @@ resolvedOptions(): DateTimeOptions 获取DateTimeFormat对象的格式化选项。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -222,36 +263,52 @@ resolvedOptions(): DateTimeOptions | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| locale | string | 是 | 否 | 区域参数, 如:zh-Hans-CN。 | -| dateStyle | string | 是 | 是 | 日期显示格式,取值包括:"long", "short", "medium", "full"。 | -| timeStyle | string | 是 | 是 | 时间显示格式,取值包括:"long", "short", "medium", "full"。 | -| hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11", "h12", "h23", "h24"。 | -| timeZone | string | 是 | 是 | 使用的时区(合法的IANA时区ID)。 | -| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。 | -| hour12 | boolean | 是 | 是 | 是否使用12小时制。 | -| weekday | string | 是 | 是 | 工作日的显示格式,取值包括:"long", "short", "narrow"。 | -| era | string | 是 | 是 | 时代的显示格式,取值包括:"long", "short", "narrow"。 | -| year | string | 是 | 是 | 年份的显示格式,取值包括:"numeric", "2-digit"。 | -| month | string | 是 | 是 | 月份的显示格式,取值包括:"numeric", "2-digit", "long", "short", "narrow"。 | -| day | string | 是 | 是 | 日期的显示格式,取值包括:"numeric", "2-digit"。 | -| hour | string | 是 | 是 | 小时的显示格式,取值包括:"numeric", "2-digit"。 | -| minute | string | 是 | 是 | 分钟的显示格式,取值包括:"numeric", "2-digit"。 | -| second | string | 是 | 是 | 秒钟的显示格式,取值包括:"numeric", "2-digit"。 | -| timeZoneName | string | 是 | 是 | 时区名称的本地化表示。 | -| dayPeriod | string | 是 | 是 | 时段的显示格式,取值包括:"long", "short", "narrow"。 | -| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。 | -| formatMatcher | string | 是 | 是 | 要使用的格式匹配算法,取值包括:"basic", "best fit"。 | +| locale | string | 是 | 否 | 区域参数, 如:zh-Hans-CN。
**系统能力**:SystemCapability.Global.I18n | +| dateStyle | string | 是 | 是 | 日期显示格式,取值包括:"long", "short", "medium", "full"。
**系统能力**:SystemCapability.Global.I18n | +| timeStyle | string | 是 | 是 | 时间显示格式,取值包括:"long", "short", "medium", "full"。
**系统能力**:SystemCapability.Global.I18n | +| hourCycle | string | 是 | 是 | 时制格式,取值包括:"h11", "h12", "h23", "h24"。
**系统能力**:SystemCapability.Global.I18n | +| timeZone | string | 是 | 是 | 使用的时区(合法的IANA时区ID)。
**系统能力**:SystemCapability.Global.I18n | +| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。
**系统能力**:SystemCapability.Global.I18n | +| hour12 | boolean | 是 | 是 | 是否使用12小时制。
**系统能力**:SystemCapability.Global.I18n | +| weekday | string | 是 | 是 | 工作日的显示格式,取值包括:"long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | +| era | string | 是 | 是 | 时代的显示格式,取值包括:"long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | +| year | string | 是 | 是 | 年份的显示格式,取值包括:"numeric", "2-digit"。
**系统能力**:SystemCapability.Global.I18n | +| month | string | 是 | 是 | 月份的显示格式,取值包括:"numeric", "2-digit", "long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | +| day | string | 是 | 是 | 日期的显示格式,取值包括:"numeric", "2-digit"。
**系统能力**:SystemCapability.Global.I18n | +| hour | string | 是 | 是 | 小时的显示格式,取值包括:"numeric", "2-digit"。
**系统能力**:SystemCapability.Global.I18n | +| minute | string | 是 | 是 | 分钟的显示格式,取值包括:"numeric", "2-digit"。
**系统能力**:SystemCapability.Global.I18n | +| second | string | 是 | 是 | 秒钟的显示格式,取值包括:"numeric", "2-digit"。
**系统能力**:SystemCapability.Global.I18n | +| timeZoneName | string | 是 | 是 | 时区名称的本地化表示。
**系统能力**:SystemCapability.Global.I18n | +| dayPeriod | string | 是 | 是 | 时段的显示格式,取值包括:"long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | +| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。
**系统能力**:SystemCapability.Global.I18n | +| formatMatcher | string | 是 | 是 | 要使用的格式匹配算法,取值包括:"basic", "best fit"。
**系统能力**:SystemCapability.Global.I18n | ## NumberFormat +### constructor + +constructor() + +创建数字格式化对象。 + +**系统能力**:SystemCapability.Global.I18n + +- 示例: + ``` + var numfmt = new Intl.NumberFormat(); + ``` + + ### constructor constructor(locale: string, options?: NumberOptions) 创建数字格式化对象。 +**系统能力**:SystemCapability.Global.I18n + 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -270,6 +327,8 @@ constructor(locales: Array<string>, options?: NumberOptions) 创建数字格式化对象。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -288,6 +347,8 @@ format(number: number): string; 格式化数字字符串。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -312,6 +373,8 @@ resolvedOptions(): NumberOptions 获取NumberFormat 对象的格式化选项。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -331,25 +394,25 @@ resolvedOptions(): NumberOptions | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| locale | string | 是 | 否 | 区域参数, 如:"zh-Hans-CN"。 | -| currency | string | 是 | 是 | 货币单位, 如:"EUR","CNY","USD"等。 | -| currencySign | string | 是 | 是 | 货币单位的符号显示,取值包括: "symbol","narrowSymbol","code","name" 。 | -| currencyDisplay | string | 是 | 是 | 货币的显示方式,取值包括:"symbol", "narrowSymbol", "code", "name"。 | -| unit | string | 是 | 是 | 单位名称,如:"meter","inch",“hectare”等。 | -| unitDisplay | string | 是 | 是 | 单位的显示格式,取值包括:"long", "short", "medium"。 | -| unitUsage | string | 是 | 是 | 单位的使用场景,取值包括:"default", "area-land-agricult", "area-land-commercl", "area-land-residntl", "length-person", "length-person-small", "length-rainfall", "length-road", "length-road-small", "length-snowfall", "length-vehicle", "length-visiblty", "length-visiblty-small", "length-person-informal", "length-person-small-informal", "length-road-informal", "speed-road-travel", "speed-wind", "temperature-person", "temperature-weather", "volume-vehicle-fuel"。 | -| signDisplay | string | 是 | 是 | 数字符号的显示格式,取值包括:"auto", "never", "always", "expectZero"。 | -| compactDisplay | string | 是 | 是 | 紧凑型的显示格式,取值包括:"long", "short"。 | -| notation | string | 是 | 是 | 数字的格式化规格,取值包括:"standard", "scientific", "engineering", "compact"。 | -| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。 | -| style | string | 是 | 是 | 数字的显示格式,取值包括:"decimal", "currency", "percent", "unit"。 | -| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。 | -| useGrouping | boolean | 是 | 是 | 是否分组显示。 | -| miniumumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。 | -| miniumumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。 | -| maxiumumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。 | -| miniumumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。 | -| maxiumumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。 | +| locale | string | 是 | 否 | 区域参数, 如:"zh-Hans-CN"。
**系统能力**:SystemCapability.Global.I18n | +| currency | string | 是 | 是 | 货币单位, 如:"EUR","CNY","USD"等。
**系统能力**:SystemCapability.Global.I18n | +| currencySign | string | 是 | 是 | 货币单位的符号显示,取值包括: "symbol","narrowSymbol","code","name" 。
**系统能力**:SystemCapability.Global.I18n | +| currencyDisplay | string | 是 | 是 | 货币的显示方式,取值包括:"symbol", "narrowSymbol", "code", "name"。
**系统能力**:SystemCapability.Global.I18n | +| unit | string | 是 | 是 | 单位名称,如:"meter","inch",“hectare”等。
**系统能力**:SystemCapability.Global.I18n | +| unitDisplay | string | 是 | 是 | 单位的显示格式,取值包括:"long", "short", "medium"。
**系统能力**:SystemCapability.Global.I18n | +| unitUsage | string | 是 | 是 | 单位的使用场景,取值包括:"default", "area-land-agricult", "area-land-commercl", "area-land-residntl", "length-person", "length-person-small", "length-rainfall", "length-road", "length-road-small", "length-snowfall", "length-vehicle", "length-visiblty", "length-visiblty-small", "length-person-informal", "length-person-small-informal", "length-road-informal", "speed-road-travel", "speed-wind", "temperature-person", "temperature-weather", "volume-vehicle-fuel"。
**系统能力**:SystemCapability.Global.I18n | +| signDisplay | string | 是 | 是 | 数字符号的显示格式,取值包括:"auto", "never", "always", "expectZero"。
**系统能力**:SystemCapability.Global.I18n | +| compactDisplay | string | 是 | 是 | 紧凑型的显示格式,取值包括:"long", "short"。
**系统能力**:SystemCapability.Global.I18n | +| notation | string | 是 | 是 | 数字的格式化规格,取值包括:"standard", "scientific", "engineering", "compact"。
**系统能力**:SystemCapability.Global.I18n | +| localeMatcher | string | 是 | 是 | 要使用的区域匹配算法,取值包括:"lookup", "best fit"。
**系统能力**:SystemCapability.Global.I18n | +| style | string | 是 | 是 | 数字的显示格式,取值包括:"decimal", "currency", "percent", "unit"。
**系统能力**:SystemCapability.Global.I18n | +| numberingSystem | string | 是 | 是 | 数字系统,取值包括:"adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho"。
**系统能力**:SystemCapability.Global.I18n | +| useGrouping | boolean | 是 | 是 | 是否分组显示。
**系统能力**:SystemCapability.Global.I18n | +| miniumumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | +| miniumumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。
**系统能力**:SystemCapability.Global.I18n | +| maxiumumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | +| miniumumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | +| maxiumumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | ## Collator8+ @@ -361,6 +424,8 @@ constructor() 创建排序对象。 +**系统能力**:SystemCapability.Global.I18n + - 示例: ``` var collator = new Intl.Collator(); @@ -373,6 +438,8 @@ constructor(locale: string | Array<string>, options?: CollatorOptions) 创建排序对象。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | @@ -392,6 +459,8 @@ compare(first: string, second: string): number 依据Collator的排序策略对两个字符串进行比较。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -416,6 +485,8 @@ resolvedOptions(): CollatorOptions 返回Collator对象的属性。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -434,13 +505,13 @@ resolvedOptions(): CollatorOptions | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | 是 | 是 | locale匹配算法,取值范围:"best fit", "lookup"。 | -| usage | string | 是 | 是 | 比较的用途,取值范围:"sort", "search"。 | -| sensitivity | string | 是 | 是 | 表示字符串中的哪些差异会导致非零结果值,取值范围:"base", "accent", "case", "variant"。 | -| ignorePunctuation | boolean | 是 | 是 | 表示是否忽略标点符号,取值范围:true, false。 | -| collation | string | 是 | 是 | 排序规则,取值范围:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。 | -| numeric | boolean | 是 | 是 | 是否使用数字排序,取值范围:true, false。 | -| caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper", "lower", "false"。 | +| localeMatcher | string | 是 | 是 | locale匹配算法,取值范围:"best fit", "lookup"。
**系统能力**:SystemCapability.Global.I18n | +| usage | string | 是 | 是 | 比较的用途,取值范围:"sort", "search"。
**系统能力**:SystemCapability.Global.I18n | +| sensitivity | string | 是 | 是 | 表示字符串中的哪些差异会导致非零结果值,取值范围:"base", "accent", "case", "variant"。
**系统能力**:SystemCapability.Global.I18n | +| ignorePunctuation | boolean | 是 | 是 | 表示是否忽略标点符号,取值范围:true, false。
**系统能力**:SystemCapability.Global.I18n | +| collation | string | 是 | 是 | 排序规则,取值范围:"big5han", "compat", "dict", "direct", "ducet", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "searchjl", "stroke", "trad", "unihan", "zhuyin"。
**系统能力**:SystemCapability.Global.I18n | +| numeric | boolean | 是 | 是 | 是否使用数字排序,取值范围:true, false。
**系统能力**:SystemCapability.Global.I18n | +| caseFirst | string | 是 | 是 | 表示大写、小写的排序顺序,取值范围:"upper", "lower", "false"。
**系统能力**:SystemCapability.Global.I18n | ## PluralRules8+ @@ -452,6 +523,8 @@ constructor() 创建PluralRules对象。 +**系统能力**:SystemCapability.Global.I18n + - 示例: ``` var pluralRules = new Intl.PluralRules(); @@ -464,6 +537,8 @@ constructor(locale: string | Array<string>, options?: PluralRulesOptions) 创建PluralRules对象。 +**系统能力**:SystemCapability.Global.I18n + 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -482,6 +557,8 @@ select(n: number): string 返回一个字符串表示该数字的单复数类别。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -505,13 +582,13 @@ select(n: number): string | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。 | -| type | string | 是 | 是 | 排序的类型,取值包括:"cardinal", "ordinal"。 | -| minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。 | -| minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。 | -| maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。 | -| minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。 | -| maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。 | +| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。
**系统能力**:SystemCapability.Global.I18n | +| type | string | 是 | 是 | 排序的类型,取值包括:"cardinal", "ordinal"。
**系统能力**:SystemCapability.Global.I18n | +| minimumIntegerDigits | number | 是 | 是 | 表示要使用的最小整数位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | +| minimumFractionDigits | number | 是 | 是 | 表示要使用的最小分数位数,取值范围:0~20。
**系统能力**:SystemCapability.Global.I18n | +| maximumFractionDigits | number | 是 | 是 | 表示要使用的最大分数位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | +| minimumSignificantDigits | number | 是 | 是 | 表示要使用的最低有效位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | +| maximumSignificantDigits | number | 是 | 是 | 表示要使用的最大有效位数,取值范围:1~21。
**系统能力**:SystemCapability.Global.I18n | ## RelativeTimeFormat8+ @@ -523,6 +600,8 @@ constructor() 创建相对时间格式化对象。 +**系统能力**:SystemCapability.Global.I18n + - 示例: ``` var relativetimefmt = new Intl.RelativeTimeFormat(); @@ -535,6 +614,8 @@ constructor(locale: string | Array<string>, options?: RelativeTimeFormatIn 创建相对时间格式化对象。 +**系统能力**:SystemCapability.Global.I18n + 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -553,6 +634,8 @@ format(value: numeric, unit: string): string 依据locale和格式化选项,对value和unit进行格式化。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -577,6 +660,8 @@ formatToParts(value: numeric, unit: string): Array<Object> 返回一个对象数组,表示可用于自定义区域设置格式的相对时间格式。 +**系统能力**:SystemCapability.Global.I18n + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -601,6 +686,8 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions 获取RelativeTimeFormat对象的格式化选项。 +**系统能力**:SystemCapability.Global.I18n + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -619,9 +706,9 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。 | -| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。 | -| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。 | +| localeMatcher | string | 是 | 是 | locale匹配算法,取值包括:"best fit", "lookup"。
**系统能力**:SystemCapability.Global.I18n | +| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。
**系统能力**:SystemCapability.Global.I18n | +| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | ## RelativeTimeFormatResolvedOptions8+ @@ -630,7 +717,7 @@ resolvedOptions(): RelativeTimeFormatResolvedOptions | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| locale | string | 是 | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。 | -| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。 | -| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。 | -| numberingSystem | string | 是 | 是 | 使用的数字系统。 | +| locale | string | 是 | 是 | 包含区域设置信息的字符串,包括语言以及可选的脚本和区域。
**系统能力**:SystemCapability.Global.I18n | +| numeric | string | 是 | 是 | 输出消息的格式,取值包括:"always", "auto"。
**系统能力**:SystemCapability.Global.I18n | +| style | string | 是 | 是 | 国际化消息的长度,取值包括:"long", "short", "narrow"。
**系统能力**:SystemCapability.Global.I18n | +| numberingSystem | string | 是 | 是 | 使用的数字系统。
**系统能力**:SystemCapability.Global.I18n | diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md index 41ed19c45881640c672680b15539b8a077b0f9e6..8c8601d225c33bf5b768714c37ef4f355bf4f421 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md @@ -53,7 +53,7 @@ isEmpty(): boolean ``` const lightWeightMap = new LightWeightMap(); -lightWeightMap.isEmpty(); +let result = lightWeightMap.isEmpty(); ``` @@ -97,21 +97,22 @@ hasKey(key: K): boolean; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | K | 是 | 指定元素。 | +| key | K | 是 | 指定key。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| boolean | 包含指定元素返回true,否则返回false。 | +| boolean | 包含指定key返回true,否则返回false。 | **示例:** ``` let lightWeightMap = new LightWeightMap(); +let result = lightWeightMap.hasKey; lightWeightMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result1 = lightWeightMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); ``` @@ -137,9 +138,9 @@ hasValue(value: V): boolean ``` let lightWeightMap = new LightWeightMap(); -lightWeightMap.hasValue(123); +let result = lightWeightMap.hasValue(123); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -lightWeightMap.hasValue(123); +let result1 = lightWeightMap.hasValue(123); ``` @@ -187,7 +188,7 @@ get(key: K): V let lightWeightMap = new LightWeightMap(); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("sdfs", 356); -lightWeightMap.get("sdfs"); +let result = lightWeightMap.get("sdfs"); ``` @@ -215,7 +216,7 @@ getIndexOfKey(key: K): number let lightWeightMap = new LightWeightMap(); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("sdfs", 356); -lightWeightMap.getIndexOfKey("sdfs"); +let result = lightWeightMap.getIndexOfKey("sdfs"); ``` @@ -243,7 +244,7 @@ getIndexOfValue(value: V): number let lightWeightMap = new LightWeightMap(); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("sdfs", 356); -lightWeightMap.getIndexOfValue(123); +let result = lightWeightMap.getIndexOfValue(123); ``` @@ -271,7 +272,7 @@ getKeyAt(index: number): K let lightWeightMap = new LightWeightMap(); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("sdfs", 356); -lightWeightMap.getKeyAt(1); +let result = lightWeightMap.getKeyAt(1); ``` @@ -279,13 +280,13 @@ lightWeightMap.getKeyAt(1); setAll(map: LightWeightMap): void -将一个LightWeightMap中的所有元素组添加到另一个LightWeightMap中。 +将一个LightWeightMap中的所有元素组添加到另一个lightWeightMap中。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| map | LightWeightMap | 是 | 被添加元素的LightWeightMap。 | +| map | LightWeightMap | 是 | 被添加元素的lightWeightMap。 | **示例:** @@ -314,13 +315,13 @@ set(key: K, value: V): Object | 类型 | 说明 | | -------- | -------- | -| Object | 返回添加数据后的LightWeightMap。 | +| Object | 返回添加数据后的lightWeightMap。 | **示例:** ``` let lightWeightMap = new LightWeightMap(); -lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); +let result = lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); ``` @@ -328,13 +329,13 @@ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); remove(key: K): V -删除指定的元素。 +删除并返回指定key映射的元素。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | K | 是 | 依据key指定删除的元素。 | +| key | K | 是 | 指定key。 | **返回值:** @@ -356,13 +357,13 @@ lightWeightMap.remove("sdfs"); removeAt(index: number): boolean -删除指定下标的元素。 +删除指定下标对应的元素。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| index | number | 是 | 指定想要删除元素下标 | +| index | number | 是 | 指定下标。 | **返回值:** @@ -376,7 +377,7 @@ removeAt(index: number): boolean let lightWeightMap = new LightWeightMap(); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("sdfs", 356); -lightWeightMap.removeAt(1); +let result = lightWeightMap.removeAt(1); ``` @@ -384,13 +385,13 @@ lightWeightMap.removeAt(1); setValueAt(index: number, newValue: V): boolean -向LightWeightMap中具体位置替换键值对中的值。 +替换指定下标对应键值对中的元素。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| index | number | 是 | 指定替换数据下标。 | +| index | number | 是 | 指定下标。 | | newValue | V | 是 | 替换键值对中的值。 | **返回值:** @@ -413,19 +414,19 @@ lightWeightMap.setValueAt(1, 3546); getValueAt(index: number): V -获取LightWeightMap中具体位置键值对中的值。 +获取指定下标对应键值对中的元素。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| index | number | 是 | 指定查询数据下标 | +| index | number | 是 | 指定下标。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| V | 返回指定位置中键值对的值。 | +| V | 返回指定下标对应键值对中的元素。 | **示例:** @@ -433,7 +434,7 @@ getValueAt(index: number): V let lightWeightMap = new LightWeightMap(); lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); lightWeightMap.set("sdfs", 356); -lightWeightMap.getValueAt(1); +let result = lightWeightMap.getValueAt(1); ``` @@ -509,7 +510,7 @@ while(temp != undefined) { ### forEach -forEach(callbackfn: (value: V, key?: K, lightWeightMap?: LightWeightMap) => void, thisArg?: Object): void +forEach(callbackfn: (value: V, key?: K, map?: LightWeightMap) => void, thisArg?: Object): void 通过回调函数来遍历实例对象上的元素以及元素对应的下标。 @@ -525,7 +526,7 @@ callbackfn的参数说明: | -------- | -------- | -------- | -------- | | value | V | 是 | 当前遍历到的元素键值对的值。 | | key | K | 是 | 当前遍历到的元素键值对的键。 | -| lightWeightMap | LightWeightMap | 否 | 当前调用forEach方法的实例对象。 | +| map | LightWeightMap | 否 | 当前调用forEach方法的实例对象。 | **示例:** @@ -543,7 +544,7 @@ lightWeightMap.forEach((value, key) => { entries(): IterableIterator<[K, V]> -返回包含此映射中包含的元素的新迭代器对象。 +返回包含此映射中包含的键值对的新迭代器对象。 **返回值:** @@ -566,6 +567,26 @@ while(temp != undefined) { } ``` +### toString + +toString(): string + +将此映射中包含的键值对拼接成字符串,并返回字符串类型。 + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | string | 返回一个字符串。 | + +**示例:** + + ``` + let lightWeightMap = new LightWeightMap(); + lightWeightMap.set("A", 123); + lightWeightMap.set("sdfs", 356); + let iter = lightWeightMap.toString(); + ``` ### [Symbol.iterator] diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md index c88e9d4762280db8e5478738f509d84d0e4d04dc..66b3a24981a800cb85100c792df746b70b0e9f93 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md @@ -53,12 +53,12 @@ isEmpty(): boolean ``` const lightWeightSet = new LightWeightSet(); -lightWeightSet.isEmpty(); +let result = lightWeightSet.isEmpty(); ``` ### add -add(value: T): boolean +add(obj: T): boolean 向此容器中添加数据。 @@ -66,7 +66,7 @@ add(value: T): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | T | 是 | 添加的成员数据。 | +| obj | T | 是 | 添加的成员数据。 | **返回值:** @@ -78,7 +78,7 @@ add(value: T): boolean ``` let lightWeightSet = new LightWeightSet(); -lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); ``` @@ -92,7 +92,7 @@ addAll(set: LightWeightSet<T>): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| set | LightWeightSet<T> | 是 | 提供添加元素的LightWeightSet。 | +| set | LightWeightSet<T> | 是 | 提供添加元素的lightWeightSet。 | **示例:** @@ -102,7 +102,7 @@ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("sdfs"); let set = new LightWeightSet(); set.add("sfage"); -lightWeightSet.addAll(set); +let result = lightWeightSet.addAll(set); ``` @@ -138,29 +138,29 @@ let result = lightWeightSet.hasAll(set); ### has -has(value: T): boolean; +has(key: T): boolean -判断此容器中是否含有该指定value。 +判断此容器中是否含有该指定key。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | T | 是 | 指定元素 | +| key | T | 是 | 指定key | **返回值:** | 类型 | 说明 | | -------- | -------- | -| boolean | 包含指定元素返回true,否则返回false。 | +| boolean | 包含指定key返回true,否则返回false。 | **示例:** ``` let lightWeightSet = new LightWeightSet(); -lightWeightSet.has(123); +let result = lightWeightSet.has(123); lightWeightSet.add(123); -lightWeightSet.has(123); +let result = lightWeightSet.has(123); ``` @@ -193,9 +193,9 @@ let result = lightWeightSet.equal(obj); ``` -### ensureCapacityTo +### increaseCapacityTo -ensureCapacityTo(minimumCapacity: number): void +increaseCapacityTo(minimumCapacity: number): void 将当前容器扩容至可以容纳指定数量元素。 @@ -209,7 +209,7 @@ ensureCapacityTo(minimumCapacity: number): void ``` let lightWeightSet = new LightWeightSet(); -lightWeightSet.ensureCapacityTo(10); +lightWeightSet.increaseCapacityTo(10); ``` @@ -229,7 +229,7 @@ getIndexOf(key: T): number | 类型 | 说明 | | -------- | -------- | -| number | 在LightWeightSet中指定数据的下标。 | +| number | 在lightWeightSet中指定数据的下标。 | **示例:** @@ -237,7 +237,7 @@ getIndexOf(key: T): number let lightWeightSet = new LightWeightSet(); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("sdfs"); -lightWeightSet.getIndexOf("sdfs"); +let result = lightWeightSet.getIndexOf("sdfs"); ``` @@ -245,13 +245,13 @@ lightWeightSet.getIndexOf("sdfs"); remove(key: T): T -删除指定的元素。 +删除并返回指定key对应的元素。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | T | 是 | 依据key指定删除的元素。 | +| key | T | 是 | 指定key。 | **返回值:** @@ -265,7 +265,7 @@ remove(key: T): T let lightWeightSet = new LightWeightSet(); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("sdfs"); -lightWeightSet.remove("sdfs"); +let result = lightWeightSet.remove("sdfs"); ``` @@ -273,13 +273,13 @@ lightWeightSet.remove("sdfs"); removeAt(index: number): boolean -删除指定下标的元素。 +删除指定下标所对应的元素。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| index | number | 是 | 指定想要删除元素下标。 | +| index | number | 是 | 指定下标。 | **返回值:** @@ -293,7 +293,7 @@ removeAt(index: number): boolean let lightWeightSet = new LightWeightSet(); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("sdfs"); -lightWeightSet.removeAt(1); +let result = lightWeightSet.removeAt(1); ``` @@ -301,19 +301,19 @@ lightWeightSet.removeAt(1); getValueAt(index: number): T -获取此容器中具体位置的元素。 +获取此容器中指定下标对应的元素。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| index | number | 是 | 指定查询数据下标。 | +| index | number | 是 | 指定下标。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| T | 返回指定位置中元素。 | +| T | 返回指定下标对应的元素。 | **参数:** @@ -321,7 +321,7 @@ getValueAt(index: number): T let lightWeightSet = new LightWeightSet(); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("sdfs"); -lightWeightSet.getValueAt(1); +let result = lightWeightSet.getValueAt(1); ``` @@ -359,7 +359,7 @@ toString(): String let lightWeightSet = new LightWeightSet(); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("sdfs"); -lightWeightSet.toString(); +let result = lightWeightSet.toString(); ``` @@ -381,7 +381,7 @@ toArray(): Array<T> let lightWeightSet = new LightWeightSet(); lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); lightWeightSet.add("sdfs"); -lightWeightSet.toString(); +let result = lightWeightSet.toArray(); ``` @@ -389,7 +389,7 @@ lightWeightSet.toString(); values(): IterableIterator<T> -返回包含此映射中包含的键的新迭代器对象。 +返回包含此映射中包含的键值的新迭代器对象。 **返回值:** @@ -414,7 +414,7 @@ while(index < lightWeightSet.length) { ### forEach -forEach(callbackfn: (value: T, key?: T, lightWeightSet?: LightWeightSet<T>) => void, thisArg?: Object): void +forEach(callbackfn: (value: T, key?: T, set?: LightWeightSet<T>) => void, thisArg?: Object): void 通过回调函数来遍历LightWeightSet实例对象上的元素以及元素对应的下标。 @@ -430,7 +430,7 @@ callbackfn的参数说明: | -------- | -------- | -------- | -------- | | value | T | 是 | 当前遍历到的元素。 | | key | T | 否 | 当前遍历到的元素(和value相同)。 | -| lightWeightSet | LightWeightSet<T> | 否 | 当前调用forEach方法的实例对象。 | +| set | LightWeightSet<T> | 否 | 当前调用forEach方法的实例对象。 | **示例:** @@ -448,7 +448,7 @@ lightWeightSet.forEach((value, key) => { entries(): IterableIterator<[T, T]> -返回包含此映射中包含的键的新迭代器对象。 +返回包含此映射中包含的键值对的新迭代器对象。 **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md index 24a6202ab65dd2699a1cd533cd62606a145d4fe8..93785e13e76db9a1493236935188edeba4083d76 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md +++ b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md @@ -27,7 +27,7 @@ SystemCapability.Utils.Lang ### constructor -constructor(_head?: NodeObj<T>, _tail?: NodeObj<T>) +constructor(head?: NodeObj<T>, tail?: NodeObj<T>) LinkedList的构造函数。 @@ -35,8 +35,8 @@ LinkedList的构造函数。 | 参数名 | 类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| _head | NodeObj<T> | 是 | 否 | 节点对象,含有element、next指向和prev指向。 | -| _tail | NodeObj<T> | 是 | 否 | 节点对象,含有element、next指向和prev指向。 | +| head | NodeObj<T> | 是 | 否 | 节点对象,含有element、next指向和prev指向。 | +| tail | NodeObj<T> | 是 | 否 | 节点对象,含有element、next指向和prev指向。 | **示例:** @@ -67,12 +67,12 @@ add(element: T): boolean ``` let linkedList = new LinkedList(); -linkedList.add("a"); -linkedList.add(1); +let result = linkedList.add("a"); +let result = linkedList.add(1); let b = [1, 2, 3]; linkedList.add(b); let c = {name : "lala", age : "13"}; -linkedList.add(false); +let result3 = linkedList.add(false); ``` ### addFirst @@ -101,7 +101,7 @@ linkedList.addFirst(false); ### insert -insert(element: T, index: number): void +insert(index: number, element: T): void 在长度范围内任意插入指定元素。 @@ -116,9 +116,9 @@ insert(element: T, index: number): void ``` let linkedList = new LinkedList(); -linkedList.insert("A", 0); -linkedList.insert(0, 1); -linkedList.insert(true, 2); +linkedList.insert(0, "A"); +linkedList.insert(1, 0); +linkedList.insert(2, true); ``` ### has @@ -143,9 +143,9 @@ has(element: T): boolean ``` let linkedList = new LinkedList(); -linkedList.has("Ahfbrgrbgnutfodgorrogorg"); +let result1 = linkedList.has("Ahfbrgrbgnutfodgorrogorg"); linkedList.add("Ahfbrgrbgnutfodgorrogorg"); -linkedList.has("Ahfbrgrbgnutfodgorrogorg"); +let result = linkedList.has("Ahfbrgrbgnutfodgorrogorg"); ``` ### get @@ -177,7 +177,7 @@ linkedList.add(2); linkedList.add(1); linkedList.add(2); linkedList.add(4); -linkedList.get(2); +let result = linkedList.get(2); ``` ### getLastIndexOf @@ -209,7 +209,7 @@ linkedList.add(2); linkedList.add(1); linkedList.add(2); linkedList.add(4); -linkedList.getLastIndexOf(2); +let result = linkedList.getLastIndexOf(2); ``` ### getIndexOf @@ -241,7 +241,7 @@ linkedList.add(2); linkedList.add(1); linkedList.add(2); linkedList.add(4); -linkedList.getIndexOf(2); +let result = linkedList.getIndexOf(2); ``` ### removeByIndex @@ -271,7 +271,7 @@ linkedList.add(4); linkedList.add(5); linkedList.add(2); linkedList.add(4); -linkedList.removeByIndex(2); +let result = linkedList.removeByIndex(2); ``` ### removeFirst @@ -295,7 +295,7 @@ linkedList.add(4); linkedList.add(5); linkedList.add(2); linkedList.add(4); -linkedList.removeFirst(); +let result = linkedList.removeFirst(); ``` ### removeLast @@ -319,14 +319,14 @@ linkedList.add(4); linkedList.add(5); linkedList.add(2); linkedList.add(4); -linkedList.removeLast(); +let result = linkedList.removeLast(); ``` ### remove remove(element: T): boolean -删除指定的元素。 +删除查找到的第一个指定的元素。 **参数:** @@ -348,7 +348,7 @@ linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(4); -linkedList.remove(2); +let result = linkedList.remove(2); ``` ### removeFirstFound @@ -377,7 +377,7 @@ linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(4); -linkedList.removeFirstFound(4); +let result = linkedList.removeFirstFound(4); ``` ### removeLastFound @@ -406,7 +406,7 @@ linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(4); -linkedList.removeLastFound(4); +let result = linkedList.removeLastFound(4); ``` ### clone @@ -430,11 +430,11 @@ linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(4); -linkedList.clone(); +let result = linkedList.clone(); ``` ### forEach -forEach(callbackfn: (value: T, index?: number, linkedlist?: LinkedList<T>) => void, +forEach(callbackfn: (value: T, index?: number, LinkedList?: LinkedList<T>) => void, thisArg?: Object): void 通过回调函数来遍历LinkedList实例对象上的元素以及元素对应的下标。 @@ -452,7 +452,7 @@ callbackfn的参数说明: | -------- | -------- | -------- | -------- | | value | T | 是 | 当前遍历到的元素。 | | index | number | 否 | 当前遍历到的下标值。 | -| linkedlist | LinkedList<T> | 否 | 当前调用forEach方法的实例对象。 | +| LinkedList | LinkedList<T> | 否 | 当前调用forEach方法的实例对象。 | **示例:** @@ -484,8 +484,7 @@ linkedList.clear(); ``` ### set -set(index: number, element: T): void - +set(index: number, element: T): T 将此LinkedList中指定位置的元素替换为指定元素。 **参数:** @@ -495,6 +494,12 @@ set(index: number, element: T): void | index | number | 是 | 查找的下标值。 | | element | T | 是 | 用来替换的元素。 | +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| T | 返回替换后的元素。 | + **示例:** ``` @@ -503,7 +508,7 @@ linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(4); -linkedList.set(2, "b"); +let result = linkedList.set(2, "b"); ``` ### convertToArray @@ -524,7 +529,7 @@ linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(4); -linkedList.convertToArray(); +let result = linkedList.convertToArray(); ``` ### getFirst @@ -547,7 +552,7 @@ linkedList.add(2); linkedList.add(4); linkedList.add(5); linkedList.add(4); -linkedList.getFirst(); +let result = linkedList.getFirst(); ``` ### getLast diff --git a/zh-cn/application-dev/reference/apis/js-apis-list.md b/zh-cn/application-dev/reference/apis/js-apis-list.md index 4c832c5776dbdbe9f2f318600be1dec3404d0a7c..f8d0856f180ab2094985018341821a6585633786 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-list.md +++ b/zh-cn/application-dev/reference/apis/js-apis-list.md @@ -27,7 +27,7 @@ SystemCapability.Utils.Lang ### constructor -constructor(_head?: NodeObj<T>) +constructor(head?: NodeObj<T>) List的构造函数。 @@ -35,7 +35,7 @@ List的构造函数。 | 参数名 | 类型 | 可读 | 说明 | | -------- | -------- | -------- | -------- | -| _head | NodeObj<T> | 是 | 节点对象,含有element、next指向。 | +| head | NodeObj<T> | 是 | 节点对象,含有element、next指向。 | **示例:** @@ -66,12 +66,12 @@ add(element: T): boolean ``` let list = new List; -list.add("a"); -list.add(1); +let result = list.add("a"); +let result1 = list.add(1); let b = [1, 2, 3]; list.add(b); let c = {name : "lala", age : "13"}; -list.add(false); +let result3 = list.add(false); ``` ### insert @@ -118,9 +118,9 @@ has(element: T): boolean ``` let list = new List(); -list.has("Ahfbrgrbgnutfodgorrogorg"); +let result = list.has("Ahfbrgrbgnutfodgorrogorg"); list.add("Ahfbrgrbgnutfodgorrogorg"); -list.has("Ahfbrgrbgnutfodgorrogorg"); +let result1 = list.has("Ahfbrgrbgnutfodgorrogorg"); ``` ### get @@ -152,7 +152,7 @@ list.add(2); list.add(1); list.add(2); list.add(4); -list.get(2); +let result = list.get(2); ``` ### getLastIndexOf @@ -184,7 +184,7 @@ list.add(2); list.add(1); list.add(2); list.add(4); -list.getLastIndexOf(2); +let result = list.getLastIndexOf(2); ``` ### getIndexOf @@ -203,7 +203,7 @@ getIndexOf(element: T): number | 类型 | 说明 | | -------- | -------- | -| number | 返回第一次找到指定元素的下标,没有找到返回-1 | +| number | 返回第一次找到指定元素的下标,没有找到返回-1。 | **示例:** @@ -217,6 +217,7 @@ list.add(1); list.add(2); list.add(4); list.getIndexOf(2); +let result = list.getIndexOf(2); ``` ### equal @@ -251,7 +252,7 @@ obj1.add(4); obj1.add(5); list.equal(obj1); let obj2 = {name : "lala", age : "13"}; -list.equal(obj2); +let result = list.equal(obj2); ``` ### removeByIndex @@ -281,7 +282,7 @@ list.add(4); list.add(5); list.add(2); list.add(4); -list.removeByIndex(2); +let result = list.removeByIndex(2); ``` ### remove @@ -294,7 +295,7 @@ remove(element: T): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| element | T | 是 | 指定元素 | +| element | T | 是 | 指定元素。 | **返回值:** @@ -310,7 +311,7 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.remove(2); +let result = list.remove(2); ``` ### replaceAllElements @@ -332,7 +333,7 @@ callbackfn的参数说明: | -------- | -------- | -------- | -------- | | value | T | 是 | 当前遍历到的元素。 | | index | number | 否 | 当前遍历到的下标值。 | -| list | List<T> | 否 | 当前调用replaceAllElements方法的实例对象 | +| list | List<T> | 否 | 当前调用replaceAllElements方法的实例对象。 | **示例:** @@ -351,7 +352,7 @@ list.replaceAllElements((value, index) => { ``` ### forEach -forEach(callbackfn: (value: T, index?: number, list?: List<T>) => void, +forEach(callbackfn: (value: T, index?: number, List?: List<T>) => void, thisArg?: Object): void 通过回调函数来遍历List实例对象上的元素以及元素对应的下标。 @@ -360,8 +361,8 @@ thisArg?: Object): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| callbackfn | function | 是 | 回调函数 | -| thisArg | Object | 否 | callbackfn被调用时用作this值 | +| callbackfn | function | 是 | 回调函数。 | +| thisArg | Object | 否 | callbackfn被调用时用作this值。 | callbackfn的参数说明: @@ -369,7 +370,7 @@ callbackfn的参数说明: | -------- | -------- | -------- | -------- | | value | T | 是 | 当前遍历到的元素。 | | index | number | 否 | 当前遍历到的下标值。 | -| list | List<T> | 否 | 当前调用forEach方法的实例对象 | +| List | List<T> | 否 | 当前调用forEach方法的实例对象。 | **示例:** @@ -431,7 +432,7 @@ getSubList(fromIndex: number, toIndex: number): List<T> | 类型 | 说明 | | -------- | -------- | -| List<T> | 返回List对象实例 | +| List<T> | 返回List对象实例。 | **示例:** @@ -441,9 +442,9 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.subList(2, 4); -list.subList(4, 3); -list.subList(2, 6); +let result = list.subList(2, 4); +let result1 = list.subList(4, 3); +let result2 = list.subList(2, 6); ``` ### clear @@ -463,7 +464,7 @@ list.clear(); ``` ### set -set(index: number, element: T): void +set(index: number, element: T): T 将此 List 中指定位置的元素替换为指定元素。 **参数:** @@ -473,6 +474,12 @@ set(index: number, element: T): void | index | number | 是 | 查找的下标值。 | | element | T | 是 | 用来替换的元素。 | +**返回值:** + +| 类型 | 说明 | +| -------- | -------- | +| T | 返回替换后的元素 | + **示例:** ``` @@ -504,7 +511,7 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.convertToArray(); +let result = list.convertToArray(); ``` ### isEmpty @@ -526,7 +533,7 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.isEmpty(); +let result = list.isEmpty(); ``` ### getFirst @@ -549,7 +556,7 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.getFirst(); +let result = list.getFirst(); ``` ### getLast @@ -572,7 +579,7 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.getLast(); +let result = list.getLast(); ``` ### [Symbol.iterator] diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index 74a1d0b8f40b304115e2cf22f1de6520f76c4a9a..bc8c7da071b7677aa1c58b93125f9ceb741d4110 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -1,5 +1,8 @@ # 媒体服务 +> **说明:** +> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + 媒体子系统为开发者提供一套简单且易于理解的接口,使得开发者能够方便接入系统并使用系统的媒体资源。 媒体子系统包含了音视频相关媒体业务,提供以下常用功能: @@ -23,7 +26,7 @@ createAudioPlayer(): [AudioPlayer](#audioplayer) 同步方式创建音频播放实例。 - +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer **返回值:** @@ -34,64 +37,7 @@ createAudioPlayer(): [AudioPlayer](#audioplayer) **示例:** ```js -var audioPlayer = media.createAudioPlayer(); -``` - -## media.createAudioPlayerAsync8+ - -createAudioPlayerAsync(callback: AsyncCallback\<[AudioPlayer](#audioplayer)>): void - -异步方式创建音频播放实例。通过注册回调函数获取返回值。 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------------------------ | ---- | ------------------------------ | -| callback | AsyncCallback<[AudioPlayer](#audioplayer)> | 是 | 异步创建音频播放实例回调方法。 | - -**示例:** - -```js -media.createAudioPlayerAsync((error, audio) => { - if (typeof(audio) != 'undefined') { - audioPlayer = audio; - console.info('audio createAudioPlayerAsync success'); - } else { - console.info(`audio createAudioPlayerAsync fail, error:${error.message}`); - } -}); -``` - -## media.createAudioPlayerAsync8+ - -createAudioPlayerAsync: Promise<[AudioPlayer](#audioplayer)> - -异步方式创建音频播放实例。通过Promise获取返回值。 - -**返回值:** - -| 类型 | 说明 | -| ------------------------------------ | ----------------------------------- | -| Promise<[AudioPlayer](#audioplayer)> | 异步创建音频播放实例Promise返回值。 | - -**示例:** - -```js -function failureCallback(error) { - console.info(`audio failureCallback, error:${error.message}`); -} -function catchCallback(error) { - console.info(`audio catchCallback, error:${error.message}`); -} - -await media.createAudioPlayerAsync.then((audio) => { - if (typeof(audio) != 'undefined') { - audioPlayer = audio; - console.info('audio createAudioPlayerAsync success'); - } else { - console.info('audio createAudioPlayerAsync fail'); - } -}, failureCallback).catch(catchCallback); +let audioPlayer = media.createAudioPlayer(); ``` ## media.createVideoPlayer8+ @@ -100,6 +46,8 @@ createVideoPlayer(callback: AsyncCallback\<[VideoPlayer](#videoplayer8)>): void 异步方式创建视频播放实例,通过注册回调函数获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -109,6 +57,8 @@ createVideoPlayer(callback: AsyncCallback\<[VideoPlayer](#videoplayer8)>): void **示例:** ```js +let videoPlayer + media.createVideoPlayer((error, video) => { if (typeof(video) != 'undefined') { videoPlayer = video; @@ -125,6 +75,8 @@ createVideoPlayer: Promise<[VideoPlayer](#videoplayer8)> 异步方式创建视频播放实例,通过Promise获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -134,6 +86,8 @@ createVideoPlayer: Promise<[VideoPlayer](#videoplayer8)> **示例:** ```js +let videoPlayer + function failureCallback(error) { console.info(`video failureCallback, error:${error.message}`); } @@ -157,6 +111,8 @@ createAudioRecorder(): AudioRecorder 创建音频录制的实例来控制音频的录制。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **返回值:** | 类型 | 说明 | @@ -169,103 +125,54 @@ createAudioRecorder(): AudioRecorder let audiorecorder = media.createAudioRecorder(); ``` -## media.createAudioRecorderAsync8+ - -createAudioRecorderAsync(callback: AsyncCallback\<[AudioRecorder](#audiorecorder)>): void - -异步方式创建音频录制实例。通过注册回调函数获取返回值。 - -**参数:** - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------------- | ---- | ------------------------------ | -| callback | AsyncCallback<[AudioRecorder](#audiorecorder)> | 是 | 异步创建音频录制实例回调方法。 | - -**示例:** - -```js -media.createAudioRecorderAsync((error, audio) => { - if (typeof(audio) != 'undefined') { - audioRecorder = audio; - console.info('audio createAudioRecorderAsync success'); - } else { - console.info(`audio createAudioRecorderAsync fail, error:${error.message}`); - } -}); -``` - -## media.createAudioRecorderAsync8+ - -createAudioRecorderAsync: Promise<[AudioRecorder](#audiorecorder)> - -异步方式创建音频录制实例。通过Promise获取返回值。 - -**返回值:** - -| 类型 | 说明 | -| ---------------------------------------- | ----------------------------------- | -| Promise<[AudioRecorder](#audiorecorder)> | 异步创建音频录制实例Promise返回值。 | - -**示例:** - -```js -function failureCallback(error) { - console.info(`audio failureCallback, error:${error.message}`); -} -function catchCallback(error) { - console.info(`audio catchCallback, error:${error.message}`); -} - -await media.createAudioRecorderAsync.then((audio) => { - if (typeof(audio) != 'undefined') { - audioRecorder = audio; - console.info('audio createAudioRecorderAsync success'); - } else { - console.info('audio createAudioRecorderAsync fail'); - } -}, failureCallback).catch(catchCallback); -``` - -## media.createVideoRecorderAsync8+ +## media.createVideoRecorder8+ -createVideoRecorderAsync(callback: AsyncCallback\<[VideoRecorder](#videorecorder8)>): void +createVideoRecorder(callback: AsyncCallback\<[VideoRecorder](#videorecorder8)>): void 异步方式创建视频录制实例。通过注册回调函数获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ----------------------------------------------------------- | ---- | ------------------------------ | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | ------------------------------ | | callback | AsyncCallback<[VideoRecorder](#videorecorder8)> | 是 | 异步创建视频录制实例回调方法。 | **示例:** ```js -media.createVideoRecorderAsync((error, video) => { +let videoRecorder + +media.createVideoRecorder((error, video) => { if (typeof(video) != 'undefined') { videoRecorder = video; - console.info('video createVideoRecorderAsync success'); + console.info('video createVideoRecorder success'); } else { - console.info(`video createVideoRecorderAsync fail, error:${error.message}`); + console.info(`video createVideoRecorder fail, error:${error.message}`); } }); ``` -## media.createVideoRecorderAsync8+ +## media.createVideoRecorder8+ -createVideoRecorderAsync: Promise<[VideoRecorder](#videorecorder8)> +createVideoRecorder: Promise<[VideoRecorder](#videorecorder8)> 异步方式创建视频录制实例。通过Promise获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **返回值:** -| 类型 | 说明 | -| ----------------------------------------------------- | ----------------------------------- | +| 类型 | 说明 | +| ----------------------------------------- | ----------------------------------- | | Promise<[VideoRecorder](#videorecorder8)> | 异步创建视频录制实例Promise返回值。 | **示例:** ```js +let videoRecorder + function failureCallback(error) { console.info(`video failureCallback, error:${error.message}`); } @@ -273,12 +180,12 @@ function catchCallback(error) { console.info(`video catchCallback, error:${error.message}`); } -await media.createVideoRecorderAsync.then((video) => { +await media.createVideoRecorder.then((video) => { if (typeof(video) != 'undefined') { videoRecorder = video; - console.info('video createVideoRecorderAsync success'); + console.info('video createVideoRecorder success'); } else { - console.info('video createVideoRecorderAsync fail'); + console.info('video createVideoRecorder fail'); } }, failureCallback).catch(catchCallback); ``` @@ -287,74 +194,72 @@ await media.createVideoRecorderAsync.then((video) => { ## MediaErrorCode8+ -媒体服务错误类型枚举 - -| 名称 | 值 | 说明 | -| -------------------------- | ---- | -------------------------------------- | -| MSERR_OK | 0 | 表示操作成功。 | -| MSERR_NO_MEMORY | 1 | 表示申请内存失败,系统可能无可用内存。 | -| MSERR_OPERATION_NOT_PERMIT | 2 | 表示无权限执行此操作。 | -| MSERR_INVALID_VAL | 3 | 表示传入入参无效。 | -| MSERR_IO | 4 | 表示发生IO错误。 | -| MSERR_TIMEOUT | 5 | 表示操作超时。 | -| MSERR_UNKNOWN | 6 | 表示未知错误。 | -| MSERR_SERVICE_DIED | 7 | 表示服务端失效。 | -| MSERR_INVALID_STATE | 8 | 表示在当前状态下,不允许执行此操作。 | -| MSERR_UNSUPPORTED | 9 | 表示在当前版本下,不支持此操作。 | +媒体服务错误类型枚举。 + +| 名称 | 值 | 说明 | +| -------------------------- | ---- | ------------------------------------------------------------ | +| MSERR_OK | 0 | 表示操作成功。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MSERR_NO_MEMORY | 1 | 表示申请内存失败,系统可能无可用内存。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MSERR_OPERATION_NOT_PERMIT | 2 | 表示无权限执行此操作。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MSERR_INVALID_VAL | 3 | 表示传入入参无效。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MSERR_IO | 4 | 表示发生IO错误。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MSERR_TIMEOUT | 5 | 表示操作超时。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MSERR_UNKNOWN | 6 | 表示未知错误。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MSERR_SERVICE_DIED | 7 | 表示服务端失效。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MSERR_INVALID_STATE | 8 | 表示在当前状态下,不允许执行此操作。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MSERR_UNSUPPORTED | 9 | 表示在当前版本下,不支持此操作。
**系统能力:** SystemCapability.Multimedia.Media.Core | ## MediaType8+ -媒体类型枚举 +媒体类型枚举。 -| 名称 | 值 | 说明 | -| ------------------- | ---- | ------------------ | -| MEDIA_TYPE_AUD | 0 | 表示音频。 | -| MEDIA_TYPE_VID | 1 | 表示视频。 | -| MEDIA_TYPE_SUBTITLE | 2 | 表示字幕:开发中。 | +| 名称 | 值 | 说明 | +| -------------- | ---- | ------------------------------------------------------------ | +| MEDIA_TYPE_AUD | 0 | 表示音频。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MEDIA_TYPE_VID | 1 | 表示视频。
**系统能力:** SystemCapability.Multimedia.Media.Core | ## CodecMimeType8+ -Codec MIME类型枚举 +Codec MIME类型枚举。 -| 名称 | 值 | 说明 | -| ------------ | ----------------- | ------------------------ | -| VIDEO_MPEG4 | ”video/mp4v-es“ | 表示视频/mpeg4类型。 | -| AUDIO_MPEG | "audio/mpeg" | 表示音频/mpeg类型。 | -| AUDIO_AAC | "audio/mp4a-latm" | 表示音频/mp4a-latm类型。 | -| AUDIO_VORBIS | "audio/vorbis" | 表示音频/vorbis类型。 | -| AUDIO_FLAC | "audio/flac" | 表示音频/flac类型。 | +| 名称 | 值 | 说明 | +| ------------ | ----------------- | ------------------------------------------------------------ | +| VIDEO_MPEG4 | ”video/mp4v-es“ | 表示视频/mpeg4类型。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| AUDIO_AAC | "audio/mp4a-latm" | 表示音频/mp4a-latm类型。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| AUDIO_VORBIS | "audio/vorbis" | 表示音频/vorbis类型。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| AUDIO_FLAC | "audio/flac" | 表示音频/flac类型。
**系统能力:** SystemCapability.Multimedia.Media.Core | ## MediaDescriptionKey8+ -媒体信息描述枚举 +媒体信息描述枚举。 | 名称 | 值 | 说明 | | ------------------------ | --------------- | ------------------------------------------------------------ | -| MD_KEY_TRACK_INDEX | "track_index" | 表示轨道序号,其对应键值类型为number。 | -| MD_KEY_TRACK_TYPE | "track_type" | 表示轨道类型,其对应键值类型为number,参考[MediaType](#mediatype8)。 | -| MD_KEY_CODEC_MIME | "codec_mime" | 表示codec_mime类型,其对应键值类型为string。 | -| MD_KEY_DURATION | "duration" | 表示媒体时长,其对应键值类型为number,单位为ms。 | -| MD_KEY_BITRATE | "bitrate" | 表示比特率,其对应键值类型为number,单位为bps。 | -| MD_KEY_WIDTH | "width" | 表示视频宽度,其对应键值类型为number,单位为像素。 | -| MD_KEY_HEIGHT | "height" | 表示视频高度,其对应键值类型为number,单位为像素。 | -| MD_KEY_FRAME_RATE | "frame_rate" | 表示视频帧率,其对应键值类型为number,单位为100fps。 | -| MD_KEY_AUD_CHANNEL_COUNT | "channel_count" | 表示声道数,其对应键值类型为number。 | -| MD_KEY_AUD_SAMPLE_RATE | "sample_rate" | 表示采样率,其对应键值类型为number,单位为HZ。 | +| MD_KEY_TRACK_INDEX | "track_index" | 表示轨道序号,其对应键值类型为number。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MD_KEY_TRACK_TYPE | "track_type" | 表示轨道类型,其对应键值类型为number,参考[MediaType](#mediatype8)。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MD_KEY_CODEC_MIME | "codec_mime" | 表示codec_mime类型,其对应键值类型为string。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MD_KEY_DURATION | "duration" | 表示媒体时长,其对应键值类型为number,单位为ms。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MD_KEY_BITRATE | "bitrate" | 表示比特率,其对应键值类型为number,单位为bps。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MD_KEY_WIDTH | "width" | 表示视频宽度,其对应键值类型为number,单位为像素。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MD_KEY_HEIGHT | "height" | 表示视频高度,其对应键值类型为number,单位为像素。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MD_KEY_FRAME_RATE | "frame_rate" | 表示视频帧率,其对应键值类型为number,单位为100fps。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MD_KEY_AUD_CHANNEL_COUNT | "channel_count" | 表示声道数,其对应键值类型为number。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| MD_KEY_AUD_SAMPLE_RATE | "sample_rate" | 表示采样率,其对应键值类型为number,单位为HZ。
**系统能力:** SystemCapability.Multimedia.Media.Core | ## BufferingInfoType8+ -缓存事件类型枚举 +缓存事件类型枚举。 -| 名称 | 值 | 说明 | -| ----------------- | ---- | -------------------------- | -| BUFFERING_START | 1 | 表示开始缓存。 | -| BUFFERING_END | 2 | 表示结束缓存。 | -| BUFFERING_PERCENT | 3 | 表示缓存百分比。 | -| CACHED_DURATION | 4 | 表示缓存时长,单位为毫秒。 | +| 名称 | 值 | 说明 | +| ----------------- | ---- | ------------------------------------------------------------ | +| BUFFERING_START | 1 | 表示开始缓存。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| BUFFERING_END | 2 | 表示结束缓存。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| BUFFERING_PERCENT | 3 | 表示缓存百分比。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| CACHED_DURATION | 4 | 表示缓存时长,单位为毫秒。
**系统能力:** SystemCapability.Multimedia.Media.Core | ## AudioPlayer -音频播放管理类,用于管理和播放音频媒体。在调用AudioPlayer的方法前,需要先通过[createAudioPlayer()](#media.createaudioplayer)或[createAudioPlayerAsync()](#media.createaudioplayerasync8)构建一个[AudioPlayer](#audioplayer)实例。 +音频播放管理类,用于管理和播放音频媒体。在调用AudioPlayer的方法前,需要先通过[createAudioPlayer()](#media.createaudioplayer)构建一个[AudioPlayer](#audioplayer)实例。 音频播放demo可参考:[音频播放开发指导](../../media/audio-playback.md) @@ -362,11 +267,11 @@ Codec MIME类型枚举 | 名称 | 类型 | 可读 | 可写 | 说明 | | ----------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| src | string | 是 | 是 | 音频媒体URI,支持当前主流的音频格式(mp4、aac、mp3、ogg)。
**支持路径示例**:
1、本地绝对路径:file:///data/data/ohos.xxx.xxx/files/test.mp4
![zh-cn_image_0000001164217678](figures/zh-cn_image_0000001164217678.png)
2、http网络播放路径:开发中
3、hls网络播放路径:开发中
4、fd类型播放:开发中
**注意事项**:
媒体素材需至少赋予读权限后,才可正常播放 | -| loop | boolean | 是 | 是 | 音频循环播放属性,设置为'true'表示循环播放。 | -| currentTime | number | 是 | 否 | 音频的当前播放位置。 | -| duration | number | 是 | 否 | 音频时长。 | -| state | [AudioState](#audiostate) | 是 | 否 | 音频播放的状态。 | +| src | string | 是 | 是 | 音频媒体URI,支持当前主流的音频格式(mp4、aac、mp3、ogg)。
**支持路径示例**:
1、fd类型播放:fd://xxx
![zh-cn_image_0000001164217678](figures/zh-cn_image_url.png)
2、http网络播放路径:开发中
3、hls网络播放路径:开发中
**注意事项**:
使用媒体素材需要获取读权限,否则无法正常播放。
**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer | +| loop | boolean | 是 | 是 | 音频循环播放属性,设置为'true'表示循环播放。
**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer | +| currentTime | number | 是 | 否 | 音频的当前播放位置。
**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer | +| duration | number | 是 | 否 | 音频时长。
**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer | +| state | [AudioState](#audiostate) | 是 | 否 | 音频播放的状态。
**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer | ### play @@ -374,6 +279,8 @@ play(): void 开始播放音频资源,需在[dataLoad](#on('play' | 'pause' | 'stop' | 'reset' | 'dataload' | 'finish' | 'volumechange'))事件成功触发后,才能调用play方法。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **示例:** ```js @@ -389,6 +296,8 @@ pause(): void 暂停播放音频资源。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **示例:** ```js @@ -404,6 +313,8 @@ stop(): void 停止播放音频资源。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **示例:** ```js @@ -419,6 +330,8 @@ reset(): void 切换播放音频资源。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **示例:** ```js @@ -434,6 +347,8 @@ seek(timeMs: number): void 跳转到指定播放位置。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -459,6 +374,8 @@ setVolume(vol: number): void 设置音量。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -480,6 +397,8 @@ release(): void 释放音频资源。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **示例:** ```js @@ -493,6 +412,8 @@ getTrackDescription(callback: AsyncCallback> 通过Promise方式获取音频轨道信息。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **返回值:** | 类型 | 说明 | @@ -568,6 +491,8 @@ on(type: 'bufferingUpdate', callback: (infoType: [BufferingInfoType](#bufferingi 开始订阅音频缓存更新事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -590,6 +515,8 @@ on(type: 'play' | 'pause' | 'stop' | 'reset' | 'dataLoad' | 'finish' | 'volumeCh 开始订阅音频播放事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -639,7 +566,19 @@ audioPlayer.on('error', (error) => { //设置'error'事件回调 console.info(`audio error called, errCode is ${error.code}`); console.info(`audio error called, errMessage is ${error.message}`); }); -audioPlayer.src = 'file:///data/data/ohos.xxx.xxx/files/test.mp4'; //设置src属性,并触发'dataLoad'事件回调 + +// 用户选择视频设置fd(本地播放) +let fdPath = 'fd://' +let path = 'data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; +await fileIO.open(path).then(fdNumber) => { + fdPath = fdPath + '' + fdNumber; + console.info('open fd sucess fd is' + fdPath); +}, (err) => { + console.info('open fd failed err is' + err); +}),catch((err) => { + console.info('open fd failed err is' + err); +}); +audioPlayer.src = fdPath; //设置src属性,并触发'dataLoad'事件回调 ``` ### on('timeUpdate') @@ -648,6 +587,8 @@ on(type: 'timeUpdate', callback: Callback\): void 开始订阅音频播放[seek()](#seek)时间更新事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -674,6 +615,8 @@ on(type: 'error', callback: ErrorCallback): void 开始订阅音频播放错误事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -696,13 +639,13 @@ audioPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 音频播放的状态机。可通过state属性获取当前状态。 -| 名称 | 类型 | 描述 | -| ------------------ | ------ | -------------- | -| idle | string | 音频播放空闲。 | -| playing | string | 音频正在播放。 | -| paused | string | 音频暂停播放。 | -| stopped | string | 音频播放停止。 | -| error8+ | string | 错误状态。 | +| 名称 | 类型 | 描述 | +| ------------------ | ------ | ------------------------------------------------------------ | +| idle | string | 音频播放空闲。
**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer | +| playing | string | 音频正在播放。
**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer | +| paused | string | 音频暂停播放。
**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer | +| stopped | string | 音频播放停止。
**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer | +| error8+ | string | 错误状态。
**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer | ## VideoPlayer8+ @@ -710,17 +653,17 @@ audioPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 视频播放demo可参考:[视频播放开发指导](../../media/video-playback.md) -### 属性8+ +### 属性 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ----------- | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| url | string | 是 | 是 | 视频媒体URL,支持当前主流的视频格式(mp4、mpeg-ts、webm、mkv)。
**支持路径示例**:
1. 本地绝对路径:file:///data/data/ohos.xxx.xxx/files/test.mp4
![zh-cn_image_0000001164217678](figures/zh-cn_image_0000001164217678.png)
**注意事项**:
媒体素材需至少赋予读权限后,才可正常播放 | -| loop | boolean | 是 | 是 | 视频循环播放属性,设置为'true'表示循环播放。 | -| currentTime | number | 是 | 否 | 视频的当前播放位置。 | -| duration | number | 是 | 否 | 视频时长,返回-1表示直播模式 | -| state | [VideoPlayState](#videoplaystate8) | 是 | 否 | 视频播放的状态。 | -| width | number | 是 | 否 | 视频宽。 | -| height | number | 是 | 否 | 视频高。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ | +| url8+ | string | 是 | 是 | 视频媒体URL,支持当前主流的视频格式(mp4、mpeg-ts、webm、mkv)。
**支持路径示例**:
1. fd类型播放:fd://xxx
![zh-cn_image_0000001164217678](figures/zh-cn_image_url.png)
**注意事项**:
使用媒体素材需要获取读权限,否则无法正常播放。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| loop8+ | boolean | 是 | 是 | 视频循环播放属性,设置为'true'表示循环播放。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| currentTime8+ | number | 是 | 否 | 视频的当前播放位置。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| duration8+ | number | 是 | 否 | 视频时长,返回-1表示直播模式。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| state8+ | [VideoPlayState](#videoplaystate8) | 是 | 否 | 视频播放的状态。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| width8+ | number | 是 | 否 | 视频宽。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| height8+ | number | 是 | 否 | 视频高。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | ### setDisplaySurface8+ @@ -728,6 +671,8 @@ setDisplaySurface(surfaceId: string, callback: AsyncCallback\): void 通过回调方式设置SurfaceId。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -753,6 +698,8 @@ setDisplaySurface(surfaceId: string): Promise\ 通过Promise方式设置SurfaceId。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -785,6 +732,8 @@ prepare(callback: AsyncCallback\): void 通过回调方式准备播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -809,6 +758,8 @@ prepare(): Promise\ 通过Promise方式准备播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -835,6 +786,8 @@ play(callback: AsyncCallback\): void; 通过回调方式开始播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -859,6 +812,8 @@ play(): Promise\; 通过Promise方式开始播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -885,6 +840,8 @@ pause(callback: AsyncCallback\): void 通过回调方式暂停播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -909,6 +866,8 @@ pause(): Promise\ 通过Promise方式暂停播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -935,6 +894,8 @@ stop(callback: AsyncCallback\): void 通过回调方式停止播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -959,6 +920,8 @@ stop(): Promise\ 通过Promise方式停止播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -985,6 +948,8 @@ reset(callback: AsyncCallback\): void 通过回调方式切换播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1009,6 +974,8 @@ reset(): Promise\ 通过Promise方式切换播放视频。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -1035,6 +1002,8 @@ seek(timeMs: number, callback: AsyncCallback\): void 通过回调方式跳转到指定播放位置,默认跳转到指定时间点的下一个关键帧。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1060,6 +1029,8 @@ seek(timeMs: number, mode:SeekMode, callback: AsyncCallback\): void 通过回调方式跳转到指定播放位置。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1086,6 +1057,8 @@ seek(timeMs: number, mode?:SeekMode): Promise\ 通过Promise方式跳转到指定播放位置,如果没有设置mode则跳转到指定时间点的下一个关键帧。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1123,6 +1096,8 @@ setVolume(vol: number, callback: AsyncCallback\): void 通过回调方式设置音量。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1148,6 +1123,8 @@ setVolume(vol: number): Promise\ 通过Promise方式设置音量。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1180,6 +1157,8 @@ release(callback: AsyncCallback\): void 通过回调方式释放视频资源。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1204,6 +1183,8 @@ release(): Promise\ 通过Promise方式释放视频资源。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -1230,6 +1211,8 @@ getTrackDescription(callback: AsyncCallback>)>> 通过Promise方式获取视频轨道信息。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **返回值:** | 类型 | 说明 | @@ -1306,6 +1291,8 @@ setSpeed(speed:number, callback: AsyncCallback\): void 通过回调方式设置播放速度。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1331,6 +1318,8 @@ setSpeed(speed:number): Promise\ 通过Promise方式设置播放速度。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1357,6 +1346,8 @@ on(type: 'playbackCompleted', callback: Callback\): void 开始监听视频播放完成事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1378,6 +1369,8 @@ on(type: 'bufferingUpdate', callback: (infoType: BufferingInfoType, value: numbe 开始监听视频缓存更新事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1400,6 +1393,8 @@ on(type: 'startRenderFrame', callback: Callback\): void 开始监听视频播放首帧送显上报事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1421,6 +1416,8 @@ on(type: 'videoSizeChanged', callback: (width: number, height: number) => void): 开始监听视频播放宽高变化事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1443,6 +1440,8 @@ on(type: 'error', callback: ErrorCallback): void 开始监听视频播放错误事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1465,48 +1464,46 @@ videoPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 视频播放的状态机,可通过state属性获取当前状态。 -| 名称 | 类型 | 描述 | -| -------- | ------ | -------------- | -| idle | string | 视频播放空闲。 | -| prepared | string | 视频播放准备。 | -| playing | string | 视频正在播放。 | -| paused | string | 视频暂停播放。 | -| stopped | string | 视频播放停止。 | -| error | string | 错误状态。 | +| 名称 | 类型 | 描述 | +| -------- | ------ | ------------------------------------------------------------ | +| idle | string | 视频播放空闲。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| prepared | string | 视频播放准备。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| playing | string | 视频正在播放。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| paused | string | 视频暂停播放。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| stopped | string | 视频播放停止。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| error | string | 错误状态。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | ## SeekMode8+ 视频播放的Seek模式枚举,可通过seek方法作为参数传递下去。 -| 名称 | 值 | 描述 | -| ----------------- | ---- | ------------------------------------------------------------ | -| SEEK_NEXT_SYNC | 0 | 表示跳转到指定时间点的下一个关键帧,建议向后快进的时候用这个枚举值 | -| SEEK_PREV_SYNC | 1 | 表示跳转到指定时间点的上一个关键帧,建议向前快进的时候用这个枚举值 | -| SEEK_CLOSEST_SYNC | 2 | 表示跳转到指定时间点最近的关键帧。 | -| SEEK_CLOSEST | 3 | 表示精确跳转到指定时间点。 | +| 名称 | 值 | 描述 | +| -------------- | ---- | ------------------------------------------------------------ | +| SEEK_NEXT_SYNC | 0 | 表示跳转到指定时间点的下一个关键帧,建议向后快进的时候用这个枚举值。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| SEEK_PREV_SYNC | 1 | 表示跳转到指定时间点的上一个关键帧,建议向前快进的时候用这个枚举值。
**系统能力:** SystemCapability.Multimedia.Media.Core | ## PlaybackSpeed8+ 视频播放的倍速枚举,可通过setSpeed方法作为参数传递下去。 -| 名称 | 值 | 描述 | -| -------------------- | ---- | ------------------------------ | -| SPEED_FORWARD_0_75_X | 0 | 表示视频播放正常播速的0.75倍。 | -| SPEED_FORWARD_1_00_X | 1 | 表示视频播放正常播速。 | -| SPEED_FORWARD_1_25_X | 2 | 表示视频播放正常播速的1.25倍。 | -| SPEED_FORWARD_1_75_X | 3 | 表示视频播放正常播速的1.75倍。 | -| SPEED_FORWARD_2_00_X | 4 | 表示视频播放正常播速的2.00倍。 | +| 名称 | 值 | 描述 | +| -------------------- | ---- | ------------------------------------------------------------ | +| SPEED_FORWARD_0_75_X | 0 | 表示视频播放正常播速的0.75倍。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| SPEED_FORWARD_1_00_X | 1 | 表示视频播放正常播速。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| SPEED_FORWARD_1_25_X | 2 | 表示视频播放正常播速的1.25倍。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| SPEED_FORWARD_1_75_X | 3 | 表示视频播放正常播速的1.75倍。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | +| SPEED_FORWARD_2_00_X | 4 | 表示视频播放正常播速的2.00倍。
**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | ## MediaDescription8+ ### [key : string] : any -通过key-value方式获取媒体信息 +通过key-value方式获取媒体信息。 | 名称 | 类型 | 说明 | | ----- | ------ | ------------------------------------------------------------ | -| key | string | 通过key值获取对应的value。key值具体可见[MediaDescriptionKey](#mediadescriptionkey8)。 | -| value | any | 对应key值得value。其类型可为任意类型,具体key对应value的类型可参考[MediaDescriptionKey](#mediadescriptionkey8)的描述信息。 | +| key | string | 通过key值获取对应的value。key值具体可见[MediaDescriptionKey](#mediadescriptionkey8)。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| value | any | 对应key值得value。其类型可为任意类型,具体key对应value的类型可参考[MediaDescriptionKey](#mediadescriptionkey8)的描述信息。
**系统能力:** SystemCapability.Multimedia.Media.Core | **示例:** @@ -1530,7 +1527,7 @@ audioPlayer.getTrackDescription((error, arrlist) => { ## AudioRecorder -音频录制管理类,用于录制音频媒体。在调用AudioRecorder的方法前,需要先通过[createAudioRecorder()](#media.createaudiorecorder) 或[createAudioRecorderAsync()](#media.createaudiorecorderasync8)构建一个[AudioRecorder](#audiorecorder)实例。 +音频录制管理类,用于录制音频媒体。在调用AudioRecorder的方法前,需要先通过[createAudioRecorder()](#media.createaudiorecorder) 构建一个[AudioRecorder](#audiorecorder)实例。 音频录制demo可参考:[音频录制开发指导](../../media/audio-recorder.md) @@ -1540,6 +1537,10 @@ prepare(config: AudioRecorderConfig): void 录音准备。 +**需要权限:** ohos.permission.MICROPHONE + +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1555,7 +1556,7 @@ let audioRecorderConfig = { audioSampleRate : 22050, numberOfChannels : 2, format : media.AudioOutputFormat.AAC_ADTS, - uri : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.m4a', // 文件需先由调用者创建,并给予适当的权限 + uri : 'fd://1', // 文件需先由调用者创建,并给予适当的权限 location : { latitude : 30, longitude : 130}, } audioRecorder.on('prepare', () => { //设置'prepare'事件回调 @@ -1571,6 +1572,8 @@ start(): void 开始录制,需在[prepare](#audiorecorder_on)事件成功触发后,才能调用start方法。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1586,6 +1589,8 @@ pause():void 暂停录制,需要在[start](#audiorecorder_on)事件成功触发后,才能调用pause方法。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1601,6 +1606,8 @@ resume():void 暂停录制,需要在[pause](#audiorecorder_on)事件成功触发后,才能调用resume方法。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1616,6 +1623,8 @@ stop(): void 停止录音。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1631,6 +1640,8 @@ release(): void 释放录音资源。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1649,6 +1660,8 @@ reset(): void 进行重置录音之前,需要先调用[stop()](#audiorecorder_stop)停止录音。重置录音之后,需要调用[prepare()](#audiorecorder_prepare)设置录音参数项,才能再次进行录音。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **示例:** ```js @@ -1664,6 +1677,8 @@ on(type: 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset' 开始订阅音频录制事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1681,7 +1696,7 @@ let audioRecorderConfig = { audioSampleRate : 22050, numberOfChannels : 2, format : media.AudioOutputFormat.AAC_ADTS, - uri : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.m4a', // 文件需先由调用者创建,并给予适当的权限 + uri : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 location : { latitude : 30, longitude : 130}, } audioRecorder.on('error', (error) => { // 设置'error'事件回调 @@ -1720,6 +1735,8 @@ on(type: 'error', callback: ErrorCallback): void 开始订阅音频录制错误事件。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1744,13 +1761,13 @@ audioRecorder.prepare(); // prepare不设置参数,触发'error' | 名称 | 参数类型 | 必填 | 说明 | | --------------------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| audioEncoder | [AudioEncoder](#audioencoder) | 否 | 音频编码格式,默认设置为AAC_LC。 | -| audioEncodeBitRate | number | 否 | 音频编码比特率,默认值为48000。 | -| audioSampleRate | number | 否 | 音频采集采样率,默认值为48000。 | -| numberOfChannels | number | 否 | 音频采集声道数,默认值为2。 | -| format | [AudioOutputFormat](#audiooutputformat) | 否 | 音量输出封装格式,默认设置为MPEG_4。 | -| location8+ | [Location](#location8) | 否 | 音频采集的地理位置。 | -| uri | string | 是 | 音频输出URI。支持:
1. 文件的绝对路径:file:///data/data/ohos.xxx.xxx/cache/test.mp4![zh-cn_image_0000001164217678](figures/zh-cn_image_0000001164217678.png)
2. 文件的fd路径:file://1 (fd number)
文件需要由调用者创建,并赋予适当的权限。 | +| audioEncoder | [AudioEncoder](#audioencoder) | 否 | 音频编码格式,默认设置为AAC_LC。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| audioEncodeBitRate | number | 否 | 音频编码比特率,默认值为48000。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| audioSampleRate | number | 否 | 音频采集采样率,默认值为48000。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| numberOfChannels | number | 否 | 音频采集声道数,默认值为2。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| format | [AudioOutputFormat](#audiooutputformat) | 否 | 音量输出封装格式,默认设置为MPEG_4。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| location8+ | [Location](#location8) | 否 | 音频采集的地理位置。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| uri | string | 是 | 视频输出URI:fd://xx (fd number)
![zh-cn_image_0000001164217678](figures/zh-cn_image_url.png)
文件需要由调用者创建,并赋予适当的权限。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | ## AudioEncoder @@ -1759,11 +1776,11 @@ audioRecorder.prepare(); // prepare不设置参数,触发'error' | 名称 | 默认值 | 说明 | | ------- | ------ | ------------------------------------------------------------ | -| DEFAULT | 0 | Default audio encoding format is AMR_NB。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AMR_NB | 1 | AMR-NB(Adaptive Multi Rate-Narrow Band Speech Codec) 编码格式。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AMR_WB | 2 | AMR-WB(Adaptive Multi Rate-Wide Band Speech Codec) 编码格式。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AAC_LC | 3 | AAC-LC(Advanced Audio Coding Low Complexity)编码格式。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| HE_AAC | 4 | HE_AAC(High-Efficiency Advanced Audio Coding)编码格式。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | +| DEFAULT | 0 | Default audio encoding format is AMR_NB。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| AMR_NB | 1 | AMR-NB(Adaptive Multi Rate-Narrow Band Speech Codec) 编码格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| AMR_WB | 2 | AMR-WB(Adaptive Multi Rate-Wide Band Speech Codec) 编码格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| AAC_LC | 3 | AAC-LC(Advanced Audio Coding Low Complexity)编码格式。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| HE_AAC | 4 | HE_AAC(High-Efficiency Advanced Audio Coding)编码格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | ## AudioOutputFormat @@ -1772,30 +1789,34 @@ audioRecorder.prepare(); // prepare不设置参数,触发'error' | 名称 | 默认值 | 说明 | | -------- | ------ | ------------------------------------------------------------ | -| DEFAULT | 0 | 默认封装格式为MPEG-4。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| MPEG_4 | 2 | 封装为MPEG-4格式。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AMR_NB | 3 | 封装为AMR_NB格式。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AMR_WB | 4 | 封装为AMR_WB格式。本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | -| AAC_ADTS | 6 | 封装为ADTS(Audio Data Transport Stream)格式,是AAC音频的传输流格式。
**系统能力:**SystemCapability.Multimedia.Media.AudioRecorder | +| DEFAULT | 0 | 默认封装格式为MPEG-4。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| MPEG_4 | 2 | 封装为MPEG-4格式。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| AMR_NB | 3 | 封装为AMR_NB格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| AMR_WB | 4 | 封装为AMR_WB格式。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | +| AAC_ADTS | 6 | 封装为ADTS(Audio Data Transport Stream)格式,是AAC音频的传输流格式。
**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | ## VideoRecorder8+ -视频录制管理类,用于录制视频媒体。在调用VideoRecorder的方法前,需要先通过[createVideoRecorderAsync()](#media.createvideorecorderasync8)构建一个[VideoRecorder](#videorecorder8)实例。 +视频录制管理类,用于录制视频媒体。在调用VideoRecorder的方法前,需要先通过[createVideoRecorder()](#media.createvideorecorder8)构建一个[VideoRecorder](#videorecorder8)实例。 视频录制demo可参考:[视频录制开发指导](../../media/video-recorder.md) ### 属性 -| 名称 | 类型 | 可读 | 可写 | 说明 | -| ----- | ------------------------------------- | ---- | ---- | ---------------- | -| state | [VideoRecordState](#videorecordstate) | 是 | 否 | 视频录制的状态。 | +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------ | ------------------------------------- | ---- | ---- | ---------------- | +| state8+ | [VideoRecordState](#videorecordstate) | 是 | 否 | 视频录制的状态。 | -### prepare +### prepare8+ prepare(config: VideoRecorderConfig, callback: AsyncCallback\): void; 异步方式进行视频录制的参数设置。通过注册回调函数获取返回值。 +**需要权限:** ohos.permission.MICROPHONE ohos.permission.CAMERA + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1823,7 +1844,7 @@ let videoConfig = { audioSourceType : 1, videoSourceType : 0, profile : videoProfile, - url : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.mp4', // 文件需先由调用者创建,并给予适当的权限 + url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 orientationHint : 0, location : { latitude : 30, longitude : 130 }, } @@ -1854,12 +1875,16 @@ media.createVideoRecorder((err, recorder) => { }); ``` -### prepare +### prepare8+ prepare(config: VideoRecorderConfig): Promise\; 异步方式进行视频录制的参数设置。通过Promise获取返回值。 +**需要权限:** ohos.permission.MICROPHONE ohos.permission.CAMERA + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1892,7 +1917,7 @@ let videoConfig = { audioSourceType : 1, videoSourceType : 0, profile : videoProfile, - url : 'file:///data/accounts/account_0/appdata/appdata/recorder/test.mp4', // 文件需先由调用者创建,并给予适当的权限 + url : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 orientationHint : 0, location : { latitude : 30, longitude : 130 }, } @@ -1921,7 +1946,7 @@ await videoRecorder.prepare(videoConfig).then(() => { }); ``` -### getInputSurface +### getInputSurface8+ getInputSurface(callback: AsyncCallback\): void; @@ -1931,6 +1956,8 @@ getInputSurface(callback: AsyncCallback\): void; 只能在[prepare()](#videorecorder_prepare1)接口调用后调用。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -1952,7 +1979,7 @@ videoRecorder.getInputSurface((err, surfaceId) => { }); ``` -### getInputSurface +### getInputSurface8+ getInputSurface(): Promise\; @@ -1962,6 +1989,8 @@ getInputSurface(): Promise\; 只能在[prepare()](#videorecorder_prepare1)接口调用后调用。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **返回值:** | 类型 | 说明 | @@ -1983,13 +2012,15 @@ await videoRecorder.getInputSurface().then((surfaceId) => { }); ``` -### start +### start8+ start(callback: AsyncCallback\): void; 异步方式开始视频录制。通过注册回调函数获取返回值。 -在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)后调用,需要依赖数据源先给surface传递数据。 +在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)后调用,需要依赖数据源先给surface传递数据。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **参数:** @@ -2010,13 +2041,15 @@ videoRecorder.start((err) => { }); ``` -### start +### start8+ start(): Promise\; 异步方式开始视频录制。通过Promise获取返回值。 -在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)后调用,需要依赖数据源先给surface传递数据。 +在[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)后调用,需要依赖数据源先给surface传递数据。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **返回值:** @@ -2037,7 +2070,7 @@ await videoRecorder.start().then(() => { }); ``` -### pause +### pause8+ pause(callback: AsyncCallback\): void; @@ -2045,6 +2078,8 @@ pause(callback: AsyncCallback\): void; 在[start()](#videorecorder_start1)后调用。可以通过调用[resume()](#videorecorder_resume1)接口来恢复录制。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2064,7 +2099,7 @@ videoRecorder.pause((err) => { }); ``` -### pause +### pause8+ pause(): Promise\; @@ -2072,6 +2107,8 @@ pause(): Promise\; 在[start()](#videorecorder_start1)后调用。可以通过调用[resume()](#videorecorder_resume1)接口来恢复录制。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **返回值:** | 类型 | 说明 | @@ -2091,12 +2128,14 @@ await videoRecorder.pause().then(() => { }); ``` -### resume +### resume8+ resume(callback: AsyncCallback\): void; 异步方式恢复视频录制。通过注册回调函数获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2116,12 +2155,14 @@ videoRecorder.resume((err) => { }); ``` -### resume +### resume8+ resume(): Promise\; 异步方式恢复视频录制。通过Promise获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **返回值:** | 类型 | 说明 | @@ -2141,13 +2182,15 @@ await videoRecorder.resume().then(() => { }); ``` -### stop +### stop8+ stop(callback: AsyncCallback\): void; 异步方式停止视频录制。通过注册回调函数获取返回值。 -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)接口才能重新录制。 +需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **参数:** @@ -2168,13 +2211,15 @@ videoRecorder.stop((err) => { }); ``` -### stop +### stop8+ stop(): Promise\; 异步方式停止视频录制。通过Promise获取返回值。 -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)接口才能重新录制。 +需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **返回值:** @@ -2195,12 +2240,14 @@ await videoRecorder.stop().then(() => { }); ``` -### release +### release8+ release(callback: AsyncCallback\): void; 异步方式释放视频录制资源。通过注册回调函数获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2220,12 +2267,14 @@ videoRecorder.release((err) => { }); ``` -### release +### release8+ release(): Promise\; 异步方式释放视频录制资源。通过Promise获取返回值。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **返回值:** | 类型 | 说明 | @@ -2245,13 +2294,15 @@ await videoRecorder.release().then(() => { }); ``` -### reset +### reset8+ reset(callback: AsyncCallback\): void; 异步方式重置视频录制。通过注册回调函数获取返回值。 -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)接口才能重新录制。 +需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **参数:** @@ -2272,13 +2323,15 @@ videoRecorder.reset((err) => { }); ``` -### reset +### reset8+ reset(): Promise\; 异步方式重置视频录制。通过Promise获取返回值。 -需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface)接口才能重新录制。 +需要重新调用[prepare()](#videorecorder_prepare1)和[getInputSurface()](#getinputsurface8)接口才能重新录制。 + +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder **返回值:** @@ -2299,12 +2352,14 @@ await videoRecorder.reset().then(() => { }); ``` -### on('error') +### on('error')8+ on(type: 'error', callback: ErrorCallback): void 开始订阅视频录制错误事件。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -2327,14 +2382,14 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 视频录制的状态机。可通过state属性获取当前状态。 -| 名称 | 类型 | 描述 | -| -------- | ------ | ---------------------- | -| idle | string | 视频录制空闲。 | -| prepared | string | 视频录制参数设置完成。 | -| playing | string | 视频正在录制。 | -| paused | string | 视频暂停录制。 | -| stopped | string | 视频录制停止。 | -| error | string | 错误状态。 | +| 名称 | 类型 | 描述 | +| -------- | ------ | ------------------------------------------------------------ | +| idle | string | 视频录制空闲。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| prepared | string | 视频录制参数设置完成。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| playing | string | 视频正在录制。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| paused | string | 视频暂停录制。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| stopped | string | 视频录制停止。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| error | string | 错误状态。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | ## VideoRecorderConfig8+ @@ -2342,60 +2397,60 @@ videoRecorder.on('error', (error) => { // 设置'error'事件回调 | 名称 | 参数类型 | 必填 | 说明 | | --------------- | ---------------------------------------------------------- | ---- | ------------------------------------------------------------ | -| audioSourceType | [AudioSourceType](#audiosourcetype8+) | 是 | 视频录制的音频源类型。 | -| videoSourceType | [VideoSourceType](#videosourcetype8+) | 是 | 视频录制的视频源类型。 | -| profile | [VideoRecorderProfile](#videorecorderprofile8+) | 是 | 视频录制的profile。 | -| orientationHint | number | 否 | 录制视频的旋转角度。 | -| location | [Location](#location8) | 否 | 录制视频的地理位置。 | -| uri | string | 是 | 视频输出URI。支持:
1. 文件的绝对路径:file:///data/data/ohos.xxx.xxx/cache/test.mp4![zh-cn_image_0000001164217678](figures/zh-cn_image_0000001164217678.png)
2. 文件的fd路径:file://1 (fd number)
文件需要由调用者创建,并赋予适当的权限。 | +| audioSourceType | [AudioSourceType](#audiosourcetype8+) | 是 | 视频录制的音频源类型。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| videoSourceType | [VideoSourceType](#videosourcetype8+) | 是 | 视频录制的视频源类型。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| profile | [VideoRecorderProfile](#videorecorderprofile8+) | 是 | 视频录制的profile。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| orientationHint | number | 否 | 录制视频的旋转角度。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| location | [Location](#location8) | 否 | 录制视频的地理位置。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| url | string | 是 | 视频输出URL:fd://xx (fd number)
![zh-cn_image_0000001164217678](figures/zh-cn_image_url.png)
文件需要由调用者创建,并赋予适当的权限。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | ## AudioSourceType8+ 表示视频录制中音频源类型的枚举。 -| 名称 | 值 | 说明 | -| -------------------------- | ---- | ---------------------- | -| AUDIO_SOURCE_TYPE_DEFAULT0 | 0 | 默认的音频输入源类型。 | -| AUDIO_SOURCE_TYPE_MIC | 1 | 表示MIC的音频输入源。 | +| 名称 | 值 | 说明 | +| ------------------------- | ---- | ------------------------------------------------------------ | +| AUDIO_SOURCE_TYPE_DEFAULT | 0 | 默认的音频输入源类型。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| AUDIO_SOURCE_TYPE_MIC | 1 | 表示MIC的音频输入源。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | ## VideoSourceType8+ 表示视频录制中视频源类型的枚举。 -| 名称 | 值 | 说明 | -| ----------------------------- | ---- | ------------------------------- | -| VIDEO_SOURCE_TYPE_SURFACE_YUV | 0 | 输入surface中携带的是raw data。 | -| VIDEO_SOURCE_TYPE_SURFACE_ES | 1 | 输入surface中携带的是ES data。 | +| 名称 | 值 | 说明 | +| ----------------------------- | ---- | ------------------------------------------------------------ | +| VIDEO_SOURCE_TYPE_SURFACE_YUV | 0 | 输入surface中携带的是raw data。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| VIDEO_SOURCE_TYPE_SURFACE_ES | 1 | 输入surface中携带的是ES data。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | ## VideoRecorderProfile8+ 视频录制的配置文件。 -| 名称 | 参数类型 | 必填 | 说明 | -| ---------------- | -------------------------------------------- | ---- | ---------------- | -| audioBitrate | number | 是 | 音频编码比特率。 | -| audioChannels | number | 是 | 音频采集声道数。 | -| audioCodec | [CodecMimeType](#CodecMimeType8) | 是 | 音频编码格式。 | -| audioSampleRate | number | 是 | 音频采样率。 | -| fileFormat | [ContainerFormatType](#containerformattype8) | 是 | 文件的容器格式。 | -| videoCodec | [CodecMimeType](#CodecMimeType8) | 是 | 视频编码格式。 | -| videoFrameWidth | number | 是 | 录制视频帧的宽。 | -| videoFrameHeight | number | 是 | 录制视频帧的高。 | +| 名称 | 参数类型 | 必填 | 说明 | +| ---------------- | -------------------------------------------- | ---- | ------------------------------------------------------------ | +| audioBitrate | number | 是 | 音频编码比特率。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| audioChannels | number | 是 | 音频采集声道数。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| audioCodec | [CodecMimeType](#CodecMimeType8) | 是 | 音频编码格式。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| audioSampleRate | number | 是 | 音频采样率。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| fileFormat | [ContainerFormatType](#containerformattype8) | 是 | 文件的容器格式。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| videoCodec | [CodecMimeType](#CodecMimeType8) | 是 | 视频编码格式。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| videoFrameWidth | number | 是 | 录制视频帧的宽。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | +| videoFrameHeight | number | 是 | 录制视频帧的高。
**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | ## ContainerFormatType8+ 表示容器格式类型的枚举,缩写为CFT。 -| 名称 | 值 | 说明 | -| ----------- | ----- | --------------------- | -| CFT_MPEG_4 | "mp4" | 视频的容器格式,MP4。 | -| CFT_MPEG_4A | "m4a" | 音频的容器格式,M4A。 | +| 名称 | 值 | 说明 | +| ----------- | ----- | ------------------------------------------------------------ | +| CFT_MPEG_4 | "mp4" | 视频的容器格式,MP4。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| CFT_MPEG_4A | "m4a" | 音频的容器格式,M4A。
**系统能力:** SystemCapability.Multimedia.Media.Core | ## Location8+ 视频录制的地理位置。 -| 名称 | 参数类型 | 必填 | 说明 | -| --------- | -------- | ---- | ---------------- | -| latitude | number | 是 | 地理位置的纬度。 | -| longitude | number | 是 | 地理位置的经度。 | \ No newline at end of file +| 名称 | 参数类型 | 必填 | 说明 | +| --------- | -------- | ---- | ------------------------------------------------------------ | +| latitude | number | 是 | 地理位置的纬度。
**系统能力:** SystemCapability.Multimedia.Media.Core | +| longitude | number | 是 | 地理位置的经度。
**系统能力:** SystemCapability.Multimedia.Media.Core | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md new file mode 100644 index 0000000000000000000000000000000000000000..06cc8523579c2ae03a8663ad3eb8c167bbd10685 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @@ -0,0 +1,1909 @@ +媒体库管理 +========== +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API Version 6开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + + 导入模块 +--------- + +``` +import mediaLibrary from '@ohos.multimedia.medialibrary'; +``` + +## mediaLibrary.getMediaLibrary + +getMediaLibrary(context: Context): MediaLibrary + +获取媒体库的实例,用于访问和修改用户的个人数据信息。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------- | ---- | -------------------- | +| context | Context | 是 | API7以下接口可不传此参数,API 8以上接口此参数是必填参数,传入Ability实例的context,获取媒体库 | + +**返回值:** + +| 类型 | 说明 | +| ------------ | :----- | +| [MediaLibrary](#medialibrary) | 媒体库实例 | + +**示例:** + +``` +import featureAbility from '@ohos.ability.featureAbility'; + +var context = featureAbility.getContext() +var media = mediaLibrary.getMediaLibrary(context); +``` +## MediaLibrary + +### getFileAssets8+ + + +getFileAssets(options: MediaFetchOptions, callback: AsyncCallback<FetchFileResult>): void + +获取文件资源,使用callback方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ---- | --------------------------------- | +| options | [MediaFetchOptions](#mediafetchoptions8) | 是 | 文件获取选项 | +| callback | AsyncCallback<[FetchFileResult](#fetchfileresult8)> | 是 | 异步获取FetchFileResult之后的回调 | + +**示例:** + +``` +let fileKeyObj = mediaLibrary.FileKey +let imageType = mediaLibrary.MediaType.IMAGE +let imagesfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], +}; +mediaLibrary.getFileAssets(imagesfetchOp, (error, fetchFileResult) => { + if (fetchFileResult != undefined) { + console.info('mediaLibraryTest : ASSET_CALLBACK fetchFileResult success'); + fetchFileResult.getAllObject((err, fileAssetList) => { + if (fileAssetList != undefined) { + fileAssetList.forEach(getAllObjectInfo); + } + }); + } +}); +``` +### getFileAssets8+ + +getFileAssets(options: MediaFetchOptions): Promise<FetchFileResult> + +获取文件资源,使用Promise方式返回结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ------------ | +| options | [MediaFetchOptions](#mediafetchoptions8) | 是 | 文件检索选项 | + +**返回值** + +| 类型 | 说明 | +| ----------------------------- | -------------- | +| [FetchFileResult](#fetchfileresult8) | 文件数据结果集 | + +**示例:** + +``` +let fileKeyObj = mediaLibrary.FileKey +let imageType = mediaLibrary.MediaType.IMAGE +let imagesfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], +}; +mediaLibrary.getFileAssets(imagesfetchOp).then(function(fetchFileResult){ + console.info("getFileAssets successfully:"+ JSON.stringify(dir)); +}).catch(function(err){ + console.info("getFileAssets failed with error:"+ err); +}); +``` + +### on8+ + +on(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange', callback: Callback<void>): void + +打开媒体媒体库变更通知,使用callback方式返回异步结果。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------- | ---- | ------------------- | +| type | string | 是 | 媒体类型
'deviceChange': 注册设备变更
'albumChange': 相册变更
'imageChange': 图片文件变更
'audioChange':  音频文件变更
'videoChange':  视频文件变更
'fileChange':  文件变更
'remoteFileChange': 注册设备上文件变更 | +| callback | callback<void> | 是 | 回调返回空 | + +**示例:** + +``` +mediaLibrary.on('imageChange', () => { + // image file had changed, do something +}) +``` +### off8+ + +off(type: 'deviceChange'|'albumChange'|'imageChange'|'audioChange'|'videoChange'|'fileChange'|'remoteFileChange', callback?: Callback<void>): void + +关闭媒体媒体库变更通知,使用callback方式返回异步结果。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------- | ---- | ------------------- | +| type | string | 是 | 媒体类型
'deviceChange': 注册设备变更
'albumChange': 相册变更
'imageChange': 图片文件变更
'audioChange':  音频文件变更
'videoChange':  视频文件变更
'fileChange':  文件变更
'remoteFileChange': 注册设备上文件变更 | +| callback | callback<void> | 否 | 回调返回空 | + +**示例:** + +``` +mediaLibrary.off('imageChange', () => { + // stop listening success +}) +``` + +### createAsset 8+ + +createAsset(mediaType: MediaType, displayName: string, relativePath: string, callback: AsyncCallback<FileAsset>): void + +创建媒体资源,使用callback方式返回结果。 + +**需要权限**:ohos.permission.READ_MEDIA, ohos.permission.WRITE_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | --------------------------------------- | ---- | ------------------------------------------------------------ | +| mediaType | [MediaType](#mediatype) | 是 | 媒体类型 | +| displayName | string | 是 | 展示文件名 | +| relativePath | string | 是 | 文件保存路径,可以通过[getPublicDirectory](#getpublicdirectory8)获取不同类型文件的保存路径 | +| callback | AsyncCallback<[FileAsset](#fileasset8)> | 是 | 异步获取媒体数据FileAsset之后的回调 | + +**示例:** + +``` +async function example() { + // 使用Callback方式创建Image类型文件 + let mediaType = mediaLibrary.MediaType.IMAGE; + let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; + const path = await media.getPublicDirectory(DIR_IMAGE); + mediaLibrary.createAsset(mediaType, 'imageCallBack.jpg', path + 'myPicture/', (err, fileAsset) => { + if (fileAsset != undefined) { + console.info('createAsset successfully, message = ' + err); + } else { + console.info('createAsset failed, message = ' + err); + } + }); +} +``` + +### createAsset8+ + +createAsset(mediaType: MediaType, displayName: string, relativePath: string): Promise<FileAsset> + +创建媒体资源,使用Promise方式返回结果。 + +**需要权限**:ohos.permission.READ_MEDIA, ohos.permission.WRITE_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ----------------------- | ---- | ------------------------------------------------------------ | +| mediaType | [MediaType](#mediatype) | 是 | 媒体类型 | +| displayName | string | 是 | 展示文件名 | +| relativePath | string | 是 | 相对路径,可以通过getPublicDirectory获取不同类型媒体文件的一层目录的relative path | + +**返回值** + +| 类型 | 说明 | +| ------------------------ | ----------------- | +| [FileAsset](#fileasset8) | 媒体数据FileAsset | + +**示例:** + +``` +async function example() { + // 使用Promise方式创建Image类型文件 + let mediaType = mediaLibrary.MediaType.IMAGE; + let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; + const path = await media.getPublicDirectory(DIR_IMAGE); + mediaLibrary.createAsset(mediaType, "image01.jpg", path + 'myPicture/').then (function (asset) { + console.info("createAsset successfully:"+ JSON.stringify(asset)); + }).catch(function(err){ + console.info("createAsset failed with error:"+ err); + }); +} +``` + +### getPublicDirectory8+ + +getPublicDirectory(type: DirectoryType, callback: AsyncCallback<string>): void + +获取公共目录路径,使用callback方式返回结果。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------------- | ---- | ------------ | +| type | [DirectoryType](#directorytype) | 是 | 公共目录类型 | +| callback |AsyncCallback<string> | 是 | callback 返回公共目录路径 | + +**示例:** + +``` +let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; +media.getPublicDirectory(DIR_CAMERA, (err, dicResult) => { + if (dicResult == 'Camera/') { + console.info('mediaLibraryTest : getPublicDirectory passed'); + } else { + console.info('mediaLibraryTest : getPublicDirectory failed'); + } +}); +``` + +### getPublicDirectory8+ + +getPublicDirectory(type: DirectoryType): Promise<string> + +获取公共目录路径,使用Promise方式返回结果。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------------------------------- | ---- | ------------ | +| type | [DirectoryType](#directorytype) | 是 | 公共目录类型 | + +**返回值:** + +| 类型 | 说明 | +| --------------- | ---------------- | +| Promise | 返回公共目录路径 | + +**示例:** + +``` +async function example() { + let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; + const dicResult = await media.getPublicDirectory(DIR_CAMERA); + if (dicResult == 'Camera/') { + console.info('MediaLibraryTest : getPublicDirectory'); + } else { + console.info('MediaLibraryTest : getPublicDirectory failed'); + } +} +``` + +### getAlbums8+ + +getAlbums(options: MediaFetchOptions, callback: AsyncCallback): void + +获取相册列表,使用callback 方式返回结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------------- | ---- | --------------------------- | +| options | [MediaFetchOptions](#mediafetchoptions8) | 是 | 相册获取条件 | +| callback | AsyncCallback<Array<[Album](#album8)>> | 是 | 异步获取Album列表之后的回调 | + +**示例:** + +``` +let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], +}; +mediaLibrary.getAlbums(AlbumNoArgsfetchOp, (err, albumList) => { + if (albumList != undefined) { + const album = albumList[0]; + console.info('album.albumName = ' + album.albumName); + console.info('album.count = ' + album.count); + } else { + console.info('getAlbum fail, message = ' + err); + } +}) +``` + +### getAlbums8+ + +getAlbums(options: MediaFetchOptions): Promise + +获取相册列表,使用 promise 方式返回结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ------------ | +| options | [MediaFetchOptions](#mediafetchoptions8) | 是 | 相册获取条件 | + +**返回值:** + +| 类型 | 说明 | +| -------------------------------- | ------------- | +| Promise> | 返回Album列表 | + +**示例:** + +``` +let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], +}; +mediaLibrary.getAlbums(AlbumNoArgsfetchOp).then(function(albumList){ + console.info("getAlbums successfully:"+ JSON.stringify(albumList)); +}).catch(function(err){ + console.info("getAlbums failed with error:"+ err); +}); +``` + +### release8+ + +release(callback: AsyncCallback<void>): void + +释放MediaLibrary实例。 +当后续不需要使用MediaLibrary实例中的方法时调用。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ---------------------- | +| callback | AsyncCallback<void> | 是 | 回调表示成功还是失败 | + +**示例:** + +``` +var media = mediaLibrary.getMediaLibrary(context); +media.release((err) => { + // do something +}); +``` + +### release8+ + +release(): Promise<void> + +释放MediaLibrary实例。 +当后续不需要使用MediaLibrary实例中的方法时调用。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值:** + +| 类型 | 说明 | +| ------------- | ----------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果 | + +**示例:** + +``` +var media = mediaLibrary.getMediaLibrary(context); +media.release() +``` + +## FileAsset8+ + +提供封装文件属性的方法。 + +### **属性** + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------ | ----------------------- | ---- | ---- | ------------------------------------------------------ | +| id | number | 是 | 否 | 文件资源编号 | +| uri | string | 是 | 否 | 文件资源uri(如:dataability:///media/image/2) | +| mimeType | string | 是 | 否 | 文件扩展属性 | +| mediaType | [MediaType](#mediatype) | 是 | 否 | 媒体类型 | +| displayName | string | 是 | 是 | 显示文件名,包含后缀名 | +| title | string | 是 | 是 | 文件标题 | +| relativePath | string | 是 | 是 | 相对公共目录路径 | +| parent | number | 是 | 否 | 父目录id | +| size | number | 是 | 否 | 文件大小(单位:字节) | +| dateAdded | number | 是 | 否 | 添加日期(添加文件时间到1970年1月1日的秒数值) | +| dateModified | number | 是 | 否 | 修改日期(修改文件时间到1970年1月1日的秒数值) | +| dateTaken | number | 是 | 否 | 拍摄日期(文件拍照时间到1970年1月1日的秒数值) | +| artist | string | 是 | 否 | 作者 | +| audioAlbum | string | 是 | 否 | 专辑 | +| width | number | 是 | 否 | 图片宽度(单位:像素) | +| height | number | 是 | 否 | 图片高度(单位:像素) | +| orientation | number | 是 | 是 | 图片显示方向(顺时针旋转角度,如0,90,180 单位:度) | +| duration | number | 是 | 否 | 持续时间(单位:秒) | +| albumId | number | 是 | 否 | 文件所归属的相册编号 | +| albumUri | string | 是 | 否 | 文件所归属相册uri | +| albumName | string | 是 | 否 | 文件所归属相册名称 | + + +### isDirectory8+ + +isDirectory(callback: AsyncCallback<boolean>): void + +判断fileAsset是否为目录,使用callback方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ----------------------------- | +| callback | AsyncCallback<boolean> | 是 | 当前FileAsset是否是目录的回调 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isDirectory((err, isDirectory) => { + // do something + }); +} +``` + +### isDirectory8+ + +isDirectory():Promise<boolean> + +判断fileAsset是否为目录,使用Promise方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值:** + +| 类型 | 说明 | +| ---------------- | ------------------------------------------ | +| Promise<boolean> | Promise实例,返回当前FileAsset是否是目录 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isDirectory().then(function(isDirectory){ + console.info("isDirectory result:"+ isDirectory); + }).catch(function(err){ + console.info("isDirectory failed with error:"+ err); + }); +} +``` + +### commitModify8+ + +commitModify(callback: AsyncCallback<void>): void + +修改文件的元数据,使用callback方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA, ohos.permission.WRITE_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | -------------------- | +| callback | AsyncCallback<void> | 是 | 回调返回空 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.title = 'newtitle'; + asset.commitModify(() => { + console.info('commitModify success'); + }); +} +``` + +### commitModify8+ + +commitModify(): Promise<void> + +修改文件的元数据,使用promise方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA, ohos.permission.WRITE_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值:** + +| 类型 | 说明 | +| ------------- | ----------------------------- | +| Promise<void> | Promise返回空 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.title = 'newtitle'; + asset.commitModify(); +} +``` + +### open8+ + +open(mode: string, callback: AsyncCallback<number>): void + +打开当前文件,使用callback方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA('r'模式打开),ohos.permission.WRITE_MEDIA('w'模式打开) + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | -------------------- | +| mode | string | 是 | 打开文件方式,如:'r'(只读), 'w'(只写), 'rw'(读写) | +| callback | AsyncCallback<number> | 是 | 回调返回文件句柄 | + +**示例:** + +``` +async function example() { + let mediaType = mediaLibrary.MediaType.IMAGE; + let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; + const path = await media.getPublicDirectory(DIR_IMAGE); + asset = await media.createAsset(mediaType, "image00003.jpg", path); + asset.open('rw', (openError, fd) => { + if(fd > 0){ + asset.close(fd); + }else{ + console.info('File Open Failed!' + openError); + } + }); +} +``` + +### open8+ + +open(mode: string): Promise<number> + +打开当前文件,使用promise方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA('r'模式打开),ohos.permission.WRITE_MEDIA('w'模式打开) + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------------------------------------- | +| mode | string | 是 | 打开文件方式,如:'r'(只读), 'w'(只写), 'rw'(读写) | + +**返回值:** + +| 类型 | 说明 | +| ------------- | ----------------------------- | +| Promise<number> | Promise返回文件句柄 | + +**示例:** + +``` +async function example() { + let mediaType = mediaLibrary.MediaType.IMAGE; + let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; + const path = await media.getPublicDirectory(DIR_IMAGE); + asset = await media.createAsset(mediaType, "image00003.jpg", path); + asset.open('rw').then((openError, fd) => { + if(fd > 0){ + asset.close(fd); + }else{ + console.info('File Open Failed!' + openError); + } + }); +} +``` + +### close8+ + +close(fd: number, callback: AsyncCallback<void>): void + +关闭当前文件,使用callback方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA('r'模式打开),ohos.permission.WRITE_MEDIA('w'模式打开) + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | -------------------- | +| fd | number | 是 | 文件描述符 | +| callback | AsyncCallback<void> | 是 | 回调返回空 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.close(fd, (closeErr) => { + if (closeErr != undefined) { + console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); + console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); + } else { + console.info("=======asset.close success====>"); + } + }); +} +``` + +### close8+ + +close(fd: number): Promise<void> + +关闭当前文件,使用promise方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA('r'模式打开),ohos.permission.WRITE_MEDIA('w'模式打开) + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------- | +| fd | number | 是 | 文件描述符 | + +**返回值:** + +| 类型 | 说明 | +| ------------- | ----------------------------- | +| Promise<void> | Promise返回空 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.close(fd).then((closeErr) => { + if (closeErr != undefined) { + console.info('mediaLibraryTest : close : FAIL ' + closeErr.message); + console.info('mediaLibraryTest : ASSET_CALLBACK : FAIL'); + + } else { + console.info("=======asset.close success====>"); + } + }); +} +``` + +### getThumbnail8+ + +getThumbnail(callback: AsyncCallback<image.PixelMap>): void + +获取文件的缩略图,使用callback方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | -------------------- | +| callback | AsyncCallback<image.PixelMap> | 是 | 回调返回缩略图的PixelMap | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.getThumbnail((err, pixelmap) => { + console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap); + }); +} +``` + +### getThumbnail8+ + +getThumbnail(size: Size, callback: AsyncCallback<image.PixelMap>): void + +获取文件的缩略图,传入缩略图尺寸,使用callback方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | -------------------- | +| size | [Size](#size8) | 是 | 缩略图尺寸 | +| callback | AsyncCallback<image.PixelMap> | 是 | 回调返回缩略图的PixelMap | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.getThumbnail(size, (err, pixelmap) => { + console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap); + }); +} +``` + +### getThumbnail8+ + +getThumbnail(size?: Size): Promise<image.PixelMap> + +获取文件的缩略图,传入缩略图尺寸,使用promise方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------- | ---- | ---------- | +| size | [Size](#size8) | 否 | 缩略图尺寸 | + +**返回值:** + +| 类型 | 说明 | +| ------------- | ----------------------------- | +| Promise<image.PixelMap> | Promise返回缩略图的PixelMap | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.getThumbnail(size, (err, pixelmap) => { + console.info('mediaLibraryTest : getThumbnail Successfull '+ pixelmap); + }); +} +``` + +### favorite8+ + +favorite(isFavorite: boolean, callback: AsyncCallback<void>): void + +将文件设置为收藏文件,使用callback方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA, ohos.permission.WRITE_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------- | ---- | -------------- | +| isFavorite | boolean | 是 | 是否设置为收藏文件, true:设置为收藏文件,false:取消收藏 | +| callback | AsyncCallback<void> | 是 | 回调返回空 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.favorite(true,function(err){ + // do something + }); +} +``` + +### favorite8+ + +favorite(isFavorite: boolean): Promise<void> + +将文件设置为收藏文件,使用promise方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA, ohos.permission.WRITE_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------- | ---- | ---------------------------------------------------------- | +| isFavorite | boolean | 是 | 是否设置为收藏文件, true:设置为收藏文件,false:取消收藏 | + +**返回值:** + +| 类型 | 说明 | +| ------------- | ----------------------------- | +| Promise<void> | Promise返回空 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.favorite(true).then(function() { + console.info("favorite successfully"); + }).catch(function(err){ + console.info("favorite failed with error:"+ err); + }); +} +``` + +### isFavorite8+ + +isFavorite(callback: AsyncCallback<boolean>): void + +判断该文件是否为收藏文件,使用callback方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | ---------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调表示是否为收藏文件 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isFavorite((err, isFavorite) => { + if (isFavorite) { + console.info('FileAsset is favorite'); + }else{ + console.info('FileAsset is not favorite'); + } + }); +} +``` + +### isFavorite8+ + +isFavorite():Promise<boolean> + +判断该文件是否为收藏文件,使用promise方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值:** + +| 类型 | 说明 | +| ------------- | ----------------------------- | +| Promise<boolean> | Promise回调表示是否是收藏文件 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isFavorite().then(function(isFavorite){ + console.info("isFavorite result:"+ isFavorite); + }).catch(function(err){ + console.info("isFavorite failed with error:"+ err); + }); +} +``` + +### trash8+ + +trash(isTrash: boolean, callback: AsyncCallback<void&g;): void + +当文件被定位时,将文件放到垃圾文件夹,使用callback方式返回异步结果。 + +放入垃圾文件夹的文件不会被真正删除,可以通过isTrash = false参数恢复成正常文件。 + +**需要权限**:ohos.permission.READ_MEDIA, ohos.permission.WRITE_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | -------------------- | +| isTrash | boolean | 是 | 是否设置为垃圾文件 | +| callback | AsyncCallback<void> | 是 | 回调返回空 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.trash(true, trashCallBack); + function trashCallBack(err, trash) { + console.info('mediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK trash'); + } +} +``` + +### trash8+ + +trash(isTrash: boolean,): Promise<void> + +当文件被定位时,将文件放到垃圾文件夹,使用promise方式返回异步结果。 + +放入垃圾文件夹的文件不会被真正删除,可以通过isTrash = false参数恢复成正常文件。 + +**需要权限**:ohos.permission.READ_MEDIA, ohos.permission.WRITE_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------- | ---- | ------------------ | +| isTrash | boolean | 是 | 是否设置为垃圾文件 | + +**返回值:** + +| 类型 | 说明 | +| ------------- | ----------------------------- | +| Promise<void> | Promise返回空 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.trash(true).then(function() { + console.info("trash successfully"); + }).catch(function(err){ + console.info("trash failed with error:"+ err); + }); +} +``` + +### isTrash8+ + +isTrash(callback: AsyncCallback<boolean>): void + +当文件被定位,判断文件是否为垃圾文件,使用callback方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------- | ---- | -------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调返回表示文件是否为垃圾文件 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isTrash(isTrashCallBack); + function isTrashCallBack(err, isTrash) { + if (isTrash == true) { + console.info('mediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isTrash = ' + isTrash); + asset.trash(true, trashCallBack); + + } else { + console.info('mediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessfull = ' + err); + console.info('mediaLibraryTest : ASSET_CALLBACK isTrash : FAIL'); + + } + } +} +``` + +### isTrash8+ + +isTrash():Promise<boolean> + +当文件被定位,判断文件是否为垃圾文件,使用promise方式返回异步结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值:** + +| 类型 | 说明 | +| ------------- | ----------------------------- | +| Promise<void> | Promise回调表示文件是否为垃圾文件 | + +**示例:** + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + const fetchFileResult = await media.getFileAssets(getImageOp); + const asset = await fetchFileResult.getFirstObject(); + asset.isTrash().then(function(isTrash){ + console.info("isTrash result:"+ isTrash); + }).catch(function(err){ + console.info("isTrash failed with error:"+ err); + }); +} +``` + +## FetchFileResult8+ + +文件检索结果集。 + +### getCount8+ + +getCount(): number + +获取文件检索结果中的文件总数。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值**: + +| 类型 | 说明 | +| ------ | ---------------- | +| number | 检索到的文件总数 | + +**示例**: + +``` +async function example() { + let getFileCountOneOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getFileCountOneOp); + const fetchCount = fetchFileResult.getCount(); +} +``` + +### isAfterLast8+ + +isAfterLast(): boolean + +检查结果集是否指向最后一行。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值**: + +| 类型 | 说明 | +| ------- | ----------------------------------------------------------- | +| boolean | 当读到最后一条记录后,后续没有记录返回true,否则返回false。 | + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + const fetchCount = fetchFileResult.getCount(); + console.info('mediaLibraryTest : count:' + fetchCount); + let fileAsset = await fetchFileResult.getFirstObject(); + for (var i = 1; i < fetchCount; i++) { + fileAsset = await fetchFileResult.getNextObject(); + if(i == fetchCount - 1) { + console.info('mediaLibraryTest : isLast'); + var result = fetchFileResult.isAfterLast(); + console.info('mediaLibraryTest : isAfterLast:' + result); + console.info('mediaLibraryTest : isAfterLast end'); + fetchFileResult.close(); + + } + } +} +``` + +### close8+ + +close(): void + +释放 FetchFileResult 实例并使其失效。无法调用其他方法。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.close(); +} +``` + +### getFirstObject8+ + +getFirstObject(callback: AsyncCallback<FileAsset>): void + +获取文件检索结果中的第一个文件资产。此方法使用回调返回FileAsset。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------- | ---- | ------------------------------------------- | +| callback | AsyncCallback<[FileAsset](#fileasset8)> | 是 | 异步获取结果集中第一个FileAsset完成后的回调 | + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getFirstObject((err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getFirstObject8+ + +getFirstObject(): Promise<FileAsset> + +获取文件检索结果中的第一个文件资产。此方法使用返回FileAsset。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值**: + +| 类型 | 说明 | +| ------------------ | -------------------------------------- | +| Promise<[FileAsset](#fileasset8)> | Promise方式返回FileAsset | + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getFirstObject().then(function(fileAsset){ + console.info("getFirstObject successfully:"+ JSON.stringify(fileAsset)); + }).catch(function(err){ + console.info("getFirstObject failed with error:"+ err); + }); +} +``` + +### getNextObject8+ + + getNextObject(callback: AsyncCallback<FileAsset>): void + +获取文件检索结果中的下一个文件资产。此方法使用callback形式返回结果。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | --------------------------------------------- | ---- | ----------------------------------------- | +| callbacke | AsyncCallback<[FileAsset](#fileasset8)> | 是 | 异步返回结果集中下一个FileAsset之后的回调 | + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getNextObject((err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getNextObject8+ + + getNextObject(): Promise<FileAsset> + +获取文件检索结果中的下一个文件资产。此方法使用promise方式来异步返回FileAsset。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值**: + +| 类型 | 说明 | +| -------------------------------- | ------------------- | +| Promise<[FileAsset](#fileasset8)> | 返回FileAsset对象 | + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + const fetchCount = fetchFileResult.getCount(); + console.info('mediaLibraryTest : count:' + fetchCount); + fileAsset = await fetchFileResult.getNextObject(); +} +``` + +### getLastObject8+ + +getLastObject(callback: AsyncCallback<FileAsset>): void + +获取文件检索结果中的最后一个文件资产。此方法使用callback回调来返回FileAsset。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数**: + +| 参数 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------- | ---- | --------------------------- | +| callback | AsyncCallback<[FileAsset](#fileasset8)> | 是 | 异步返回FileAsset之后的回调 | + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getLastObject((err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getLastObject8+ + +getLastObject(): Promise<FileAsset> + +获取文件检索结果中的最后一个文件资产。此方法使用Promise方式来返回FileAsset。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值**: + +| 类型 | 说明 | +| -------------------------------- | ------------------- | +| Promise<[FileAsset](#fileasset8)> | 返回FileAsset对象 | + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + let lastObject = await fetchFileResult.getLastObject(); +} +``` + +### getPositionObject8+ + +getPositionObject(index: number, callback: AsyncCallback<FileAsset>): void + +获取文件检索结果中具有指定索引的文件资产。此方法使用回调来返回FileAsset。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数**: + +| 参数 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------- | ---- | --------------------------- | +| index | number | 是 | 要获取的文件的索引,从0开始 | +| callback | AsyncCallback<[FileAsset](#fileasset8)> | 是 | 异步返回FileAsset之后的回调 | + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getPositionObject(0, (err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getPositionObject8+ + +getPositionObject(index: number): Promise<FileAsset> + +获取文件检索结果中具有指定索引的文件资产。此方法使用Promise形式返回文件Asset。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数**: + +| 参数 | 类型 | 必填 | 说明 | +| ----- | ------ | ---- | -------------------- | +| index | number | 是 | 要获取的文件的索引,从0开始 | + +**返回值**: + +| 类型 | 说明 | +| -------------------------------- | ------------------- | +| Promise<[FileAsset](#fileasset8)> | 返回FileAsset对象 | + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getPositionObject(1, (err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getAllObject8+ + +getAllObject(callback: AsyncCallback<Array<FileAsset>>): void + +获取文件检索结果中的所有文件资产。此方法使用Callback回调来返回FileAsset结果集。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数**: + +| 参数 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------- | ---- | ------------------------------- | +| callback | AsyncCallback> | 是 | 异步返回FileAsset列表之后的回调 | + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + fetchFileResult.getAllObject((err, value) => { + if (err) { + console.error('Failed '); + return; + } + console.log(value); + }) +} +``` + +### getAllObject8+ + +getAllObject(): Promise<Array<FileAsset>> + +获取文件检索结果中的所有文件资产。此方法使用Promise来返回FileAsset结果集。 + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值**: + +| 类型 | 说明 | +| ---------------------------------------- | --------------------- | +| Promise> | 返回FileAsset对象列表 | + +**示例**: + +``` +async function example() { + let imageType = mediaLibrary.MediaType.IMAGE; + let getImageOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC", + extendArgs: "", + }; + let fetchFileResult = await media.getFileAssets(getImageOp); + var data = fetchFileResult.getAllObject(); +} +``` + +## Album8+ + +实体相册 + +### **属性** + +| 名称 | 参数型 | 可读 | 可写 | 说明 | +| ------------ | ------ | ---- | ---- | -------------- | +| albumId | number | 是 | 否 | 相册编号 | +| albumName | string | 是 | 是 | 相册名称 | +| albumUri | string | 是 | 否 | 相册Uri | +| dateModified | number | 是 | 否 | 修改日期 | +| count | number | 是 | 否 | 相册中文件数量 | +| relativePath | string | 是 | 否 | 相对路径 | +| coverUri | string | 是 | 否 | 封面文件Uri | + +### commitModify8+ + +commitModify(callback: AsyncCallback<void>): void + +更新相册属性修改到数据库中。 + +**需要权限**:ohos.permission.READ_MEDIA, ohos.permission.WRITE_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数**: + +| 参数 | 类型 | 必填 | 说明 | +| -------- | ------------------- | ---- | ----------------------------- | +| callback | AsyncCallback<void> | 是 | 回调返回空 | + +**示例**: + +``` +async function example() { + let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], + }; + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + album.albumName = 'hello'; + album.commitModify((err) => { + if (err) { + console.error('Failed '); + return; + } + console.log('Modify successful.'); + }) +} +``` + +### commitModify8+ + +commitModify(): Promise<void> + +更新相册属性修改到数据库中。 + +**需要权限**:ohos.permission.READ_MEDIA, ohos.permission.WRITE_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**返回值**: + +| 类型 | 说明 | +| ------------- | ---------------------------------------------------- | +| Promise<void> | Promise调用返回空 | + +**示例**: + +``` +async function example() { + let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], + }; + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + album.albumName = 'hello'; + album.commitModify().then(function() { + console.info("commitModify successfully"); + }).catch(function(err){ + console.info("commitModify failed with error:"+ err); + }); +} +``` + +### getFileAssets8+ + +getFileAssets(options: MediaFetchOptions, callback: AsyncCallback<FetchFileResult>): void + +按照检索条件获取相册中的文件。此方法使用Callback回调来返回文件结果集。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数**: + +| 参数 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------------- | ---- | --------------------------------- | +| options | [MediaFetchOptions](#mediafetchoptions8) | 是 | 媒体检索选项 | +| callback | AsyncCallback<[FetchFileResult](#fetchfileresult8)> | 是 | 异步返回FetchFileResult之后的回调 | + +**示例**: + +``` +async function example() { + let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], + }; + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + album.getFileAssets(fileNoArgsfetchOp, getFileAssetsCallBack); + function getFileAssetsCallBack(err, fetchFileResult) { + // do something + } +} +``` + +### getFileAssets8+ + + getFileAssets(options?: MediaFetchOptions): Promise<FetchFileResult> + +按照检索条件获取相册中的文件。此方法使用异步回调来返回文件结果集。 + +**需要权限**:ohos.permission.READ_MEDIA + +**系统能力**:SystemCapability.Multimedia.MediaLibrary.Core + +**参数**: + +| 参数 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ------------ | +| options | [MediaFetchOptions](#mediafetchoptions8) | 否 | 媒体检索选项 | + +**返回值**: + +| 类型 | 说明 | +| --------------------------------------------- | ----------------------- | +| Promise<[FetchFileResult](#fetchfileresult8)> | 返回FetchFileResult对象 | + +**示例**: + +``` +async function example() { + let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], + }; + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + album.getFileAssets(fileNoArgsfetchOp).then(function(albumFetchFileResult){ + console.info("getFileAssets successfully:"+ JSON.stringify(albumFetchFileResult)); + }).catch(function(err){ + console.info("getFileAssets failed with error:"+ err); + }); +} +``` + +## PeerInfo8+ + +注册设备的信息。 + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---------- | ---------- | ---- | ---- | ---------------- | +| deviceName | string | 是 | 否 | 注册设备的名称 | +| networkId | string | 是 | 否 | 注册设备的网络ID | +| deviceType | DeviceType | 是 | 否 | 设备类型 | +| isOnline | boolean | 是 | 否 | 是否在线 | + + + +MediaType +--------- + +枚举,媒体类型。 + +| 名称 | 默认值 | 描述 | +| ----- | ------ | ---- | +| FILE | 0 | 文件 | +| IMAGE | 1 | 图片 | +| VIDEO | 2 | 视频 | +| AUDIO | 3 | 音频 | + +FileKey +------- + +枚举,文件关键信息。 + +| 名称 | 默认值 | 描述 | +| ------------- | ------------------- | ---------------------------------------------------------- | +| ID | file_id | 文件编号 | +| RELATIVE_PATH | relative_path | 相对公共目录路径 | +| DISPLAY_NAME | display_name | 显示名字 | +| PARENT | parent | 父目录id | +| MIME_TYPE | mime_type | 文件扩展属性 | +| MEDIA_TYPE | media_type | 媒体类型 | +| SIZE | size | 文件大小(单位:字节) | +| DATE_ADDED | date_added | 添加日期(添加文件时间到1970年1月1日的秒数值) | +| DATE_MODIFIED | date_modified | 修改日期(修改文件时间到1970年1月1日的秒数值) | +| DATE_TAKEN | date_taken | 拍摄日期(文件拍照时间到1970年1月1日的秒数值) | +| TITLE | title | 文件标题 | +| ARTIST | artist | 作者 | +| AUDIOALBUM | audio_album | 专辑 | +| DURATION | duration | 持续时间(单位:秒) | +| WIDTH | width | 图片宽度(单位:像素) | +| HEIGHT | height | 图片高度(单位:像素) | +| ORIENTATION | orientation | 图片显示方向,即顺时针旋转角度,如0,90,180。(单位:度) | +| ALBUM_ID | bucket_id | 文件所归属的相册编号 | +| ALBUM_NAME | bucket_display_name | 文件所归属相册名称 | + +DirectoryType +------------- + +枚举,目录类型。 + +| 名称 | 默认值 | 描述 | +| ------------- | ------ | ------------------ | +| DIR_CAMERA | 0 | 表示Camera文件路径 | +| DIR_VIDEO | 1 | 表示视频路径 | +| DIR_IMAGE | 2 | 表示图片路径 | +| DIR_AUDIO | 3 | 表示音频路径 | +| DIR_DOCUMENTS | 4 | 表示文档路径 | +| DIR_DOWNLOAD | 5 | 表示下载路径 | + +DeviceType +----------- + +枚举,设备类型。 + +| 名称 | 默认值 | 描述 | +| ------------ | ------ | ---------- | +| TYPE_UNKNOWN | 0 | 未识别设备 | +| TYPE_LAPTOP | 1 | 笔记本电脑 | +| TYPE_PHONE | 2 | 手机 | +| TYPE_TABLET | 3 | 平板电脑 | +| TYPE_WATCH | 4 | 智能手表 | +| TYPE_CAR | 5 | 车载设备 | +| TYPE_TV | 6 | 电视设备 | + +## MediaFetchOptions8+ + +检索条件。 + +| 名称 | 类型 | 可读 | 可写 | 必填 |说明 | +| ------------- | ------------- | ---- | ---- | ---- |---------------- | +| selections | string | 是 | 是 |是 | 检索条件,使用[FileKey](#filekey)中的枚举值作为检索条件的列名。示例:
selections: mediaLibrary.FileKey.MEDIA_TYPE + '= ? OR' +mediaLibrary.FileKey.MEDIA_TYPE + '= ?‘, | +| selectionArgs | Array<string> | 是 | 是 |是 | 检索条件的值,对应selections中检索条件列的值。
示例:
selectionArgs: [mediaLibrary.MediaType.IMAGE.toString(), mediaLibrary.MediaType.VIDEO.toString()], | +| order | string | 是 | 是 | 否 |检索结果排序方式,使用[FileKey](#filekey)中的枚举值作为检索结果排序的列,可以用升序或降序排列。示例:
升序排列:order: mediaLibrary.FileKey.DATE_ADDED + " AESC"
降序排列:order: mediaLibrary.FileKey.DATE_ADDED + " DESC" | +| uri | string | 是 | 是 | 否 |文件URI | +| networkId | string | 是 | 是 | 否 |注册设备网络ID | +| extendArgs | string | 是 | 是 | 否 |扩展的检索参数,目前没有扩展检索参数 | + +## Size8+ + +图片尺寸。 + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------ | ------ | ---- | ---- | ---------------- | +| width | number | 是 | 是 | 宽(单位:像素) | +| height | number | 是 | 是 | 高(单位:像素) | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md new file mode 100644 index 0000000000000000000000000000000000000000..107a0b739fdef9400beda39e01091f9534a47859 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md @@ -0,0 +1,956 @@ +# 网络连接管理 + + +> **说明:** +> +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +```javascript +import connection from '@ohos.net.connection' +``` + +## connection.getDefaultNet + +getDefaultNet(callback: AsyncCallback\): void + +获取默认激活的数据网络,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------- | ---- | ---------- | +| callback | AsyncCallback\<[NetHandle](#nethandle)> | 是 | 回调函数。 | + +**示例:** + +```javascript +connection.getDefaultNet(function (error, netHandle) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(netHandle)) +}) +``` + +## connection.getDefaultNet + +getDefaultNet(): Promise\ + +获取默认激活的数据网络,使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**返回值:** + +| 类型 | 说明 | +| --------------------------------- | ------------------------------------- | +| Promise\<[NetHandle](#nethandle)> | 以Promise形式返回默认激活的数据网络。 | + +**示例:** + +```javascript +connection.getDefaultNet().then(function (netHandle) { + console.log(JSON.stringify(netHandle)) +}) +``` + +## connection.hasDefaultNet + +hasDefaultNet(callback: AsyncCallback\): void + +检查默认数据网络是否被激活,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------- | +| callback | AsyncCallback\ | 是 | 回调函数,默认数据网络被激活返回true。 | + +**示例:** + +```javascript +connection.hasDefaultNet(function (error, has) { + console.log(JSON.stringify(error)) + console.log(has) +}) +``` + +## connection.hasDefaultNet + +hasDefaultNet(): Promise\ + +检查默认数据网络是否被激活,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ----------------------------------------------- | +| Promise\ | 以Promise形式返回,默认数据网络被激活返回true。 | + +**示例:** + +```javascript +connection.hasDefaultNet().then(function (has) { + console.log(has) +}) +``` + +## connection.getAllNets + +getAllNets(callback: AsyncCallback<Array<NetHandle>>): void + +获取全部激活的数据网络列表,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<Array<[NetHandle](#nethandle)>> | 是 | 回调函数。 | + +**示例:** + +``` +connection.getAllNets(function (error, nets) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(nets)) +}); +``` + + +## connection.getAllNets + +getAllNets(): Promise<Array<NetHandle>> + +获取全部激活的数据网络列表,使用promise方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**返回值:** +| 类型 | 说明 | +| -------- | -------- | +| Promise<Array<[NetHandle](#nethandle)>> | 以Promise形式返回激活的数据网络列表。 | + +**示例:** + +``` +connection.getAllNets().then(function (nets) { + console.log(JSON.stringify(nets)) +}); +``` + +## connection.getConnectionProperties + +getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback\): void + +获取netHandle对应的网络的连接信息,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------------------------------------------ | ---- | ---------------- | +| netHandle | [NetHandle](#nethandle) | 是 | 数据网络的句柄。 | +| callback | AsyncCallback\<[ConnectionProperties](#connectionproperties)> | 是 | 回调函数。 | + +**示例:** + +```javascript +connection.getDefaultNet().then(function (netHandle) { + connection.getConnectionProperties(netHandle, function (error, info) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(info)) + }) +}) +``` + +## connection.getConnectionProperties + +getConnectionProperties(netHandle: NetHandle): Promise\ + +获取netHandle对应的网络的连接信息,使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ----------------------- | ---- | ---------------- | +| netHandle | [NetHandle](#nethandle) | 是 | 数据网络的句柄。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------------------- | --------------------------------- | +| Promise\<[ConnectionProperties](#connectionproperties)> | 以Promise形式返回网络的连接信息。 | + +**示例:** + +```javascript +connection.getDefaultNet().then(function (netHandle) { + connection.getConnectionProperties(netHandle).then(function (info) { + console.log(JSON.stringify(info)) + }) +}) +``` + +## connection.getNetCapabilities + +getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback\): void + +获取netHandle对应的网络的能力信息,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | --------------------------------------------------- | ---- | ---------------- | +| netHandle | [NetHandle](#nethandle) | 是 | 数据网络的句柄。 | +| callback | AsyncCallback\<[NetCapabilities](#netcapabilities)> | 是 | 回调函数。 | + +**示例:** + +```javascript +connection.getDefaultNet().then(function (netHandle) { + connection.getNetCapabilities(netHandle, function (error, info) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(info)) + }) +}) +``` + +## connection.getNetCapabilities + +getNetCapabilities(netHandle: NetHandle): Promise\ + +获取netHandle对应的网络的能力信息,使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ----------------------- | ---- | ---------------- | +| netHandle | [NetHandle](#nethandle) | 是 | 数据网络的句柄。 | + +**返回值:** + +| 类型 | 说明 | +| --------------------------------------------- | --------------------------------- | +| Promise\<[NetCapabilities](#netcapabilities)> | 以Promise形式返回网络的能力信息。 | + +**示例:** + +```javascript +connection.getDefaultNet().then(function (netHandle) { + connection.getNetCapabilities(netHandle).then(function (info) { + console.log(JSON.stringify(info)) + }) +}) +``` + +## connection.reportNetConnected + +reportNetConnected(netHandle: NetHandle, callback: AsyncCallback<void>): void + +报告网络状态已连接,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO 和 ohos.permission.INTERNET + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| netHandle | [NetHandle](#nethandle) | 是 | 数据网络的句柄,参考[NetHandle](#nethandle)。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +``` +connection.getDefaultNet().then(function (netHandle) { + connection.reportNetConnected(netHandle, function (error) { + console.log(JSON.stringify(error)) + }); +}); +``` + + +## connection.reportNetConnected + +reportNetConnected(netHandle: NetHandle): Promise<void> + +报告网络状态已连接,使用promise方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO 和 ohos.permission.INTERNET + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| netHandle | [NetHandle](#nethandle) | 是 | 数据网络的句柄,参考[NetHandle](#nethandle)。 | + +**返回值:** +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 以Promise形式返回执行结果。 | + +**示例:** + +``` +connection.getDefaultNet().then(function (netHandle) { + connection.reportNetConnected(netHandle).then(function () { + console.log(`report success`) + }); +}); +``` + + +## connection.reportNetDisconnected + +reportNetDisconnected(netHandle: NetHandle, callback: AsyncCallback<void>): void + +报告网络状态已断开,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO 和 ohos.permission.INTERNET + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| netHandle | [NetHandle](#nethandle) | 是 | 数据网络的句柄,参考[NetHandle](#nethandle)。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +``` +connection.getDefaultNet().then(function (netHandle) { + connection.reportNetDisconnected(netHandle, function (error) { + console.log(JSON.stringify(error)) + }); +}); +``` + + +## connection.reportNetDisconnected + +reportNetDisconnected(netHandle: NetHandle): Promise<void> + +报告网络状态已断开,使用promise方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO 和 ohos.permission.INTERNET + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------- | -------- | -------- | +| netHandle | [NetHandle](#nethandle) | 是 | 数据网络的句柄,参考[NetHandle](#nethandle)。 | + +**返回值:** +| 类型 | 说明 | +| -------- | -------- | +| Promise<void> | 以Promise形式返回执行结果。 | + +**示例:** + +``` +connection.getDefaultNet().then(function (netHandle) { + connection.reportNetDisconnected(netHandle).then(function () { + console.log(`report success`) + }); +}); +``` + +## connection.getAddressesByName + +getAddressesByName(host: string, callback: AsyncCallback\>): void + +使用默认网络解析主机名以获取所有IP地址,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------- | ---- | ------------------ | +| host | string | 是 | 需要解析的主机名。 | +| callback | AsyncCallback\> | 是 | 回调函数。 | + +**示例:** + +``` +let host = "xxxx"; +connection.getAddressesByName(host, function (error, addresses) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(addresses)) +}) +``` + +## connection.getAddressesByName + +getAddressesByName(host: string): Promise\> + +使用默认网络解析主机名以获取所有IP地址,使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| host | string | 是 | 需要解析的主机名。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------- | ----------------------------- | +| Promise\> | 以Promise形式返回所有IP地址。 | + +**示例:** + +``` +let host = "xxxx"; +connection.getAddressesByName(host).then(function (addresses) { + console.log(JSON.stringify(addresses)) +}) +``` + +## connection.createNetConnection + +createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection + +获取一个netSpecifier指定的网络的句柄。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | +| netSpecifier | [NetSpecifier](#netspecifier) | 否 | 指定网络的各项特征,不指定则关注默认网络。 | +| timeout | number | 否 | 获取netSpecifier指定的网络时的超时时间,仅netSpecifier存在时生效。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------- | -------------------- | +| [NetConnection](#netconnection) | 所关注的网络的句柄。 | + +**示例:** + +```javascript +// 关注默认网络 +let netConnection = connection.createNetConnection() + +// 关注蜂窝网络 +let netConnectionCellular = connection.createNetConnection({ + netCapabilities: { + bearerTypes: [NetBearType.BEARER_CELLULAR] + } +}) +``` + +## NetConnection + +网络连接的句柄。 + +### on('netAvailable') + +on(type: 'netAvailable', callback: Callback\): void + +订阅网络可用事件。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 订阅事件,固定为'netAvailable'。
netAvailable:数据网络可用事件。 | +| callback | Callback\<[NetHandle](#nethandle)> | 是 | 回调函数。 | + +**示例:** + +```javascript +netConnection.on('netAvailable', function (data) { + console.log(JSON.stringify(data)) +}) +``` + +### on('netCapabilitiesChange') + +on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, netCap: NetCapabilities }>): void + +订阅网络能力变化事件。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 订阅事件,固定为'netCapabilitiesChange'。
netCapabilitiesChange:网络能力变化事件。 | +| callback | Callback<{ netHandle: [NetHandle](#nethandle), netCap: [NetCapabilities](#netcapabilities) }> | 是 | 回调函数。 | + +**示例:** + +```javascript +netConnection.on('netCapabilitiesChange', function (data) { + console.log(JSON.stringify(data)) +}) +``` + +### on('netConnectionPropertiesChange') + +on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }>): void + +订阅网络连接信息变化事件。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 订阅事件,固定为'netConnectionPropertiesChange'。
netConnectionPropertiesChange:网络连接信息变化事件。 | +| callback | Callback<{ netHandle: [NetHandle](#nethandle), connectionProperties: [ConnectionProperties](#connectionproperties) }> | 是 | 回调函数。 | + +**示例:** + +```javascript +netConnection.on('netConnectionPropertiesChange', function (data) { + console.log(JSON.stringify(data)) +}) +``` + +### on('netBlockStatusChange') + +on(type: 'netBlockStatusChange', callback: Callback<{ netHandle: NetHandle, blocked: boolean }>): void + +订阅网络阻塞状态事件,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 订阅事件,固定为'netBlockStatusChange'。
netBlockStatusChange:网络阻塞状态事件。 | +| callback | Callback<{ netHandle: [NetHandle](#nethandle), blocked: boolean }> | 是 | 回调函数。 | + +**示例:** + +```javascript +netConnection.on('netBlockStatusChange', function (data) { + console.log(JSON.stringify(data)) +}) +``` + +### on('netLost') + +on(type: 'netLost', callback: Callback\): void + +订阅网络丢失事件。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 订阅事件,固定为'netLost'。
netLost:网络严重中断或正常断开事件。 | +| callback | Callback\<[NetHandle](#nethandle)> | 是 | 回调函数。 | + +**示例:** + +```javascript +let netConnection1 = connection.createNetConnection() +netConnection1.on('netLost', function (data) { + console.log(JSON.stringify(data)) +}) +``` + +### on('netUnavailable') + +on(type: 'netUnavailable', callback: Callback\): void + +订阅网络不可用事件。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 订阅事件,固定为'netUnavailable'。
netUnavailable:网络不可用事件。 | +| callback | Callback\ | 是 | 回调函数。 | + +**示例:** + +```javascript +netConnection.on('netUnavailable', function (data) { + console.log(JSON.stringify(data)) +}) +``` + +### register + +register(callback: AsyncCallback\): void + +订阅指定网络状态变化的通知。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------- | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +```javascript +netConnection.register(function (error) { + console.log(JSON.stringify(error)) +}) +``` + +### unregister + +unregister(callback: AsyncCallback\): void + +取消订阅默认网络状态变化的通知。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------- | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +```javascript +netConnection.unregister(function (error) { + console.log(JSON.stringify(error)) +}) +``` + +## NetHandle + +数据网络的句柄。 + +在调用NetHandle的方法之前,需要先获取NetHandle对象。 + +### 属性 + +| 变量 | 类型 | 说明 | +| ----- | ------ | ------------------------- | +| netId | number | 网络ID,必须大于等于100。 | + +### bindSocket + +bindSocket(socketParam: TCPSocket | UDPSocket, callback: AsyncCallback<void>): void + +将TCPSocket或UDPSocket绑定到当前网络,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | ---------------- | +| socketParam | TCPSocket \| UDPSocket | 是 | TCPSocket或UDPSocket对象。 | +| callback | AsyncCallback<void> | 是 | 回调函数。 | + +**示例:** + +``` +// 绑定TCPSocket +connection.getDefaultNet().then(function (netHandle) { + let tcpSocket = socket.constructTCPSocketInstance() + netHandle.bindSocket(tcpSocket, (function (error) { + console.log(JSON.stringify(error)) + })) +}) +// 绑定UDPSocket +connection.getDefaultNet().then(function (netHandle) { + let udpSocket = socket.constructUDPSocketInstance() + netHandle.bindSocket(udpSocket, (function (error) { + console.log(JSON.stringify(error)) + })) +}) +``` + + +### bindSocket + +bindSocket(socketParam: TCPSocket | UDPSocket): Promise<void> + +将TCPSocket或UDPSocket绑定到当前网络,使用promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| socketParam | TCPSocket \| UDPSocket | 是 | TCPSocket或UDPSocket对象。 | + +**返回值:** +| 类型 | 说明 | +| ------------------- | --------------------------- | +| Promise<void> | 以Promise形式返回执行结果。 | + +**示例:** + +``` +// 绑定TCPSocket +connection.getDefaultNet().then(function (netHandle) { + let tcpSocket = socket.constructTCPSocketInstance() + netHandle.bindSocket(tcpSocket).then(function () { + console.log("bind socket success") + }) +}) +// 绑定UDPSocket +connection.getDefaultNet().then(function (netHandle) { + let udpSocket = socket.constructUDPSocketInstance() + netHandle.bindSocket(udpSocket).then(function () { + console.log("bind socket success") + }) +}) +``` + +### getAddressesByName + +getAddressesByName(host: string, callback: AsyncCallback\>): void + +使用对应网络解析主机名以获取所有IP地址,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------- | ---- | ------------------ | +| host | string | 是 | 需要解析的主机名。 | +| callback | AsyncCallback\> | 是 | 回调函数 | + +**示例:** + +```javascript +connection.getDefaultNet().then(function (netHandle) { + let host = "xxxx"; + netHandle.getAddressesByName(host, function (error, addresses) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(addresses)) + }) +}) +``` + +### getAddressesByName + +getAddressesByName(netHandle: NetHandle): Promise\> + +使用对应网络解析主机名以获取所有IP地址,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| host | string | 是 | 需要解析的主机名。 | + +**返回值:** + +| 类型 | 说明 | +| ------------------------------------------- | ----------------------------- | +| Promise\> | 以Promise形式返回所有IP地址。 | + +**示例:** + +```javascript +connection.getDefaultNet().then(function (netHandle) { + let host = "xxxx"; + netHandle.getAddressesByName(host).then(function (addresses) { + console.log(JSON.stringify(addresses)) + }) +}) +``` + +### getAddressByName + +getAddressByName(host: string, callback: AsyncCallback\): void + +使用对应网络解析主机名以获取第一个IP地址,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------ | +| host | string | 是 | 需要解析的主机名。 | +| callback | AsyncCallback\<[NetAddress](#netaddress)> | 是 | 回调函数。 | + +**示例:** + +```javascript +connection.getDefaultNet().then(function (netHandle) { + let host = "xxxx"; + netHandle.getAddressByName(host, function (error, address) { + console.log(JSON.stringify(error)) + console.log(JSON.stringify(address)) + }) +}) +``` + +### getAddressByName + +getAddressByName(netHandle: NetHandle): Promise\ + +使用对应网络解析主机名以获取第一个IP地址,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------ | +| host | string | 是 | 需要解析的主机名。 | + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------- | ------------------------------- | +| Promise\<[NetAddress](#netaddress)> | 以Promise形式返回第一个IP地址。 | + +**示例:** + +```javascript +connection.getDefaultNet().then(function (netHandle) { + let host = "xxxx"; + netHandle.getAddressByName(host).then(function (address) { + console.log(JSON.stringify(address)) + }) +}) +``` + +## NetSpecifier + +提供承载数据网络能力的实例。 + +| 变量 | 类型 | 说明 | +| ----------------------- | ----------------------------------- | ------------------------------------------------------------ | +| netCapabilities | [NetCapabilities](#netcapabilities) | 存储数据网络的传输能力和承载类型。 | +| bearerPrivateIdentifier | string | 网络标识符,WIFI网络的标识符是"wifi",蜂窝网络的标识符是"slot0"(对应SIM卡1)。 | + +## NetCapabilities + +网络的能力集。 + +| 变量 | 类型 | 说明 | +| --------------------- | ---------------------------------- | ------------------------ | +| linkUpBandwidthKbps | number | 上行(设备到网络)带宽。 | +| linkDownBandwidthKbps | number | 下行(网络到设备)带宽。 | +| networkCap | Array<[NetCap](#netcap)> | 网络具体能力。 | +| bearerTypes | Array<[NetBearType](#netbearType)> | 网络类型。 | + +## NetCap + +网络具体能力。 + +| 变量 | 值 | 说明 | +| ------------------------ | ---- | ---------------------- | +| NET_CAPABILITY_MMS | 0 | 表示网络可以访问运营商的MMSC(Multimedia Message Service,多媒体短信服务)发送和接收彩信。 | +| NET_CAPABILITY_NOT_METERED | 11 | 表示网络流量未被计费。 | +| NET_CAPABILITY_INTERNET | 12 | 网络可以访问Internet。 | +| NET_CAPABILITY_NOT_VPN | 15 | 表示网络不使用VPN(Virtual Private Network,虚拟专用网络)。 | +| NET_CAPABILITY_VALIDATED | 16 | 网络可用。 | + +## NetBearType + +网络类型。 + +| 变量 | 值 | 说明 | +| --------------- | ---- | ----------- | +| BEARER_CELLULAR | 0 | 蜂窝网络。 | +| BEARER_WIFI | 1 | Wi-Fi网络。 | +| BEARER_ETHERNET | 3 | 以太网网络。 | + +## ConnectionProperties + +网络连接信息。 + +| 变量 | 类型 | 说明 | +| ------------- | ---------------------------------- | ---------------- | +| interfaceName | string | 网卡名称。 | +| domains | string | 所属域,默认""。 | +| linkAddresses | Array<[LinkAddress](#linkaddress)> | 链路信息。 | +| routes | Array<[RouteInfo](#routeinfo)> | 路由信息。 | +| dnses | Array<[NetAddress](#netaddress)> | 网络地址,参考[NetAddress](#netaddress)。 | +| mtu | number | 最大传输单元。 | + +## LinkAddress + +网络链路信息。 + +| 变量 | 类型 | 说明 | +| ------------ | ------------------------- | -------------------- | +| address | [NetAddress](#netaddress) | 链路地址。 | +| prefixLength | number | 链路地址前缀的长度。 | + +## RouteInfo + +网络路由信息。 + +| 变量 | 类型 | 说明 | +| -------------- | --------------------------- | ---------------- | +| interface | string | 网卡名称。 | +| destination | [LinkAddress](#linkaddress) | 目的地址。 | +| gateway | [NetAddress](#netaddress) | 网关地址。 | +| hasGateway | boolean | 是否有网关。 | +| isDefaultRoute | boolean | 是否为默认路由。 | + +## NetAddress + +网络地址。 + +| 变量 | 类型 | 说明 | +| ------- | ------ | ------------------------------ | +| address | string | 地址。 | +| family | number | IPv4 = 1,IPv6 = 2,默认IPv4。 | +| port | number | 端口,取值范围\[0, 65535]。 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-notification.md b/zh-cn/application-dev/reference/apis/js-apis-notification.md index 101947cd5e3db9aa059ca2f6176fe024dbbeb14c..b5afd3db1313e7bec144dd1d74e110f9467fe8f0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-notification.md +++ b/zh-cn/application-dev/reference/apis/js-apis-notification.md @@ -2001,61 +2001,6 @@ Notification.isSupportTemplate(templateName).then((data) => { -## Notiifcation.isNotificationEnabledSelf - -isNotificationEnabledSelf(callback: AsyncCallback\): void - -查询应用通知是否使能。 - -- 参数 - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------------------------ | ---- | -------------------------- | -| callback | AsyncCallback\ | 是 | 查询模板是否存在的回调函数 | - -- 示例 - -```javascript -function isNotificationEnabledSelfCallback(err, enabled) { - console.info("isNotificationEnabledSelf"); - if (err.code) { - console.info("failed " + JSON.stringify(err)); - } else { - console.info("isNotificationEnabledSelf " + JSON.stringify(enabled)); - } -}; - -Notification.isNotificationEnabledSelf(isNotificationEnabledSelfCallback); -``` - - - -## Notiifcation.isNotificationEnabledSelf - -isNotificationEnabledSelf(): Promise\ - -查询应用通知是否使能。 - -- 返回值 - -| 类型 | 说明 | -| ------------------ | --------------- | -| Promise\ | Promise方式返回 | - -- 示例 - -```javascript -Notification.isNotificationEnabledSelf() - .then((enabled) => { - console.info("isNotificationEnabledSelf " + JSON.stringify(enabled)); - }) - .catch((err) => { - console.info("isNotificationEnabledSelf failed " + JSON.stringify(err)); - }); -``` - - - ## Notification.requestEnabledNotification requestEnabledNotification(callback: AsyncCallback\): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-observer.md b/zh-cn/application-dev/reference/apis/js-apis-observer.md index e020047aa5e967808761fede6d7c06e4e407b2d8..46cb6213e1cd3042210684b78f1f5c9d9d20ebee 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-observer.md +++ b/zh-cn/application-dev/reference/apis/js-apis-observer.md @@ -263,3 +263,279 @@ observer.on('callStateChange', callback); observer.off('callStateChange', callback); observer.off('callStateChange'); ``` + + +## observer.on('cellularDataConnectionStateChange')7+ + +on\(type: 'cellularDataConnectionStateChange', callback: Callback\<{ state: DataConnectState, network: RadioTechnology }\>\): void; + +订阅蜂窝数据链路连接状态,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 蜂窝数据链路连接状态事件 | +| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#DataConnectState), network: [RadioTechnology](js-apis-radio.md#RadioTechnology) }\> | 是 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#DataConnectState),radio的[RadioTechnology](js-apis-radio.md#RadioTechnology)。 | + +**示例:** + +``` +observer.on('cellularDataConnectionStateChange', value =>{ + console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); +}); +``` + + +## observer.on('cellularDataConnectionStateChange')7+ + +on\(type: 'cellularDataConnectionStateChange', options: { slotId: number }, callback: Callback\<{ state: DataConnectState, network: RadioTechnology }\>\): void; + +订阅指定卡槽位的蜂窝数据链路连接状态,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 蜂窝数据链路连接状态事件 | +| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | +| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#DataConnectState), network: [RadioTechnology](js-apis-radio.md#RadioTechnology) }\> | 是 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#DataConnectState),radio的[RadioTechnology](js-apis-radio.md#RadioTechnology)。 | + +**示例:** + +``` +observer.on('cellularDataConnectionStateChange', {slotId: 0}, value =>{ + console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); +}); +``` + + +## observer.off('cellularDataConnectionStateChange')7+ + +off\(type: 'cellularDataConnectionStateChange', callback?: Callback\<{ state: DataConnectState, network: RadioTechnology }\>\): void; + +移除订阅蜂窝数据链路连接状态,使用callback方式作为异步方法。 + +>**说明:** +> +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 蜂窝数据链路连接状态事件 | +| callback | Callback\<{ state: [DataConnectState](js-apis-telephony-data.md#DataConnectState), network: [RadioTechnology](js-apis-radio.md#RadioTechnology) }\> | 否 | 回调函数,参考data的[DataConnectState](js-apis-telephony-data.md#DataConnectState),radio的[RadioTechnology](js-apis-radio.md#RadioTechnology)。 | + +**示例:** + +``` +let callback = value => { + console.log("on cellularDataConnectionStateChange, state:" + value.state + ", network:" + value.network); +} +observer.on('cellularDataConnectionStateChange', callback); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +observer.off('cellularDataConnectionStateChange', callback); +observer.off('cellularDataConnectionStateChange'); +``` + + +## observer.on('cellularDataFlowChange')7+ + +on\(type: 'cellularDataFlowChange', callback: Callback\\): void; + +订阅蜂窝数据业务的上下行数据流状态,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 蜂窝数据业务的上下行数据流状态状态事件 | +| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#DataFlowType)\> | 是 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#DataFlowType)。 | + +**示例:** + +``` +observer.on('cellularDataFlowChange', data =>{ + console.log("on networkStateChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.on('cellularDataFlowChange')7+ + +on\(type: 'cellularDataFlowChange', options: { slotId: number }, callback: Callback\\): void; + +订阅指定卡槽位的蜂窝数据业务的上下行数据流状态,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 蜂窝数据业务的上下行数据流状态事件 | +| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | +| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#DataFlowType)\> | 是 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#DataFlowType)。 | + +**示例:** + +``` +observer.on('cellularDataFlowChange', {slotId: 0}, data =>{ + console.log("on cellularDataFlowChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.off('cellularDataFlowChange')7+ + +off\(type: 'cellularDataFlowChange', callback?: Callback\\): void; + +移除订阅蜂窝数据业务的上下行数据流状态,使用callback方式作为异步方法。 + +>**说明:** +> +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | 蜂窝数据业务的上下行数据流状态事件 | +| callback | Callback\<[DataFlowType](js-apis-telephony-data.md#DataFlowType)\> | 否 | 回调函数,参考data的[DataFlowType](js-apis-telephony-data.md#DataFlowType)。 | + +**示例:** + +``` +let callback = data => { + console.log("on cellularDataFlowChange, data:" + JSON.stringify(data)); +} +observer.on('cellularDataFlowChange', callback); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +observer.off('cellularDataFlowChange', callback); +observer.off('cellularDataFlowChange'); +``` + + +## observer.on('simStateChange')7+ + +on\(type: 'simStateChange', callback: Callback\\): void; + +订阅sim状态更改事件,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | sim状态更改事件 | +| callback | Callback\<[SimStateData](#simstatedata7)\> | 是 | 回调函数。 | + +**示例:** + +``` +observer.on('simStateChange', data =>{ + console.log("on simStateChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.on('simStateChange')7+ + +on\(type: 'simStateChange', options: { slotId: number }, callback: Callback\\): void; + +订阅指定卡槽位的sim状态更改事件,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | sim状态更改事件 | +| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | +| callback | Callback\<[SimStateData](#simstatedata7)\> | 是 | 回调函数。 | + +**示例:** + +``` +observer.on('simStateChange', {slotId: 0}, data =>{ + console.log("on simStateChange, data:" + JSON.stringify(data)); +}); +``` + + +## observer.off('simStateChange')7+ + +off\(type: 'simStateChange', callback?: Callback\\): void; + +移除订阅sim状态更改事件,使用callback方式作为异步方法。 + +>**说明:** +> +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**系统能力**:SystemCapability.Telephony.StateRegistry + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| type | string | 是 | sim状态更改事件 | +| callback | Callback\<[SimStateData](#simstatedata7)\> | 否 | 回调函数。 | + +**示例:** + +``` +let callback = data => { + console.log("on simStateChange, data:" + JSON.stringify(data)); +} +observer.on('simStateChange', callback); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +observer.off('simStateChange', callback); +observer.off('simStateChange'); +``` + + +## LockReason8+ + +SIM卡锁类型。 + +| 变量 | 值 | 说明 | +| ----------- | ---- | ------------------------------------------------------------ | +| SIM_NONE | 0 | 无锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_PIN | 1 | PIN锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_PUK | 2 | PUK锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_PN_PIN | 3 | 网络PIN锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_PN_PUK | 4 | 网络PUK锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_PU_PIN | 5 | 子网PIN锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_PU_PUK | 6 | 子网PUK锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_PP_PIN | 7 | 服务提供商PIN锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_PP_PUK | 8 | 服务提供商PUK锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_PC_PIN | 9 | 组织PIN锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_PC_PUK | 10 | 组织PUK锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_SIM_PIN | 11 | SIM PIN锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| SIM_SIM_PUK | 12 | SIM PUK锁。
**系统能力**:SystemCapability.Telephony.StateRegistry | + + +## SimStateData7+ + +SIM卡类型和状态。 + +| 变量 | 类型 | 说明 | +| ----------------- | --------------------- | ------------------------------------------------------------ | +| type | [CardType](js-apis-sim.md#cardtype) | SIM卡类型,参考sim的[CardType](js-apis-sim.md#cardtype)。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| state | [SimState](js-apis-sim.md#SimState) | SIM卡状态,参考sim的[SimState](js-apis-sim.md#SimState)。
**系统能力**:SystemCapability.Telephony.StateRegistry | +| reason8+ | [LockReason](#lockreason8) | SIM卡锁类型。
**系统能力**:SystemCapability.Telephony.StateRegistry | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md index e1379476c531c9183822403d040e53bcfea8aef6..9f12115ff008d02a4c3eff94dda598f127a822bb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md +++ b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md @@ -16,6 +16,10 @@ startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\: v 使用此方法启动指定的particleAbility(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** @@ -53,9 +57,17 @@ particleAbility.startAbility( ## particleAbility.startAbility +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + startAbility(parameter: StartAbilityParameter): Promise\ 使用此方法启动指定的particleAbility(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** @@ -99,6 +111,10 @@ terminateSelf(callback: AsyncCallback\): void 终止particleAbility(callback形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -124,6 +140,10 @@ terminateSelf(): Promise\ 终止particleAbility(Promise形式)。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **返回值:** | 类型 | 说明 | | -------------- | ------------------------- | @@ -146,6 +166,10 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper 获取dataAbilityHelper。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.FAModel + **参数:** | 名称 | 类型 | 必填 | 描述 | @@ -170,43 +194,43 @@ particleAbility.acquireDataAbilityHelper(uri) | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ------------------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | -| want | 只读 | [Want](#want) | 是 | 表示需要包含有关目标启动能力的信息。 | -| abilityStartSetting | 只读 | {[key: string]: any} | 否 | 表示能力的特殊属性,当开发者启动能力时,该属性可以作为调用中的输入参数传递。 | +| want | 只读 | [Want](#want) | 是 | 表示需要包含有关目标启动能力的信息。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | +| abilityStartSetting | 只读 | {[key: string]: any} | 否 | 表示能力的特殊属性,当开发者启动能力时,该属性可以作为调用中的输入参数传递。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | ## Want | 名称 | 读写属性 | 类型 | 必填 | 描述 | | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | -| deviceId | 只读 | string | 否 | 表示运行指定Ability的设备ID。 | -| bundleName | 只读 | string | 否 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | -| abilityName | 只读 | string | 否 | 表示待启动的Ability名称。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。 | -| uri | 只读 | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。 | -| type | 只读 | string | 否 | 表示MIME type类型描述,比如:"text/plain" 、 "image/*"等。 | -| flags | 只读 | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](#flags说明)。 | -| action | 只读 | string | 否 | 表示action选项描述。 | -| parameters | 只读 | {[key: string]: any} | 否 | 表示WantParams描述。 | -| entities | 只读 | Array\ | 否 | 表示entities相关描述。 | +| deviceId | 只读 | string | 否 | 表示运行指定Ability的设备ID。
系统能力:SystemCapability.Ability.AbilityBase | +| bundleName | 只读 | string | 否 | 表示包描述。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。
系统能力:SystemCapability.Ability.AbilityBase | +| abilityName | 只读 | string | 否 | 表示待启动的Ability名称。如果在Want中同时指定了BundleName和AbilityName,则Want可以直接匹配到指定的Ability。
系统能力:SystemCapability.Ability.AbilityBase | +| uri | 只读 | string | 否 | 表示Uri描述。如果在Want中指定了Uri,则Want将匹配指定的Uri信息,包括scheme, schemeSpecificPart, authority和path信息。
系统能力:SystemCapability.Ability.AbilityBase | +| type | 只读 | string | 否 | 表示MIME type类型描述,比如:"text/plain" 、 "image/*"等。
系统能力:SystemCapability.Ability.AbilityBase | +| flags | 只读 | number | 否 | 表示处理Want的方式。默认传数字,具体参考:[flags说明](#flags说明)。
系统能力:SystemCapability.Ability.AbilityBase | +| action | 只读 | string | 否 | 表示action选项描述。
系统能力:SystemCapability.Ability.AbilityBase | +| parameters | 只读 | {[key: string]: any} | 否 | 表示WantParams描述。
系统能力:SystemCapability.Ability.AbilityBase | +| entities | 只读 | Array\ | 否 | 表示entities相关描述。
系统能力:SystemCapability.Ability.AbilityBase | ## flags说明 | 名称 | 参数 | 描述 | | ------------------------------------ | ---------- | ------------------------------------------------------------ | -| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | 指示对URI执行读取操作的授权 | -| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | 指示对URI执行写入操作的授权 | -| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | 将结果返回给元能力 | -| FLAG_ABILITY_CONTINUATION | 0x00000008 | 确定是否可以将本地设备上的功能迁移到远程设备 | -| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | 指定组件是否属于OHOS | -| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | 指定是否启动某个能力 | -| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上可能持久化的授权 | -| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 按照前缀匹配的方式验证URI权限 | -| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支持分布式调度系统中的多设备启动 | -| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | 指示无论主机应用程序是否已启动,都将启动使用服务模板的功能 | -| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示迁移是可拉回的。 | -| FLAG_INSTALL_ON_DEMAND | 0x00000800 | 如果未安装指定的功能,请安装该功能 | -| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | 如果未安装,使用后台模式安装该功能。 | -| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | 指示清除其他任务的操作。可以为传递给{@link ohos.app.Context#startAbility}的{@code Want}设置此标志,并且必须与{@link flag_ABILITY_NEW_MISSION}一起使用 | -| FLAG_ABILITY_NEW_MISSION | 0x10000000 | 指示在历史任务堆栈上创建任务的操作。 | -| FLAG_ABILITY_MISSION_TOP | 0x20000000 | 指示如果启动能力的现有实例已位于任务堆栈的顶部,则将重用该实例。否则,将创建一个新的能力实例。 | +| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | 指示对URI执行读取操作的授权
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | 指示对URI执行写入操作的授权
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | 将结果返回给元能力
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION | 0x00000008 | 确定是否可以将本地设备上的功能迁移到远程设备
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | 指定组件是否属于OHOS
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | 指定是否启动某个能力
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上可能持久化的授权
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 按照前缀匹配的方式验证URI权限
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支持分布式调度系统中的多设备启动
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | 指示无论主机应用程序是否已启动,都将启动使用服务模板的功能
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示迁移是可拉回的。
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_ON_DEMAND | 0x00000800 | 如果未安装指定的功能,请安装该功能
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | 如果未安装,使用后台模式安装该功能。
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | 指示清除其他任务的操作。可以为传递给{@link ohos.app.Context#startAbility}的{@code Want}设置此标志,并且必须与{@link flag_ABILITY_NEW_MISSION}一起使用
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_NEW_MISSION | 0x10000000 | 指示在历史任务堆栈上创建任务的操作。
系统能力:SystemCapability.Ability.AbilityBase | +| FLAG_ABILITY_MISSION_TOP | 0x20000000 | 指示如果启动能力的现有实例已位于任务堆栈的顶部,则将重用该实例。否则,将创建一个新的能力实例。
系统能力:SystemCapability.Ability.AbilityBase | ## AbilityStartSetting @@ -216,9 +240,9 @@ abilityStartSetting属性是一个定义为[key: string]: any的对象,key对 | 名称 | 参数 | 描述 | | --------------- | --------------- | -------------------------- | -| BOUNDS_KEY | "abilityBounds" | 窗口显示大小属性的名称。 | -| WINDOW_MODE_KEY | "windowMode" | 窗口显示模式属性的名称。 | -| DISPLAY_ID_KEY | "displayId" | 窗口显示设备ID属性的名称。 | +| BOUNDS_KEY | "abilityBounds" | 窗口显示大小属性的名称。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | +| WINDOW_MODE_KEY | "windowMode" | 窗口显示模式属性的名称。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | +| DISPLAY_ID_KEY | "displayId" | 窗口显示设备ID属性的名称。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | ## AbilityWindowConfiguration @@ -226,11 +250,11 @@ abilityStartSetting属性是一个定义为[key: string]: any的对象,key对 | 名称 | 参数 | 描述 | | --------------------------- | ---- | ---------- | -| WINDOW_MODE_UNDEFINED | 0 | 未定义。 | -| WINDOW_MODE_FULLSCREEN | 1 | 全屏。 | -| WINDOW_MODE_SPLIT_PRIMARY | 100 | 分屏主屏。 | -| WINDOW_MODE_SPLIT_SECONDARY | 101 | 分屏次屏。 | -| WINDOW_MODE_FLOATING | 102 | 悬浮窗。 | +| WINDOW_MODE_UNDEFINED | 0 | 未定义。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | +| WINDOW_MODE_FULLSCREEN | 1 | 全屏。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | +| WINDOW_MODE_SPLIT_PRIMARY | 100 | 分屏主屏。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | +| WINDOW_MODE_SPLIT_SECONDARY | 101 | 分屏次屏。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | +| WINDOW_MODE_FLOATING | 102 | 悬浮窗。
系统能力:SystemCapability.Ability.AbilityRuntime.FAModel | ## particleAbility.startBackgroundRunning @@ -239,6 +263,10 @@ startBackgroundRunning(id: number, request: NotificationRequest, callback: Async 向系统申请长时任务,使用callback形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口) +**系统能力:** + +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -295,6 +323,10 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { startBackgroundRunning(id: number, request: NotificationRequest): Promise<void> +**系统能力:** + +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + 向系统申请长时任务,使用promise形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口) **参数**: @@ -355,6 +387,10 @@ cancelBackgroundRunning(callback: AsyncCallback<void>): void; 向系统申请取消长时任务,使用callback形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口) +**系统能力:** + +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + - **参数**: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -382,6 +418,10 @@ cancelBackgroundRunning(): Promise<void>; 向系统申请取消长时任务,使用promise形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口) +**系统能力:** + +SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask + **返回值** | 类型 | 说明 | | -------------- | ------------------------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md b/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md index 65317e07f3e3b68c887fec2687701407ddd19386..472bb7dbbc5112ee102fcb4489de68ff74d3c23e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md +++ b/zh-cn/application-dev/reference/apis/js-apis-permissionrequestresult.md @@ -1,10 +1,7 @@ # PermissionRequestResult -- [属性](#属性) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。 +> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 权限请求结果。 @@ -14,5 +11,5 @@ | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| permissions | Array<string> | 是 | 否 | 用户传入的权限。 | -| authResults | Array<number> | 是 | 否 | 相应请求权限的结果。0表示授权成功,-1表示失败。 | +| permissions | Array<string> | 是 | 否 | 用户传入的权限。
系统能力:SystemCapability.Ability.AbilityRuntime.Core| +| authResults | Array<number> | 是 | 否 | 相应请求权限的结果。0表示授权成功,-1表示失败。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | diff --git a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md index 65183ed8035905fc634ef4b309117f0ed7016ad9..44ce21f9db6b77f0fab9179db7c21be38a40e7da 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md +++ b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md @@ -53,7 +53,7 @@ isEmpty(): boolean ``` const plainArray = new PlainArray(); -plainArray.isEmpty(); +let result = plainArray.isEmpty(); ``` @@ -67,13 +67,13 @@ has(key: number): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | number | 是 | 查询的元素。 | +| key | number | 是 | 指定key。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| boolean | 包含指定元素返回true,否则返回false。 | +| boolean | 包含指定key返回true,否则返回false。 | **示例:** @@ -81,7 +81,7 @@ has(key: number): boolean let plainArray = new PlainArray(); plainArray.has(1); plainArray.add(1, "sddfhf"); -plainArray.has(1); +let result1 = plainArray.has(1); ``` @@ -109,7 +109,7 @@ get(key: number): T let plainArray = new PlainArray(); plainArray.add(1, "sddfhf"); plainArray.add(2, "sffdfhf"); -plainArray.get(1); +let result = plainArray.get(1); ``` @@ -117,19 +117,19 @@ plainArray.get(1); getIndexOfKey(key: number): number; -查找指定元素第一次出现的下标值,如果没有找到该元素返回-1。 +查找指定key第一次出现的下标值,如果没有找到该key返回-1。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | number | 是 | 被查找的元素。 | +| key | number | 是 | 指定key。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 | +| number | 返回指定key第一次出现时的下标值,查找失败返回-1。 | **示例:** @@ -137,7 +137,7 @@ getIndexOfKey(key: number): number; let plainArray = new PlainArray(); plainArray.add(1, "sddfhf"); plainArray.add(2, "sffdfhf"); -plainArray.getIndexOfKey("sdfs"); +let result = plainArray.getIndexOfKey("sdfs"); ``` @@ -145,19 +145,19 @@ plainArray.getIndexOfKey("sdfs"); getIndexOfValue(value: T): number; -查找指定元素第一次出现的下标值,如果没有找到该元素返回-1。 +查找指定value元素第一次出现的下标值,如果没有找到该value元素返回-1。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | T | 是 | 被查找的元素。 | +| value | T | 是 | 指定value元素。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 | +| number | 返回指定value元素第一次出现时的下标值,查找失败返回-1。 | **示例:** @@ -165,7 +165,7 @@ getIndexOfValue(value: T): number; let plainArray = new PlainArray(); plainArray.add(1, "sddfhf"); plainArray.add(2, "sffdfhf"); -plainArray.getIndexOfValue("sddfhf"); +let result = plainArray.getIndexOfValue("sddfhf"); ``` @@ -179,13 +179,13 @@ getKeyAt(index: number): number; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| index | number | 是 | 所查找的下标。 | +| index | number | 是 | 指定下标。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| number | 返回该下标对应的元素键值对中key值,失败返回undefined。 | +| number | 返回该下标对应的元素键值对中key值,失败返回-1。 | **示例:** @@ -193,17 +193,41 @@ getKeyAt(index: number): number; let plainArray = new PlainArray(); plainArray.add(1, "sddfhf"); plainArray.add(2, "sffdfhf"); -plainArray.getKeyAt(1); +let result = plainArray.getKeyAt(1); ``` +### getValueAt + +getValueAt(index: number): T + +查找指定下标元素键值对中Value值,否则返回undefined。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | index | number | 是 | 指定下标。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | T | 返回该下标对应的元素键值对中key值,失败返回undefined。 | + +**示例:** + + ``` + let plainArray = new PlainArray(); + plainArray.add(1, "sddfhf"); + plainArray.add(2, "sffdfhf"); + let result = plainArray.getKeyAt(1); + ``` ### clone clone(): PlainArray<T> -克隆一个实例,并返回克隆后的实例。 - -修改克隆后的实例并不会影响原实例。 +克隆一个实例,并返回克隆后的实例。修改克隆后的实例并不会影响原实例。 **返回值:** @@ -223,7 +247,7 @@ let newPlainArray = plainArray.clone(); ### add -add(key: number, value: T): boolean +add(key: number, value: T): void 向容器中添加一组数据。 @@ -234,12 +258,6 @@ add(key: number, value: T): boolean | key | number | 是 | 添加成员数据的键名。 | | value | T | 是 | 添加成员数据的值。 | -**返回值:** - -| 类型 | 说明 | -| -------- | -------- | -| boolean | 成功添加返回true,否则返回false。 | - **示例:** ``` @@ -252,13 +270,13 @@ plainArray.add(1, "sddfhf"); remove(key: number): T -删除指定的元素。 +删除指定key对应元素。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | number | 是 | 根据key删除的指定元素。 | +| key | number | 是 | 指定key。 | **返回值:** @@ -273,14 +291,15 @@ let plainArray = new PlainArray(); plainArray.add(1, "sddfhf"); plainArray.add(2, "sffdfhf"); plainArray.remove(2); +let result = plainArray.remove(2); ``` ### removeAt -removeAt(index: number): boolean; +removeAt(index: number): T -删除指定下标的元素。 +删除指定下标对应的元素。 **参数:** @@ -292,7 +311,7 @@ removeAt(index: number): boolean; | 类型 | 说明 | | -------- | -------- | -| boolean | 成功删除元素返回true,否则返回false。 | +| T | 返回删除的元素。 | **示例:** @@ -301,6 +320,7 @@ let plainArray = new PlainArray(); plainArray.add(1, "sddfhf"); plainArray.add(2, "sffdfhf"); plainArray.removeAt(1); +let result = plainArray.removeAt(1); ``` @@ -329,22 +349,22 @@ removeRangeFrom(index: number, size: number): number let plainArray = new PlainArray(); plainArray.add(1, "sddfhf"); plainArray.add(2, "sffdfhf"); -plainArray.removeAt(1, 3); +let result = plainArray.removeRangeFrom(1, 3); ``` ### setValueAt -setValueAt(index: number, newValue: T): void +setValueAt(index: number, value: T): void -向容器中具体位置替换键值对中的值。 +替换容器中指定下标对应键值对中的键值。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | index | number | 是 | 指定替换数据下标。 | -| newValue | T | 是 | 替换键值对中的值。 | +| value | T | 是 | 替换键值对中的值。 | **示例:** @@ -374,7 +394,7 @@ toString(): String let plainArray = new PlainArray(); plainArray.add(1, "sddfhf"); plainArray.add(2, "sffdfhf"); -plainArray.toString(); +let result = plainArray.toString(); ``` @@ -396,7 +416,7 @@ plainArray.clear(); ### forEach -forEach(callbackfn: (value: T, key?: number, plainArray?: PlainArray) => void, thisArg?: Object): void +forEach(callbackfn: (value: T, key?: number, PlainArray?: PlainArray) => void, thisArg?: Object): void 通过回调函数来遍历实例对象上的元素以及元素对应的下标。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-power.md b/zh-cn/application-dev/reference/apis/js-apis-power.md index f4e764d4cef37ad798181d37167f11e7a772f4da..3c223afea0f4c2f32ee59080d1c723ad84aadb68 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-power.md +++ b/zh-cn/application-dev/reference/apis/js-apis-power.md @@ -3,6 +3,8 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +该模块主要提供重启、关机、查询屏幕状态等接口。 + ## 导入模块 @@ -12,7 +14,7 @@ import power from '@ohos.power'; ## 系统能力 -SystemCapability.PowerManager.PowerManager +SystemCapability.PowerManager.PowerManager.Core ## power.shutdownDevice @@ -21,13 +23,15 @@ shutdownDevice(reason: string): void 系统关机。 -需要权限:ohos.permission.SHUTDOWN +**需要权限:**ohos.permission.SHUTDOWN + +**补充说明:**该接口为system api,仅供系统应用使用。 **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| reason | string | 是 | 关机原因。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ----- | +| reason | string | 是 | 关机原因。 | **示例:** @@ -43,13 +47,13 @@ rebootDevice(reason: string): void 重启设备。 -需要权限:ohos.permission.REBOOT(重启权限)、ohos.permission.REBOOT_RECOVERY(重启并进入recovery模式的权限) +**需要权限:**ohos.permission.REBOOT(重启权限)、ohos.permission.REBOOT_UPDATER(重启并进入updater模式的权限) **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| reason | string | 是 | 重启原因。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ----- | +| reason | string | 是 | 重启原因。 | **示例:** @@ -67,9 +71,9 @@ isScreenOn(callback: AsyncCallback<boolean>): void **参数:** -| 类型 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | 是 | 指定的callback回调方法,用于获取返回值。
callback返回值:亮屏返回true,灭屏返回false。 | +| 类型 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 指定的callback回调方法,用于获取返回值。
callback返回值:亮屏返回true,灭屏返回false。 | **示例:** @@ -91,8 +95,8 @@ isScreenOn(): Promise<boolean> 检测当前设备的亮灭屏状态。 **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------- | --------------------------------------- | | Promise<boolean> | Promise实例,用于异步获取返回值,亮屏返回true,灭屏返回false。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md b/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md index d22b2afe122785331b69c77ac474f52512dda061..cfedc01e68f6daea411b7345a5c5166d9f47154d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md +++ b/zh-cn/application-dev/reference/apis/js-apis-processrunninginfo.md @@ -1,11 +1,7 @@ # ProcessRunningInfo -- [使用说明](#使用说明) -- [属性](#属性) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 8开始支持。 +> 本模块首批接口从API 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 进程运行信息。 @@ -30,7 +26,7 @@ appManager.getProcessRunningInfos((error,data) => { | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| pid | number | 是 | 否 | 进程ID。 | -| uid | number | 是 | 否 | 用户ID。 | -| processName | string | 是 | 否 | 进程名称。 | -| bundleNames | Array<string> | 是 | 否 | 进程中所有运行的包名称。 | +| pid | number | 是 | 否 | 进程ID。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| uid | number | 是 | 否 | 用户ID。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| processName | string | 是 | 否 | 进程名称。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| bundleNames | Array<string> | 是 | 否 | 进程中所有运行的包名称。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | diff --git a/zh-cn/application-dev/reference/apis/js-apis-queue.md b/zh-cn/application-dev/reference/apis/js-apis-queue.md index 1ccf500073f7d97d964f7004f283f77840cd31c9..bfabc48531a3d8e81e1f1cf22eef4715150bd25d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-queue.md +++ b/zh-cn/application-dev/reference/apis/js-apis-queue.md @@ -60,12 +60,13 @@ add(element: T): boolean ``` let queue = new Queue(); -queue.add("a"); +let result = queue.add("a"); +let result1 = queue.add(1); queue.add(1); let b = [1, 2, 3]; queue.add(b); let c = {name : "lala", age : "13"}; -queue.add(false); +let result3 = queue.add(c); ``` ### pop @@ -89,7 +90,7 @@ queue.add(4); queue.add(5); queue.add(2); queue.add(4); -queue.pop(); +let result = queue.pop(); ``` ### getFirst @@ -112,11 +113,11 @@ queue.add(2); queue.add(4); queue.add(5); queue.add(2); -queue.getFirst(); +let result = queue.getFirst(); ``` ### forEach -forEach(callbackfn: (value: T, index?: number, queue?: Queue<T>) => void, +forEach(callbackfn: (value: T, index?: number, Queue?: Queue<T>) => void, thisArg?: Object): void 通过回调函数来遍历Queue实例对象上的元素以及元素对应的下标。 @@ -132,9 +133,9 @@ callbackfn的参数说明: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | T | 是 | 当前遍历到的元素 | -| index | number | 否 | 当前遍历到的下标值 | -| queue | Queue<T> | 否 | 当前调用forEach方法的实例对象 | +| value | T | 是 | 当前遍历到的元素。 | +| index | number | 否 | 当前遍历到的下标值。 | +| Queue | Queue<T> | 否 | 当前调用forEach方法的实例对象。 | **示例:** @@ -161,7 +162,7 @@ queue.forEach((value, index) => { | 类型 | 说明 | | -------- | -------- | -| IterableIterator<T> | 返回一个迭代器 | +| IterableIterator<T> | 返回一个迭代器。 | **示例:** ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-radio.md b/zh-cn/application-dev/reference/apis/js-apis-radio.md index 1d7b120625bd501e8f10cb603614947aefb800ae..e42486a49146657e9c306e38a96ce77c40fd76f4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-radio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-radio.md @@ -276,7 +276,56 @@ promise.then(data => { ``` -## radio.getSignalInformation +## radio.getPrimarySlotId7+ + +getPrimarySlotId\(callback: AsyncCallback\\): void + +获取主卡所在卡槽的索引号,使用callback方式作为异步方法。 + +**系统能力**:SystemCapability.Telephony.CoreService + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| callback | AsyncCallback\ | 是 | 回调函数 | + +**示例:** + +``` +radio.getPrimarySlotId((err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## radio.getPrimarySlotId7+ + +getPrimarySlotId\(\): Promise\ + +获取主卡所在卡槽的索引号,使用Promise方式作为异步方法。 + +**系统能力**:SystemCapability.Telephony.CoreService + +**返回值:** + +| 类型 | 说明 | +| ----------------------------------------------------------- | ------------------------------------------------------------ | +| Promise\ | 以Promise形式返回获取设备主卡所在卡槽的索引号的结果。 | + +**示例:** + +``` +let promise = radio.getPrimarySlotId(); +promise.then(data => { + console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.error(`getPrimarySlotId fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +## radio.getSignalInformation7+ getSignalInformation\(slotId: number, callback: AsyncCallback\>\): void @@ -301,7 +350,7 @@ radio.getSignalInformation(slotId, (err, data) => { ``` -## radio.getSignalInformation +## radio.getSignalInformation7+ getSignalInformation\(slotId: number\): Promise\> @@ -334,6 +383,35 @@ promise.then(data => { ``` +## radio.isNrSupported8+ + +isNrSupported\(slotId: number\): boolean + +判断当前设备是否支持5G\(NR\)。 + +**系统能力**:SystemCapability.Telephony.CoreService + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | + +**返回值:** + +| 类型 | 说明 | +| ------------------ | ------------------------------------------------------------ | +| boolean | - true:支持
- false:不支持 | + +**示例:** + +``` +let slotId = 0; +let result = radio.isNrSupported(slotId); +console.log(result); +``` + + ## radio.isRadioOn7+ isRadioOn\(callback: AsyncCallback\): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md index 400480d8d1e077b911b9206a53b9a5d625381182..58054eb9b5a6c5e24e9526ec2cf45d34a599f5d0 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-resource-manager.md @@ -10,18 +10,14 @@ import resourceManager from '@ohos.resourceManager'; ``` - -## 权限 - -无 - - ## resourceManager.getResourceManager getResourceManager(callback: AsyncCallback<ResourceManager>): void 获取当前应用的资源管理对象,使用callback形式返回ResourceManager对象。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -51,6 +47,8 @@ getResourceManager(bundleName: string, callback: AsyncCallback<ResourceManage 获取指定应用的资源管理对象,使用callback形式返回ResourceManager对象。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -70,6 +68,8 @@ getResourceManager(): Promise<ResourceManager> 获取当前应用的资源管理对象,使用Promise形式返回ResourceManager对象。 +**系统能力**:SystemCapability.Global.ResourceManager + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -97,6 +97,8 @@ getResourceManager(bundleName: string): Promise<ResourceManager> 获取指定应用的资源管理对象,使用Promise形式返回ResourceManager对象。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -123,8 +125,8 @@ getResourceManager(bundleName: string): Promise<ResourceManager> | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | -| DIRECTION_VERTICAL | 0 | 竖屏 | -| DIRECTION_HORIZONTAL | 1 | 横屏 | +| DIRECTION_VERTICAL | 0 | 竖屏
**系统能力**:SystemCapability.Global.ResourceManager | +| DIRECTION_HORIZONTAL | 1 | 横屏
**系统能力**:SystemCapability.Global.ResourceManager | ## DeviceType @@ -133,12 +135,12 @@ getResourceManager(bundleName: string): Promise<ResourceManager> | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | -| DEVICE_TYPE_PHONE | 0x00 | 手机 | -| DEVICE_TYPE_TABLET | 0x01 | 平板 | -| DEVICE_TYPE_CAR | 0x02 | 汽车 | -| DEVICE_TYPE_PC | 0x03 | 电脑 | -| DEVICE_TYPE_TV | 0x04 | 电视 | -| DEVICE_TYPE_WEARABLE | 0x06 | 穿戴 | +| DEVICE_TYPE_PHONE | 0x00 | 手机
**系统能力**:SystemCapability.Global.ResourceManager | +| DEVICE_TYPE_TABLET | 0x01 | 平板
**系统能力**:SystemCapability.Global.ResourceManager | +| DEVICE_TYPE_CAR | 0x02 | 汽车
**系统能力**:SystemCapability.Global.ResourceManager | +| DEVICE_TYPE_PC | 0x03 | 电脑
**系统能力**:SystemCapability.Global.ResourceManager | +| DEVICE_TYPE_TV | 0x04 | 电视
**系统能力**:SystemCapability.Global.ResourceManager | +| DEVICE_TYPE_WEARABLE | 0x06 | 穿戴
**系统能力**:SystemCapability.Global.ResourceManager | ## ScreenDensity @@ -147,12 +149,12 @@ getResourceManager(bundleName: string): Promise<ResourceManager> | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | -| SCREEN_SDPI | 120 | 小规模的屏幕密度 | -| SCREEN_MDPI | 160 | 中规模的屏幕密度 | -| SCREEN_LDPI | 240 | 大规模的屏幕密度 | -| SCREEN_XLDPI | 320 | 特大规模的屏幕密度 | -| SCREEN_XXLDPI | 480 | 超大规模的屏幕密度 | -| SCREEN_XXXLDPI | 640 | 超特大规模的屏幕密度 | +| SCREEN_SDPI | 120 | 小规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | +| SCREEN_MDPI | 160 | 中规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | +| SCREEN_LDPI | 240 | 大规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | +| SCREEN_XLDPI | 320 | 特大规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | +| SCREEN_XXLDPI | 480 | 超大规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | +| SCREEN_XXXLDPI | 640 | 超特大规模的屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | ## Configuration @@ -162,8 +164,8 @@ getResourceManager(bundleName: string): Promise<ResourceManager> | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| direction | [Direction](#direction) | 是 | 否 | 当前设备屏幕方向 | -| locale | string | 是 | 否 | 当前系统语言 | +| direction | [Direction](#direction) | 是 | 否 | 当前设备屏幕方向
**系统能力**:SystemCapability.Global.ResourceManager | +| locale | string | 是 | 否 | 当前系统语言
**系统能力**:SystemCapability.Global.ResourceManager | ## DeviceCapability @@ -173,8 +175,8 @@ getResourceManager(bundleName: string): Promise<ResourceManager> | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| screenDensity | [ScreenDensity](#screendensity) | 是 | 否 | 当前设备屏幕密度 | -| deviceType | [DeviceType](#devicetype) | 是 | 否 | 当前设备类型 | +| screenDensity | [ScreenDensity](#screendensity) | 是 | 否 | 当前设备屏幕密度
**系统能力**:SystemCapability.Global.ResourceManager | +| deviceType | [DeviceType](#devicetype) | 是 | 否 | 当前设备类型
**系统能力**:SystemCapability.Global.ResourceManager | ## ResourceManager @@ -193,6 +195,8 @@ getString(resId: number, callback: AsyncCallback<string>): void 用户获取指定资源ID对应的字符串,使用callback形式返回字符串。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -219,6 +223,8 @@ getString(resId: number): Promise<string> 用户获取指定资源ID对应的字符串,使用Promise形式返回字符串。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -247,6 +253,8 @@ getStringArray(resId: number, callback: AsyncCallback<Array<string>> 用户获取指定资源ID对应的字符串数组,使用callback形式返回字符串数组。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -273,6 +281,8 @@ getStringArray(resId: number): Promise<Array<string>> 用户获取指定资源ID对应的字符串数组,使用Promise形式返回字符串数组。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -301,6 +311,8 @@ getMedia(resId: number, callback: AsyncCallback<Uint8Array>): void 用户获取指定资源ID对应的媒体文件内容,使用callback形式返回字节数组。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -327,6 +339,8 @@ getMedia(resId: number): Promise<Uint8Array> 用户获取指定资源ID对应的媒体文件内容,使用Promise形式返回字节数组。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -355,6 +369,8 @@ getMediaBase64(resId: number, callback: AsyncCallback<string>): void 用户获取指定资源ID对应的图片资源Base64编码,使用callback形式返回字符串。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -381,6 +397,8 @@ getMediaBase64(resId: number): Promise<string> 用户获取指定资源ID对应的图片资源Base64编码,使用Promise形式返回字符串。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -409,6 +427,8 @@ getConfiguration(callback: AsyncCallback<Configuration>): void 用户获取设备的Configuration,使用callback形式返回Configuration对象。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -434,6 +454,8 @@ getConfiguration(): Promise<Configuration> 用户获取设备的Configuration,使用Promise形式返回Configuration对象。 +**系统能力**:SystemCapability.Global.ResourceManager + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -457,6 +479,8 @@ getDeviceCapability(callback: AsyncCallback<DeviceCapability>): void 用户获取设备的DeviceCapability,使用callback形式返回DeviceCapability对象。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -482,6 +506,8 @@ getDeviceCapability(): Promise<DeviceCapability> 用户获取设备的DeviceCapability,使用Promise形式返回DeviceCapability对象。 +**系统能力**:SystemCapability.Global.ResourceManager + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -505,6 +531,8 @@ getPluralString(resId: number, num: number, callback: AsyncCallback<string> 根据指定数量获取指定ID字符串表示的单复数字符串,使用callback形式返回字符串。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -532,6 +560,8 @@ getPluralString(resId: number, num: number): Promise<string> 根据指定数量获取对指定ID字符串表示的单复数字符串,使用Promise形式返回字符串。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -560,6 +590,8 @@ getRawFile(path: string, callback: AsyncCallback<Uint8Array>): void 用户获取指定路径对应的rawfile文件内容,使用callback形式返回字节数组。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -585,6 +617,8 @@ getRawFile(path: string): Promise<Uint8Array> 用户获取指定路径对应的rawfile文件内容,使用Promise形式返回字节数组。 +**系统能力**:SystemCapability.Global.ResourceManager + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-runninglock.md b/zh-cn/application-dev/reference/apis/js-apis-runninglock.md index 16c3f0e119ae70c14e7f9080bc9b051ce23805e8..df65e342c82b8c2d8a31229a7f92ce88134b207d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-runninglock.md +++ b/zh-cn/application-dev/reference/apis/js-apis-runninglock.md @@ -3,27 +3,26 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +该模块主要提供Runninglock锁相关操作的接口,包括创建、查询、持锁、释放锁等操作。 + ## 导入模块 ``` -import runninglock from '@ohos.runningLock'; +import runningLock from '@ohos.runningLock'; ``` -## 系统能力 - -SystemCapability.PowerManager.PowerManager - - ## RunningLockType RunningLock锁的类型。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| BACKGROUND | 1 | 阻止系统休眠的锁。 | -| PROXIMITY_SCREEN_CONTROL | 2 | 通过接近或者远离状态来控制亮灭屏的锁。 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.PowerManager.PowerManager.Core + +| 名称 | 默认值 | 描述 | +| ------------------------ | ---- | ------------------- | +| BACKGROUND | 1 | 阻止系统休眠的锁。 | +| PROXIMITY_SCREEN_CONTROL | 2 | 通过接近或者远离状态来控制亮灭屏的锁。 | ## isRunningLockTypeSupported @@ -32,12 +31,14 @@ isRunningLockTypeSupported(type: RunningLockType, callback: AsyncCallback<boo 查询系统是否支持该类型的锁。 +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| type | RunningLockType | 是 | 需要查询的锁的类型。 | -| callback | AsyncCallback<boolean> | 是 | 指定的callback回调方法,用于获取返回值。
callback返回值:支持返回true,不支持返回false。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ---------------------------------------- | +| type | RunningLockType | 是 | 需要查询的锁的类型。 | +| callback | AsyncCallback<boolean> | 是 | 指定的callback回调方法,用于获取返回值。
callback返回值:支持返回true,不支持返回false。 | **示例:** @@ -58,16 +59,18 @@ isRunningLockTypeSupported(type: RunningLockType): Promise<boolean> 查询系统是否支持该类型的锁。 +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| type | RunningLockType | 是 | 需要查询的锁的类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---- | --------------- | ---- | ---------- | +| type | RunningLockType | 是 | 需要查询的锁的类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------- | ---------------------------------------- | | Promise<boolean> | Promise实例,用于异步获取返回值,支持返回true,不支持返回false。 | **示例:** @@ -89,15 +92,17 @@ createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback&l 创建RunningLock锁。 -需要权限:ohos.permission.RUNNING_LOCK +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + +**需要权限:** ohos.permission.RUNNING_LOCK **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| name | string | 是 | 锁的名字。 | -| type | RunningLockType | 是 | 要创建的锁的类型。 | -| callback | AsyncCallback<[RunningLock](#runninglock)> | 是 | 指定的callback回调方法,用于获取返回的RunningLock锁对象。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | -------------------------------------- | +| name | string | 是 | 锁的名字。 | +| type | RunningLockType | 是 | 要创建的锁的类型。 | +| callback | AsyncCallback<[RunningLock](#runninglock)> | 是 | 指定的callback回调方法,用于获取返回的RunningLock锁对象。 | **示例:** @@ -122,19 +127,21 @@ createRunningLock(name: string, type: RunningLockType): Promise<RunningLock&g 创建Runninglock锁。 -需要权限:ohos.permission.RUNNING_LOCK +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + +**需要权限:** ohos.permission.RUNNING_LOCK **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| name | string | 是 | 锁的名字。 | -| type | RunningLockType | 是 | 要创建的锁的类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---- | --------------- | ---- | --------- | +| name | string | 是 | 锁的名字。 | +| type | RunningLockType | 是 | 要创建的锁的类型。 | **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ---------------------------------------- | ---------------------------------- | | Promise<[RunningLock](#runninglock)> | Promise实例,用于异步获取返回的RunningLock锁对象。 | **示例:** @@ -159,13 +166,15 @@ runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.B lock(timeout: number): void -锁定和持有RunningLock +锁定和持有RunningLock。 + +**系统能力:** SystemCapability.PowerManager.PowerManager.Core **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| timeout | number | 否 | 锁定和持有RunningLock的时长。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | -------------------- | +| timeout | number | 否 | 锁定和持有RunningLock的时长。 | **示例:** @@ -187,6 +196,8 @@ unlock(): void 释放Runninglock锁。 +**系统能力:** SystemCapability.PowerManager.PowerManager.Core + **示例:** ``` @@ -205,11 +216,13 @@ runningLock.createRunningLock("running_lock_test", runningLock.RunningLockType.B isUsed(): boolean -查询当前Runninglock是持有状态,还是释放状态。 +查询当前Runninglock是持有状态还是释放状态。 + +**系统能力:** SystemCapability.PowerManager.PowerManager.Core **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------- | ------------------------------------- | | boolean | 当前RunningLock是持有状态返回true,释放状态返回false。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-sensor.md b/zh-cn/application-dev/reference/apis/js-apis-sensor.md index 660c64edcd258e76548e2299655ad61f6f7ac9b5..315cf74f9f2439e245b012adfa5a588b834ad1a3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sensor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sensor.md @@ -1450,7 +1450,7 @@ getAngleModify(currentRotationMatrix: Array<number>, preRotationMatrix: Ar | 参数名 | 类型 | 必填 | 说明 | | --------------------- | ------------------- | ---- | ------------------ | | currentRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | - | preRotationMatrix | Array<number> | 是 | 表示当前旋转矩阵。 | + | preRotationMatrix | Array<number> | 是 | 表示旋转矩阵。 | - 返回值 diff --git a/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md b/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md index 9df9866c2cd51d00b76c2bd3b72809a483629bbb..1438b120f5806e34d2c72c9dda1b2de62930ddcc 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md +++ b/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md @@ -16,6 +16,10 @@ startAbility(want: Want, callback: AsyncCallback<void>): void; 启动Ability。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -40,6 +44,10 @@ startAbility(want: Want): Promise<void>; 启动Ability。通过Promise返回结果。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -70,6 +78,10 @@ terminateSelf(callback: AsyncCallback<void>): void; 停止Ability自身。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -89,6 +101,10 @@ terminateSelf(): Promise<void>; 停止自身。通过Promise返回结果。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 返回值: | 类型 | 说明 | | -------- | -------- | @@ -110,6 +126,10 @@ connectAbility(want: Want, options: ConnectOptions): number; 将一个Ability与服务类型的Ability绑定。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -142,6 +162,10 @@ disconnectAbility(connection: number, callback:AsyncCallback<void>): void; 将一个Ability与绑定的服务类型的Ability解绑。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -162,6 +186,10 @@ disconnectAbility(connection: number): Promise<void>; 将一个Ability与绑定的服务类型的Ability解绑。通过Promise返回结果。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -171,7 +199,7 @@ disconnectAbility(connection: number): Promise<void>; | 类型 | 说明 | | -------- | -------- | | Promise<void> | 返回一个Promise,包含接口的结果。 | - + - 示例: ``` this.context.disconnectAbility(connection).then((data) => { // connection为connectAbility中的返回值 @@ -188,6 +216,6 @@ ConnectOptions数据结构。 | 名称 | 说明 | | -------- | -------- | -| onConnect(elementName:ElementName, remote:IRemoteObject) | Ability成功连接一个服务类型Ability的回调接口。 | -| onDisconnect(elementName:ElementName) | 对端服务发生异常或者被杀死回调该接口。 | -| onFailed(code: number) | 连接失败时回调该接口。 | +| onConnect(elementName:ElementName, remote:IRemoteObject) | Ability成功连接一个服务类型Ability的回调接口。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| onDisconnect(elementName:ElementName) | 对端服务发生异常或者被杀死回调该接口。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | +| onFailed(code: number) | 连接失败时回调该接口。
系统能力:SystemCapability.Ability.AbilityRuntime.Core | diff --git a/zh-cn/application-dev/reference/apis/js-apis-service-extension.md b/zh-cn/application-dev/reference/apis/js-apis-service-extension.md index 4084b560e9ebed38d7be22ebf75285723e1a80da..52366fd4dcc40a35bbb4342fec2f781b12b802e7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-service-extension.md +++ b/zh-cn/application-dev/reference/apis/js-apis-service-extension.md @@ -32,6 +32,10 @@ onCreate(want: Want): void; Extension生命周期回调,在创建时回调,执行初始化业务逻辑操作。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -53,6 +57,10 @@ onDestroy(): void; Extension生命周期回调,在销毁时回调,执行资源清理等操作。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 示例: ``` class ServiceExt extends ServiceExtension { @@ -69,6 +77,10 @@ onRequest(want: Want, startId: number): void; Extension生命周期回调,如果是startAbility拉起的服务,会在onCreate之后回调。每次拉起服务都会回调,startId会递增。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -91,6 +103,10 @@ onConnect(want: Want): rpc.RemoteObject; Extension生命周期回调,如果是connectAbility拉起的服务,会在onCreate之后回调。返回一个RemoteObject对象,用于和客户端进行通信。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | @@ -126,6 +142,10 @@ onDisconnect(want: Want): void; Extension的生命周期,断开服务连接时回调。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-settings.md b/zh-cn/application-dev/reference/apis/js-apis-settings.md index 2f8fd145e1c173325f117cef24b61a2c923e4e65..39aaf3e3bec734b370f8768f9ec3783e7ab8b88a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-settings.md +++ b/zh-cn/application-dev/reference/apis/js-apis-settings.md @@ -19,9 +19,9 @@ import settings from '@ohos.settings'; 无 -## settings.getUri +## settings.getUriSync -getUri(name: string): string +getUriSync(name: string): string 获取数据项的URI。 @@ -38,13 +38,13 @@ getUri(name: string): string - 示例: ``` // 获取数据项的URI - let urivar = settings.getUri('settings.screen.brightness'); + let urivar = settings.getUriSync('settings.screen.brightness'); ``` -## settings.getValue +## settings.getValueSync -getValue(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string +getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string 获取数据项的值。 @@ -66,18 +66,18 @@ getValue(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): //获取数据项亮度的值(该数据项在数据库中已存在) let brightness = 'settings.screen.brightness'; - let uri = settings.getUri(brightness); + let uri = settings.getUriSync(brightness); let helper = featureAbility.acquireDataAbilityHelper(uri); - let value = settings.getValue(helper, brightness, '10'); + let value = settings.getValueSync(helper, brightness, '10'); ``` -## settings.setValue +## settings.setValueSync -setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean +setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean 设置数据项的值。 -如果数据库中已经存在该数据项,则setValue方法将更新该数据项的值;如果数据库中尚未存在该数据项,则setValue方法将向数据库中插入该数据项。 +如果数据库中已经存在该数据项,则setValueSync方法将更新该数据项的值;如果数据库中尚未存在该数据项,则setValueSync方法将向数据库中插入该数据项。 使用此方法需获取ohos.permission.WRITE_SYSTEM_SETTING权限。 @@ -97,9 +97,9 @@ setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boo ``` import featureAbility from '@ohos.featureAbility'; - //更新数据项亮度的值(该数据项在数据库中已存在,故setValue方法将更新该数据项的值) + //更新数据项亮度的值(该数据项在数据库中已存在,故setValueSync方法将更新该数据项的值) let brightness = 'settings.screen.brightness'; - let uri = settings.getUri(brightness); + let uri = settings.getUriSync(brightness); let helper = featureAbility.acquireDataAbilityHelper(uri); - let ret = settings.setValue(helper, brightness, '100'); + let ret = settings.setValueSync(helper, brightness, '100'); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-sim.md b/zh-cn/application-dev/reference/apis/js-apis-sim.md index abdaf41abbefd83eaaea3ba92f731e06a3ad6fc3..4adc8b442a2e875f3a093374012d704d30d43d6f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sim.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sim.md @@ -10,37 +10,37 @@ import sim from '@ohos.telephony.sim'; ``` -## sim.getSimIccId +## sim.isSimActive -getSimIccId\(slotId: number, callback: AsyncCallback\): void +isSimActive\(slotId: number, callback: AsyncCallback\): void -获取指定卡槽SIM卡的ICCID(Integrate Circuit Card Identity),使用callback方式作为异步方法。 +获取指定卡槽SIM卡是否激活,使用callback方式作为异步方法。 -需要ohos.permission.GET\_TELEPHONY\_STATE权限,该权限为系统权限。 +**需要权限**:ohos.permission.GET_TELEPHONY_STATE **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | --------------------------- | ---- | -------------------------------------- | | slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | -| callback | AsyncCallback<string> | 是 | 回调函数。 | +| callback | AsyncCallback<boolean> | 是 | 回调函数。 | **示例:** ``` -sim.getSimIccId(0, (err, data) => { +sim.isSimActive(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` -## sim.getSimIccId +## sim.isSimActive -getSimIccId\(slotId: number\): Promise +isSimActive\(slotId: number\): Promise -获取指定卡槽SIM卡的ICCID(Integrate Circuit Card Identity),使用Promise方式作为异步方法。 +获取指定卡槽SIM卡是否激活,使用Promise方式作为异步方法。 -需要ohos.permission.GET\_TELEPHONY\_STATE权限,该权限为系统权限。 +**需要权限**:ohos.permission.GET_TELEPHONY_STATE **参数:** @@ -52,19 +52,20 @@ getSimIccId\(slotId: number\): Promise | 类型 | 说明 | | --------------------- | ---------------------------------- | -| Promise<string> | 以Promise形式返回指定卡槽的ICCID。 | +| Promise<boolean> | 以Promise形式返回指定卡槽是否激活,如果激活返回true。 | **示例:** ``` -let promise = sim.getSimIccId(0); +let promise = sim.isSimActive(0); promise.then(data => { - console.log(`getSimIccId success, promise: data->${JSON.stringify(data)}`); + console.log(`isSimActive success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`getSimIccId fail, promise: err->${JSON.stringify(err)}`); + console.log(`isSimActive fail, promise: err->${JSON.stringify(err)}`); }); ``` + ## sim.getDefaultVoiceSlotId7+ getDefaultVoiceSlotId\(callback: AsyncCallback\): void @@ -109,6 +110,7 @@ promise.then(data => { }); ``` + ## sim.getISOCountryCodeForSim getISOCountryCodeForSim\(slotId: number, callback: AsyncCallback\): void @@ -316,37 +318,37 @@ promise.then(data => { }); ``` -## sim.getSimGid1 +## sim.getCardType -getSimGid1\(slotId: number, callback: AsyncCallback\): void +getCardType\(slotId: number, callback: AsyncCallback\): void -获取指定卡槽SIM卡的GID1\(Group Identifier Level 1\),使用callback方式作为异步方法。 +获取指定卡槽SIM卡的卡类型,使用callback方式作为异步方法。 -需要ohos.permission.GET\_TELEPHONY\_STATE权限,该权限为系统权限。 +**需要权限**:ohos.permission.GET_TELEPHONY_STATE **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | ----------------------- | ---- | -------------------------------------- | | slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | -| callback | AsyncCallback\ | 是 | 回调函数。 | +| callback | AsyncCallback\<[CardType](#cardtype)\> | 是 | 回调函数。 | **示例:** ``` -sim.getSimGid1(0, (err, data) => { +sim.getCardType(0, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` -## sim.getSimGid1 +## sim.getCardType -getSimGid1\(slotId: number\): Promise +getCardType\(slotId: number\): Promise -获取指定卡槽SIM卡的GID1\(Group Identifier Level 1\),使用Promise方式作为异步方法。 +获取指定卡槽SIM卡的卡类型,使用Promise方式作为异步方法。 -需要ohos.permission.GET\_TELEPHONY\_STATE权限,该权限为系统权限。 +**需要权限**:ohos.permission.GET_TELEPHONY_STATE **参数:** @@ -358,20 +360,97 @@ getSimGid1\(slotId: number\): Promise | 类型 | 说明 | | ----------------- | ------------------------------------------------------------ | -| Promise\ | 以Promise形式返回获取指定卡槽SIM卡的GID1(Group Identifier Level 1)。 | +| Promise\<[CardType](#cardtype)\> | 以Promise形式返回指定卡槽SIM卡的卡类型。 | + +**示例:** + +``` +let promise = sim.getCardType(0); +promise.then(data => { + console.log(`getCardType success, promise: data->${JSON.stringify(data)}`); +}).catch(err => { + console.log(`getCardType fail, promise: err->${JSON.stringify(err)}`); +}); +``` + + +## sim.hasSimCard + +hasSimCard\(slotId: number, callback: AsyncCallback\): void + +获取指定卡槽SIM卡是否插卡,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.GET_TELEPHONY_STATE + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------------------------------- | +| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | +| callback | AsyncCallback<boolean> | 是 | 回调函数。 | + +**示例:** + +``` +sim.hasSimCard(0, (err, data) => { + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); +}); +``` + + +## sim.hasSimCard + +hasSimCard\(slotId: number\): Promise + +获取指定卡槽SIM卡是否插卡,使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.GET_TELEPHONY_STATE + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------------------------------- | +| slotId | number | 是 | 卡槽ID。
- 0:卡槽1
- 1:卡槽2 | + +**返回值:** + +| 类型 | 说明 | +| --------------------- | ---------------------------------- | +| Promise<boolean> | 以Promise形式返回指定卡槽是否插卡,如果插卡返回true。 | **示例:** ``` -let promise = sim.getSimGid1(0); +let promise = sim.hasSimCard(0); promise.then(data => { - console.log(`getSimGid1 success, promise: data->${JSON.stringify(data)}`); + console.log(`hasSimCard success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`getSimGid1 fail, promise: err->${JSON.stringify(err)}`); + console.log(`hasSimCard fail, promise: err->${JSON.stringify(err)}`); }); ``` +## sim.getMaxSimCount + +getMaxSimCount\(\): number + +获取卡槽数量。 + +**需要权限**:ohos.permission.GET_TELEPHONY_STATE + +**返回值:** + +| 类型 | 说明 | +| ----------------- | ------------------------------------------------------------ | +| number | 卡槽数量。 | + +**示例:** + +``` +console.log(sim.getMaxSimCount()) +``` + + ## SimState SIM卡状态。 @@ -383,4 +462,21 @@ SIM卡状态。 | SIM_STATE_LOCKED | 表示SIM卡处于locked状态,即SIM卡被PIN、PUK或网络锁锁定。 | | SIM_STATE_NOT_READY | 表示SIM卡处于not ready状态,即SIM卡在位但无法正常工作。 | | SIM_STATE_READY | 表示SIM卡处于ready状态,即SIM卡在位且工作正常。 | -| SIM_STATE_LOADED | 表示SIM卡处于loaded状态,即SIM卡在位且所有卡文件加载完毕。 | \ No newline at end of file +| SIM_STATE_LOADED | 表示SIM卡处于loaded状态,即SIM卡在位且所有卡文件加载完毕。 | + +## CardType + +卡类型。 + +| 变量 | 值 | 说明 | +| ----- | ----- | ----- | +UNKNOWN_CARD | -1 | 未知类型 | +SINGLE_MODE_SIM_CARD | 10 | 单SIM卡 | +SINGLE_MODE_USIM_CARD | 20 | 单USIM卡 | +SINGLE_MODE_RUIM_CARD | 30 | 单RUIM卡 | +DUAL_MODE_CG_CARD | 40 | 双卡模式C+G | +CT_NATIONAL_ROAMING_CARD | 41 | 中国电信内部漫游卡 | +CU_DUAL_MODE_CARD | 42 | 中国联通双模卡 | +DUAL_MODE_TELECOM_LTE_CARD | 43 | 双模式电信LTE卡 | +DUAL_MODE_UG_CARD | 50 | 双模式UG卡 | +SINGLE_MODE_ISIM_CARD | 60 | 单一ISIM卡类型 | \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-sms.md b/zh-cn/application-dev/reference/apis/js-apis-sms.md index bad012c67faa9b803406a051265d0311d253cdac..8b50b835799a6dc826077e398a219cba4a512749 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sms.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sms.md @@ -148,7 +148,7 @@ getDefaultSmsSlotId\(\): Promise **示例:** ``` -let promise = call.getDefaultSmsSlotId(); +let promise = sms.getDefaultSmsSlotId(); promise.then(data => { console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -233,6 +233,8 @@ getSmscAddr\(slotId: number, callback: AsyncCallback\): void **系统能力**:SystemCapability.Telephony.SmsMms +**补充说明**:该接口为systemapi,仅供系统应用使用 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -260,6 +262,8 @@ getSmscAddr\(slotId: number\): Promise **系统能力**:SystemCapability.Telephony.SmsMms +**补充说明**:该接口为systemapi,仅供系统应用使用 + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -284,6 +288,24 @@ promise.then(data => { }); ``` +## sms.hasSmsCapability7+ + +hasSmsCapability(): boolean + +检查当前设备是否具备短信发送和接收能力,该方法是同步方法。 + +**系统能力**:SystemCapability.Telephony.SmsMms + +**返回值:** + +| 类型 | 说明 | +| ------- | ------------------------------------------------------------ | +| boolean | - true:设备具备短信发送和接收能力
- false:设备不具备短信发送和接收能力 | + +``` +let result = sms.hasSmsCapability(); +console.log(`hasSmsCapability: ${JSON.stringify(result)}`); +``` ## ShortMessage @@ -293,10 +315,7 @@ promise.then(data => { | 变量 | 类型 | 说明 | | ------------------------ | --------------------------------------- | ------------------------------------------------------------ | -| emailAddress | string | 电子邮件地址。 | -| emailMessageBody | string | 电子邮件正文。 | | hasReplyPath | boolean | 收到的短信是否包含“TP-Reply-Path”,默认为false。
“TP-Reply-Path”:移动电话根据发送SMS消息的短消息中心进行回复。 | -| isEmailMessage | boolean | 收到的短信是否为电子邮件。 | | isReplaceMessage | boolean | 收到的短信是否为“替换短信”,默认为false。
“替换短信”有关详细信息,参见 “3GPP TS 23.040 9.2.3.9”。 | | isSmsStatusReportMessage | boolean | 当前消息是否为“短信状态报告”,默认为false。
“短信状态报告”是一种特定格式的短信,被用来从Service Center到Mobile Station传送状态报告。 | | messageClass | [ShortMessageClass](#ShortMessageClass) | 短信类型。 | @@ -305,7 +324,6 @@ promise.then(data => { | scAddress | string | 短消息服务中心(SMSC)地址。 | | scTimestamp | number | SMSC时间戳。 | | status | number | SMS-STATUS-REPORT消息中的短信状态指示短信服务中心(SMSC)发送的短信状态。 | -| userRawData | Array<number> | 除数据头外的用户数据。 | | visibleMessageBody | string | 短信正文。 | | visibleRawAddress | string | 发送者地址。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-socket.md b/zh-cn/application-dev/reference/apis/js-apis-socket.md new file mode 100644 index 0000000000000000000000000000000000000000..701c53fd9c4e9d38a35e2166543605d7812b5f36 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-socket.md @@ -0,0 +1,1364 @@ +# Socket连接 + +>![](public_sys-resources/icon-note.gif) **说明:** +> +>本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +>本模块所有接口需要设备具有系统能力:SystemCapability.Communication.NetStack + +## 导入模块 + +``` +import socket from '@ohos.net.socket'; +``` + +## 权限列表 + +ohos.permission.INTERNET + +## socket.constructUDPSocketInstance + +constructUDPSocketInstance\(\): UDPSocket + +创建一个UDPSocket对象。 + +**返回值:** + +| 类型 | 说明 | +| :--------------------------------- | :---------------------- | +| [UDPSocket](#udpsocket) | 返回一个UDPSocket对象。 | + + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +``` + + +## UDPSocket + +UDPSocket连接。在调用UDPSocket的方法前,需要先通过[socket.constructUDPSocketInstance](#socketconstructudpsocketinstance)创建UDPSocket对象。 + +### bind + +bind\(address: NetAddress, callback: AsyncCallback\): void + +绑定IP地址和端口,端口可以指定或由系统随机分配。使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------- | ---- | ------------------------------------------------------ | +| address | [NetAddress](#netaddress) | 是 | 目标地址信息,参考[NetAddress](#netaddress)。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); +}) +``` + + +### bind + +bind\(address: NetAddress\): Promise + +绑定IP地址和端口,端口可以指定或由系统随机分配。使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------- | ---- | ------------------------------------------------------ | +| address | [NetAddress](#netaddress) | 是 | 目标地址信息,参考[NetAddress](#netaddress)。 | + + +**返回值:** + +| 类型 | 说明 | +| :-------------- | :----------------------------------------- | +| Promise\ | 以Promise形式异步返回UDPSocket绑定的结果。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +let promise = udp.bind({address: '192.168.xx.xxx', port: 8080, family: 1}); +promise .then(() => { + console.log('bind success'); +}).catch(err => { + console.log('bind fail'); +}); +``` + + +### send + +send\(options: UDPSendOptions, callback: AsyncCallback\): void + +通过UDPSocket连接发送数据。使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [UDPSendOptions](#udpsendoptions) | 是 | UDPSocket发送参数,参考[UDPSendOptions](#udpsendoptions)。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +udp.send({ + data:'Hello, server!', + address: { + address:'192.168.xx.xxx', + port:xxxx, + family:1 + } +}, err=> { + if (err) { + console.log('send fail'); + return; + } + console.log('send success'); +}) +``` + + +### send + +send\(options: UDPSendOptions\): Promise + +通过UDPSocket连接发送数据。使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [UDPSendOptions](#udpsendoptions) | 是 | UDPSocket发送参数,参考[UDPSendOptions](#udpsendoptions)。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------- | :--------------------------------------------- | +| Promise\ | 以Promise形式返回UDPSocket连接发送数据的结果。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +let promise = udp.send({ + data:'Hello, server!', + address: { + address:'192.168.xx.xxx', + port:xxxx, + family:1 + } +}); +promise.then(() => { + console.log('send success'); +}).catch(err => { + console.log('send fail'); +}); +``` + + +### close + +close\(callback: AsyncCallback\): void + +关闭UDPSocket连接。使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ---------- | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +udp.close(err => { + if (err) { + console.log('close fail'); + return; + } + console.log('close success'); +}) +``` + + +### close + +close\(\): Promise + +关闭UDPSocket连接。使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**返回值:** + +| 类型 | 说明 | +| :-------------- | :----------------------------------------- | +| Promise\ | 以Promise形式返回关闭UDPSocket连接的结果。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +let promise = udp.close(); +promise.then(() => { + console.log('close success'); +}).catch(err => { + console.log('close fail'); +}); +``` + + +### getState + +getState\(callback: AsyncCallback\): void + +获取UDPSocket状态。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[bind](#bind)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------ | ---- | ---------- | +| callback | AsyncCallback<[SocketStateBase](#socketstatebase)> | 是 | 回调函数。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); + udp.getState((err, data) => { + if (err) { + console.log('getState fail'); + return; + } + console.log('getState success:' + JSON.stringify(data)); + }) +}) +``` + + +### getState + +getState\(\): Promise + +获取UDPSocket状态。使用Promise方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[bind](#bind)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**返回值:** + +| 类型 | 说明 | +| :----------------------------------------------- | :----------------------------------------- | +| Promise<[SocketStateBase](#socketstatebase)> | 以Promise形式返回获取UDPSocket状态的结果。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +udp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); + let promise = udp.getState({}); + promise.then(data => { + console.log('getState success:' + JSON.stringify(data)); + }).catch(err => { + console.log('getState fail'); + }); +}) +``` + + +### setExtraOptions + +setExtraOptions\(options: UDPExtraOptions, callback: AsyncCallback\): void + +设置UDPSocket连接的其他属性。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[bind](#bind)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [UDPExtraOptions](#udpextraoptions) | 是 | UDPSocket连接的其他属性,参考[UDPExtraOptions](#udpextraoptions)。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}, err=> { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); + udp.setExtraOptions({ + receiveBufferSize:1000, + sendBufferSize:1000, + reuseAddress:false, + socketTimeout:6000, + broadcast:true + }, err=> { + if (err) { + console.log('setExtraOptions fail'); + return; + } + console.log('setExtraOptions success'); + }) +}) +``` + + +### setExtraOptions + +setExtraOptions\(options: UDPExtraOptions\): Promise + +设置UDPSocket连接的其他属性。使用Promise方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[bind](#bind)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [UDPExtraOptions](#udpextraoptions) | 是 | UDPSocket连接的其他属性,参考[UDPExtraOptions](#udpextraoptions)。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------- | :--------------------------------------------------- | +| Promise\ | 以Promise形式返回设置UDPSocket连接的其他属性的结果。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +let promise = udp.bind({address:'192.168.xx.xxx', port:xxxx, family:1}); +promise.then(() => { + console.log('bind success'); + let promise1 = udp.setExtraOptions({ + receiveBufferSize:1000, + sendBufferSize:1000, + reuseAddress:false, + socketTimeout:6000, + broadcast:true + }); + promise1.then(() => { + console.log('setExtraOptions success'); + }).catch(err => { + console.log('setExtraOptions fail'); + }); +}).catch(err => { + console.log('bind fail'); +}); +``` + + +### on\('message'\) + +on\(type: 'message', callback: Callback<\{message: ArrayBuffer, remoteInfo: SocketRemoteInfo\}\>\): void + +订阅UDPSocket连接的接收消息事件。使用callback方式作为异步方法。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | +| type | string | 是 | 订阅的事件类型。'message':接收消息事件。 | +| callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}> | 是 | 回调函数。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +udp.on('message', value => { + console.log("on message, message:" + value.message) + ", remoteInfo:" + value.remoteInfo); +}); +``` + + +### off\('message'\) + +off\(type: 'message', callback?: Callback<\{message: ArrayBuffer, remoteInfo: SocketRemoteInfo\}\>\): void + +取消订阅UDPSocket连接的接收消息事件。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | +| type | string | 是 | 订阅的事件类型。'message':接收消息事件。 | +| callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}> | 否 | 回调函数。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +let callback = value =>{ + console.log("on message, message:" + value.message) + ", remoteInfo:" + value.remoteInfo); +} +udp.on('message', callback); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +udp.off('message', callback); +udp.off('message'); +``` + + +### on\('listening' | 'close'\) + +on\(type: 'listening' | 'close', callback: Callback\): void + +订阅UDPSocket连接的数据包消息事件或关闭事件。使用callback方式作为异步方法。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 订阅的事件类型。
- 'listening':数据包消息事件。
- 'close':关闭事件。 | +| callback | Callback\ | 是 | 回调函数。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +udp.on('listening', () => { + console.log("on listening success")); +}); +udp.on('close', () => { + console.log("on close success" ); +}); +``` + + +### off\('listening' | 'close'\) + +off\(type: 'listening' | 'close', callback?: Callback\): void + +取消订阅UDPSocket连接的数据包消息事件或关闭事件。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 订阅事件类型。
- 'listening':数据包消息事件。
- 'close':关闭事件。 | +| callback | Callback\ | 否 | 回调函数。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance(); +let callback1 = () =>{ + console.log("on listening, success"); +} +udp.on('listening', callback1); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +udp.off('listening', callback1); +udp.off('listening'); +let callback2 = () =>{ + console.log("on close, success"); +} +udp.on('close', callback2); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +udp.off('close', callback2); +udp.off('close'); +``` + + +### on\('error'\) + +on\(type: 'error', callback: ErrorCallback\): void + +订阅UDPSocket连接的error事件。使用callback方式作为异步方法。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------- | ---- | ------------------------------------ | +| type | string | 是 | 订阅的事件类型。'error':error事件。 | +| callback | ErrorCallback | 是 | 回调函数。 | + + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance() +udp.on('error', err => { + console.log("on error, err:" + JSON.stringify(err)) +}); +``` + + +### off\('error'\) + +off\(type: 'error', callback?: ErrorCallback\): void + +取消订阅UDPSocket连接的error事件。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------- | ---- | ------------------------------------ | +| type | string | 是 | 订阅的事件类型。'error':error事件。 | +| callback | ErrorCallback | 否 | 回调函数。 | + +**示例:** + +``` +let udp = socket.constructUDPSocketInstance() +let callback = err =>{ + console.log("on error, err:" + JSON.stringify(err)); +} +udp.on('error', callback); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +udp.off('error', callback); +udp.off('error'); +``` + + +## NetAddress + +目标地址信息。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| address | string | 是 | 本地绑定的ip地址。 | +| port | number | 否 | 端口号 ,范围0~65535。如果不指定系统随机分配端口。 | +| family | number | 否 | 网络协议类型,可选类型:
- 1:IPv4
- 2:IPv6
默认为1。 | + +## UDPSendOptions + +UDPSocket发送参数。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------- | ---- | -------------- | +| data | string | 是 | 发送的数据。 | +| address | [NetAddress](#netaddress) | 是 | 目标地址信息。 | + +## UDPExtraOptions + +UDPSocket连接的其他属性。 + +| 参数名 | 类型 | 必填 | 说明 | +| ----------------- | ------- | ---- | -------------------------------- | +| broadcast | boolean | 否 | 是否可以发送广播。默认为false。 | +| receiveBufferSize | number | 否 | 接收缓冲区大小(单位:Byte)。 | +| sendBufferSize | number | 否 | 发送缓冲区大小(单位:Byte)。 | +| reuseAddress | boolean | 否 | 是否重用地址。默认为false。 | +| socketTimeout | number | 否 | 套接字超时时间,单位毫秒(ms)。 | + +## SocketStateBase + +Socket的状态信息。 + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------- | ---- | ---------- | +| isBound | boolean | 是 | 是否绑定。 | +| isClose | boolean | 是 | 是否关闭。 | +| isConnected | boolean | 是 | 是否连接。 | + +## SocketRemoteInfo + +Socket的连接信息。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------------------------------------------------ | +| address | string | 是 | 本地绑定的ip地址。 | +| family | string | 是 | 网络协议类型,可选类型:
- IPv4
- IPv6
默认为IPv4。 | +| port | number | 是 | 端口号,范围0~65535。 | +| size | number | 是 | 服务器响应信息的字节长度。 | + +## socket.constructTCPSocketInstance + +constructTCPSocketInstance\(\): TCPSocket + +创建一个TCPSocket对象。 + +**返回值:** + + | 类型 | 说明 | + | :--------------------------------- | :---------------------- | + | [TCPSocket](#tcpsocket) | 返回一个TCPSocket对象。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +``` + + +## TCPSocket + +TCPSocket连接。在调用TCPSocket的方法前,需要先通过[socket.constructTCPSocketInstance](#socketconstructtcpsocketinstance)创建TCPSocket对象。 + +### bind + +bind\(address: NetAddress, callback: AsyncCallback\): void + +绑定IP地址和端口,端口可以指定或由系统随机分配。使用callback方法作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------- | ---- | ------------------------------------------------------ | +| address | [NetAddress](#netaddress) | 是 | 目标地址信息,参考[NetAddress](#netaddress)。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}, err => { + if (err) { + console.log('bind fail'); + return; + } + console.log('bind success'); +}) +``` + + +### bind + +bind\(address NetAddress\): Promise + +绑定IP地址和端口,端口可以指定或由系统随机分配。使用Promise方法作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------- | ---- | ------------------------------------------------------ | +| address | [NetAddress](#netaddress) | 是 | 目标地址信息,参考[NetAddress](#netaddress)。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------- | :------------------------------------------------------- | +| Promise\ | 以Promise形式返回TCPSocket绑定本机的IP地址和端口的结果。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let promise = tcp.bind({address: '192.168.xx.xxx', port: xxxx, family: 1}); +promise.then(() => { + console.log('bind success'); +}).catch(err => { + console.log('bind fail'); +}); +``` + + +### connect + +connect\(options: TCPConnectOptions, callback: AsyncCallback\): void + +连接到指定的IP地址和端口。使用callback方法作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPConnectOptions](#tcpconnectoptions) | 是 | TCPSocket连接的参数,参考[TCPConnectOptions](#tcpconnectoptions)。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}, err => { + if (err) { + console.log('connect fail'); + return; + } + console.log('connect success'); +}) +``` + + +### connect + +connect\(options: TCPConnectOptions\): Promise + +连接到指定的IP地址和端口。使用promise方法作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPConnectOptions](#tcpconnectoptions) | 是 | TCPSocket连接的参数,参考[TCPConnectOptions](#tcpconnectoptions)。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------- | :--------------------------------------------------------- | +| Promise\ | 以Promise形式返回TCPSocket连接到指定的IP地址和端口的结果。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); +promise.then(() => { + console.log('connect success') +}).catch(err => { + console.log('connect fail'); +}); +``` + + +### send + +send\(options: TCPSendOptions, callback: AsyncCallback\): void + +通过TCPSocket连接发送数据。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[connect](#connect)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPSendOptions](#tcpsendoptions) | 是 | TCPSocket发送请求的参数,参考[TCPSendOptions](#tcpsendoptions)。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); +promise.then(() => { + console.log('connect success'); + tcp.send({ + data:'Hello, server!' + },err => { + if (err) { + console.log('send fail'); + return; + } + console.log('send success'); + }) +}).catch(err => { + console.log('connect fail'); +}); +``` + + +### send + +send\(options: TCPSendOptions\): Promise + +通过TCPSocket连接发送数据。使用Promise方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[connect](#connect)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPSendOptions](#tcpsendoptions) | 是 | TCPSocket发送请求的参数,参考[TCPSendOptions](#tcpsendoptions)。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------- | :------------------------------------------------- | +| Promise\ | 以Promise形式返回通过TCPSocket连接发送数据的结果。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); +promise1.then(() => { + console.log('connect success'); + let promise2 = tcp.send({ + data:'Hello, server!' + }); + promise2.then(() => { + console.log('send success'); + }).catch(err => { + console.log('send fail'); + }); +}).catch(err => { + console.log('connect fail'); +}); +``` + + +### close + +close\(callback: AsyncCallback\): void + +关闭TCPSocket连接。使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------- | ---- | ---------- | +| callback | AsyncCallback\ | 是 | 回调函数。 | + + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +tcp.close(err => { + if (err) { + console.log('close fail'); + return; + } + console.log('close success'); +}) +``` + + +### close + +close\(\): Promise + +关闭TCPSocket连接。使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**返回值:** + +| 类型 | 说明 | +| :-------------- | :----------------------------------------- | +| Promise\ | 以Promise形式返回关闭TCPSocket连接的结果。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let promise = tcp.close(); +promise.then(() => { + console.log('close success'); +}).catch(err => { + console.log('close fail'); +}); +``` + + +### getRemoteAddress + +getRemoteAddress\(callback: AsyncCallback\): void + +获取对端Socket地址。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[connect](#connect)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------- | ---- | ---------- | +| callback | AsyncCallback<[NetAddress](#netaddress)> | 是 | 回调函数。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); +promise.then(() => { + console.log('connect success'); + tcp.getRemoteAddress((err, data) => { + if (err) { + console.log('getRemoteAddressfail'); + return; + } + console.log('getRemoteAddresssuccess:' + JSON.stringify(data)); + }) +}).catch(err => { + console.log('connect fail'); +}); +``` + + +### getRemoteAddress + +getRemoteAddress\(\): Promise + +获取对端Socket地址。使用Promise方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[connect](#connect)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**返回值:** + +| 类型 | 说明 | +| :------------------------------------------ | :------------------------------------------ | +| Promise<[NetAddress](#netaddress)> | 以Promise形式返回获取对端socket地址的结果。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let promise1 = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); +promise1.then(() => { + console.log('connect success'); + let promise2 = tcp.getRemoteAddress(); + promise2.then(() => { + console.log('getRemoteAddress success:' + JSON.stringify(data)); + }).catch(err => { + console.log('getRemoteAddressfail'); + }); +}).catch(err => { + console.log('connect fail'); +}); +``` + + +### getState + +getState\(callback: AsyncCallback\): void + +获取TCPSocket状态。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[bind](#bind)或[connect](#connect)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------ | ---- | ---------- | +| callback | AsyncCallback<[SocketStateBase](#socketstatebase)> | 是 | 回调函数。 | + + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); +promise.then(() => { + console.log('connect success'); + tcp.getState((err, data) => { + if (err) { + console.log('getState fail'); + return; + } + console.log('getState success:' + JSON.stringify(data)); + }); +}).catch(err => { + console.log('connect fail'); +}); +``` + + +### getState + +getState\(\): Promise + +获取TCPSocket状态。使用Promise方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[bind](#bind)或[connect](#connect)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**返回值:** + +| 类型 | 说明 | +| :----------------------------------------------- | :----------------------------------------- | +| Promise<[SocketStateBase](#socketstatebase)> | 以Promise形式返回获取TCPSocket状态的结果。 | + + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); +promise.then(() => { + console.log('connect success'); + let promise1 = tcp.getState(); + promise1.then(() => { + console.log('getState success:' + JSON.stringify(data)); + }).catch(err => { + console.log('getState fail'); + }); +}).catch(err => { + console.log('connect fail'); +}); +``` + + +### setExtraOptions + +setExtraOptions\(options: TCPExtraOptions, callback: AsyncCallback\): void + +设置TCPSocket连接的其他属性。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[bind](#bind)或[connect](#connect)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPExtraOptions](#tcpextraoptions) | 是 | TCPSocket连接的其他属性,参考[TCPExtraOptions](#tcpextraoptions)。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); +promise.then(() => { + console.log('connect success'); + tcp.setExtraOptions({ + keepAlive: true, + OOBInline: true, + TCPNoDelay: true, + socketLinger: { on:true, linger:10 } + receiveBufferSize: 1000, + sendBufferSize: 1000, + reuseAddress: true, + socketTimeout: 3000, + },err => { + if (err) { + console.log('setExtraOptions fail'); + return; + } + console.log('setExtraOptions success'); + }); +}).catch(err => { + console.log('connect fail'); +}); +``` + + +### setExtraOptions + +setExtraOptions\(options: TCPExtraOptions\): Promise + +设置TCPSocket连接的其他属性,使用Promise方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>[bind](#bind)或[connect](#connect)方法调用成功后,才可调用此方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------------------------- | ---- | ------------------------------------------------------------ | +| options | [TCPExtraOptions](#tcpextraoptions) | 是 | TCPSocket连接的其他属性,参考[TCPExtraOptions](#tcpextraoptions)。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------- | :--------------------------------------------------- | +| Promise\ | 以Promise形式返回设置TCPSocket连接的其他属性的结果。 | + + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let promise = tcp.connect({ address: {address: '192.168.xx.xxx', port: xxxx, family: 1} , timeout: 6000}); +promise.then(() => { + console.log('connect success'); + let promise1 = tcp.setExtraOptions({ + keepAlive: true, + OOBInline: true, + TCPNoDelay: true, + socketLinger: { on:true, linger:10 } + receiveBufferSize: 1000, + sendBufferSize: 1000, + reuseAddress: true, + socketTimeout: 3000, + }); + promise1.then(() => { + console.log('setExtraOptions success'); + }).catch(err => { + console.log('setExtraOptions fail'); + }); +}).catch(err => { + console.log('connect fail'); +}); +``` + + +### on\('message'\) + +on\(type: 'message', callback: Callback<\{message: ArrayBuffer, remoteInfo: SocketRemoteInfo\}\>\): void + +订阅TCPSocket连接的接收消息事件。使用callback方式作为异步方法。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | +| type | string | 是 | 订阅的事件类型。'message':接收消息事件。 | +| callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}> | 是 | 回调函数。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +tcp.on('message', value => { + console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo) +}); +``` + + +### off\('message'\) + +off\(type: 'message', callback?: Callback<\{message: ArrayBuffer, remoteInfo: SocketRemoteInfo\}\>\): void + +取消订阅TCPSocket连接的接收消息事件。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------- | +| type | string | 是 | 订阅的事件类型。'message':接收消息事件。 | +| callback | Callback<{message: ArrayBuffer, remoteInfo: [SocketRemoteInfo](#socketremoteinfo)}> | 否 | 回调函数。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let callback = value =>{ + console.log("on message, message:" + value.message + ", remoteInfo:" + value.remoteInfo); +} +tcp.on('message', callback); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +tcp.off('message', callback); +tcp.off('message'); +``` + + +### on\('connect' | 'close'\) + +on\(type: 'connect' | 'close', callback: Callback\): void + +订阅TCPSocket的连接事件或关闭事件。使用callback方式作为异步方法。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 订阅的事件类型。
- 'connect':连接事件。
- 'close':关闭事件。 | +| callback | Callback\ | 是 | 回调函数。 | + + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +tcp.on('connect', () => { + console.log("on connect success") +}); +tcp.on('close', data => { + console.log("on close success") +}); +``` + + +### off\('connect' | 'close'\) + +off\(type: 'connect' | 'close', callback: Callback\): void + +取消订阅TCPSocket的连接事件或关闭事件。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------- | ---- | ------------------------------------------------------------ | +| type | string | 是 | 订阅的事件类型。
- 'connect':连接事件。
- 'close':关闭事件。 | +| callback | Callback\ | 否 | 回调函数。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let callback1 = () =>{ + console.log("on connect success"); +} +tcp.on('connect', callback1); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +tcp.off('connect', callback1); +tcp.off('connect'); +let callback2 = () =>{ + console.log("on close success"); +} +tcp.on('close', callback2); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +tcp.off('close', callback2); +tcp.off('close'); +``` + + +### on\('error'\) + +on\(type: 'error', callback: ErrorCallback\): void + +订阅TCPSocket连接的error事件。使用callback方式作为异步方法。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------- | ---- | ------------------------------------ | +| type | string | 是 | 订阅的事件类型。'error':error事件。 | +| callback | ErrorCallback | 是 | 回调函数。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +tcp.on('error', err => { + console.log("on error, err:" + JSON.stringify(err)) +}); +``` + + +### off\('error'\) + +off\(type: 'error', callback?: ErrorCallback\): void + +取消订阅TCPSocket连接的error事件。使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------- | ---- | ------------------------------------ | +| type | string | 是 | 订阅的事件类型。'error':error事件。 | +| callback | ErrorCallback | 否 | 回调函数。 | + +**示例:** + +``` +let tcp = socket.constructTCPSocketInstance(); +let callback = err =>{ + console.log("on error, err:" + JSON.stringify(err)); +} +tcp.on('error', callback); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 +tcp.off('error', callback); +tcp.off('error'); +``` + + +## TCPConnectOptions + +TCPSocket连接的参数。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---------------------------------- | ---- | -------------------------- | +| address | [NetAddress](#netaddress) | 是 | 绑定的地址以及端口。 | +| timeout | number | 否 | 超时时间,单位毫秒(ms)。 | + +## TCPSendOptions + +TCPSocket发送请求的参数。 + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| data | string | 是 | 发送的数据。 | +| encoding | string | 否 | 字符编码(UTF-8,UTF-16BE,UTF-16LE,UTF-16,US-AECII,ISO-8859-1),默认为UTF-8。 | + +## TCPExtraOptions + +TCPSocket连接的其他属性。 + +| 参数名 | 类型 | 必填 | 说明 | +| ----------------- | ------- | ---- | ------------------------------------------------------------ | +| keepAlive | boolean | 否 | 是否保持连接。默认为false。 | +| OOBInline | boolean | 否 | 是否为OOB内联。默认为false。 | +| TCPNoDelay | boolean | 否 | TCPSocket连接是否无时延。默认为false。 | +| socketLinger | Object | 是 | socket是否继续逗留。
- on:是否逗留(true:逗留;false:不逗留)。
- linger:逗留时长,单位毫秒(ms),取值范围为0~65535。
当入参on设置为true时,才需要设置。 | +| receiveBufferSize | number | 否 | 接收缓冲区大小(单位:Byte)。 | +| sendBufferSize | number | 否 | 发送缓冲区大小(单位:Byte)。 | +| reuseAddress | boolean | 否 | 是否重用地址。默认为false。 | +| socketTimeout | number | 否 | 套接字超时时间,单位毫秒(ms)。 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-stack.md b/zh-cn/application-dev/reference/apis/js-apis-stack.md index bac8197f592b465fdc1d6b18a78d462603decabc..0341c7ca8367410a6d451c128b8d4b0f730ced63 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-stack.md +++ b/zh-cn/application-dev/reference/apis/js-apis-stack.md @@ -60,12 +60,12 @@ push(item: T): T ``` let stack = new Stack(); -stack.push("a"); -stack.push(1); +let result = stack.push("a"); +let result1 = stack.push(1); let b = [1, 2, 3]; stack.push(b); let c = {name : "lala", age : "13"}; -stack.push(false); +let result3 = stack.push(c); ``` ### pop @@ -89,7 +89,7 @@ stack.push(4); stack.push(5); stack.push(2); stack.push(4); -stack.pop(); +let result = stack.pop(); ``` ### peek @@ -112,7 +112,7 @@ stack.push(2); stack.push(4); stack.push(5); stack.push(2); -stack.peek(); +let result = stack.peek(); ``` ### locate @@ -141,7 +141,7 @@ stack.push(2); stack.push(4); stack.push(5); stack.push(2); -stack.locate(2); +let result = stack.locate(2); ``` ### forEach @@ -197,7 +197,7 @@ stack.push(2); stack.push(4); stack.push(5); stack.push(4); -stack.isEmpty(); +let result = stack.isEmpty(); ``` ### [Symbol.iterator] diff --git a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md index 1f6fd7240d544c637071afe99294fc1e46af5ae1..423630408b85eba49db29a0c27c1d6438cf9e511 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md +++ b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md @@ -6,7 +6,7 @@ ## 导入模块 ```js -import storagestatistics from "@ohos.storagestatistics"; +import storagestatistics from "@ohos.storageStatistics"; ``` ## 系统能力 @@ -61,9 +61,10 @@ getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):v let uuid = ""; storagestatistics.getTotalSizeOfVolume(uuid, function(error, number){ // do something + console.info("getTotalSizeOfVolume successfully:"+ number); }); ``` - + ## storagestatistics.getFreeSizeOfVolume @@ -115,22 +116,22 @@ getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):vo let uuid = ""; storagestatistics.getFreeSizeOfVolume(uuid, function(error, number){ // do something + console.info("getFreeSizeOfVolume successfully:"+ number); }); ``` -## storagestatistics.getBundleStats +## storagestatistics.getBundleStats9+ -getBundleStats(volumeUuid: string, packageName:String, ): Promise<BundleStats> +getBundleStats(packageName:String, ): Promise<BundleStats> -异步获取指定卷上的应用存储状态,以promise方式返回。 +异步获取应用存储状态,以promise方式返回。 - 参数 | 参数名 | 类型 | 必填 | 说明 | | ----------- | ------ | ---- | -------- | - | volumeUuid | string | 是 | 卷id | | packageName | string | 是 | 应用包名 | - + - 返回值 | 类型 | 说明 | @@ -140,35 +141,33 @@ getBundleStats(volumeUuid: string, packageName:String, ): Promise<BundleStat - 示例 ```js - let uuid = ""; let packageName = ""; - storagestatistics.getBundleStats(uuid, packageName).then(function(BundleStats){ + storagestatistics.getBundleStats(packageName).then(function(BundleStats){ console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); }).catch(function(err){ console.info("getBundleStats failed with error:"+ err); }); ``` -## storagestatistics.getBundleStats +## storagestatistics.getBundleStats9+ -getBundleStats(volumeUuid: string, callback:AsyncCallback<BundleStats>):void +getBundleStats(callback:AsyncCallback<BundleStats>):void -异步获取指定卷上的应用存储状态,以callback方式返回。 +异步获取应用存储状态,以callback方式返回。 - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | --------------------------------------------------------- | ---- | ------------------------------------ | - | volumeUuid | string | 是 | 卷id | - | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 | - + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------------------------------- | ---- | ------------------------------------ | + | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 | + - 示例 ```js - let uuid = ""; let packageName = ""; - storagestatistics.getBundleStats(uuid, packageName, function(error, BundleStats){ + storagestatistics.getBundleStats(packageName, function(error, BundleStats){ // do something + console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats)); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-thermal.md b/zh-cn/application-dev/reference/apis/js-apis-thermal.md index 5154348d0971d2e2df8c4c53932e9cfc65aa927b..363db2384ab989276424de0283cb30604289b70e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-thermal.md +++ b/zh-cn/application-dev/reference/apis/js-apis-thermal.md @@ -3,6 +3,8 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +该模块主要提供设备热状态的监听接口。 + ## 导入模块 @@ -15,15 +17,15 @@ import thermal from '@ohos.thermal'; 热档位信息。 -| 名称 | 默认值 | 描述 | -| -------- | -------- | -------- | -| COOL | 0 | 表明设备处于低温的状态,业务执行不受热控的限制。 | -| NORMAL | 1 | 表明设备处于正常工作状态,但温度不低,需要注意是否临近发热状态。 | -| WARM | 2 | 表明设备已经进入温热状态,部分无感知业务需要考虑停止或延迟执行。 | -| HOT | 3 | 表明设备已经明显发热,无感知业务应全面停止,其他业务应考虑降规格及负载。 | -| OVERHEATED | 4 | 表明设备已经发热严重,无感知业务应全面停止,主要业务需降低规格及负载。 | -| WARNING | 5 | 表明设备已经发热严重并且即将进入紧急状态,无感知业务应全面停止,主要业务应降低至最低规格。 | -| EMERGENCY | 6 | 表明设备已经进入紧急状态,所有业务应当全面停止工作,可保留部分紧急求助功能。 | +| 名称 | 默认值 | 描述 | +| ---------- | ---- | ---------------------------------------- | +| COOL | 0 | 表明设备处于低温的状态,业务执行不受热控的限制。
**系统能力:** SystemCapability.PowerManager.ThermalManager | +| NORMAL | 1 | 表明设备处于正常工作状态,但温度不低,需要注意是否临近发热状态。
**系统能力:** SystemCapability.PowerManager.ThermalManager | +| WARM | 2 | 表明设备已经进入温热状态,部分无感知业务需要考虑停止或延迟执行。
**系统能力:** SystemCapability.PowerManager.ThermalManager | +| HOT | 3 | 表明设备已经明显发热,无感知业务应全面停止,其他业务应考虑降规格及负载。
**系统能力:** SystemCapability.PowerManager.ThermalManager | +| OVERHEATED | 4 | 表明设备已经发热严重,无感知业务应全面停止,主要业务需降低规格及负载。
**系统能力:** SystemCapability.PowerManager.ThermalManager | +| WARNING | 5 | 表明设备已经发热严重并且即将进入紧急状态,无感知业务应全面停止,主要业务应降低至最低规格。
**系统能力:** SystemCapability.PowerManager.ThermalManager | +| EMERGENCY | 6 | 表明设备已经进入紧急状态,所有业务应当全面停止工作,可保留部分紧急求助功能。
**系统能力:** SystemCapability.PowerManager.ThermalManager | ## thermal.subscribeThermalLevel @@ -32,19 +34,18 @@ subscribeThermalLevel(callback: AsyncCallback<ThermalLevel>): void 订阅热档位变化时的回调提醒。 -**系统能力:** - -SystemCapability.PowerManager.ThermalManager +**系统能力:** SystemCapability.PowerManager.ThermalManager **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<ThermalLevel> | 是 | 指定的callback回调方法,用于获取返回值。
callback返回值:热档位信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------- | ---- | ---------------------------------------- | +| callback | AsyncCallback<ThermalLevel> | 是 | 指定的callback回调方法,用于获取返回值。
callback返回值:热档位信息。 | **示例:** ``` +var lev = 0; thermal.subscribeThermalLevel((lev) => { console.info("Thermal level is: " + lev); }) @@ -52,19 +53,17 @@ thermal.subscribeThermalLevel((lev) => { ## thermal.unsubscribeThermalLevel -unsubscribeThermalLevel(callback?: AsyncCallback): void +unsubscribeThermalLevel(callback?: AsyncCallback\): void 取消订阅热档位变化时的回调提醒。 -**系统能力:** - -SystemCapability.PowerManager.ThermalManager +**系统能力:** SystemCapability.PowerManager.ThermalManager **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------- | -------- | -------- | -| callback | AsyncCallback<void> | 可选 | 指定的callback回调方法,无返回值。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | --------------------- | +| callback | AsyncCallback<void> | 可选 | 指定的callback回调方法,无返回值。 | **示例:** @@ -80,14 +79,12 @@ getThermalLevel(): ThermalLevel 获取当前热档位信息。 -**系统能力:** - -SystemCapability.PowerManager.ThermalManager +**系统能力:** SystemCapability.PowerManager.ThermalManager **返回值:** -| 类型 | 说明 | -| -------- | -------- | +| 类型 | 说明 | +| ------------ | ------ | | ThermalLevel | 热档位信息。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-treemap.md b/zh-cn/application-dev/reference/apis/js-apis-treemap.md index c66771b269d9ffaa9a75de6eba27baae7d86d00c..796112066e342dd7fe36577480a0481f3962d2b1 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treemap.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treemap.md @@ -21,7 +21,7 @@ SystemCapability.Utils.Lang | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------- | -------- | -------- | -------- | -------- | -| length | number | 是 | 否 | TreeMap的元素个数 | +| length | number | 是 | 否 | TreeMap的元素个数。 | ### constructor @@ -59,7 +59,7 @@ isEmpty(): boolean; ``` const treeMap = new TreeMap(); -treeMap.isEmpty(); +let result = treeMap.isEmpty(); ``` @@ -73,21 +73,21 @@ hasKey(key: K): boolean; | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | K | 是 | 指定元素 | +| key | K | 是 | 指定key | **返回值:** | 类型 | 说明 | | -------- | -------- | -| boolean | 包含指定元素返回true,否则返回false。 | +| boolean | 包含指定key返回true,否则返回false。 | **示例:** ``` let treeMap = new TreeMap(); -treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result1 = treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); ``` @@ -101,7 +101,7 @@ hasValue(value: V): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | V | 是 | 指定元素。 | +| value | V | 是 | 指定value。 | **返回值:** @@ -113,9 +113,9 @@ hasValue(value: V): boolean ``` let treeMap = new TreeMap(); -treeMap.hasValue(123); +let result = treeMap.hasValue(123); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); -treeMap.hasValue(123); +let result1 = treeMap.hasValue(123); ``` @@ -129,7 +129,7 @@ get(key: K): V | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | K | 是 | 查找的指定key。 | +| key | K | 是 | 指定key。 | **返回值:** @@ -143,7 +143,7 @@ get(key: K): V let treeMap = new TreeMap(); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("sdfs", 356); -treeMap.get("sdfs"); +let result = treeMap.get("sdfs"); ``` @@ -151,13 +151,13 @@ treeMap.get("sdfs"); getFirstKey(): K; -获取容器中排序第一的数据。 +获取容器中排序第一的key。 **返回值:** | 类型 | 说明 | | -------- | -------- | -| K | 返回排序第一的数据。 | +| K | 返回排序第一的key。 | **示例:** @@ -173,13 +173,13 @@ let result = treeMap.getFirstKey(); getLastKey(): K; -获取容器中排序最后的数据。 +获取容器中排序最后的key。 **返回值:** | 类型 | 说明 | | -------- | -------- | -| K | 返回排序最后的数据 | +| K | 返回排序最后的key | **示例:** @@ -195,13 +195,13 @@ let result = treeMap.getLastKey(); setAll(map: TreeMap): void -将一个treemap中的所有元素组添加到另一个treemap中。 +将一个treemap中的所有元素组添加到另一个treeMap中。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| map | TreeMap | 是 | 被添加元素的TreeMap。 | +| map | TreeMap | 是 | 被添加元素的treeMap。 | **示例:** @@ -230,7 +230,7 @@ set(key: K, value: V): Object | 类型 | 说明 | | -------- | -------- | -| Object | 返回添加后的treemap | +| Object | 返回添加后的treeMap | **示例:** @@ -244,13 +244,13 @@ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); remove(key: K): V; -删除指定的元素。 +删除指定key对应的元素。 **参数:** | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | K | 是 | 依据key指定删除的元素。 | +| key | K | 是 | 指定key。 | **返回值:** @@ -268,9 +268,9 @@ treeMap.remove("sdfs"); ``` -### getLowerByKey +### getLowerKey -getLowerByKey(key: K): K +getLowerKey(key: K): K 获取容器中比传入key排序靠前一位的key。 @@ -293,13 +293,13 @@ let treeMap = new TreeMap(); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("sdfs", 356); treeMap.set("zdfgsd", 356); -let result = treeMap.getLowerByKey("sdfs"); +let result = treeMap.getLowerKey("sdfs"); ``` -### getHigherByKey +### getHigherKey -getHigherByKey(key: K): K +getHigherKey(key: K): K 获取容器中比传入key排序靠后一位的key。 @@ -322,12 +322,11 @@ let treeMap = new TreeMap(); treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123); treeMap.set("sdfs", 356); treeMap.set("zdfgsd", 356); -let result = treeMap.getHigherByKey("sdfs"); +let result = treeMap.getHigherKey("sdfs"); ``` - ### replace -replace(key: K, value: V): boolean +replace(key: K, newValue: V): boolean 对TreeMap中一组数据进行更新(替换)。 @@ -335,21 +334,21 @@ replace(key: K, value: V): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | K | 是 | 依据key指定替换的元素。 | -| value | V | 是 | 成员数据的新值。 | +| key | K | 是 | 指定key。 | +| newValue | V | 是 | 替换的元素。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| boolean | 成功对已有数据进行替换返回true,否则返回false。 | +| boolean | 对指定key对应的元素替换成功返回true,否则返回false。 | **示例:** ``` let treeMap = new TreeMap(); treeMap.set("sdfs", 123); -treeMap.replace("sdfs", 357); +let result = treeMap.replace("sdfs", 357); ``` @@ -425,7 +424,7 @@ while(temp != undefined) { ### forEach -forEach(callbackfn: (value: V, key?: K, treeMap?: TreeMap) => void, thisArg?: Object): void +forEach(callbackfn: (value: V, key?: K, map?: TreeMap) => void, thisArg?: Object): void 通过回调函数来遍历实例对象上的元素以及元素对应的下标。 @@ -441,7 +440,7 @@ callbackfn的参数说明: | -------- | -------- | -------- | -------- | | value | V | 是 | 当前遍历到的元素键值对的值。 | | key | K | 是 | 当前遍历到的元素键值对的键。 | -| treeMap | TreeMap | 否 | 当前调用forEach方法的实例对象。 | +| map | TreeMap | 否 | 当前调用forEach方法的实例对象。 | **示例:** @@ -459,7 +458,7 @@ treeMap.forEach((value, key) => { entries(): IterableIterator<[K, V]> -返回包含此映射中包含的元素的新迭代器对象。 +返回包含此映射中包含的键值对的新迭代器对象。 **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-treeset.md b/zh-cn/application-dev/reference/apis/js-apis-treeset.md index ccc118ddc5f273681a88ab3c4b4984d2d31fac7e..48c65fea23227ff1113273dc6aff3f772ab2ab99 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-treeset.md +++ b/zh-cn/application-dev/reference/apis/js-apis-treeset.md @@ -59,7 +59,7 @@ isEmpty(): boolean ``` const treeSet = new TreeSet(); -treeSet.isEmpty(); +let result = treeSet.isEmpty(); ``` @@ -67,7 +67,7 @@ treeSet.isEmpty(); has(value: T): boolean -判断此容器中是否含有该指定value。 +判断此容器中是否含有该指定元素。 **参数:** @@ -87,7 +87,7 @@ has(value: T): boolean let treeSet = new TreeSet(); treeSet.has(123); treeSet.add(123); -treeSet.has(123); +let result1 = treeSet.has(123); ``` @@ -156,13 +156,13 @@ add(value: T): boolean ``` let treeSet = new TreeSet(); -treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); ``` ### remove -remove(key: T): boolean +remove(value: T): boolean; 删除指定的元素。 @@ -170,7 +170,7 @@ remove(key: T): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| key | T | 是 | 指定的元素。 | +| value | T | 是 | 指定的元素。 | **返回值:** @@ -184,7 +184,7 @@ remove(key: T): boolean let treeSet = new TreeSet(); treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); treeSet.add("sdfs"); -treeSet.remove("sdfs"); +let result = treeSet.remove("sdfs"); ``` @@ -233,7 +233,7 @@ getHigherValue(key: T): T | 类型 | 说明 | | -------- | -------- | -| T | 返回排序中传入元素后一位的数据 | +| T | 返回排序中传入元素后一位的数据。 | **示例:** @@ -278,7 +278,7 @@ popLast(): T | 类型 | 说明 | | -------- | -------- | -| T | 返回删除的数据 | +| T | 返回删除的数据。 | **返回值:** @@ -335,7 +335,7 @@ while(temp != undefined) { ### forEach -forEach(callbackfn: (value: T, key?: T, treeSet?: TreeSet<T>) => void, thisArg?: Object): void +forEach(callbackfn: (value: T, key?: T, set?: TreeSet<T>) => void, thisArg?: Object): void 通过回调函数来遍历实例对象上的元素以及元素对应的下标。 @@ -351,7 +351,7 @@ callbackfn的参数说明: | -------- | -------- | -------- | -------- | | value | T | 是 | 当前遍历到的元素。 | | key | T | 否 | 当前遍历到的元素(和value相同)。 | -| treeSet | TreeSet<T> | 否 | 当前调用forEach方法的实例对象。 | +| set | TreeSet<T> | 否 | 当前调用forEach方法的实例对象。 | **示例:** @@ -369,7 +369,7 @@ treeSet.forEach((value, key) => { entries(): IterableIterator<[T, T]> -返回包含此映射中包含的元素的新迭代器对象。 +返回包含此映射中包含的键值对的新迭代器对象。 **返回值:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-update.md b/zh-cn/application-dev/reference/apis/js-apis-update.md index 96153284d2d1b36fcc2e4d407fff209470f4ad18..ea84b0d18e42292353a90ff55f8c9f70b6fcec1b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-update.md +++ b/zh-cn/application-dev/reference/apis/js-apis-update.md @@ -1,5 +1,8 @@ # 升级 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + 升级范围:升级整个系统,包括内置的资源、预置应用;第三方的应用不在升级的范围。 升级依赖:升级分为SD卡升级和在线升级两种。 @@ -17,14 +20,14 @@ import update from '@ohos.update' 无 -## 获取升级对象Updater - -### update.getUpdater +## update.getUpdater getUpdater(upgradeFile: string, updateType?: UpdateTypes): Updater 获取本地升级Updater。 +**系统能力**:SystemCapability.Update.UpdateService + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -48,12 +51,14 @@ try { } ``` -### update.getUpdaterForOther +## update.getUpdaterForOther getUpdaterForOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater 获取升级对象给待升级设备。 +**系统能力**:SystemCapability.Update.UpdateService + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -78,12 +83,14 @@ try { } ``` -### update.getUpdaterFromOther +## update.getUpdaterFromOther getUpdaterFromOther(upgradeFile: string, device: string, updateType?: UpdateTypes): Updater 获取其它设备为本设备升级的Updater。 +**系统能力**:SystemCapability.Update.UpdateService + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -116,6 +123,8 @@ getNewVersionInfo(callback: AsyncCallback\): void 获取新版本信息,使用callback方式作为异步方法。 +**系统能力**:SystemCapability.Update.UpdateService + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -139,6 +148,8 @@ getNewVersionInfo(): Promise\ 获取新版本信息,使用promise方式作为异步方法。 +**系统能力**:SystemCapability.Update.UpdateService + **返回值:** | 类型 | 说明 | @@ -163,6 +174,8 @@ checkNewVersion(callback: AsyncCallback\): void 检查新版本,使用callback方式作为异步方法。 +**系统能力**:SystemCapability.Update.UpdateService + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -186,6 +199,8 @@ checkNewVersion(): Promise\ 检查新版本,使用promise方式作为异步方法。 +**系统能力**:SystemCapability.Update.UpdateService + **返回值:** | 类型 | 说明 | @@ -210,6 +225,8 @@ verifyUpdatePackage(upgradeFile: string, certsFile: string): void 升级前检查升级包是否有效。 +**系统能力**:SystemCapability.Update.UpdateService + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -232,6 +249,8 @@ rebootAndCleanUserData(): Promise\ 重启设备并清除用户分区数据。 +**系统能力**:SystemCapability.Update.UpdateService + **返回值:** | 类型 | 说明 | @@ -254,6 +273,8 @@ rebootAndCleanUserData(callback: AsyncCallback\): void 重启设备并清除用户分区数据。 +**系统能力**:SystemCapability.Update.UpdateService + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -274,6 +295,8 @@ applyNewVersion(): Promise\ 重启设备后安装升级包。 +**系统能力**:SystemCapability.Update.UpdateService + **返回值:** | 类型 | 说明 | @@ -296,6 +319,8 @@ applyNewVersion(callback: AsyncCallback\): void 重启设备后安装升级包。 +**系统能力**:SystemCapability.Update.UpdateService + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -316,6 +341,8 @@ download(): void 下载新版本,并监听下载进程。 +**系统能力**:SystemCapability.Update.UpdateService + **示例:** ``` @@ -333,6 +360,8 @@ updater.upgrade():void 启动升级。 +**系统能力**:SystemCapability.Update.UpdateService + **示例:** ``` @@ -350,6 +379,8 @@ setUpdatePolicy(policy: UpdatePolicy, callback: AsyncCallback\): void 设置升级策略,使用callback方式作为异步方法。 +**系统能力**:SystemCapability.Update.UpdateService + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -379,6 +410,8 @@ setUpdatePolicy(policy: UpdatePolicy): Promise\ 设置升级策略,使用promise方式作为异步方法。 +**系统能力**:SystemCapability.Update.UpdateService + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -414,6 +447,8 @@ getUpdatePolicy(callback: AsyncCallback\): void 获取升级策略信息,使用callback方式作为异步方法。 +**系统能力**:SystemCapability.Update.UpdateService + **参数:** | 参数名 | 类型 | 必填 | 说明 | @@ -437,6 +472,8 @@ getUpdatePolicy(): Promise\ 获取升级策略,通过promise方式作为异步方法。 +**系统能力**:SystemCapability.Update.UpdateService + **返回值:** | 类型 | 说明 | @@ -459,6 +496,8 @@ update.getUpdatePolicy().then(value => { 升级类型。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 参数名 | 说明 | | ------ | -------- | | OTA | OTA升级 | @@ -468,6 +507,8 @@ update.getUpdatePolicy().then(value => { 升级包类型。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 参数名 | 默认值 | 说明 | | -------------------- | ------ | -------------- | | PACKAGE_TYPE_NORMAL | 1 | 通用升级包 | @@ -482,6 +523,8 @@ update.getUpdatePolicy().then(value => { 安装模式。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 参数名 | 默认值 | 说明 | | ------------------- | ------ | -------- | | INSTALL_MODE_NORMAL | 0 | 正常升级 | @@ -492,6 +535,8 @@ update.getUpdatePolicy().then(value => { 新版本检测状态。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 参数名 | 默认值 | 说明 | | ------------------- | ------ | ---------------- | | VERSION_STATUS_ERR | -1 | 检测版本时出错 | @@ -503,6 +548,8 @@ update.getUpdatePolicy().then(value => { 升级策略。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 名称 | 参数类型 | 必填 | 说明 | | ------------------- | --------------------------- | ---- | -------------- | | autoDownload | bool | 是 | 自动升级开关 | @@ -513,6 +560,8 @@ update.getUpdatePolicy().then(value => { 新版本信息。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 名称 | 参数类型 | 必填 | 说明 | | --------------- | ------------------------------------------- | ---- | -------- | | status | [NewVersionStatus](#newversionstatus) | 是 | 升级状态 | @@ -524,6 +573,8 @@ update.getUpdatePolicy().then(value => { 检测结果。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 名称 | 参数类型 | 必填 | 说明 | | ------------- | ----------------------------- | ---- | ------------ | | versionName | string | 是 | 版本名称 | @@ -537,6 +588,8 @@ update.getUpdatePolicy().then(value => { 版本描述信息。 +**系统能力**:以下各项对应的系统能力均为:SystemCapability.Update.UpdateService + | 名称 | 参数类型 | 必填 | 说明 | | ------------- | -------- | ---- | ----------------- | | descriptionId | string | 是 | 版本versionId信息 | diff --git a/zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md b/zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md index 34cc33c69437954800242c7cbeff198bccd1da5f..f09e2458dfda147edba473e448e7d6ead422e85e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uripermissionmanager.md @@ -1,12 +1,7 @@ # UriPermissionManager -- [导入模块](#导入模块) -- [verifyUriPermission](#verifyUriPermission) -- [verifyUriPermission](#verifyUriPermission) - - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API 9开始支持。 +> 本模块首批接口从API 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 Uri权限管理。 @@ -26,13 +21,17 @@ verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number 检验某个应用是否对指定的uri有flag指定的权限。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | | uri | string | 是 | 指向文件的uri,例如fileshare:///com.samples.filesharetest.FileShare/person/10。 | | flag | wantConstant.Flags | 是 | uri的读权限或写权限。 | | accessTokenId | number | 是 | 每个应用的唯一标识ID,开发者通过包管理接口自行获取。 | - | callback | AsyncCallback<number> | 是 | callback形式返回启动结果,返回0表示有权限,返回-1表示无权限。 | + | callback | AsyncCallback<number> | 是 | callback形式返回检验结果,返回0表示有权限,返回-1表示无权限。 | - 示例: @@ -50,6 +49,10 @@ verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number 检验某个应用是否对指定的uri有flag指定的权限。 +**系统能力:** + +SystemCapability.Ability.AbilityRuntime.Core + - 参数: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-url.md b/zh-cn/application-dev/reference/apis/js-apis-url.md index f9fc0379bbb57eff50d727381e10b4267a1c8d61..2208093cd8c569b43645479e6840acf41e5f4ef4 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-url.md +++ b/zh-cn/application-dev/reference/apis/js-apis-url.md @@ -36,7 +36,7 @@ var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'] var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2}); var objectParams2 = new URLSearchParams('?fod=1&bard=2'); var urlObject = new URL('https://developer.mozilla.org/?fod=1&bard=2'); -var params = new URLSearchParams(urlObject .search); +var params = new URLSearchParams(urlObject.search); ``` @@ -79,7 +79,7 @@ delete(name: string): void ``` let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsobject = new URLSearchParams(urlObject.search.slice(1)); -paramsobject.delete('foo'); +paramsobject.delete('fod'); ``` @@ -106,7 +106,7 @@ getAll(name: string): string[] ``` let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); let paramsObject = new URLSearchParams(urlObject.search.slice(1)); -paramsObject.append('fod', 3); // Add a second value for the foo parameter. +paramsObject.append('fod', 3); // Add a second value for the fod parameter. console.log(params.getAll('fod')) // Output ["1","3"]. ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-usb.md b/zh-cn/application-dev/reference/apis/js-apis-usb.md index ab99f323c24414152803f02edc7ba2f308f414fa..7a5667f118a442823b90f3200180e8db4d8f7a8f 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-usb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-usb.md @@ -11,7 +11,7 @@ import usb from "@ohos.usb"; ## usb.getDevices -usb.getDevices(): Array<Readonly<USBDevice>> +getDevices(): Array<Readonly<USBDevice>> 获取USB设备列表。 @@ -81,7 +81,7 @@ usb.getDevices(): Array<Readonly<USBDevice>> ## usb.connectDevice -usb.connectDevice(device: USBDevice): Readonly<USBDevicePipe> +connectDevice(device: USBDevice): Readonly<USBDevicePipe> 打开USB设备。 @@ -108,7 +108,7 @@ usb.connectDevice(device: USBDevice): Readonly<USBDevicePipe> ## usb.hasRight -usb.hasRight(deviceName: string): boolean +hasRight(deviceName: string): boolean 判断是否有权访问该设备。 @@ -134,7 +134,7 @@ usb.hasRight(deviceName: string): boolean ## usb.requestRight -usb.requestRight(deviceName: string): Promise<boolean> +requestRight(deviceName: string): Promise<boolean> 请求软件包的临时权限以访问设备。 @@ -161,7 +161,7 @@ usb.requestRight(deviceName: string): Promise<boolean> ## usb.claimInterface -usb.claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number +claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number 注册通信接口。 @@ -190,7 +190,7 @@ usb.claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): n ## usb.releaseInterface -usb.releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number +releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number 释放注册过的通信接口。 @@ -218,7 +218,7 @@ usb.releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number ## usb.setConfiguration -usb.setConfiguration(pipe: USBDevicePipe, config: USBConfig): number +setConfiguration(pipe: USBDevicePipe, config: USBConfig): number 设置设备配置。 @@ -246,7 +246,7 @@ usb.setConfiguration(pipe: USBDevicePipe, config: USBConfig): number ## usb.setInterface -usb.setInterface(pipe: USBDevicePipe, iface: USBInterface): number +setInterface(pipe: USBDevicePipe, iface: USBInterface): number 设置设备接口。 @@ -274,7 +274,7 @@ usb.setInterface(pipe: USBDevicePipe, iface: USBInterface): number ## usb.getRawDescriptor -usb.getRawDescriptor(pipe: USBDevicePipe): Uint8Array +getRawDescriptor(pipe: USBDevicePipe): Uint8Array 获取原始的USB描述符。 @@ -300,7 +300,7 @@ usb.getRawDescriptor(pipe: USBDevicePipe): Uint8Array ## usb.getFileDescriptor -usb.getFileDescriptor(pipe: USBDevicePipe): number +getFileDescriptor(pipe: USBDevicePipe): number 获取文件描述符。 @@ -326,7 +326,7 @@ usb.getFileDescriptor(pipe: USBDevicePipe): number ## usb.controlTransfer -usb.controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise<number> +controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise<number> 控制传输。 @@ -356,7 +356,7 @@ usb.controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout? ## usb.bulkTransfer -usb.bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise<number> +bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise<number> 批量传输。 @@ -390,7 +390,7 @@ usb.bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, ## usb.closePipe -usb.closePipe(pipe: USBDevicePipe): number +closePipe(pipe: USBDevicePipe): number 关闭设备消息控制通道。 @@ -536,12 +536,5 @@ USB设备消息传输通道,用于确定设备。 | 名称 | 默认值 | 说明 | | -------- | -------- | -------- | -| USB_REQUEST_TYPE_STANDARD | 0 | 写数据,主设备往从设备。
**系统能力**: SystemCapability.USB.USBManager | -| USB_REQUEST_TYPE_CLASS | 0x80 | 读数据,从设备往主设备。
**系统能力**: SystemCapability.USB.USBManager | - -| 名称 | 默认值 | 说明 | -| -------- | -------- | -------- | -| NONE | 0 | 无。
**系统能力**: SystemCapability.USB.USBManager | -| ACM | 1 | 串口设备。
**系统能力**: SystemCapability.USB.USBManager | -| ECM | 2 | 网口设备。
**系统能力**: SystemCapability.USB.USBManager | -| HDC | 4 | HDC设备。
**系统能力**: SystemCapability.USB.USBManager | +| USB_REQUEST_DIR_TO_DEVICE | 0 | 写数据,主设备往从设备。
**系统能力**: SystemCapability.USB.USBManager | +| USB_REQUEST_DIR_FROM_DEVICE | 0x80 | 读数据,从设备往主设备。
**系统能力**: SystemCapability.USB.USBManager | diff --git a/zh-cn/application-dev/reference/apis/js-apis-vector.md b/zh-cn/application-dev/reference/apis/js-apis-vector.md index c3e4ed2235f160924c8c9fa0d31896685e33d671..3e9285e735f00541bdee712b0f1488123d8a65a9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-vector.md +++ b/zh-cn/application-dev/reference/apis/js-apis-vector.md @@ -48,24 +48,24 @@ add(element: T): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| element | T | 是 | 添加进去的元素 | +| element | T | 是 | 添加进去的元素。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| boolean | 插入成功返回true,失败返回false | +| boolean | 插入成功返回true,失败返回false。 | **示例:** ``` let vector = new Vector(); -vector.add("a"); -vector.add(1); +let result = vector.add("a"); +let result1 = vector.add(1); let b = [1, 2, 3]; vector.add(b); let c = {name : "lala", age : "13"}; -vector.add(false); +let result3 = vector.add(c); ``` ### insert @@ -78,8 +78,8 @@ insert(element: T, index: number): void | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| element | T | 是 | 被插入的元素 | -| index | number | 是 | 被插入的位置索引 | +| element | T | 是 | 被插入的元素。 | +| index | number | 是 | 被插入的位置索引。 | **示例:** @@ -100,21 +100,21 @@ has(element: T): boolean | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| element | T | 是 | 指定的元素 | +| element | T | 是 | 指定的元素。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| boolean | 是否包含指定元素 | +| boolean | 是否包含指定元素。 | **示例:** ``` let vector = new Vector(); -vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); vector.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); -vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); +let result = vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf"); ``` ### getIndexOf @@ -127,13 +127,13 @@ getIndexOf(element: T): number | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| element | T | 是 | 指定的元素 | +| element | T | 是 | 指定的元素。 | **返回值:** | 类型 | 说明 | | -------- | -------- | -| number | 返回指定元素第一次出现时的下标值,查找失败返回-1 | +| number | 返回指定元素第一次出现时的下标值,查找失败返回-1。 | **示例:** @@ -146,7 +146,7 @@ vector.add(2); vector.add(1); vector.add(2); vector.add(4); -vector.getIndexOf(2); +let result = vector.getIndexOf(2); ``` ### getLastIndexOf @@ -178,7 +178,7 @@ vector.add(2); vector.add(1); vector.add(2); vector.add(4); -vector.getLastIndexOf(2); +let result = vector.getLastIndexOf(2); ``` ### removeByIndex @@ -208,7 +208,7 @@ vector.add(4); vector.add(5); vector.add(2); vector.add(4); -vector.removeByIndex(2); +let result = vector.removeByIndex(2); ``` ### remove @@ -237,7 +237,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.remove(2); +let result = vector.remove(2); ``` ### removeByRange @@ -282,9 +282,9 @@ callbackfn的参数说明: | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| value | T | 是 | 当前遍历到的元素 | -| index | number | 否 | 当前遍历到的下标值 | -| vector | Vector<T> | 否 | 当前调用replaceAllElements方法的实例对象 | +| value | T | 是 | 当前遍历到的元素。 | +| index | number | 否 | 当前遍历到的下标值。 | +| vector | Vector<T> | 否 | 当前调用replaceAllElements方法的实例对象。 | **示例:** @@ -377,8 +377,8 @@ subVector(fromIndex: number, toIndex: number): Vector<T> | 参数名 | 类型 | 必填 | 说明 | | -------- | -------- | -------- | -------- | -| fromIndex | number | 是 | 起始下标 | -| toIndex | number | 是 | 终止下标 | +| fromIndex | number | 是 | 起始下标。 | +| toIndex | number | 是 | 终止下标。 | **返回值:** @@ -394,9 +394,9 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.subVector(2,4); -vector.subVector(4,3); -vector.subVector(2,6); +let result = vector.subVector(2,4); +let result1 = vector.subVector(4,3); +let result2 = vector.subVector(2,6); ``` @@ -419,15 +419,13 @@ vector.clear(); ### clone clone(): Vector<T> -克隆一个与Vector相同的实例,并返回克隆后的实例。 - -修改克隆后的实例并不会影响原实例。 +克隆一个与Vector相同的实例,并返回克隆后的实例。修改克隆后的实例并不会影响原实例。 **返回值:** | 类型 | 说明 | | -------- | -------- | -| Vector<T> | 返回Vector对象实例 | +| Vector<T> | 返回Vector对象实例。 | **示例:** @@ -437,7 +435,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.clone(); +let result = vector.clone(); ``` ### getCapacity @@ -459,7 +457,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.getCapacity(); +let result = vector.getCapacity(); ``` ### convertToArray @@ -481,7 +479,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.convertToArray(); +let result = vector.convertToArray(); ``` ### isEmpty @@ -503,7 +501,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.isEmpty(); +let result = vector.isEmpty(); ``` ### increaseCapacityTo @@ -542,7 +540,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.trimToCurrentLength(2); +vector.trimToCurrentLength(); ``` ### toString @@ -565,13 +563,12 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.toSting(); +let result = vector.toSting(); ``` ### copyToArray -copyToArray(array: Array<T>): void; - +copyToArray(array: Array<T>): void 将Vector实例中的元素按照下标复制到指定数组。 **参数:** @@ -589,7 +586,7 @@ vector.add(4); vector.add(5); vector.add(4); let array = ["a", "b", "c", "d", "e", "f"]; -vector.copyToArray(array); +let result = vector.copyToArray(array); ``` ### getFirstElement @@ -612,7 +609,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.getFirstElement(); +let result = vector.getFirstElement(); ``` ### getLastElement @@ -635,7 +632,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.getLastElement(); +let result = vector.getLastElement(); ``` ### getLastIndexFrom @@ -666,12 +663,12 @@ vector.add(4); vector.add(5); vector.add(4); vector.add("a"); -vector.getLastIndexFrom(4,3); +let result = vector.getLastIndexFrom(4,3); ``` ### getIndexFrom -getIndexFrom(element: T, index: number): number; +getIndexFrom(element: T, index: number): number 从指定索引向前搜索,返回该元素的下标索引。 @@ -697,11 +694,11 @@ vector.add(4); vector.add(5); vector.add(4); vector.add("a"); -vector.getIndexFrom(4, 3); +let result = vector.getIndexFrom(4, 3); ``` ### setLength -setLength(newSize: number): void; +setLength(newSize: number): void 设置Vector实例的元素个数。 @@ -723,6 +720,59 @@ vector.setLength(8); vector.setLength(2); ``` +### get +get(index: number): T +根据下标值获取Vector实例中的元素。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | index | number | 是 | 查找的下标值。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | T | 返回获取到的元素。 | + +**示例:** + + ``` + let vector = new Vector(); + vector.add(2); + vector.add(4); + vector.add(5); + vector.add(4); + let result = vector.get(2); + ``` +### set +set(index: number, element: T): T +替换指定下标对应的元素。 + +**参数:** + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | index | number | 是 | 指定下标。 | + +**返回值:** + + | 类型 | 说明 | + | -------- | -------- | + | T | 返回替换后的元素。 | + +**示例:** + + ``` + let vector = new Vector(); + vector.add(2); + vector.add(4); + vector.add(5); + vector.add(4); + let result = vector.set(2, "A"); + ``` + ### [Symbol.iterator] [Symbol.iterator]\(): IterableIterator<T> diff --git a/zh-cn/application-dev/reference/apis/js-apis-webSocket.md b/zh-cn/application-dev/reference/apis/js-apis-webSocket.md new file mode 100644 index 0000000000000000000000000000000000000000..05d58dddb672a6481209807c4c519b3291951d73 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-webSocket.md @@ -0,0 +1,588 @@ +# WebSocket连接 + +>![](public_sys-resources/icon-note.gif) **说明:** +>本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 +> +>当前暂时不支持WebSocket,预计在MR版本支持。 + +使用WebSocket建立服务器与客户端的双向连接,需要先通过[createWebSocket](#websocketcreatewebsocket)方法创建[WebSocket](#websocket)对象,然后通过[connect](#connect)方法连接到服务器。当连接成功后,客户端会收到[open](#onopen)事件的回调,之后客户端就可以通过[send](#send)方法与服务器进行通信。当服务器发信息给客户端时,客户端会收到[message](#onmessage)事件的回调。当客户端不要此连接时,可以通过调用[close](#close)方法主动断开连接,之后客户端会收到[close](#onclose)事件的回调。 + +若在上述任一过程中发生错误,客户端会收到[error](#onerror)事件的回调。 + + +## 导入模块 + +``` +import webSocket from '@ohos.net.webSocket'; +``` + +## 完整示例 + +``` +import webSocket from '@ohos.net.webSocket'; + +var defaultIpAddress = "ws://"; +let ws = webSocket.createWebSocket(); +ws.on('open', (err, value) => { + console.log("on open, status:" + value.status + ", message:" + value.message); + // 当收到on('open')事件时,可以通过send()方法与服务器进行通信 + ws.send("Hello, server!", (err, value) => { + if (!err) { + console.log("send success"); + } else { + console.log("send fail, err:" + JSON.stringify(err)); + } + }); +}); +ws.on('message', (err, value) => { + console.log("on message, message:" + value); + // 当收到服务器的`bye`消息时(此消息字段仅为示意,具体字段需要与服务器协商),主动断开连接 + if (value === 'bye') { + ws.close((err, value) => { + if (!err) { + console.log("close success"); + } else { + console.log("close fail, err is " + JSON.stringify(err)); + } + }); + } +}); +ws.on('close', (err, value) => { + console.log("on close, code is " + value.code + ", reason is " + value.reason); +}); +ws.on('error', (err) => { + console.log("on error, error:" + JSON.stringify(err)); +}); +ws.connect(defaultIpAddress, (err, value) => { + if (!err) { + console.log("connect success"); + } else { + console.log("connect fail, err:" + JSON.stringify(err)); + } +}); +``` + +## webSocket.createWebSocket + +createWebSocket\(\): WebSocket + +创建一个WebSocket,里面包括建立连接、关闭连接、发送数据和订阅/取消订阅WebSocket连接的打开事件、接收到服务器消息事件、关闭事件和错误事件。 + +**返回值:** + +| 类型 | 说明 | +| :---------------------------------- | :----------------------------------------------------------- | +| [WebSocket](#websocket) | 返回一个WebSocket对象,里面包括connect、send、close、on和off方法。 | + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +``` + + +## WebSocket + +在调用WebSocket的方法前,需要先通过[webSocket.createWebSocket](#webSocketcreatewebsocket)创建一个WebSocket。 + +### connect + +connect\(url: string, callback: AsyncCallback\): void + +根据URL地址,建立一个WebSocket连接,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------ | ---- | ---------------------------- | +| url | string | 是 | 建立WebSocket连接的URL地址。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +let url = "ws://" +ws.connect(url, (err, value) => { + if (!err) { + console.log("connect success"); + } else { + console.log("connect fail, err:" + JSON.stringify(err)) + } +}); +``` + + +### connect + +connect\(url: string, options: WebSocketRequestOptions, callback: AsyncCallback\): void + +根据URL地址和header,建立一个WebSocket连接,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------ | ---- | ------------------------------------------------------- | +| url | string | 是 | 建立WebSocket连接的URL地址。 | +| options | WebSocketRequestOptions | 是 | 参考[WebSocketRequestOptions](#websocketrequestoptions)。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +let url = "ws://" +ws.connect(url, { + header: { + "key": "value", + "key2": "value2" + } +}, (err, value) => { + if (!err) { + console.log("connect success"); + } else { + console.log("connect fail, err:" + JSON.stringify(err)) + } +}); +``` + + +### connect + +connect\(url: string, options?: WebSocketRequestOptions\): Promise + +根据URL地址和header,建立一个WebSocket连接,使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ----------------------- | ---- | ------------------------------------------------------- | +| url | string | 是 | 建立WebSocket连接的URL地址。 | +| options | WebSocketRequestOptions | 否 | 参考[WebSocketRequestOptions](#websocketrequestoptions)。 | + +**返回值:** + +| 类型 | 说明 | +| :----------------- | :-------------------------------- | +| Promise\ | 以Promise形式返回建立连接的结果。 | + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +let url = "ws://" +let promise = ws.connect(url); +promise.then((value) => { + console.log("connect success") +}).catch((err) => { + console.log("connect fail, error:" + JSON.stringify(err)) +}); +``` + + +### send + +send\(data: string | ArrayBuffer, callback: AsyncCallback\): void + +通过WebSocket连接发送数据,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------ | ---- | ------------ | +| data | string \| ArrayBuffer 8+ | 是 | 发送的数据。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +let url = "ws://" +ws.connect(url, (err, value) => { + ws.send("Hello, server!", (err, value) => { + if (!err) { + console.log("send success"); + } else { + console.log("send fail, err:" + JSON.stringify(err)) + } + }); +}); +``` + + +### send + +send\(data: string | ArrayBuffer\): Promise + +通过WebSocket连接发送数据,使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------ | +| data | string \| ArrayBuffer 8+ | 是 | 发送的数据。 | + +**返回值:** + +| 类型 | 说明 | +| :----------------- | :-------------------------------- | +| Promise\ | 以Promise形式返回发送数据的结果。 | + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +let url = "ws://" +ws.connect(url, (err, value) => { + let promise = ws.send("Hello, server!"); + promise.then((value) => { + console.log("send success") + }).catch((err) => { + console.log("send fail, error:" + JSON.stringify(err)) + }); +}); +``` + + +### close + +close\(callback: AsyncCallback\): void + +关闭WebSocket连接,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------ | ---- | ---------- | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +let url = "ws://" +ws.close((err, value) => { + if (!err) { + console.log("close success") + } else { + console.log("close fail, err is " + JSON.stringify(err)) + } +}); +``` + + +### close + +close\(options: WebSocketCloseOptions, callback: AsyncCallback\): void + +根据可选参数code和reason,关闭WebSocket连接,使用callback方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------ | ---- | ----------------------------------------------------- | +| options | WebSocketCloseOptions | 是 | 参考[WebSocketCloseOptions](#websocketcloseoptions)。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +let url = "ws://" +ws.close({ + code: 1000, + reason: "your reason" +}, (err, value) => { + if (!err) { + console.log("close success") + } else { + console.log("close fail, err is " + JSON.stringify(err)) + } +}); +``` + + +### close + +close\(options?: WebSocketCloseOptions\): Promise + +根据可选参数code和reason,关闭WebSocket连接,使用Promise方式作为异步方法。 + +**需要权限**:ohos.permission.INTERNET + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | --------------------- | ---- | ----------------------------------------------------- | +| options | WebSocketCloseOptions | 否 | 参考[WebSocketCloseOptions](#websocketcloseoptions)。 | + +**返回值:** + +| 类型 | 说明 | +| :----------------- | :-------------------------------- | +| Promise\ | 以Promise形式返回关闭连接的结果。 | + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +let url = "ws://" +let promise = ws.close({ + code: 1000, + reason: "your reason" +}); +promise.then((value) => { + console.log("close success") +}).catch((err) => { + console.log("close fail, err is " + JSON.stringify(err)) +}); +``` + + +### on\('open'\) + +on\(type: 'open', callback: AsyncCallback\): void + +订阅WebSocket的打开事件,使用callback方式作为异步方法。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ----------------------------- | +| type | string | 是 | 'open':WebSocket的打开事件。 | +| callback | AsyncCallback\ | 是 | 回调函数。 | + + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +ws.on('open', (err, value) => { + console.log("on open, status:" + value.status + ", message:" + value.message); +}); +``` + + +### off\('open'\) + +off\(type: 'open', callback?: AsyncCallback\): void + +取消订阅WebSocket的打开事件,使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | ----------------------------- | +| type | string | 是 | 'open':WebSocket的打开事件。 | +| callback | AsyncCallback\ | 否 | 回调函数。 | + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +let callback1 = (err, value) => { + console.log("on open, status:" + value.status + ", message:" + value.message); +} +ws.on('open', callback1); +// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅 +ws.off('open', callback1); +``` + + +### on\('message'\) + +on\(type: 'message', callback: AsyncCallback\): void + +订阅WebSocket的接收到服务器消息事件,使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>AsyncCallback中的数据可以是字符串\(API 6\)或ArrayBuffer\(API 8\)。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------- | ---- | -------------------------------------------- | +| type | string | 是 | 'message':WebSocket的接收到服务器消息事件。 | +| callback | AsyncCallback\8+
\> | 是 | 回调函数。 | + + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +ws.on('message', (err, value) => { + console.log("on message, message:" + value); +}); +``` + + +### off\('message'\) + +off\(type: 'message', callback?: AsyncCallback\): void + +取消订阅WebSocket的接收到服务器消息事件,使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>AsyncCallback中的数据可以是字符串\(API 6\)或ArrayBuffer\(API 8\)。 +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------------------------------- | ---- | -------------------------------------------- | +| type | string | 是 | 'message':WebSocket的接收到服务器消息事件。 | +| callback | AsyncCallback\8+
\> | 否 | 回调函数。 | + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +ws.off('message'); +``` + + +### on\('close'\) + +on\(type: 'close', callback: AsyncCallback<\{ code: number, reason: string \}\>\): void + +订阅WebSocket的关闭事件,使用callback方式作为异步方法。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | ------------------------------ | +| type | string | 是 | 'close':WebSocket的关闭事件。 | +| callback | AsyncCallback<{ code: number, reason: string }> | 是 | 回调函数。 | + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +ws.on('close', (err, value) => { + console.log("on close, code is " + value.code + ", reason is " + value.reason); +}); +``` + + +### off\('close'\) + +off\(type: 'close', callback?: AsyncCallback<\{ code: number, reason: string \}\>\): void + +取消订阅WebSocket的关闭事件,使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------------------- | ---- | ------------------------------ | +| type | string | 是 | 'close':WebSocket的关闭事件。 | +| callback | AsyncCallback<{ code: number, reason: string }> | 否 | 回调函数。 | + + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +ws.off('close'); +``` + + +### on\('error'\) + +on\(type: 'error', callback: ErrorCallback\): void + +订阅WebSocket的Error事件,使用callback方式作为异步方法。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------- | ---- | ------------------------------- | +| type | string | 是 | 'error':WebSocket的Error事件。 | +| callback | ErrorCallback | 是 | 回调函数。 | + + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +ws.on('error', (err) => { + console.log("on error, error:" + JSON.stringify(err)) +}); +``` + + +### off\('error'\) + +off\(type: 'error', callback?: ErrorCallback\): void + +取消订阅WebSocket的Error事件,使用callback方式作为异步方法。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------- | ---- | ------------------------------- | +| type | string | 是 | 'error':WebSocket的Error事件。 | +| callback | ErrorCallback | 否 | 回调函数。 | + +**示例:** + +``` +let ws = webSocket.createWebSocket(); +ws.off('error'); +``` + + +## WebSocketRequestOptions + +建立WebSocket连接时,可选参数的类型和说明。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| header | Object | 否 | 建立WebSocket连接可选参数,代表建立连接时携带的HTTP头信息。参数内容自定义,也可以不指定。 | + + +## WebSocketCloseOptions + +关闭WebSocket连接时,可选参数的类型和说明。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------------------------------------------ | +| code | number | 否 | 错误码,关闭WebSocket连接时的可选参数,可根据实际情况来填。默认值为1000。 | +| reason | string | 否 | 原因值,关闭WebSocket连接时的可选参数,可根据实际情况来填。默认值为空字符串("")。 | + +## close错误码说明 + +发送给服务端的错误码可以自行定义,下面的列表仅供参考。 + +| 值 | 说明 | +| :-------- | :----------------- | +| 1000 | 正常关闭 | +| 1001 | 服务器主动关闭 | +| 1002 | 协议错误 | +| 1003 | 无法处理的数据类型 | +| 1004~1015 | 保留值 | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-webgl.md b/zh-cn/application-dev/reference/apis/js-apis-webgl.md index b199eb4b73277ac1137883c258ae8027d272f91d..e247718d3ebca84f5b2b40258487ad70d4c63315 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webgl.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webgl.md @@ -1,696 +1,586 @@ -# WebGL - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -WebGL标准图形API,对应OpenGL ES 2.0特性集。更多信息请参考[WebgGL™标准](https://www.khronos.org/registry/webgl/specs/latest/1.0/)。 - - - - -## 导入模块 - -``` -import webgl from 'ohos.webglnapi' -``` - - -## 系统能力 - -SystemCapability.Graphic.Graphic2D.WebGL - - -## 调用方式 - -``` -// 获取canvas组件实例 -const el = this.$refs.canvas -// 从canvas组件实例获取WebGL上下文 -const gl = el.getContext('webgl'); -// 调用WebGL API -gl.clearColor(0.0, 0.0, 0.0, 1.0); -gl.flush(); -``` - - -## GLenum - -| 名称 | 类型 | -| -------- | -------- | -| GLenum | number | - - -## GLboolean - -| 名称 | 类型 | -| -------- | -------- | -| GLboolean | boolean | - - -## GLbitfield - -| 名称 | 类型 | -| -------- | -------- | -| GLbitfield | number | - - -## GLbyte - -| 名称 | 类型 | -| -------- | -------- | -| GLbyte | number | - - -## GLshort - -| 名称 | 类型 | -| -------- | -------- | -| GLshort | number | - - -## GLint - -| 名称 | 类型 | -| -------- | -------- | -| GLint | number | - - -## GLsizei - -| 名称 | 类型 | -| -------- | -------- | -| GLsizei | number | - - -## GLintptr - -| 名称 | 类型 | -| -------- | -------- | -| GLintptr | number | - - -## GLsizeiptr - -| 名称 | 类型 | -| -------- | -------- | -| GLsizeiptr | number | - - -## GLubyte - -| 名称 | 类型 | -| -------- | -------- | -| GLubyte | number | - - -## GLushort - -| 名称 | 类型 | -| -------- | -------- | -| GLushort | number | - - -## GLuint - -| 名称 | 类型 | -| -------- | -------- | -| GLuint | number | - - -## GLfloat - -| 名称 | 类型 | -| -------- | -------- | -| GLfloat | number | - - -## GLclampf - -| 名称 | 类型 | -| -------- | -------- | -| GLclampf | number | - - -## TexImageSource - -| 名称 | 类型 | -| -------- | -------- | -| TexImageSource | ImageData | - - -## Float32List - -| 名称 | 类型 | -| -------- | -------- | -| Float32List | array | - - -## Int32List - -| 名称 | 类型 | -| -------- | -------- | -| Int32List | array | - - -## WebGLPowerPreference - -| 名称 | 类型 | -| -------- | -------- | -| WebGLPowerPreference | string | - - -## webgl.WebGLContextAttributes - -WebGLContextAttributes - - -| 名称 | 参数类型 | 必填 | -| -------- | -------- | -------- | -| alpha | boolean | 否 | -| depth | boolean | 否 | -| stencil | boolean | 否 | -| antialias | boolean | 否 | -| premultipliedAlpha | boolean | 否 | -| preserveDrawingBuffer | boolean | 否 | -| powerPreference | WebGLPowerPreference | 否 | -| failIfMajorPerformanceCaveat | boolean | 否 | -| desynchronized | boolean | 否 | - - -## webgl.WebGLBuffer - -WebGLBuffer - - -## webgl.WebGLFrameBuffer - -WebGLFrameBuffer - - -## webgl.WebGLProgram - -WebGLProgram - - -## webgl.WebGLRenderbuffer - -WebGLRenderbuffer - - -## webgl.WebGLShader - -WebGLShader - - -## webgl.WebGLTexture - -WebGLTexture - - -## webgl.WebGLUniformLocation - -WebGLUniformLocation - - -## webgl.WebGLActiveInfo - -WebGLActiveInfo - -| 名称 | 参数类型 | 必填 | -| -------- | -------- | -------- | -| size | [GLint](#glint) | 是 | -| type | [GLenum](#glenum) | 是 | -| name | string | 是 | - - -## webgl.WebGLShaderPrecisionFormat - -WebGLShaderPrecisionFormat - -| 名称 | 参数类型 | 必填 | -| -------- | -------- | -------- | -| rangeMin | [GLint](#glint) | 是 | -| rangeMax | [GLint](#glint) | 是 | -| precision | [GLint](#glint) | 是 | - - -## webgl.WebGLRenderingContextBase - -WebGLRenderingContextBase - - -### 属性 - -| 名称 | 参数类型 | 必填 | -| -------- | -------- | -------- | -| DEPTH_BUFFER_BIT | [GLenum](#glenum) | 是 | -| STENCIL_BUFFER_BIT | [GLenum](#glenum) | 是 | -| COLOR_BUFFER_BIT | [GLenum](#glenum) | 是 | -| POINTS | [GLenum](#glenum) | 是 | -| LINES | [GLenum](#glenum) | 是 | -| LINE_LOOP | [GLenum](#glenum) | 是 | -| LINE_STRIP | [GLenum](#glenum) | 是 | -| TRIANGLES | [GLenum](#glenum) | 是 | -| TRIANGLE_STRIP | [GLenum](#glenum) | 是 | -| TRIANGLE_FAN | [GLenum](#glenum) | 是 | -| ZERO | [GLenum](#glenum) | 是 | -| ONE | [GLenum](#glenum) | 是 | -| SRC_COLOR | [GLenum](#glenum) | 是 | -| ONE_MINUS_SRC_COLOR | [GLenum](#glenum) | 是 | -| SRC_ALPHA | [GLenum](#glenum) | 是 | -| ONE_MINUS_SRC_ALPHA | [GLenum](#glenum) | 是 | -| DST_ALPHA | [GLenum](#glenum) | 是 | -| ONE_MINUS_DST_ALPHA | [GLenum](#glenum) | 是 | -| DST_COLOR | [GLenum](#glenum) | 是 | -| ONE_MINUS_DST_COLOR | [GLenum](#glenum) | 是 | -| SRC_ALPHA_SATURATE | [GLenum](#glenum) | 是 | -| FUNC_ADD | [GLenum](#glenum) | 是 | -| BLEND_EQUATION | [GLenum](#glenum) | 是 | -| BLEND_EQUATION_RGB | [GLenum](#glenum) | 是 | -| BLEND_EQUATION_ALPHA | [GLenum](#glenum) | 是 | -| FUNC_SUBTRACT | [GLenum](#glenum) | 是 | -| FUNC_REVERSE_SUBTRACT | [GLenum](#glenum) | 是 | -| BLEND_DST_RGB | [GLenum](#glenum) | 是 | -| BLEND_SRC_RGB | [GLenum](#glenum) | 是 | -| BLEND_DST_ALPHA | [GLenum](#glenum) | 是 | -| BLEND_SRC_ALPHA | [GLenum](#glenum) | 是 | -| CONSTANT_COLOR | [GLenum](#glenum) | 是 | -| ONE_MINUS_CONSTANT_COLOR | [GLenum](#glenum) | 是 | -| CONSTANT_ALPHA | [GLenum](#glenum) | 是 | -| ONE_MINUS_CONSTANT_ALPHA | [GLenum](#glenum) | 是 | -| BLEND_COLOR | [GLenum](#glenum) | 是 | -| ARRAY_BUFFER | [GLenum](#glenum) | 是 | -| ELEMENT_ARRAY_BUFFER | [GLenum](#glenum) | 是 | -| ARRAY_BUFFER_BINDING | [GLenum](#glenum) | 是 | -| ELEMENT_ARRAY_BUFFER_BINDING | [GLenum](#glenum) | 是 | -| STREAM_DRAW | [GLenum](#glenum) | 是 | -| STATIC_DRAW | [GLenum](#glenum) | 是 | -| DYNAMIC_DRAW | [GLenum](#glenum) | 是 | -| BUFFER_SIZE | [GLenum](#glenum) | 是 | -| BUFFER_USAGE | [GLenum](#glenum) | 是 | -| CURRENT_VERTEX_ATTRIB | [GLenum](#glenum) | 是 | -| FRONT | [GLenum](#glenum) | 是 | -| BACK | [GLenum](#glenum) | 是 | -| FRONT_AND_BACK | [GLenum](#glenum) | 是 | -| CULL_FACE | [GLenum](#glenum) | 是 | -| BLEND | [GLenum](#glenum) | 是 | -| DITHER | [GLenum](#glenum) | 是 | -| STENCIL_TEST | [GLenum](#glenum) | 是 | -| DEPTH_TEST | [GLenum](#glenum) | 是 | -| SCISSOR_TEST | [GLenum](#glenum) | 是 | -| POLYGON_OFFSET_FILL | [GLenum](#glenum) | 是 | -| SAMPLE_ALPHA_TO_COVERAGE | [GLenum](#glenum) | 是 | -| SAMPLE_COVERAGE | [GLenum](#glenum) | 是 | -| NO_ERROR | [GLenum](#glenum) | 是 | -| INVALID_ENUM | [GLenum](#glenum) | 是 | -| INVALID_VALUE | [GLenum](#glenum) | 是 | -| INVALID_OPERATION | [GLenum](#glenum) | 是 | -| OUT_OF_MEMORY | [GLenum](#glenum) | 是 | -| CW | [GLenum](#glenum) | 是 | -| CCW | [GLenum](#glenum) | 是 | -| ALIASED_POINT_SIZE_RANGE | [GLenum](#glenum) | 是 | -| ALIASED_LINE_WIDTH_RANGE | [GLenum](#glenum) | 是 | -| CULL_FACE_MODE | [GLenum](#glenum) | 是 | -| FRONT_FACE | [GLenum](#glenum) | 是 | -| DEPTH_RANGE | [GLenum](#glenum) | 是 | -| DEPTH_WRITEMASK | [GLenum](#glenum) | 是 | -| DEPTH_CLEAR_VALUE | [GLenum](#glenum) | 是 | -| DEPTH_FUNC | [GLenum](#glenum) | 是 | -| STENCIL_CLEAR_VALUE | [GLenum](#glenum) | 是 | -| STENCIL_FUNC | [GLenum](#glenum) | 是 | -| STENCIL_FAIL | [GLenum](#glenum) | 是 | -| STENCIL_PASS_DEPTH_FAIL | [GLenum](#glenum) | 是 | -| STENCIL_PASS_DEPTH_PASS | [GLenum](#glenum) | 是 | -| STENCIL_REF | [GLenum](#glenum) | 是 | -| STENCIL_VALUE_MASK | [GLenum](#glenum) | 是 | -| STENCIL_WRITEMASK | [GLenum](#glenum) | 是 | -| STENCIL_BACK_FUNC | [GLenum](#glenum) | 是 | -| STENCIL_BACK_FAIL | [GLenum](#glenum) | 是 | -| STENCIL_BACK_PASS_DEPTH_FAIL | [GLenum](#glenum) | 是 | -| STENCIL_BACK_PASS_DEPTH_PASS | [GLenum](#glenum) | 是 | -| STENCIL_BACK_REF | [GLenum](#glenum) | 是 | -| STENCIL_BACK_VALUE_MASK | [GLenum](#glenum) | 是 | -| STENCIL_BACK_WRITEMASK | [GLenum](#glenum) | 是 | -| VIEWPORT | [GLenum](#glenum) | 是 | -| SCISSOR_BOX | [GLenum](#glenum) | 是 | -| COLOR_CLEAR_VALUE | [GLenum](#glenum) | 是 | -| COLOR_WRITEMASK | [GLenum](#glenum) | 是 | -| UNPACK_ALIGNMENT | [GLenum](#glenum) | 是 | -| PACK_ALIGNMENT | [GLenum](#glenum) | 是 | -| MAX_TEXTURE_SIZE | [GLenum](#glenum) | 是 | -| MAX_VIEWPORT_DIMS | [GLenum](#glenum) | 是 | -| SUBPIXEL_BITS | [GLenum](#glenum) | 是 | -| RED_BITS | [GLenum](#glenum) | 是 | -| GREEN_BITS | [GLenum](#glenum) | 是 | -| BLUE_BITS | [GLenum](#glenum) | 是 | -| ALPHA_BITS | [GLenum](#glenum) | 是 | -| DEPTH_BITS | [GLenum](#glenum) | 是 | -| STENCIL_BITS | [GLenum](#glenum) | 是 | -| POLYGON_OFFSET_UNITS | [GLenum](#glenum) | 是 | -| POLYGON_OFFSET_FACTOR | [GLenum](#glenum) | 是 | -| TEXTURE_BINDING_2D | [GLenum](#glenum) | 是 | -| SAMPLE_BUFFERS | [GLenum](#glenum) | 是 | -| SAMPLES | [GLenum](#glenum) | 是 | -| SAMPLE_COVERAGE_VALUE | [GLenum](#glenum) | 是 | -| SAMPLE_COVERAGE_INVERT | [GLenum](#glenum) | 是 | -| COMPRESSED_TEXTURE_FORMATS | [GLenum](#glenum) | 是 | -| DONT_CARE | [GLenum](#glenum) | 是 | -| FASTEST | [GLenum](#glenum) | 是 | -| NICEST | [GLenum](#glenum) | 是 | -| GENERATE_MIPMAP_HINT | [GLenum](#glenum) | 是 | -| BYTE | [GLenum](#glenum) | 是 | -| UNSIGNED_BYTE | [GLenum](#glenum) | 是 | -| SHORT | [GLenum](#glenum) | 是 | -| UNSIGNED_SHORT | [GLenum](#glenum) | 是 | -| INT | [GLenum](#glenum) | 是 | -| UNSIGNED_INT | [GLenum](#glenum) | 是 | -| FLOAT | [GLenum](#glenum) | 是 | -| DEPTH_COMPONENT | [GLenum](#glenum) | 是 | -| ALPHA | [GLenum](#glenum) | 是 | -| RGB | [GLenum](#glenum) | 是 | -| RGBA | [GLenum](#glenum) | 是 | -| LUMINANCE | [GLenum](#glenum) | 是 | -| LUMINANCE_ALPHA | [GLenum](#glenum) | 是 | -| UNSIGNED_SHORT_4_4_4_4 | [GLenum](#glenum) | 是 | -| UNSIGNED_SHORT_5_5_5_1 | [GLenum](#glenum) | 是 | -| UNSIGNED_SHORT_5_6_5 | [GLenum](#glenum) | 是 | -| FRAGMENT_SHADER | [GLenum](#glenum) | 是 | -| VERTEX_SHADER | [GLenum](#glenum) | 是 | -| MAX_VERTEX_ATTRIBS | [GLenum](#glenum) | 是 | -| MAX_VERTEX_UNIFORM_VECTORS | [GLenum](#glenum) | 是 | -| MAX_VARYING_VECTORS | [GLenum](#glenum) | 是 | -| MAX_COMBINED_TEXTURE_IMAGE_UNITS | [GLenum](#glenum) | 是 | -| MAX_VERTEX_TEXTURE_IMAGE_UNITS | [GLenum](#glenum) | 是 | -| MAX_TEXTURE_IMAGE_UNITS | [GLenum](#glenum) | 是 | -| MAX_FRAGMENT_UNIFORM_VECTORS | [GLenum](#glenum) | 是 | -| SHADER_TYPE | [GLenum](#glenum) | 是 | -| DELETE_STATUS | [GLenum](#glenum) | 是 | -| LINK_STATUS | [GLenum](#glenum) | 是 | -| VALIDATE_STATUS | [GLenum](#glenum) | 是 | -| ATTACHED_SHADERS | [GLenum](#glenum) | 是 | -| ACTIVE_UNIFORMS | [GLenum](#glenum) | 是 | -| ACTIVE_ATTRIBUTES | [GLenum](#glenum) | 是 | -| SHADING_LANGUAGE_VERSION | [GLenum](#glenum) | 是 | -| CURRENT_PROGRAM | [GLenum](#glenum) | 是 | -| NEVER | [GLenum](#glenum) | 是 | -| LESS | [GLenum](#glenum) | 是 | -| EQUAL | [GLenum](#glenum) | 是 | -| LEQUAL | [GLenum](#glenum) | 是 | -| GREATER | [GLenum](#glenum) | 是 | -| NOTEQUAL | [GLenum](#glenum) | 是 | -| GEQUAL | [GLenum](#glenum) | 是 | -| ALWAYS | [GLenum](#glenum) | 是 | -| KEEP | [GLenum](#glenum) | 是 | -| REPLACE | [GLenum](#glenum) | 是 | -| INCR | [GLenum](#glenum) | 是 | -| DECR | [GLenum](#glenum) | 是 | -| INVERT | [GLenum](#glenum) | 是 | -| INCR_WRAP | [GLenum](#glenum) | 是 | -| DECR_WRAP | [GLenum](#glenum) | 是 | -| VENDOR | [GLenum](#glenum) | 是 | -| RENDERER | [GLenum](#glenum) | 是 | -| VERSION | [GLenum](#glenum) | 是 | -| NEAREST | [GLenum](#glenum) | 是 | -| LINEAR | [GLenum](#glenum) | 是 | -| NEAREST_MIPMAP_NEAREST | [GLenum](#glenum) | 是 | -| LINEAR_MIPMAP_NEAREST | [GLenum](#glenum) | 是 | -| NEAREST_MIPMAP_LINEAR | [GLenum](#glenum) | 是 | -| LINEAR_MIPMAP_LINEAR | [GLenum](#glenum) | 是 | -| TEXTURE_MAG_FILTER | [GLenum](#glenum) | 是 | -| TEXTURE_MIN_FILTER | [GLenum](#glenum) | 是 | -| TEXTURE_WRAP_S | [GLenum](#glenum) | 是 | -| TEXTURE_WRAP_T | [GLenum](#glenum) | 是 | -| TEXTURE_2D | [GLenum](#glenum) | 是 | -| TEXTURE | [GLenum](#glenum) | 是 | -| TEXTURE_CUBE_MAP | [GLenum](#glenum) | 是 | -| TEXTURE_BINDING_CUBE_MAP | [GLenum](#glenum) | 是 | -| TEXTURE_CUBE_MAP_POSITIVE_X | [GLenum](#glenum) | 是 | -| TEXTURE_CUBE_MAP_NEGATIVE_X | [GLenum](#glenum) | 是 | -| TEXTURE_CUBE_MAP_POSITIVE_Y | [GLenum](#glenum) | 是 | -| TEXTURE_CUBE_MAP_NEGATIVE_Y | [GLenum](#glenum) | 是 | -| TEXTURE_CUBE_MAP_POSITIVE_Z | [GLenum](#glenum) | 是 | -| TEXTURE_CUBE_MAP_NEGATIVE_Z | [GLenum](#glenum) | 是 | -| TEXTURE0 | [GLenum](#glenum) | 是 | -| TEXTURE1 | [GLenum](#glenum) | 是 | -| TEXTURE2 | [GLenum](#glenum) | 是 | -| TEXTURE3 | [GLenum](#glenum) | 是 | -| TEXTURE4 | [GLenum](#glenum) | 是 | -| TEXTURE5 | [GLenum](#glenum) | 是 | -| TEXTURE6 | [GLenum](#glenum) | 是 | -| TEXTURE7 | [GLenum](#glenum) | 是 | -| TEXTURE8 | [GLenum](#glenum) | 是 | -| TEXTURE9 | [GLenum](#glenum) | 是 | -| TEXTURE10 | [GLenum](#glenum) | 是 | -| TEXTURE11 | [GLenum](#glenum) | 是 | -| TEXTURE12 | [GLenum](#glenum) | 是 | -| TEXTURE13 | [GLenum](#glenum) | 是 | -| TEXTURE14 | [GLenum](#glenum) | 是 | -| TEXTURE15 | [GLenum](#glenum) | 是 | -| TEXTURE16 | [GLenum](#glenum) | 是 | -| TEXTURE17 | [GLenum](#glenum) | 是 | -| TEXTURE18 | [GLenum](#glenum) | 是 | -| TEXTURE19 | [GLenum](#glenum) | 是 | -| TEXTURE20 | [GLenum](#glenum) | 是 | -| TEXTURE21 | [GLenum](#glenum) | 是 | -| TEXTURE22 | [GLenum](#glenum) | 是 | -| TEXTURE23 | [GLenum](#glenum) | 是 | -| TEXTURE24 | [GLenum](#glenum) | 是 | -| TEXTURE25 | [GLenum](#glenum) | 是 | -| TEXTURE26 | [GLenum](#glenum) | 是 | -| TEXTURE27 | [GLenum](#glenum) | 是 | -| TEXTURE28 | [GLenum](#glenum) | 是 | -| TEXTURE29 | [GLenum](#glenum) | 是 | -| TEXTURE30 | [GLenum](#glenum) | 是 | -| TEXTURE31 | [GLenum](#glenum) | 是 | -| ACTIVE_TEXTURE | [GLenum](#glenum) | 是 | -| REPEAT | [GLenum](#glenum) | 是 | -| CLAMP_TO_EDGE | [GLenum](#glenum) | 是 | -| MIRRORED_REPEAT | [GLenum](#glenum) | 是 | -| FLOAT_VEC2 | [GLenum](#glenum) | 是 | -| FLOAT_VEC3 | [GLenum](#glenum) | 是 | -| FLOAT_VEC4 | [GLenum](#glenum) | 是 | -| INT_VEC2 | [GLenum](#glenum) | 是 | -| INT_VEC3 | [GLenum](#glenum) | 是 | -| INT_VEC4 | [GLenum](#glenum) | 是 | -| BOOL | [GLenum](#glenum) | 是 | -| BOOL_VEC2 | [GLenum](#glenum) | 是 | -| BOOL_VEC3 | [GLenum](#glenum) | 是 | -| BOOL_VEC4 | [GLenum](#glenum) | 是 | -| FLOAT_MAT2 | [GLenum](#glenum) | 是 | -| FLOAT_MAT3 | [GLenum](#glenum) | 是 | -| FLOAT_MAT4 | [GLenum](#glenum) | 是 | -| SAMPLER_2D | [GLenum](#glenum) | 是 | -| SAMPLER_CUBE | [GLenum](#glenum) | 是 | -| VERTEX_ATTRIB_ARRAY_ENABLED | [GLenum](#glenum) | 是 | -| VERTEX_ATTRIB_ARRAY_SIZE | [GLenum](#glenum) | 是 | -| VERTEX_ATTRIB_ARRAY_STRIDE | [GLenum](#glenum) | 是 | -| VERTEX_ATTRIB_ARRAY_TYPE | [GLenum](#glenum) | 是 | -| VERTEX_ATTRIB_ARRAY_NORMALIZED | [GLenum](#glenum) | 是 | -| VERTEX_ATTRIB_ARRAY_POINTER | [GLenum](#glenum) | 是 | -| VERTEX_ATTRIB_ARRAY_BUFFER_BINDING | [GLenum](#glenum) | 是 | -| IMPLEMENTATION_COLOR_READ_TYPE | [GLenum](#glenum) | 是 | -| IMPLEMENTATION_COLOR_READ_FORMAT | [GLenum](#glenum) | 是 | -| COMPILE_STATUS | [GLenum](#glenum) | 是 | -| LOW_FLOAT | [GLenum](#glenum) | 是 | -| MEDIUM_FLOAT | [GLenum](#glenum) | 是 | -| HIGH_FLOAT | [GLenum](#glenum) | 是 | -| LOW_INT | [GLenum](#glenum) | 是 | -| MEDIUM_INT | [GLenum](#glenum) | 是 | -| HIGH_INT | [GLenum](#glenum) | 是 | -| FRAMEBUFFER | [GLenum](#glenum) | 是 | -| RENDERBUFFER | [GLenum](#glenum) | 是 | -| RGBA4 | [GLenum](#glenum) | 是 | -| RGB5_A1 | [GLenum](#glenum) | 是 | -| RGB565 | [GLenum](#glenum) | 是 | -| DEPTH_COMPONENT16 | [GLenum](#glenum) | 是 | -| STENCIL_INDEX8 | [GLenum](#glenum) | 是 | -| DEPTH_STENCIL | [GLenum](#glenum) | 是 | -| RENDERBUFFER_WIDTH | [GLenum](#glenum) | 是 | -| RENDERBUFFER_HEIGHT | [GLenum](#glenum) | 是 | -| RENDERBUFFER_INTERNAL_FORMAT | [GLenum](#glenum) | 是 | -| RENDERBUFFER_RED_SIZE | [GLenum](#glenum) | 是 | -| RENDERBUFFER_GREEN_SIZE | [GLenum](#glenum) | 是 | -| RENDERBUFFER_BLUE_SIZE | [GLenum](#glenum) | 是 | -| RENDERBUFFER_ALPHA_SIZE | [GLenum](#glenum) | 是 | -| RENDERBUFFER_DEPTH_SIZE | [GLenum](#glenum) | 是 | -| RENDERBUFFER_STENCIL_SIZE | [GLenum](#glenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE | [GLenum](#glenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_OBJECT_NAME | [GLenum](#glenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL | [GLenum](#glenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE | [GLenum](#glenum) | 是 | -| COLOR_ATTACHMENT0 | [GLenum](#glenum) | 是 | -| DEPTH_ATTACHMENT | [GLenum](#glenum) | 是 | -| STENCIL_ATTACHMENT | [GLenum](#glenum) | 是 | -| DEPTH_STENCIL_ATTACHMENT | [GLenum](#glenum) | 是 | -| NONE | [GLenum](#glenum) | 是 | -| FRAMEBUFFER_COMPLETE | [GLenum](#glenum) | 是 | -| FRAMEBUFFER_INCOMPLETE_ATTACHMENT | [GLenum](#glenum) | 是 | -| FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT | [GLenum](#glenum) | 是 | -| FRAMEBUFFER_INCOMPLETE_DIMENSIONS | [GLenum](#glenum) | 是 | -| FRAMEBUFFER_UNSUPPORTED | [GLenum](#glenum) | 是 | -| FRAMEBUFFER_BINDING | [GLenum](#glenum) | 是 | -| RENDERBUFFER_BINDING | [GLenum](#glenum) | 是 | -| MAX_RENDERBUFFER_SIZE | [GLenum](#glenum) | 是 | -| INVALID_FRAMEBUFFER_OPERATION | [GLenum](#glenum) | 是 | -| UNPACK_FLIP_Y_WEBGL | [GLenum](#glenum) | 是 | -| UNPACK_PREMULTIPLY_ALPHA_WEBGL | [GLenum](#glenum) | 是 | -| CONTEXT_LOST_WEBGL | [GLenum](#glenum) | 是 | -| UNPACK_COLORSPACE_CONVERSION_WEBGL | [GLenum](#glenum) | 是 | -| BROWSER_DEFAULT_WEBGL | [GLenum](#glenum) | 是 | -| canvas | HTMLCanvasElement \| OffscreenCanvas | 是 | -| drawingBufferWidth | [GLsizei](#glsizei) | 是 | -| drawingBufferHeight | [GLsizei](#glsizei) | 是 | - - -### 方法 - -| 方法 | 返回值类型 | -| -------- | -------- | -| getContextAttributes() | WebGLContextAttributes \| null | -| isContextLost() | boolean | -| getSupportedExtensions() | string[] \| null | -| getExtension(name: string) | any | -| activeTexture(texture: GLenum) | void | -| attachShader(program: WebGLProgram, shader: WebGLShader) | void | -| bindAttribLocation(program: WebGLProgram, index: GLuint, name: string) | void | -| bindBuffer(target: GLenum, buffer: WebGLBuffer \| null) | void | -| bindFramebuffer(target: GLenum, framebuffer: WebGLFramebuffer \| null) | void | -| bindRenderbuffer(target: GLenum, renderbuffer: WebGLRenderbuffer \| null) | void | -| bindTexture(target: GLenum, texture: WebGLTexture \| null) | void | -| blendColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) | void | -| blendEquation(mode: GLenum) | void | -| blendEquationSeparate(modeRGB: GLenum, modeAlpha: GLenum) | void | -| blendFunc(sfactor: GLenum, dfactor: GLenum) | void | -| blendFuncSeparate(srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum) | void | -| checkFramebufferStatus(target: GLenum) | GLenum | -| clear(mask: GLbitfield) | void | -| clearColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) | void | -| clearDepth(depth: GLclampf) | void | -| clearStencil(s: GLint) | void | -| colorMask(red: GLboolean, green: GLboolean, blue: GLboolean, alpha: GLboolean) | void | -| compileShader(shader: WebGLShader) | void | -| copyTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, x: GLint, y: GLint, width: GLsizei, height: GLsizei, border: GLint) | void | -| copyTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | -| createBuffer() | WebGLBuffer \| null | -| createFramebuffer() | WebGLFramebuffer \| null | -| createProgram() | WebGLProgram \| null | -| createRenderbuffer() | WebGLRenderbuffer \| null | -| createShader(type: GLenum) | WebGLShader \| null | -| createTexture() | WebGLTexture \| nullvoid | -| cullFace(mode: GLenum) | void | -| deleteBuffer(buffer: WebGLBuffer \| null) | void | -| deleteFramebuffer(framebuffer: WebGLFramebuffer \| null) | void | -| deleteProgram(program: WebGLProgram \| null) | void | -| deleteRenderbuffer(renderbuffer: WebGLRenderbuffer \| null) | void | -| deleteShader(shader: WebGLShader \| null) | void | -| deleteTexture(texture: WebGLTexture \| null) | void | -| depthFunc(func: GLenum) | void | -| depthMask(flag: GLboolean) | void | -| depthRange(zNear: GLclampf, zFar: GLclampf) | void | -| detachShader(program: WebGLProgram, shader: WebGLShader) | void | -| disable(cap: GLenum) | void | -| disableVertexAttribArray(index: GLuint) | void | -| drawArrays(mode: GLenum, first: GLint, count: GLsizei) | void | -| drawElements(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr) | void | -| enable(cap: GLenum) | void | -| enableVertexAttribArray(index: GLuint) | void | -| finish() | void | -| flush() | void | -| framebufferRenderbuffer(target: GLenum, attachment: GLenum, renderbuffertarget: GLenum, renderbuffer: WebGLRenderbuffer \| null) | void | -| framebufferTexture2D(target: GLenum, attachment: GLenum, textarget: GLenum, texture: WebGLTexture \| null, level: GLint) | void | -| frontFace(mode: GLenum) | void | -| generateMipmap(target: GLenum) | void | -| getActiveAttrib(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | -| getActiveUniform(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | -| getAttachedShaders(program: WebGLProgram) | WebGLShader[] \| null | -| getAttribLocation(program: WebGLProgram, name: string) | GLint | -| getBufferParameter(target: GLenum, pname: GLenum) | any | -| getParameter(pname: GLenum) | any | -| getError() | GLenum | -| getFramebufferAttachmentParameter(target: GLenum, attachment: GLenum, pname: GLenum) | any | -| getProgramParameter(program: WebGLProgram, pname: GLenum) | any | -| getProgramInfoLog(program: WebGLProgram) | string \| null | -| getRenderbufferParameter(target: GLenum, pname: GLenum) | any | -| getShaderParameter(shader: WebGLShader, pname: GLenum) | any | -| getShaderPrecisionFormat(shadertype: GLenum, precisiontype: GLenum) | WebGLShaderPrecisionFormat \| null | -| getShaderInfoLog(shader: WebGLShader) | string \| null | -| getShaderSource(shader: WebGLShader) | string \| null | -| getTexParameter(target: GLenum, pname: GLenum) | any | -| getUniform(program: WebGLProgram, location: WebGLUniformLocation) | any | -| getUniformLocation(program: WebGLProgram, name: string) | WebGLUniformLocation \| null | -| getVertexAttrib(index: GLuint, pname: GLenum) | any | -| getVertexAttribOffset(index: GLuint, pname: GLenum) | GLintptr | -| hint(target: GLenum, mode: GLenum) | void | -| isBuffer(buffer: WebGLBuffer \| null) | GLboolean | -| isEnabled(cap: GLenum) | GLboolean | -| isFramebuffer(framebuffer: WebGLFramebuffer \| null) | GLboolean | -| isProgram(program: WebGLProgram \| null) | GLboolean | -| isRenderbuffer(renderbuffer: WebGLRenderbuffer \| null) | GLboolean | -| isShader(shader: WebGLShader \| null) | GLboolean | -| isTexture(texture: WebGLTexture \| null) | GLboolean | -| lineWidth(width: GLfloat) | void | -| linkProgram(program: WebGLProgram) | void | -| pixelStorei(pname: GLenum, param: GLint \| GLboolean) | void | -| polygonOffset(factor: GLfloat, units: GLfloat) | void | -| renderbufferStorage(target: GLenum, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | -| sampleCoverage(value: GLclampf, invert: GLboolean) | void | -| scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | -| shaderSource(shader: WebGLShader, source: string) | void | -| stencilFunc(func: GLenum, ref: GLint, mask: GLuint) | void | -| stencilFuncSeparate(face: GLenum, func: GLenum, ref: GLint, mask: GLuint) | void | -| stencilMask(mask: GLuint) | void | -| stencilMaskSeparate(face: GLenum, mask: GLuint) | void | -| stencilOp(fail: GLenum, zfail: GLenum, zpass: GLenum) | void | -| stencilOpSeparate(face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum) | void | -| texParameterf(target: GLenum, pname: GLenum, param: GLfloat) | void | -| texParameteri(target: GLenum, pname: GLenum, param: GLint) | void | -| uniform1f(location: WebGLUniformLocation \| null, x: GLfloat) | void | -| uniform2f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat) | void | -| uniform3f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat) | void | -| uniform4f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) | void | -| uniform1i(location: WebGLUniformLocation \| null, x: GLint) | void | -| uniform2i(location: WebGLUniformLocation \| null, x: GLint, y: GLint) | void | -| uniform3i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint) | void | -| uniform4i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint, w: GLint) | void | -| useProgram(program: WebGLProgram \| null) | void | -| validateProgram(program: WebGLProgram) | void | -| vertexAttrib1f(index: GLuint, x: GLfloat) | void | -| vertexAttrib2f(index: GLuint, x: GLfloat, y: GLfloat) | void | -| vertexAttrib3f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat) | void | -| vertexAttrib4f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) | void | -| vertexAttrib1fv(index: GLuint, values: Float32List) | void | -| vertexAttrib2fv(index: GLuint, values: Float32List) | void | -| vertexAttrib3fv(index: GLuint, values: Float32List) | void | -| vertexAttrib4fv(index: GLuint, values: Float32List) | void | -| vertexAttribPointer(index: GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLintptr) | void | -| viewport(x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | - - -## webgl.WebGLRenderingContextOverloads - -WebGLRenderingContextOverloads - -| 方法 | 返回值类型 | -| -------- | -------- | -| bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum) | void | -| bufferData(target: GLenum, data: BufferSource \| null, usage: GLenum) | void | -| bufferSubData(target: GLenum, offset: GLintptr, data: BufferSource) | void | -| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: ArrayBufferView) | void | -| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: ArrayBufferView) | void | -| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | -| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | -| texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | -| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | -| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | -| uniform1fv(location: WebGLUniformLocation \| null, v: Float32List) | void | -| uniform2fv(location: WebGLUniformLocation \| null, v: Float32List) | void | -| uniform3fv(location: WebGLUniformLocation \| null, v: Float32List) | void | -| uniform4fv(location: WebGLUniformLocation \| null, v: Float32List) | void | -| uniform1iv(location: WebGLUniformLocation \| null, v: Int32List) | void | -| uniform2iv(location: WebGLUniformLocation \| null, v: Int32List) | void | -| uniform3iv(location: WebGLUniformLocation \| null, v: Int32List) | void | -| uniform4iv(location: WebGLUniformLocation \| null, v: Int32List) | void | -| uniformMatrix2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | -| uniformMatrix3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | -| uniformMatrix4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | +# webgl + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +WebGL标准图形API,对应OpenGL ES 2.0特性集。更多信息请参考[WebGL™标准](https://www.khronos.org/registry/webgl/specs/latest/1.0/)。 + + +## 导入模块 + +``` +import webgl from '@ohos.webglnapi' +``` + + +## 调用方式 + +hml内创建canvas,示例如下: + + +``` +
+ + +
+``` + +js内获取canvas实例,示例如下: + + +``` +// 获取canvas组件实例 +const el = this.$refs.canvas1; +// 从canvas组件实例获取WebGL上下文 +const gl = el.getContext('webgl'); +// 调用WebGL API +gl.clearColor(0.0, 0.0, 0.0, 1.0); +``` + + +## Type + + **表1** Type + +| 名称 | 类型 | 说明 | +| -------- | -------- | -------- | +| GLenum | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLboolean | boolean | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLbitfield | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLbyte | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLshort | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLint | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLsizei | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLintptr | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLsizeiptr | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLubyte | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLushort | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLuint | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLfloat | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| GLclampf | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| TexImageSource | ImageData | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| Float32List | array | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| Int32List | array | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLPowerPreference | string | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | + + +## Interface + + **表2** Interface + +| 名称 | 说明 | +| -------- | -------- | +| [WebGLContextAttributes](#webglcontextattributes) | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLBuffer | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLFrameBuffer | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLProgram | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLRenderbuffer | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLShader | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLTexture | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| WebGLUniformLocation | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| [WebGLActiveInfo](#webglactiveinfo) | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| [WebGLShaderPrecisionFormat](#webglshaderprecisionformat) | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| [WebGLRenderingContextBase](#webglrenderingcontextbase) | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | +| [WebGLRenderingContextOverloads](#webglrenderingcontextoverloads) | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL | + + +## WebGLContextAttributes + +WebGLContextAttributes + + + | 名称 | 参数类型 | 必填 | +| -------- | -------- | -------- | +| alpha | boolean | 否 | +| depth | boolean | 否 | +| stencil | boolean | 否 | +| antialias | boolean | 否 | +| premultipliedAlpha | boolean | 否 | +| preserveDrawingBuffer | boolean | 否 | +| powerPreference | WebGLPowerPreference | 否 | +| failIfMajorPerformanceCaveat | boolean | 否 | +| desynchronized | boolean | 否 | + + +## WebGLActiveInfo + +WebGLActiveInfo + + | 名称 | 参数类型 | 必填 | +| -------- | -------- | -------- | +| size | GLint | 是 | +| type | GLenum | 是 | +| name | string | 是 | + + +## WebGLShaderPrecisionFormat + +WebGLShaderPrecisionFormat + + | 名称 | 参数类型 | 必填 | +| -------- | -------- | -------- | +| rangeMin | GLint | 是 | +| rangeMax | GLint | 是 | +| precision | GLint | 是 | + + +## WebGLRenderingContextBase + +WebGLRenderingContextBase + + +### 属性 + + | 名称 | 参数类型 | 必填 | +| -------- | -------- | -------- | +| DEPTH_BUFFER_BIT | GLenum | 是 | +| STENCIL_BUFFER_BIT | GLenum | 是 | +| COLOR_BUFFER_BIT | GLenum | 是 | +| POINTS | GLenum | 是 | +| LINES | GLenum | 是 | +| LINE_LOOP | GLenum | 是 | +| LINE_STRIP | GLenum | 是 | +| TRIANGLES | GLenum | 是 | +| TRIANGLE_STRIP | GLenum | 是 | +| TRIANGLE_FAN | GLenum | 是 | +| ZERO | GLenum | 是 | +| ONE | GLenum | 是 | +| SRC_COLOR | GLenum | 是 | +| ONE_MINUS_SRC_COLOR | GLenum | 是 | +| SRC_ALPHA | GLenum | 是 | +| ONE_MINUS_SRC_ALPHA | GLenum | 是 | +| DST_ALPHA | GLenum | 是 | +| ONE_MINUS_DST_ALPHA | GLenum | 是 | +| DST_COLOR | GLenum | 是 | +| ONE_MINUS_DST_COLOR | GLenum | 是 | +| SRC_ALPHA_SATURATE | GLenum | 是 | +| FUNC_ADD | GLenum | 是 | +| BLEND_EQUATION | GLenum | 是 | +| BLEND_EQUATION_RGB | GLenum | 是 | +| BLEND_EQUATION_ALPHA | GLenum | 是 | +| FUNC_SUBTRACT | GLenum | 是 | +| FUNC_REVERSE_SUBTRACT | GLenum | 是 | +| BLEND_DST_RGB | GLenum | 是 | +| BLEND_SRC_RGB | GLenum | 是 | +| BLEND_DST_ALPHA | GLenum | 是 | +| BLEND_SRC_ALPHA | GLenum | 是 | +| CONSTANT_COLOR | GLenum | 是 | +| ONE_MINUS_CONSTANT_COLOR | GLenum | 是 | +| CONSTANT_ALPHA | GLenum | 是 | +| ONE_MINUS_CONSTANT_ALPHA | GLenum | 是 | +| BLEND_COLOR | GLenum | 是 | +| ARRAY_BUFFER | GLenum | 是 | +| ELEMENT_ARRAY_BUFFER | GLenum | 是 | +| ARRAY_BUFFER_BINDING | GLenum | 是 | +| ELEMENT_ARRAY_BUFFER_BINDING | GLenum | 是 | +| STREAM_DRAW | GLenum | 是 | +| STATIC_DRAW | GLenum | 是 | +| DYNAMIC_DRAW | GLenum | 是 | +| BUFFER_SIZE | GLenum | 是 | +| BUFFER_USAGE | GLenum | 是 | +| CURRENT_VERTEX_ATTRIB | GLenum | 是 | +| FRONT | GLenum | 是 | +| BACK | GLenum | 是 | +| FRONT_AND_BACK | GLenum | 是 | +| CULL_FACE | GLenum | 是 | +| BLEND | GLenum | 是 | +| DITHER | GLenum | 是 | +| STENCIL_TEST | GLenum | 是 | +| DEPTH_TEST | GLenum | 是 | +| SCISSOR_TEST | GLenum | 是 | +| POLYGON_OFFSET_FILL | GLenum | 是 | +| SAMPLE_ALPHA_TO_COVERAGE | GLenum | 是 | +| SAMPLE_COVERAGE | GLenum | 是 | +| NO_ERROR | GLenum | 是 | +| INVALID_ENUM | GLenum | 是 | +| INVALID_VALUE | GLenum | 是 | +| INVALID_OPERATION | GLenum | 是 | +| OUT_OF_MEMORY | GLenum | 是 | +| CW | GLenum | 是 | +| CCW | GLenum | 是 | +| LINE_WIDTH | GLenum | 是 | +| ALIASED_POINT_SIZE_RANGE | GLenum | 是 | +| ALIASED_LINE_WIDTH_RANGE | GLenum | 是 | +| CULL_FACE_MODE | GLenum | 是 | +| FRONT_FACE | GLenum | 是 | +| DEPTH_RANGE | GLenum | 是 | +| DEPTH_WRITEMASK | GLenum | 是 | +| DEPTH_CLEAR_VALUE | GLenum | 是 | +| DEPTH_FUNC | GLenum | 是 | +| STENCIL_CLEAR_VALUE | GLenum | 是 | +| STENCIL_FUNC | GLenum | 是 | +| STENCIL_FAIL | GLenum | 是 | +| STENCIL_PASS_DEPTH_FAIL | GLenum | 是 | +| STENCIL_PASS_DEPTH_PASS | GLenum | 是 | +| STENCIL_REF | GLenum | 是 | +| STENCIL_VALUE_MASK | GLenum | 是 | +| STENCIL_WRITEMASK | GLenum | 是 | +| STENCIL_BACK_FUNC | GLenum | 是 | +| STENCIL_BACK_FAIL | GLenum | 是 | +| STENCIL_BACK_PASS_DEPTH_FAIL | GLenum | 是 | +| STENCIL_BACK_PASS_DEPTH_PASS | GLenum | 是 | +| STENCIL_BACK_REF | GLenum | 是 | +| STENCIL_BACK_VALUE_MASK | GLenum | 是 | +| STENCIL_BACK_WRITEMASK | GLenum | 是 | +| VIEWPORT | GLenum | 是 | +| SCISSOR_BOX | GLenum | 是 | +| COLOR_CLEAR_VALUE | GLenum | 是 | +| COLOR_WRITEMASK | GLenum | 是 | +| UNPACK_ALIGNMENT | GLenum | 是 | +| PACK_ALIGNMENT | GLenum | 是 | +| MAX_TEXTURE_SIZE | GLenum | 是 | +| MAX_VIEWPORT_DIMS | GLenum | 是 | +| SUBPIXEL_BITS | GLenum | 是 | +| RED_BITS | GLenum | 是 | +| GREEN_BITS | GLenum | 是 | +| BLUE_BITS | GLenum | 是 | +| ALPHA_BITS | GLenum | 是 | +| DEPTH_BITS | GLenum | 是 | +| STENCIL_BITS | GLenum | 是 | +| POLYGON_OFFSET_UNITS | GLenum | 是 | +| POLYGON_OFFSET_FACTOR | GLenum | 是 | +| TEXTURE_BINDING_2D | GLenum | 是 | +| SAMPLE_BUFFERS | GLenum | 是 | +| SAMPLES | GLenum | 是 | +| SAMPLE_COVERAGE_VALUE | GLenum | 是 | +| SAMPLE_COVERAGE_INVERT | GLenum | 是 | +| COMPRESSED_TEXTURE_FORMATS | GLenum | 是 | +| DONT_CARE | GLenum | 是 | +| FASTEST | GLenum | 是 | +| NICEST | GLenum | 是 | +| GENERATE_MIPMAP_HINT | GLenum | 是 | +| BYTE | GLenum | 是 | +| UNSIGNED_BYTE | GLenum | 是 | +| SHORT | GLenum | 是 | +| UNSIGNED_SHORT | GLenum | 是 | +| INT | GLenum | 是 | +| UNSIGNED_INT | GLenum | 是 | +| FLOAT | GLenum | 是 | +| DEPTH_COMPONENT | GLenum | 是 | +| ALPHA | GLenum | 是 | +| RGB | GLenum | 是 | +| RGBA | GLenum | 是 | +| LUMINANCE | GLenum | 是 | +| LUMINANCE_ALPHA | GLenum | 是 | +| UNSIGNED_SHORT_4_4_4_4 | GLenum | 是 | +| UNSIGNED_SHORT_5_5_5_1 | GLenum | 是 | +| UNSIGNED_SHORT_5_6_5 | GLenum | 是 | +| FRAGMENT_SHADER | GLenum | 是 | +| VERTEX_SHADER | GLenum | 是 | +| MAX_VERTEX_ATTRIBS | GLenum | 是 | +| MAX_VERTEX_UNIFORM_VECTORS | GLenum | 是 | +| MAX_VARYING_VECTORS | GLenum | 是 | +| MAX_COMBINED_TEXTURE_IMAGE_UNITS | GLenum | 是 | +| MAX_VERTEX_TEXTURE_IMAGE_UNITS | GLenum | 是 | +| MAX_TEXTURE_IMAGE_UNITS | GLenum | 是 | +| MAX_FRAGMENT_UNIFORM_VECTORS | GLenum | 是 | +| SHADER_TYPE | GLenum | 是 | +| DELETE_STATUS | GLenum | 是 | +| LINK_STATUS | GLenum | 是 | +| VALIDATE_STATUS | GLenum | 是 | +| ATTACHED_SHADERS | GLenum | 是 | +| ACTIVE_UNIFORMS | GLenum | 是 | +| ACTIVE_ATTRIBUTES | GLenum | 是 | +| SHADING_LANGUAGE_VERSION | GLenum | 是 | +| CURRENT_PROGRAM | GLenum | 是 | +| NEVER | GLenum | 是 | +| LESS | GLenum | 是 | +| EQUAL | GLenum | 是 | +| LEQUAL | GLenum | 是 | +| GREATER | GLenum | 是 | +| NOTEQUAL | GLenum | 是 | +| GEQUAL | GLenum | 是 | +| ALWAYS | GLenum | 是 | +| KEEP | GLenum | 是 | +| REPLACE | GLenum | 是 | +| INCR | GLenum | 是 | +| DECR | GLenum | 是 | +| INVERT | GLenum | 是 | +| INCR_WRAP | GLenum | 是 | +| DECR_WRAP | GLenum | 是 | +| VENDOR | GLenum | 是 | +| RENDERER | GLenum | 是 | +| VERSION | GLenum | 是 | +| NEAREST | GLenum | 是 | +| LINEAR | GLenum | 是 | +| NEAREST_MIPMAP_NEAREST | GLenum | 是 | +| LINEAR_MIPMAP_NEAREST | GLenum | 是 | +| NEAREST_MIPMAP_LINEAR | GLenum | 是 | +| LINEAR_MIPMAP_LINEAR | GLenum | 是 | +| TEXTURE_MIN_FILTER | GLenum | 是 | +| TEXTURE_WRAP_S | GLenum | 是 | +| TEXTURE_WRAP_T | GLenum | 是 | +| TEXTURE_2D | GLenum | 是 | +| TEXTURE | GLenum | 是 | +| TEXTURE_CUBE_MAP | GLenum | 是 | +| TEXTURE_BINDING_CUBE_MAP | GLenum | 是 | +| TEXTURE_CUBE_MAP_POSITIVE_X | GLenum | 是 | +| TEXTURE_CUBE_MAP_NEGATIVE_X | GLenum | 是 | +| TEXTURE_CUBE_MAP_POSITIVE_Y | GLenum | 是 | +| TEXTURE_CUBE_MAP_NEGATIVE_Y | GLenum | 是 | +| TEXTURE_CUBE_MAP_POSITIVE_Z | GLenum | 是 | +| TEXTURE_CUBE_MAP_NEGATIVE_Z | GLenum | 是 | +| MAX_CUBE_MAP_TEXTURE_SIZE | GLenum | 是 | +| TEXTURE0 | GLenum | 是 | +| TEXTURE1 | GLenum | 是 | +| TEXTURE2 | GLenum | 是 | +| TEXTURE3 | GLenum | 是 | +| TEXTURE4 | GLenum | 是 | +| TEXTURE5 | GLenum | 是 | +| TEXTURE6 | GLenum | 是 | +| TEXTURE7 | GLenum | 是 | +| TEXTURE8 | GLenum | 是 | +| TEXTURE9 | GLenum | 是 | +| TEXTURE10 | GLenum | 是 | +| TEXTURE11 | GLenum | 是 | +| TEXTURE12 | GLenum | 是 | +| TEXTURE13 | GLenum | 是 | +| TEXTURE14 | GLenum | 是 | +| TEXTURE15 | GLenum | 是 | +| TEXTURE16 | GLenum | 是 | +| TEXTURE17 | GLenum | 是 | +| TEXTURE18 | GLenum | 是 | +| TEXTURE19 | GLenum | 是 | +| TEXTURE20 | GLenum | 是 | +| TEXTURE21 | GLenum | 是 | +| TEXTURE22 | GLenum | 是 | +| TEXTURE23 | GLenum | 是 | +| TEXTURE24 | GLenum | 是 | +| TEXTURE25 | GLenum | 是 | +| TEXTURE26 | GLenum | 是 | +| TEXTURE27 | GLenum | 是 | +| TEXTURE28 | GLenum | 是 | +| TEXTURE29 | GLenum | 是 | +| TEXTURE30 | GLenum | 是 | +| TEXTURE31 | GLenum | 是 | +| ACTIVE_TEXTURE | GLenum | 是 | +| REPEAT | GLenum | 是 | +| CLAMP_TO_EDGE | GLenum | 是 | +| MIRRORED_REPEAT | GLenum | 是 | +| FLOAT_VEC2 | GLenum | 是 | +| FLOAT_VEC3 | GLenum | 是 | +| FLOAT_VEC4 | GLenum | 是 | +| INT_VEC2 | GLenum | 是 | +| INT_VEC3 | GLenum | 是 | +| INT_VEC4 | GLenum | 是 | +| BOOL | GLenum | 是 | +| BOOL_VEC2 | GLenum | 是 | +| BOOL_VEC3 | GLenum | 是 | +| BOOL_VEC4 | GLenum | 是 | +| FLOAT_MAT2 | GLenum | 是 | +| FLOAT_MAT3 | GLenum | 是 | +| FLOAT_MAT4 | GLenum | 是 | +| SAMPLER_2D | GLenum | 是 | +| SAMPLER_CUBE | GLenum | 是 | +| VERTEX_ATTRIB_ARRAY_ENABLED | GLenum | 是 | +| VERTEX_ATTRIB_ARRAY_SIZE | GLenum | 是 | +| VERTEX_ATTRIB_ARRAY_STRIDE | GLenum | 是 | +| VERTEX_ATTRIB_ARRAY_TYPE | GLenum | 是 | +| VERTEX_ATTRIB_ARRAY_NORMALIZED | GLenum | 是 | +| VERTEX_ATTRIB_ARRAY_POINTER | GLenum | 是 | +| VERTEX_ATTRIB_ARRAY_BUFFER_BINDING | GLenum | 是 | +| IMPLEMENTATION_COLOR_READ_TYPE | GLenum | 是 | +| IMPLEMENTATION_COLOR_READ_FORMAT | GLenum | 是 | +| COMPILE_STATUS | GLenum | 是 | +| LOW_FLOAT | GLenum | 是 | +| MEDIUM_FLOAT | GLenum | 是 | +| HIGH_FLOAT | GLenum | 是 | +| LOW_INT | GLenum | 是 | +| MEDIUM_INT | GLenum | 是 | +| HIGH_INT | GLenum | 是 | +| FRAMEBUFFER | GLenum | 是 | +| RENDERBUFFER | GLenum | 是 | +| RGBA4 | GLenum | 是 | +| RGB5_A1 | GLenum | 是 | +| RGB565 | GLenum | 是 | +| DEPTH_COMPONENT16 | GLenum | 是 | +| STENCIL_INDEX8 | GLenum | 是 | +| DEPTH_STENCIL | GLenum | 是 | +| RENDERBUFFER_WIDTH | GLenum | 是 | +| RENDERBUFFER_HEIGHT | GLenum | 是 | +| RENDERBUFFER_INTERNAL_FORMAT | GLenum | 是 | +| RENDERBUFFER_RED_SIZE | GLenum | 是 | +| RENDERBUFFER_GREEN_SIZE | GLenum | 是 | +| RENDERBUFFER_BLUE_SIZE | GLenum | 是 | +| RENDERBUFFER_ALPHA_SIZE | GLenum | 是 | +| RENDERBUFFER_DEPTH_SIZE | GLenum | 是 | +| RENDERBUFFER_STENCIL_SIZE | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE | GLenum | 是 | +| COLOR_ATTACHMENT0 | GLenum | 是 | +| DEPTH_ATTACHMENT | GLenum | 是 | +| STENCIL_ATTACHMENT | GLenum | 是 | +| DEPTH_STENCIL_ATTACHMENT | GLenum | 是 | +| NONE | GLenum | 是 | +| FRAMEBUFFER_COMPLETE | GLenum | 是 | +| FRAMEBUFFER_INCOMPLETE_ATTACHMENT | GLenum | 是 | +| FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT | GLenum | 是 | +| FRAMEBUFFER_INCOMPLETE_DIMENSIONS | GLenum | 是 | +| FRAMEBUFFER_UNSUPPORTED | GLenum | 是 | +| FRAMEBUFFER_BINDING | GLenum | 是 | +| RENDERBUFFER_BINDING | GLenum | 是 | +| MAX_RENDERBUFFER_SIZE | GLenum | 是 | +| INVALID_FRAMEBUFFER_OPERATION | GLenum | 是 | +| UNPACK_FLIP_Y_WEBGL | GLenum | 是 | +| UNPACK_PREMULTIPLY_ALPHA_WEBGL | GLenum | 是 | +| CONTEXT_LOST_WEBGL | GLenum | 是 | +| UNPACK_COLORSPACE_CONVERSION_WEBGL | GLenum | 是 | +| BROWSER_DEFAULT_WEBGL | GLenum | 是 | +| canvas | HTMLCanvasElement \| OffscreenCanvas | 是 | +| drawingBufferWidth | GLsizei | 是 | +| drawingBufferHeight | GLsizei | 是 | + + +### 方法 + + | 方法 | 返回值类型 | +| -------- | -------- | +| getContextAttributes() | WebGLContextAttributes \| null | +| isContextLost() | boolean | +| getSupportedExtensions() | string[] \| null | +| getExtension(name: string) | any | +| activeTexture(texture: GLenum) | void | +| attachShader(program: WebGLProgram, shader: WebGLShader) | void | +| bindAttribLocation(program: WebGLProgram, index: GLuint, name: string) | void | +| bindBuffer(target: GLenum, buffer: WebGLBuffer \| null) | void | +| bindFramebuffer(target: GLenum, framebuffer: WebGLFramebuffer \| null) | void | +| bindRenderbuffer(target: GLenum, renderbuffer: WebGLRenderbuffer \| null) | void | +| bindTexture(target: GLenum, texture: WebGLTexture \| null) | void | +| blendColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) | void | +| blendEquation(mode: GLenum) | void | +| blendEquationSeparate(modeRGB: GLenum, modeAlpha: GLenum) | void | +| blendFunc(sfactor: GLenum, dfactor: GLenum) | void | +| blendFuncSeparate(srcRGB: GLenum, dstRGB: GLenum, srcAlpha: GLenum, dstAlpha: GLenum) | void | +| checkFramebufferStatus(target: GLenum) | GLenum | +| clear(mask: GLbitfield) | void | +| clearColor(red: GLclampf, green: GLclampf, blue: GLclampf, alpha: GLclampf) | void | +| clearDepth(depth: GLclampf) | void | +| clearStencil(s: GLint) | void | +| colorMask(red: GLboolean, green: GLboolean, blue: GLboolean, alpha: GLboolean) | void | +| compileShader(shader: WebGLShader) | void | +| copyTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, x: GLint, y: GLint, width: GLsizei, height: GLsizei, border: GLint) | void | +| copyTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | +| createBuffer() | WebGLBuffer \| null | +| createFramebuffer() | WebGLFramebuffer \| null | +| createProgram() | WebGLProgram \| null | +| createRenderbuffer() | WebGLRenderbuffer \| null | +| createShader(type: GLenum) | WebGLShader \| null | +| createTexture() | WebGLTexture \| null | +| cullFace(mode: GLenum) | void | +| deleteBuffer(buffer: WebGLBuffer \| null) | void | +| deleteFramebuffer(framebuffer: WebGLFramebuffer \| null) | void | +| deleteProgram(program: WebGLProgram \| null) | void | +| deleteRenderbuffer(renderbuffer: WebGLRenderbuffer \| null) | void | +| deleteShader(shader: WebGLShader \| null) | void | +| deleteTexture(texture: WebGLTexture \| null) | void | +| depthFunc(func: GLenum) | void | +| depthMask(flag: GLboolean) | void | +| depthRange(zNear: GLclampf, zFar: GLclampf) | void | +| detachShader(program: WebGLProgram, shader: WebGLShader) | void | +| disable(cap: GLenum) | void | +| disableVertexAttribArray(index: GLuint) | void | +| drawArrays(mode: GLenum, first: GLint, count: GLsizei) | void | +| drawElements(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr) | void | +| enable(cap: GLenum) | void | +| enableVertexAttribArray(index: GLuint) | void | +| finish() | void | +| flush() | void | +| framebufferRenderbuffer(target: GLenum, attachment: GLenum, renderbuffertarget: GLenum, renderbuffer: WebGLRenderbuffer \| null) | void | +| framebufferTexture2D(target: GLenum, attachment: GLenum, textarget: GLenum, texture: WebGLTexture \| null, level: GLint) | void | +| frontFace(mode: GLenum) | void | +| generateMipmap(target: GLenum) | void | +| getActiveAttrib(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | +| getActiveUniform(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | +| getAttachedShaders(program: WebGLProgram) | WebGLShader[] \| null | +| getAttribLocation(program: WebGLProgram, name: string) | GLint | +| getBufferParameter(target: GLenum, pname: GLenum) | any | +| getParameter(pname: GLenum) | any | +| getError() | GLenum | +| getFramebufferAttachmentParameter(target: GLenum, attachment: GLenum, pname: GLenum) | any | +| getProgramParameter(program: WebGLProgram, pname: GLenum) | any | +| getProgramInfoLog(program: WebGLProgram) | string \| null | +| getRenderbufferParameter(target: GLenum, pname: GLenum) | any | +| getShaderParameter(shader: WebGLShader, pname: GLenum) | any | +| getShaderPrecisionFormat(shadertype: GLenum, precisiontype: GLenum) | WebGLShaderPrecisionFormat \| null | +| getShaderInfoLog(shader: WebGLShader) | string \| null | +| getShaderSource(shader: WebGLShader) | string \| null | +| getTexParameter(target: GLenum, pname: GLenum) | any | +| getUniform(program: WebGLProgram, location: WebGLUniformLocation) | any | +| getUniformLocation(program: WebGLProgram, name: string) | WebGLUniformLocation \| null | +| getVertexAttrib(index: GLuint, pname: GLenum) | any | +| getVertexAttribOffset(index: GLuint, pname: GLenum) | GLintptr | +| hint(target: GLenum, mode: GLenum) | void | +| isBuffer(buffer: WebGLBuffer \| null) | GLboolean | +| isEnabled(cap: GLenum) | GLboolean | +| isFramebuffer(framebuffer: WebGLFramebuffer \| null) | GLboolean | +| isProgram(program: WebGLProgram \| null) | GLboolean | +| isRenderbuffer(renderbuffer: WebGLRenderbuffer \| null) | GLboolean | +| isShader(shader: WebGLShader \| null) | GLboolean | +| isTexture(texture: WebGLTexture \| null) | GLboolean | +| lineWidth(width: GLfloat) | void | +| linkProgram(program: WebGLProgram) | void | +| pixelStorei(pname: GLenum, param: GLint \| GLboolean) | void | +| polygonOffset(factor: GLfloat, units: GLfloat) | void | +| renderbufferStorage(target: GLenum, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | +| sampleCoverage(value: GLclampf, invert: GLboolean) | void | +| scissor(x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | +| shaderSource(shader: WebGLShader, source: string) | void | +| stencilFunc(func: GLenum, ref: GLint, mask: GLuint) | void | +| stencilFuncSeparate(face: GLenum, func: GLenum, ref: GLint, mask: GLuint) | void | +| stencilMask(mask: GLuint) | void | +| stencilMaskSeparate(face: GLenum, mask: GLuint) | void | +| stencilOp(fail: GLenum, zfail: GLenum, zpass: GLenum) | void | +| stencilOpSeparate(face: GLenum, fail: GLenum, zfail: GLenum, zpass: GLenum) | void | +| texParameterf(target: GLenum, pname: GLenum, param: GLfloat) | void | +| texParameteri(target: GLenum, pname: GLenum, param: GLint) | void | +| uniform1f(location: WebGLUniformLocation \| null, x: GLfloat) | void | +| uniform2f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat) | void | +| uniform3f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat) | void | +| uniform4f(location: WebGLUniformLocation \| null, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) | void | +| uniform1i(location: WebGLUniformLocation \| null, x: GLint) | void | +| uniform2i(location: WebGLUniformLocation \| null, x: GLint, y: GLint) | void | +| uniform3i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint) | void | +| uniform4i(location: WebGLUniformLocation \| null, x: GLint, y: GLint, z: GLint, w: GLint) | void | +| useProgram(program: WebGLProgram \| null) | void | +| validateProgram(program: WebGLProgram) | void | +| vertexAttrib1f(index: GLuint, x: GLfloat) | void | +| vertexAttrib2f(index: GLuint, x: GLfloat, y: GLfloat) | void | +| vertexAttrib3f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat) | void | +| vertexAttrib4f(index: GLuint, x: GLfloat, y: GLfloat, z: GLfloat, w: GLfloat) | void | +| vertexAttrib1fv(index: GLuint, values: Float32List) | void | +| vertexAttrib2fv(index: GLuint, values: Float32List) | void | +| vertexAttrib3fv(index: GLuint, values: Float32List) | void | +| vertexAttrib4fv(index: GLuint, values: Float32List) | void | +| vertexAttribPointer(index: GLuint, size: GLint, type: GLenum, normalized: GLboolean, stride: GLsizei, offset: GLintptr) | void | +| viewport(x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | + + +## WebGLRenderingContextOverloads + +WebGLRenderingContextOverloads + + | 方法 | 返回值类型 | +| -------- | -------- | +| bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum) | void | +| bufferData(target: GLenum, data: BufferSource \| null, usage: GLenum) | void | +| bufferSubData(target: GLenum, offset: GLintptr, data: BufferSource) | void | +| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, data: ArrayBufferView) | void | +| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, data: ArrayBufferView) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void; | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| uniform1fv(location: WebGLUniformLocation \| null, v: Float32List) | void | +| uniform2fv(location: WebGLUniformLocation \| null, v: Float32List) | void | +| uniform3fv(location: WebGLUniformLocation \| null, v: Float32List) | void | +| uniform4fv(location: WebGLUniformLocation \| null, v: Float32List) | void | +| uniform1iv(location: WebGLUniformLocation \| null, v: Int32List) | void | +| uniform2iv(location: WebGLUniformLocation \| null, v: Int32List) | void | +| uniform3iv(location: WebGLUniformLocation \| null, v: Int32List) | void | +| uniform4iv(location: WebGLUniformLocation \| null, v: Int32List) | void | +| uniformMatrix2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | +| uniformMatrix3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | +| uniformMatrix4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, value: Float32List) | void | diff --git a/zh-cn/application-dev/reference/apis/js-apis-webgl2.md b/zh-cn/application-dev/reference/apis/js-apis-webgl2.md index ab0618b8e9f36775d3181c4926fe1378aad95ddf..7a6147cd44ee9848005d6e471d418138e53daefd 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-webgl2.md +++ b/zh-cn/application-dev/reference/apis/js-apis-webgl2.md @@ -1,501 +1,481 @@ -# WebGL2 - -> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** -> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 - - -WebGL标准图形API,对应OpenGL ES 3.0特性集。更多信息请参考[WebgGL™标准](https://www.khronos.org/registry/webgl/specs/latest/2.0/)。 - - - -## 导入模块 - -``` -import webgl from 'ohos.webglnapi' -``` - - -## 系统能力 - -SystemCapability.Graphic.Graphic2D.WebGL2 - - -## 调用方式 - -``` -// 获取canvas组件实例 -const el = this.$refs.canvas -// 从canvas组件实例获取WebGL上下文 -const gl = el.getContext('webgl'); -const gl2 = el.getContext('webgl2'); -// 调用WebGL API -gl2.readBuffer(gl.COLOR_ATTACHMENT0) -``` - - -## GLenum - -| 名称 | 类型 | -| -------- | -------- | -| GLenum | number | - - -## Glint64 - -| 名称 | 类型 | -| -------- | -------- | -| Glint64 | number | - - -## Gluint64 - -| 名称 | 类型 | -| -------- | -------- | -| Gluint64 | number | - - -## Uint32List - -| 名称 | 类型 | -| -------- | -------- | -| Uint32List | array | - - -## webgl.webGL2RenderingContexBase - -WebGL2RenderingContexBase - - -### 属性 - -| 名称 | 参数类型 | 必填 | -| -------- | ------- | --------- | -| READ_BUFFER | [GLenum](#GLenum) | 是 | -| UNPACK_ROW_LENGTH | [GLenum](#GLenum) | 是 | -| UNPACK_SKIP_ROWS | [GLenum](#GLenum) | 是 | -| UNPACK_SKIP_PIXELS | [GLenum](#GLenum) | 是 | -| PACK_ROW_LENGTH | [GLenum](#GLenum) | 是 | -| PACK_SKIP_ROWS | [GLenum](#GLenum) | 是 | -| PACK_SKIP_PIXELS | [GLenum](#GLenum) | 是 | -| COLOR | [GLenum](#GLenum) | 是 | -| DEPTH | [GLenum](#GLenum) | 是 | -| STENCIL | [GLenum](#GLenum) | 是 | -| RED | [GLenum](#GLenum) | 是 | -| RGB8 | [GLenum](#GLenum) | 是 | -| RGBA8 | [GLenum](#GLenum) | 是 | -| RGB10_A2 | [GLenum](#GLenum) | 是 | -| TEXTURE_BINDING_3D | [GLenum](#GLenum) | 是 | -| UNPACK_SKIP_IMAGES | [GLenum](#GLenum) | 是 | -| UNPACK_IMAGE_HEIGHT | [GLenum](#GLenum) | 是 | -| TEXTURE_3D | [GLenum](#GLenum) | 是 | -| TEXTURE_WRAP_R | [GLenum](#GLenum) | 是 | -| MAX_3D_TEXTURE_SIZE | [GLenum](#GLenum) | 是 | -| UNSIGNED_INT_2_10_10_10_REV | [GLenum](#GLenum) | 是 | -| MAX_ELEMENTS_VERTICES | [GLenum](#GLenum) | 是 | -| MAX_ELEMENTS_INDICES | [GLenum](#GLenum) | 是 | -| TEXTURE_MIN_LOD | [GLenum](#GLenum) | 是 | -| TEXTURE_MAX_LOD | [GLenum](#GLenum) | 是 | -| TEXTURE_BASE_LEVEL | [GLenum](#GLenum) | 是 | -| TEXTURE_MAX_LEVEL | [GLenum](#GLenum) | 是 | -| MIN | [GLenum](#GLenum) | 是 | -| MAX | [GLenum](#GLenum) | 是 | -| DEPTH_COMPONENT24 | [GLenum](#GLenum) | 是 | -| MAX_TEXTURE_LOD_BIAS | [GLenum](#GLenum) | 是 | -| TEXTURE_COMPARE_MODE | [GLenum](#GLenum) | 是 | -| TEXTURE_COMPARE_FUNC | [GLenum](#GLenum) | 是 | -| CURRENT_QUERY | [GLenum](#GLenum) | 是 | -| QUERY_RESULT | [GLenum](#GLenum) | 是 | -| QUERY_RESULT_AVAILABLE | [GLenum](#GLenum) | 是 | -| STREAM_READ | [GLenum](#GLenum) | 是 | -| STREAM_COPY | [GLenum](#GLenum) | 是 | -| STATIC_READ | [GLenum](#GLenum) | 是 | -| STATIC_COPY | [GLenum](#GLenum) | 是 | -| DYNAMIC_READ | [GLenum](#GLenum) | 是 | -| DYNAMIC_COPY | [GLenum](#GLenum) | 是 | -| MAX_DRAW_BUFFERS | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER0 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER1 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER2 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER3 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER4 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER5 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER6 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER7 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER8 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER9 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER10 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER11 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER12 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER13 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER14 | [GLenum](#GLenum) | 是 | -| DRAW_BUFFER15 | [GLenum](#GLenum) | 是 | -| MAX_FRAGMENT_UNIFORM_COMPONENTS | [GLenum](#GLenum) | 是 | -| MAX_VERTEX_UNIFORM_COMPONENTS | [GLenum](#GLenum) | 是 | -| SAMPLER_3D | [GLenum](#GLenum) | 是 | -| SAMPLER_2D_SHADOW | [GLenum](#GLenum) | 是 | -| FRAGMENT_SHADER_DERIVATIVE_HINT | [GLenum](#GLenum) | 是 | -| PIXEL_PACK_BUFFER | [GLenum](#GLenum) | 是 | -| PIXEL_UNPACK_BUFFER | [GLenum](#GLenum) | 是 | -| PIXEL_PACK_BUFFER_BINDING | [GLenum](#GLenum) | 是 | -| PIXEL_UNPACK_BUFFER_BINDING | [GLenum](#GLenum) | 是 | -| FLOAT_MAT2x3 | [GLenum](#GLenum) | 是 | -| FLOAT_MAT2x4 | [GLenum](#GLenum) | 是 | -| FLOAT_MAT3x2 | [GLenum](#GLenum) | 是 | -| FLOAT_MAT3x4 | [GLenum](#GLenum) | 是 | -| FLOAT_MAT4x2 | [GLenum](#GLenum) | 是 | -| FLOAT_MAT4x3 | [GLenum](#GLenum) | 是 | -| SRGB | [GLenum](#GLenum) | 是 | -| SRGB8 | [GLenum](#GLenum) | 是 | -| SRGB8_ALPHA8 | [GLenum](#GLenum) | 是 | -| COMPARE_REF_TO_TEXTURE | [GLenum](#GLenum) | 是 | -| RGBA32F | [GLenum](#GLenum) | 是 | -| RGB32F | [GLenum](#GLenum) | 是 | -| RGBA16F | [GLenum](#GLenum) | 是 | -| RGB16F | [GLenum](#GLenum) | 是 | -| VERTEX_ATTRIB_ARRAY_INTEGER | [GLenum](#GLenum) | 是 | -| MAX_ARRAY_TEXTURE_LAYERS | [GLenum](#GLenum) | 是 | -| MIN_PROGRAM_TEXEL_OFFSET | [GLenum](#GLenum) | 是 | -| MAX_PROGRAM_TEXEL_OFFSET | [GLenum](#GLenum) | 是 | -| MAX_VARYING_COMPONENTS | [GLenum](#GLenum) | 是 | -| TEXTURE_2D_ARRAY | [GLenum](#GLenum) | 是 | -| TEXTURE_BINDING_2D_ARRAY | [GLenum](#GLenum) | 是 | -| R11F_G11F_B10F | [GLenum](#GLenum) | 是 | -| UNSIGNED_INT_10F_11F_11F_REV | [GLenum](#GLenum) | 是 | -| RGB9_E5 | [GLenum](#GLenum) | 是 | -| UNSIGNED_INT_5_9_9_9_REV | [GLenum](#GLenum) | 是 | -| TRANSFORM_FEEDBACK_BUFFER_MODE | [GLenum](#GLenum) | 是 | -| MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS | [GLenum](#GLenum) | 是 | -| TRANSFORM_FEEDBACK_VARYINGS | [GLenum](#GLenum) | 是 | -| TRANSFORM_FEEDBACK_BUFFER_START | [GLenum](#GLenum) | 是 | -| TRANSFORM_FEEDBACK_BUFFER_SIZE | [GLenum](#GLenum) | 是 | -| TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN | [GLenum](#GLenum) | 是 | -| RASTERIZER_DISCARD | [GLenum](#GLenum) | 是 | -| MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS | [GLenum](#GLenum) | 是 | -| MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS | [GLenum](#GLenum) | 是 | -| INTERLEAVED_ATTRIBS | [GLenum](#GLenum) | 是 | -| SEPARATE_ATTRIBS | [GLenum](#GLenum) | 是 | -| TRANSFORM_FEEDBACK_BUFFER | [GLenum](#GLenum) | 是 | -| TRANSFORM_FEEDBACK_BUFFER_BINDING | [GLenum](#GLenum) | 是 | -| RGBA32UI | [GLenum](#GLenum) | 是 | -| RGB32UI | [GLenum](#GLenum) | 是 | -| RGBA16UI | [GLenum](#GLenum) | 是 | -| RGB16UI | [GLenum](#GLenum) | 是 | -| RGBA8UI | [GLenum](#GLenum) | 是 | -| RGB8UI | [GLenum](#GLenum) | 是 | -| RGBA32I | [GLenum](#GLenum) | 是 | -| RGB32I | [GLenum](#GLenum) | 是 | -| RGBA16I | [GLenum](#GLenum) | 是 | -| RGB16I | [GLenum](#GLenum) | 是 | -| RGBA8I | [GLenum](#GLenum) | 是 | -| RGB8I | [GLenum](#GLenum) | 是 | -| RED_INTEGER | [GLenum](#GLenum) | 是 | -| RGB_INTEGER | [GLenum](#GLenum) | 是 | -| RGBA_INTEGER | [GLenum](#GLenum) | 是 | -| SAMPLER_2D_ARRAY | [GLenum](#GLenum) | 是 | -| SAMPLER_2D_ARRAY_SHADOW | [GLenum](#GLenum) | 是 | -| SAMPLER_CUBE_SHADOW | [GLenum](#GLenum) | 是 | -| UNSIGNED_INT_VEC2 | [GLenum](#GLenum) | 是 | -| UNSIGNED_INT_VEC3 | [GLenum](#GLenum) | 是 | -| UNSIGNED_INT_VEC4 | [GLenum](#GLenum) | 是 | -| INT_SAMPLER_2D | [GLenum](#GLenum) | 是 | -| INT_SAMPLER_3D | [GLenum](#GLenum) | 是 | -| INT_SAMPLER_CUBE | [GLenum](#GLenum) | 是 | -| INT_SAMPLER_2D_ARRAY | [GLenum](#GLenum) | 是 | -| UNSIGNED_INT_SAMPLER_2D | [GLenum](#GLenum) | 是 | -| UNSIGNED_INT_SAMPLER_3D | [GLenum](#GLenum) | 是 | -| UNSIGNED_INT_SAMPLER_CUBE | [GLenum](#GLenum) | 是 | -| UNSIGNED_INT_SAMPLER_2D_ARRAY | [GLenum](#GLenum) | 是 | -| DEPTH_COMPONENT32F | [GLenum](#GLenum) | 是 | -| DEPTH32F_STENCIL8 | [GLenum](#GLenum) | 是 | -| FLOAT_32_UNSIGNED_INT_24_8_REV | [GLenum](#GLenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING | [GLenum](#GLenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE | [GLenum](#GLenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_RED_SIZE | [GLenum](#GLenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_GREEN_SIZE | [GLenum](#GLenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_BLUE_SIZE | [GLenum](#GLenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE | [GLenum](#GLenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE | [GLenum](#GLenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE | [GLenum](#GLenum) | 是 | -| FRAMEBUFFER_DEFAULT | [GLenum](#GLenum) | 是 | -| UNSIGNED_INT_24_8 | [GLenum](#GLenum) | 是 | -| DEPTH24_STENCIL8 | [GLenum](#GLenum) | 是 | -| UNSIGNED_NORMALIZED | [GLenum](#GLenum) | 是 | -| DRAW_FRAMEBUFFER_BINDING | [GLenum](#GLenum) | 是 | -| READ_FRAMEBUFFER | [GLenum](#GLenum) | 是 | -| DRAW_FRAMEBUFFER | [GLenum](#GLenum) | 是 | -| READ_FRAMEBUFFER_BINDING | [GLenum](#GLenum) | 是 | -| RENDERBUFFER_SAMPLES | [GLenum](#GLenum) | 是 | -| FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER | [GLenum](#GLenum) | 是 | -| MAX_COLOR_ATTACHMENTS | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT1 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT2 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT3 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT4 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT5 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT6 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT7 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT8 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT9 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT10 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT11 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT12 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT13 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT14 | [GLenum](#GLenum) | 是 | -| COLOR_ATTACHMENT15 | [GLenum](#GLenum) | 是 | -| FRAMEBUFFER_INCOMPLETE_MULTISAMPLE | [GLenum](#GLenum) | 是 | -| MAX_SAMPLES | [GLenum](#GLenum) | 是 | -| HALF_FLOAT | [GLenum](#GLenum) | 是 | -| RG | [GLenum](#GLenum) | 是 | -| RG_INTEGER | [GLenum](#GLenum) | 是 | -| R8 | [GLenum](#GLenum) | 是 | -| RG8 | [GLenum](#GLenum) | 是 | -| R16F | [GLenum](#GLenum) | 是 | -| R32F | [GLenum](#GLenum) | 是 | -| RG16F | [GLenum](#GLenum) | 是 | -| RG32F | [GLenum](#GLenum) | 是 | -| R8I | [GLenum](#GLenum) | 是 | -| R8UI | [GLenum](#GLenum) | 是 | -| R16I | [GLenum](#GLenum) | 是 | -| R16UI | [GLenum](#GLenum) | 是 | -| R32I | [GLenum](#GLenum) | 是 | -| R32UI | [GLenum](#GLenum) | 是 | -| RG8I | [GLenum](#GLenum) | 是 | -| RG8UI | [GLenum](#GLenum) | 是 | -| RG16I | [GLenum](#GLenum) | 是 | -| RG16UI | [GLenum](#GLenum) | 是 | -| RG32I | [GLenum](#GLenum) | 是 | -| RG32UI | [GLenum](#GLenum) | 是 | -| VERTEX_ARRAY_BINDING | [GLenum](#GLenum) | 是 | -| R8_SNORM | [GLenum](#GLenum) | 是 | -| RG8_SNORM | [GLenum](#GLenum) | 是 | -| RGB8_SNORM | [GLenum](#GLenum) | 是 | -| SIGNED_NORMALIZED | [GLenum](#GLenum) | 是 | -| COPY_READ_BUFFER | [GLenum](#GLenum) | 是 | -| COPY_WRITE_BUFFER | [GLenum](#GLenum) | 是 | -| COPY_READ_BUFFER_BINDING | [GLenum](#GLenum) | 是 | -| COPY_WRITE_BUFFER_BINDING | [GLenum](#GLenum) | 是 | -| UNIFORM_BUFFER | [GLenum](#GLenum) | 是 | -| UNIFORM_BUFFER_BINDING | [GLenum](#GLenum) | 是 | -| UNIFORM_BUFFER_START | [GLenum](#GLenum) | 是 | -| UNIFORM_BUFFER_SIZE | [GLenum](#GLenum) | 是 | -| MAX_VERTEX_UNIFORM_BLOCKS | [GLenum](#GLenum) | 是 | -| MAX_FRAGMENT_UNIFORM_BLOCKS | [GLenum](#GLenum) | 是 | -| MAX_COMBINED_UNIFORM_BLOCKS | [GLenum](#GLenum) | 是 | -| MAX_UNIFORM_BUFFER_BINDINGS | [GLenum](#GLenum) | 是 | -| MAX_UNIFORM_BLOCK_SIZE | [GLenum](#GLenum) | 是 | -| MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS | [GLenum](#GLenum) | 是 | -| MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS | [GLenum](#GLenum) | 是 | -| UNIFORM_BUFFER_OFFSET_ALIGNMENT | [GLenum](#GLenum) | 是 | -| ACTIVE_UNIFORM_BLOCKS | [GLenum](#GLenum) | 是 | -| UNIFORM_TYPE | [GLenum](#GLenum) | 是 | -| UNIFORM_SIZE | [GLenum](#GLenum) | 是 | -| UNIFORM_BLOCK_INDEX | [GLenum](#GLenum) | 是 | -| UNIFORM_OFFSET | [GLenum](#GLenum) | 是 | -| UNIFORM_ARRAY_STRIDE | [GLenum](#GLenum) | 是 | -| UNIFORM_MATRIX_STRIDE | [GLenum](#GLenum) | 是 | -| UNIFORM_IS_ROW_MAJOR | [GLenum](#GLenum) | 是 | -| UNIFORM_BLOCK_BINDING | [GLenum](#GLenum) | 是 | -| UNIFORM_BLOCK_DATA_SIZE | [GLenum](#GLenum) | 是 | -| UNIFORM_BLOCK_ACTIVE_UNIFORMS | [GLenum](#GLenum) | 是 | -| UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES | [GLenum](#GLenum) | 是 | -| UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER | [GLenum](#GLenum) | 是 | -| UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER | [GLenum](#GLenum) | 是 | -| INVALID_INDEX | [GLenum](#GLenum) | 是 | -| MAX_VERTEX_OUTPUT_COMPONENTS | [GLenum](#GLenum) | 是 | -| MAX_FRAGMENT_INPUT_COMPONENTS | [GLenum](#GLenum) | 是 | -| MAX_SERVER_WAIT_TIMEOUT | [GLenum](#GLenum) | 是 | -| OBJECT_TYPE | [GLenum](#GLenum) | 是 | -| SYNC_CONDITION | [GLenum](#GLenum) | 是 | -| SYNC_STATUS | [GLenum](#GLenum) | 是 | -| SYNC_FLAGS | [GLenum](#GLenum) | 是 | -| SYNC_FENCE | [GLenum](#GLenum) | 是 | -| SYNC_GPU_COMMANDS_COMPLETE | [GLenum](#GLenum) | 是 | -| UNSIGNALED | [GLenum](#GLenum) | 是 | -| SIGNALED | [GLenum](#GLenum) | 是 | -| ALREADY_SIGNALED | [GLenum](#GLenum) | 是 | -| TIMEOUT_EXPIRED | [GLenum](#GLenum) | 是 | -| CONDITION_SATISFIED | [GLenum](#GLenum) | 是 | -| WAIT_FAILED | [GLenum](#GLenum) | 是 | -| SYNC_FLUSH_COMMANDS_BIT | [GLenum](#GLenum) | 是 | -| VERTEX_ATTRIB_ARRAY_DIVISOR | [GLenum](#GLenum) | 是 | -| ANY_SAMPLES_PASSED | [GLenum](#GLenum) | 是 | -| ANY_SAMPLES_PASSED_CONSERVATIVE | [GLenum](#GLenum) | 是 | -| SAMPLER_BINDING | [GLenum](#GLenum) | 是 | -| RGB10_A2UI | [GLenum](#GLenum) | 是 | -| INT_2_10_10_10_REV | [GLenum](#GLenum) | 是 | -| TRANSFORM_FEEDBACK | [GLenum](#GLenum) | 是 | -| TRANSFORM_FEEDBACK_PAUSED | [GLenum](#GLenum) | 是 | -| TRANSFORM_FEEDBACK_ACTIVE | [GLenum](#GLenum) | 是 | -| TRANSFORM_FEEDBACK_BINDING | [GLenum](#GLenum) | 是 | -| TEXTURE_IMMUTABLE_FORMAT | [GLenum](#GLenum) | 是 | -| MAX_ELEMENT_INDEX | [GLenum](#GLenum) | 是 | -| TEXTURE_IMMUTABLE_LEVELS | [GLenum](#GLenum) | 是 | -| TIMEOUT_IGNORED | [GLenum](#GLenum) | 是 | -| MAX_CLIENT_WAIT_TIMEOUT_WEBGL | [GLenum](#GLenum) | 是 | - - -### 方法 - -| 方法 | 返回值类型 | -| -------- | ---------- | -| copyBufferSubData(readTarget:  GLenum,  writeTarget:  GLenum,  readOffset:  GLintptr,  writeOffset:  GLintptr,  size:  GLsizeiptr) | void | -| getBufferSubData(target:  GLenum,  srcByteOffset:  GLintptr,  dstBuffer:  ArrayBufferView,  dstOffset?:  GLuint,  length?:  GLuint) | void | -| blitFramebuffer(srcX0:  GLint,  srcY0:  GLint,  srcX1:  GLint,  srcY1:  GLint,  dstX0:  GLint,  dstY0:  GLint,  dstX1:  GLint,  dstY1:  GLint,  mask:  GLbitfield,  filter:  GLenum) | void | -| framebufferTextureLayer(target:  GLenum,  attachment:  GLenum,  texture:  WebGLTexture \| null,  level:  GLint,  layer:  GLint) | void | -| invalidateFramebuffer(target:  GLenum,  attachments:  GLenum[]) | void | -| invalidateSubFramebuffer(target:  GLenum,  attachments:  GLenum[],  x:  GLint,  y:  GLint,  width:  GLsizei,  height:  GLsizei) | void | -| readBuffer(src:  GLenum) | void | -| getInternalformatParameter(target:  GLenum,  internalformat:  GLenum,  pname:  GLenum) | any | -| renderbufferStorageMultisample(target:  GLenum,  samples:  GLsizei,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei) | void | -| texStorage2D(target:  GLenum,  levels:  GLsizei,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei) | void | -| texStorage3D(target:  GLenum,  levels:  GLsizei,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei) | void | -| texImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  pboOffset:  GLintptr) | void | -| texImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  srcData:  ArrayBufferView \| null) | void | -| texImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  srcData:  ArrayBufferView,  srcOffset:  GLuint) | void | -| texSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  format:  GLenum,  type:  GLenum,  pboOffset:  GLintptr) | void | -| texSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  format:  GLenum,  type:  GLenum,  srcData:  ArrayBufferView \| null,  srcOffset?:  GLuint) | void | -| copyTexSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  x:  GLint,  y:  GLint,  width:  GLsizei,  height:  GLsizei) | void | -| compressedTexImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  imageSize:  GLsizei,  offset:  GLintptr) | void | -| compressedTexImage3D(target:  GLenum,  level:  GLint,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  border:  GLint,  srcData:  ArrayBufferView,  srcOffset?:  GLuint,  srcLengthOverride?:  GLuint) | void | -| compressedTexSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  format:  GLenum,  imageSize:  GLsizei,  offset:  GLintptr) | void | -| compressedTexSubImage3D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  zoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  depth:  GLsizei,  format:  GLenum,  srcData:  ArrayBufferView,  srcOffset?:  GLuint,  srcLengthOverride?:  GLuint) | void | -| getFragDataLocation(program:  WebGLProgram,  name:  string) | GLint | -| uniform1ui(location:  WebGLUniformLocation \| null,  v0:  GLuint) | void | -| uniform2ui(location:  WebGLUniformLocation \| null,  v0:  GLuint,  v1:  GLuint) | void | -| uniform3ui(location:  WebGLUniformLocation \| null,  v0:  GLuint,  v1:  GLuint,  v2:  GLuint) | void | -| uniform4ui(location:  WebGLUniformLocation \| null,  v0:  GLuint,  v1:  GLuint,  v2:  GLuint,  v3:  GLuint) | void | -| uniform1uiv(location:  WebGLUniformLocation \| null,  data:  Uint32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform2uiv(location:  WebGLUniformLocation \| null,  data:  Uint32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform3uiv(location:  WebGLUniformLocation \| null,  data:  Uint32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform4uiv(location:  WebGLUniformLocation \| null,  data:  Uint32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix3x2fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix4x2fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix2x3fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix4x3fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix2x4fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix3x4fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| vertexAttribI4i(index:  GLuint,  x:  GLint,  y:  GLint,  z:  GLint,  w:  GLint) | void | -| vertexAttribI4iv(index:  GLuint,  values:  Int32List) | void | -| vertexAttribI4ui(index:  GLuint,  x:  GLuint,  y:  GLuint,  z:  GLuint,  w:  GLuint) | void | -| vertexAttribI4uiv(index:  GLuint,  values:  Uint32List) | void | -| vertexAttribIPointer(index:  GLuint,  size:  GLint,  type:  GLenum,  stride:  GLsizei,  offset:  GLintptr) | void | -| vertexAttribDivisor(index:  GLuint,  divisor:  GLuint) | void | -| drawArraysInstanced(mode:  GLenum,  first:  GLint,  count:  GLsizei,  instanceCount:  GLsizei) | void | -| drawElementsInstanced(mode:  GLenum,  count:  GLsizei,  type:  GLenum,  offset:  GLintptr,  instanceCount:  GLsizei) | void | -| drawRangeElements(mode:  GLenum,  start:  GLuint,  end:  GLuint,  count:  GLsizei,  type:  GLenum,  offset:  GLintptr) | void | -| drawBuffers(buffers:  GLenum[]) | void | -| clearBufferfv(buffer:  GLenum,  drawbuffer:  GLint,  values:  Float32List,  srcOffset?:  GLuint) | void | -| clearBufferiv(buffer:  GLenum,  drawbuffer:  GLint,  values:  Int32List,  srcOffset?:  GLuint) | void | -| clearBufferuiv(buffer:  GLenum,  drawbuffer:  GLint,  values:  Uint32List,  srcOffset?:  GLuint) | void | -| clearBufferfi(buffer:  GLenum,  drawbuffer:  GLint,  depth:  GLfloat,  stencil:  GLint) | void | -| createQuery() | WebGLQuery \| null | -| deleteQuery(query:  WebGLQuery \| null) | void | -| isQuery(query:  WebGLQuery \| null) | GLboolean | -| beginQuery(target:  GLenum,  query:  WebGLQuery) | void | -| endQuery(target:  GLenum) | void | -| getQuery(target:  GLenum,  pname:  GLenum) | WebGLQuery \| null | -| getQueryParameter(query:  WebGLQuery,  pname:  GLenum) | any | -| createSampler() | WebGLSampler \| null | -| deleteSampler(sampler:  WebGLSampler \| null) | void | -| isSampler(sampler:  WebGLSampler \| null) | GLboolean | -| bindSampler(unit:  GLuint,  sampler:  WebGLSampler \| null) | void | -| samplerParameteri(sampler:  WebGLSampler,  pname:  GLenum,  param:  GLint) | void | -| samplerParameterf(sampler:  WebGLSampler,  pname:  GLenum,  param:  GLfloat) | void | -| getSamplerParameter(sampler:  WebGLSampler,  pname:  GLenum) | any | -| fenceSync(condition:  GLenum,  flags:  GLbitfield) | WebGLSync \| null | -| isSync(sync:  WebGLSync \| null) | GLboolean | -| deleteSync(sync:  WebGLSync \| null) | void | -| clientWaitSync(sync:  WebGLSync,  flags:  GLbitfield,  timeout:  GLuint64) | GLenum | -| waitSync(sync:  WebGLSync,  flags:  GLbitfield,  timeout:  GLint64) | void | -| getSyncParameter(sync:  WebGLSync,  pname:  GLenum) | any | -| createTransformFeedback() | WebGLTransformFeedback \| null | -| deleteTransformFeedback(tf:  WebGLTransformFeedback \| null) | void | -| isTransformFeedback(tf:  WebGLTransformFeedback \| null) | GLboolean | -| bindTransformFeedback(target:  GLenum,  tf:  WebGLTransformFeedback \| null) | void | -| beginTransformFeedback(primitiveMode:  GLenum) | void | -| endTransformFeedback() | void | -| transformFeedbackVaryings(program:  WebGLProgram,  varyings:  string[],  bufferMode:  GLenum) | void | -| getTransformFeedbackVarying(program:  WebGLProgram,  index:  GLuint) | WebGLActiveInfo \| null | -| pauseTransformFeedback() | void | -| resumeTransformFeedback() | void | -| bindBufferBase(target:  GLenum,  index:  GLuint,  buffer:  WebGLBuffer \| null) | void | -| bindBufferRange(target:  GLenum,  index:  GLuint,  buffer:  WebGLBuffer \| null,  offset:  GLintptr,  size:  GLsizeiptr) | void | -| getIndexedParameter(target:  GLenum,  index:  GLuint) | any | -| getUniformIndices(program:  WebGLProgram,  uniformNames:  string[]) | GLuint[] \| null | -| getActiveUniforms(program:  WebGLProgram,  uniformIndices:  GLuint[],  pname:  GLenum) | any | -| getUniformBlockIndex(program:  WebGLProgram,  uniformBlockName:  string) | GLuint | -| getActiveUniformBlockParameter(program:  WebGLProgram,  uniformBlockIndex:  GLuint,  pname:  GLenum) | any | -| getActiveUniformBlockName(program:  WebGLProgram,  uniformBlockIndex:  GLuint) | string \| null | -| uniformBlockBinding(program:  WebGLProgram,  uniformBlockIndex:  GLuint,  uniformBlockBinding:  GLuint) | void | -| createVertexArray() | WebGLVertexArrayObject \| null | -| deleteVertexArray(vertexArray:  WebGLVertexArrayObject \| null) | void | -| isVertexArray(vertexArray:  WebGLVertexArrayObject \| null) | GLboolean | -| bindVertexArray(array:  WebGLVertexArrayObject \| null) | void | - - -## webgl.WebGL2RenderingContextOverloads - -WebGL2RenderingContextOverloads - -| 方法 | 返回值类型 | -| -------- | ---------- | -| bufferData(target:  GLenum,  size:  GLsizeiptr,  usage:  GLenum) | void | -| bufferData(target:  GLenum,  srcData:  BufferSource \| null,  usage:  GLenum) | void | -| bufferSubData(target:  GLenum,  dstByteOffset:  GLintptr,  srcData:  BufferSource) | void | -| bufferData(target:  GLenum,  srcData:  ArrayBufferView,  usage:  GLenum,  srcOffset:  GLuint,  length?:  GLuint) | void | -| bufferSubData(target:  GLenum,  dstByteOffset:  GLintptr,  srcData:  ArrayBufferView,  srcOffset:  GLuint,  length?:  GLuint) | void | -| texImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  pixels:  ArrayBufferView \| null) | void | -| texImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  pixels:  ArrayBufferView \| null) | void | -| texSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  pboOffset:  GLintptr) | void | -| texImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLint,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  format:  GLenum,  type:  GLenum,  srcData:  ArrayBufferView,  srcOffset:  GLuint) | void | -| texSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  pboOffset:  GLintptr) | void | -| texSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  source:  TexImageSource) | void | -| texSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  srcData:  ArrayBufferView,  srcOffset:  GLuint) | void | -| compressedTexImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  imageSize:  GLsizei,  offset:  GLintptr) | void | -| compressedTexImage2D(target:  GLenum,  level:  GLint,  internalformat:  GLenum,  width:  GLsizei,  height:  GLsizei,  border:  GLint,  srcData:  ArrayBufferView,  srcOffset?:  GLuint,  srcLengthOverride?:  GLuint) | void | -| compressedTexSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  imageSize:  GLsizei,  offset:  GLintptr) | void | -| compressedTexSubImage2D(target:  GLenum,  level:  GLint,  xoffset:  GLint,  yoffset:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  srcData:  ArrayBufferView,  srcOffset?:  GLuint,  srcLengthOverride?:  GLuint) | void | -| uniform1fv(location:  WebGLUniformLocation \| null,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform2fv(location:  WebGLUniformLocation \| null,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform3fv(location:  WebGLUniformLocation \| null,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform4fv(location:  WebGLUniformLocation \| null,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform1iv(location:  WebGLUniformLocation \| null,  data:  Int32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform2iv(location:  WebGLUniformLocation \| null,  data:  Int32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform3iv(location:  WebGLUniformLocation \| null,  data:  Int32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniform4iv(location:  WebGLUniformLocation \| null,  data:  Int32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix2fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix3fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| uniformMatrix4fv(location:  WebGLUniformLocation \| null,  transpose:  GLboolean,  data:  Float32List,  srcOffset?:  GLuint,  srcLength?:  GLuint) | void | -| readPixels(x:  GLint,  y:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  dstData:  ArrayBufferView \| null) | void | -| readPixels(x:  GLint,  y:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  offset:  GLintptr) | void | -| readPixels(x:  GLint,  y:  GLint,  width:  GLsizei,  height:  GLsizei,  format:  GLenum,  type:  GLenum,  dstData:  ArrayBufferView,  dstOffset:  GLuint) | void | - - -## webgl.WebGLQuery - -WebGLQuery - - -## webgl.WebGLSampler - -WebGLSampler - - -## webgl.WebGLSync - -WebGLSync - - -## webgl.WebGLTransformFeedback - -WebGLTransformFeedback - - -## webgl.WebGLVertexArrayObject - -WebGLVertexArrayObject \ No newline at end of file +# webgl2 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + + +WebGL标准图形API,对应OpenGL ES 3.0特性集。更多信息请参考[WebGL™标准](https://www.khronos.org/registry/webgl/specs/latest/2.0/)。 + + +## 导入模块 + +``` +import webgl from '@ohos.webglnapi' +``` + + +## 调用方式 + +hml内创建canvas,示例如下: + + +``` +
+ + +
+``` + +js内获取canvas实例,示例如下: + + +``` +// 获取canvas组件实例 +const el = this.$refs.canvas1; +// 从canvas组件实例获取WebGL上下文 +const gl = el.getContext('webgl'); +// 调用WebGL API +gl.clearColor(0.0, 0.0, 0.0, 1.0); +``` + + +## Type + + **表1** Type + +| 名称 | 类型 | 说明 | +| -------- | -------- | -------- | +| GLenum | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL2 | +| GLint64 | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL2 | +| GLuint64 | number | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL2 | +| Uint32List | array | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL2 | + + +## Interface + + **表2** Interface + +| 名称 | 说明 | +| -------- | -------- | +| [WebGL2RenderingContextBase](#webgl2renderingcontextbase) | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL2 | +| [WebGL2RenderingContextOverloads](#webgl2renderingcontextoverloads) | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL2 | +| WebGLQuery | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL2 | +| WebGLSampler | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL2 | +| WebGLSync | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL2 | +| WebGLTransformFeedback | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL2 | +| WebGLVertexArrayObject | **系统能力:** SystemCapability.Graphic.Graphic2D.WebGL2 | + + +## WebGL2RenderingContextBase + +WebGL2RenderingContextBase + + +### 属性 + + | 名称 | 参数类型 | 必填 | +| -------- | -------- | -------- | +| READ_BUFFER | GLenum | 是 | +| UNPACK_ROW_LENGTH | GLenum | 是 | +| UNPACK_SKIP_ROWS | GLenum | 是 | +| UNPACK_SKIP_PIXELS | GLenum | 是 | +| PACK_ROW_LENGTH | GLenum | 是 | +| PACK_SKIP_ROWS | GLenum | 是 | +| PACK_SKIP_PIXELS | GLenum | 是 | +| COLOR | GLenum | 是 | +| DEPTH | GLenum | 是 | +| STENCIL | GLenum | 是 | +| RED | GLenum | 是 | +| RGB8 | GLenum | 是 | +| RGBA8 | GLenum | 是 | +| RGB10_A2 | GLenum | 是 | +| TEXTURE_BINDING_3D | GLenum | 是 | +| UNPACK_SKIP_IMAGES | GLenum | 是 | +| UNPACK_IMAGE_HEIGHT | GLenum | 是 | +| TEXTURE_3D | GLenum | 是 | +| TEXTURE_WRAP_R | GLenum | 是 | +| MAX_3D_TEXTURE_SIZE | GLenum | 是 | +| UNSIGNED_INT_2_10_10_10_REV | GLenum | 是 | +| MAX_ELEMENTS_VERTICES | GLenum | 是 | +| MAX_ELEMENTS_INDICES | GLenum | 是 | +| TEXTURE_MIN_LOD | GLenum | 是 | +| TEXTURE_MAX_LOD | GLenum | 是 | +| TEXTURE_BASE_LEVEL | GLenum | 是 | +| TEXTURE_MAX_LEVEL | GLenum | 是 | +| MIN | GLenum | 是 | +| MAX | GLenum | 是 | +| DEPTH_COMPONENT24 | GLenum | 是 | +| MAX_TEXTURE_LOD_BIAS | GLenum | 是 | +| TEXTURE_COMPARE_MODE | GLenum | 是 | +| TEXTURE_COMPARE_FUNC | GLenum | 是 | +| CURRENT_QUERY | GLenum | 是 | +| QUERY_RESULT | GLenum | 是 | +| QUERY_RESULT_AVAILABLE | GLenum | 是 | +| STREAM_READ | GLenum | 是 | +| STREAM_COPY | GLenum | 是 | +| STATIC_READ | GLenum | 是 | +| STATIC_COPY | GLenum | 是 | +| DYNAMIC_READ | GLenum | 是 | +| DYNAMIC_COPY | GLenum | 是 | +| MAX_DRAW_BUFFERS | GLenum | 是 | +| DRAW_BUFFER0 | GLenum | 是 | +| DRAW_BUFFER1 | GLenum | 是 | +| DRAW_BUFFER2 | GLenum | 是 | +| DRAW_BUFFER3 | GLenum | 是 | +| DRAW_BUFFER4 | GLenum | 是 | +| DRAW_BUFFER5 | GLenum | 是 | +| DRAW_BUFFER6 | GLenum | 是 | +| DRAW_BUFFER7 | GLenum | 是 | +| DRAW_BUFFER8 | GLenum | 是 | +| DRAW_BUFFER9 | GLenum | 是 | +| DRAW_BUFFER10 | GLenum | 是 | +| DRAW_BUFFER11 | GLenum | 是 | +| DRAW_BUFFER12 | GLenum | 是 | +| DRAW_BUFFER13 | GLenum | 是 | +| DRAW_BUFFER14 | GLenum | 是 | +| DRAW_BUFFER15 | GLenum | 是 | +| MAX_FRAGMENT_UNIFORM_COMPONENTS | GLenum | 是 | +| MAX_VERTEX_UNIFORM_COMPONENTS | GLenum | 是 | +| SAMPLER_3D | GLenum | 是 | +| SAMPLER_2D_SHADOW | GLenum | 是 | +| FRAGMENT_SHADER_DERIVATIVE_HINT | GLenum | 是 | +| PIXEL_PACK_BUFFER | GLenum | 是 | +| PIXEL_UNPACK_BUFFER | GLenum | 是 | +| PIXEL_PACK_BUFFER_BINDING | GLenum | 是 | +| PIXEL_UNPACK_BUFFER_BINDING | GLenum | 是 | +| FLOAT_MAT2x3 | GLenum | 是 | +| FLOAT_MAT2x4 | GLenum | 是 | +| FLOAT_MAT3x2 | GLenum | 是 | +| FLOAT_MAT3x4 | GLenum | 是 | +| FLOAT_MAT4x2 | GLenum | 是 | +| FLOAT_MAT4x3 | GLenum | 是 | +| SRGB | GLenum | 是 | +| SRGB8 | GLenum | 是 | +| SRGB8_ALPHA8 | GLenum | 是 | +| COMPARE_REF_TO_TEXTURE | GLenum | 是 | +| RGBA32F | GLenum | 是 | +| RGB32F | GLenum | 是 | +| RGBA16F | GLenum | 是 | +| RGB16F | GLenum | 是 | +| VERTEX_ATTRIB_ARRAY_INTEGER | GLenum | 是 | +| MAX_ARRAY_TEXTURE_LAYERS | GLenum | 是 | +| MIN_PROGRAM_TEXEL_OFFSET | GLenum | 是 | +| MAX_PROGRAM_TEXEL_OFFSET | GLenum | 是 | +| MAX_VARYING_COMPONENTS | GLenum | 是 | +| TEXTURE_2D_ARRAY | GLenum | 是 | +| TEXTURE_BINDING_2D_ARRAY | GLenum | 是 | +| R11F_G11F_B10F | GLenum | 是 | +| UNSIGNED_INT_10F_11F_11F_REV | GLenum | 是 | +| RGB9_E5 | GLenum | 是 | +| UNSIGNED_INT_5_9_9_9_REV | GLenum | 是 | +| TRANSFORM_FEEDBACK_BUFFER_MODE | GLenum | 是 | +| MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS | GLenum | 是 | +| TRANSFORM_FEEDBACK_VARYINGS | GLenum | 是 | +| TRANSFORM_FEEDBACK_BUFFER_START | GLenum | 是 | +| TRANSFORM_FEEDBACK_BUFFER_SIZE | GLenum | 是 | +| TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN | GLenum | 是 | +| RASTERIZER_DISCARD | GLenum | 是 | +| MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS | GLenum | 是 | +| MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS | GLenum | 是 | +| INTERLEAVED_ATTRIBS | GLenum | 是 | +| SEPARATE_ATTRIBS | GLenum | 是 | +| TRANSFORM_FEEDBACK_BUFFER | GLenum | 是 | +| TRANSFORM_FEEDBACK_BUFFER_BINDING | GLenum | 是 | +| RGBA32UI | GLenum | 是 | +| RGB32UI | GLenum | 是 | +| RGBA16UI | GLenum | 是 | +| RGB16UI | GLenum | 是 | +| RGBA8UI | GLenum | 是 | +| RGB8UI | GLenum | 是 | +| RGBA32I | GLenum | 是 | +| RGB32I | GLenum | 是 | +| RGBA16I | GLenum | 是 | +| RGB16I | GLenum | 是 | +| RGBA8I | GLenum | 是 | +| RGB8I | GLenum | 是 | +| RED_INTEGER | GLenum | 是 | +| RGB_INTEGER | GLenum | 是 | +| RGBA_INTEGER | GLenum | 是 | +| SAMPLER_2D_ARRAY | GLenum | 是 | +| SAMPLER_2D_ARRAY_SHADOW | GLenum | 是 | +| SAMPLER_CUBE_SHADOW | GLenum | 是 | +| UNSIGNED_INT_VEC2 | GLenum | 是 | +| UNSIGNED_INT_VEC3 | GLenum | 是 | +| UNSIGNED_INT_VEC4 | GLenum | 是 | +| INT_SAMPLER_2D | GLenum | 是 | +| INT_SAMPLER_3D | GLenum | 是 | +| INT_SAMPLER_CUBE | GLenum | 是 | +| INT_SAMPLER_2D_ARRAY | GLenum | 是 | +| UNSIGNED_INT_SAMPLER_2D | GLenum | 是 | +| UNSIGNED_INT_SAMPLER_3D | GLenum | 是 | +| UNSIGNED_INT_SAMPLER_CUBE | GLenum | 是 | +| UNSIGNED_INT_SAMPLER_2D_ARRAY | GLenum | 是 | +| DEPTH_COMPONENT32F | GLenum | 是 | +| DEPTH32F_STENCIL8 | GLenum | 是 | +| FLOAT_32_UNSIGNED_INT_24_8_REV | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_RED_SIZE | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_GREEN_SIZE | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_BLUE_SIZE | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE | GLenum | 是 | +| FRAMEBUFFER_DEFAULT | GLenum | 是 | +| UNSIGNED_INT_24_8 | GLenum | 是 | +| DEPTH24_STENCIL8 | GLenum | 是 | +| UNSIGNED_NORMALIZED | GLenum | 是 | +| DRAW_FRAMEBUFFER_BINDING | GLenum | 是 | +| READ_FRAMEBUFFER | GLenum | 是 | +| DRAW_FRAMEBUFFER | GLenum | 是 | +| READ_FRAMEBUFFER_BINDING | GLenum | 是 | +| RENDERBUFFER_SAMPLES | GLenum | 是 | +| FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER | GLenum | 是 | +| MAX_COLOR_ATTACHMENTS | GLenum | 是 | +| COLOR_ATTACHMENT1 | GLenum | 是 | +| COLOR_ATTACHMENT2 | GLenum | 是 | +| COLOR_ATTACHMENT3 | GLenum | 是 | +| COLOR_ATTACHMENT4 | GLenum | 是 | +| COLOR_ATTACHMENT5 | GLenum | 是 | +| COLOR_ATTACHMENT6 | GLenum | 是 | +| COLOR_ATTACHMENT7 | GLenum | 是 | +| COLOR_ATTACHMENT8 | GLenum | 是 | +| COLOR_ATTACHMENT9 | GLenum | 是 | +| COLOR_ATTACHMENT10 | GLenum | 是 | +| COLOR_ATTACHMENT11 | GLenum | 是 | +| COLOR_ATTACHMENT12 | GLenum | 是 | +| COLOR_ATTACHMENT13 | GLenum | 是 | +| COLOR_ATTACHMENT14 | GLenum | 是 | +| COLOR_ATTACHMENT15 | GLenum | 是 | +| FRAMEBUFFER_INCOMPLETE_MULTISAMPLE | GLenum | 是 | +| MAX_SAMPLES | GLenum | 是 | +| HALF_FLOAT | GLenum | 是 | +| RG | GLenum | 是 | +| RG_INTEGER | GLenum | 是 | +| R8 | GLenum | 是 | +| RG8 | GLenum | 是 | +| R16F | GLenum | 是 | +| R32F | GLenum | 是 | +| RG16F | GLenum | 是 | +| RG32F | GLenum | 是 | +| R8I | GLenum | 是 | +| R8UI | GLenum | 是 | +| R16I | GLenum | 是 | +| R16UI | GLenum | 是 | +| R32I | GLenum | 是 | +| R32UI | GLenum | 是 | +| RG8I | GLenum | 是 | +| RG8UI | GLenum | 是 | +| RG16I | GLenum | 是 | +| RG16UI | GLenum | 是 | +| RG32I | GLenum | 是 | +| RG32UI | GLenum | 是 | +| VERTEX_ARRAY_BINDING | GLenum | 是 | +| R8_SNORM | GLenum | 是 | +| RG8_SNORM | GLenum | 是 | +| RGB8_SNORM | GLenum | 是 | +| SIGNED_NORMALIZED | GLenum | 是 | +| COPY_READ_BUFFER | GLenum | 是 | +| COPY_WRITE_BUFFER | GLenum | 是 | +| COPY_READ_BUFFER_BINDING | GLenum | 是 | +| COPY_WRITE_BUFFER_BINDING | GLenum | 是 | +| UNIFORM_BUFFER | GLenum | 是 | +| UNIFORM_BUFFER_BINDING | GLenum | 是 | +| UNIFORM_BUFFER_START | GLenum | 是 | +| UNIFORM_BUFFER_SIZE | GLenum | 是 | +| MAX_VERTEX_UNIFORM_BLOCKS | GLenum | 是 | +| MAX_FRAGMENT_UNIFORM_BLOCKS | GLenum | 是 | +| MAX_COMBINED_UNIFORM_BLOCKS | GLenum | 是 | +| MAX_UNIFORM_BUFFER_BINDINGS | GLenum | 是 | +| MAX_UNIFORM_BLOCK_SIZE | GLenum | 是 | +| MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS | GLenum | 是 | +| MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS | GLenum | 是 | +| UNIFORM_BUFFER_OFFSET_ALIGNMENT | GLenum | 是 | +| ACTIVE_UNIFORM_BLOCKS | GLenum | 是 | +| UNIFORM_TYPE | GLenum | 是 | +| UNIFORM_SIZE | GLenum | 是 | +| UNIFORM_BLOCK_INDEX | GLenum | 是 | +| UNIFORM_OFFSET | GLenum | 是 | +| UNIFORM_ARRAY_STRIDE | GLenum | 是 | +| UNIFORM_MATRIX_STRIDE | GLenum | 是 | +| UNIFORM_IS_ROW_MAJOR | GLenum | 是 | +| UNIFORM_BLOCK_BINDING | GLenum | 是 | +| UNIFORM_BLOCK_DATA_SIZE | GLenum | 是 | +| UNIFORM_BLOCK_ACTIVE_UNIFORMS | GLenum | 是 | +| UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES | GLenum | 是 | +| UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER | GLenum | 是 | +| UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER | GLenum | 是 | +| INVALID_INDEX | GLenum | 是 | +| MAX_VERTEX_OUTPUT_COMPONENTS | GLenum | 是 | +| MAX_FRAGMENT_INPUT_COMPONENTS | GLenum | 是 | +| MAX_SERVER_WAIT_TIMEOUT | GLenum | 是 | +| OBJECT_TYPE | GLenum | 是 | +| SYNC_CONDITION | GLenum | 是 | +| SYNC_STATUS | GLenum | 是 | +| SYNC_FLAGS | GLenum | 是 | +| SYNC_FENCE | GLenum | 是 | +| SYNC_GPU_COMMANDS_COMPLETE | GLenum | 是 | +| UNSIGNALED | GLenum | 是 | +| SIGNALED | GLenum | 是 | +| ALREADY_SIGNALED | GLenum | 是 | +| TIMEOUT_EXPIRED | GLenum | 是 | +| CONDITION_SATISFIED | GLenum | 是 | +| WAIT_FAILED | GLenum | 是 | +| SYNC_FLUSH_COMMANDS_BIT | GLenum | 是 | +| VERTEX_ATTRIB_ARRAY_DIVISOR | GLenum | 是 | +| ANY_SAMPLES_PASSED | GLenum | 是 | +| ANY_SAMPLES_PASSED_CONSERVATIVE | GLenum | 是 | +| SAMPLER_BINDING | GLenum | 是 | +| RGB10_A2UI | GLenum | 是 | +| INT_2_10_10_10_REV | GLenum | 是 | +| TRANSFORM_FEEDBACK | GLenum | 是 | +| TRANSFORM_FEEDBACK_PAUSED | GLenum | 是 | +| TRANSFORM_FEEDBACK_ACTIVE | GLenum | 是 | +| TRANSFORM_FEEDBACK_BINDING | GLenum | 是 | +| TEXTURE_IMMUTABLE_FORMAT | GLenum | 是 | +| MAX_ELEMENT_INDEX | GLenum | 是 | +| TEXTURE_IMMUTABLE_LEVELS | GLenum | 是 | +| TIMEOUT_IGNORED | GLint64 | 是 | +| MAX_CLIENT_WAIT_TIMEOUT_WEBGL | GLenum | 是 | + + +### 方法 + + | 方法 | 返回值类型 | +| -------- | -------- | +| copyBufferSubData(readTarget: GLenum, writeTarget: GLenum, readOffset: GLintptr, writeOffset: GLintptr, size: GLsizeiptr) | void | +| getBufferSubData(target: GLenum, srcByteOffset: GLintptr, dstBuffer: ArrayBufferView, dstOffset?: GLuint, length?: GLuint) | void | +| blitFramebuffer(srcX0: GLint, srcY0: GLint, srcX1: GLint, srcY1: GLint, dstX0: GLint, dstY0: GLint, dstX1: GLint, dstY1: GLint, mask: GLbitfield, filter: GLenum) | void | +| framebufferTextureLayer(target: GLenum, attachment: GLenum, texture: WebGLTexture \| null, level: GLint, layer: GLint) | void | +| invalidateFramebuffer(target: GLenum, attachments: GLenum[]) | void | +| invalidateSubFramebuffer(target: GLenum, attachments: GLenum[], x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | +| readBuffer(src: GLenum) | void | +| getInternalformatParameter(target: GLenum, internalformat: GLenum, pname: GLenum) | any | +| renderbufferStorageMultisample(target: GLenum, samples: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | +| texStorage2D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei) | void | +| texStorage3D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView \| null) | void | +| texImage3D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | +| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView \| null, srcOffset?: GLuint) | void | +| copyTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, x: GLint, y: GLint, width: GLsizei, height: GLsizei) | void | +| compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexImage3D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, depth: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexSubImage3D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, zoffset: GLint, width: GLsizei, height: GLsizei, depth: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| getFragDataLocation(program: WebGLProgram, name: string) | GLint | +| uniform1ui(location: WebGLUniformLocation \| null, v0: GLuint) | void | +| uniform2ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint) | void | +| uniform3ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint, v2: GLuint) | void | +| uniform4ui(location: WebGLUniformLocation \| null, v0: GLuint, v1: GLuint, v2: GLuint, v3: GLuint) | void | +| uniform1uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform2uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform3uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform4uiv(location: WebGLUniformLocation \| null, data: Uint32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix3x2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix4x2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix2x3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix4x3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix2x4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix3x4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| vertexAttribI4i(index: GLuint, x: GLint, y: GLint, z: GLint, w: GLint) | void | +| vertexAttribI4iv(index: GLuint, values: Int32List) | void | +| vertexAttribI4ui(index: GLuint, x: GLuint, y: GLuint, z: GLuint, w: GLuint) | void | +| vertexAttribI4uiv(index: GLuint, values: Uint32List) | void | +| vertexAttribIPointer(index: GLuint, size: GLint, type: GLenum, stride: GLsizei, offset: GLintptr) | void | +| vertexAttribDivisor(index: GLuint, divisor: GLuint) | void | +| drawArraysInstanced(mode: GLenum, first: GLint, count: GLsizei, instanceCount: GLsizei) | void | +| drawElementsInstanced(mode: GLenum, count: GLsizei, type: GLenum, offset: GLintptr, instanceCount: GLsizei) | void | +| drawRangeElements(mode: GLenum, start: GLuint, end: GLuint, count: GLsizei, type: GLenum, offset: GLintptr) | void | +| drawBuffers(buffers: GLenum[]) | void | +| clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Float32List, srcOffset?: GLuint) | void | +| clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Int32List, srcOffset?: GLuint) | void | +| clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Uint32List, srcOffset?: GLuint) | void | +| clearBufferfi(buffer: GLenum, drawbuffer: GLint, depth: GLfloat, stencil: GLint) | void | +| createQuery() | WebGLQuery \| null | +| deleteQuery(query: WebGLQuery \| null) | void | +| isQuery(query: WebGLQuery \| null) | GLboolean | +| beginQuery(target: GLenum, query: WebGLQuery) | void | +| endQuery(target: GLenum) | void | +| getQuery(target: GLenum, pname: GLenum) | WebGLQuery \| null | +| getQueryParameter(query: WebGLQuery, pname: GLenum) | any | +| createSampler() | WebGLSampler \| null | +| deleteSampler(sampler: WebGLSampler \| null) | void | +| isSampler(sampler: WebGLSampler \| null) | GLboolean | +| bindSampler(unit: GLuint, sampler: WebGLSampler \| null) | void | +| samplerParameteri(sampler: WebGLSampler, pname: GLenum, param: GLint) | void | +| samplerParameterf(sampler: WebGLSampler, pname: GLenum, param: GLfloat) | void; | +| getSamplerParameter(sampler: WebGLSampler, pname: GLenum) | any | +| fenceSync(condition: GLenum, flags: GLbitfield) | WebGLSync \| null | +| isSync(sync: WebGLSync \| null) | GLboolean | +| deleteSync(sync: WebGLSync \| null) | void | +| clientWaitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLuint64) | GLenum | +| waitSync(sync: WebGLSync, flags: GLbitfield, timeout: GLint64) | void | +| getSyncParameter(sync: WebGLSync, pname: GLenum) | any | +| createTransformFeedback() | WebGLTransformFeedback \| null | +| deleteTransformFeedback(tf: WebGLTransformFeedback \| null) | void | +| isTransformFeedback(tf: WebGLTransformFeedback \| null) | GLboolean | +| bindTransformFeedback(target: GLenum, tf: WebGLTransformFeedback \| null) | void | +| beginTransformFeedback(primitiveMode: GLenum) | void | +| endTransformFeedback() | void | +| transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: GLenum) | void | +| getTransformFeedbackVarying(program: WebGLProgram, index: GLuint) | WebGLActiveInfo \| null | +| pauseTransformFeedback() | void | +| resumeTransformFeedback() | void | +| bindBufferBase(target: GLenum, index: GLuint, buffer: WebGLBuffer \| null) | void | +| bindBufferRange(target: GLenum, index: GLuint, buffer: WebGLBuffer \| null, offset: GLintptr, size: GLsizeiptr) | void | +| getIndexedParameter(target: GLenum, index: GLuint) | any | +| getUniformIndices(program: WebGLProgram, uniformNames: string[]) | GLuint[] \| null | +| getActiveUniforms(program: WebGLProgram, uniformIndices: GLuint[], pname: GLenum) | any | +| getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string) | GLuint | +| getActiveUniformBlockParameter(program: WebGLProgram, uniformBlockIndex: GLuint, pname: GLenum) | any | +| getActiveUniformBlockName(program: WebGLProgram, uniformBlockIndex: GLuint) | string \| null | +| uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: GLuint, uniformBlockBinding: GLuint) | void | +| createVertexArray() | WebGLVertexArrayObject \| null | +| deleteVertexArray(vertexArray: WebGLVertexArrayObject \| null) | void | +| isVertexArray(vertexArray: WebGLVertexArrayObject \| null) | GLboolean | +| bindVertexArray(array: WebGLVertexArrayObject \| null) | void | + + +## WebGL2RenderingContextOverloads + +WebGL2RenderingContextOverloads + + | 方法 | 返回值类型 | +| -------- | -------- | +| bufferData(target: GLenum, size: GLsizeiptr, usage: GLenum) | void | +| bufferData(target: GLenum, srcData: BufferSource \| null, usage: GLenum) | void | +| bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: BufferSource) | void | +| bufferData(target: GLenum, srcData: ArrayBufferView, usage: GLenum, srcOffset: GLuint, length?: GLuint) | void | +| bufferSubData(target: GLenum, dstByteOffset: GLintptr, srcData: ArrayBufferView, srcOffset: GLuint, length?: GLuint) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pixels: ArrayBufferView \| null) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texImage2D(target: GLenum, level: GLint, internalformat: GLint, width: GLsizei, height: GLsizei, border: GLint, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, pboOffset: GLintptr) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, source: TexImageSource) | void | +| texSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, srcData: ArrayBufferView, srcOffset: GLuint) | void | +| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexImage2D(target: GLenum, level: GLint, internalformat: GLenum, width: GLsizei, height: GLsizei, border: GLint, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, imageSize: GLsizei, offset: GLintptr) | void | +| compressedTexSubImage2D(target: GLenum, level: GLint, xoffset: GLint, yoffset: GLint, width: GLsizei, height: GLsizei, format: GLenum, srcData: ArrayBufferView, srcOffset?: GLuint, srcLengthOverride?: GLuint) | void | +| uniform1fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform2fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform3fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform4fv(location: WebGLUniformLocation \| null, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform1iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform2iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform3iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniform4iv(location: WebGLUniformLocation \| null, data: Int32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix2fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix3fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| uniformMatrix4fv(location: WebGLUniformLocation \| null, transpose: GLboolean, data: Float32List, srcOffset?: GLuint, srcLength?: GLuint) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView \| null) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, offset: GLintptr) | void | +| readPixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format: GLenum, type: GLenum, dstData: ArrayBufferView, dstOffset: GLuint) | void | diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md index 0e14e726a69181d5bed3fb6e3233ea1889010cb1..975ce49cb9e17efb19f024ea0afaeed95936ce51 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-window.md +++ b/zh-cn/application-dev/reference/apis/js-apis-window.md @@ -13,118 +13,152 @@ import window from '@ohos.window'; 窗口类型。 -| 名称 | 默认值 | 说明 | -| ----------------- | ------ | ------------------------------------------------------------ | -| TYPE_APP | 0 | 表示应用子窗口。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| TYPE_SYSTEM_ALERT | 1 | 表示系统告警窗口。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 默认值 | 说明 | +| ----------------- | ------ | ------------------ | +| TYPE_APP | 0 | 表示应用子窗口。 | +| TYPE_SYSTEM_ALERT | 1 | 表示系统告警窗口。 | ## AvoidAreaType7+ 窗口内容需要规避区域的类型。 -| 名称 | 默认值 | 说明 | -| ----------- | ------ | ------------------------------------------------------------ | -| TYPE_SYSTEM | 0 | 表示系统默认区域。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| TYPE_CUTOUT | 1 | 表示刘海屏区域。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 默认值 | 说明 | +| ----------- | ------ | ------------------ | +| TYPE_SYSTEM | 0 | 表示系统默认区域。 | +| TYPE_CUTOUT | 1 | 表示刘海屏区域。 | ## WindowMode7+ 窗口模式。 -| 名称 | 默认值 | 说明 | -| ---------- | ------ | ------------------------------------------------------------ | -| UNDEFINED | 1 | 表示APP未定义窗口模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| FULLSCREEN | 2 | 表示APP全屏模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| PRIMARY | 3 | 表示APP分屏多窗口主要模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| SECONDARY | 4 | 表示APP分屏多窗口次要模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| FLOATING | 5 | 表示APP自由悬浮形式窗口模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +此接口为系统接口,三方应用不支持调用。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 默认值 | 说明 | +| ---------- | ------ | ----------------------------- | +| UNDEFINED | 1 | 表示APP未定义窗口模式。 | +| FULLSCREEN | 2 | 表示APP全屏模式。 | +| PRIMARY | 3 | 表示APP分屏多窗口主要模式。 | +| SECONDARY | 4 | 表示APP分屏多窗口次要模式。 | +| FLOATING | 5 | 表示APP自由悬浮形式窗口模式。 | ## SystemBarProperties 状态栏导航栏的属性。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | -------------------------------------- | -------- | ---- | ---- | ------------------------------------------------------------ | -| statusBarColor | string | 是 | 是 | 状态栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| isStatusBarLightIcon7+ | boolean | 否 | 是 | 状态栏图标是否为高亮状态。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| statusBarContentColor8+ | string | 否 | 是 | 状态栏文字颜色。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| navigationBarColor | string | 是 | 是 | 导航栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| isNavigationBarLightIcon7+ | boolean | 否 | 否 | 导航栏图标是否为高亮状态。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| navigationBarContentColor8+ | string | 否 | 是 | 导航栏文字颜色。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| statusBarColor | string | 是 | 是 | 状态栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。 | +| isStatusBarLightIcon7+ | boolean | 否 | 是 | 状态栏图标是否为高亮状态。 | +| statusBarContentColor8+ | string | 否 | 是 | 状态栏文字颜色。 | +| navigationBarColor | string | 是 | 是 | 导航栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。 | +| isNavigationBarLightIcon7+ | boolean | 否 | 否 | 导航栏图标是否为高亮状态。 | +| navigationBarContentColor8+ | string | 否 | 是 | 导航栏文字颜色。 | ## SystemBarRegionTint 8+ 单个导航栏或状态栏回调信息。 +此接口为系统接口,三方应用不支持调用。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | --------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| type | [WindowType](#windowtype) | 是 | 是 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| isEnable | boolean | 是 | 是 | 当前系统栏是否显示。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| region | [Rect](#rect) | 是 | 是 | 当前系统栏的位置及大小。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| backgroundColor | string | 是 | 是 | 系统栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| contentColor | string | 是 | 是 | 系统栏文字颜色。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| type | [WindowType](#windowtype) | 是 | 是 | 当前属性改变的系统栏类型,仅支持类型为导航栏、状态栏的系统栏。 | +| isEnable | boolean | 是 | 是 | 当前系统栏是否显示。 | +| region | [Rect](#rect) | 是 | 是 | 当前系统栏的位置及大小。 | +| backgroundColor | string | 是 | 是 | 系统栏背景颜色,为16进制RGB或ARGB颜色,例如"\#00FF00"或"\#FF00FF00"。 | +| contentColor | string | 是 | 是 | 系统栏文字颜色。 | ## SystemBarTintState 8+ 当前系统栏回调信息集合。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---------- | -------------------------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| displayId | number | 是 | 否 | 当前物理屏幕id。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| regionTint | Array<[SystemBarRegionTint](#systembartegiontint)> | 是 | 是 | 当前改变所有的系统栏信息。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +此接口为系统接口,三方应用不支持调用。 + +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---------- | -------------------------------------------------- | ---- | ---- | -------------------------- | +| displayId | number | 是 | 否 | 当前物理屏幕id。 | +| regionTint | Array<[SystemBarRegionTint](#systembartegiontint)> | 是 | 是 | 当前改变所有的系统栏信息。 | ## Rect7+ 矩形。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | -| left | number | 是 | 是 | 矩形区域的左边界。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| top | number | 是 | 是 | 矩形区域的上边界。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| width | number | 是 | 是 | 矩形区域的宽度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| height | number | 是 | 是 | 矩形区域的高度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | -------- | ---- | ---- | ------------------ | +| left | number | 是 | 是 | 矩形区域的左边界。 | +| top | number | 是 | 是 | 矩形区域的上边界。 | +| width | number | 是 | 是 | 矩形区域的宽度。 | +| height | number | 是 | 是 | 矩形区域的高度。 | ## AvoidArea7+ 表示窗口内容规避区域。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ---------- | ------------- | ---- | ---- | ------------------------------------------------------------ | -| leftRect | [Rect](#rect) | 是 | 是 | 屏幕左侧的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| topRect | [Rect](#rect) | 是 | 是 | 屏幕顶部的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| rightRect | [Rect](#rect) | 是 | 是 | 屏幕右侧的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| bottomRect | [Rect](#rect) | 是 | 是 | 屏幕底部的矩形区。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ---------- | ------------- | ---- | ---- | ------------------ | +| leftRect | [Rect](#rect) | 是 | 是 | 屏幕左侧的矩形区。 | +| topRect | [Rect](#rect) | 是 | 是 | 屏幕顶部的矩形区。 | +| rightRect | [Rect](#rect) | 是 | 是 | 屏幕右侧的矩形区。 | +| bottomRect | [Rect](#rect) | 是 | 是 | 屏幕底部的矩形区。 | ## Size7+ 窗口大小。 -| 名称 | 参数类型 | 可读 | 可写 | 说明 | -| ------ | -------- | ---- | ---- | ------------------------------------------------------------ | -| width | number | 是 | 是 | 窗口宽度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| height | number | 是 | 是 | 窗口高度。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 参数类型 | 可读 | 可写 | 说明 | +| ------ | -------- | ---- | ---- | ---------- | +| width | number | 是 | 是 | 窗口宽度。 | +| height | number | 是 | 是 | 窗口高度。 | ## WindowProperties 窗口属性。 +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + | 名称 | 参数类型 | 可读 | 可写 | 说明 | | ------------------------------- | ------------------------- | ---- | ---- | ------------------------------------------------------------ | -| windowRect7+ | [Rect](#rect) | 是 | 是 | 窗口尺寸。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| type7+ | [WindowType](#windowtype) | 是 | 是 | 窗口类型。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| isLayoutFullScreen7+ | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| focusable7+ | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| touchable7+ | boolean | 是 | 否 | 窗口是否可触摸,默认为true。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +| windowRect7+ | [Rect](#rect) | 是 | 是 | 窗口尺寸。 | +| type7+ | [WindowType](#windowtype) | 是 | 是 | 窗口类型。 | +| isFullScreen | boolean | 是 | 是 | 是否全屏,默认为false。 | +| isLayoutFullScreen7+ | boolean | 是 | 是 | 窗口是否为沉浸式,默认为false。 | +| focusable7+ | boolean | 是 | 否 | 窗口是否可聚焦,默认为true。 | +| touchable7+ | boolean | 是 | 否 | 窗口是否可触摸,默认为true。 | +| brightness | number | 是 | 是 | 屏幕亮度, 取值范围为0~1,1表示最大亮度值。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| dimBehindValue7+ | number | 是 | 是 | 靠后窗口的暗度值,取值范围为0~1,1表示最暗。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| isKeepScreenOn | boolean | 是 | 是 | 屏幕是否常亮,默认为false。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| isPrivacyMode7+ | boolean | 是 | 是 | 隐私模式,默认为false。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| isRoundCorner7+ | boolean | 是 | 是 | 窗口是否为圆角。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | +| isTransparent7+ | boolean | 是 | 是 | 窗口是否透明。默认为false。
本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 | ## ColorSpace8+ 色域模式。 -| 名称 | 默认值 | 说明 | -| ---------- | ------ | ------------------------------------------------------------ | -| DEFAULT | 0 | 默认色域模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | -| WIDE_GAMUT | 1 | 广色域模式。
**系统能力**:SystemCapability.WindowManager.WindowManager.Core | +**系统能力**:以下各项对应的系统能力均为SystemCapability.WindowManager.WindowManager.Core。 + +| 名称 | 默认值 | 说明 | +| ---------- | ------ | -------------- | +| DEFAULT | 0 | 默认色域模式。 | +| WIDE_GAMUT | 1 | 广色域模式。 | ## window.create7 @@ -145,12 +179,13 @@ create(id: string, type: WindowType, callback: AsyncCallback<Window>): voi - 示例 ``` + var windowClass = null; window.create("first", window.WindowType.TYPE_APP, (err, data) => { - windowClass = data; - if (err) { + if (err.code) { console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); return; } + windowClass = data; console.info('SubWindow created. Data: ' + JSON.stringify(data)) windowClass.resetSize(500, 1000); }); @@ -180,8 +215,10 @@ create(id: string, type: WindowType): Promise<Window> - 示例 ``` + var windowClass = null; let promise = window.create("first", window.WindowType.TYPE_APP); promise.then((data)=> { + windowClass = data; console.info('SubWindow created. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to create the subWindow. Cause: ' + JSON.stringify(err)); @@ -208,12 +245,13 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Wi - 示例 ``` + var windowClass = null; window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT, (err, data) => { - windowClass = data; - if (err) { + if (err.code) { console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); return; } + windowClass = data; console.info('Window created. Data: ' + JSON.stringify(data)) windowClass.resetSize(500, 1000); }); @@ -221,7 +259,7 @@ create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Wi ## window.create8+ -function create(ctx: Context, id: string, type: WindowType): Promise<Window> +create(ctx: Context, id: string, type: WindowType): Promise<Window> 当Context为[ServiceExtensionContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-service-extension-context.md)时,创建系统窗口,使用Promise方式作为异步方法。 @@ -244,8 +282,10 @@ function create(ctx: Context, id: string, type: WindowType): Promise<Window&g - 示例 ``` + var windowClass = null; let promise = window.create(this.context, "alertWindow", window.WindowType.TYPE_SYSTEM_ALERT); promise.then((data)=> { + windowClass = data; console.info('Window created. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to create the Window. Cause: ' + JSON.stringify(err)); @@ -270,13 +310,14 @@ find(id: string, callback: AsyncCallback<Window>): void - 示例 ``` - window.find("first", (err, data) => { - if (err) { + var windowClass = null; + window.find("alertWindow", (err, data) => { + if (err.code) { console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); return; } - console.info('window found. Data: ' + JSON.stringify(data)) - windowClass = data; + windowClass = data; + console.info('window found. Data: ' + JSON.stringify(data)) }); ``` @@ -303,8 +344,10 @@ find(id: string): Promise<Window> - 示例 ``` - let promise = window.find("first"); + var windowClass = null; + let promise = window.find("alertWindow"); promise.then((data)=> { + windowClass = data; console.info('window found. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to find the Window. Cause: ' + JSON.stringify(err)); @@ -328,13 +371,14 @@ getTopWindow(callback: AsyncCallback<Window>): void - 示例 ``` + var windowClass = null; window.getTopWindow((err, data) => { - if (err) { + if (err.code) { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); }); ``` @@ -355,8 +399,10 @@ getTopWindow(): Promise<Window> - 示例 ``` + var windowClass = null; let promise = window.getTopWindow(); promise.then((data)=> { + windowClass = data; console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); @@ -381,13 +427,14 @@ getTopWindow(ctx: Context, callback: AsyncCallback<Window>): void - 示例 ``` + var windowClass = null; window.getTopWindow(this.context, (err, data) => { - if (err) { + if (err.code) { console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); windowClass = data; + console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)); }); ``` @@ -414,8 +461,10 @@ getTopWindow(ctx: Context): Promise<Window> - 示例 ``` + var windowClass = null; let promise = window.getTopWindow(this.context); promise.then((data)=> { + windowClass = data; console.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err)); @@ -428,6 +477,8 @@ on(type: 'systemBarTintChange', callback: Callback<SystemBarTintState>): v 注册状态栏、导航栏的监听函数。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 @@ -452,6 +503,8 @@ off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState >) 关闭监听。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 @@ -478,6 +531,8 @@ hide (callback: AsyncCallback<void>): void 隐藏当前窗口,使用callback方式作为异步方法。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 @@ -489,21 +544,23 @@ hide (callback: AsyncCallback<void>): void - 示例 ``` - windowClass.hide((err) => { - if (err) { + windowClass.hide((err, data) => { + if (err.code) { console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); return; } - console.info('window hidden.') + console.info('window hidden. data: ' + JSON.stringify(data)) }) ``` ### hide7+ -hide(): Promise<void>; +hide(): Promise<void> 隐藏当前窗口,使用Promise方式作为异步方法。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 返回值 @@ -516,8 +573,8 @@ hide(): Promise<void>; ``` let promise = windowClass.hide(); - promise.then(()=> { - console.info('window hidden.') + promise.then((data)=> { + console.info('window hidden. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to hide the window. Cause: ' + JSON.stringify(err)); }) @@ -540,12 +597,12 @@ show(callback: AsyncCallback<void>): void - 示例 ``` - windowClass.show((err) => { - if (err) { + windowClass.show((err, data) => { + if (err.code) { console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in showing the window.') + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)) }) ``` @@ -567,8 +624,8 @@ show(): Promise<void> ``` let promise = windowClass.show(); - promise.then(()=> { - console.info('Succeeded in showing the window.') + promise.then((data)=> { + console.info('Succeeded in showing the window. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to show the window. Cause: ' + JSON.stringify(err)); }) @@ -591,12 +648,12 @@ destroy(callback: AsyncCallback<void>): void - 示例 ``` - windowClass.destroy((err) => { - if (err) { + windowClass.destroy((err, data) => { + if (err.code) { console.error('Failed to destroy the window. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in destroying the window.') + console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) }) ``` @@ -618,8 +675,8 @@ destroy(): Promise<void> ``` let promise = windowClass.destroy(); - promise.then(()=> { - console.info('Succeeded in destroying the window.') + promise.then((data)=> { + console.info('Succeeded in destroying the window. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to destroy the window. Cause: ' + JSON.stringify(err)); }) @@ -644,12 +701,12 @@ moveTo(x: number, y: number, callback: AsyncCallback<void>): void - 示例 ``` - windowClass.moveTo(300, 300, (err)=>{ - if (err) { + windowClass.moveTo(300, 300, (err, data)=>{ + if (err.code) { console.error('Failed to move the window. Cause:' + JSON.stringify(err)); return; } - console.info('Window moved.'); + console.info('Window moved. Data: ' + JSON.stringify(data)) }); ``` @@ -679,8 +736,8 @@ moveTo(x: number, y: number): Promise<void> ``` let promise = windowClass.moveTo(300, 300); - promise.then(()=> { - console.info('Window moved.') + promise.then((data)=> { + console.info('Window moved. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to move the window. Cause: ' + JSON.stringify(err)); }) @@ -705,12 +762,12 @@ resetSize(width: number, height: number, callback: AsyncCallback<void>): v - 示例 ``` - windowClass.resetSize(500, 1000, (err) => { - if (err) { + windowClass.resetSize(500, 1000, (err, data) => { + if (err.code) { console.error('Failed to change the window size. Cause:' + JSON.stringify(err)); return; } - console.info('Window size changed.'); + console.info('Window size changed. Data: ' + JSON.stringify(data)) }); ``` @@ -739,8 +796,8 @@ resetSize(width: number, height: number): Promise<void> ``` let promise = windowClass.resetSize(500, 1000); - promise.then(()=> { - console.info('Window size changed.') + promise.then((data)=> { + console.info('Window size changed. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to change the window size. Cause: ' + JSON.stringify(err)); }); @@ -752,6 +809,8 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void 设置窗口类型,使用callback方式作为异步方法。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 @@ -765,12 +824,12 @@ setWindowType(type: WindowType, callback: AsyncCallback<void>): void ``` var type = window.TYPE_APP; - windowClass.setWindowType(type, (err) => { - if (err) { + windowClass.setWindowType(type, (err, data) => { + if (err.code) { console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window type.') + console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)) }); ``` @@ -780,6 +839,8 @@ setWindowType(type: WindowType): Promise<void> 设置窗口类型,使用Promise方式作为异步方法。 +此接口为系统接口,三方应用不支持调用。 + **系统能力**:SystemCapability.WindowManager.WindowManager.Core - 参数 @@ -799,8 +860,8 @@ setWindowType(type: WindowType): Promise<void> ``` var type = window.TYPE_APP; let promise = windowClass.setWindowType(type); - promise.then(()=> { - console.info('Succeeded in setting the window type.') + promise.then((data)=> { + console.info('Succeeded in setting the window type. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to set the window type. Cause: ' + JSON.stringify(err)); }); @@ -824,7 +885,7 @@ getProperties(callback: AsyncCallback<WindowProperties>): void ``` windowClass.getProperties((err, data) => { - if (err) { + if (err.code) { console.error('Failed to obtain the window properties. Cause: ' + JSON.stringify(err)); return; } @@ -877,7 +938,7 @@ getAvoidArea(type: AvoidAreaType, callback: AsyncCallback<AvoidArea>): voi ``` var type = window.AvoidAreaType.TYPE_SYSTEM; windowClass.getAvoidArea(type, (err, data) => { - if (err) { + if (err.code) { console.error('Failed to obtain the area. Cause:' + JSON.stringify(err)); return; } @@ -935,12 +996,12 @@ setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void ``` var isFullScreen = true; - windowClass.setFullScreen(isFullScreen, (err) => { - if (err) { + windowClass.setFullScreen(isFullScreen, (err, data) => { + if (err.code) { console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in enabling the full-screen mode.'); + console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)) }); ``` @@ -969,8 +1030,8 @@ setFullScreen(isFullScreen: boolean): Promise<void> ``` var isFullScreen = true; let promise = windowClass.setFullScreen(isFullScreen); - promise.then(()=> { - console.info('Succeeded in enabling the full-screen mode.')) + promise.then((data)=> { + console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to enable the full-screen mode. Cause: ' + JSON.stringify(err)); }); @@ -995,12 +1056,12 @@ setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void ``` var isLayoutFullScreen= true; - windowClass.setLayoutFullScreen(isLayoutFullScreen, (err) => { - if (err) { + windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { + if (err.code) { console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the window layout to full-screen mode.'); + console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)) }); ``` @@ -1029,8 +1090,8 @@ setLayoutFullScreen(isLayoutFullScreen: boolean): Promise<void> ``` var isLayoutFullScreen = true; let promise = windowClass.setLayoutFullScreen(isLayoutFullScreen); - promise.then(()=> { - console.info('Succeeded in setting the window layout to full-screen mode.')) + promise.then((data)=> { + console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); }); @@ -1055,12 +1116,12 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>, callback: AsyncCallbac ``` var names = ["status", "navigation"]; - windowClass.setSystemBarEnable(names, (err) => { - if (err) { + windowClass.setSystemBarEnable(names, (err, data) => { + if (err.code) { console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the system bar to be visible.'); + console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)) }); ``` @@ -1089,8 +1150,8 @@ setSystemBarEnable(names: Array<'status' | 'navigation'>): Promise<void> ``` var names = ["status", "navigation"]; let promise = windowClass.setSystemBarEnable(names); - promise.then(()=> { - console.info('Succeeded in setting the system bar to be visible.')) + promise.then((data)=> { + console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); }); @@ -1121,15 +1182,15 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: Async isStatusBarLightIcon: true, isNavigationBarLightIcon:false, //以下两个属性从API Version8开始支持 - statusBarContentColor:'#ffffff' + statusBarContentColor:'#ffffff', navigationBarContentColor:'#00ffff' }; - windowClass.setSystemBarProperties(SystemBarProperties, (err) => { - if (err) { + windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { + if (err.code) { console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); return; } - console.info('Succeeded in setting the system bar properties.'); + console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)) }); ``` @@ -1163,20 +1224,20 @@ setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise<voi isStatusBarLightIcon: true, isNavigationBarLightIcon:false, //以下两个属性从API Version8开始支持 - statusBarContentColor:'#ffffff' + statusBarContentColor:'#ffffff', navigationBarContentColor:'#00ffff' }; let promise = windowClass.setSystemBarProperties(SystemBarProperties); - promise.then(()=> { - console.info('Succeeded in setting the system bar properties.')) + promise.then((data)=> { + console.info('Succeeded in setting the system bar properties. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); }); ``` -### loadContent8+ +### loadContent7+ -loadContent(path: string, storage: ContentStorage, callback: AsyncCallback<void>): void +loadContent(path: string, callback: AsyncCallback<void>): void 当前窗口加载具体页面内容,使用callback方式作为异步方法。 @@ -1187,24 +1248,23 @@ loadContent(path: string, storage: ContentStorage, callback: AsyncCallback<vo | 参数名 | 类型 | 必填 | 说明 | | -------- | ------------------------- | ---- | -------------------- | | path | string | 是 | 设置加载页面的路径。 | - | storage | ContentStorage | 否 | 当前应用内的数据。 | | callback | AsyncCallback<void> | 是 | 回调函数。 | - + - 示例 ``` - windowClass.loadContent("pages/page2/page2", (err) => { - if (err) { + windowClass.loadContent("pages/page2/page2", (err, data) => { + if (err.code) { console.error('Failed to load the content. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in loading the content.'); + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) }); ``` -### loadContent8+ +### loadContent7+ -loadContent(path: string, storage?: ContentStorage): Promise<void> +loadContent(path: string): Promise<void> 当前窗口加载具体页面内容,使用Promise方式作为异步方法。 @@ -1212,11 +1272,10 @@ loadContent(path: string, storage?: ContentStorage): Promise<void> - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | ------- | -------------- | ---- | -------------------- | - | path | string | 是 | 设置加载页面的路径。 | - | storage | ContentStorage | 否 | 当前应用内的数据。 | - + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | -------------------- | + | path | string | 是 | 设置加载页面的路径。 | + - 返回值 | 类型 | 说明 | @@ -1227,8 +1286,8 @@ loadContent(path: string, storage?: ContentStorage): Promise<void> ``` let promise = windowClass.loadContent("pages/page2/page2"); - promise.then(()=> { - console.info('Succeeded in loading the content.')) + promise.then((data)=> { + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to load the content. Cause: ' + JSON.stringify(err)); }); @@ -1251,12 +1310,12 @@ isShowing(callback: AsyncCallback<boolean>): void - 示例 ``` - windowClass.isShowing((err) => { - if (err) { + windowClass.isShowing((err, data) => { + if (err.code) { console.error('Failed to check whether the window is showing. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in checking whether the window is showing. Cause:') + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)) }); ``` @@ -1278,16 +1337,16 @@ isShowing(): Promise<boolean> ``` let promise = windowClass.isShowing(); - promise.then(()=> { - console.info('Succeeded in checking whether the window is showing.') + promise.then((data)=> { + console.info('Succeeded in checking whether the window is showing. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to check whether the window is showing. Cause: ' + JSON.stringify(err)); }); ``` -### on('windowSizeChange'|'systemAvoidAreaChange') +### on('windowSizeChange')7+ -on(type: 'windowSizeChange'|'systemAvoidAreaChange', callback: Callback<AvoidArea | Size>): void +on(type: 'windowSizeChange', callback: Callback<Size>): void 开启监听。 @@ -1295,10 +1354,10 @@ on(type: 'windowSizeChange'|'systemAvoidAreaChange', callback: Callback<Avoid - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | - | type | string | 是 | 设置监听类型。
- type为'windowSizeChange'7+时表示监听类型为窗口尺寸变化监听;
- type为'systemAvoidAreaChange'7+时表示监听类型为系统窗口规避区变化监听。 | - | callback | Callback<[AvoidArea](#avoidarea) \| [Size](#size)> | 是 | 回调返回监听到的信息。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ----------------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'windowSizeChange'时表示监听类型为窗口尺寸变化监听; | + | callback | Callback<[Size](#size)> | 是 | 回调返回监听到的信息。 | - 示例 @@ -1309,9 +1368,9 @@ on(type: 'windowSizeChange'|'systemAvoidAreaChange', callback: Callback<Avoid }); ``` -### off('windowSizeChange'|'systemAvoidAreaChange')7+ +### off('windowSizeChange')7+ -off(type: 'windowSizeChange'|'systemAvoidAreaChange', callback?: Callback<AvoidArea | Size >): void +off(type: 'windowSizeChange', callback?: Callback<Size >): void 关闭监听。 @@ -1319,10 +1378,10 @@ off(type: 'windowSizeChange'|'systemAvoidAreaChange', callback?: Callback<Avo - 参数 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | - | type | string | 是 | 设置监听类型。
- type为'windowSizeChange'7+时表示监听类型为窗口尺寸变化监听;
- type为'systemAvoidAreaChange'7+时表示监听类型为系统窗口规避区变化监听。 | - | callback | Callback<[AvoidArea](#avoidarea) \| [Size](#size)> | 否 | 回调返回监听到的信息。 | + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ----------------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'windowSizeChange'7+时表示监听类型为窗口尺寸变化监听; | + | callback | Callback<[Size](#size)> | 否 | 回调返回监听到的信息。 | - 示例 @@ -1331,6 +1390,102 @@ off(type: 'windowSizeChange'|'systemAvoidAreaChange', callback?: Callback<Avo windowClass.off(type); ``` +### on('systemAvoidAreaChange')7+ + +on(type: 'systemAvoidAreaChange', callback: Callback<AvoidArea>): void + +开启监听。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'systemAvoidAreaChange'时表示监听类型为系统窗口规避区变化监听。 | + | callback | Callback<[AvoidArea](#avoidarea)> | 是 | 回调返回监听到的信息。 | + +- 示例 + + ``` + var type = 'systemAvoidAreaChange'; + windowClass.on(type, (data) => { + console.info('Succeeded in enabling the listener for system avoid area changes. Data: ' + JSON.stringify(data)); + }); + ``` + +### off('systemAvoidAreaChange')7+ + +off(type: 'systemAvoidAreaChange', callback?: Callback<AvoidArea>): void + +关闭监听。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'systemAvoidAreaChange'时表示监听类型为系统窗口规避区变化监听。 | + | callback | Callback<[AvoidArea](#avoidarea)> | 否 | 回调返回监听到的信息。 | + +- 示例 + + ``` + var type = 'systemAvoidAreaChange'; + windowClass.off(type); + ``` + +### on('keyboardHeightChange')7+ + +on(type: 'keyboardHeightChange', callback: Callback<number>): void + +开启键盘高度变化的监听。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'keyboardHeightChange'时表示监听类型为键盘高度变化监听。 | + | callback | Callback<[AvoidArea](#avoidarea)> | 是 | 回调返回监听到的信息。 | + +- 示例 + + ``` + var type = 'keyboardHeightChange'; + windowClass.on(type, (data) => { + console.info('Succeeded in enabling the listener for keyboard height changes. Data: ' + JSON.stringify(data)); + }); + ``` + +### off('keyboardHeightChange')7+ + +off(type: 'keyboardHeightChange', callback?: Callback<number>): void + +关闭键盘高度变化的监听。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ---------------------- | ---- | ------------------------------------------------------------ | + | type | string | 是 | 设置监听类型。
- type为'keyboardHeightChange'时表示监听类型为键盘高度变化监听。 | + | callback | Callback<number> | 否 | 回调返回监听到的信息。 | + +- 示例 + + ``` + var type = 'keyboardHeightChange'; + windowClass.off(type); + ``` + ### isSupportWideGamut8+ isSupportWideGamut(callback: AsyncCallback<boolean>): void @@ -1348,12 +1503,12 @@ isSupportWideGamut(callback: AsyncCallback<boolean>): void - 示例 ``` - windowClass.isSupportWideGamut((err) => { - if (err) { + windowClass.isSupportWideGamut((err, data) => { + if (err.code) { console.error('Failed to check whether the window support WideGamut. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in checking whether the window support WideGamut.') + console.info('Succeeded in checking whether the window support WideGamut Data: ' + JSON.stringify(data)) }) ``` @@ -1375,8 +1530,8 @@ isSupportWideGamut(): Promise<boolean> ``` let promise = windowClass.isSupportWideGamut(); - promise.then(()=> { - console.info('Succeeded in checking whether the window support WideGamut.') + promise.then((data)=> { + console.info('Succeeded in checking whether the window support WideGamut. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to check whether the window support WideGamut. Cause: ' + JSON.stringify(err)); }); @@ -1400,12 +1555,12 @@ setColorSpace(colorSpace:ColorSpace, callback: AsyncCallback<void>): void - 示例 ``` - windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err) => { - if (err) { + windowClass.setColorSpace(window.ColorSpace.WIDE_GAMUT, (err, data) => { + if (err.code) { console.error('Failed to set window colorspace. Cause:' + JSON.stringify(err)); return; } - console.info('Succeeded in setting window colorspace.') + console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)) }) ``` @@ -1433,8 +1588,8 @@ setColorSpace(colorSpace:ColorSpace): Promise<void> ``` let promise = windowClass.isSupportWideGamut(window.ColorSpace.WIDE_GAMUT); - promise.then(()=> { - console.info('Succeeded in setting window colorspace.') + promise.then((data)=> { + console.info('Succeeded in setting window colorspace. Data: ' + JSON.stringify(data)) }).catch((err)=>{ console.error('Failed to set window colorspacet. Cause: ' + JSON.stringify(err)); }); @@ -1458,7 +1613,7 @@ getColorSpace(callback: AsyncCallback<ColorSpace>): void ``` windowClass.getColorSpace((err, data) => { - if (err) { + if (err.code) { console.error('Failed to get window color space. Cause:' + JSON.stringify(err)); return; } @@ -1491,3 +1646,514 @@ getColorSpace(): Promise<ColorSpace> }); ``` +### setBackgroundColor + +setBackgroundColor(color: string, callback: AsyncCallback<void>): void + +设置窗口的背景色,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------- | ------------------------- | ---- | ------------------------------------------------------------ | + | color | string | 是 | 需要设置的背景色,为16进制颜色,例如"#00FF00"或"#FF00FF00"。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var color = '#00ff33'; + windowClass.setBackgroundColor(color, (err, data) => { + if (err.code) { + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)); + }); + ``` + +### setBackgroundColor + +setBackgroundColor(color: string): Promise<void> + +设置窗口的背景色,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ------ | ------ | ---- | ------------------------------------------------------------ | + | color | string | 是 | 需要设置的背景色,为16进制颜色,例如"#00FF00"或"#FF00FF00"。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var color = '#00ff33'; + let promise = windowClass.setBackgroundColor(color); + promise.then((data)=> { + console.info('Succeeded in setting the background color. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the background color. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setBrightness + +setBrightness(brightness: number, callback: AsyncCallback<void>): void + +设置屏幕亮度值,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------------------------- | ---- | ------------------------------------ | + | brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var brightness = 1; + windowClass.setBrightness(brightness, (err, data) => { + if (err.code) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)); + }); + ``` + +### setBrightness + +setBrightness(brightness: number): Promise<void> + +设置屏幕亮度值,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ---------- | ------ | ---- | ------------------------------------ | + | brightness | number | 是 | 屏幕亮度值,值为0-1之间。1表示最亮。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var brightness = 1; + let promise = windowClass.setBrightness(brightness); + promise.then((data)=> { + console.info('Succeeded in setting the brightness. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setDimBehind7+ + +setDimBehind(dimBehindValue: number, callback: AsyncCallback<void>): void + +窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------------------------- | ---- | -------------------------------------------------- | + | dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + windowClass.setDimBehind(0.5, (err, data) => { + if (err.code) { + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the dimness. Data:' + JSON.stringify(data)); + }); + ``` + +### setDimBehind7+ + +setDimBehind(dimBehindValue: number): Promise<void> + +窗口叠加时,设备有子窗口的情况下设置靠后的窗口的暗度值,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------ | ---- | -------------------------------------------------- | + | dimBehindValue | number | 是 | 表示靠后的窗口的暗度值,取值范围为0-1,1表示最暗。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + let promise = windowClass.setDimBehind(0.5); + promise.then((data)=> { + console.info('Succeeded in setting the dimness. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the dimness. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setFocusable7+ + +setFocusable(isFocusable: boolean, callback: AsyncCallback<void>): void + +设置点击时是否支持切换焦点窗口,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | ------------------------- | ---- | ---------------------------- | + | isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var isFocusable= true; + windowClass.setFocusable(isFocusable, (err, data) => { + if (err.code) { + console.error('Failed to set the window to be focusable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)); + }); + ``` + +### setFocusable7+ + +setFocusable(isFocusable: boolean): Promise<void> + +设置点击时是否支持切换焦点窗口,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | ------- | ---- | ---------------------------- | + | isFocusable | boolean | 是 | 点击时是否支持切换焦点窗口。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var isFocusable= true; + let promise = windowClass.setFocusable(isFocusable); + promise.then((data)=> { + console.info('Succeeded in setting the window to be focusable. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the window to be focusable. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setKeepScreenOn + +setKeepScreenOn(isKeepScreenOn: boolean, callback: AsyncCallback<void>): void + +设置屏幕是否为常亮状态,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------------------------- | ---- | ------------------------ | + | isKeepScreenOn | boolean | 是 | 是否设置为屏幕常亮状态。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var isKeepScreenOn = true; + windowClass.setKeepScreenOn(isKeepScreenOn, (err, data) => { + if (err.code) { + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)); + }); + ``` + +### setKeepScreenOn + +setKeepScreenOn(isKeepScreenOn: boolean): Promise<void> + +设置屏幕是否为常亮状态,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | -------------- | ------- | ---- | ------------------------ | + | isKeepScreenOn | boolean | 是 | 是否设置为屏幕常亮状态。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var isKeepScreenOn= true; + let promise = windowClass.setKeepScreenOn(isKeepScreenOn); + promise.then((data)=> { + console.info('Succeeded in setting the screen to be always on. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the screen to be always on. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setOutsideTouchable7+ + +setOutsideTouchable(touchable: boolean, callback: AsyncCallback<void>): void + +设置是否允许可点击子窗口以外的区域,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | ------------------------- | ---- | ---------------- | + | touchable | boolean | 是 | 设置是否可点击。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + windowClass.setOutsideTouchable(true, (err, data) => { + if (err.code) { + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) + }) + ``` + +### setOutsideTouchable7+ + +setOutsideTouchable(touchable: boolean): Promise<void> + +设置是否允许可点击子窗口以外的区域,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | --------- | ------- | ---- | ---------------- | + | touchable | boolean | 是 | 设置是否可点击。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + let promise = windowClass.setOutsideTouchable(true); + promise.then((data)=> { + console.info('Succeeded in setting the area to be touchable. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the area to be touchable. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setPrivacyMode7+ + +setPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void + +设置窗口是否为隐私模式,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ------------- | ------------------------- | ---- | -------------------- | + | isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var isPrivacyMode = true; + windowClass.setPrivacyMode(isPrivacyMode, (err, data) => { + if (err.code) { + console.error('Failed to set the window to privacy mode. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to privacy mode. Data:' + JSON.stringify(data)); + + }); + ``` + +### setPrivacyMode7+ + +setPrivacyMode(isPrivacyMode: boolean): Promise<void> + +设置窗口是否为隐私模式,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ------------- | ------- | ---- | -------------------- | + | isPrivacyMode | boolean | 是 | 窗口是否为隐私模式。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var isPrivacyMode = true; + let promise = windowClass.setPrivacyMode(isPrivacyMode); + promise.then((data)=> { + console.info('Succeeded in setting the window to privacy mode. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the window to privacy mode. Cause: ' + JSON.stringify(err)); + }); + ``` + +### setTouchable7+ + +setTouchable(isTouchable: boolean, callback: AsyncCallback<void>): void + +设置窗口是否为可触状态,使用callback方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | ------------------------- | ---- | -------------------- | + | isTouchable | boolean | 是 | 窗口是否为可触状态。 | + | callback | AsyncCallback<void> | 是 | 回调函数。 | + +- 示例 + + ``` + var isTouchable = true; + windowClass.setTouchable(isTouchable, (err, data) => { + if (err.code) { + console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the window to be touchable. Data:' + JSON.stringify(data)); + + }); + ``` + +### setTouchable7+ + +setTouchable(isTouchable: boolean): Promise<void> + +设置窗口是否为可触状态,使用Promise方式作为异步方法。 + +本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。接口将在OpenHarmony 3.1 MR版本中提供使用支持。 + +**系统能力**:SystemCapability.WindowManager.WindowManager.Core + +- 参数 + + | 参数名 | 类型 | 必填 | 说明 | + | ----------- | ------- | ---- | -------------------- | + | isTouchable | boolean | 是 | 窗口是否为可触状态。 | + +- 返回值 + + | 类型 | 说明 | + | ------------------- | ----------------------------------------------- | + | Promise<void> | 以Promise形式返回结果,返回当前函数执行的结果。 | + +- 示例 + + ``` + var isTouchable = true; + let promise = windowClass.setTouchable(isTouchable); + promise.then((data)=> { + console.info('Succeeded in setting the window to be touchable. Data: ' + JSON.stringify(data)) + }).catch((err)=>{ + console.error('Failed to set the window to be touchable. Cause: ' + JSON.stringify(err)); + }); + ``` + +### \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-zlib.md b/zh-cn/application-dev/reference/apis/js-apis-zlib.md new file mode 100644 index 0000000000000000000000000000000000000000..c23db3897b773977947ff00036821b625845cd0a --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-zlib.md @@ -0,0 +1,161 @@ +# Zip模块(JS端SDK接口) + +## 使用限制 +无。 +## 导入模块 +import zlib from '@ohos.zlib' +## zlib.zipFile +zipFile(inFile:string, outFile:string, options: Options): Promise; +压缩接口(Promise形式)。 + +**系统能力:** SystemCapability.BundleManager.Zlib + +**参数:** + +| 名称 | 类型 | 必填 | 描述 | +| ------- | ----------------------------------- | ---- | ------------------------------------------- | +| inFile | string | 是 | 指定压缩的文件夹路径或者文件路径 | +| outFile | string | 是 | 指定的压缩结果的文件路径(文件的扩展名zip) | +| options | [Options](#options对象可选参数说明) | 否 | 压缩的可选参数 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ---------------------------------------------------- | +| Promise\ | ERROR_CODE_OK:压缩成功 ERROR_CODE_ERRNO:压缩失败 | + +**示例1:** + +```javascript + +//【压缩文件 例子1】 +import zlib from '@ohos.zlib' +var inFile = "/xxx/filename.xxx"; +var outFile = "/xxx/xxx.zip"; +var options = {}; +options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; +options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; +options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; + +zlib.zipFile(inFile, outFile, options).then((data) => { + if (data == zlib.ErrorCode.ERROR_CODE_OK) { + console.log("zipFile OK"); + } else { + console.log("zipFile NG"); + } +}).catch((err)=>{ + console.log("catch((err)=>" + err); +}); + +``` + +**示例2:** + +``` +// 【压缩文件夹 例子2】 +import zlib from '@ohos.zlib' +var inFile = "/xxx/xxx"; +var outFile = "/xxx/xxx.zip"; +var options = {}; +options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; +options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; +options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; + +zlib.zipFile(inFile , unzipDir, options).then((data) => { + if (data == zlib.ErrorCode.ERROR_CODE_OK) { + console.log("zipFile OK"); + } else { + console.log("zipFile NG"); + } +}).catch((err)=>{ + console.log("catch((err)=>" + err); +}); +``` + +## zlib.unzipFile + +unzipFile(inFile:string, outFile:string, options: Options): Promise; + +解压文件,解压完成返回执行结果(Promise形式)。 + +**系统能力:** SystemCapability.BundleManager.Zlib + +**参数:** + +| 名称 | 类型 | 必填 | 描述 | +| ------- | ----------------------------------- | ---- | ----------------------------------- | +| inFile | string | 是 | 指定解压的文件路径(文件扩展名zip) | +| outFile | string | 是 | 指定的解压文件路径 | +| options | [Options](#options对象可选参数说明) | 否 | 解压的可选参数 | + +**返回值:** + +| 类型 | 说明 | +| -------------- | ------------------------------------------------------------ | +| Promise\ | ERROR_CODE_OK:解压成功 ERROR_CODE_ERRNO:解压失败返回执行结果。 | + +**示例:** + +```javascript +// 【解压例子1】 +import zlib from '@ohos.zlib' +var inFile = "/xx/xxx.zip"; +var outFile = "/xxx"; + +var options = {}; +options.level = zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION; +options.memLevel = zlib.MemLevel.MEM_LEVEL_DEFAULT; +options.strategy = zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY; + +zlib.unzipFile(inFile, outFile, options).then((data) => { + if (data == zlib.ErrorCode.ERROR_CODE_OK) { + console.log("unzipFile OK"); + } else { + console.log("unzipFile NG"); + } +}).catch((err)=>{ + console.log("catch((err)=>" + err); +}) + +``` + +## Options对象可选参数说明 + +| 参数 | | +| --------------------------- | ------------------------------------------------------------ | +| level?: CompressLeve | [参考zip.CompressLevel枚举定义](#zip.CompressLevel压缩等级可选参数说明) | +| memLevel?: MemLevel | [参考zip.MemLevel枚举定义](#zip.MemLevel可选参数说明) | +| strategy?: CompressStrategy | [参考zip.CompressStrategy枚举定义](#zip.CompressStrategy压缩策略可选参数说明) | + +## zip.MemLevel可选参数说明 + +| MEM_LEVEL_MIN | zip 接口在压缩过程中最小使用内存 | +| ----------------- | -------------------------------- | +| MEM_LEVEL_MAX | zip 接口在压缩过程中最大使用内存 | +| MEM_LEVEL_DEFAULT | zip 接口在压缩过程中默认使用内存 | + +## zip.CompressLevel压缩等级可选参数说明 + +| 参数 | 描述 | +| --------------------------------------- | ----------------- | +| COMPRESS_LEVEL_NO_COMPRESSION : 0 | 压缩率为0压缩等级 | +| COMPRESS_LEVEL_BEST_SPEED : 1 | 最佳速度压缩等级 | +| COMPRESS_LEVEL_BEST_COMPRESSION :9 | 最佳压缩等级 | +| COMPRESS_LEVEL_DEFAULT_COMPRESSION :-1 | 默认压缩等级 | + +## zip.CompressStrategy压缩策略可选参数说明 + +| 参数 | 描述 | +| -------------------------------------- | ------------------------ | +| COMPRESS_STRATEGY_DEFAULT_STRATEGY : 0 | 常规数据策略 | +| COMPRESS_STRATEGY_FILTERED : 1 | 过滤器产生的数据压缩策略 | +| COMPRESS_STRATEGY_HUFFMAN_ONLY : 2 | 霍夫曼编码格式压缩策略 | +| OMPRESS_STRATEGY_RLE : 3 | 游标编码压缩策略 | +| COMPRESS_STRATEGY_FIXED : 4 | 固定的压缩策略 | + +## zip.ErrorCode接口返回值参数说明 + +| 参数 | 描述 | +| -------------------- | ------------ | +| ERROR_CODE_OK: 0 | 函数调用成功 | +| ERROR_CODE_ERRNO:- 1 | 函数调用失败 | diff --git a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md index b0adfa00699fb5b9d5bb1f98a58fc29b08391073..5053eff042adcc7395f1025b845e834cdec232e9 100644 --- a/zh-cn/application-dev/reference/arkui-js/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-js/Readme-CN.md @@ -1,111 +1,103 @@ -# 基于JS扩展的类Web开发范式 - -- [组件](js-components.md) - - [通用](js-components-common.md) - - [通用属性](js-components-common-attributes.md) - - [通用样式](js-components-common-styles.md) - - [通用事件](js-components-common-events.md) - - [通用方法](js-components-common-methods.md) - - [动画样式](js-components-common-animation.md) - - [渐变样式](js-components-common-gradient.md) - - [转场样式](js-components-common-transition.md) - - [媒体查询](js-components-common-mediaquery.md) - - [自定义字体样式](js-components-common-customizing-font.md) - - [原子布局](js-components-common-atomic-layout.md) - - - [容器组件](js-components-container.md) - - [badge](js-components-container-badge.md) - - [dialog](js-components-container-dialog.md) - - [div](js-components-container-div.md) - - [form](js-components-container-form.md) - - [list](js-components-container-list.md) - - [list-item](js-components-container-list-item.md) - - [list-item-group](js-components-container-list-item-group.md) - - [panel](js-components-container-panel.md) - - [popup](js-components-container-popup.md) - - [refresh](js-components-container-refresh.md) - - [stack](js-components-container-stack.md) - - [stepper](js-components-container-stepper.md) - - [stepper-item](js-components-container-stepper-item.md) - - [swiper](js-components-container-swiper.md) - - [tabs](js-components-container-tabs.md) - - [tab-bar](js-components-container-tab-bar.md) - - [tab-content](js-components-container-tab-content.md) - - - [基础组件](js-components-basic.md) - - [button](js-components-basic-button.md) - - [chart](js-components-basic-chart.md) - - [divider](js-components-basic-divider.md) - - [image](js-components-basic-image.md) - - [image-animator](js-components-basic-image-animator.md) - - [input](js-components-basic-input.md) - - [label](js-components-basic-label.md) - - [marquee](js-components-basic-marquee.md) - - [menu](js-components-basic-menu.md) - - [option](js-components-basic-option.md) - - [picker](js-components-basic-picker.md) - - [picker-view](js-components-basic-picker-view.md) - - [piece](js-components-basic-piece.md) - - [progress](js-components-basic-progress.md) - - [qrcode](js-components-basic-qrcode.md) - - [rating](js-components-basic-rating.md) - - [richtext](js-components-basic-richtext.md) - - [search](js-components-basic-search.md) - - [select](js-components-basic-select.md) - - [slider](js-components-basic-slider.md) - - [span](js-components-basic-span.md) - - [switch](js-components-basic-switch.md) - - [text](js-components-basic-text.md) - - [textarea](js-components-basic-textarea.md) - - [toolbar](js-components-basic-toolbar.md) - - [toolbar-item](js-components-basic-toolbar-item.md) - - [toggle](js-components-basic-toggle.md) - - - [媒体组件](js-components-media.md) - - [video](js-components-media-video.md) - - - [画布组件](js-components-canvas.md) - - [canvas组件](js-components-canvas-canvas.md) - - [CanvasRenderingContext2D对象](js-components-canvas-canvasrenderingcontext2d.md) - - [Image对象](js-components-canvas-image.md) - - [CanvasGradient对象](js-components-canvas-canvasgradient.md) - - [ImageData对象](js-components-canvas-imagedata.md) - - [Path2D对象](js-components-canvas-path2d.md) - - [ImageBitmap对象](js-components-canvas-imagebitmap.md) - - [OffscreenCanvas对象](js-components-canvas-offscreencanvas.md) - - [OffscreenCanvasRenderingContext2D对象](js-offscreencanvasrenderingcontext2d.md) - - - [栅格组件](js-components-grid.md) - - [基本概念](js-components-grid-basic-concepts.md) - - [grid-container](js-components-grid-container.md) - - [grid-row](js-components-grid-row.md) - - [grid-col](js-components-grid-col.md) - - - [svg组件](js-svg.md) - - [通用属性](js-components-svg-common-attributes.md) - - [svg](js-components-svg.md) - - [rect](js-components-svg-rect.md) - - [circle](js-components-svg-circle.md) - - [ellipse](js-components-svg-ellipse.md) - - [path](js-components-svg-path.md) - - [line](js-components-svg-line.md) - - [polyline](js-components-svg-polyline.md) - - [polygon](js-components-svg-polygon.md) - - [text](js-components-svg-text.md) - - [tspan](js-components-svg-tspan.md) - - [textPath](js-components-svg-textpath.md) - - [animate](js-components-svg-animate.md) - - [animateMotion](js-components-svg-animatemotion.md) - - [animateTransform](js-components-svg-animatetransform.md) - -- [自定义组件](js-components-custom.md) - - [基本用法](js-components-custom-basic-usage.md) - - [自定义事件](js-components-custom-events.md) - - [Props](js-components-custom-props.md) - - [事件参数](js-components-custom-event-parameter.md) - - [slot插槽](js-components-custom-slot.md) - - [生命周期定义](js-components-custom-lifecycle.md) - -- [附录](js-appendix.md) - - [类型说明](js-appendix-types.md) +# 基于JS扩展的类Web开发范式 +- 组件 + - 通用 + - [通用属性](js-components-common-attributes.md) + - [通用样式](js-components-common-styles.md) + - [通用事件](js-components-common-events.md) + - [通用方法](js-components-common-methods.md) + - [动画样式](js-components-common-animation.md) + - [渐变样式](js-components-common-gradient.md) + - [转场样式](js-components-common-transition.md) + - [媒体查询](js-components-common-mediaquery.md) + - [自定义字体样式](js-components-common-customizing-font.md) + - [原子布局](js-components-common-atomic-layout.md) + - 容器组件 + - [badge](js-components-container-badge.md) + - [dialog](js-components-container-dialog.md) + - [div](js-components-container-div.md) + - [form](js-components-container-form.md) + - [list](js-components-container-list.md) + - [list-item](js-components-container-list-item.md) + - [list-item-group](js-components-container-list-item-group.md) + - [panel](js-components-container-panel.md) + - [popup](js-components-container-popup.md) + - [refresh](js-components-container-refresh.md) + - [stack](js-components-container-stack.md) + - [stepper](js-components-container-stepper.md) + - [stepper-item](js-components-container-stepper-item.md) + - [swiper](js-components-container-swiper.md) + - [tabs](js-components-container-tabs.md) + - [tab-bar](js-components-container-tab-bar.md) + - [tab-content](js-components-container-tab-content.md) + - 基础组件 + - [button](js-components-basic-button.md) + - [chart](js-components-basic-chart.md) + - [divider](js-components-basic-divider.md) + - [image](js-components-basic-image.md) + - [image-animator](js-components-basic-image-animator.md) + - [input](js-components-basic-input.md) + - [label](js-components-basic-label.md) + - [marquee](js-components-basic-marquee.md) + - [menu](js-components-basic-menu.md) + - [option](js-components-basic-option.md) + - [picker](js-components-basic-picker.md) + - [picker-view](js-components-basic-picker-view.md) + - [piece](js-components-basic-piece.md) + - [progress](js-components-basic-progress.md) + - [qrcode](js-components-basic-qrcode.md) + - [rating](js-components-basic-rating.md) + - [richtext](js-components-basic-richtext.md) + - [search](js-components-basic-search.md) + - [select](js-components-basic-select.md) + - [slider](js-components-basic-slider.md) + - [span](js-components-basic-span.md) + - [switch](js-components-basic-switch.md) + - [text](js-components-basic-text.md) + - [textarea](js-components-basic-textarea.md) + - [toolbar](js-components-basic-toolbar.md) + - [toolbar-item](js-components-basic-toolbar-item.md) + - [toggle](js-components-basic-toggle.md) + - [web](js-components-basic-web.md) + - 媒体组件 + - [video](js-components-media-video.md) + - 画布组件 + - [canvas组件](js-components-canvas-canvas.md) + - [CanvasRenderingContext2D对象](js-components-canvas-canvasrenderingcontext2d.md) + - [Image对象](js-components-canvas-image.md) + - [CanvasGradient对象](js-components-canvas-canvasgradient.md) + - [ImageData对象](js-components-canvas-imagedata.md) + - [Path2D对象](js-components-canvas-path2d.md) + - [ImageBitmap对象](js-components-canvas-imagebitmap.md) + - [OffscreenCanvas对象](js-components-canvas-offscreencanvas.md) + - [OffscreenCanvasRenderingContext2D对象](js-offscreencanvasrenderingcontext2d.md) + - 栅格组件 + - [基本概念](js-components-grid-basic-concepts.md) + - [grid-container](js-components-grid-container.md) + - [grid-row](js-components-grid-row.md) + - [grid-col](js-components-grid-col.md) + - svg组件 + - [通用属性](js-components-svg-common-attributes.md) + - [svg](js-components-svg.md) + - [rect](js-components-svg-rect.md) + - [circle](js-components-svg-circle.md) + - [ellipse](js-components-svg-ellipse.md) + - [path](js-components-svg-path.md) + - [line](js-components-svg-line.md) + - [polyline](js-components-svg-polyline.md) + - [polygon](js-components-svg-polygon.md) + - [text](js-components-svg-text.md) + - [tspan](js-components-svg-tspan.md) + - [textPath](js-components-svg-textpath.md) + - [animate](js-components-svg-animate.md) + - [animateMotion](js-components-svg-animatemotion.md) + - [animateTransform](js-components-svg-animatetransform.md) +- 自定义组件 + - [基本用法](js-components-custom-basic-usage.md) + - [自定义事件](js-components-custom-events.md) + - [Props](js-components-custom-props.md) + - [事件参数](js-components-custom-event-parameter.md) + - [slot插槽](js-components-custom-slot.md) + - [生命周期定义](js-components-custom-lifecycle.md) +- 附录 + - [类型说明](js-appendix-types.md) diff --git a/zh-cn/application-dev/reference/arkui-js/figures/Video_2021-03-26_154549.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125114.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/Video_2021-03-26_154549.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125114.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/tab.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125116.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/tab.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125116.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/textpath-animate1.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125118.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/textpath-animate1.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125118.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/text-animate-part3.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125122.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/text-animate-part3.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125122.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/animate-4.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125126.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/animate-4.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125126.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125174.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125174.png new file mode 100644 index 0000000000000000000000000000000000000000..f1abe2afcb7902557ac3c4f58abfdf333af03121 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125174.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125178.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125178.png new file mode 100644 index 0000000000000000000000000000000000000000..6064f64867e3aca621244e1e6fdb16d3ab2ed748 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125178.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125180.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125180.png new file mode 100644 index 0000000000000000000000000000000000000000..7cc96f8f6364b93923f0a88b895fe6b151080932 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125180.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125184.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125184.png new file mode 100644 index 0000000000000000000000000000000000000000..ecf361e4c749446160da1e8a07169b21d99f362a Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125184.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125188.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125188.png new file mode 100644 index 0000000000000000000000000000000000000000..44e4d991524bd0ef88a0dd10f204e022dd9d0621 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125188.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125190.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125190.png new file mode 100644 index 0000000000000000000000000000000000000000..5e23c304c4911dc0ef487dfeb8d7820aea5fb44b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125190.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/animate-transform2.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125192.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/animate-transform2.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125192.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125194.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125194.png new file mode 100644 index 0000000000000000000000000000000000000000..e370a44cf043fc34bd8891f57faad2cd2ca05707 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125194.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/tspan-part1.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125196.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/tspan-part1.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125196.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/tspan-animate-part2.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125198.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/tspan-animate-part2.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125198.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/tspan-animate-part4.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125200.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/tspan-animate-part4.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125200.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125210.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125210.png new file mode 100644 index 0000000000000000000000000000000000000000..a59bc9cdb0f75ad79e4714d3593216021369c862 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125210.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125214.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125214.png new file mode 100644 index 0000000000000000000000000000000000000000..b3c353b6a872d3597b767f4c216b2d16bfc2139b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125214.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125216.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125216.png new file mode 100644 index 0000000000000000000000000000000000000000..664d13c38389361e61a45870899e2a6f0bfc835f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125216.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125218.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125218.png new file mode 100644 index 0000000000000000000000000000000000000000..1b0ed50716d897398c1e9a741e08ff5f1b9fd9de Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125218.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125222.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125222.png new file mode 100644 index 0000000000000000000000000000000000000000..2dadb92ce56793e2dd693bfa7d99b0c1168130dc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125222.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125224.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125224.png new file mode 100644 index 0000000000000000000000000000000000000000..41be1a646e14511b5d177d11a7bce10deaee5bc9 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125224.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125226.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125226.png new file mode 100644 index 0000000000000000000000000000000000000000..2dadb92ce56793e2dd693bfa7d99b0c1168130dc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125226.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125228.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125228.png new file mode 100644 index 0000000000000000000000000000000000000000..515185ab1b3cf9aaba1204760dae19ab3c112b42 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125228.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125230.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125230.png new file mode 100644 index 0000000000000000000000000000000000000000..984e7a561e661ecefca8b60d5ac239b67f96c98c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125230.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125232.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125232.png new file mode 100644 index 0000000000000000000000000000000000000000..115cb4c96382681743381aeba099549dc24c2ae5 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125232.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125234.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125234.png new file mode 100644 index 0000000000000000000000000000000000000000..af32ecea68c1cef693bcfa379af5ac28f66c1e14 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125234.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125236.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125236.png new file mode 100644 index 0000000000000000000000000000000000000000..63a8c6adc29d340634ed06a1006a0fb56c991a9d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125236.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125238.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125238.png new file mode 100644 index 0000000000000000000000000000000000000000..dfcb0c5e259b3f8d7375c21712249c1e847edd67 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125238.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125240.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125240.png new file mode 100644 index 0000000000000000000000000000000000000000..a9aba5f67b94427168fade014542532431e28a2e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125240.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125242.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125242.png new file mode 100644 index 0000000000000000000000000000000000000000..5c5e360f249a2002ba68ad9b94bd7f66f5d6aab1 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125242.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125244.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125244.png new file mode 100644 index 0000000000000000000000000000000000000000..0d386fef5c4fa9faf1b29c7667c7392db250f2eb Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125244.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125246.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125246.png new file mode 100644 index 0000000000000000000000000000000000000000..7dfc7ee8793298d19c939369ba980abd547982ff Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125246.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125248.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125248.png new file mode 100644 index 0000000000000000000000000000000000000000..4b1948de8581602c6c5879c03d68c14f06eccd00 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125248.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125250.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125250.png new file mode 100644 index 0000000000000000000000000000000000000000..5d0ae86ad14ff863511a10ecc1a85b273e826dfc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125250.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125254.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125254.png new file mode 100644 index 0000000000000000000000000000000000000000..309d1c46f8bc396df5eaed381a5ffa2f0389d602 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125254.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125256.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125256.png new file mode 100644 index 0000000000000000000000000000000000000000..02d5f4e31b020ea9f64e36a7b7cd50299cf3d7f2 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125256.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125258.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125258.png new file mode 100644 index 0000000000000000000000000000000000000000..e9a0799a203fdd7bd41fa5175585dc170a20156e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125258.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125260.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125260.png new file mode 100644 index 0000000000000000000000000000000000000000..ac66614c0f277cd722b3d090cb10efb973152b0f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125260.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125262.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125262.png new file mode 100644 index 0000000000000000000000000000000000000000..131584c72c082f40e2b466e2706c86a05df375e0 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125262.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/gauge.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125264.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/gauge.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127125264.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/textpath-animate4.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284924.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/textpath-animate4.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284924.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/textPath-part4.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284930.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/textPath-part4.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284930.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/sample1.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284934.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/sample1.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284934.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/GIF.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284936.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/GIF.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284936.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/animate-3.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284938.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/animate-3.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284938.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/image-animator.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284946.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/image-animator.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284946.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284968.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284968.png new file mode 100644 index 0000000000000000000000000000000000000000..c0df3f4f7d99f0b8c39995133c71d944bc07ea4b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284968.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284970.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284970.png new file mode 100644 index 0000000000000000000000000000000000000000..1c4f9ae52153198f8690a1066fe66ba8c7bd1ee1 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284970.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284972.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284972.png new file mode 100644 index 0000000000000000000000000000000000000000..69cb300d4bc8decee06c7fb64b03a24287865a8f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284972.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284974.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284974.png new file mode 100644 index 0000000000000000000000000000000000000000..0a5eb251a8d731dc6a9d8b1f31f904c42fd372c3 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284974.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284976.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284976.png new file mode 100644 index 0000000000000000000000000000000000000000..ac0521001d2513fd69e48ce61e1d1128b9d3a6dd Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284976.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/list6.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284978.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/list6.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284978.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284980.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284980.png new file mode 100644 index 0000000000000000000000000000000000000000..4e41450db5d70f6d10d6d7bf59daba33085c177e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284980.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284982.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284982.png new file mode 100644 index 0000000000000000000000000000000000000000..6e4476c4791e37d4681f8e12313ae1cad0887c1b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284982.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284990.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284990.png new file mode 100644 index 0000000000000000000000000000000000000000..4c4c304b67c398f32c5fff516cdde377ca39c73d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284990.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284992.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284992.png new file mode 100644 index 0000000000000000000000000000000000000000..6dc88e656c293c2e65939e4a793684488dfc81be Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284992.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284996.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284996.png new file mode 100644 index 0000000000000000000000000000000000000000..e72165fdf1b24d80f0abde742ad3d848497c6ea7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284996.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284998.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284998.png new file mode 100644 index 0000000000000000000000000000000000000000..57594c6855d4cdf1b37cc3e5354374c9dae0823b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284998.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285000.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285000.png new file mode 100644 index 0000000000000000000000000000000000000000..c89f746719790333bce2bde8c5b8d86102fdfc33 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285000.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285002.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285002.png new file mode 100644 index 0000000000000000000000000000000000000000..8bc3583f82d21c8bec0c70b2da36ed05723fd9a7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285002.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/animate-transform.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285004.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/animate-transform.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285004.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285006.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285006.png new file mode 100644 index 0000000000000000000000000000000000000000..891d52276622fd51893634ce26e08bd56f62b782 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285006.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/tspan-animate-part1.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285008.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/tspan-animate-part1.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285008.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285010.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285010.png new file mode 100644 index 0000000000000000000000000000000000000000..8b3eec4e46f6a29dc47694940ceaef1cfa1314af Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285010.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285012.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285012.png new file mode 100644 index 0000000000000000000000000000000000000000..45467f3e6fc0866b6da0521911bdb5e7d740df29 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285012.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285014.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285014.png new file mode 100644 index 0000000000000000000000000000000000000000..8e195633945b3387c46a7d295862351d4ff1fc64 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285014.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285016.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285016.png new file mode 100644 index 0000000000000000000000000000000000000000..cbc1d312680f479e8c443476ea39eaf1e8a16e55 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285016.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285018.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285018.png new file mode 100644 index 0000000000000000000000000000000000000000..1324b43b3f5b8dd0548cf2069c4c532c5284c445 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285018.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285020.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285020.png new file mode 100644 index 0000000000000000000000000000000000000000..481c833482d38c5f564127c8f412fe3c0275fd24 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285020.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285022.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285022.png new file mode 100644 index 0000000000000000000000000000000000000000..1072a50f468dda3c90c889c31424b7c290eb1a13 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285022.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285026.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285026.png new file mode 100644 index 0000000000000000000000000000000000000000..0d53a47b7eace81d5c7da88c59fee61e30c89681 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285026.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285028.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285028.png new file mode 100644 index 0000000000000000000000000000000000000000..f1abe2afcb7902557ac3c4f58abfdf333af03121 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285028.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285030.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285030.png new file mode 100644 index 0000000000000000000000000000000000000000..64fdda07447707816e8a6238939169f58a4ce58f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285030.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285032.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285032.png new file mode 100644 index 0000000000000000000000000000000000000000..4e41c2cd90ba17798448d70b493ccceb3ac960f0 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285032.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285038.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285038.png new file mode 100644 index 0000000000000000000000000000000000000000..6eb2d41877c85cccfb918b042bc13c81c58ec191 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285038.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285040.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285040.png new file mode 100644 index 0000000000000000000000000000000000000000..2e7cec00f9d186d76ff5cb12d47811084217cc1c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285040.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285042.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285042.png new file mode 100644 index 0000000000000000000000000000000000000000..daa035cea33b810571c18de67e4ac887eeb11850 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285042.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285044.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285044.png new file mode 100644 index 0000000000000000000000000000000000000000..6823cbc9203b07abae455b4ee5c7692878c4be72 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285044.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285046.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285046.png new file mode 100644 index 0000000000000000000000000000000000000000..ca1edf2219980ab9c8533b9fda3219521c50533d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285046.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285048.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285048.png new file mode 100644 index 0000000000000000000000000000000000000000..bf38fe45eaf254939b88b9d2a66635408060acf7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285048.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285050.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285050.png new file mode 100644 index 0000000000000000000000000000000000000000..3e6aaacfe1c26157294e6dedfeaa1488aeed12a3 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285050.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285052.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285052.png new file mode 100644 index 0000000000000000000000000000000000000000..6823cbc9203b07abae455b4ee5c7692878c4be72 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285052.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285054.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285054.png new file mode 100644 index 0000000000000000000000000000000000000000..dfcb0c5e259b3f8d7375c21712249c1e847edd67 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285054.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285056.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285056.png new file mode 100644 index 0000000000000000000000000000000000000000..9114031e04fc28be59e8c9567c0fcfe81a9cc5cb Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285056.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285058.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285058.png new file mode 100644 index 0000000000000000000000000000000000000000..6f085565bd8c64d44bf58ce0969557515ec7ab97 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285058.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285060.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285060.png new file mode 100644 index 0000000000000000000000000000000000000000..93825b7fe53a0794751ee4aa3ca46300c404835e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285060.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285062.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285062.png new file mode 100644 index 0000000000000000000000000000000000000000..c0b21ed6b44c2f756458137f931873f540c16e5f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285062.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285064.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285064.png new file mode 100644 index 0000000000000000000000000000000000000000..b80a6c31cdb287c35965c7841aa97711d79b371c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285064.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285066.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285066.png new file mode 100644 index 0000000000000000000000000000000000000000..bca655617699ef8dc1265bf692a3170c7effe15b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285066.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285068.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285068.png new file mode 100644 index 0000000000000000000000000000000000000000..8a5c7039b580128e75299672dc5438151dcf3572 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285068.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285070.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285070.png new file mode 100644 index 0000000000000000000000000000000000000000..12085848c0f6472d53f7e6504c1924ea6f5a44c1 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285070.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/000000.jpg b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285072.jpg similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/000000.jpg rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127285072.jpg diff --git a/zh-cn/application-dev/reference/arkui-js/figures/menu13.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001131795738.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/menu13.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001131795738.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/c3.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152773860.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/c3.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001152773860.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/1-3.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167662852.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/1-3.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167662852.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/3.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167823076.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/3.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167823076.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/4-0.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167823326.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/4-0.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167823326.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/4.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167846062.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/4.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167846062.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/smoothOff.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167952236.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/smoothOff.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001167952236.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/6.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001168005276.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/6.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001168005276.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/5.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001168440692.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/5.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001168440692.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/textPath-part1.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164775.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/textPath-part1.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164775.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/textpath-animate3.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164779.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/textpath-animate3.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164779.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/text-animate-part2.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164783.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/text-animate-part2.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164783.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/panel6.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164785.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/panel6.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164785.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/1.jpg b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164799.jpg similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/1.jpg rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164799.jpg diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164835.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164835.png new file mode 100644 index 0000000000000000000000000000000000000000..53081e06f458cfc1772de30f669180333b8d783d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164835.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164837.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164837.png new file mode 100644 index 0000000000000000000000000000000000000000..a33c4fce8448e2127b21e277437195ce0002766b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164837.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164841.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164841.png new file mode 100644 index 0000000000000000000000000000000000000000..b234a769d1a9f1f30c4d2127160cf067e9f71ad6 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164841.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164843.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164843.png new file mode 100644 index 0000000000000000000000000000000000000000..3ca3e045717379bb09fa8d13ea0d42019bf546f2 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164843.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164849.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164849.png new file mode 100644 index 0000000000000000000000000000000000000000..069f570291be858a1768b75719a4a6adbd1bdef8 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164849.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164851.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164851.png new file mode 100644 index 0000000000000000000000000000000000000000..c33d763d18f5108bf0eedba19c662d05af397ee9 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164851.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164855.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164855.png new file mode 100644 index 0000000000000000000000000000000000000000..fe422eecde9ec9f1fcac762bd81a23b3fa3abde7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164855.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164859.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164859.gif new file mode 100644 index 0000000000000000000000000000000000000000..2ec52b162dcfdd39c2d2f5a7be4106321935b010 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164859.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/tspan-animate-part3.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164863.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/tspan-animate-part3.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164863.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164865.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164865.png new file mode 100644 index 0000000000000000000000000000000000000000..bc28f5056c679e189543c8ad6fba67fb56db7655 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164865.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164875.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164875.png new file mode 100644 index 0000000000000000000000000000000000000000..9ed54c6c5c5186fb43f24dab24f7689ae0d14a12 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164875.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164877.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164877.png new file mode 100644 index 0000000000000000000000000000000000000000..8442c9b2258c79ee6b6a3d5963df5b792bbb1a16 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164877.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164879.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164879.png new file mode 100644 index 0000000000000000000000000000000000000000..d77ed21418dc3035feb9f9c8e15815e577d71a90 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164879.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164881.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164881.gif new file mode 100644 index 0000000000000000000000000000000000000000..fc1eadbb05520daa6d79779683db96d0afe7cbdd Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164881.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164883.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164883.gif new file mode 100644 index 0000000000000000000000000000000000000000..ba4751108ff3dbaf329d80859bd0a7d371edfb86 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164883.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164885.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164885.png new file mode 100644 index 0000000000000000000000000000000000000000..9c43caf5fdfd466eafc37b793f509a6bde2b885d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164885.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164887.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164887.png new file mode 100644 index 0000000000000000000000000000000000000000..ff0aa71de78cb461a6602398ee915c677efdf3d4 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164887.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164889.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164889.png new file mode 100644 index 0000000000000000000000000000000000000000..04bcf099edface801be6074a33ff33a980c9b606 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164889.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164893.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164893.png new file mode 100644 index 0000000000000000000000000000000000000000..00767e63c899eec52c2c732e834bca8d26d348ce Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164893.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164895.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164895.png new file mode 100644 index 0000000000000000000000000000000000000000..7983d590a2c617c6cad68c90af6b12aa17518810 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164895.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164897.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164897.png new file mode 100644 index 0000000000000000000000000000000000000000..0ac129028e67b43fcae8e3d5c1a539cc45ba6d21 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164897.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164899.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164899.png new file mode 100644 index 0000000000000000000000000000000000000000..800bf296338fd01962f16a8863c37bfe515ce3be Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164899.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164901.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164901.png new file mode 100644 index 0000000000000000000000000000000000000000..d1d37504e15eb6fccd6b1c8e985d37fcc8ba9875 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164901.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164905.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164905.png new file mode 100644 index 0000000000000000000000000000000000000000..c88212b6818d6d18c77ee497cfcafaf661a70d52 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164905.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164907.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164907.png new file mode 100644 index 0000000000000000000000000000000000000000..6a64534a0a867d44cf81c8a34c9981b5fbaf5faf Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164907.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164909.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164909.png new file mode 100644 index 0000000000000000000000000000000000000000..6d795f1618b1546c94266548069eccf9e9af2e01 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164909.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164911.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164911.png new file mode 100644 index 0000000000000000000000000000000000000000..1072a50f468dda3c90c889c31424b7c290eb1a13 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164911.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164913.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164913.png new file mode 100644 index 0000000000000000000000000000000000000000..d62fc7767f7b2e0e8d0d7fed57e30bdf6a6a332f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164913.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164915.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164915.png new file mode 100644 index 0000000000000000000000000000000000000000..87915df37741dacfe9448bfebccf5a88d3ca2a76 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164915.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164917.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164917.png new file mode 100644 index 0000000000000000000000000000000000000000..bdb02fdda28a155e2f622eeea2ff820144780e50 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164917.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164921.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164921.png new file mode 100644 index 0000000000000000000000000000000000000000..39cf9d01563cf63bee003a47cd88258e860a0757 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164921.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164923.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164923.png new file mode 100644 index 0000000000000000000000000000000000000000..f89e20a55ba1e81f2cbda2bd0241edefadbe7149 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164923.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164925.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164925.png new file mode 100644 index 0000000000000000000000000000000000000000..a68e61ab120651294310c5e3632ce22d71917a52 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164925.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/screenshot.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164927.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/screenshot.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164927.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/barchart.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164929.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/barchart.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173164929.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/textPath-part3.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324689.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/textPath-part3.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324689.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/textPath-part2.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324691.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/textPath-part2.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324691.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/textpath-animate2.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324693.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/textpath-animate2.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324693.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/text-part1.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324697.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/text-part1.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324697.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/text-animate-part1.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324699.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/text-animate-part1.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324699.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/animate-1.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324703.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/animate-1.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324703.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/slider.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324709.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/slider.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324709.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324729.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324729.png new file mode 100644 index 0000000000000000000000000000000000000000..c25a692065d473ccf9f5b6d36254787e2497fad6 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324729.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324731.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324731.png new file mode 100644 index 0000000000000000000000000000000000000000..283cf90b3828b36af6fb3a746e806f6715053310 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324731.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324733.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324733.png new file mode 100644 index 0000000000000000000000000000000000000000..858c4187d3a2874f651adc09dcae9a32f8407d86 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324733.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324735.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324735.png new file mode 100644 index 0000000000000000000000000000000000000000..58293d5e874f2aa36ecaf7282ca9e4736318092f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324735.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324737.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324737.png new file mode 100644 index 0000000000000000000000000000000000000000..e863d7a1c3b9c1ca08bd182dce43c55a4866d59b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324737.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324739.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324739.png new file mode 100644 index 0000000000000000000000000000000000000000..486baf6be50982404fd1c68a5bc51db45c62046a Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324739.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324741.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324741.png new file mode 100644 index 0000000000000000000000000000000000000000..93299fc38d761e5251673210c364f6825e319153 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324741.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324743.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324743.png new file mode 100644 index 0000000000000000000000000000000000000000..0491d350277cd67d7774e3761164b9dd7038a117 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324743.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324745.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324745.png new file mode 100644 index 0000000000000000000000000000000000000000..b780eb08852e8916ec6ff1a401ea6946c8d727cf Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324745.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324747.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324747.png new file mode 100644 index 0000000000000000000000000000000000000000..b162dbf0a6c890a03ea1aa0b28bdb454651b697c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324747.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324755.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324755.png new file mode 100644 index 0000000000000000000000000000000000000000..454b1796715794d51e2a1a4649bfafa1bfde80f0 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324755.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324757.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324757.png new file mode 100644 index 0000000000000000000000000000000000000000..a618da21cf6c6d32066286e594921c0fc75b5dba Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324757.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324759.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324759.png new file mode 100644 index 0000000000000000000000000000000000000000..5e23c304c4911dc0ef487dfeb8d7820aea5fb44b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324759.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324761.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324761.png new file mode 100644 index 0000000000000000000000000000000000000000..91a276a7dffb4d98c507e9af6afa1912cca1fed2 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324761.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/animate-transform3.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324765.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/animate-transform3.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324765.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324767.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324767.png new file mode 100644 index 0000000000000000000000000000000000000000..6348bb2b6ee281976f7d58159e4c33db29f542ad Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324767.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324769.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324769.png new file mode 100644 index 0000000000000000000000000000000000000000..1821f9c40ad9d24dc10dc662ecbe7936c9e10633 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324769.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324771.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324771.png new file mode 100644 index 0000000000000000000000000000000000000000..5ee9f7e893611dce988b8aa7ccfe3fab4b9d912f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324771.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324773.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324773.png new file mode 100644 index 0000000000000000000000000000000000000000..21f20a4220aabf9449c707291633e7b3723fe378 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324773.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324775.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324775.png new file mode 100644 index 0000000000000000000000000000000000000000..adca00e684afb79ff4f21313d0586025576a8be1 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324775.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324777.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324777.png new file mode 100644 index 0000000000000000000000000000000000000000..c952585d8032733700b57ce1a919d71ce9a4b58b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324777.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324779.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324779.png new file mode 100644 index 0000000000000000000000000000000000000000..848454297b67eb73ab641424badc438433e24479 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324779.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324781.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324781.png new file mode 100644 index 0000000000000000000000000000000000000000..3621ef6876dbd1103487aed8ff190e6a0204ffde Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324781.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324785.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324785.png new file mode 100644 index 0000000000000000000000000000000000000000..6f5fe69b5a5a62b2d2b719b2be0a17a501363918 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324785.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324789.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324789.png new file mode 100644 index 0000000000000000000000000000000000000000..3e6aaacfe1c26157294e6dedfeaa1488aeed12a3 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324789.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324793.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324793.png new file mode 100644 index 0000000000000000000000000000000000000000..56db1024a714f821528656c64e12520311bae8f5 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324793.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324795.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324795.png new file mode 100644 index 0000000000000000000000000000000000000000..d87462d1cdc9410e91ee050a53d58e71d1c5f312 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324795.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324799.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324799.png new file mode 100644 index 0000000000000000000000000000000000000000..6f929d8ab35b708978d8053047cb56bec4fa83bc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324799.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324801.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324801.png new file mode 100644 index 0000000000000000000000000000000000000000..3fca22c329e9dc9ef73eee20757eac4ce7386842 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324801.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324803.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324803.png new file mode 100644 index 0000000000000000000000000000000000000000..378000d344e90ab4db41869a4612daf6b60d66ab Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324803.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324805.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324805.png new file mode 100644 index 0000000000000000000000000000000000000000..f89943fc98661a6d2b78b5659c41483308a0c54b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324805.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324807.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324807.png new file mode 100644 index 0000000000000000000000000000000000000000..d1ca7dd07fe7812ec1f87bf748595174569a5672 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324807.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324809.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324809.png new file mode 100644 index 0000000000000000000000000000000000000000..5b22707e37ec772dc08a961e557a937862210167 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324809.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324811.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324811.png new file mode 100644 index 0000000000000000000000000000000000000000..3026d3c195598159232b4b1f08e9f198f4b4fa2c Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324811.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324813.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324813.png new file mode 100644 index 0000000000000000000000000000000000000000..51fb00e10bb5c167506ddfae1689b58e368df340 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324813.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324815.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324815.png new file mode 100644 index 0000000000000000000000000000000000000000..6e4476c4791e37d4681f8e12313ae1cad0887c1b Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324815.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324817.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324817.png new file mode 100644 index 0000000000000000000000000000000000000000..04ab7decab16cb7341665c2a67e8d5655a7eed6a Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324817.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324821.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324821.png new file mode 100644 index 0000000000000000000000000000000000000000..db83d39f98583ee653ee39b0237eb55961e539c7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324821.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324823.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324823.png new file mode 100644 index 0000000000000000000000000000000000000000..56d32d4cd371c5374b133cb81c9c077aaf7b110d Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324823.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324825.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324825.png new file mode 100644 index 0000000000000000000000000000000000000000..7cfd4846ca697424582edbfed23ed93ef9e98138 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324825.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324829.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324829.png new file mode 100644 index 0000000000000000000000000000000000000000..6315d4654d04dd6b9b295fa1f8b37e8c550b17cf Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324829.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324831.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324831.png new file mode 100644 index 0000000000000000000000000000000000000000..1e0bad2b2bfed2559e53a8bc21162e6163ec8434 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324831.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324833.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324833.png new file mode 100644 index 0000000000000000000000000000000000000000..0d22570503febc7a7dcba0d1e870f49f32fe489a Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324833.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324835.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324835.png new file mode 100644 index 0000000000000000000000000000000000000000..26f2f228b47b8acb8adcddc3abf9156d6c29364e Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324835.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324837.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324837.png new file mode 100644 index 0000000000000000000000000000000000000000..b54dbc2391d1a8f16312dd02dc3d65a35ea2626f Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324837.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324839.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324839.png new file mode 100644 index 0000000000000000000000000000000000000000..639f16f8aaf261176b3bc760c2eb616ad2f4aa28 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324839.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/sssssss.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324845.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/sssssss.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324845.png diff --git "a/zh-cn/application-dev/reference/arkui-js/figures/\346\215\225\350\216\267.png" b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001177265268.png similarity index 100% rename from "zh-cn/application-dev/reference/arkui-js/figures/\346\215\225\350\216\267.png" rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001177265268.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/11-1.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001177428498.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/11-1.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001177428498.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001179981036.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001179981036.gif new file mode 100644 index 0000000000000000000000000000000000000000..53e718c2879554c82d4a3d9800507a00e37613dc Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001179981036.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001180134670.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001180134670.gif new file mode 100644 index 0000000000000000000000000000000000000000..bd5fea51c64deb1268793f3a3f70a2c379aebfda Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001180134670.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/progress.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001180339632.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/progress.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001180339632.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/001.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001180658376.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/001.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001180658376.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/list.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001185033226.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/list.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001185033226.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001188551432.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001188551432.png new file mode 100644 index 0000000000000000000000000000000000000000..7933730b5753d05a6f5734cb3d7ebb39aeb5f173 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001188551432.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001188711340.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001188711340.png new file mode 100644 index 0000000000000000000000000000000000000000..994f8510b56d1f66d8a40dbd0349ca61baf242cb Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001188711340.png differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/222.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001189854534.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/222.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001189854534.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/111.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001190934502.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/111.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001190934502.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/mmmm.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001191939702.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/mmmm.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001191939702.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/grid.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001192960596.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/grid.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001192960596.gif diff --git "a/zh-cn/application-dev/reference/arkui-js/figures/\345\215\241\347\211\207\350\275\254\345\234\272.gif" b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001193544358.gif similarity index 100% rename from "zh-cn/application-dev/reference/arkui-js/figures/\345\215\241\347\211\207\350\275\254\345\234\272.gif" rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001193544358.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/1-2.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001198530395.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/1-2.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001198530395.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001198898293.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001207995958.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001198898293.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001207995958.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324749.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001208155956.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324749.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001208155956.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324751.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001208315918.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001173324751.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001208315918.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/0.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001212053183.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/0.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001212053183.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/2.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001213103299.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/2.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001213103299.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/11.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001213276619.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/11.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001213276619.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/9.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001213284927.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/9.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001213284927.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/2-4.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001213381209.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/2-4.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001213381209.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/22.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001213396721.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/22.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001213396721.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/ellipse.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214823665.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/ellipse.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001214823665.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/12.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001222948301.gif similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/12.gif rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001222948301.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001224225943.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001224225943.gif new file mode 100644 index 0000000000000000000000000000000000000000..e64a81a267d1cb0f6f216caa7cefe75020850e75 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001224225943.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001225204601.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001225204601.gif new file mode 100644 index 0000000000000000000000000000000000000000..2215e5cfa56f533c6b4d1318b2fa1fb07093dfaa Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001225204601.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001225418523.gif b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001225418523.gif new file mode 100644 index 0000000000000000000000000000000000000000..3b6df4b26274fdf5c3e6e1fab2423400455b7050 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001225418523.gif differ diff --git "a/zh-cn/application-dev/reference/arkui-js/figures/AnimationAPI\350\243\201\345\211\252.gif" b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001229677045.gif similarity index 100% rename from "zh-cn/application-dev/reference/arkui-js/figures/AnimationAPI\350\243\201\345\211\252.gif" rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001229677045.gif diff --git a/zh-cn/application-dev/reference/arkui-js/figures/333.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001236694521.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/333.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001236694521.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/444.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001237134475.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/444.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001237134475.png diff --git "a/zh-cn/application-dev/reference/arkui-js/figures/\345\205\261\344\272\253\345\205\203\347\264\240\350\275\254\345\234\272\351\273\230\350\256\244\346\225\210\346\236\234.png" b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001238424309.png similarity index 100% rename from "zh-cn/application-dev/reference/arkui-js/figures/\345\205\261\344\272\253\345\205\203\347\264\240\350\275\254\345\234\272\351\273\230\350\256\244\346\225\210\346\236\234.png" rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001238424309.png diff --git a/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284984.png b/zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001252835901.png similarity index 100% rename from zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001127284984.png rename to zh-cn/application-dev/reference/arkui-js/figures/zh-cn_image_0000001252835901.png diff --git a/zh-cn/application-dev/reference/arkui-js/js-appendix-types.md b/zh-cn/application-dev/reference/arkui-js/js-appendix-types.md index 48589bfa9b3bf27a18c47763a4ca587f169ad670..eaec4b89c7e510cad40d6af970f59cbb0f051052 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-appendix-types.md +++ b/zh-cn/application-dev/reference/arkui-js/js-appendix-types.md @@ -2,1094 +2,166 @@ ## 长度类型 - - - - - - - - - - - - - - -

名称

-

类型定义

-

描述

-

length

-

string | number

-

用于描述尺寸单位,输入为number类型时,使用px单位;输入为string类型时,需要显式指定像素单位,当前支持的像素单位有:

-
  • px:逻辑尺寸单位。
  • fp6+:字体尺寸单位,会随系统字体大小设置发生变化,仅支持文本类组件设置相应的字体大小。
-

percentage

-

string

-

百分比尺寸单位,如“50%”。

-
+| 名称 | 类型定义 | 描述 | +| -------- | -------- | -------- | +| length | string \| number | 用于描述尺寸单位,输入为number类型时,使用px单位;输入为string类型时,需要显式指定像素单位,当前支持的像素单位有:
- px:逻辑尺寸单位。
- fp6+:字体尺寸单位,会随系统字体大小设置发生变化,仅支持文本类组件设置相应的字体大小。 | +| percentage | string | 百分比尺寸单位,如“50%”。 | + ## 颜色类型 - - - - - - - - - - -

名称

-

类型定义

-

描述

-

color

-

string | 颜色枚举字符串

-

用于描述颜色信息。

-
字符串格式如下:
  • 'rgb(255, 255, 255)'
  • 'rgba(255, 255, 255, 1.0)'
  • HEX格式:'#rrggbb','#aarrggbb'
  • 枚举格式:'black','white'。
    说明:

    JS脚本中不支持颜色枚举格式。

    -
    -
-
-
+| 名称 | 类型定义 | 描述 | +| -------- | -------- | -------- | +| color | string \|颜色枚举字符串 | 用于描述颜色信息。
字符串格式如下:
- 'rgb(255, 255, 255)'
- 'rgba(255, 255, 255, 1.0)'
- HEX格式:'\#rrggbb','\#aarrggbb'
- 枚举格式:'black','white'。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > JS脚本中不支持颜色枚举格式。 | -**表 1** 当前支持的颜色枚举 +**表1** 当前支持的颜色枚举 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

枚举名称

-

对应颜色

-

颜色

-

aliceblue

-

#f0f8ff

-

-

antiquewhite

-

#faebd7

-

-

aqua

-

#00ffff

-

-

aquamarine

-

#7fffd4

-

-

azure

-

#f0ffff

-

-

beige

-

#f5f5dc

-

-

bisque

-

#ffe4c4

-

-

black

-

#000000

-

-

blanchedalmond

-

#ffebcd

-

-

blue

-

#0000ff

-

-

blueviolet

-

#8a2be2

-

-

brown

-

#a52a2a

-

-

burlywood

-

#deB887

-

-

cadetblue

-

#5f9ea0

-

-

chartreuse

-

#7fff00

-

-

chocolate

-

#d2691e

-

-

coral

-

#ff7f50

-

-

cornflowerblue

-

#6495ed

-

-

cornsilk

-

#fff8dc

-

-

crimson

-

#dc143c

-

-

cyan

-

#00ffff

-

-

darkblue

-

#00008b

-

-

darkcyan

-

#008b8b

-

-

darkgoldenrod

-

#b8860b

-

-

darkgray

-

#a9a9a9

-

-

darkgreen

-

#006400

-

-

darkgrey

-

#a9a9a9

-

-

darkkhaki

-

#bdb76b

-

-

darkmagenta

-

#8b008b

-

-

darkolivegreen

-

#556b2f

-

-

darkorange

-

#ff8c00

-

-

darkorchid

-

#9932cc

-

-

darkred

-

#8b0000

-

-

darksalmon

-

#e9967a

-

-

darkseagreen

-

#8fbc8f

-

-

darkslateblue

-

#483d8b

-

-

darkslategray

-

#2f4f4f

-

-

darkslategrey

-

#2f4f4f

-

-

darkturquoise

-

#00ced1

-

-

darkviolet

-

#9400d3

-

-

deeppink

-

#ff1493

-

-

deepskyblue

-

#00bfff

-

-

dimgray

-

#696969

-

-

dimgrey

-

#696969

-

-

dodgerblue

-

#1e90ff

-

-

firebrick

-

#b22222

-

-

floralwhite

-

#fffaf0

-

-

forestgreen

-

#228b22

-

-

fuchsia

-

#ff00ff

-

-

gainsboro

-

#dcdcdc

-

-

ghostwhite

-

#f8f8ff

-

-

gold

-

#ffd700

-

-

goldenrod

-

#daa520

-

-

gray

-

#808080

-

-

green

-

#008000

-

-

greenyellow

-

#adff2f

-

-

grey

-

#808080

-

-

honeydew

-

#f0fff0

-

-

hotpink

-

#ff69b4

-

-

indianred

-

#cd5c5c

-

-

indigo

-

#4b0082

-

-

ivory

-

#fffff0

-

-

khaki

-

#f0e68c

-

-

lavender

-

#e6e6fa

-

-

lavenderblush

-

#fff0f5

-

-

lawngreen

-

#7cfc00

-

-

lemonchiffon

-

#fffacd

-

-

lightblue

-

#add8e6

-

-

lightcoral

-

#f08080

-

-

lightcyan

-

#e0ffff

-

-

lightgoldenrodyellow

-

#fafad2

-

-

lightgray

-

#d3d3d3

-

-

lightgreen

-

#90ee90

-

-

lightpink

-

#ffb6c1

-

-

lightsalmon

-

#ffa07a

-

-

lightseagreen

-

#20b2aa

-

-

lightskyblue

-

#87cefa

-

-

lightslategray

-

#778899

-

-

lightslategrey

-

#778899

-

-

lightsteelblue

-

#b0c4de

-

-

lightyellow

-

#ffffe0

-

-

lime

-

#00ff00

-

-

limegreen

-

#32cd32

-

-

linen

-

#faf0e6

-

-

magenta

-

#ff00ff

-

-

maroon

-

#800000

-

-

mediumaquamarine

-

#66cdaa

-

-

mediumblue

-

#0000cd

-

-

mediumorchid

-

#ba55d3

-

-

mediumpurple

-

#9370db

-

-

mediumseagreen

-

#3cb371

-

-

mediumslateblue

-

#7b68ee

-

-

mediumspringgreen

-

#00fa9a

-

-

mediumturquoise

-

#48d1cc

-

-

mediumvioletred

-

#c71585

-

-

midnightblue

-

#191970

-

-

mintcream

-

#f5fffa

-

-

mistyrose

-

#ffe4e1

-

-

moccasin

-

#ffe4b5

-

-

navajowhite

-

#ffdead

-

-

navy

-

#000080

-

-

oldlace

-

#fdf5e6

-

-

olive

-

#808000

-

-

olivedrab

-

#6b8e23

-

-

orange

-

#ffa500

-

-

orangered

-

#ff4500

-

-

orchid

-

#da70d6

-

-

palegoldenrod

-

#eee8aa

-

-

palegreen

-

#98fb98

-

-

paleturquoise

-

#afeeee

-

-

palevioletred

-

#db7093

-

-

papayawhip

-

#ffefd5

-

-

peachpuff

-

#ffdab9

-

-

peru

-

#cd853f

-

-

pink

-

#ffc0cb

-

-

plum

-

#dda0dd

-

-

powderblue

-

#b0e0e6

-

-

purple

-

#800080

-

-

rebeccapurple

-

#663399

-

-

red

-

#ff0000

-

-

rosybrown

-

#bc8f8f

-

-

royalblue

-

#4169e1

-

-

saddlebrown

-

#8b4513

-

-

salmon

-

#fa8072

-

-

sandybrown

-

#f4a460

-

-

seagreen

-

#2e8b57

-

-

seashell

-

#fff5ee

-

-

sienna

-

#a0522d

-

-

silver

-

#c0c0c0

-

-

skyblue

-

#87ceeb

-

-

slateblue

-

#6a5acd

-

-

slategray

-

#708090

-

-

slategrey

-

#708090

-

-

snow

-

#fffafa

-

-

springgreen

-

#00ff7f

-

-

steelblue

-

#4682b4

-

-

tan

-

#d2b48c

-

-

teal

-

#008080

-

-

thistle

-

#d8Bfd8

-

-

tomato

-

#ff6347

-

-

turquoise

-

#40e0d0

-

-

violet

-

#ee82ee

-

-

wheat

-

#f5deb3

-

-

white

-

#ffffff

-

-

whitesmoke

-

#f5f5f5

-

-

yellow

-

#ffff00

-

-

yellowgreen

-

#9acd32

-

-
+| 枚举名称 | 对应颜色 | 颜色 | +| -------- | -------- | -------- | +| aliceblue | \#f0f8ff | ![zh-cn_image_0000001173324803](figures/zh-cn_image_0000001173324803.png) | +| antiquewhite | \#faebd7 | ![zh-cn_image_0000001127285014](figures/zh-cn_image_0000001127285014.png) | +| aqua | \#00ffff | ![zh-cn_image_0000001127285050](figures/zh-cn_image_0000001127285050.png) | +| aquamarine | \#7fffd4 | ![zh-cn_image_0000001173324729](figures/zh-cn_image_0000001173324729.png) | +| azure | \#f0ffff | ![zh-cn_image_0000001127285040](figures/zh-cn_image_0000001127285040.png) | +| beige | \#f5f5dc | ![zh-cn_image_0000001173324773](figures/zh-cn_image_0000001173324773.png) | +| bisque | \#ffe4c4 | ![zh-cn_image_0000001173164895](figures/zh-cn_image_0000001173164895.png) | +| black | \#000000 | ![zh-cn_image_0000001173324735](figures/zh-cn_image_0000001173324735.png) | +| blanchedalmond | \#ffebcd | ![zh-cn_image_0000001173164889](figures/zh-cn_image_0000001173164889.png) | +| blue | \#0000ff | ![zh-cn_image_0000001127125194](figures/zh-cn_image_0000001127125194.png) | +| blueviolet | \#8a2be2 | ![zh-cn_image_0000001127285046](figures/zh-cn_image_0000001127285046.png) | +| brown | \#a52a2a | ![zh-cn_image_0000001173324833](figures/zh-cn_image_0000001173324833.png) | +| burlywood | \#deB887 | ![zh-cn_image_0000001127285026](figures/zh-cn_image_0000001127285026.png) | +| cadetblue | \#5f9ea0 | ![zh-cn_image_0000001127125210](figures/zh-cn_image_0000001127125210.png) | +| chartreuse | \#7fff00 | ![zh-cn_image_0000001173324811](figures/zh-cn_image_0000001173324811.png) | +| chocolate | \#d2691e | ![zh-cn_image_0000001127125256](figures/zh-cn_image_0000001127125256.png) | +| coral | \#ff7f50 | ![zh-cn_image_0000001173164877](figures/zh-cn_image_0000001173164877.png) | +| cornflowerblue | \#6495ed | ![zh-cn_image_0000001173324781](figures/zh-cn_image_0000001173324781.png) | +| cornsilk | \#fff8dc | ![zh-cn_image_0000001127285048](figures/zh-cn_image_0000001127285048.png) | +| crimson | \#dc143c | ![zh-cn_image_0000001127285066](figures/zh-cn_image_0000001127285066.png) | +| cyan | \#00ffff | ![zh-cn_image_0000001173324789](figures/zh-cn_image_0000001173324789.png) | +| darkblue | \#00008b | ![zh-cn_image_0000001173164841](figures/zh-cn_image_0000001173164841.png) | +| darkcyan | \#008b8b | ![zh-cn_image_0000001173324745](figures/zh-cn_image_0000001173324745.png) | +| darkgoldenrod | \#b8860b | ![zh-cn_image_0000001173324835](figures/zh-cn_image_0000001173324835.png) | +| darkgray | \#a9a9a9 | ![zh-cn_image_0000001127285028](figures/zh-cn_image_0000001127285028.png) | +| darkgreen | \#006400 | ![zh-cn_image_0000001127284990](figures/zh-cn_image_0000001127284990.png) | +| darkgrey | \#a9a9a9 | ![zh-cn_image_0000001127125174](figures/zh-cn_image_0000001127125174.png) | +| darkkhaki | \#bdb76b | ![zh-cn_image_0000001127285070](figures/zh-cn_image_0000001127285070.png) | +| darkmagenta | \#8b008b | ![zh-cn_image_0000001173164875](figures/zh-cn_image_0000001173164875.png) | +| darkolivegreen | \#556b2f | ![zh-cn_image_0000001173164835](figures/zh-cn_image_0000001173164835.png) | +| darkorange | \#ff8c00 | ![zh-cn_image_0000001127125178](figures/zh-cn_image_0000001127125178.png) | +| darkorchid | \#9932cc | ![zh-cn_image_0000001173324829](figures/zh-cn_image_0000001173324829.png) | +| darkred | \#8b0000 | ![zh-cn_image_0000001173164851](figures/zh-cn_image_0000001173164851.png) | +| darksalmon | \#e9967a | ![zh-cn_image_0000001127284998](figures/zh-cn_image_0000001127284998.png) | +| darkseagreen | \#8fbc8f | ![zh-cn_image_0000001173324755](figures/zh-cn_image_0000001173324755.png) | +| darkslateblue | \#483d8b | ![zh-cn_image_0000001127125246](figures/zh-cn_image_0000001127125246.png) | +| darkslategray | \#2f4f4f | ![zh-cn_image_0000001127125190](figures/zh-cn_image_0000001127125190.png) | +| darkslategrey | \#2f4f4f | ![zh-cn_image_0000001173324759](figures/zh-cn_image_0000001173324759.png) | +| darkturquoise | \#00ced1 | ![zh-cn_image_0000001127284980](figures/zh-cn_image_0000001127284980.png) | +| darkviolet | \#9400d3 | ![zh-cn_image_0000001127285058](figures/zh-cn_image_0000001127285058.png) | +| deeppink | \#ff1493 | ![zh-cn_image_0000001173324767](figures/zh-cn_image_0000001173324767.png) | +| deepskyblue | \#00bfff | ![zh-cn_image_0000001173164897](figures/zh-cn_image_0000001173164897.png) | +| dimgray | \#696969 | ![zh-cn_image_0000001127285022](figures/zh-cn_image_0000001127285022.png) | +| dimgrey | \#696969 | ![zh-cn_image_0000001173164911](figures/zh-cn_image_0000001173164911.png) | +| dodgerblue | \#1e90ff | ![zh-cn_image_0000001173164855](figures/zh-cn_image_0000001173164855.png) | +| firebrick | \#b22222 | ![zh-cn_image_0000001127125234](figures/zh-cn_image_0000001127125234.png) | +| floralwhite | \#fffaf0 | ![zh-cn_image_0000001173324771](figures/zh-cn_image_0000001173324771.png) | +| forestgreen | \#228b22 | ![zh-cn_image_0000001173324825](figures/zh-cn_image_0000001173324825.png) | +| fuchsia | \#ff00ff | ![zh-cn_image_0000001127285052](figures/zh-cn_image_0000001127285052.png) | +| gainsboro | \#dcdcdc | ![zh-cn_image_0000001173164901](figures/zh-cn_image_0000001173164901.png) | +| ghostwhite | \#f8f8ff | ![zh-cn_image_0000001127285012](figures/zh-cn_image_0000001127285012.png) | +| gold | \#ffd700 | ![zh-cn_image_0000001173324761](figures/zh-cn_image_0000001173324761.png) | +| goldenrod | \#daa520 | ![zh-cn_image_0000001173324817](figures/zh-cn_image_0000001173324817.png) | +| gray | \#808080 | ![zh-cn_image_0000001127125238](figures/zh-cn_image_0000001127125238.png) | +| green | \#008000 | ![zh-cn_image_0000001173164865](figures/zh-cn_image_0000001173164865.png) | +| greenyellow | \#adff2f | ![zh-cn_image_0000001127285000](figures/zh-cn_image_0000001127285000.png) | +| grey | \#808080 | ![zh-cn_image_0000001127285054](figures/zh-cn_image_0000001127285054.png) | +| honeydew | \#f0fff0 | ![zh-cn_image_0000001173324813](figures/zh-cn_image_0000001173324813.png) | +| hotpink | \#ff69b4 | ![zh-cn_image_0000001127285016](figures/zh-cn_image_0000001127285016.png) | +| indianred | \#cd5c5c | ![zh-cn_image_0000001173164849](figures/zh-cn_image_0000001173164849.png) | +| indigo | \#4b0082 | ![zh-cn_image_0000001173324821](figures/zh-cn_image_0000001173324821.png) | +| ivory | \#fffff0 | ![zh-cn_image_0000001173164887](figures/zh-cn_image_0000001173164887.png) | +| khaki | \#f0e68c | ![zh-cn_image_0000001173324801](figures/zh-cn_image_0000001173324801.png) | +| lavender | \#e6e6fa | ![zh-cn_image_0000001127125188](figures/zh-cn_image_0000001127125188.png) | +| lavenderblush | \#fff0f5 | ![zh-cn_image_0000001173324809](figures/zh-cn_image_0000001173324809.png) | +| lawngreen | \#7cfc00 | ![zh-cn_image_0000001127125224](figures/zh-cn_image_0000001127125224.png) | +| lemonchiffon | \#fffacd | ![zh-cn_image_0000001173164879](figures/zh-cn_image_0000001173164879.png) | +| lightblue | \#add8e6 | ![zh-cn_image_0000001127125180](figures/zh-cn_image_0000001127125180.png) | +| lightcoral | \#f08080 | ![zh-cn_image_0000001127125228](figures/zh-cn_image_0000001127125228.png) | +| lightcyan | \#e0ffff | ![zh-cn_image_0000001173324799](figures/zh-cn_image_0000001173324799.png) | +| lightgoldenrodyellow | \#fafad2 | ![zh-cn_image_0000001127125218](figures/zh-cn_image_0000001127125218.png) | +| lightgray | \#d3d3d3 | ![zh-cn_image_0000001127284974](figures/zh-cn_image_0000001127284974.png) | +| lightgreen | \#90ee90 | ![zh-cn_image_0000001173324805](figures/zh-cn_image_0000001173324805.png) | +| lightpink | \#ffb6c1 | ![zh-cn_image_0000001127285038](figures/zh-cn_image_0000001127285038.png) | +| lightsalmon | \#ffa07a | ![zh-cn_image_0000001173324795](figures/zh-cn_image_0000001173324795.png) | +| lightseagreen | \#20b2aa | ![zh-cn_image_0000001173324737](figures/zh-cn_image_0000001173324737.png) | +| lightskyblue | \#87cefa | ![zh-cn_image_0000001127285042](figures/zh-cn_image_0000001127285042.png) | +| lightslategray | \#778899 | ![zh-cn_image_0000001127125226](figures/zh-cn_image_0000001127125226.png) | +| lightslategrey | \#778899 | ![zh-cn_image_0000001127125222](figures/zh-cn_image_0000001127125222.png) | +| lightsteelblue | \#b0c4de | ![zh-cn_image_0000001127284976](figures/zh-cn_image_0000001127284976.png) | +| lightyellow | \#ffffe0 | ![zh-cn_image_0000001173324807](figures/zh-cn_image_0000001173324807.png) | +| lime | \#00ff00 | ![zh-cn_image_0000001127285020](figures/zh-cn_image_0000001127285020.png) | +| limegreen | \#32cd32 | ![zh-cn_image_0000001127125236](figures/zh-cn_image_0000001127125236.png) | +| linen | \#faf0e6 | ![zh-cn_image_0000001173324739](figures/zh-cn_image_0000001173324739.png) | +| magenta | \#ff00ff | ![zh-cn_image_0000001127285044](figures/zh-cn_image_0000001127285044.png) | +| maroon | \#800000 | ![zh-cn_image_0000001127285018](figures/zh-cn_image_0000001127285018.png) | +| mediumaquamarine | \#66cdaa | ![zh-cn_image_0000001173164899](figures/zh-cn_image_0000001173164899.png) | +| mediumblue | \#0000cd | ![zh-cn_image_0000001127284968](figures/zh-cn_image_0000001127284968.png) | +| mediumorchid | \#ba55d3 | ![zh-cn_image_0000001127125216](figures/zh-cn_image_0000001127125216.png) | +| mediumpurple | \#9370db | ![zh-cn_image_0000001173324779](figures/zh-cn_image_0000001173324779.png) | +| mediumseagreen | \#3cb371 | ![zh-cn_image_0000001127125230](figures/zh-cn_image_0000001127125230.png) | +| mediumslateblue | \#7b68ee | ![zh-cn_image_0000001173164921](figures/zh-cn_image_0000001173164921.png) | +| mediumspringgreen | \#00fa9a | ![zh-cn_image_0000001173324793](figures/zh-cn_image_0000001173324793.png) | +| mediumturquoise | \#48d1cc | ![zh-cn_image_0000001127125214](figures/zh-cn_image_0000001127125214.png) | +| mediumvioletred | \#c71585 | ![zh-cn_image_0000001173164893](figures/zh-cn_image_0000001173164893.png) | +| midnightblue | \#191970 | ![zh-cn_image_0000001127125260](figures/zh-cn_image_0000001127125260.png) | +| mintcream | \#f5fffa | ![zh-cn_image_0000001127285030](figures/zh-cn_image_0000001127285030.png) | +| mistyrose | \#ffe4e1 | ![zh-cn_image_0000001173324785](figures/zh-cn_image_0000001173324785.png) | +| moccasin | \#ffe4b5 | ![zh-cn_image_0000001127125232](figures/zh-cn_image_0000001127125232.png) | +| navajowhite | \#ffdead | ![zh-cn_image_0000001173164925](figures/zh-cn_image_0000001173164925.png) | +| navy | \#000080 | ![zh-cn_image_0000001127285032](figures/zh-cn_image_0000001127285032.png) | +| oldlace | \#fdf5e6 | ![zh-cn_image_0000001127125184](figures/zh-cn_image_0000001127125184.png) | +| olive | \#808000 | ![zh-cn_image_0000001127125244](figures/zh-cn_image_0000001127125244.png) | +| olivedrab | \#6b8e23 | ![zh-cn_image_0000001173324839](figures/zh-cn_image_0000001173324839.png) | +| orange | \#ffa500 | ![zh-cn_image_0000001173164885](figures/zh-cn_image_0000001173164885.png) | +| orangered | \#ff4500 | ![zh-cn_image_0000001127284996](figures/zh-cn_image_0000001127284996.png) | +| orchid | \#da70d6 | ![zh-cn_image_0000001127285056](figures/zh-cn_image_0000001127285056.png) | +| palegoldenrod | \#eee8aa | ![zh-cn_image_0000001127125262](figures/zh-cn_image_0000001127125262.png) | +| palegreen | \#98fb98 | ![zh-cn_image_0000001127285006](figures/zh-cn_image_0000001127285006.png) | +| paleturquoise | \#afeeee | ![zh-cn_image_0000001173324757](figures/zh-cn_image_0000001173324757.png) | +| palevioletred | \#db7093 | ![zh-cn_image_0000001173164905](figures/zh-cn_image_0000001173164905.png) | +| papayawhip | \#ffefd5 | ![zh-cn_image_0000001127125248](figures/zh-cn_image_0000001127125248.png) | +| peachpuff | \#ffdab9 | ![zh-cn_image_0000001173324769](figures/zh-cn_image_0000001173324769.png) | +| peru | \#cd853f | ![zh-cn_image_0000001173164843](figures/zh-cn_image_0000001173164843.png) | +| pink | \#ffc0cb | ![zh-cn_image_0000001127125242](figures/zh-cn_image_0000001127125242.png) | +| plum | \#dda0dd | ![zh-cn_image_0000001173324831](figures/zh-cn_image_0000001173324831.png) | +| powderblue | \#b0e0e6 | ![zh-cn_image_0000001127285010](figures/zh-cn_image_0000001127285010.png) | +| purple | \#800080 | ![zh-cn_image_0000001127285002](figures/zh-cn_image_0000001127285002.png) | +| rebeccapurple | \#663399 | ![zh-cn_image_0000001173164907](figures/zh-cn_image_0000001173164907.png) | +| red | \#ff0000 | ![zh-cn_image_0000001127125254](figures/zh-cn_image_0000001127125254.png) | +| rosybrown | \#bc8f8f | ![zh-cn_image_0000001173324775](figures/zh-cn_image_0000001173324775.png) | +| royalblue | \#4169e1 | ![zh-cn_image_0000001127284972](figures/zh-cn_image_0000001127284972.png) | +| saddlebrown | \#8b4513 | ![zh-cn_image_0000001127125250](figures/zh-cn_image_0000001127125250.png) | +| salmon | \#fa8072 | ![zh-cn_image_0000001127285064](figures/zh-cn_image_0000001127285064.png) | +| sandybrown | \#f4a460 | ![zh-cn_image_0000001173324777](figures/zh-cn_image_0000001173324777.png) | +| seagreen | \#2e8b57 | ![zh-cn_image_0000001173324733](figures/zh-cn_image_0000001173324733.png) | +| seashell | \#fff5ee | ![zh-cn_image_0000001127285062](figures/zh-cn_image_0000001127285062.png) | +| sienna | \#a0522d | ![zh-cn_image_0000001173164917](figures/zh-cn_image_0000001173164917.png) | +| silver | \#c0c0c0 | ![zh-cn_image_0000001173324743](figures/zh-cn_image_0000001173324743.png) | +| skyblue | \#87ceeb | ![zh-cn_image_0000001127284970](figures/zh-cn_image_0000001127284970.png) | +| slateblue | \#6a5acd | ![zh-cn_image_0000001173164915](figures/zh-cn_image_0000001173164915.png) | +| slategray | \#708090 | ![zh-cn_image_0000001173324815](figures/zh-cn_image_0000001173324815.png) | +| slategrey | \#708090 | ![zh-cn_image_0000001127284982](figures/zh-cn_image_0000001127284982.png) | +| snow | \#fffafa | ![zh-cn_image_0000001173324731](figures/zh-cn_image_0000001173324731.png) | +| springgreen | \#00ff7f | ![zh-cn_image_0000001127285060](figures/zh-cn_image_0000001127285060.png) | +| steelblue | \#4682b4 | ![zh-cn_image_0000001127125240](figures/zh-cn_image_0000001127125240.png) | +| tan | \#d2b48c | ![zh-cn_image_0000001173324747](figures/zh-cn_image_0000001173324747.png) | +| teal | \#008080 | ![zh-cn_image_0000001173324741](figures/zh-cn_image_0000001173324741.png) | +| thistle | \#d8Bfd8 | ![zh-cn_image_0000001173164913](figures/zh-cn_image_0000001173164913.png) | +| tomato | \#ff6347 | ![zh-cn_image_0000001173164909](figures/zh-cn_image_0000001173164909.png) | +| turquoise | \#40e0d0 | ![zh-cn_image_0000001173164837](figures/zh-cn_image_0000001173164837.png) | +| violet | \#ee82ee | ![zh-cn_image_0000001127125258](figures/zh-cn_image_0000001127125258.png) | +| wheat | \#f5deb3 | ![zh-cn_image_0000001127285068](figures/zh-cn_image_0000001127285068.png) | +| white | \#ffffff | ![zh-cn_image_0000001173324823](figures/zh-cn_image_0000001173324823.png) | +| whitesmoke | \#f5f5f5 | ![zh-cn_image_0000001127284992](figures/zh-cn_image_0000001127284992.png) | +| yellow | \#ffff00 | ![zh-cn_image_0000001173324837](figures/zh-cn_image_0000001173324837.png) | +| yellowgreen | \#9acd32 | ![zh-cn_image_0000001173164923](figures/zh-cn_image_0000001173164923.png) | diff --git a/zh-cn/application-dev/reference/arkui-js/js-appendix.md b/zh-cn/application-dev/reference/arkui-js/js-appendix.md index 3c0b115e1f6a55aefbb33006a93dd611e8ff3a34..064f8f5fd18317e708c5f5834ba3c79599707168 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-appendix.md +++ b/zh-cn/application-dev/reference/arkui-js/js-appendix.md @@ -1,4 +1,5 @@ # 附录 -- **[类型说明](js-appendix-types.md)** + +- **[类型说明](js-appendix-types.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-button.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-button.md index d763b53429b03e67322337b3039ba60aa127da9b..2470492c22ed4bfcbf86f4011e230e13dd2dfa27 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-button.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-button.md @@ -1,334 +1,86 @@ -# button +# button + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 提供按钮组件,包括胶囊按钮、圆形按钮、文本按钮、弧形按钮、下载按钮。 -## 子组件 + +## 子组件 不支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

type

-

string

-

-

-

-

不支持动态修改。如果该属性缺省,展示类胶囊型按钮,不同于胶囊类型,四边圆角可以通过border-radius分别指定,如果需要设置该属性,则可选值包括如下:

-
  • capsule:胶囊型按钮,带圆角按钮,有背景色和文本;
  • circle:圆形按钮,支持放置图标;
  • text:文本按钮,仅包含文本显示;
  • arc:弧形按钮,仅支持智能穿戴;
  • download:下载按钮,额外增加下载进度条功能,仅支持手机和智慧屏。
-

value

-

string

-

-

-

-

button的文本值。

-

icon

-

string

-

-

-

-

button的图标路径,图标格式为jpg,png和svg。

-

placement5+

-

string

-

end

-

-

仅在type属性为缺省时生效,设置图标位于文本的位置,可选值为:

-
  • start:图标位于文本起始处;
  • end:图标位于文本结束处;
  • top:图标位于文本上方;
  • bottom:图标位于文本下方。
-

waiting

-

boolean

-

false

-

-

waiting状态,waiting为true时展现等待中转圈效果,位于文本左侧。类型为download时不生效,不支持智能穿戴。

-
- -## 样式 - -### type设置为非arc - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

text-color

-

<color>

-

#ff007dff

-

-

按钮的文本颜色。

-

font-size

-

<length>

-

16px

-

-

按钮的文本尺寸。

-

allow-scale

-

boolean

-

true

-

-

按钮的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。

-
-

font-style

-

string

-

normal

-

-

按钮的字体样式。

-

font-weight

-

number | string

-

normal

-

-

按钮的字体粗细。见text组件font-weight的样式属性

-

font-family

-

<string>

-

sans-serif

-

-

按钮的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-

icon-width

-

<length>

-

-

-

-

设置圆形按钮内部图标的宽,默认填满整个圆形按钮。

-
说明:

icon使用svg图源时必须设置该样式。

-
-

icon-height

-

<length>

-

-

-

-

设置圆形按钮内部图标的高,默认填满整个圆形按钮。

-
说明:

icon使用svg图源时必须设置该样式。

-
-

radius

-

<length>

-

-

-

-

按钮圆角半径。在圆形按钮类型下该样式优先于通用样式的width和height样式。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 胶囊按钮(type=capsule)时,不支持border相关样式; ->- 圆形按钮(type=circle)时,不支持文本相关样式; ->- 文本按钮(type=text)时,自适应文本大小,不支持尺寸设置(radius,width,height),背景透明不支持background-color样式。 - -### type设置为arc - -除支持[通用样式](js-components-common-styles.md)中background-color、opacity、display、visibility、position、\[left|top|right|bottom外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

text-color

-

<color>

-

#de0000

-

-

弧形按钮的文本颜色。

-

font-size

-

<length>

-

37.5px

-

-

弧形按钮的文本尺寸。

-

allow-scale

-

boolean

-

true

-

-

弧形按钮的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-

font-style

-

string

-

normal

-

-

弧形按钮的字体样式。

-

font-weight

-

number | string

-

normal

-

-

弧形按钮的字体粗细。见text组件font-weight的样式属性

-

font-family

-

<string>

-

sans-serif

-

-

按钮的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-
- -## 事件 - -支持[通用事件](js-components-common-events.md)。 - -## 方法 - -支持[通用方法](js-components-common-methods.md)。 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string | - | 否 | 不支持动态修改。如果该属性缺省,展示类胶囊型按钮,不同于胶囊类型,四边圆角可以通过border-radius分别指定,如果需要设置该属性,则可选值包括如下:
- capsule:胶囊型按钮,带圆角按钮,有背景色和文本;
- circle:圆形按钮,支持放置图标;
- text:文本按钮,仅包含文本显示;
- arc:弧形按钮,仅支持智能穿戴;
- download:下载按钮,额外增加下载进度条功能。 | +| value | string | - | 否 | button的文本值。 | +| icon | string | - | 否 | button的图标路径,图标格式为jpg,png和svg。 | +| placement5+ | string | end | 否 | 仅在type属性为缺省时生效,设置图标位于文本的位置,可选值为:
- start:图标位于文本起始处;
- end:图标位于文本结束处;
- top:图标位于文本上方;
- bottom:图标位于文本下方。 | +| waiting | boolean | false | 否 | waiting状态,waiting为true时展现等待中转圈效果,位于文本左侧。类型为download时不生效。 | + + +## 样式 + + +### type设置为非arc + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| text-color | <color> | \#ff007dff
| 否 | 按钮的文本颜色。 | +| font-size | <length> | 16px
| 否 | 按钮的文本尺寸。 | +| allow-scale | boolean | true | 否 | 按钮的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| font-style | string | normal | 否 | 按钮的字体样式。 | +| font-weight | number \| string | normal | 否 | 按钮的字体粗细。见[text组件font-weight的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family | <string> | sans-serif | 否 | 按钮的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | +| icon-width | <length> | - | 否 | 设置圆形按钮内部图标的宽,默认填满整个圆形按钮。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> icon使用svg图源时必须设置该样式。 | +| icon-height | <length> | - | 否 | 设置圆形按钮内部图标的高,默认填满整个圆形按钮。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> icon使用svg图源时必须设置该样式。 | +| radius | <length> | - | 否 | 按钮圆角半径。在圆形按钮类型下该样式优先于通用样式的width和height样式。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 胶囊按钮(type=capsule)时,不支持border相关样式; +> +> - 圆形按钮(type=circle)时,不支持文本相关样式; +> +> - 文本按钮(type=text)时,自适应文本大小,不支持尺寸设置(radius,width,height),背景透明不支持background-color样式。 + + +### type设置为arc + +除支持[通用样式](../arkui-js/js-components-common-styles.md)中background-color、opacity、display、visibility、position、[left|top|right|bottom外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| text-color | <color> | \#de0000 | 否 | 弧形按钮的文本颜色。 | +| font-size | <length> | 37.5px | 否 | 弧形按钮的文本尺寸。 | +| allow-scale | boolean | true | 否 | 弧形按钮的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。 | +| font-style | string | normal | 否 | 弧形按钮的字体样式。 | +| font-weight | number \| string | normal | 否 | 弧形按钮的字体粗细。见[text组件font-weight的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family | <string> | sans-serif | 否 | 按钮的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | + + +## 事件 + +支持[通用事件](../arkui-js/js-components-common-events.md)。 + + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 类型为download时,支持如下方法: - - - - - - - - - - -

名称

-

参数

-

描述

-

setProgress

-

{ progress:percent }

-

设定下载按钮进度条进度,取值位于0-100区间内,当设置的值大于0时,下载按钮展现进度条。当设置的值大于等于100时,取消进度条显示。

-
说明:

浮在进度条上的文字通过value值进行变更。

-
-
- -## 示例 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| setProgress | { progress:percent } | 设定下载按钮进度条进度,取值位于0-100区间内,当设置的值大于0时,下载按钮展现进度条。当设置的值大于等于100时,取消进度条显示。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 浮在进度条上的文字通过value值进行变更。 | + +## 示例 ``` @@ -403,5 +155,4 @@ export default { } ``` -![](figures/zh-cn_image_0000001127125132.png) - +![zh-cn_image_0000001127125132](figures/zh-cn_image_0000001127125132.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-chart.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-chart.md index f9befe5cf7115b7226ca278d090f18009e0ccf25..dcde8ec5c94c414b88680deed4fda54ef7d0633f 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-chart.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-chart.md @@ -1,1150 +1,354 @@ -# chart +# chart + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 图表组件,用于呈现线形图、柱状图、量规图界面。 -## 权限列表 +## 权限列表 无 -## 子组件 - -不支持。 - -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

type

-

string

-

line

-

-

设置图表类型(不支持动态修改),可选项有:

-
  • bar:柱状图。
  • line:线形图。
  • gauge:量规图。
  • progress5+:进度类圆形图表。
  • loading5+:加载类圆形图表。
  • rainbow5+:占比类圆形图表。
-

options

-

ChartOptions

-

-

-

-

图表参数设置,柱状图和线形图必须设置参数设置,量规图不生效。可以设置x轴、y轴的最小值、最大值、刻度数、是否显示,线条宽度、是否平滑等。(不支持动态修改)

-

datasets

-

Array<ChartDataset>

-

-

-

-

数据集合,柱状图和线形图必须设置数据集合,量规图不生效。可以设置多条数据集及其背景色。

-

segments5+

-

DataSegment | Array<DataSegment>

-

-

-

-

进度类、加载类和占比类圆形图表使用的数据结构。

-

DataSegment针对进度类和加载类圆形图表使用,

-

Array<DataSegment>针对占比类图标使用,DataSegment最多9个。

-
说明:

仅手机和平板设备支持。

-
-

effects5+

-

boolean

-

true

-

-

是否开启占比类、进度类圆形图表特效。

-
说明:

仅手机和平板设备支持。

-
-

animationduration6+

-

number

-

3000

-

-

设置占比类圆形图表展开动画时长,单位为ms。

-
说明:

仅手机和平板设备支持。

-
-
- -**表 1** ChartOptions - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

xAxis

-

ChartAxis

-

-

-

-

x轴参数设置。可以设置x轴最小值、最大值、刻度数以及是否显示。

-

yAxis

-

ChartAxis

-

-

-

-

y轴参数设置。可以设置y轴最小值、最大值、刻度数以及是否显示。

-

series

-

ChartSeries

-

-

-

-

数据序列参数设置。可以设置1)线的样式,如线宽、是否平滑;2)设置线最前端位置白点的样式和大小。

-
说明:

仅线形图支持。

-
-
- -**表 2** ChartDataset - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

strokeColor

-

<color>

-

#ff6384

-

-

线条颜色。

-
说明:

仅线形图支持。

-
-

fillColor

-

<color>

-

#ff6384

-

-

填充颜色。线形图表示填充的渐变颜色。

-

data

-

Array<number> | Array<Point>5+

-

-

-

-

设置绘制线或柱中的点集。

-

gradient

-

boolean

-

false

-

-

设置是否显示填充渐变颜色。

-
说明:

仅线形图支持。

-
-
- -**表 3** ChartAxis - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

min

-

number

-

0

-

-

轴的最小值。

-
说明:

仅线形图支持负数。

-
-

max

-

number

-

100

-

-

轴的最大值。

-
说明:

仅线形图支持负数。

-
-

axisTick

-

number

-

10

-

-

轴显示的刻度数量。

-
说明:

仅支持1~20,且具体显示的效果与如下计算值有关(图的宽度所占的像素/(max-min))。

-

在柱状图中,每组数据显示的柱子数量与刻度数量一致,且柱子显示在刻度处。

-
-

display

-

boolean

-

false

-

-

是否显示轴。

-

color

-

<color>

-

#c0c0c0

-

-

轴颜色。

-
-**表 4** ChartSeries +## 子组件 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

lineStyle

-

ChartLineStyle

-

-

-

-

线样式设置,如线宽、是否平滑。

-

headPoint

-

PointStyle

-

-

-

-

线最前端位置白点的样式和大小。

-

topPoint

-

PointStyle

-

-

-

-

最高点的样式和大小。

-

bottomPoint

-

PointStyle

-

-

-

-

最低点的样式和大小。

-

loop

-

ChartLoop

-

-

-

-

设置屏幕显示满时,是否需要重头开始绘制。

-
- -**表 5** ChartLineStyle - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

width

-

<length>

-

1px

-

-

线宽设置。

-

smooth

-

boolean

-

false

-

-

是否平滑。

-
- -**表 6** PointStyle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

shape

-

string

-

circle

-

-

高亮点的形状。可选值为:

-
  • circle:圆形。
  • square:方形。
  • triangle:三角形。
-

size

-

<length>

-

5px

-

-

高亮点的大小。

-

strokeWidth

-

<length>

-

1px

-

-

边框宽度

-

strokeColor

-

<color>

-

#ff0000

-

-

边框颜色。

-

fillColor

-

<color>

-

#ff0000

-

-

填充颜色。

-
- -**表 7** ChartLoop - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

margin

-

<length>

-

1

-

-

擦除点的个数(最新绘制的点与最老的点之间的横向距离)。注意:轻量设备margin和topPoint/bottomPoint/headPoint同时使用时,有概率出现point正好位于擦除区域的情况,导致point不可见,因此不建议同时使用。

-

gradient

-

boolean

-

false

-

-

是否需要渐变擦除。

-
- -**表 8** Point5+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

value

-

number

-

0

-

-

表示绘制点的Y轴坐标。

-

pointStyle

-

PointStyle

-

-

-

-

表示当前数据点的绘制样式。

-

description

-

string

-

-

-

-

表示当前点的注释内容。

-

textLocation

-

string

-

-

-

-

可选值为top,bottom,none。分别表示注释的绘制位置位于点的上方,下方,以及不绘制。

-

textColor

-

<color>

-

#000000

-

-

表示注释文字的颜色。

-

lineDash

-

string

-

solid

-

-

表示绘制当前线段虚线的样式。“dashed, 5, 5”表示纯虚线,绘制5px的实线后留5px的空白。“solid”表示绘制实线。

-

lineColor

-

<color>

-

#000000

-

-

表示绘制当前线段的颜色。此颜色不设置会默认使用整体的strokeColor。

-
- -**表 9** DataSegment5+ +不支持。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

startColor

-

Color

-

-

-

-

起始位置的颜色,设置startColor必须设置endColor。不设置startColor时,会使用系统默认预置的颜色数组,具体颜色值见下表。

-

endColor

-

Color

-

-

-

-

终止位置的颜色,设置endColor必须设置startColor。

-

不设置startColor时,会使用系统默认预置的颜色数组。

-

value

-

number

-

0

-

-

占比数据的所占份额,最大100。

-

name

-

string

-

-

-

-

此类数据的名称。

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

数据组

-

浅色主题

-

深色主题

-

0

-

起始颜色:#f7ce00,结束颜色:#f99b11

-

起始颜色:#d1a738,结束颜色:#eb933d

-

1

-

起始颜色:#f76223,结束颜色:#f2400a

-

起始颜色:#e67d50,结束颜色:#d9542b

-

2

-

起始颜色:#f772ac,结束颜色:#e65392

-

起始颜色:#d5749e,结束颜色:#d6568d

-

3

-

起始颜色:#a575eb,结束颜色:#a12df7

-

起始颜色:#9973d1,结束颜色:#5552d9

-

4

-

起始颜色:#7b79f7,结束颜色:#4b48f7

-

起始颜色:#7977d9,结束颜色:#f99b11

-

5

-

起始颜色:#4b8af3,结束颜色:#007dff

-

起始颜色:#4c81d9,结束颜色:#217bd9

-

6

-

起始颜色:#73c1e6,结束颜色:#4fb4e3

-

起始颜色:#5ea6d1,结束颜色:#4895c2

-

7

-

起始颜色:#a5d61d,结束颜色:#69d14f

-

起始颜色:#91c23a,结束颜色:#70ba5d

-

8

-

起始颜色:#a2a2b0,结束颜色:#8e8e93

-

起始颜色:#8c8c99,结束颜色:#6b6b76

-
+## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string | line | 否 | 设置图表类型(不支持动态修改),可选项有:
- bar:柱状图。
- line:线形图。
- gauge:量规图。
- progress5+:进度类圆形图表。
- loading5+:加载类圆形图表。
- rainbow5+:占比类圆形图表。 | +| options | ChartOptions | - | 否 | 图表参数设置,柱状图和线形图必须设置参数设置,量规图不生效。可以设置x轴、y轴的最小值、最大值、刻度数、是否显示,线条宽度、是否平滑等。(不支持动态修改) | +| datasets | Array<ChartDataset> | - | 否 | 数据集合,柱状图和线形图必须设置数据集合,量规图不生效。可以设置多条数据集及其背景色。 | +| segments5+ | DataSegment \| Array<DataSegment> | - | 否 | 进度类、加载类和占比类圆形图表使用的数据结构。
DataSegment针对进度类和加载类圆形图表使用,
Array<DataSegment>针对占比类图标使用,DataSegment最多9个。 | +| effects5+ | boolean | true | 否 | 是否开启占比类、进度类圆形图表特效。 | +| animationduration6+ | number | 3000 | 否 | 设置占比类圆形图表展开动画时长,单位为ms。 | + +**表1** ChartOptions + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| xAxis | ChartAxis | - | 是 | x轴参数设置。可以设置x轴最小值、最大值、刻度数以及是否显示。 | +| yAxis | ChartAxis | - | 是 | y轴参数设置。可以设置y轴最小值、最大值、刻度数以及是否显示。 | +| series | ChartSeries | - | 否 | 数据序列参数设置。可以设置1)线的样式,如线宽、是否平滑;2)设置线最前端位置白点的样式和大小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅线形图支持。 | + +**表2** ChartDataset + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| strokeColor | <color> | \#ff6384 | 否 | 线条颜色。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅线形图支持。 | +| fillColor | <color> | \#ff6384 | 否 | 填充颜色。线形图表示填充的渐变颜色。 | +| data | Array<number> \| Array<Point>5+ | - | 是 | 设置绘制线或柱中的点集。 | +| gradient | boolean | false | 否 | 设置是否显示填充渐变颜色。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅线形图支持。 | + +**表3** ChartAxis + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| min | number | 0 | 否 | 轴的最小值。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅线形图支持负数。 | +| max | number | 100 | 否 | 轴的最大值。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅线形图支持负数。 | +| axisTick | number | 10 | 否 | 轴显示的刻度数量。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅支持1~20,且具体显示的效果与如下计算值有关(图的宽度所占的像素/(max-min))。
> 在柱状图中,每组数据显示的柱子数量与刻度数量一致,且柱子显示在刻度处。 | +| display | boolean | false | 否 | 是否显示轴。 | +| color | <color> | \#c0c0c0 | 否 | 轴颜色。 | + +**表4** ChartSeries + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| lineStyle | ChartLineStyle | - | 否 | 线样式设置,如线宽、是否平滑。 | +| headPoint | PointStyle | - | 否 | 线最前端位置白点的样式和大小。 | +| topPoint | PointStyle | - | 否 | 最高点的样式和大小。 | +| bottomPoint | PointStyle | - | 否 | 最低点的样式和大小。 | +| loop | ChartLoop | - | 否 | 设置屏幕显示满时,是否需要重头开始绘制。 | + +**表5** ChartLineStyle + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| width | <length> | 1px | 否 | 线宽设置。 | +| smooth | boolean | false | 否 | 是否平滑。 | + +**表6** PointStyle + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| shape | string | circle | 否 | 高亮点的形状。可选值为:
- circle:圆形。
- square:方形。
- triangle:三角形。 | +| size | <length> | 5px | 否 | 高亮点的大小。 | +| strokeWidth | <length> | 1px | 否 | 边框宽度 | +| strokeColor | <color> | \#ff0000 | 否 | 边框颜色。 | +| fillColor | <color> | \#ff0000 | 否 | 填充颜色。 | + +**表7** ChartLoop + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| margin | <length> | 1 | 否 | 擦除点的个数(最新绘制的点与最老的点之间的横向距离)。注意:轻量设备margin和topPoint/bottomPoint/headPoint同时使用时,有概率出现point正好位于擦除区域的情况,导致point不可见,因此不建议同时使用。 | +| gradient | boolean | false | 否 | 是否需要渐变擦除。 | + +**表8** Point5+ + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| value | number | 0 | 是 | 表示绘制点的Y轴坐标。 | +| pointStyle | PointStyle | - | 否 | 表示当前数据点的绘制样式。 | +| description | string | - | 否 | 表示当前点的注释内容。 | +| textLocation | string | - | 否 | 可选值为top,bottom,none。分别表示注释的绘制位置位于点的上方,下方,以及不绘制。 | +| textColor | <color> | \#000000 | 否 | 表示注释文字的颜色。 | +| lineDash | string | solid | 否 | 表示绘制当前线段虚线的样式。“dashed, 5, 5”表示纯虚线,绘制5px的实线后留5px的空白。“solid”表示绘制实线。 | +| lineColor | <color> | \#000000 | 否 | 表示绘制当前线段的颜色。此颜色不设置会默认使用整体的strokeColor。 | + +**表9** DataSegment5+ + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| startColor | Color | - | 否 | 起始位置的颜色,设置startColor必须设置endColor。不设置startColor时,会使用系统默认预置的颜色数组,具体颜色值见下表。 | +| endColor | Color | - | 否 | 终止位置的颜色,设置endColor必须设置startColor。
不设置startColor时,会使用系统默认预置的颜色数组。 | +| value | number | 0 | 是 | 占比数据的所占份额,最大100。 | +| name | string | - | 否 | 此类数据的名称。 | + +| 数据组 | 浅色主题 | 深色主题 | +| -------- | -------- | -------- | +| 0 | 起始颜色:\#f7ce00,结束颜色:\#f99b11 | 起始颜色:\#d1a738,结束颜色:\#eb933d | +| 1 | 起始颜色:\#f76223,结束颜色:\#f2400a | 起始颜色:\#e67d50,结束颜色:\#d9542b | +| 2 | 起始颜色:\#f772ac,结束颜色:\#e65392 | 起始颜色:\#d5749e,结束颜色:\#d6568d | +| 3 | 起始颜色:\#a575eb,结束颜色:\#a12df7 | 起始颜色:\#9973d1,结束颜色:\#5552d9 | +| 4 | 起始颜色:\#7b79f7,结束颜色:\#4b48f7 | 起始颜色:\#7977d9,结束颜色:\#f99b11 | +| 5 | 起始颜色:\#4b8af3,结束颜色:\#007dff | 起始颜色:\#4c81d9,结束颜色:\#217bd9 | +| 6 | 起始颜色:\#73c1e6,结束颜色:\#4fb4e3 | 起始颜色:\#5ea6d1,结束颜色:\#4895c2 | +| 7 | 起始颜色:\#a5d61d,结束颜色:\#69d14f | 起始颜色:\#91c23a,结束颜色:\#70ba5d | +| 8 | 起始颜色:\#a2a2b0,结束颜色:\#8e8e93 | 起始颜色:\#8c8c99,结束颜色:\#6b6b76 | 当类型为量规图时,还支持如下属性: - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

percent

-

number

-

0

-

-

当前值占整体的百分比,取值范围为0-100。

-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

stroke-width

-

<length>

-

32px(量规)

-

24px(占比类圆形图表)

-

-

量规、占比类圆形图表组件刻度条的宽度。

-

start-angle

-

<deg>

-

240(量规)

-

0(占比类圆形图表)

-

-

量规、占比类圆形图表组件刻度条起始角度,以时钟0点为基线。范围为0到360。

-

total-angle

-

<deg>

-

240(量规)

-

360(占比类圆形图表)

-

-

量规、占比类圆形图表组件刻度条总长度,范围为-360到360,负数标识起点到终点为逆时针。

-

center-x

-

<length>

-

-

-

-

量规组件刻度条中心位置,该样式优先于通用样式的position样式。该样式需要和center-y和radius一起配置才能生效。(仅量规图支持)

-

center-y

-

<length>

-

-

-

-

量规组件刻度条中心位置,该样式优先于通用样式的position样式。该样式需要和center-x和radius一起配置才能生效。(仅量规图支持)

-

radius

-

<length>

-

-

-

-

量规组件刻度条半径,该样式优先于通用样式的width和height样式。该样式需要和center-x和center-y一起配置才能生效。(仅量规图支持)

-

colors

-

Array

-

-

-

-

量规组件刻度条每一个区段的颜色。

-

如:colors: #ff0000, #00ff00。(仅量规图支持)

-

weights

-

Array

-

-

-

-

量规组件刻度条每一个区段的权重。

-

如:weights: 2, 2。(仅量规图支持)

-

font-family5+

-

Array

-

-

-

-

表示绘制注释的字体样式,支持自定义字体

-

font-size5+

-

<length>

-

-

-

-

表示绘制注释的字体的大小。

-
- -## 事件 - -支持[通用事件](js-components-common-events.md)。 - -## 方法 - -除支持[通用方法](js-components-common-methods.md)外,还支持如下方法: - - - - - - - - - - - -

方法

-

参数

-

描述

-

append

-

{

-

serial: number, // 设置要更新的线形图数据下标

-

data: Array<number>, // 设置新增的数据

-

}

-

往已有的数据序列中动态添加数据,根据serial指定目标序列,serial为datasets数组的下标,从0开始。注意:不会更新datasets[index].data。仅线形图支持,按横坐标加1递增(与xAxis min/max设置相关)。

-
- -## 示例 - -1. 线形图 - - ``` - -
- - - - - -
- ``` - - ``` - /* xxx.css */ - .container { - flex-direction: column; - justify-content: center; - align-items: center; - } - .chart-region { - height: 400px; - width: 700px; - } - .chart-background { - object-fit: fill; - } - .chart-data { - width: 700px; - height: 600px; - } - button { - width: 100%; - height: 50px; - background-color: #F4F2F1; - text-color: #0C81F3; - } - ``` - - ``` - // xxx.js - export default { - data: { - lineData: [ - { - strokeColor: '#0081ff', - fillColor: '#cce5ff', - data: [763, 550, 551, 554, 731, 654, 525, 696, 595, 628, 791, 505, 613, 575, 475, 553, 491, 680, 657, 716], - gradient: true, - } - ], - lineOps: { - xAxis: { - min: 0, - max: 20, - display: false, - }, - yAxis: { - min: 0, - max: 1000, - display: false, - }, - series: { - lineStyle: { - width: "5px", - smooth: true, - }, - headPoint: { - shape: "circle", - size: 20, - strokeWidth: 5, - fillColor: '#ffffff', - strokeColor: '#007aff', - display: true, - }, - loop: { - margin: 2, - gradient: true, - } - } - }, - }, - addData() { - this.$refs.linechart.append({ - serial: 0, - data: [Math.floor(Math.random() * 400) + 400] - }) - } - } - ``` - - ![](figures/zh-cn_image_0000001173324843.png) - -2. 柱状图 - - ``` - -
- - - - -
- ``` - - ``` - /* xxx.css */ - .container { - flex-direction: column; - justify-content: center; - align-items: center; - } - .data-region { - height: 400px; - width: 700px; - } - .data-background { - object-fit: fill; - } - .data-bar { - width: 700px; - height: 400px; - } - ``` - - ``` - // xxx.js - export default { - data: { - barData: [ - { - fillColor: '#f07826', - data: [763, 550, 551, 554, 731, 654, 525, 696, 595, 628], - }, - { - fillColor: '#cce5ff', - data: [535, 776, 615, 444, 694, 785, 677, 609, 562, 410], - }, - { - fillColor: '#ff88bb', - data: [673, 500, 574, 483, 702, 583, 437, 506, 693, 657], - }, - ], - barOps: { - xAxis: { - min: 0, - max: 20, - display: false, - axisTick: 10, - }, - yAxis: { - min: 0, - max: 1000, - display: false, - }, - }, - } - } - ``` - - ![](figures/barchart.png) - -3. 量规图 - - ``` - -
-
- -
-
- ``` - - ``` - /* xxx.css */ - .container { - flex-direction: column; - justify-content: center; - align-items: center; - } - .gauge-region { - height: 400px; - width: 400px; - } - .data-gauge { - colors: #83f115, #fd3636, #3bf8ff; - weights: 4, 2, 1; - } - ``` - - ![](figures/gauge.png) - - +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| percent | number | 0 | 否 | 当前值占整体的百分比,取值范围为0-100。 | + + +## 样式 + + + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| stroke-width | <length> | 32px(量规)
24px(占比类圆形图表) | 否 | 量规、占比类圆形图表组件刻度条的宽度。 | +| start-angle | <deg> | 240(量规)
0(占比类圆形图表) | 否 | 量规、占比类圆形图表组件刻度条起始角度,以时钟0点为基线。范围为0到360。 | +| total-angle | <deg> | 240(量规)
360(占比类圆形图表) | 否 | 量规、占比类圆形图表组件刻度条总长度,范围为-360到360,负数标识起点到终点为逆时针。 | +| center-x | <length> | - | 否 | 量规组件刻度条中心位置,该样式优先于通用样式的position样式。该样式需要和center-y和radius一起配置才能生效。(仅量规图支持) | +| center-y | <length> | - | 否 | 量规组件刻度条中心位置,该样式优先于通用样式的position样式。该样式需要和center-x和radius一起配置才能生效。(仅量规图支持) | +| radius | <length> | - | 否 | 量规组件刻度条半径,该样式优先于通用样式的width和height样式。该样式需要和center-x和center-y一起配置才能生效。(仅量规图支持) | +| colors | Array | - | 否 | 量规组件刻度条每一个区段的颜色。
如:colors: \#ff0000, \#00ff00。(仅量规图支持) | +| weights | Array | - | 否 | 量规组件刻度条每一个区段的权重。
如:weights: 2, 2。(仅量规图支持) | +| font-family5+ | Array | - | 否 | 表示绘制注释的字体样式,支持[自定义字体](../arkui-js/js-components-common-customizing-font.md)。 | +| font-size5+ | <length> | - | 否 | 表示绘制注释的字体的大小。 | + + +## 事件 + +支持[通用事件](../arkui-js/js-components-common-events.md)。 + + +## 方法 + +除支持[通用方法](../arkui-js/js-components-common-methods.md)外,还支持如下方法: + +| 方法 | 参数 | 描述 | +| -------- | -------- | -------- | +| append | {
serial: number, // 设置要更新的线形图数据下标
data: Array<number>, // 设置新增的数据
} | 往已有的数据序列中动态添加数据,根据serial指定目标序列,serial为datasets数组的下标,从0开始。注意:不会更新datasets[index].data。仅线形图支持,按横坐标加1递增(与xAxis min/max设置相关)。 | + +## 示例 + +1. 线形图 + ``` + +
+ + + + + +
+ ``` + + ``` + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + } + .chart-region { + height: 400px; + width: 700px; + } + .chart-background { + object-fit: fill; + } + .chart-data { + width: 700px; + height: 600px; + } + button { + width: 100%; + height: 50px; + background-color: #F4F2F1; + text-color: #0C81F3; + } + ``` + + ``` + // xxx.js + export default { + data: { + lineData: [ + { + strokeColor: '#0081ff', + fillColor: '#cce5ff', + data: [763, 550, 551, 554, 731, 654, 525, 696, 595, 628, 791, 505, 613, 575, 475, 553, 491, 680, 657, 716], + gradient: true, + } + ], + lineOps: { + xAxis: { + min: 0, + max: 20, + display: false, + }, + yAxis: { + min: 0, + max: 1000, + display: false, + }, + series: { + lineStyle: { + width: "5px", + smooth: true, + }, + headPoint: { + shape: "circle", + size: 20, + strokeWidth: 5, + fillColor: '#ffffff', + strokeColor: '#007aff', + display: true, + }, + loop: { + margin: 2, + gradient: true, + } + } + }, + }, + addData() { + this.$refs.linechart.append({ + serial: 0, + data: [Math.floor(Math.random() * 400) + 400] + }) + } + } + ``` + + ![zh-cn_image_0000001173324843](figures/zh-cn_image_0000001173324843.png) + +2. 柱状图 + ``` + +
+ + + + +
+ ``` + + ``` + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + } + .data-region { + height: 400px; + width: 700px; + } + .data-background { + object-fit: fill; + } + .data-bar { + width: 700px; + height: 400px; + } + ``` + + ``` + // xxx.js + export default { + data: { + barData: [ + { + fillColor: '#f07826', + data: [763, 550, 551, 554, 731, 654, 525, 696, 595, 628], + }, + { + fillColor: '#cce5ff', + data: [535, 776, 615, 444, 694, 785, 677, 609, 562, 410], + }, + { + fillColor: '#ff88bb', + data: [673, 500, 574, 483, 702, 583, 437, 506, 693, 657], + }, + ], + barOps: { + xAxis: { + min: 0, + max: 20, + display: false, + axisTick: 10, + }, + yAxis: { + min: 0, + max: 1000, + display: false, + }, + }, + } + } + ``` + + ![zh-cn_image_0000001173164929](figures/zh-cn_image_0000001173164929.png) + +3. 量规图 + ``` + +
+
+ +
+
+ ``` + + ``` + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + } + .gauge-region { + height: 400px; + width: 400px; + } + .data-gauge { + colors: #83f115, #fd3636, #3bf8ff; + weights: 4, 2, 1; + } + ``` + + ![zh-cn_image_0000001127125264](figures/zh-cn_image_0000001127125264.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-divider.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-divider.md index 0fa9d6c594146179d6d468e93368c3c8cb533481..84fa5f4274f1abd90b87dc5d0c2f785cdfa8bd65 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-divider.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-divider.md @@ -1,210 +1,62 @@ -# divider +# divider + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 提供分隔器组件,分隔不同内容块/内容元素。可用于列表或界面布局。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

vertical

-

boolean

-

false

-

-

使用水平分割线还是垂直分割线,默认水平。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->不支持focusable、disabled属性。 - -## 样式 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| vertical | boolean | false | 否 | 使用水平分割线还是垂直分割线,默认水平。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 不支持focusable、disabled属性。 + + +## 样式 仅支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

margin

-

<length>

-

0

-

-

使用简写属性设置所有的外边距属性,该属性可以有1到4个值。

-

margin-[left|top|right|bottom]

-

<length>

-

0

-

-

使用简写属性设置左、上、右、下外边距属性,类型length,单位px,默认值0。

-

color

-

<color>

-

#08000000

-

-

设置分割线颜色。

-

stroke-width

-

<length>

-

1

-

-

设置分割线宽度。

-

display

-

string

-

flex

-

-

确定分割线所产生的框的类型。值flex/none,默认值flex。

-

visibility

-

string

-

visible

-

-

是否显示分割线。不可见的框会占用布局。visible代表显示元素,hidden代表不显示元素。

-

line-cap

-

string

-

butt

-

-

设置分割线条的端点样式,默认为butt,可选值为:

-
  • butt:分割线两端为平行线;
  • round:分割线两端额外添加半圆;
  • square:分割线两端额外添加半方形;
-
说明:

round和square会额外增加一个线宽的分割线长度。

-
-

flex

-

number

-

-

-

-

规定了分割线如何适应父组件中的可用空间。它作为一个简写属性,用来设置组件的flex-grow。

-
说明:

仅父容器为<div>、<list-item>、<tabs>时生效。

-
-

flex-grow

-

number

-

0

-

-

设置分割线的伸展因子,指定父组件容器主轴方向上剩余空间(容器本身大小减去所有flex项加起来的大小)的分配系数。0为不伸展。

-
说明:

仅父容器为<div>、<list-item>、<tabs>时生效。

-
-

-

flex-shrink

-

number

-

1

-

-

设置分割线的收缩因子,flex元素仅在默认宽度之和大于容器的时候才会发生收缩,0为不收缩。

-
说明:

仅父容器为<div>、<list-item>、<tabs>时生效。

-
-

flex-basis

-

<length>

-

-

-

-

-

设置分割线在主轴方向上的初始大小。

-
说明:

仅父容器为<div>、<list-item>、<tabs>时生效。

-
-
- -## 事件 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| margin | <length> | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。 | +| margin-[left\|top\|right\|bottom] | <length> | 0 | 否 | 使用简写属性设置左、上、右、下外边距属性,类型length,单位px,默认值0。 | +| color | <color> | \#08000000 | 否 | 设置分割线颜色。 | +| stroke-width | <length> | 1 | 否 | 设置分割线宽度。 | +| display | string | flex | 否 | 确定分割线所产生的框的类型。值flex/none,默认值flex。 | +| visibility | string | visible | 否 | 是否显示分割线。不可见的框会占用布局。visible代表显示元素,hidden代表不显示元素。 | +| line-cap | string | butt | 否 | 设置分割线条的端点样式,默认为butt,可选值为:
- butt:分割线两端为平行线;
- round:分割线两端额外添加半圆;
- square:分割线两端额外添加半方形;
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> round和square会额外增加一个线宽的分割线长度。 | +| flex | number | - | 否 | 规定了分割线如何适应父组件中的可用空间。它作为一个简写属性,用来设置组件的flex-grow。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>时生效。 | +| flex-grow | number | 0 | 否 | 设置分割线的伸展因子,指定父组件容器主轴方向上剩余空间(容器本身大小减去所有flex项加起来的大小)的分配系数。0为不伸展。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>时生效。 | +| flex-shrink | number | 1 | 否 | 设置分割线的收缩因子,flex元素仅在默认宽度之和大于容器的时候才会发生收缩,0为不收缩。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>时生效。 | +| flex-basis | <length> | - | 否 | 设置分割线在主轴方向上的初始大小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>时生效。 | + + +## 事件 不支持。 -## 方法 + +## 方法 不支持。 -## 示例 + +## 示例 ``` @@ -240,5 +92,4 @@ } ``` -![](figures/1.jpg) - +![zh-cn_image_0000001173164799](figures/zh-cn_image_0000001173164799.jpg) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-image-animator.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-image-animator.md index dff6cc80512cc66d65017fdeff34d09a528fd6e1..114a6713ed84dcfec61d14ce2152ecb4266d147e 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-image-animator.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-image-animator.md @@ -1,294 +1,73 @@ -# image-animator +# image-animator + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 图片帧动画播放器。 -## 子组件 + +## 子组件 不支持。 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| images | Array<ImageFrame> | - | 是 | 设置图片帧信息集合。每一帧的帧信息包含图片路径、图片大小和图片位置信息。目前支持以下图片格式:png、jpg。ImageFrame的详细说明请见表 ImageFrame说明。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如images = {{images}},js中声明相应变量:images: [{src: "/common/heart-rate01.png"}, {src: "/common/heart-rate02.png"}]。

> js中声明相应变量:images: [{src: "/common/heart-rate01.png", duration: "100"}, {src: "/common/heart-rate02.png", duration: "200"}]。支持配置每一帧图片的时长,单位毫秒。6+ | +| predecode6+ | number | 0 | 否 | 是否启用预解码,默认值为0,即不启用预解码,如该值设为2,则播放当前页时会提前加载后面两张图片至缓存以提升性能。 | +| iteration | number \| string | infinite | 否 | 设置帧动画播放次数。number表示固定次数,infinite枚举表示无限次数播放。 | +| reverse | boolean | false | 否 | 设置播放顺序。false表示从第1张图片播放到最后1张图片; true表示从最后1张图片播放到第1张图片。 | +| fixedsize | boolean | true | 否 | 设置图片大小是否固定为组件大小。 true表示图片大小与组件大小一致,此时设置图片的width 、height 、top 和left属性是无效的。false表示每一张图片的 width 、height 、top和left属性都要单独设置。 | +| duration | string | - | 是 | 设置单次播放时长。单位支持[s(秒)\|ms(毫秒)],默认单位为ms。 duration为0时,不播放图片。 值改变只会在下一次循环开始时生效,当images中设置了单独的duration后,该属性设置无效。 | +| fillmode5+ | string | forwards | 否 | 指定帧动画执行结束后的状态。可选项有:
- none:恢复初始状态。
- forwards:保持帧动画结束时的状态(在最后一个关键帧中定义)。 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

images

-

Array<ImageFrame>

-

-

-

-

设置图片帧信息集合。每一帧的帧信息包含图片路径、图片大小和图片位置信息。目前支持以下图片格式:png、jpg。ImageFrame的详细说明请见表1

-
说明:

使用时需要使用数据绑定的方式,如images = {{images}},js中声明相应变量:images: [{src: "/common/heart-rate01.png"}, {src: "/common/heart-rate02.png"}]。

-

js中声明相应变量:images: [{src: "/common/heart-rate01.png", duration: "100"}, {src: "/common/heart-rate02.png", duration: "200"}]。支持配置每一帧图片的时长,单位毫秒。6+

-
-

predecode6+

-

number

-

0

-

-

是否启用预解码,默认值为0,即不启用预解码,如该值设为2,则播放当前页时会提前加载后面两张图片至缓存以提升性能。

-

iteration

-

number | string

-

infinite

-

-

设置帧动画播放次数。number表示固定次数,infinite枚举表示无限次数播放。

-

reverse

-

boolean

-

false

-

-

设置播放顺序。false表示从第1张图片播放到最后1张图片; true表示从最后1张图片播放到第1张图片。

-

fixedsize

-

boolean

-

true

-

-

设置图片大小是否固定为组件大小。 true表示图片大小与组件大小一致,此时设置图片的width 、height 、top 和left属性是无效的。false表示每一张图片的 width 、height 、top和left属性都要单独设置。

-

duration

-

string

-

-

-

-

设置单次播放时长。单位支持[s(秒)|ms(毫秒)],默认单位为ms。 duration为0时,不播放图片。 值改变只会在下一次循环开始时生效,当images中设置了单独的duration后,该属性设置无效。

-

fillmode5+

-

string

-

forwards

-

-

指定帧动画执行结束后的状态。可选项有:

-
  • none:恢复初始状态。
  • forwards:保持帧动画结束时的状态(在最后一个关键帧中定义)。
-
+**表1** ImageFrame说明 -**表 1** ImageFrame说明 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| src | <uri> | - | 是 | 图片路径,图片格式为svg,png和jpg。 | +| width | <length> | 0 | 否 | 图片宽度。 | +| height | <length> | 0 | 否 | 图片高度。 | +| top | <length> | 0 | 否 | 图片相对于组件左上角的纵向坐标。 | +| left | <length> | 0 | 否 | 图片相对于组件左上角的横向坐标。 | +| duration6+ | number | - | 否 | 每一帧图片的播放时长,单位毫秒。 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

src

-

<uri>

-

-

-

-

图片路径,图片格式为svg,png和jpg

-

width

-

<length>

-

0

-

-

图片宽度。

-

height

-

<length>

-

0

-

-

图片高度。

-

top

-

<length>

-

0

-

-

图片相对于组件左上角的纵向坐标。

-

left

-

<length>

-

0

-

-

图片相对于组件左上角的横向坐标。

-

duration6+

-

number

-

-

-

-

每一帧图片的播放时长,单位毫秒。

-
-## 样式 +## 样式 -支持[通用样式](js-components-common-styles.md)。 +支持[通用样式](../arkui-js/js-components-common-styles.md)。 -## 事件 -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: +## 事件 - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

start

-

-

-

帧动画启动时触发。

-

pause

-

-

-

帧动画暂停时触发。

-

stop

-

-

-

帧动画结束时触发。

-

resume

-

-

-

帧动画恢复时触发。

-
+除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: -## 方法 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| start | - | 帧动画启动时触发。 | +| pause | - | 帧动画暂停时触发。 | +| stop | - | 帧动画结束时触发。 | +| resume | - | 帧动画恢复时触发。 | -支持[通用方法](js-components-common-methods.md)外,还支持如下方法: - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

start

-

-

-

开始播放图片帧动画。再次调用,重新从第1帧开始播放。

-

pause

-

-

-

暂停播放图片帧动画。

-

stop

-

-

-

停止播放图片帧动画。

-

resume

-

-

-

继续播放图片帧。

-

getState

-

-

-

获取播放状态。可能值有:

-
  • playing:播放中
  • paused:已暂停
  • stopped:已停止。
-
+## 方法 -## 示例 +支持[通用方法](../arkui-js/js-components-common-methods.md)外,还支持如下方法: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| start | - | 开始播放图片帧动画。再次调用,重新从第1帧开始播放。 | +| pause | - | 暂停播放图片帧动画。 | +| stop | - | 停止播放图片帧动画。 | +| resume | - | 继续播放图片帧。 | +| getState | - | 获取播放状态。可能值有:
- playing:播放中
- paused:已暂停
- stopped:已停止。 | + + +## 示例 ``` @@ -411,5 +190,4 @@ export default { }; ``` -![](figures/image-animator.gif) - +![zh-cn_image_0000001127284946](figures/zh-cn_image_0000001127284946.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md index 0983d9d761542fcffb8b8708607af958007b1dc1..c6551400e9cd3f1f99f2489a9c36ac9dbbdc0029 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-image.md @@ -1,209 +1,83 @@ -# image +# image + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 图片组件,用来渲染展示图片。 -## 子组件 + +## 子组件 不支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

src

-

string

-

-

-

-

图片的路径,支持本地路径,图片格式包括png、jpg、bmp、svg和gif。

-

支持Base64字符串6+。格式为data:image/[png | jpeg | bmp | webp];base64, [base64 data], 其中[base64 data]为Base64字符串数据。

-

支持dataability://的路径前缀,用于访问通过data ability提供的图片路径6+

-

alt

-

string

-

-

-

-

占位图,当指定图片在加载中时显示。

-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

object-fit

-

string

-

cover

-

-

设置图片的缩放类型。可选值类型说明请见object-fit 类型说明。(不支持svg格式)

-

match-text-direction

-

boolean

-

false

-

-

图片是否跟随文字方向。(不支持svg格式)

-

fit-original-size

-

boolean

-

false

-

-

image组件在未设置宽高的情况下是否适应图源尺寸(该属性为true时object-fit属性不生效),svg类型图源不支持该属性。

-

object-position7+

-

string

-

0px 0px

-

-

设置图片在组件内展示的位置。

-

设置类型有两种:

-

1. 像素,单位px,示例 15px 15px 代表X轴或者Y轴移动的位置

-

2. 字符,可选值:

-
  • left 图片显示在组件左侧;
  • top 图片显示在组件顶部位置;
  • right 图片显示在组件右侧位置;
  • bottom图片显示在组件底部位置。
-
- -**表 1** object-fit 类型说明 - - - - - - - - - - - - - - - - - - - - - - -

类型

-

描述

-

cover

-

保持宽高比进行缩小或者放大,使得图片两边都大于或等于显示边界,居中显示。

-

contain

-

保持宽高比进行缩小或者放大,使得图片完全显示在显示边界内,居中显示。

-

fill

-

不保持宽高比进行放大缩小,使得图片填充满显示边界。

-

none

-

保持原有尺寸进行居中显示。

-

scale-down

-

保持宽高比居中显示,图片缩小或者保持不变。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->使用svg图片资源时: ->- 建议设置image组件的长宽,否则在父组件的长或宽为无穷大的场景下,svg资源将不会绘制; ->- 如果svg描述中未指定相应的长宽,则svg将会填满image组件区域; ->- 如果svg描述中指定了相应的长宽,和image组件本身的长宽效果如下: ->1. 如果image组件本身的长宽小于svg中的长宽,svg会被裁切,仅显示左上角部分; ->2. 如果image组件本身的长宽大于svg中的长宽,svg会被放置在image组件的左上角,image组件其他部分显示空白。 - -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

complete(Rich)

-

{ width:width, height:height }

-

图片成功加载时触发该回调,返回成功加载的图源尺寸。

-

error(Rich)

-

{ width:width, height:height }

-

图片加载出现异常时触发该回调,异常时长宽为零。

-
- -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| src | string | - | 否 | 图片的路径,支持本地路径,图片格式包括png、jpg、bmp、svg和gif。
支持Base64字符串6+。格式为data:image/[png \| jpeg \| bmp \| webp];base64, [base64 data], 其中[base64 data]为Base64字符串数据。
支持dataability://的路径前缀,用于访问通过data ability提供的图片路径6+。 | +| alt | string | - | 否 | 占位图,当指定图片在加载中时显示。 | + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| object-fit | string | cover | 否 | 设置图片的缩放类型。可选值类型说明请见object-fit 类型说明。(不支持svg格式) | +| match-text-direction | boolean | false | 否 | 图片是否跟随文字方向。(不支持svg格式) | +| fit-original-size | boolean | false | 否 | image组件在未设置宽高的情况下是否适应图源尺寸(该属性为true时object-fit属性不生效),svg类型图源不支持该属性。 | +| object-position7+ | string | 0px 0px | 否 | 设置图片在组件内展示的位置。
设置类型有两种:
1. 像素,单位px,示例 15px 15px 代表X轴或者Y轴移动的位置
2. 字符,可选值:
- left 图片显示在组件左侧;
- top 图片显示在组件顶部位置;
- right 图片显示在组件右侧位置;
- bottom 图片显示在组件底部位置。 | + +**表1** object-fit 类型说明 + +| 类型 | 描述 | +| -------- | -------- | +| cover | 保持宽高比进行缩小或者放大,使得图片两边都大于或等于显示边界,居中显示。 | +| contain | 保持宽高比进行缩小或者放大,使得图片完全显示在显示边界内,居中显示。 | +| fill | 不保持宽高比进行放大缩小,使得图片填充满显示边界。 | +| none | 保持原有尺寸进行居中显示。 | +| scale-down | 保持宽高比居中显示,图片缩小或者保持不变。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 使用svg图片资源时: +> +> - 建议设置image组件的长宽,否则在父组件的长或宽为无穷大的场景下,svg资源将不会绘制; +> +> - 如果svg描述中未指定相应的长宽,则svg将会填满image组件区域; +> +> - 如果svg描述中指定了相应的长宽,和image组件本身的长宽效果如下: +> +> 1. 如果image组件本身的长宽小于svg中的长宽,svg会被裁切,仅显示左上角部分; +> +> 2. 如果image组件本身的长宽大于svg中的长宽,svg会被放置在image组件的左上角,image组件其他部分显示空白。 + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| complete(Rich) | { width:width, height:height } | 图片成功加载时触发该回调,返回成功加载的图源尺寸。 | +| error(Rich) | { width:width, height:height } | 图片加载出现异常时触发该回调,异常时长宽为零。 | + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ```
- + - + <select class="selects" onchange="change_fit"><option for="{{fits}}" value="{{$item}}">{{$item}}</option></select>
``` @@ -214,12 +88,11 @@ align-items: center; flex-direction: column; - } .selects{ margin-top: 20px; width:300px; - border:1px solid #808080; + border:1px solid \#808080; border-radius: 10px; } ``` @@ -237,5 +110,6 @@ export default { } ``` -![](figures/GIF.gif) +![zh-cn_image_0000001127284936](figures/zh-cn_image_0000001127284936.gif) + diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-input.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-input.md index 7cb6905561198191831c3b84c26304be98116871..215d9960e367614c4b9dbc571a28f9992b964088 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-input.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-input.md @@ -1,606 +1,238 @@ -# input +# input + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 交互式组件,包括单选框,多选框,按钮和单行文本输入框。 -## 权限列表 +## 权限列表 无 -## 子组件 -不支持。 +## 子组件 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

type

-

string

-

text

-

-

input组件类型,可选值为text,email,date,time,number,password,button,checkbox,radio。

-

其中text,email,date,time,number,password这六种类型之间支持动态切换修改。

-

button,checkbox,radio不支持动态修改。可选值定义如下:

-
  • button:定义可点击的按钮;
  • checkbox:定义多选框;
  • radio:定义单选按钮,允许在多个拥有相同name值的选项中选中其中一个;
  • text:定义一个单行的文本字段
  • email:定义用于e-mail地址的字段;
  • date:定义 date 控件(包括年、月、日,不包括时间);
  • time:定义用于输入时间的控件(不带时区);
  • number:定义用于输入数字的字段;
  • password:定义密码字段(字段中的字符会被遮蔽)。
    说明:

    智能穿戴仅支持button、radio、checkbox类型。

    -
    -
-

checked

-

boolean

-

false

-

-

当前组件是否选中,仅type为checkbox和radio生效。

-

name

-

string

-

-

-

-

input组件的名称。

-

value

-

string

-

-

-

-

input组件的value值,当类型为radio时必填且相同name值的选项该值唯一。

-

placeholder

-

string

-

-

-

-

设置提示文本的内容,仅在type为text|email|date|time|number|password时生效。

-

maxlength

-

number

-

-

-

-

输入框可输入的最多字符数量,不填表示不限制输入框中字符数量。

-

enterkeytype

-

string

-

default

-

-

不支持动态修改。

-

设置软键盘Enter按钮的类型,可选值为:

-
  • default:默认
  • next:下一项
  • go:前往
  • done:完成
  • send:发送
  • search:搜索
-
说明:

除“next”外,点击后会自动收起软键盘。

-
-

headericon

-

string

-

-

-

-

在文本输入前的图标资源路径,该图标不支持点击事件(button,checkbox和radio不生效),图标格式为jpg,png和svg。

-

showcounter5+

-

boolean

-

false

-

-

文本输入框是否显示计数下标,需要配合maxlength一起使用。

-

menuoptions5+

-

Array<MenuOption>

-

-

-

-

设置文本选择弹框点击更多按钮之后显示的菜单项。

-

autofocus6+

-

boolean

-

false

-

-

是否自动获焦。

-
说明:

应用首页中设置不生效,可在onActive中延迟(100-500ms左右)调用focus方法实现输入框在首页中自动获焦。

-
-

selectedstart6+

-

number

-

-1

-

-

开始选择文本时初始选择位置。

-

selectedend6+

-

number

-

-1

-

-

开始选择文本时结尾选择位置。

-

softkeyboardenabled6+

-

boolean

-

true

-

-

编辑时是否弹出系统软键盘。

-

showpasswordicon6+

-

boolean

-

true

-

-

是否显示密码框末尾的图标(仅type为password时生效)。

-
- -**表 1** MenuOption5+ - - - - - - - - - - - - - - - - -

名称

-

类型

-

描述

-

icon

-

string

-

菜单选项中的图标路径。

-

content

-

string

-

菜单选项中的文本内容。

-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#e6000000

-

-

单行输入框或者按钮的文本颜色。

-

font-size

-

<length>

-

16px

-

-

单行输入框或者按钮的文本尺寸。

-

allow-scale

-

boolean

-

true

-

-

单行输入框或者按钮的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。

-
-

placeholder-color

-

<color>

-

#99000000

-

-

单行输入框的提示文本的颜色,type为text|email|date|time|number|password时生效。

-

font-weight

-

number | string

-

normal

-

-

单行输入框或者按钮的字体粗细,见text组件font-weight的样式属性

-

caret-color6+

-

<color>

-

-

-

-

设置输入光标的颜色。

-
- -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - -- 当input类型为text、email、date、time、number、password时,支持如下事件: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ value:inputValue }

-

输入框输入内容发生变化时触发该事件,返回用户当前输入值。

-
说明:

改变value属性值不会触发该回调。

-
-

enterkeyclick

-

{ value:enterKey }

-

软键盘enter键点击后触发该事件,返回enter按钮的类型,enterKey类型为number,可选值为:

-
  • 2:设置enterkeytype属性为go时生效。
  • 3:设置enterkeytype属性为search时生效。
  • 4:设置enterkeytype属性为send时生效。
  • 5:设置enterkeytype属性为next时生效。
  • 6:不设置enterkeytype或者设置enterkeytype属性为default、done时生效。
-

translate5+

-

{ value: selectedText }

-

设置此事件后,进行文本选择操作后文本选择弹窗会出现翻译按钮,点击翻译按钮之后,触发该回调,返回选中的文本内容。

-

share5+

-

{ value: selectedText }

-

设置此事件后,进行文本选择操作后文本选择弹窗会出现分享按钮,点击分享按钮之后,触发该回调,返回选中的文本内容。

-

search5+

-

{ value: selectedText }

-

设置此事件后,进行文本选择操作后文本选择弹窗会出现搜索按钮,点击搜索按钮之后,触发该回调,返回选中的文本内容。

-

optionselect5+

-

{ index:optionIndex, value: selectedText }

-

文本选择弹窗中设置menuoptions属性后,用户在文本选择操作后,点击菜单项后触发该回调,返回点击的菜单项序号和选中的文本内容。

-

selectchange6+

-

{ start: number,end: number }

-

文本选择变化时触发事件。

-
- -- 当input类型为checkbox、radio时,支持如下事件: - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ checked:true | false }

-

checkbox多选框或radio单选框的checked状态发生变化时触发该事件。

-
- - -## 方法 - -除支持[通用方法](js-components-common-methods.md)外,还支持如下方法: - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

focus

-

{ focus: true|false },focus不传默认为true。

-

使组件获得或者失去焦点,type为text|email|date|time|number|password时,可弹出或收起输入法。

-

showError

-

{ error: string }

-

展示输入错误提示,type为text|email|date|time|number|password时生效。

-

delete6+

-

-

-

type为text|email|date|time|number|password时,根据当前光标位置删除文本内容,如果当前输入组件没有光标,默认删除最后一个字符并展示光标。

-
- -## 示例 - -1. type为text - - ``` - -
- - - -
- ``` - - ``` - /* xxx.css */ - .content { - width: 60%; - flex-direction: column; - align-items: center; - } - .input { - placeholder-color: gray; - } - .button { - background-color: gray; - margin-top: 20px; - } - ``` - - ``` - // xxx.js - import prompt from '@system.prompt' - export default { - change(e){ - prompt.showToast({ - message: "value: " + e.value, - duration: 3000, - }); - }, - enterkeyClick(e){ - prompt.showToast({ - message: "enterkey clicked", - duration: 3000, - }); - }, - buttonClick(e){ - this.$element("input").showError({ - error: 'error text' - }); - }, - } - ``` - - ![](figures/zh-cn_image_0000001127284984.png) - -2. type为button - - ``` - -
- -
- ``` - - ``` - /* xxx.css */ - .div-button { - flex-direction: column; - align-items: center; - - - } - .button { - margin-top: 30px; - width: 280px; - } - ``` - - ![](figures/zh-cn_image_0000001198898293.png) - -3. type为checkbox - - ``` - -
- - -
- ``` - - ``` - /* xxx.css */ - .content{ - width: 100%; - height: 200px; - - - align-items: center; - justify-content: center; - } - ``` - - ``` - // xxx.js - import prompt from '@system.prompt' - export default { - checkboxOnChange(e) { - prompt.showToast({ - message:'checked: ' + e.checked, - duration: 3000, - }); - } - } - ``` - - ![](figures/zh-cn_image_0000001173324749.png) - -4. type为radio - - ``` - -
- - - -
- ``` - - ``` - /* xxx.css */ - .content{ - width: 100%; - height: 200px; - justify-content: center; - align-items: center; - } - ``` - - ``` - // xxx.js - import prompt from '@system.prompt' - export default { - onRadioChange(inputValue, e) { - if (inputValue === e.value) { - prompt.showToast({ - message: 'The chosen radio is ' + e.value, - duration: 3000, - }); - } - } - } - ``` - - ![](figures/zh-cn_image_0000001173324751.png) +不支持。 +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string | text
| 否 | input组件类型,可选值为text,email,date,time,number,password,button,checkbox,radio。
其中text,email,date,time,number,password这六种类型之间支持动态切换修改。
button,checkbox,radio不支持动态修改。可选值定义如下:
- button:定义可点击的按钮;
- checkbox:定义多选框;
- radio:定义单选按钮,允许在多个拥有相同name值的选项中选中其中一个;
- text:定义一个单行的文本字段;
- email:定义用于e-mail地址的字段;
- date:定义 date 控件(包括年、月、日,不包括时间);
- time:定义用于输入时间的控件(不带时区);
- number:定义用于输入数字的字段;
- password:定义密码字段(字段中的字符会被遮蔽)。 | +| checked | boolean | false | 否 | 当前组件是否选中,仅type为checkbox和radio生效。 | +| name | string | - | 否 | input组件的名称。 | +| value | string | - | 否 | input组件的value值,当类型为radio时必填且相同name值的选项该值唯一。 | +| placeholder | string | - | 否 | 设置提示文本的内容,仅在type为text\|email\|date\|time\|number\|password时生效。 | +| maxlength | number | - | 否 | 输入框可输入的最多字符数量,不填表示不限制输入框中字符数量。 | +| enterkeytype | string | default | 否 | 不支持动态修改。
设置软键盘Enter按钮的类型,可选值为:
- default:默认
- next:下一项
- go:前往
- done:完成
- send:发送
- search:搜索
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 除“next”外,点击后会自动收起软键盘。 | +| headericon | string | - | 否 | 在文本输入前的图标资源路径,该图标不支持点击事件(button,checkbox和radio不生效),图标格式为jpg,png和svg。 | +| showcounter5+ | boolean | false | 否 | 文本输入框是否显示计数下标,需要配合maxlength一起使用。 | +| menuoptions5+ | Array<MeunOption> | - | 否 | 设置文本选择弹框点击更多按钮之后显示的菜单项。 | +| autofocus6+ | boolean | false | 否 | 是否自动获焦。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 应用首页中设置不生效,可在onActive中延迟(100-500ms左右)调用focus方法实现输入框在首页中自动获焦。 | +| selectedstart6+ | number | -1 | 否 | 开始选择文本时初始选择位置。 | +| selectedend6+ | number | -1 | 否 | 开始选择文本时结尾选择位置。 | +| softkeyboardenabled6+ | boolean | true | 否 | 编辑时是否弹出系统软键盘。 | +| showpasswordicon6+ | boolean | true | 否 | 是否显示密码框末尾的图标(仅type为password时生效)。 | + +**表1** MenuOption5+ + +| 名称 | 类型 | 描述 | +| -------- | -------- | -------- | +| icon | string | 菜单选项中的图标路径。 | +| content | string | 菜单选项中的文本内容。 | + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#e6000000 | 否 | 单行输入框或者按钮的文本颜色。 | +| font-size | <length> | 16px | 否 | 单行输入框或者按钮的文本尺寸。 | +| allow-scale | boolean | true | 否 | 单行输入框或者按钮的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| placeholder-color | <color> | \#99000000 | 否 | 单行输入框的提示文本的颜色,type为text\|email\|date\|time\|number\|password时生效。 | +| font-weight | number \| string | normal | 否 | 单行输入框或者按钮的字体粗细,见[text组件font-weight的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| caret-color6+ | <color> | - | 否 | 设置输入光标的颜色。 | + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +- 当input类型为text、email、date、time、number、password时,支持如下事件: + | 名称 | 参数 | 描述 | + | -------- | -------- | -------- | + | change | { value:inputValue } | 输入框输入内容发生变化时触发该事件,返回用户当前输入值。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 改变value属性值不会触发该回调。 | + | enterkeyclick | { value:enterKey } | 软键盘enter键点击后触发该事件,返回enter按钮的类型,enterKey类型为number,可选值为:
- 2:设置enterkeytype属性为go时生效。
- 3:设置enterkeytype属性为search时生效。
- 4:设置enterkeytype属性为send时生效。
- 5:设置enterkeytype属性为next时生效。
- 6:不设置enterkeytype或者设置enterkeytype属性为default、done时生效。 | + | translate5+ | { value: selectedText } | 设置此事件后,进行文本选择操作后文本选择弹窗会出现翻译按钮,点击翻译按钮之后,触发该回调,返回选中的文本内容。 | + | share5+ | { value: selectedText } | 设置此事件后,进行文本选择操作后文本选择弹窗会出现分享按钮,点击分享按钮之后,触发该回调,返回选中的文本内容。 | + | search5+ | { value: selectedText } | 设置此事件后,进行文本选择操作后文本选择弹窗会出现搜索按钮,点击搜索按钮之后,触发该回调,返回选中的文本内容。 | + | optionselect5+ | { index:optionIndex, value: selectedText } | 文本选择弹窗中设置menuoptions属性后,用户在文本选择操作后,点击菜单项后触发该回调,返回点击的菜单项序号和选中的文本内容。 | + | selectchange6+ | { start: number,end: number } | 文本选择变化时触发事件。 | + +- 当input类型为checkbox、radio时,支持如下事件: + | 名称 | 参数 | 描述 | + | -------- | -------- | -------- | + | change | { checked:true \| false } | checkbox多选框或radio单选框的checked状态发生变化时触发该事件。 | + +## 方法 + +除支持[通用方法](../arkui-js/js-components-common-methods.md)外,还支持如下方法: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| focus | { focus: true\|false },focus不传默认为true。 | 使组件获得或者失去焦点,type为text\|email\|date\|time\|number\|password时,可弹出或收起输入法。 | +| showError | { error: string } | 展示输入错误提示,type为text\|email\|date\|time\|number\|password时生效。 | +| delete6+ | - | type为text\|email\|date\|time\|number\|password时,根据当前光标位置删除文本内容,如果当前输入组件没有光标,默认删除最后一个字符并展示光标。 | + +## 示例 + +1. type为text + ``` + +
+ + + +
+ ``` + + ``` + /* xxx.css */ + .content { + width: 60%; + flex-direction: column; + align-items: center; + } + .input { + placeholder-color: gray; + } + .button { + background-color: gray; + margin-top: 20px; + } + ``` + + ``` + // xxx.js + import prompt from '@system.prompt' + export default { + change(e){ + prompt.showToast({ + message: "value: " + e.value, + duration: 3000, + }); + }, + enterkeyClick(e){ + prompt.showToast({ + message: "enterkey clicked", + duration: 3000, + }); + }, + buttonClick(e){ + this.$element("input").showError({ + error: 'error text' + }); + }, + } + ``` + + ![zh-cn_image_0000001252835901](figures/zh-cn_image_0000001252835901.png) + +2. type为button + ``` + +
+ +
+ ``` + + ``` + /* xxx.css */ + .div-button { + flex-direction: column; + align-items: center; + } + .button { + margin-top: 30px; + width: 280px; + } + ``` + + ![zh-cn_image_0000001207995958](figures/zh-cn_image_0000001207995958.png) + +3. type为checkbox + ``` + +
+ +
+ ``` + + ``` + /* xxx.css */ + .content{ + width: 100%; + height: 200px; + align-items: center; + justify-content: center; + } + ``` + + ``` + // xxx.js + import prompt from '@system.prompt' + export default { + checkboxOnChange(e) { + prompt.showToast({ + message:'checked: ' + e.checked, + duration: 3000, + }); + } + } + ``` + + ![zh-cn_image_0000001208155956](figures/zh-cn_image_0000001208155956.png) + +4. type为radio + ``` + +
+ + + +
+ ``` + + ``` + /* xxx.css */ + .content{ + width: 100%; + height: 200px; + justify-content: center; + align-items: center; + } + ``` + + ``` + // xxx.js + import prompt from '@system.prompt' + export default { + onRadioChange(inputValue, e) { + if (inputValue === e.value) { + prompt.showToast({ + message: 'The chosen radio is ' + e.value, + duration: 3000, + }); + } + } + } + ``` + + ![zh-cn_image_0000001208315918](figures/zh-cn_image_0000001208315918.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-label.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-label.md index b411b26956eea31e47a1e07117fee3bbb552794f..cfa7a4a4389ecea266e06c90d32fb400c793a98f 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-label.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-label.md @@ -1,261 +1,64 @@ -# label +# label + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 为input、button、textarea组件定义相应的标注,点击该标注时会触发绑定组件的点击效果。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| target | string | - | 否 | 目标组件的属性id值。 | - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

target

-

string

-

-

-

-

目标组件的属性id值。

-
-## 样式 +## 样式 -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#e5000000

-

-

设置文本的颜色。

-

font-size

-

<length>

-

30px

-

-

设置文本的尺寸。

-

allow-scale

-

boolean

-

true

-

-

文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果需要支持动态生效,请参看config描述文件中config-changes标签。

-
-

letter-spacing

-

<length>

-

0px

-

-

设置文本的字符间距。

-

font-style

-

string

-

normal

-

-

设置文本的字体样式,可选值为:

-
  • normal:标准的字体样式;
  • italic:斜体的字体样式。
-

font-weight

-

number | string

-

normal

-

-

设置文本的字体粗细,number类型取值[100, 900],默认为400,取值越大,字体越粗。

-
说明:

number取值必须为100的整数倍。

-
-

string类型取值支持如下四个值:lighter、normal、bold、bolder。

-

text-decoration

-

string

-

none

-

-

设置文本的文本修饰,可选值为:

-
  • underline:文字下划线修饰;
  • line-through:穿过文本的修饰线n
  • none:标准文本。
-

text-align

-

string

-

start

-

-

设置文本的文本对齐方式,可选值为:

-
  • left:文本左对齐;
  • center:文本居中对齐;
  • right:文本右对齐;
  • start:根据文字书写相同的方向对齐;
  • end:根据文字书写相反的方向对齐。
-
说明:

如文本宽度未指定大小,文本的宽度和父容器的宽度大小相等的情况下,对齐效果可能会不明显。

-
-

line-height

-

<length>

-

0px

-

-

设置文本的文本行高,设置为0px时,不限制文本行高,自适应字体大小。

-

text-overflow

-

string

-

clip

-

-

在设置了最大行数的情况下生效,可选值为:

-
  • clip:将文本根据父容器大小进行裁剪显示;
  • ellipsis:根据父容器大小显示,显示不下的文本用省略号代替。需配合max-lines使用。
-

font-family

-

string

-

sans-serif

-

-

设置文本的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-

max-lines

-

number

-

-

-

-

设置文本的最大行数。

-

min-font-size

-

<length>

-

-

-

-

文本最小字号,需要和文本最大字号同时设置,支持文本字号动态变化。设置最大最小字体样式后,font-size不生效。

-

max-font-size

-

<length>

-

-

-

-

文本最大字号,需要和文本最小字号同时设置,支持文本字号动态变化。设置最大最小字体样式后,font-size不生效。

-

font-size-step

-

<length>

-

1px

-

-

文本动态调整字号时的步长,需要设置最小,最大字号样式生效。

-

prefer-font-sizes

-

<array>

-

-

-

-

预设的字号集合,在动态尺寸调整时,优先使用预设字号集合中的字号匹配设置的最大行数,如果预设字号集合未设置,则使用最大最小和步长调整字号。针对仍然无法满足最大行数要求的情况,使用text-overflow设置项进行截断,设置预设尺寸集后,font-size、max-font-size、min-font-size和font-size-step不生效。

-

如:prefer-font-sizes: 12px,14px,16px

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | #e5000000 | 否 | 设置文本的颜色。 | +| font-size | <length> | 30px | 否 | 设置文本的尺寸。 | +| allow-scale | boolean | true | 否 | 文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果需要支持动态生效,请参看config描述文件中config-changes标签。 | +| letter-spacing | <length> | 0px | 否 | 设置文本的字符间距。 | +| font-style | string | normal | 否 | 设置文本的字体样式,可选值为:
- normal:标准的字体样式;
- italic:斜体的字体样式。 | +| font-weight | number \| string | normal | 否 | 设置文本的字体粗细,number类型取值[100, 900],默认为400,取值越大,字体越粗。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> number取值必须为100的整数倍。
string类型取值支持如下四个值:lighter、normal、bold、bolder。 | +| text-decoration | string | none | 否 | 设置文本的文本修饰,可选值为:
- underline:文字下划线修饰;
- line-through:穿过文本的修饰线n
- none:标准文本。 | +| text-align | string | start
| 否 | 设置文本的文本对齐方式,可选值为:
- left:文本左对齐;
- center:文本居中对齐;
- right:文本右对齐;
- start:根据文字书写相同的方向对齐;
- end:根据文字书写相反的方向对齐。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如文本宽度未指定大小,文本的宽度和父容器的宽度大小相等的情况下,对齐效果可能会不明显。 | +| line-height | <length> | 0px | 否 | 设置文本的文本行高,设置为0px时,不限制文本行高,自适应字体大小。 | +| text-overflow | string | clip | 否 | 在设置了最大行数的情况下生效,可选值为:
- clip:将文本根据父容器大小进行裁剪显示;
- ellipsis:根据父容器大小显示,显示不下的文本用省略号代替。需配合max-lines使用。 | +| font-family | string | sans-serif | 否 | 设置文本的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | +| max-lines | number | - | 否 | 设置文本的最大行数。 | +| min-font-size | <length> | - | 否 | 文本最小字号,需要和文本最大字号同时设置,支持文本字号动态变化。设置最大最小字体样式后,font-size不生效。 | +| max-font-size | <length> | - | 否 | 文本最大字号,需要和文本最小字号同时设置,支持文本字号动态变化。设置最大最小字体样式后,font-size不生效。 | +| font-size-step | <length> | 1px | 否 | 文本动态调整字号时的步长,需要设置最小,最大字号样式生效。 | +| prefer-font-sizes | <array> | - | 否 | 预设的字号集合,在动态尺寸调整时,优先使用预设字号集合中的字号匹配设置的最大行数,如果预设字号集合未设置,则使用最大最小和步长调整字号。针对仍然无法满足最大行数要求的情况,使用text-overflow设置项进行截断,设置预设尺寸集后,font-size、max-font-size、min-font-size和font-size-step不生效。
如:prefer-font-sizes: 12px,14px,16px | -## 事件 + +## 事件 不支持。 -## 方法 + +## 方法 不支持。 -## 示例 + +## 示例 ``` @@ -294,5 +97,4 @@ } ``` -![](figures/zh-cn_image_0000001152834002.png) - +![zh-cn_image_0000001152834002](figures/zh-cn_image_0000001152834002.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-marquee.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-marquee.md index efc07b40de3c548bc983bed6829d57a5781fbd6a..94d3f55c402e7f2ac49015b1b9b895b694005189 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-marquee.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-marquee.md @@ -1,209 +1,65 @@ -# marquee +# marquee + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 跑马灯组件,用于展示一段单行滚动的文字。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| scrollamount | number | 6 | 否 | 跑马灯每次滚动时移动的最大长度。 | +| loop | number | -1 | 否 | 跑马灯滚动的次数。如果未指定,则默认值为-1,当该值小于等于零时表示marquee将连续滚动。 | +| direction | string | left | 否 | 设置跑马灯的文字滚动方向,可选值为left和right。 | - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

scrollamount

-

number

-

6

-

-

跑马灯每次滚动时移动的最大长度。

-

loop

-

number

-

-1

-

-

跑马灯滚动的次数。如果未指定,则默认值为-1,当该值小于等于零时表示marquee将连续滚动。

-

direction

-

string

-

left

-

-

设置跑马灯的文字滚动方向,可选值为left和right。

-
-## 样式 +## 样式 -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#e5000000

-

-

设置跑马灯中文字的文本颜色。

-

font-size

-

<length>

-

37.5

-

-

设置跑马灯中文字的文本尺寸。

-

allow-scale

-

boolean

-

true

-

-

设置跑马灯中文字的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。

-
-

font-weight

-

number | string

-

normal

-

-

设置跑马灯中文字的字体的粗细,见text组件font-weight的样式属性

-

font-family

-

string

-

sans-serif

-

-

设置跑马灯中文字的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#e5000000 | 否 | 设置跑马灯中文字的文本颜色。 | +| font-size | <length> | 37.5 | 否 | 设置跑马灯中文字的文本尺寸。 | +| allow-scale | boolean | true | 否 | 设置跑马灯中文字的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| font-weight | number \| string | normal | 否 | 设置跑马灯中文字的字体的粗细,见[text组件font-weight的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family | string | sans-serif | 否 | 设置跑马灯中文字的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | -## 事件 -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: +## 事件 - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

bounce(Rich)

-

-

-

当文本滚动到末尾时触发该事件。

-

finish(Rich)

-

-

-

当完成滚动次数时触发该事件。需要在 loop 属性值大于 0 时触发。

-

start(Rich)

-

-

-

当文本滚动开始时触发该事件。

-
+除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: -## 方法 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| bounce(Rich) | - | 当文本滚动到末尾时触发该事件。 | +| finish(Rich) | - | 当完成滚动次数时触发该事件。需要在 loop 属性值大于 0 时触发。 | +| start(Rich) | - | 当文本滚动开始时触发该事件。 | -除支持[通用方法](js-components-common-methods.md)外,还支持如下方法: +## 方法 - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

start

-

-

-

开始滚动。

-

stop

-

-

-

停止滚动。

-
+除支持[通用方法](../arkui-js/js-components-common-methods.md)外,还支持如下方法: -## 示例 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| start | - | 开始滚动。 | +| stop | - | 停止滚动。 | + + +## 示例 ``` @@ -275,5 +131,6 @@ export default { } ``` -![](figures/sample1.gif) +![zh-cn_image_0000001127284934](figures/zh-cn_image_0000001127284934.gif) + diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-menu.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-menu.md index 4e65ea084a69caa4c7fcf8e3e5e792273c020055..bdb2d032b1f8dd2a8acd3976ae63839971f13a27 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-menu.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-menu.md @@ -1,221 +1,68 @@ -# menu +# menu + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 提供菜单组件,作为临时性弹出窗口,用于展示用户可执行的操作。 -## 权限列表 +## 权限列表 无 -## 子组件 -<[option](js-components-basic-option.md)\>子组件。 +## 子组件 + +<[option](../arkui-js/js-components-basic-option.md)>子组件。 + + +## 属性 -## 属性 +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性:↵ -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性:↵ +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| target | string | - | 否 | 目标元素选择器。当使用目标元素选择器后,点击目标元素会自动弹出menu菜单。弹出菜单位置优先为目标元素右下角,当右边可视空间不足时会适当左移,当下方空间不足时会适当上移。 | +| type | string | click | 否 | 目标元素触发弹窗的方式,可选值有:
- click:点击弹窗。
- longpress:长按弹窗。 | +| title | string | - | 否 | 菜单标题内容。 | - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

target

-

string

-

-

-

-

目标元素选择器。当使用目标元素选择器后,点击目标元素会自动弹出menu菜单。弹出菜单位置优先为目标元素右下角,当右边可视空间不足时会适当左移,当下方空间不足时会适当上移。

-

type

-

string

-

click

-

-

目标元素触发弹窗的方式,可选值有:

-
  • click:点击弹窗。
  • longpress:长按弹窗。
-

title

-

string

-

-

-

-

菜单标题内容。

-
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 不支持focusable、disabled属性。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->不支持focusable、disabled属性。 -## 样式 +## 样式 仅支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

text-color

-

<color>

-

-

-

-

设置菜单的文本颜色。

-

font-size

-

<length>

-

30px

-

-

设置菜单的文本尺寸。

-

allow-scale

-

boolean

-

true

-

-

设置菜单的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。

-
-

letter-spacing

-

<length>

-

0

-

-

设置菜单的字符间距。

-

font-style

-

string

-

normal

-

-

设置菜单的字体样式。见text组件font-style的样式属性

-

font-weight

-

number | string

-

normal

-

-

设置菜单的字体粗细。见text组件font-weight的样式属性

-

font-family

-

string

-

sans-serif

-

-

设置菜单的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| text-color | <color> | - | 否 | 设置菜单的文本颜色。 | +| font-size | <length> | 30px | 否 | 设置菜单的文本尺寸。 | +| allow-scale | boolean | true | 否 | 设置菜单的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| letter-spacing | <length> | 0 | 否 | 设置菜单的字符间距。 | +| font-style | string | normal | 否 | 设置菜单的字体样式。见[text组件font-style的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-weight | number \| string | normal | 否 | 设置菜单的字体粗细。见[text组件font-weight的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family | string | sans-serif | 否 | 设置菜单的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | -## 事件 + +## 事件 仅支持如下事件: - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

selected

-

{ value:value }

-

菜单中某个值被点击选中时触发,返回的value值为option组件的value属性。

-

cancel

-

-

-

用户取消。

-
+| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| selected | { value:value } | 菜单中某个值被点击选中时触发,返回的value值为option组件的value属性。 | +| cancel | - | 用户取消。 | + -## 方法 +## 方法 仅支持如下方法。 - - - - - - - - - - -

名称

-

参数

-

描述

-

show

-

{ x:x, y:y }

-

显示menu菜单。(x, y)指定菜单弹窗位置。其中x表示距离可见区域左边沿的 X 轴坐标,不包含任何滚动偏移,y表示距离可见区域上边沿的 Y 轴坐标,不包含任何滚动偏移以及状态栏。菜单优先显示在弹窗位置右下角,当右边可视空间不足时会适当左移,当下方空间不足时会适当上移。

-
+| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| show | { x:x,  y:y } | 显示menu菜单。(x, y)指定菜单弹窗位置。其中x表示距离可见区域左边沿的 X 轴坐标,不包含任何滚动偏移,y表示距离可见区域上边沿的 Y 轴坐标,不包含任何滚动偏移以及状态栏。菜单优先显示在弹窗位置右下角,当右边可视空间不足时会适当左移,当下方空间不足时会适当上移。 | -## 示例 +## 示例 ``` @@ -256,5 +103,4 @@ export default { } ``` -![](figures/menu13.gif) - +![zh-cn_image_0000001131795738](figures/zh-cn_image_0000001131795738.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-option.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-option.md index 9106a3e8cad1847499654c5918964344f732d872..3e64a270020e709963c3dc6bcf2015c228eded5f 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-option.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-option.md @@ -1,167 +1,59 @@ -# option +# option -当作为<[select](js-components-basic-select.md)\>的子组件时用来展示下拉选择的具体项目。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -当作为<[menu](js-components-basic-menu.md)\>的子组件时用来展示弹出菜单的具体项目。 +当作为<[select](../arkui-js/js-components-basic-select.md)>的子组件时用来展示下拉选择的具体项目。 -## 权限列表 + +当作为<[menu](../arkui-js/js-components-basic-menu.md)>的子组件时用来展示弹出菜单的具体项目。 + + +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性:↵ - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

selected

-

boolean

-

-

-

-

选择项是否为下拉列表的默认项,仅在父组件是select时生效。

-

value

-

string

-

-

-

-

选择项的值,作为select、menu父组件的selected事件中的返回值。

-
说明:

option选项的UI展示值需要放在标签内,如<option value="10">十月</option>

-
-

icon

-

string

-

-

-

-

图标资源路径,该图标展示在选项文本前,图标格式为jpg,png和svg。

-
- -## 样式 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性:↵ + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| selected | boolean | - | 否 | 选择项是否为下拉列表的默认项,仅在父组件是select时生效。 | +| value | string | - | 是 | 选择项的值,作为select、menu父组件的selected事件中的返回值。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> option选项的UI展示值需要放在标签内,如<option value="10">十月</option> | +| icon | string | - | 否 | 图标资源路径,该图标展示在选项文本前,图标格式为jpg,png和svg。 | + + +## 样式 支持如下样式。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#e6000000

-

-

选择项的文本颜色。

-

font-size

-

<length>

-

16px

-

-

选择项的文本尺寸。

-

allow-scale

-

boolean

-

true

-

-

选择项的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。

-
-

font-weight

-

number | string

-

normal

-

-

选择项的字体粗细,见text组件font-weight的样式属性

-

text-decoration

-

string

-

none

-

-

选择项的文本修饰,见text组件text-decoration的样式属性

-

font-family

-

string

-

sans-serif

-

-

选择项的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-
- -## 事件 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#e6000000 | 否 | 选择项的文本颜色。 | +| font-size | <length> | 16px | 否 | 选择项的文本尺寸。 | +| allow-scale | boolean | true | 否 | 选择项的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| font-weight | number \| string | normal | 否 | 选择项的字体粗细,见[text组件font-weight的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| text-decoration | string | none | 否 | 选择项的文本修饰,见[text组件text-decoration的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family | string | sans-serif | 否 | 选择项的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | + + +## 事件 不支持。 -## 方法 + +## 方法 不支持。 -## 示例 -详见[menu示例](js-components-basic-menu.md#section54636714136)。 +## 示例 +详见[menu示例](../arkui-js/js-components-basic-menu.md#示例)。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker-view.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker-view.md index 665604b18b775f0a181febfe2599e31f151c6798..0d9575bb3f714aed9f084bc3ae2f8a6e74bb7d16 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker-view.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker-view.md @@ -1,563 +1,125 @@ -# picker-view +# picker-view + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 嵌入页面的滑动选择器。 -## 子组件 + +## 子组件 不支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

type

-

string

-

text

-

-

设置滑动选择器的类型,该属性不支持动态修改,可选项有:

-
  • text:文本选择器。
  • time:时间选择器。
  • date:日期选择器。
  • datetime:日期时间选择器。
  • multi-text:多列文本选择器。
-
+ +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string | text | 否 | 设置滑动选择器的类型,该属性不支持动态修改,可选项有:
- text:文本选择器。
- time:时间选择器。
- date:日期选择器。
- datetime:日期时间选择器。
- multi-text:多列文本选择器。 | 文本选择器:type=text - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

range

-

Array

-

-

-

-

设置文本选择器的取值范围。

-
说明:

使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:["15", "20", "25"]。

-
-

selected

-

string

-

0

-

-

设置文本选择器的默认选择值,该值需要为range的索引。

-

indicatorprefix

-

string

-

-

-

-

文本选择器选定值增加的前缀字段。

-

indicatorsuffix

-

string

-

-

-

-

文本选择器选定值增加的后缀字段。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| range | Array | - | 否 | 设置文本选择器的取值范围。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:["15", "20", "25"]。 | +| selected | string | 0 | 否 | 设置文本选择器的默认选择值,该值需要为range的索引。 | +| indicatorprefix | string | - | 否 | 文本选择器选定值增加的前缀字段。 | +| indicatorsuffix | string | - | 否 | 文本选择器选定值增加的后缀字段。 | 时间选择器:type=time - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

containsecond

-

boolean

-

false

-

-

时间选择器是否包含秒。

-

selected

-

string

-

当前时间

-

-

设置时间选择器的默认取值,格式为 HH:mm;

-

当包含秒时,格式为HH:mm:ss。

-

hours

-

number

-

241-4

-

-5+

-

-

设置时间选择器采用的时间格式,可选值:

-
  • 12:按照12小时制显示,用上午和下午进行区分;
  • 24:按照24小时制显示。
    说明:

    默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+

    -
    -
-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| containsecond | boolean | false | 否 | 时间选择器是否包含秒。 | +| selected | string | 当前时间 | 否 | 设置时间选择器的默认取值,格式为 HH:mm;
当包含秒时,格式为HH:mm:ss。 | +| hours | number | 241-4
-5+ | 否 | 设置时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | 日期选择器:type=date - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

start

-

<time>

-

1970-1-1

-

-

设置日期选择器的起始时间,格式为 YYYY-MM-DD。

-

end

-

<time>

-

2100-12-31

-

-

设置日期选择器的结束时间,格式为 YYYY-MM-DD。

-

selected

-

string

-

当前日期

-

-

设置日期选择器的默认选择值,格式为 YYYY-MM-DD。

-

lunar5+

-

boolean

-

false

-

-

设置日期选择器弹窗界面是否为农历展示。

-

lunarswitch

-

boolean

-

false

-

-

设置日期选择器是否显示农历开关,显示农历开关时,可以在弹窗界面展现农历的开关由于公历和农历切换。在设置显示农历时,开关状态为开,当设置不显示农历时,开关状态为关。手机生效。

-
说明:

仅手机和平板设备支持。

-
-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| start | <time> | 1970-1-1 | 否 | 设置日期选择器的起始时间,格式为 YYYY-MM-DD。 | +| end | <time> | 2100-12-31 | 否 | 设置日期选择器的结束时间,格式为 YYYY-MM-DD。 | +| selected | string | 当前日期 | 否 | 设置日期选择器的默认选择值,格式为 YYYY-MM-DD。 | +| lunar5+ | boolean | false | 否 | 设置日期选择器弹窗界面是否为农历展示。 | +| lunarswitch | boolean | false | 否 | 设置日期选择器是否显示农历开关,显示农历开关时,可以在弹窗界面展现农历的开关由于公历和农历切换。在设置显示农历时,开关状态为开,当设置不显示农历时,开关状态为关。手机生效。 | 日期时间选择器:type=datetime,日期的选择范围为本年的日月。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

selected

-

string

-

当前日期时间

-

-

设置日期时间选择器的默认取值,格式有两种,为月日时分MM-DD-HH-mm或者年月日时分YYYY-MM-DD-HH-mm,不设置年时,默认使用当前年,该取值表示选择器弹窗时弹窗界面的默认选择值。

-

hours

-

number

-

241-4

-

-5+

-

-

设置日期时间选择器采用的时间格式,可选值:

-
  • 12:按照12小时制显示,用上午和下午进行区分;
  • 24:按照24小时制显示。
    说明:

    默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+

    -
    -
-

lunar5+

-

boolean

-

false

-

-

设置日期时间选择器弹窗界面是否为农历展示。

-

lunarswitch

-

boolean

-

false

-

-

设置日期时间选择器是否显示农历开关,显示农历开关时,可以在弹窗界面展现农历的开关由于公历和农历切换。在设置显示农历时,开关状态为开,当设置不显示农历时,开关状态为关。手机生效。

-
说明:

仅手机和平板设备支持。

-
-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| selected | string | 当前日期时间 | 否 | 设置日期时间选择器的默认取值,格式有两种,为月日时分MM-DD-HH-mm或者年月日时分YYYY-MM-DD-HH-mm,不设置年时,默认使用当前年,该取值表示选择器弹窗时弹窗界面的默认选择值。 | +| hours | number | 241-4
-5+ | 否 | 设置日期时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | +| lunar5+ | boolean | false | 否 | 设置日期时间选择器弹窗界面是否为农历展示。 | +| lunarswitch | boolean | false | 否 | 设置日期时间选择器是否显示农历开关,显示农历开关时,可以在弹窗界面展现农历的开关由于公历和农历切换。在设置显示农历时,开关状态为开,当设置不显示农历时,开关状态为关。手机生效。 | 多列文本选择器:type=multi-text - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

columns

-

number

-

-

-

-

设置多列文本选择器的列数。

-

range

-

二维Array

-

-

-

-

设置多列文本选择器的选择值,该值为二维数组。长度表示多少列,数组的每项表示每列的数据,如 [["a","b"], ["c","d"]]。

-
说明:

使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:[["a","b"], ["c","d"]]。

-
-

selected

-

Array

-

[0,0,0,…]

-

-

设置多列文本选择器的默认值,每一列被选中项对应的索引构成的数组,该取值表示选择器弹窗时弹窗界面的默认选择值。

-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#ffffff

-

-

候选项字体颜色。

-

font-size

-

<length>

-

16px

-

-

候选项字体尺寸,类型length,单位px。

-

selected-color

-

<color>

-

#ff0a69f7

-

-

选中项字体颜色。

-

selected-font-size

-

<length>

-

20px

-

-

选中项字体尺寸,类型length,单位px。

-

disappear-color5+

-

<color>

-

#ffffff

-

-

渐变消失项的字体颜色。消失项是在一列中有五个选项场景下最上和最下的两个选项。

-
说明:

仅手机和平板设备支持。

-
-

disappear-font-size5+

-

<length>

-

14px

-

-

渐变消失项的字体尺寸。消失项是在一列中有五个选项场景下最上和最下的两个选项。

-
说明:

仅手机和平板设备支持。

-
-

font-family

-

string

-

sans-serif

-

-

选项字体类型。字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-
- -## 事件 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| columns | number | - | 是 | 设置多列文本选择器的列数。 | +| range | 二维Array | - | 否 | 设置多列文本选择器的选择值,该值为二维数组。长度表示多少列,数组的每项表示每列的数据,如  [["a","b"], ["c","d"]]。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:[["a","b"], ["c","d"]]。 | +| selected | Array | [0,0,0,…] | 否 | 设置多列文本选择器的默认值,每一列被选中项对应的索引构成的数组,该取值表示选择器弹窗时弹窗界面的默认选择值。 | + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#ffffff | 否 | 候选项字体颜色。 | +| font-size | <length> | 16px | 否 | 候选项字体尺寸,类型length,单位px。 | +| selected-color | <color> | #ff0a69f7 | 否 | 选中项字体颜色。 | +| selected-font-size | <length> | 20px | 否 | 选中项字体尺寸,类型length,单位px。 | +| disappear-color5+ | <color> | \#ffffff | 否 | 渐变消失项的字体颜色。消失项是在一列中有五个选项场景下最上和最下的两个选项。 | +| disappear-font-size5+ | <length> | 14px | 否 | 渐变消失项的字体尺寸。消失项是在一列中有五个选项场景下最上和最下的两个选项。 | +| font-family | string | sans-serif | 否 | 选项字体类型。字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | + + +## 事件 仅支持如下事件: type=text: - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ newValue: newValue, newSelected: newSelected }

-

文本选择器选定值后触发该事件。

-
+| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { newValue: newValue, newSelected: newSelected } | 文本选择器选定值后触发该事件。 | type=time: - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ hour: hour, minute: minute, [second:second] }

-

时间选择器选定值后触发该事件。

-

包含秒时,返回时分秒。

-
+| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { hour: hour, minute: minute, [second:second]} | 时间选择器选定值后触发该事件。
包含秒时,返回时分秒。 | type=date: - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ year:year, month:month, day:day }

-

日期选择器选择值后触发该事件。

-
+| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { year:year, month:month, day:day } | 日期选择器选择值后触发该事件。 | type=datetime: - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ year:year, month:month, day:day, hour:hour, minute:minute }

-

日期时间选择器选择值后触发该事件。

-
+| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { year:year, month:month, day:day,  hour:hour, minute:minute } | 日期时间选择器选择值后触发该事件。 | type=multi-text: - - - - - - - - - - -

名称

-

参数

-

描述

-

columnchange

-

{ column:column, newValue:newValue, newSelected:newSelected }

-

多列文本选择器某一列的值改变时触发该事件,column:第几列修改,newValue:选中的值,newSelected:选中值对应的索引。

-
- -## 方法 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| columnchange | { column:column, newValue:newValue, newSelected:newSelected } | 多列文本选择器某一列的值改变时触发该事件,column:第几列修改,newValue:选中的值,newSelected:选中值对应的索引。 | + + +## 方法 不支持。 -## 示例 + +## 示例 ``` @@ -621,5 +183,4 @@ export default { } ``` -![](figures/sssssss.png) - +![zh-cn_image_0000001173324845](figures/zh-cn_image_0000001173324845.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md index c49072a3cf378833f26a6bd6b6850ced66798034..aae0f7e0c51f613d8f0bc597b4c68e1eb525e717 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-picker.md @@ -1,708 +1,166 @@ -# picker +# picker + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 滑动选择器组件,类型支持普通选择器、日期选择器、时间选择器、时间日期选择器和多列文本选择器。 -## 权限列表 + +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性:↵ - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

type

-

string

-

-

-

-

该属性值不支持动态修改。可选择项有:

-
  • text:文本选择器。
  • date:日期选择器。
  • time:时间选择器。
  • datetime:日期时间选择器。
  • multi-text:多列文本选择器。
-
- -### 普通选择器 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性:↵ + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string | - | 否 | 该属性值不支持动态修改。可选择项有:
- text:文本选择器。
- date:日期选择器。
- time:时间选择器。
- datetime:日期时间选择器。
- multi-text:多列文本选择器。 | + + +### 普通选择器 滑动选择器类型设置为text时表示普通选择器。 - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

range

-

Array

-

-

-

-

设置普通选择器的取值范围,如["15", "20", "25"]。

-
说明:

使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:["15", "20", "25"]。

-
-

selected

-

string

-

0

-

-

设置普通选择器弹窗的默认取值,取值需要是 range 的索引值,该取值表示选择器弹窗界面的默认选择值。

-

value

-

string

-

-

-

-

设置普通选择器的值。

-
- -### 日期选择器 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| range | Array | - | 否 | 设置普通选择器的取值范围,如["15", "20", "25"]。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:["15", "20", "25"]。 | +| selected | string | 0 | 否 | 设置普通选择器弹窗的默认取值,取值需要是 range 的索引值,该取值表示选择器弹窗界面的默认选择值。 | +| value | string | - | 否 | 设置普通选择器的值。 | + + +### 日期选择器 滑动选择器类型设置为date时表示日期选择器。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

start

-

<time>

-

1970-1-1

-

-

设置日期选择器的起始时间,格式为 YYYY-MM-DD。

-

end

-

<time>

-

2100-12-31

-

-

设置日期选择器的结束时间,格式为 YYYY-MM-DD。

-

selected

-

string

-

当前日期

-

-

设置日期选择器弹窗的默认取值,格式为 YYYY-MM-DD,该取值表示选择器弹窗界面的默认选择值。

-

value

-

string

-

-

-

-

设置日期选择器的值。

-

lunar5+

-

boolean

-

false

-

-

设置日期选择器弹窗界面是否为农历展示。

-

lunarswitch

-

boolean

-

false

-

-

设置日期选择器是否显示农历开关。当值为true时,显示农历开关,点击农历开关可切换公历和农历。当值为false时,不显示农历开关。

-
说明:

仅手机和平板设备支持。 当lunarswitch=true且lunar=true时,开关按钮处于被选中状态。

-
-
- -### 时间选择器 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| start | <time> | 1970-1-1 | 否 | 设置日期选择器的起始时间,格式为 YYYY-MM-DD。 | +| end | <time> | 2100-12-31 | 否 | 设置日期选择器的结束时间,格式为 YYYY-MM-DD。 | +| selected | string | 当前日期 | 否 | 设置日期选择器弹窗的默认取值,格式为 YYYY-MM-DD,该取值表示选择器弹窗界面的默认选择值。 | +| value | string | - | 是 | 设置日期选择器的值。 | +| lunar5+ | boolean | false | 否 | 设置日期选择器弹窗界面是否为农历展示。 | +| lunarswitch | boolean | false | 否 | 设置日期选择器是否显示农历开关。当值为true时,显示农历开关,点击农历开关可切换公历和农历。当值为false时,不显示农历开关。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅手机和平板设备支持。 当lunarswitch=true且lunar=true时,开关按钮处于被选中状态。 | + + +### 时间选择器 滑动选择器类型设置为time时表示时间选择器。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

containsecond

-

boolean

-

false

-

-

设置时间选择器是否包含秒。

-

selected

-

string

-

当前时间

-

-

设置时间选择器弹窗的默认取值,格式为 HH:mm;当包含秒时,格式为HH:mm:ss,

-

该取值表示选择器弹窗界面的默认选择值。

-

value

-

string

-

-

-

-

设置时间选择器的值。

-

hours

-

number

-

241-4

-

-5+

-

-

设置时间选择器采用的时间格式,可选值:

-
  • 12:按照12小时制显示,用上午和下午进行区分;
  • 24:按照24小时制显示。
    说明:

    默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+

    -
    -
-
- -### 日期时间选择器 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| containsecond | boolean | false | 否 | 设置时间选择器是否包含秒。 | +| selected | string | 当前时间 | 否 | 设置时间选择器弹窗的默认取值,格式为 HH:mm;当包含秒时,格式为HH:mm:ss,
该取值表示选择器弹窗界面的默认选择值。 | +| value | string | - | 否 | 设置时间选择器的值。 | +| hours | number | 241-4
-5+ | 否 | 设置时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | + + +### 日期时间选择器 滑动选择器类型设置为datetime时表示日期时间选择器,日期的选择范围为本年的日月。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

selected

-

string

-

当前日期时间

-

-

设置日期时间选择器弹窗的默认取值,有两种可选格式。

-
  • 月日时分:MM-DD-HH-mm
  • 年月日时分:YYYY-MM-DD-HH-mm
-

不设置年时,默认使用当前年,该取值表示选择器弹窗界面的默认选择值。

-

value

-

string

-

-

-

-

设置日期时间选择器的值。

-

hours

-

number

-

241-4

-

-5+

-

-

设置日期时间选择器采用的时间格式,可选值:

-
  • 12:按照12小时制显示,用上午和下午进行区分;
  • 24:按照24小时制显示。
    说明:

    默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+

    -
    -
-

lunar5+

-

boolean

-

false

-

-

设置日期时间选择器弹窗界面是否为农历展示。

-

lunarswitch

-

boolean

-

false

-

-

设置日期选择器是否显示农历开关。当值为true时,显示农历开关,点击农历开关可切换公历和农历。当值为false时,不显示农历开关。

-
说明:

仅手机和平板设备支持。 当lunarswitch=true且lunar=true时,开关按钮处于被选中状态。

-
-
- -### 多列文本选择器 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| selected | string | 当前日期时间 | 否 | 设置日期时间选择器弹窗的默认取值,有两种可选格式。
- 月日时分:MM-DD-HH-mm
- 年月日时分:YYYY-MM-DD-HH-mm
不设置年时,默认使用当前年,该取值表示选择器弹窗界面的默认选择值。 | +| value | string | - | 是 | 设置日期时间选择器的值。 | +| hours | number | 241-4
-5+ | 否 | 设置日期时间选择器采用的时间格式,可选值:
- 12:按照12小时制显示,用上午和下午进行区分;
- 24:按照24小时制显示。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 默认值会依据系统当前所选地区和语言选择当地习惯的小时制(12小时制或24小时制)。5+ | +| lunar5+ | boolean | false | 否 | 设置日期时间选择器弹窗界面是否为农历展示。 | +| lunarswitch | boolean | false | 否 | 设置日期选择器是否显示农历开关。当值为true时,显示农历开关,点击农历开关可切换公历和农历。当值为false时,不显示农历开关。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅手机和平板设备支持。 当lunarswitch=true且lunar=true时,开关按钮处于被选中状态。 | + + +### 多列文本选择器 滑动选择器类型设置为multi-text时表示多列文本选择器。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

columns

-

number

-

-

-

-

设置多列文本选择器的列数。

-

range

-

二维Array

-

-

-

-

设置多列文本选择器的选择项,其中range 为二维数组。长度表示多少列,数组的每项表示每列的数据,如 [["a","b"], ["c","d"]]。

-
说明:

使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:[["a","b"], ["c","d"]]。

-
-

selected

-

Array

-

[0,0,0,…]

-

-

设置多列文本选择器弹窗的默认值,每一列被选中项对应的索引构成的数组,该取值表示选择器弹窗界面的默认选择值。

-

value

-

Array

-

-

-

-

设置多列文本选择器的值,每一列被选中项对应的值构成的数组。

-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

text-color

-

<color>

-

-

-

-

选择器的文本颜色。

-

font-size

-

<length>

-

-

-

-

选择器的文本尺寸。

-

allow-scale

-

boolean

-

true

-

-

选择器的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。

-
-

letter-spacing

-

<length>

-

0

-

-

选择器的字符间距。见text组件的letter-spacing样式属性

-

text-decoration

-

string

-

-

-

-

选择器的文本修饰。见text组件的text-decoration样式属性

-

font-style

-

string

-

normal

-

-

选择器的字体样式。见text组件的font-style样式属性

-

font-weight

-

number | string

-

normal

-

-

选择器的字体粗细。见text组件的font-weight样式属性

-

font-family

-

string

-

sans-serif

-

-

选择器的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-

line-height

-

<length>

-

0px

-

-

选择器的文本行高。

-

column-height5+

-

<length>

-

-

-

-

选择器的选择项列表高度。

-
说明:

仅手机和平板设备支持。

-
-
- -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - -### 普通选择器 - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ newValue: newValue, newSelected: newSelected }

-

普通选择器选择值后点击弹窗中的确定按钮时触发该事件(newSelected为索引)。

-

cancel

-

-

-

用户点击弹窗中的取消按钮时触发该事件。

-
- -### 日期选择器 - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ year: year, month: month, day: day }

-

日期选择器选择值后点击弹窗中的确认按钮时触发该事件。

-
说明:

month值范围为: 0(1月)~11(12月)。5+

-
-

cancel

-

-

-

用户点击弹窗中的取消按钮时触发该事件。

-
- -### 日期时间选择器 - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ year: year, month: month, day: day, hour: hour, minute: minute}

-

日期时间选择器选择值后点击弹窗中的确认按钮时触发该事件。

-

cancel

-

-

-

用户点击弹窗中的取消按钮时触发该事件。

-
- -### 时间选择器 - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ hour: hour, minute: minute, [second: second] }

-

时间选择器选择值后点击弹窗中的确认按钮时触发该事件,当使用时分秒时,还包含秒数据。

-

cancel

-

-

-

用户点击弹窗中的取消按钮时触发该事件。

-
- -### 多列文本选择器 - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ newValue: [newValue1, newValue2, newValue3, …], newSelected:[newSelected1, newSelected2, newSelected3, …] }

-

多列文本选择器选择值后点击弹窗中的确认按钮时触发该事件,其中:

-
  • newValue:被选中项对应的值构成的数组。
  • newSelected:被选中项对应的索引构成的数组,两者的长度和range的长度一致。
-

columnchange

-

{ column: column, newValue: newValue, newSelected: newSelected }

-

多列文本选择器中某一列的值改变时触发该事件,其中:

-
  • column:第几列修改。
  • newValue:选中的值。
  • newSelected:选中值对应的索引。
-

cancel

-

-

-

用户点击弹窗中的取消按钮时触发该事件。

-
- -## 方法 - -除支持[通用方法](js-components-common-methods.md)外,支持如下方法: - - - - - - - - - - - -

名称

-

参数

-

描述

-

show

-

-

-

显示 picker。

-
- -## 示例 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| columns | number | - | 是 | 设置多列文本选择器的列数。 | +| range | 二维Array | - | 否 | 设置多列文本选择器的选择项,其中range 为二维数组。长度表示多少列,数组的每项表示每列的数据,如  [["a","b"], ["c","d"]]。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用时需要使用数据绑定的方式,如range = {{data}},js中声明相应变量:data:[["a","b"], ["c","d"]]。 | +| selected | Array | [0,0,0,…] | 否 | 设置多列文本选择器弹窗的默认值,每一列被选中项对应的索引构成的数组,该取值表示选择器弹窗界面的默认选择值。 | +| value | Array | - | 否 | 设置多列文本选择器的值,每一列被选中项对应的值构成的数组。 | + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| text-color | <color> | - | 否 | 选择器的文本颜色。 | +| font-size | <length> | - | 否 | 选择器的文本尺寸。 | +| allow-scale | boolean | true | 否 | 选择器的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| letter-spacing | <length> | 0 | 否 | 选择器的字符间距。见[text组件的letter-spacing样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| text-decoration | string | - | 否 | 选择器的文本修饰。见[text组件的text-decoration样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-style | string | normal | 否 | 选择器的字体样式。见[text组件的font-style样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-weight | number \| string | normal | 否 | 选择器的字体粗细。见[text组件的font-weight样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family | string | sans-serif | 否 | 选择器的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | +| line-height | <length> | 0px | 否 | 选择器的文本行高。 | +| column-height5+ | <length> | - | 否 | 选择器的选择项列表高度。 | + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + + +### 普通选择器 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { newValue: newValue, newSelected: newSelected } | 普通选择器选择值后点击弹窗中的确定按钮时触发该事件(newSelected为索引)。 | +| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | + + +### 日期选择器 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { year: year, month: month, day: day } | 日期选择器选择值后点击弹窗中的确认按钮时触发该事件。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> month值范围为: 0(1月)~11(12月)。5+ | +| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | + + +### 日期时间选择器 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { year: year, month: month, day: day,  hour: hour, minute: minute} | 日期时间选择器选择值后点击弹窗中的确认按钮时触发该事件。 | +| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | + + +### 时间选择器 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { hour: hour, minute: minute, [second: second] } | 时间选择器选择值后点击弹窗中的确认按钮时触发该事件,当使用时分秒时,还包含秒数据。 | +| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | + + +### 多列文本选择器 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { newValue: [newValue1, newValue2, newValue3, …], newSelected:[newSelected1, newSelected2, newSelected3, …] } | 多列文本选择器选择值后点击弹窗中的确认按钮时触发该事件,其中:
- newValue:被选中项对应的值构成的数组。
- newSelected:被选中项对应的索引构成的数组,两者的长度和range的长度一致。 | +| columnchange | { column: column, newValue: newValue, newSelected: newSelected } | 多列文本选择器中某一列的值改变时触发该事件,其中:
- column:第几列修改。
- newValue:选中的值。
- newSelected:选中值对应的索引。 | +| cancel | - | 用户点击弹窗中的取消按钮时触发该事件。 | + + +## 方法 + +除支持[通用方法](../arkui-js/js-components-common-methods.md)外,支持如下方法: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| show | - | 显示 picker。 | + + +## 示例 ``` @@ -829,5 +287,4 @@ export default { } ``` -![](figures/mmmm.gif) - +![zh-cn_image_0000001191939702](figures/zh-cn_image_0000001191939702.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-piece.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-piece.md index 7cab19b45c3046537b850656563fdc81f09238f5..6052a8fea067fd39a6870faad84d93c0f80546f1 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-piece.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-piece.md @@ -1,97 +1,49 @@ -# piece +# piece + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 一种块状的入口,可包含图片和文本。常用于展示收件人,例如:邮件收件人或信息收件人。 -## 子组件 + +## 子组件 无 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

content

-

string

-

-

-

-

操作块文本内容。

-

closable

-

boolean

-

false

-

-

设置当前操作块是否显示删除图标,当显示删除图标时,点击删除图标会触发close事件。

-

icon

-

string

-

-

-

-

操作块删除图标的url,支持本地。

-
- -## 样式 - -支持[通用样式](js-components-common-styles.md)。 - ->![](../../public_sys-resources/icon-note.gif) **说明:** ->文本和图片默认在整个piece组件中居中。 - -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - -

名称

-

参数

-

描述

-

close

-

-

-

当piece组件点击删除图标触发,此时可以通过渲染属性if删除该组件。

-
- -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| content | string | - | 是 | 操作块文本内容。 | +| closable | boolean | false | 否 | 设置当前操作块是否显示删除图标,当显示删除图标时,点击删除图标会触发close事件。 | +| icon | string | - | 否 | 操作块删除图标的url,支持本地路径。 | + + +## 样式 + +支持[通用样式](../arkui-js/js-components-common-styles.md)。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 文本和图片默认在整个piece组件中居中。 + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| close | - | 当piece组件点击删除图标触发,此时可以通过渲染属性if删除该组件。 | + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -124,5 +76,4 @@ export default { } ``` -![](figures/11-1.gif) - +![zh-cn_image_0000001177428498](figures/zh-cn_image_0000001177428498.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-progress.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-progress.md index 9be9c6722894dceabb7714da9fb126ef503369b7..9eaac1397d576e2515afc0e1f2970762deb05c9e 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-progress.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-progress.md @@ -1,480 +1,108 @@ -# progress +# progress + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 进度条,用于显示内容加载或操作处理进度。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

type

-

string

-

horizontal

-

-

设置进度条的类型,该属性不支持动态修改,可选值为:

-
  • horizontal:线性进度条;
  • circular:loading样式进度条;
  • ring:圆环形进度条;
  • scale-ring:带刻度圆环形进度条
  • arc:弧形进度条。
  • eclipse5+:圆形进度条,展现类似月圆月缺的进度展示效果。
-
+ +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string | horizontal | 否 | 设置进度条的类型,该属性不支持动态修改,可选值为:
- horizontal:线性进度条;
- circular:loading样式进度条;
- ring:圆环形进度条;
- scale-ring:带刻度圆环形进度条
- arc:弧形进度条。
- eclipse5+:圆形进度条,展现类似月圆月缺的进度展示效果。 | 不同类型的进度条还支持不同的属性: -- 类型为horizontal、ring、scale-ring时,支持如下属性: - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

percent

-

number

-

0

-

-

当前进度。取值范围为0-100。

-

secondarypercent

-

number

-

0

-

-

次级进度。取值范围为0-100。

-
- -- 类型为ring、scale-ring时,支持如下属性: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

clockwise

-

boolean

-

true

-

-

圆环形进度条是否采用顺时针。

-
- -- 类型为arc、eclipse5+时,支持如下属性: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

percent

-

number

-

0

-

-

当前进度。取值范围为0-100。

-
- - -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: +- 类型为horizontal、ring、scale-ring时,支持如下属性: + | 名称 | 类型 | 默认值 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | -------- | + | percent | number | 0 | 否 | 当前进度。取值范围为0-100。 | + | secondarypercent | number | 0 | 否 | 次级进度。取值范围为0-100。 | + +- 类型为ring、scale-ring时,支持如下属性: + | 名称 | 类型 | 默认值 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | -------- | + | clockwise | boolean | true | 否 | 圆环形进度条是否采用顺时针。 | + +- 类型为arc、eclipse5+时,支持如下属性: + | 名称 | 类型 | 默认值 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | -------- | + | percent | number | 0 | 否 | 当前进度。取值范围为0-100。 | + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: type=horizontal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#ff007dff

-

-

设置进度条的颜色。

-

stroke-width

-

<length>

-

4px

-

-

-

设置进度条的宽度。

-

background-color

-

<color>

-

-

-

-

设置进度条的背景色。

-

secondary-color

-

<color>

-

-

-

-

设置次级进度条的颜色。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#ff007dff | 否 | 设置进度条的颜色。 | +| stroke-width | <length> | 4px | 否 | 设置进度条的宽度。 | +| background-color | <color> | - | 否 | 设置进度条的背景色。 | +| secondary-color | <color> | - | 否 | 设置次级进度条的颜色。 | type=circular - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

-

-

-

loading进度条上的圆点颜色。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | - | 否 | loading进度条上的圆点颜色。 | type=ring, scale-ring - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color> | <linear-gradient>

-

-

-

-

环形进度条的颜色,ring类型支持线性渐变色设置。

-
说明:

线性渐变色仅支持两个颜色参数设置格式,如color = linear-gradient(#ff0000, #00ff00)。

-
-

background-color

-

<color>

-

-

-

-

环形进度条的背景色。

-

secondary-color

-

<color>

-

-

-

-

环形次级进度条的颜色。

-

stroke-width

-

<length>

-

10px

-

-

环形进度条的宽度。

-

scale-width

-

<length>

-

-

-

-

带刻度的环形进度条的刻度粗细,类型为scale-ring生效。

-

scale-number

-

number

-

120

-

-

带刻度的环形进度条的刻度数量,类型为scale-ring生效。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> \| <linear-gradient> | - | 否 | 环形进度条的颜色,ring类型支持线性渐变色设置。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 线性渐变色仅支持两个颜色参数设置格式,如color = linear-gradient(\#ff0000, \#00ff00)。 | +| background-color | <color> | - | 否 | 环形进度条的背景色。 | +| secondary-color | <color> | - | 否 | 环形次级进度条的颜色。 | +| stroke-width | <length> | 10px | 否 | 环形进度条的宽度。 | +| scale-width | <length> | - | 否 | 带刻度的环形进度条的刻度粗细,类型为scale-ring生效。 | +| scale-number | number | 120 | 否 | 带刻度的环形进度条的刻度数量,类型为scale-ring生效。 | type=arc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

-

-

-

-

弧形进度条的颜色。

-

background-color

-

<color>

-

-

-

-

-

弧形进度条的背景色。

-

stroke-width

-

<length>

-

4px

-

-

弧形进度条的宽度。

-
说明:

进度条宽度越大,进度条越靠近圆心,进度条始终在半径区域内。

-
-

start-angle

-

<deg>

-

240

-

-

弧形进度条起始角度,以时钟0点为基线,取值范围为0到360(顺时针)。

-

total-angle

-

<deg>

-

240

-

-

弧形进度条总长度,范围为-360到360,负数标识起点到终点为逆时针。

-

center-x

-

<length>

-

弧形进度条宽度的一半

-

-

弧形进度条中心位置,(坐标原点为组件左上角顶点)。该样式需要和center-y和radius一起使用。

-

center-y

-

<length>

-

弧形进度条高度的一半

-

-

弧形进度条中心位置,(坐标原点为组件左上角顶点)。该样式需要和center-x和radius一起使用。

-

radius

-

<length>

-

弧形进度条宽高最小值的一半

-

-

弧形进度条半径,该样式需要和center-x和center-y一起使用。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | - | 否 | 弧形进度条的颜色。 | +| background-color | <color> | - | 否 | 弧形进度条的背景色。 | +| stroke-width | <length> | 4px | 否 | 弧形进度条的宽度。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 进度条宽度越大,进度条越靠近圆心,进度条始终在半径区域内。 | +| start-angle | <deg> | 240 | 否 | 弧形进度条起始角度,以时钟0点为基线,取值范围为0到360(顺时针)。 | +| total-angle | <deg> | 240 | 否 | 弧形进度条总长度,范围为-360到360,负数标识起点到终点为逆时针。 | +| center-x | <length> | 弧形进度条宽度的一半 | 否 | 弧形进度条中心位置,(坐标原点为组件左上角顶点)。该样式需要和center-y和radius一起使用。 | +| center-y | <length> | 弧形进度条高度的一半 | 否 | 弧形进度条中心位置,(坐标原点为组件左上角顶点)。该样式需要和center-x和radius一起使用。 | +| radius | <length> | 弧形进度条宽高最小值的一半 | 否 | 弧形进度条半径,该样式需要和center-x和center-y一起使用。 | type=eclipse5+ - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

-

-

-

圆形进度条的颜色。

-

background-color

-

<color>

-

-

-

-

弧形进度条的背景色。

-
- -## 事件 - -支持[通用事件](js-components-common-events.md)。 - -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | - | 否 | 圆形进度条的颜色。 | +| background-color | <color> | - | 否 | 弧形进度条的背景色。 | + + +## 事件 + +支持[通用事件](../arkui-js/js-components-common-events.md)。 + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -500,5 +128,6 @@ type=eclipse5+ } ``` -![](figures/progress.png) +![zh-cn_image_0000001180339632](figures/zh-cn_image_0000001180339632.png) + diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-qrcode.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-qrcode.md index d1149797eb3119b84e75a83ac0fd36388c5185b0..b0c73ee2aedfc933b78457fa0dbf535b6dbcd41f 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-qrcode.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-qrcode.md @@ -1,111 +1,57 @@ -# qrcode +# qrcode + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 生成并显示二维码。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

value

-

string

-

-

-

-

用来生成二维码的内容。

-

type

-

string

-

rect

-

-

二维码类型。可能选项有:

-
  • rect:矩形二维码。
  • circle:圆形二维码。
-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#000000

-

-

二维码颜色。

-

background-color

-

<color>

-

#ffffff

-

-

二维码背景颜色。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- width和height不一致时,取二者较小值作为二维码的边长。且最终生成的二维码居中显示。 ->- width和height只设置一个时,取设置的值作为二维码的边长。都不设置时,使用200px作为默认边长。 - -## 事件 - -支持[通用事件](js-components-common-events.md)。 - -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| value | string | - | 是 | 用来生成二维码的内容。 | +| type | string | rect | 否 | 二维码类型。可能选项有:
- rect:矩形二维码。
- circle:圆形二维码。 | + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#000000 | 否 | 二维码颜色。 | +| background-color | <color> | \#ffffff | 否 | 二维码背景颜色。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - width和height不一致时,取二者较小值作为二维码的边长。且最终生成的二维码居中显示。 +> +> +> - width和height只设置一个时,取设置的值作为二维码的边长。都不设置时,使用200px作为默认边长。 +> + + +## 事件 + +支持[通用事件](../arkui-js/js-components-common-events.md)。 + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -174,5 +120,6 @@ export default { } ``` -![](figures/12.gif) +![zh-cn_image_0000001222948301](figures/zh-cn_image_0000001222948301.gif) + diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-rating.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-rating.md index 40811a1e11b65bcddeea2c38c74af62550327e78..dbd604a380dd9c8f5b589b19bd8428ec5f9351ec 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-rating.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-rating.md @@ -1,197 +1,65 @@ -# rating +# rating + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 评分条,表示用户使用感受的衡量标准条。 -## 权限列表 + +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

numstars

-

number

-

5

-

-

设置评分条的星级总数。

-

rating

-

number

-

0

-

-

设置评分条当前评星数。

-

stepsize

-

number

-

0.5

-

-

设置评分条的评星步长。

-
说明:

仅手机和平板设备支持

-
-

indicator

-

boolean

-

false

-

-

设置评分条是否作为一个指示器,此时用户不可操作。

-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

star-background

-

string

-

-

-

-

设置单个星级未选中的背景图片,只支持本地路径图片,图片格式为png和jpg。

-

star-foreground

-

string

-

-

-

-

设置单个星级选中的前景图片,只支持本地路径图片,图片格式为png和jpg。

-

star-secondary

-

string

-

-

-

-

设置单个星级部分选中的次级背景图片,该图片会覆盖背景图片,只支持本地路径图片,图片格式为png和jpg。

-

width

-

<length>|<percentage>

-

120px

-

60px(不可操作)

-

-

默认值是在未设置自定义资源和评分星数时,使用5个星和默认资源下的宽度值。

-

height

-

<length>|<percentage>

-

24px

-

12px(不可操作)

-

-

默认值是在未设置自定义资源和评分星数时,使用5个星和默认资源下的高度值。

-

rtl-flip

-

boolean

-

true

-

-

在RTL文字方向下是否自动翻转图源。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->star-background,star-secondary,star-foreground三个星级图源必须全部设置,否则默认的星级颜色为灰色,以此提示图源设置错误。 - -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ rating: number }

-

评分条的评星发生改变时触发该回调。

-
- -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| numstars | number | 5 | 否 | 设置评分条的星级总数。 | +| rating | number | 0 | 否 | 设置评分条当前评星数。 | +| stepsize | number | 0.5 | 否 | 设置评分条的评星步长。 | +| indicator | boolean | false | 否 | 设置评分条是否作为一个指示器,此时用户不可操作。 | + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| star-background | string | - | 否 | 设置单个星级未选中的背景图片,只支持本地路径图片,图片格式为png和jpg。 | +| star-foreground | string | - | 否 | 设置单个星级选中的前景图片,只支持本地路径图片,图片格式为png和jpg。 | +| star-secondary | string | - | 否 | 设置单个星级部分选中的次级背景图片,该图片会覆盖背景图片,只支持本地路径图片,图片格式为png和jpg。 | +| width | <length>\|<percentage> | 120px
60px(不可操作) | 否 | 默认值是在未设置自定义资源和评分星数时,使用5个星和默认资源下的宽度值。 | +| height | <length>\|<percentage> | 24px
12px(不可操作) | 否 | 默认值是在未设置自定义资源和评分星数时,使用5个星和默认资源下的高度值。 | +| rtl-flip | boolean | true | 否 | 在RTL文字方向下是否自动翻转图源。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> star-background,star-secondary,star-foreground三个星级图源必须全部设置,否则默认的星级颜色为灰色,以此提示图源设置错误。 + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { rating:  number } | 评分条的评星发生改变时触发该回调。 | + + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -225,5 +93,4 @@ export default { } ``` -![](figures/zh-cn_image_0000001198670487.png) - +![zh-cn_image_0000001198670487](figures/zh-cn_image_0000001198670487.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-richtext.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-richtext.md index 3886b92819dff6fc9bd9b1689b4dd2da39ff98e0..0cf2771909362ece954b1c4f55a9562ad0a7fc03 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-richtext.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-richtext.md @@ -1,60 +1,56 @@ -# richtext +# richtext -富文本组件,用于展示富文本信息,内容需要写在元素标签内。 -## 权限列表 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 该组件从API version 6开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - 富文本内容需要写在元素标签内。 + +富文本组件,用于展示富文本信息。 + +## 权限列表 无 -## 子组件 -不包含子组件。 +## 属性 + +仅支持[通用属性](../arkui-js/js-components-common-attributes.md)中的id、style和class属性。 + -## 属性 +## 样式 -仅支持[通用属性](js-components-common-attributes.md)中的id、style和class属性。 +仅支持[通用样式](../arkui-js/js-components-common-styles.md)中的display和visibility样式。 -## 样式 -仅支持[通用样式](js-components-common-styles.md)中的display和visibility样式。 +## 事件 -## 事件 +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| start | - | 开始加载时触发。 | +| complete | - | 加载完成时触发。 | - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

start

-

-

-

开始加载时触发。

-

complete

-

-

-

加载完成时触发。

-
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 不支持focus、blur、key事件。 +> +> - 不支持无障碍事件。 +> +> - 包含richtext的页面返回时richtext显示区域不会跟随页面的转场动效。 +> +> - richtext内容不建议超过一个屏幕高度,超出部分不会显示。 +> +> - 不支持设置宽度,默认撑开全屏。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 不支持focus、blur、key事件。 ->- 不支持无障碍事件。 ->- 包含richtext的页面返回时richtext显示区域不会跟随页面的转场动效。 ->- richtext内容不建议超过一个屏幕高度,超出部分不会显示。 ->- 不支持设置宽度,默认撑开全屏。 -## 示例 +## 方法 + +不支持。 + + +## 示例 ``` @@ -68,26 +64,20 @@ export default { data: { content: ` -

h1标题

-

h1斜体

-

h1下划线

-

h2标题

-

h3标题

-

p常规


-
-

字体大小35px,行高45px

-

- 这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字这是一段文字 - 这是一段文字

-
+
+ +

h1

+

文本测试(h1测试)

+

h2

+

文本测试(h2测试)

+
`, }, onLoadStart() { - console.error("start load rich text.") + console.error("start load rich text:" + JSON.stringify()) }, onLoadEnd() { - console.error("end load rich text.") + console.error("end load rich text:" + JSON.stringify()) } } ``` - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-search.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-search.md index 4f36d73e57139c86f4ead73dfd50111dba71c524..7e8e09b155d0c3d1b8d0e60682bf07c3bc3e9164 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-search.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-search.md @@ -1,275 +1,71 @@ -# search +# search + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 提供搜索框组件,用于提供用户搜索内容的输入区域。 -## 子组件 + +## 子组件 不支持。 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| icon | string | - | 否 | 搜索图标,默认使用系统搜索图标,图标格式为svg,jpg和png。 | +| hint | string | - | 否 | 搜索提示文字。 | +| value | string | - | 否 | 搜索框搜索文本值。 | +| searchbutton5+ | string | - | 否 | 搜索框末尾搜索按钮文本值。 | +| menuoptions5+ | Array<MenuOption> | - | 否 | 设置文本选择弹框点击更多按钮之后显示的菜单项。 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

icon

-

string

-

-

-

-

搜索图标,默认使用系统搜索图标,图标格式为svg,jpg和png。

-

hint

-

string

-

-

-

-

搜索提示文字。

-

value

-

string

-

-

-

-

搜索框搜索文本值。

-

searchbutton5+

-

string

-

-

-

-

搜索框末尾搜索按钮文本值。

-

menuoptions5+

-

Array<MenuOption>

-

-

-

-

设置文本选择弹框点击更多按钮之后显示的菜单项。

-
+**表1** MenuOption5+ -**表 1** MenuOption5+ +| 名称 | 类型 | 描述 | +| -------- | -------- | -------- | +| icon | string | 菜单选项中的图标路径。 | +| content | string | 菜单选项中的文本内容。 | - - - - - - - - - - - - - - - -

名称

-

类型

-

描述

-

icon

-

string

-

菜单选项中的图标路径。

-

content

-

string

-

菜单选项中的文本内容。

-
-## 样式 +## 样式 -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#e6000000

-

-

搜索框的文本颜色。

-

font-size

-

<length>

-

16px

-

-

搜索框的文本尺寸。

-

allow-scale

-

boolean

-

true

-

-

搜索框的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。

-
-

placeholder-color

-

<color>

-

#99000000

-

-

搜索框的提示文本颜色。

-

font-weight

-

number | string

-

normal

-

-

搜索框的字体粗细,见text组件font-weight的样式属性

-

font-family

-

string

-

sans-serif

-

-

搜索框的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-

caret-color6+

-

<color>

-

-

-

-

设置输入光标的颜色。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#e6000000 | 否 | 搜索框的文本颜色。 | +| font-size | <length> | 16px | 否 | 搜索框的文本尺寸。 | +| allow-scale | boolean | true | 否 | 搜索框的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| placeholder-color | <color> | \#99000000
| 否 | 搜索框的提示文本颜色。 | +| font-weight | number \| string | normal | 否 | 搜索框的字体粗细,见[text组件font-weight的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family | string | sans-serif | 否 | 搜索框的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | +| caret-color6+ | <color> | - | 否 | 设置输入光标的颜色。 | -## 事件 -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: +## 事件 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ text:newText }

-

输入内容发生变化时触发。

-
说明:

改变value属性值不会触发该回调。

-
-

submit

-

{ text:submitText }

-

点击搜索图标、搜索按钮5+或者按下软键盘搜索按钮时触发。

-

translate5+

-

{ value: selectedText }

-

设置此事件后,进行文本选择操作后文本选择弹窗会出现翻译按钮,点击翻译按钮之后,触发该回调,返回选中的文本内容。

-

share5+

-

{ value: selectedText }

-

设置此事件后,进行文本选择操作后文本选择弹窗会出现分享按钮,点击分享按钮之后,触发该回调,返回选中的文本内容。

-

search5+

-

{ value: selectedText }

-

设置此事件后,进行文本选择操作后文本选择弹窗会出现搜索按钮,点击搜索按钮之后,触发该回调,返回选中的文本内容。

-

optionselect5+

-

{ index:optionIndex, value: selectedText }

-

文本选择弹窗中设置menuoptions属性后,用户在文本选择操作后,点击菜单项后触发该回调,返回点击的菜单项序号和选中的文本内容。

-
+除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: -## 方法 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { text:newText } | 输入内容发生变化时触发。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 改变value属性值不会触发该回调。 | +| submit | { text:submitText } | 点击搜索图标、搜索按钮5+或者按下软键盘搜索按钮时触发。 | +| translate5+ | { value: selectedText } | 设置此事件后,进行文本选择操作后文本选择弹窗会出现翻译按钮,点击翻译按钮之后,触发该回调,返回选中的文本内容。 | +| share5+ | { value: selectedText } | 设置此事件后,进行文本选择操作后文本选择弹窗会出现分享按钮,点击分享按钮之后,触发该回调,返回选中的文本内容。 | +| search5+ | { value: selectedText } | 设置此事件后,进行文本选择操作后文本选择弹窗会出现搜索按钮,点击搜索按钮之后,触发该回调,返回选中的文本内容。 | +| optionselect5+ | { index:optionIndex, value: selectedText } | 文本选择弹窗中设置menuoptions属性后,用户在文本选择操作后,点击菜单项后触发该回调,返回点击的菜单项序号和选中的文本内容。 | -支持[通用方法](js-components-common-methods.md)。 -## 示例 +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -288,5 +84,4 @@ } ``` -![](figures/zh-cn_image_0000001153427082.png) - +![zh-cn_image_0000001153427082](figures/zh-cn_image_0000001153427082.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-select.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-select.md index 54127fa0ecf141ba15cdcbd11388063fe042e691..8ddc87c5f32a728d67cf5a3ff700fb652b8d14e1 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-select.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-select.md @@ -1,79 +1,53 @@ -# select +# select + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 下拉选择按钮,可让用户在多个选项之间选择。 -## 权限列表 +## 权限列表 无 -## 子组件 - -支持<[option](js-components-basic-option.md)\>。 - -## 属性 - -支持[通用属性](js-components-common-attributes.md)。 - -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

font-family

-

string

-

sans-serif

-

-

字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-
- -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{newValue: newValue}

-

下拉选择新值后触发该事件,newValue的值为子组件option的value属性值。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- select组件不支持click事件。 - -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 + +## 子组件 + +支持<[option](../arkui-js/js-components-basic-option.md)>。 + + +## 属性 + +支持[通用属性](../arkui-js/js-components-common-attributes.md)。 + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| font-family | string | sans-serif | 否 | 字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | {newValue: newValue} | 下拉选择新值后触发该事件,newValue的值为子组件option的value属性值。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - select组件不支持click事件。 + + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -101,5 +75,4 @@ } ``` -![](figures/zh-cn_image_0000001152588538.png) - +![zh-cn_image_0000001152588538](figures/zh-cn_image_0000001152588538.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-slider.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-slider.md index 19644290837f2f68c82b738f63ba592a6fe76404..fec6983512032ad84693f293302f85ed66430b3c 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-slider.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-slider.md @@ -1,235 +1,59 @@ -# slider +# slider + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 滑动条组件,用来快速调节设置值,如音量、亮度等。 -## 子组件 + +## 子组件 不支持。 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| min | number | 0 | 否 | 滑动选择器的最小值。 | +| max | number | 100 | 否 | 滑动选择器的最大值。 | +| step | number | 1 | 否 | 每次滑动的步长。 | +| value | number | 0 | 否 | 滑动选择器的初始值。 | +| mode5+ | string | outset | 否 | 滑动条样式:
- outset:滑块在滑杆上;
- inset:滑块在滑杆内。 | +| showsteps5+ | boolean | false | 否 | 是否显示步长标识。 | +| showtips5+ | boolean | false | 否 | 滑动时是否有气泡提示百分比。 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

min

-

number

-

0

-

-

滑动选择器的最小值。

-

max

-

number

-

100

-

-

滑动选择器的最大值。

-

step

-

number

-

1

-

-

每次滑动的步长。

-

value

-

number

-

0

-

-

滑动选择器的初始值。

-

mode5+

-

string

-

outset

-

-

滑动条样式:

-
  • outset:滑块在滑杆上;
  • inset:滑块在滑杆内。
    说明:

    仅手机和平板设备支持。

    -
    -
-

showsteps5+

-

boolean

-

false

-

-

是否显示步长标识;

-
说明:

仅手机和平板设备支持。

-
-

showtips5+

-

boolean

-

false

-

-

滑动时是否有气泡提示百分比;

-
说明:

仅手机和平板设备支持。

-
-
-## 样式 +## 样式 -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#19000000

-

-

滑动条的背景颜色。

-

selected-color

-

<color>

-

#ff007dff

-

-

滑动条的已选择颜色。

-

block-color

-

<color>

-

#ffffff

-

-

滑动条的滑块颜色。

-
说明:

仅手机、平板和智慧屏设备支持。

-
-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | #19000000 | 否 | 滑动条的背景颜色。 | +| selected-color | <color> | #ff007dff | 否 | 滑动条的已选择颜色。 | +| block-color | <color> | \#ffffff | 否 | 滑动条的滑块颜色。 | -## 事件 -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: +## 事件 - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

ChangeEvent

-

选择值发生变化时触发该事件。

-
+除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: -**表 1** ChangeEvent +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | ChangeEvent | 选择值发生变化时触发该事件。 | - - - - - - - - - - - - - - - - - - - - - - - -

属性

-

类型

-

说明

-

progress(deprecated5+)

-

string

-

当前slider的进度值。

-

isEnd(deprecated5+)

-

string

-

当前slider是否拖拽结束,可选值为:

-
  • true:slider拖拽结束。
  • false:slider拖拽中。
-

value5+

-

number

-

当前slider的进度值。

-

mode5+

-

string

-

当前change事件的类型,可选值为:

-
  • start:slider的值开始改变。
  • move:slider的值跟随手指拖动中。
  • end:slider的值结束改变。
-
+**表1** ChangeEvent -## 示例 +| 属性 | 类型 | 说明 | +| -------- | -------- | -------- | +| value5+ | number | 当前slider的进度值。 | +| mode5+ | string | 当前change事件的类型,可选值为:
- start:slider的值开始改变。
- move:slider的值跟随手指拖动中。
- end:slider的值结束改变。 | + + +## 示例 ``` @@ -248,7 +72,6 @@ justify-content: center; align-items: center; - } ``` @@ -276,5 +99,6 @@ export default { } ``` -![](figures/slider.png) +![zh-cn_image_0000001173324709](figures/zh-cn_image_0000001173324709.png) + diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-span.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-span.md index 657a0bbd8a917bb6316c5d2a1e91280679de808d..1c8e3af694f3bbe4bbad43fb87d29072efd44cc2 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-span.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-span.md @@ -1,129 +1,54 @@ -# span +# span -作为<[text](js-components-basic-text.md)\>子组件提供文本修饰能力。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 +作为<[text](../arkui-js/js-components-basic-text.md)>子组件提供文本修饰能力。 + +## 权限列表 无 -## 子组件 -支持子组件。 +## 子组件 + +支持子组件<span>。 + -## 属性 +## 属性 -支持[通用属性](js-components-common-attributes.md)。 +支持[通用属性](../arkui-js/js-components-common-attributes.md)。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->不支持focusable和disabled属性。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 不支持focusable和disabled属性。 -## 样式 + +## 样式 仅支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

-

-

-

设置文本段落的文本颜色。

-

font-size

-

<length>

-

30px

-

-

设置文本段落的文本尺寸。

-

allow-scale

-

boolean

-

true

-

-

设置文本段落的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。

-
-

font-style

-

string

-

normal

-

-

设置文本段落的字体样式,见text组件font-style的样式属性

-

font-weight

-

number | string

-

normal

-

-

设置文本段落的字体粗细,见text组件font-weight的样式属性

-

text-decoration

-

string

-

none

-

-

设置文本段落的文本修饰,见text组件text-decoration样式属性

-

font-family

-

string

-

sans-serif

-

-

设置文本段落的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-
- -## 事件 - -仅支持[通用事件](js-components-common-events.md)中的click事件。 - -## 方法 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | - | 否 | 设置文本段落的文本颜色。 | +| font-size | <length> | 30px | 否 | 设置文本段落的文本尺寸。 | +| allow-scale | boolean | true | 否 | 设置文本段落的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| font-style | string | normal | 否 | 设置文本段落的字体样式,见[text组件font-style的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-weight | number \| string | normal | 否 | 设置文本段落的字体粗细,见[text组件font-weight的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| text-decoration | string | none | 否 | 设置文本段落的文本修饰,见[text组件text-decoration样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family | string | sans-serif | 否 | 设置文本段落的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | + + +## 事件 + +仅支持[通用事件](../arkui-js/js-components-common-events.md)中的click事件。 + + +## 方法 不支持。 -## 示例 + +## 示例 ``` @@ -153,5 +78,4 @@ } ``` -![](figures/zh-cn_image_0000001152588626.png) - +![zh-cn_image_0000001152588626](figures/zh-cn_image_0000001152588626.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-switch.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-switch.md index 95d5c8319bc71ac78ac0127e31aaecd63f476f35..9d8e6bfc8079d0aaeec0129c13ce97a55b366449 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-switch.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-switch.md @@ -1,214 +1,63 @@ -# switch +# switch + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 开关选择器,通过开关,开启或关闭某个功能。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| checked | boolean | false | 否 | 是否选中。 | +| showtext | boolean | false | 否 | 是否显示文本。 | +| texton | string | "On" | 否 | 选中时显示的文本。 | +| textoff | string | "Off" | 否 | 未选中时显示的文本。 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

checked

-

boolean

-

false

-

-

是否选中。

-

showtext

-

boolean

-

false

-

-

是否显示文本。

-

texton

-

string

-

"On"

-

-

选中时显示的文本。

-

textoff

-

string

-

"Off"

-

-

未选中时显示的文本。

-
-## 样式 +## 样式 -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

texton-color(Rich)

-

<color>

-

#000000

-

-

选中时显示的文本颜色。

-

textoff-color(Rich)

-

<color>

-

#000000

-

-

未选中时显示的文本颜色。

-

text-padding(Rich)

-

number

-

0px

-

-

texton/textoff中最长文本两侧距离滑块边界的距离。

-

font-size(Rich)

-

<length>

-

-

-

-

文本尺寸,仅设置texton和textoff生效。

-

allow-scale(Rich)

-

boolean

-

true

-

-

文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。

-
-

font-style(Rich)

-

string

-

normal

-

-

字体样式,仅设置texton和textoff生效。见text组件font-style的样式属性

-

font-weight(Rich)

-

number | string

-

normal

-

-

字体粗细,仅设置texton和textoff生效。见text组件的font-weight的样式属性

-

font-family(Rich)

-

string

-

sans-serif

-

-

字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。仅设置texton和textoff生效。

-
-## 事件 +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| texton-color(Rich) | <color> | \#000000 | 否 | 选中时显示的文本颜色。 | +| textoff-color(Rich) | <color> | \#000000 | 否 | 未选中时显示的文本颜色。 | +| text-padding(Rich) | number | 0px | 否 | texton/textoff中最长文本两侧距离滑块边界的距离。 | +| font-size(Rich) | <length> | - | 否 | 文本尺寸,仅设置texton和textoff生效。 | +| allow-scale(Rich) | boolean | true | 否 | 文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| font-style(Rich) | string | normal | 否 | 字体样式,仅设置texton和textoff生效。见[text组件font-style的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-weight(Rich) | number \| string | normal | 否 | 字体粗细,仅设置texton和textoff生效。见[text组件的font-weight的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family(Rich) | string | sans-serif | 否 | 字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。仅设置texton和textoff生效。 | - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ checked: checkedValue }

-

选中状态改变时触发该事件。

-
-## 方法 +## 事件 -支持[通用方法](js-components-common-methods.md)。 +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: -## 示例 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { checked: checkedValue } | 选中状态改变时触发该事件。 | + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + +## 示例 ``` @@ -254,5 +103,4 @@ export default { } ``` -![](figures/zh-cn_image_0000001152862510.gif) - +![zh-cn_image_0000001152862510](figures/zh-cn_image_0000001152862510.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-text.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-text.md index ffb96e5c30d14007417d421e196ab8e9458c6d25..d2975d0745deaf8be7f5e632ceaff68b80b410fd 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-text.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-text.md @@ -1,320 +1,81 @@ -# text +# text -文本,用于呈现一段信息。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 该组件从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - 文本的展示内容需要写在元素标签内。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 文本的展示内容需要写在元素标签内。 +文本,用于呈现一段信息。 -## 权限列表 +## 权限列表 无 -## 子组件 -支持<[span](js-components-basic-span.md)\>。 +## 子组件 + +支持<[span](../arkui-js/js-components-basic-span.md)>。 + -## 属性 +## 属性 -支持[通用属性](js-components-common-attributes.md)。 +支持[通用属性](../arkui-js/js-components-common-attributes.md)。 -## 样式 -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: +## 样式 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#e5000000

-

-

设置文本的颜色。

-

font-size

-

<length>

-

30px

-

-

设置文本的尺寸。

-

allow-scale

-

boolean

-

true

-

-

文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果需要支持动态生效,请参看config描述文件中config-changes标签。

-
-

letter-spacing

-

<length>

-

0px

-

-

设置文本的字符间距。

-

word-spacing7+

-

<length> | <percentage> | string

-

normal

-

-

设置文本之间的间距,string可选值为:

-

normal:默认的字间距。

-

font-style

-

string

-

normal

-

-

设置文本的字体样式,可选值为:

-
  • normal:标准的字体样式;
  • italic:斜体的字体样式。
-

font-weight

-

number | string

-

normal

-

-

设置文本的字体粗细,number类型取值[100, 900],默认为400,取值越大,字体越粗。

-
说明:

number取值必须为100的整数倍。

-
-

string类型取值支持如下四个值:lighter、normal、bold、bolder。

-

text-decoration

-

string

-

none

-

-

设置文本的文本修饰,可选值为:

-
  • underline:文字下划线修饰;
  • line-through:穿过文本的修饰线n
  • none:标准文本。
-

text-decoration-color7+

-

<color>

-

-

-

-

设置文本修饰线的颜色。

-

text-align

-

string

-

start

-

-

设置文本的文本对齐方式,可选值为:

-
  • left:文本左对齐;
  • center:文本居中对齐;
  • right:文本右对齐;
  • start:根据文字书写相同的方向对齐;
  • end:根据文字书写相反的方向对齐。
-
说明:

如文本宽度未指定大小,文本的宽度和父容器的宽度大小相等的情况下,对齐效果可能会不明显。

-
-

line-height

-

<length> | <percentage>7+ | string7+

-

0px1-6

-

normal7+

-

-

设置文本的文本行高,设置为0px时,不限制文本行高,自适应字体大小。string可选值为:

-

normal7+:默认的行高。

-

text-overflow

-

string

-

clip

-

-

在设置了最大行数的情况下生效,可选值为:

-
  • clip:将文本根据父容器大小进行裁剪显示;
  • ellipsis:根据父容器大小显示,显示不下的文本用省略号代替。需配合max-lines使用。
-

font-family

-

string

-

sans-serif

-

-

设置文本的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-

max-lines

-

number | string7+

-

-

-

-

设置文本的最大行数,string类型可选值为:

-
  • auto7+:文本行数自适应容器高度。
-

min-font-size

-

<length>

-

-

-

-

文本最小字号,需要和文本最大字号同时设置,支持文本字号动态变化。设置最大最小字体样式后,font-size不生效。

-

max-font-size

-

<length>

-

-

-

-

文本最大字号,需要和文本最小字号同时设置,支持文本字号动态变化。设置最大最小字体样式后,font-size不生效。

-

font-size-step

-

<length>

-

1px

-

-

文本动态调整字号时的步长,需要设置最小,最大字号样式生效。

-

prefer-font-sizes

-

<array>

-

-

-

-

预设的字号集合,在动态尺寸调整时,优先使用预设字号集合中的字号匹配设置的最大行数,如果预设字号集合未设置,则使用最大最小和步长调整字号。针对仍然无法满足最大行数要求的情况,使用text-overflow设置项进行截断,设置预设尺寸集后,font-size、max-font-size、min-font-size和font-size-step不生效。

-

如:prefer-font-sizes: 12px,14px,16px

-

word-break6+

-

string

-

normal

-

-

设置文本折行模式,可选值为:

-
  • normal:默认换行规则,依据各自语言的规则,允许在字间发生换行。
  • break-all:对于非中文/日文/韩文的文本,可在任意字符间断行。
  • break-word:与break-all相同,不同的地方在于它要求一个没有断行破发点的词必须保持为一个整体单位。
-

text-indent7+

-

<length>

-

-

-

-

设置首行缩进量。

-

white-space7+

-

string

-

pre

-

-

设置处理元素中空白的模式,可选值为:

-
  • normal:所有空格、回车、制表符都合并成一个空格,文本自动换行;
  • nowrap:所有空格、回车、制表符都合并成一个空格,文本不换行;
  • pre:所有东西原样输出;
  • pre-wrap:所有东西原样输出,文本换行;
  • pre-line:所有空格、制表符合并成一个空格,回车不变,文本换行。
-

adapt-height7+

-

boolean

-

false

-

-

文本大小是否自适应容器高度。

-
说明:

设置字体大小自适应相关样式后生效。

-
-
+除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 字体动态缩放:预设尺寸集合和最小最大字号调节基于是否满足最大行数要求,预设尺寸集合会按照从左到右顺序查看是否满足最大行数要求,最小最大字号调节则基于从大到小顺序查看是否满足最大行数要求。 ->- 文本换行:文本可以通过转义字符\\r\\n进行换行。 ->- 文本标签内支持以下转义字符:\\a,\\b,\\f,\\n,\\r,\\t,\\v,\\',\\",\\0。 ->- 当使用子组件span组成文本段落时,如果span属性样式异常,将导致text段落无法显示。 ->- letter-spacing、text-align、line-height、text-overflow和max-lines样式作用于text及其子组件(span)组成的文本内容。 ->- text组件说明:不支持text内同时存在文本内容和span子组件。(如果同时存在,只显示span内的内容\) +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | #e5000000 | 否 | 设置文本的颜色。 | +| font-size | <length> | 30px | 否 | 设置文本的尺寸。 | +| allow-scale | boolean | true | 否 | 文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果需要支持动态生效,请参看config描述文件中config-changes标签。 | +| letter-spacing | <length> | 0px | 否 | 设置文本的字符间距。 | +| word-spacing7+ | <length> \| <percentage> \| string | normal | 否 | 设置文本之间的间距,string可选值为:
normal:默认的字间距。 | +| font-style | string | normal | 否 | 设置文本的字体样式,可选值为:
- normal:标准的字体样式;
- italic:斜体的字体样式。 | +| font-weight | number \| string | normal | 否 | 设置文本的字体粗细,number类型取值[100, 900],默认为400,取值越大,字体越粗。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> number取值必须为100的整数倍。
string类型取值支持如下四个值:lighter、normal、bold、bolder。 | +| text-decoration | string | none | 否 | 设置文本的文本修饰,可选值为:
- underline:文字下划线修饰;
- line-through:穿过文本的修饰线n
- none:标准文本。 | +| text-decoration-color7+ | <color> | - | 否 | 设置文本修饰线的颜色。 | +| text-align | string | start
| 否 | 设置文本的文本对齐方式,可选值为:
- left:文本左对齐;
- center:文本居中对齐;
- right:文本右对齐;
- start:根据文字书写相同的方向对齐;
- end:根据文字书写相反的方向对齐。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如文本宽度未指定大小,文本的宽度和父容器的宽度大小相等的情况下,对齐效果可能会不明显。 | +| line-height | <length> \| <percentage>7+ \| string7+ | 0px1-6
normal7+ | 否 | 设置文本的文本行高,设置为0px时,不限制文本行高,自适应字体大小。string可选值为:
normal7+:默认的行高。 | +| text-overflow | string | clip | 否 | 在设置了最大行数的情况下生效,可选值为:
- clip:将文本根据父容器大小进行裁剪显示;
- ellipsis:根据父容器大小显示,显示不下的文本用省略号代替。需配合max-lines使用。 | +| font-family | string | sans-serif | 否 | 设置文本的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | +| max-lines | number \| string7+ | - | 否 | 设置文本的最大行数,string类型可选值为:
- auto7+:文本行数自适应容器高度。 | +| min-font-size | <length> | - | 否 | 文本最小字号,需要和文本最大字号同时设置,支持文本字号动态变化。设置最大最小字体样式后,font-size不生效。 | +| max-font-size | <length> | - | 否 | 文本最大字号,需要和文本最小字号同时设置,支持文本字号动态变化。设置最大最小字体样式后,font-size不生效。 | +| font-size-step | <length> | 1px | 否 | 文本动态调整字号时的步长,需要设置最小,最大字号样式生效。 | +| prefer-font-sizes | <array> | - | 否 | 预设的字号集合,在动态尺寸调整时,优先使用预设字号集合中的字号匹配设置的最大行数,如果预设字号集合未设置,则使用最大最小和步长调整字号。针对仍然无法满足最大行数要求的情况,使用text-overflow设置项进行截断,设置预设尺寸集后,font-size、max-font-size、min-font-size和font-size-step不生效。
如:prefer-font-sizes: 12px,14px,16px | +| word-break6+ | string | normal | 否 | 设置文本折行模式,可选值为:
- normal:默认换行规则,依据各自语言的规则,允许在字间发生换行。
- break-all:对于非中文/日文/韩文的文本,可在任意字符间断行。
- break-word:与break-all相同,不同的地方在于它要求一个没有断行破发点的词必须保持为一个整体单位。 | +| text-indent7+ | <length> | - | 否 | 设置首行缩进量。 | +| white-space7+ | string | pre | 否 | 设置处理元素中空白的模式,可选值为:
- normal:所有空格、回车、制表符都合并成一个空格,文本自动换行;
- nowrap:所有空格、回车、制表符都合并成一个空格,文本不换行;
- pre:所有东西原样输出;
- pre-wrap:所有东西原样输出,文本换行;
- pre-line:所有空格、制表符合并成一个空格,回车不变,文本换行。 | +| adapt-height7+ | boolean | false | 否 | 文本大小是否自适应容器高度。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 设置字体大小自适应相关样式后生效。 | -## 事件 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 字体动态缩放:预设尺寸集合和最小最大字号调节基于是否满足最大行数要求,预设尺寸集合会按照从左到右顺序查看是否满足最大行数要求,最小最大字号调节则基于从大到小顺序查看是否满足最大行数要求。 +> +> - 文本换行:文本可以通过转义字符\r\n进行换行。 +> +> - 文本标签内支持以下转义字符:\a,\b,\f,\n,\r,\t,\v,\',\",\0。 +> +> - 当使用子组件span组成文本段落时,如果span属性样式异常,将导致text段落无法显示。 +> +> - letter-spacing、text-align、line-height、text-overflow和max-lines样式作用于text及其子组件(span)组成的文本内容。 +> +> - text组件说明:不支持text内同时存在文本内容和span子组件。(如果同时存在,只显示span内的内容) -支持[通用事件](js-components-common-events.md)。 -## 方法 +## 事件 -支持[通用方法](js-components-common-methods.md)。 +支持[通用事件](../arkui-js/js-components-common-events.md)。 -## 示例 +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -361,7 +122,7 @@ export default { } ``` -![](figures/3.png) +![zh-cn_image_0000001167823076](figures/zh-cn_image_0000001167823076.png) ``` @@ -400,5 +161,4 @@ export default { } ``` -![](figures/2.png) - +![zh-cn_image_0000001213103299](figures/zh-cn_image_0000001213103299.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-textarea.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-textarea.md index 0d9ee4508e1055600a489648c8642b4801bb0309..37c5ca2da80d15ab8ac54d66b56c74d22b8e68a6 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-textarea.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-textarea.md @@ -1,345 +1,82 @@ -# textarea +# textarea + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 多行文本输入的文本框。 -## 权限列表 + +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| placeholder | string | - | 否 | 多行文本框的提示文本内容。 | +| maxlength | number | - | 否 | 多行文本框可输入的最多字符数量。 | +| headericon | string | - | 否 | 在文本输入前的图标展示,该图标不支持点击事件,图标格式为jpg,png和svg。 | +| extend | boolean | false | 否 | 文本框是否支持可扩展,设置可扩展属性后文本框高度可以跟随文字自适应。 | +| value5+ | string | - | 否 | 多行文本框的内容。 | +| showcounter5+ | boolean | false | 否 | 文本框是否需要开启计数下标功能,需要配合maxlength一起使用。 | +| menuoptions5+ | Array<MenuOption> | - | 否 | 设置文本选择弹框点击更多按钮之后显示的菜单项。 | +| autofocus6+ | boolean | false | 否 | 是否自动获焦。 | +| selectedstart6+ | number | -1 | 否 | 开始选择文本时初始选择位置。 | +| selectedend6+ | number | -1 | 否 | 开始选择文本时结尾选择位置。 | +| softkeyboardenabled6+ | boolean | true | 否 | 编辑时是否弹出系统软键盘。 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

placeholder

-

string

-

-

-

-

多行文本框的提示文本内容。

-

maxlength

-

number

-

-

-

-

多行文本框可输入的最多字符数量。

-

headericon

-

string

-

-

-

-

在文本输入前的图标展示,该图标不支持点击事件,图标格式为jpg,png和svg。

-

extend

-

boolean

-

false

-

-

文本框是否支持可扩展,设置可扩展属性后文本框高度可以跟随文字自适应。

-

value5+

-

string

-

-

-

-

多行文本框的内容。

-

showcounter5+

-

boolean

-

false

-

-

文本框是否需要开启计数下标功能,需要配合maxlength一起使用。

-

menuoptions5+

-

Array<MenuOption>

-

-

-

-

设置文本选择弹框点击更多按钮之后显示的菜单项。

-

autofocus6+

-

boolean

-

false

-

-

是否自动获焦。

-

selectedstart6+

-

number

-

-1

-

-

开始选择文本时初始选择位置。

-

selectedend6+

-

number

-

-1

-

-

开始选择文本时结尾选择位置。

-

softkeyboardenabled6+

-

boolean

-

true

-

-

编辑时是否弹出系统软键盘。

-
+**表1** MenuOption5+ -**表 1** MenuOption5+ +| 名称 | 类型 | 描述 | +| -------- | -------- | -------- | +| icon | string | 菜单选项中的图标路径。 | +| content | string | 菜单选项中的文本内容。 | - - - - - - - - - - - - - - - -

名称

-

类型

-

描述

-

icon

-

string

-

菜单选项中的图标路径。

-

content

-

string

-

菜单选项中的文本内容。

-
-## 样式 +## 样式 -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#e6000000

-

-

多行文本框的文本颜色。

-

font-size

-

<length>

-

16px

-

-

多行文本框的文本尺寸。

-

allow-scale

-

boolean

-

true

-

-

多行文本框的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。

-
-

placeholder-color

-

<color>

-

#99000000

-

-

多行文本框的提示文本颜色,type为text|email|date|time|number|password时生效。

-

font-weight

-

number | string

-

normal

-

-

多行文本框的字体粗细,见text组件font-weight的样式属性

-

font-family

-

string

-

sans-serif

-

-

多行文本框的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-

caret-color6+

-

<color>

-

-

-

-

设置输入光标的颜色。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#e6000000 | 否 | 多行文本框的文本颜色。 | +| font-size | <length> | 16px | 否 | 多行文本框的文本尺寸。 | +| allow-scale | boolean | true | 否 | 多行文本框的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| placeholder-color | <color> | \#99000000 | 否 | 多行文本框的提示文本颜色,type为text\|email\|date\|time\|number\|password时生效。 | +| font-weight | number \| string | normal | 否 | 多行文本框的字体粗细,见[text组件font-weight的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family | string | sans-serif | 否 | 多行文本框的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | +| caret-color6+ | <color> | - | 否 | 设置输入光标的颜色。 | -## 事件 -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: +## 事件 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ text: newText, lines: textLines, height: textHeight }

-

输入内容发生变化时触发该事件,通过参数获取输入内容、行数和行高。

-
说明:

改变value属性值不会触发该回调。5+

-
-

translate5+

-

{ value: selectedText }

-

设置此事件后,进行文本选择操作后文本选择弹窗会出现翻译按钮,点击翻译按钮之后,触发该回调,返回选中的文本内容。

-

share5+

-

{ value: selectedText }

-

设置此事件后,进行文本选择操作后文本选择弹窗会出现分享按钮,点击分享按钮之后,触发该回调,返回选中的文本内容。

-

search5+

-

{ value: selectedText }

-

设置此事件后,进行文本选择操作后文本选择弹窗会出现搜索按钮,点击搜索按钮之后,触发该回调,返回选中的文本内容。

-

optionselect5+

-

{ index:optionIndex, value: selectedText }

-

文本选择弹窗中设置menuoptions属性后,用户在文本选择操作后,点击菜单项后触发该回调,返回点击的菜单项序号和选中的文本内容。

-

selectchange6+

-

{ start: number,end: number }

-

文本选择变化时触发事件。

-
+除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: -## 方法 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { text: newText, lines: textLines, height: textHeight } | 输入内容发生变化时触发该事件,通过参数获取输入内容、行数和行高。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 改变value属性值不会触发该回调。5+ | +| translate5+ | { value: selectedText } | 设置此事件后,进行文本选择操作后文本选择弹窗会出现翻译按钮,点击翻译按钮之后,触发该回调,返回选中的文本内容。 | +| share5+ | { value: selectedText } | 设置此事件后,进行文本选择操作后文本选择弹窗会出现分享按钮,点击分享按钮之后,触发该回调,返回选中的文本内容。 | +| search5+ | { value: selectedText } | 设置此事件后,进行文本选择操作后文本选择弹窗会出现搜索按钮,点击搜索按钮之后,触发该回调,返回选中的文本内容。 | +| optionselect5+ | { index:optionIndex, value: selectedText } | 文本选择弹窗中设置menuoptions属性后,用户在文本选择操作后,点击菜单项后触发该回调,返回点击的菜单项序号和选中的文本内容。 | +| selectchange6+ | { start: number,end: number } | 文本选择变化时触发事件。 | -支持[通用方法](js-components-common-methods.md)。 -## 示例 +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -369,5 +106,4 @@ change(e){ } ``` -![](figures/zh-cn_image_0000001127125124.png) - +![zh-cn_image_0000001127125124](figures/zh-cn_image_0000001127125124.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-toggle.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-toggle.md index 300959e89d4aa8d5d816479a9353580b4efd0fa1..a4693c14a7e68d09d545dc88d3bdebcedf20cc15 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-toggle.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-toggle.md @@ -1,170 +1,60 @@ -# toggle +# toggle + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 状态按钮用于从一组选项中进行选择,并可能在界面上实时显示选择后的结果。通常这一组选项都是由状态按钮构成。 -## 权限列表 + +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

value

-

string

-

-

-

-

状态按钮的文本值。

-

checked

-

boolean

-

false

-

-

状态按钮是否被选中。

-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

text-color

-

<color>

-

#E5000000

-

-

状态按钮的文本颜色。

-

font-size

-

<length>

-

16px

-

-

状态按钮的文本尺寸。

-

allow-scale

-

boolean

-

true

-

-

状态按钮的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-
说明:

如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。

-
-

font-style

-

string

-

normal

-

-

状态按钮的字体样式。

-

font-weight

-

number | string

-

normal

-

-

状态按钮的字体粗细。见text组件font-weight的样式属性

-

font-family

-

<string>

-

sans-serif

-

-

状态按钮的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-
- -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ checked:isChecked }

-

组件选中状态发生变化时触发。

-
- -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| value | string | - | 是 | 状态按钮的文本值。 | +| checked | boolean | false | 否 | 状态按钮是否被选中。 | + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| text-color | <color> | \#E5000000 | 否 | 状态按钮的文本颜色。 | +| font-size | <length> | 16px | 否 | 状态按钮的文本尺寸。 | +| allow-scale | boolean | true | 否 | 状态按钮的文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 如果在config描述文件中针对ability配置了fontSize的config-changes标签,则应用不会重启而直接生效。 | +| font-style | string | normal | 否 | 状态按钮的字体样式。 | +| font-weight | number \| string | normal | 否 | 状态按钮的字体粗细。见[text组件font-weight的样式属性](../arkui-js/js-components-basic-text.md#样式)。 | +| font-family | <string> | sans-serif | 否 | 状态按钮的字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { checked:isChecked } | 组件选中状态发生变化时触发。 | + + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -222,5 +112,4 @@ export default { } ``` -![](figures/screenshot.png) - +![zh-cn_image_0000001173164927](figures/zh-cn_image_0000001173164927.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md index a67f201a7272846c658cdaf283e99aadda90d370..21e0b16883e8065fa81dc2473a4382d8f9a956d4 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar-item.md @@ -1,271 +1,61 @@ -# toolbar-item +# toolbar-item + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 工具栏子组件。作为工具栏组件的子组件,用于展示工具栏上的一个操作选项。 -## 子组件 + +## 子组件 无 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| value | string | - | 是 | 该操作项文本内容。 | +| icon | string | - | 是 | 该操作项图标资源路径,该图标展示在选项文本上,支持本地路径,格式为png,jpg和svg。 | - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

value

-

string

-

-

-

-

该操作项文本内容。

-

icon

-

string

-

-

-

-

该操作项图标资源路径,该图标展示在选项文本上,支持本地路径,格式为png,jpg和svg。

-
-## 样式 +## 样式 仅支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

#e6000000

-

-

文本颜色。

-

font-size

-

<length>

-

16px

-

-

文本大小。

-

allow-scale

-

boolean

-

true

-

-

文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-

font-style

-

string

-

normal

-

-

文本字体样式,可选值为:

-
  1. normal: 标准的字体样式;
  2. italic: 斜体的字体样式。
-

font-weight

-

number|string

-

normal

-

-

文本字体粗细,number类型取值[100, 900]的整数(被100整除),默认为400,取值越大,字体越粗。string类型取值为:lighter、normal、bold、bolder。

-

text-decoration

-

string

-

none

-

-

文本修饰,可选值为:

-
  1. underline: 文本下划线修饰;
  2. line-through: 穿过文本的修饰线;
  3. none: 标准文本。
-

font-family

-

string

-

sans-serif

-

-

字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-

background

-

<linear-gradient>

-

-

-

-

仅支持设置渐变样式,与background-color、background-image不兼容。

-

background-color

-

<color>

-

-

-

-

设置背景颜色。

-

background-image

-

string

-

-

-

-

设置背景图片。与background-color、background不兼容;支持网络图片资源和本地图片资源地址。

-

background-size

-
  • string
  • <length> <length>
  • <percentage> <percentage>
-

auto

-

-

设置背景图片的大小。

-
  • string可选值:
    • contain:把图像扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
    • cover:把背景图像扩展至足够大,以使背景图像完全覆盖背景区域;背景图像的某些部分也许无法显示在背景定位区域中。
    • auto:保持原图的比例不变。
    -
  • length值参数方式:

    设置背景图像的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。

    -
  • 百分比参数方式:

    以父元素的百分比来设置背景图像的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。

    -
-

background-repeat

-

string

-

repeat

-

-

针对重复背景图像样式进行设置,背景图像默认在水平和垂直方向上重复。

-
  • repeat:在水平轴和竖直轴上同时重复绘制图片。
  • repeat-x:只在水平轴上重复绘制图片。
  • repeat-y:只在竖直轴上重复绘制图片。
  • no-repeat:不会重复绘制图片。
-

background-position

-
  • string string
  • <length> <length>
  • <percentage> <percentage>
-

0px 0px

-

-
  • 关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。
    • left:水平方向上最左侧。
    • right:水平方向上最右侧。
    • top:竖直方向上最顶部。
    • bottom:竖直方向上最底部。
    • center:水平方向或竖直方向上中间位置。
    -
-
  • length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px) 。如果仅规定了一个值,另外一个值将是50%。
  • 百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。
  • 可以混合使用<percentage>和<length>。
-

opacity

-

number

-

1

-

-

元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。

-

display

-

string

-

-

flex

-

-

确定一个元素所产生的框的类型,可选值为:

-
  • flex:弹性布局。
  • none:不渲染此元素。
-

visibility

-

string

-

-

visible

-

-

是否显示元素所产生的框。不可见的框会占用布局(将'display'属性设置为'none'来完全去除框),可选值为:

-
  • visible:元素正常显示。
  • hidden:隐藏元素,但是其他元素的布局不改变,相当于此元素变成透明。
-
说明:

visibility和display样式都设置时,仅display生效。

-
-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | \#e6000000 | 否 | 文本颜色。 | +| font-size | <length> | 16px | 否 | 文本大小。 | +| allow-scale | boolean | true | 否 | 文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。 | +| font-style | string | normal | 否 | 文本字体样式,可选值为:
1. normal: 标准的字体样式;
2. italic: 斜体的字体样式。 | +| font-weight | number\|string | normal | 否 | 文本字体粗细,number类型取值[100, 900]的整数(被100整除),默认为400,取值越大,字体越粗。string类型取值为:lighter、normal、bold、bolder。 | +| text-decoration | string | none | 否 | 文本修饰,可选值为:
1. underline: 文本下划线修饰;
2. line-through: 穿过文本的修饰线;
3. none: 标准文本。 | +| font-family | string | sans-serif | 否 | 字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | +| background | <linear-gradient> | - | 否 | 仅支持设置[渐变样式](../arkui-js/js-components-common-gradient.md),与background-color、background-image不兼容。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| background-image | string | - | 否 | 设置背景图片。与background-color、background不兼容;支持网络图片资源和本地图片资源地址。 | +| background-size | - string
- <length> <length>
- <percentage> <percentage> | auto | 否 | 设置背景图片的大小。
- string可选值:
  - contain:把图像扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
  - cover:把背景图像扩展至足够大,以使背景图像完全覆盖背景区域;背景图像的某些部分也许无法显示在背景定位区域中。
  - auto:保持原图的比例不变。
- length值参数方式:
  设置背景图像的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。
- 百分比参数方式:
  以父元素的百分比来设置背景图像的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。 | +| background-repeat | string | repeat | 否 | 针对重复背景图像样式进行设置,背景图像默认在水平和垂直方向上重复。
- repeat:在水平轴和竖直轴上同时重复绘制图片。
- repeat-x:只在水平轴上重复绘制图片。
- repeat-y:只在竖直轴上重复绘制图片。
- no-repeat:不会重复绘制图片。 | +| background-position | - string string
- <length> <length>
- <percentage> <percentage> | 0px 0px | 否 | - 关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。
  - left:水平方向上最左侧。
  - right:水平方向上最右侧。
  - top:竖直方向上最顶部。
  - bottom:竖直方向上最底部。
  - center:水平方向或竖直方向上中间位置。
- length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px)  。如果仅规定了一个值,另外一个值将是50%。
- 百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。
- 可以混合使用<percentage>和<length>。 | +| opacity | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| visibility | string | visible | 否 | 是否显示元素所产生的框。不可见的框会占用布局(将'display'属性设置为'none'来完全去除框),可选值为:
- visible:元素正常显示。
- hidden:隐藏元素,但是其他元素的布局不改变,相当于此元素变成透明。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> visibility和display样式都设置时,仅display生效。 | -## 事件 -支持[通用事件](js-components-common-events.md)。 +## 事件 -## 方法 +支持[通用事件](../arkui-js/js-components-common-events.md)。 + + +## 方法 不支持。 -## 示例 + +## 示例 ``` @@ -279,5 +69,4 @@ ``` -![](figures/000000.jpg) - +![zh-cn_image_0000001127285072](figures/zh-cn_image_0000001127285072.jpg) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar.md index f2c03a3ac53bd29a4ce661314ebf2d73f981b6bb..c0338b3f7c3296c37bf94cbb4741450e3a39629d 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-toolbar.md @@ -1,38 +1,47 @@ -# toolbar +# toolbar + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 工具栏。放在界面底部,用于展示针对当前界面的操作选项。 -## 权限列表 + +## 权限列表 无 -## 子组件 -支持子组件。 +## 子组件 + +支持<toolbar-item>子组件。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 工具栏最多可以展示5个toolbar-item子组件,如果存在6个及以上toolbar-item子组件,则保留前面4个子组件,后续的子组件收纳到工具栏上的更多项中,通过点击更多项弹窗展示剩下的子组件,更多项展示的组件样式采用系统默认样式,toolbar-item上设置的自定义样式不生效。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->工具栏最多可以展示5个toolbar-item子组件,如果存在6个及以上toolbar-item子组件,则保留前面4个子组件,后续的子组件收纳到工具栏上的更多项中,通过点击更多项弹窗展示剩下的子组件,更多项展示的组件样式采用系统默认样式,toolbar-item上设置的自定义样式不生效。 -## 属性 +## 属性 -支持[通用属性](js-components-common-attributes.md)。 +支持[通用属性](../arkui-js/js-components-common-attributes.md)。 -## 样式 -支持[通用样式](js-components-common-styles.md)。 +## 样式 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->不支持height样式,高度固定为56px。 +支持[通用样式](../arkui-js/js-components-common-styles.md)。 -## 事件 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 不支持height样式,高度固定为56px。 + + +## 事件 不支持。 -## 方法 + +## 方法 不支持。 -## 示例 -详见[toolbar-item示例](js-components-basic-toolbar-item.md)。 +## 示例 +详见[toolbar-item示例](../arkui-js/js-components-basic-toolbar-item.md)。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic-web.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic-web.md new file mode 100644 index 0000000000000000000000000000000000000000..c7f4bd776a2011ab8cdec8bc3bb5805e2423bad1 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic-web.md @@ -0,0 +1,70 @@ +# web +展示网页内容的组件。 +>![](../../public_sys-resources/icon-note.gif) **说明:** +> 该组件从API version 6开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +## 权限列表 +ohos.permission.INTERNET + +## 约束 +web组件不跟随转场动画。一个页面仅支持一个web组件。 + +## 子组件 +不支持。 + +## 属性 + +| 名称 | 参数类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| src | string | - | 否 |设置需要显示网页的地址,网址的域名必须为https协议且经过ICP备案。| +| id | string | - | 否 | 组件的唯一标识。 | + + +## 样式 +不支持通用样式设置。 + +## 事件 +仅支持如下事件: +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| pagestart | {url: string} | 加载网页时触发。 | +| pagefinish | {url: string} | 网页加载结束时触发。 | +| error | {url: string, errorCode: number, description: string} | 加载网页出现错误时触发或打开网页出错时触发。 | + +## 方法 +仅支持如下方法: +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| reload | - | 重新加载页面。 | + +## 示例 +``` + +
+ + +
+``` + +``` + +export default { + reloadWeb() { + this.$element('web').reload() + }, + + pageStart: function(e) { + console.info('web pageStart: ' + e.url) + }, + + pageFinish: function(e) { + console.info('web pageFinish: ' + e.url) + }, + + pageError: function(e) { + console.info('web pageError url: ' + e.url) + console.info('web pageError errorCode: ' + e.errorCode) + console.info('web pageError description: ' + e.description) + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-basic.md b/zh-cn/application-dev/reference/arkui-js/js-components-basic.md index e03bcd63f036b44469709a344c7cb80b43b91422..6c21e41f39d1a72b9f4fc9e507f9c169da761339 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-basic.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-basic.md @@ -1,57 +1,57 @@ -# 基础组件 +# 基础组件 -- **[button](js-components-basic-button.md)** -- **[chart](js-components-basic-chart.md)** -- **[divider](js-components-basic-divider.md)** +- **[button](js-components-basic-button.md)** -- **[image](js-components-basic-image.md)** +- **[chart](js-components-basic-chart.md)** -- **[image-animator](js-components-basic-image-animator.md)** +- **[divider](js-components-basic-divider.md)** -- **[input](js-components-basic-input.md)** +- **[image](js-components-basic-image.md)** -- **[label](js-components-basic-label.md)** +- **[image-animator](js-components-basic-image-animator.md)** -- **[marquee](js-components-basic-marquee.md)** +- **[input](js-components-basic-input.md)** -- **[menu](js-components-basic-menu.md)** +- **[label](js-components-basic-label.md)** -- **[option](js-components-basic-option.md)** +- **[marquee](js-components-basic-marquee.md)** -- **[picker](js-components-basic-picker.md)** +- **[menu](js-components-basic-menu.md)** -- **[picker-view](js-components-basic-picker-view.md)** +- **[option](js-components-basic-option.md)** -- **[piece](js-components-basic-piece.md)** +- **[picker](js-components-basic-picker.md)** -- **[progress](js-components-basic-progress.md)** +- **[picker-view](js-components-basic-picker-view.md)** -- **[qrcode](js-components-basic-qrcode.md)** +- **[piece](js-components-basic-piece.md)** -- **[rating](js-components-basic-rating.md)** +- **[progress](js-components-basic-progress.md)** -- **[richtext](js-components-basic-richtext.md)** +- **[qrcode](js-components-basic-qrcode.md)** -- **[search](js-components-basic-search.md)** +- **[rating](js-components-basic-rating.md)** -- **[select](js-components-basic-select.md)** +- **[richtext](js-components-basic-richtext.md)** -- **[slider](js-components-basic-slider.md)** +- **[search](js-components-basic-search.md)** -- **[span](js-components-basic-span.md)** +- **[select](js-components-basic-select.md)** -- **[switch](js-components-basic-switch.md)** +- **[slider](js-components-basic-slider.md)** -- **[text](js-components-basic-text.md)** +- **[span](js-components-basic-span.md)** -- **[textarea](js-components-basic-textarea.md)** +- **[switch](js-components-basic-switch.md)** -- **[toolbar](js-components-basic-toolbar.md)** +- **[text](js-components-basic-text.md)** -- **[toolbar-item](js-components-basic-toolbar-item.md)** +- **[textarea](js-components-basic-textarea.md)** -- **[toggle](js-components-basic-toggle.md)** +- **[toolbar](js-components-basic-toolbar.md)** +- **[toolbar-item](js-components-basic-toolbar-item.md)** +- **[toggle](js-components-basic-toggle.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvas.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvas.md index 2282db3ba563c2f0f6605a8e32f2fd7b09989579..ffd3d1426f89de720ddf2cbb5263baf1bcea481e 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvas.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvas.md @@ -1,165 +1,81 @@ -# canvas组件 +# canvas组件 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 提供画布组件。用于自定义绘制图形。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 -支持[通用属性](js-components-common-attributes.md)。 +## 属性 + +支持[通用属性](../arkui-js/js-components-common-attributes.md)。 + + +## 样式 + +支持[通用样式](../arkui-js/js-components-common-styles.md)。 + -## 样式 +## 事件 -支持[通用样式](js-components-common-styles.md)。 +支持[通用事件](../arkui-js/js-components-common-events.md)。 -## 事件 -支持[通用事件](js-components-common-events.md)。 +## 方法 -## 方法 +除支持[通用方法](../arkui-js/js-components-common-methods.md)外,还支持如下方法: -除支持[通用方法](js-components-common-methods.md)外,还支持如下方法: -### getContext +### getContext -getContext\(type: '2d', options?: ContextAttrOptions\): CanvasRendering2dContext +getContext(type: '2d', options?: ContextAttrOptions): CanvasRendering2dContext 获取canvas绘图上下文。不支持在onInit和onReady中进行调用。 -- 参数 - - - - - - - - - - - - - - - - - - -

参数名

-

参数类型

-

必填

-

描述

-

type

-

string

-

-

设置为'2d',返回值为2D绘制对象,该对象可用于在画布组件上绘制矩形、文本、图片等。

-

options6+

-

ContextAttrOptions

-

-

当前仅支持配置是否开启抗锯齿功能,默认为关闭。

-
- - **表 1** ContextAttrOptions - - - - - - - - - - - - -

参数名

-

类型

-

说明

-

antialias

-

boolean

-

是否开启抗锯齿功能,默认为false。

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

CanvasRenderingContext2D

-

用于在画布组件上绘制矩形、文本、图片等

-
- - -### toDataURL6+ - -toDataURL\(type?: string, quality?: number\): string +- 参数 + | 参数名 | 参数类型 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | + | type | string | 是 | 设置为'2d',返回值为2D绘制对象,该对象可用于在画布组件上绘制矩形、文本、图片等。 | + | options6+ | ContextAttrOptions | 否 | 当前仅支持配置是否开启抗锯齿功能,默认为关闭。 | + + **表1** ContextAttrOptions + + | 参数名 | 类型 | 说明 | + | -------- | -------- | -------- | + | antialias | boolean | 是否开启抗锯齿功能,默认为false。 | + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | [CanvasRenderingContext2D](../arkui-js/js-components-canvas-canvasrenderingcontext2d.md) | 用于在画布组件上绘制矩形、文本、图片等。 | + +### toDataURL6+ + +toDataURL(type?: string, quality?: number): string 生成一个包含图片展示的URL。 -- 参数 - - - - - - - - - - - - - - - - - - -

参数名

-

参数类型

-

必填

-

描述

-

type

-

string

-

-

可选参数,用于指定图像格式,默认格式为image/png。

-

quality

-

number

-

-

在指定图片格式为image/jpeg或image/webp的情况下,可以从0到1的区间内选择图片的质量。如果超出取值范围,将会使用默认值0.92。

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

string

-

图像的URL地址。

-
- - -## 示例 +- 参数 + | 参数名 | 参数类型 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | + | type | string | 否 | 可选参数,用于指定图像格式,默认格式为image/png。 | + | quality | number | 否 | 在指定图片格式为image/jpeg或image/webp的情况下,可以从0到1的区间内选择图片的质量。如果超出取值范围,将会使用默认值0.92。 | + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | string | 图像的URL地址。 | + +## 示例 ``` @@ -180,4 +96,3 @@ export default { } } ``` - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md index 11b339ea2de42b9b26fa00dfdce4fff2144f088f..376fcb47b32908a11a0953f76ae26a70279d2399 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasgradient.md @@ -1,63 +1,43 @@ -# CanvasGradient对象 +# CanvasGradient对象 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 渐变对象。 -## addColorStop -addColorStop\(offset: number, color: string\): void +## addColorStop + +addColorStop(offset: number, color: string): void 设置渐变断点值,包括偏移和颜色。 -- 参数 - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

offset

-

number

-

设置渐变点距离起点的位置占总体长度的比例,范围为0到1。

-

color

-

string

-

设置渐变的颜色。

-
- -- 示例 - - ``` - -
- - -
- ``` - - ``` - // xxx.js - export default { - handleClick() { - const el =this.$refs.canvas; - const ctx =el.getContext('2d'); - const gradient = ctx.createLinearGradient(0,0,100,0); - gradient.addColorStop(0,'#00ffff'); - gradient.addColorStop(1,'#ffff00'); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | offset | number | 设置渐变点距离起点的位置占总体长度的比例,范围为0到1。 | + | color | string | 设置渐变的颜色。 | + +- 示例 + ``` + +
+ + +
+ ``` + + ``` + // xxx.js + export default { + handleClick() { + const el =this.$refs.canvas; + const ctx =el.getContext('2d'); + const gradient = ctx.createLinearGradient(0,0,100,0); + gradient.addColorStop(0,'#00ffff'); + gradient.addColorStop(1,'#ffff00'); } - ``` - - ![](figures/zh-cn_image_0000001152610806.png) - + } + ``` + ![zh-cn_image_0000001152610806](figures/zh-cn_image_0000001152610806.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md index 0a80d1c92e4c2ebc2f9ecc1c056f861ba375746a..91ae2975bd8a4e0195b309283d91add3dffc9307 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md @@ -1,227 +1,66 @@ -# CanvasRenderingContext2D对象 +# CanvasRenderingContext2D对象 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 使用CanvasRenderingContext2D在canvas画布组件上进行绘制,绘制对象可以是矩形、文本、图片等。 -- 示例 - - ``` - -
- - - -
- ``` - - ``` - // xxx.js - export default { - handleClick() { - const el = this.$refs.canvas1; - const ctx = el.getContext('2d'); - ctx.beginPath(); - ctx.arc(100, 75, 50, 0, 6.28); - ctx.stroke(); - }, - antialias() { - const el = this.$refs.canvas1; - const ctx = el.getContext('2d', { antialias: true }); - ctx.beginPath(); - ctx.arc(100, 75, 50, 0, 6.28); - ctx.stroke(); - } - } - ``` - - -- 示意图(关闭抗锯齿) - - ![](figures/zh-cn_image_0000001214837333.png) - -- 示意图(开启抗锯齿) - - ![](figures/zh-cn_image_0000001127125162.png) - - -## 属性 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

描述

-

fillStyle

-

<color> | CanvasGradient | CanvasPattern

-

-

-

指定绘制的填充色。

-
  • 类型为<color>时,表示设置填充区域的颜色。
  • 类型为CanvasGradient时,表示渐变对象,使用 createLinearGradient()方法创建。
  • 类型为CanvasPattern时,使用 createPattern()方法创建。
-

lineWidth

-

number

-

-

-

设置绘制线条的宽度。

-

strokeStyle

-

<color> | CanvasGradient | CanvasPattern

-

-

-

设置描边的颜色。

-
  • 类型为<color>时,表示设置描边使用的颜色。
  • 类型为CanvasGradient时,表示渐变对象,使用 createLinearGradient()方法创建。
  • 类型为CanvasPattern时,使用 createPattern()方法创建。
-

lineCap

-

string

-

butt

-

指定线端点的样式,可选值为:

-
  • butt:线端点以方形结束。
  • round:线端点以圆形结束。
  • square:线端点以方形结束,该样式下会增加一个长度和线段厚度相同,宽度是线段厚度一半的矩形。
-

lineJoin

-

string

-

miter

-

指定线段间相交的交点样式,可选值为:

-
  • round:在线段相连处绘制一个扇形,扇形的圆角半径是线段的宽度。
  • bevel:在线段相连处使用三角形为底填充, 每个部分矩形拐角独立。
  • miter:在相连部分的外边缘处进行延伸,使其相交于一点,形成一个菱形区域,该属性可以通过设置miterLimit属性展现效果。
-

miterLimit

-

number

-

10

-

设置斜接面限制值,该值指定了线条相交处内角和外角的距离。

-

font

-

string

-

"normal normal 14px sans-serif"

-

设置文本绘制中的字体样式。

-

语法:ctx.font="font-style font-weight font-size font-family"5+

-
  • font-style(可选),用于指定字体样式,支持如下几种样式:normal, italic。
  • font-weight(可选),用于指定字体的粗细,支持如下几种类型:normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900。
  • font-size(可选),指定字号和行高,单位只支持px。
  • font-family(可选),指定字体系列,支持如下几种类型:sans-serif, serif, monospace。
-

textAlign

-

string

-

left

-

设置文本绘制中的文本对齐方式,可选值为:

-
  • left:文本左对齐。
  • right:文本右对齐。
  • center:文本居中对齐。
  • start:文本对齐界线开始的地方。
  • end:文本对齐界线结束的地方。
-
说明:

ltr布局模式下start和left一致,rtl布局模式下start和right一致·。

-
-

textBaseline

-

string

-

alphabetic

-

设置文本绘制中的水平对齐方式,可选值为:

-
  • alphabetic:文本基线是标准的字母基线。
  • top:文本基线在文本块的顶部。
  • hanging:文本基线是悬挂基线。
  • middle:文本基线在文本块的中间。
  • ideographic:文字基线是表意字基线;如果字符本身超出了alphabetic 基线,那么ideographic基线位置在字符本身的底部。
  • bottom:文本基线在文本块的底部。 与 ideographic 基线的区别在于 ideographic 基线不需要考虑下行字母。
-

globalAlpha

-

number

-

-

-

设置透明度,0.0为完全透明,1.0为完全不透明。

-

lineDashOffset

-

number

-

0.0

-

设置画布的虚线偏移量,精度为float。

-

globalCompositeOperation

-

string

-

source-over

-

设置合成操作的方式。类型字段可选值有source-over,source-atop,source-in,source-out,destination-over,destination-atop,destination-in,destination-out,lighter,copy,xor。具体请参考类型字段说明

-

shadowBlur

-

number

-

0.0

-

设置绘制阴影时的模糊级别,值越大越模糊,精度为float。

-

shadowColor

-

<color>

-

-

-

设置绘制阴影时的阴影颜色。

-

shadowOffsetX

-

number

-

-

-

设置绘制阴影时和原有对象的水平偏移值。

-

shadowOffsetY

-

number

-

-

-

设置绘制阴影时和原有对象的垂直偏移值。

-

imageSmoothingEnabled6+

-

boolean

-

true

-

用于设置绘制图片时是否进行图像平滑度调整,true为启用,false为不启用。

-
- -### fillStyle + +- 示例 + ``` + +
+ + + <input type="button" style="width: 180px; height: 60px;" value="fillStyle" onclick="antialias" />
+ ``` + + ``` + // xxx.js + export default { + handleClick() { + const el = this.$refs.canvas1; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.arc(100, 75, 50, 0, 6.28); + ctx.stroke(); + }, + antialias() { + const el = this.$refs.canvas1; + const ctx = el.getContext('2d', { antialias: true }); ctx.beginPath(); ctx.arc(100, 75, 50, 0, 6.28); ctx.stroke(); }} + ``` + +- 示意图(关闭抗锯齿) + ![zh-cn_image_0000001214837333](figures/zh-cn_image_0000001214837333.png) + +- 示意图(开启抗锯齿) + ![zh-cn_image_0000001127125162](figures/zh-cn_image_0000001127125162.png) + + +## 属性 + +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| [fillStyle](#fillstyle) | <color> \| [CanvasGradient](../arkui-js/js-components-canvas-canvasgradient.md) \| CanvasPattern | - | 指定绘制的填充色。
- 类型为<color>时,表示设置填充区域的颜色。
- 类型为CanvasGradient时,表示渐变对象,使用 createLinearGradient()方法创建。
- 类型为CanvasPattern时,使用 createPattern()方法创建。 | +| [lineWidth](#linewidth) | number | - | 设置绘制线条的宽度。 | +| [strokeStyle](#strokestyle) | <color> \| [CanvasGradient](../arkui-js/js-components-canvas-canvasgradient.md) \| CanvasPattern | - | 设置描边的颜色。
- 类型为<color>时,表示设置描边使用的颜色。
- 类型为CanvasGradient时,表示渐变对象,使用 createLinearGradient()方法创建。
- 类型为CanvasPattern时,使用 createPattern()方法创建。 | +| [lineCap](#linecap) | string | butt | 指定线端点的样式,可选值为:
- butt:线端点以方形结束。
- round:线端点以圆形结束。
- square:线端点以方形结束,该样式下会增加一个长度和线段厚度相同,宽度是线段厚度一半的矩形。 | +| [lineJoin](#linejoin) | string | miter | 指定线段间相交的交点样式,可选值为:
- round:在线段相连处绘制一个扇形,扇形的圆角半径是线段的宽度。
- bevel:在线段相连处使用三角形为底填充, 每个部分矩形拐角独立。
- miter:在相连部分的外边缘处进行延伸,使其相交于一点,形成一个菱形区域,该属性可以通过设置miterLimit属性展现效果。 | +| [miterLimit](#miterlimit) | number | 10 | 设置斜接面限制值,该值指定了线条相交处内角和外角的距离。 | +| [font](#font) | string | "normal normal 14px sans-serif" | 设置文本绘制中的字体样式。
语法:ctx.font="font-style font-weight font-size font-family"5+
- font-style(可选),用于指定字体样式,支持如下几种样式:normal, italic。
- font-weight(可选),用于指定字体的粗细,支持如下几种类型:normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900。
- font-size(可选),指定字号和行高,单位只支持px。
- font-family(可选),指定字体系列,支持如下几种类型:sans-serif, serif, monospace。 | +| [textAlign](#textalign) | string | left | 设置文本绘制中的文本对齐方式,可选值为:
- left:文本左对齐。
- right:文本右对齐。
- center:文本居中对齐。
- start:文本对齐界线开始的地方。
- end:文本对齐界线结束的地方。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> ltr布局模式下start和left一致,rtl布局模式下start和right一致·。 | +| [textBaseline](#textbaseline) | string | alphabetic | 设置文本绘制中的水平对齐方式,可选值为:
- alphabetic:文本基线是标准的字母基线。
- top:文本基线在文本块的顶部。
- hanging:文本基线是悬挂基线。
- middle:文本基线在文本块的中间。
- ideographic:文字基线是表意字基线;如果字符本身超出了alphabetic 基线,那么ideographic基线位置在字符本身的底部。
- bottom:文本基线在文本块的底部。 与 ideographic 基线的区别在于 ideographic 基线不需要考虑下行字母。 | +| [globalAlpha](#globalalpha) | number | - | 设置透明度,0.0为完全透明,1.0为完全不透明。 | +| [lineDashOffset](#linedashoffset) | number | 0.0 | 设置画布的虚线偏移量,精度为float。 | +| [globalCompositeOperation](#globalcompositeoperation) | string | source-over | 设置合成操作的方式。类型字段可选值有source-over,source-atop,source-in,source-out,destination-over,destination-atop,destination-in,destination-out,lighter,copy,xor。具体请参考[表 类型字段说明](#globalcompositeoperation)。 | +| [shadowBlur](#shadowblur) | number | 0.0 | 设置绘制阴影时的模糊级别,值越大越模糊,精度为float。 | +| [shadowColor](#shadowcolor) | <color> | - | 设置绘制阴影时的阴影颜色。 | +| [shadowOffsetX](#shadowoffsetx) | number | - | 设置绘制阴影时和原有对象的水平偏移值。 | +| [shadowOffsetY](#shadowoffsety) | number | - | 设置绘制阴影时和原有对象的垂直偏移值。 | +| [imageSmoothingEnabled](#imagesmoothingenabled6-)6+ | boolean | true | 用于设置绘制图片时是否进行图像平滑度调整,true为启用,false为不启用。 | + + +### fillStyle ``` @@ -242,9 +81,10 @@ export default { } ``` -![](figures/zh-cn_image_0000001166962736.png) +![zh-cn_image_0000001166962736](figures/zh-cn_image_0000001166962736.png) -### lineWidth + +### lineWidth ``` @@ -265,9 +105,10 @@ export default { } ``` -![](figures/zh-cn_image_0000001166484430.png) +![zh-cn_image_0000001166484430](figures/zh-cn_image_0000001166484430.png) + -### strokeStyle +### strokeStyle ``` @@ -289,9 +130,10 @@ export default { } ``` -![](figures/zh-cn_image_0000001212124299.png) -### lineCap +![zh-cn_image_0000001212124299](figures/zh-cn_image_0000001212124299.png) + +### lineCap ``` @@ -316,9 +158,9 @@ export default { } ``` -![](figures/zh-cn_image_0000001214837127.png) +![zh-cn_image_0000001214837127](figures/zh-cn_image_0000001214837127.png) -### lineJoin +### lineJoin ``` @@ -344,9 +186,9 @@ export default { } ``` -![](figures/zh-cn_image_0000001214717247.png) +![zh-cn_image_0000001214717247](figures/zh-cn_image_0000001214717247.png) -### miterLimit +### miterLimit ``` @@ -372,9 +214,10 @@ export default { } ``` -![](figures/zh-cn_image_0000001167001464.png) +![zh-cn_image_0000001167001464](figures/zh-cn_image_0000001167001464.png) -### font + +### font ``` @@ -395,9 +238,10 @@ export default { } ``` -![](figures/zh-cn_image_0000001167046832.png) +![zh-cn_image_0000001167046832](figures/zh-cn_image_0000001167046832.png) + -### textAlign +### textAlign ``` @@ -434,9 +278,10 @@ export default { } ``` -![](figures/zh-cn_image_0000001167472798.png) -### textBaseline +![zh-cn_image_0000001167472798](figures/zh-cn_image_0000001167472798.png) + +### textBaseline ``` @@ -472,9 +317,9 @@ export default { } ``` -![](figures/zh-cn_image_0000001169315920.png) +![zh-cn_image_0000001169315920](figures/zh-cn_image_0000001169315920.png) -### globalAlpha +### globalAlpha ``` @@ -499,9 +344,9 @@ export default { } ``` -![](figures/zh-cn_image_0000001167953648.png) +![zh-cn_image_0000001167953648](figures/zh-cn_image_0000001167953648.png) -### lineDashOffset +### lineDashOffset ``` @@ -524,113 +369,59 @@ export default { } ``` -![](figures/zh-cn_image_0000001167950468.png) - -### globalCompositeOperation - -- 类型字段说明 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-

描述

-

source-over

-

在现有绘制内容上显示新绘制内容,属于默认值。

-

source-atop

-

在现有绘制内容顶部显示新绘制内容。

-

source-in

-

在现有绘制内容中显示新绘制内容。

-

source-out

-

在现有绘制内容之外显示新绘制内容。

-

destination-over

-

在新绘制内容上方显示现有绘制内容。

-

destination-atop

-

在新绘制内容顶部显示现有绘制内容。

-

destination-in

-

在新绘制内容中显示现有绘制内容。

-

destination-out

-

在新绘制内容外显示现有绘制内容。

-

lighter

-

显示新绘制内容和现有绘制内容。

-

copy

-

显示新绘制内容而忽略现有绘制内容。

-

xor

-

使用异或操作对新绘制内容与现有绘制内容进行融合。

-
- - -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.fillStyle = 'rgb(255,0,0)'; - ctx.fillRect(20, 20, 50, 50); - ctx.globalCompositeOperation = 'source-over'; - ctx.fillStyle = 'rgb(0,0,255)'; - ctx.fillRect(50, 50, 50, 50); - // Start drawing second example - ctx.fillStyle = 'rgb(255,0,0)'; - ctx.fillRect(120, 20, 50, 50); - ctx.globalCompositeOperation = 'destination-over'; - ctx.fillStyle = 'rgb(0,0,255)'; - ctx.fillRect(150, 50, 50, 50); - } +![zh-cn_image_0000001167950468](figures/zh-cn_image_0000001167950468.png) + +### globalCompositeOperation + +- 类型字段说明 + | 值 | 描述 | + | -------- | -------- | + | source-over | 在现有绘制内容上显示新绘制内容,属于默认值。 | + | source-atop | 在现有绘制内容顶部显示新绘制内容。 | + | source-in | 在现有绘制内容中显示新绘制内容。 | + | source-out | 在现有绘制内容之外显示新绘制内容。 | + | destination-over | 在新绘制内容上方显示现有绘制内容。 | + | destination-atop | 在新绘制内容顶部显示现有绘制内容。 | + | destination-in | 在新绘制内容中显示现有绘制内容。 | + | destination-out | 在新绘制内容外显示现有绘制内容。 | + | lighter | 显示新绘制内容和现有绘制内容。 | + | copy | 显示新绘制内容而忽略现有绘制内容。 | + | xor | 使用异或操作对新绘制内容与现有绘制内容进行融合。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(20, 20, 50, 50); + ctx.globalCompositeOperation = 'source-over'; + ctx.fillStyle = 'rgb(0,0,255)'; + ctx.fillRect(50, 50, 50, 50); + // Start drawing second example + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(120, 20, 50, 50); + ctx.globalCompositeOperation = 'destination-over'; + ctx.fillStyle = 'rgb(0,0,255)'; + ctx.fillRect(150, 50, 50, 50); } - ``` - - ![](figures/zh-cn_image_0000001213192781.png) + } + ``` - 示例中,新绘制内容是蓝色矩形,现有绘制内容是红色矩形。 + ![zh-cn_image_0000001213192781](figures/zh-cn_image_0000001213192781.png) + 示例中,新绘制内容是蓝色矩形,现有绘制内容是红色矩形。 -### shadowBlur +### shadowBlur ``` @@ -653,9 +444,9 @@ export default { } ``` -![](figures/zh-cn_image_0000001168111514.png) +![zh-cn_image_0000001168111514](figures/zh-cn_image_0000001168111514.png) -### shadowColor +### shadowColor ``` @@ -678,9 +469,9 @@ export default { } ``` -![](figures/zh-cn_image_0000001168111610.png) +![zh-cn_image_0000001168111610](figures/zh-cn_image_0000001168111610.png) -### shadowOffsetX +### shadowOffsetX ``` @@ -704,9 +495,10 @@ export default { } ``` -![](figures/zh-cn_image_0000001167631876.png) -### shadowOffsetY +![zh-cn_image_0000001167631876](figures/zh-cn_image_0000001167631876.png) + +### shadowOffsetY ``` @@ -730,9 +522,9 @@ export default { } ``` -![](figures/zh-cn_image_0000001213193285.png) +![zh-cn_image_0000001213193285](figures/zh-cn_image_0000001213193285.png) -### imageSmoothingEnabled6+ +### imageSmoothingEnabled6+ ``` @@ -757,2463 +549,1384 @@ export default { } ``` -![](figures/smoothOff.png) +![zh-cn_image_0000001167952236](figures/zh-cn_image_0000001167952236.png) + + -## 方法 +## 方法 -### fillRect -fillRect\(x: number, y: number, width:number, height: number\): void +### fillRect + +fillRect(x: number, y: number, width:number, height: number): void 填充一个矩形。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

指定矩形左上角点的x坐标。

-

y

-

number

-

指定矩形左上角点的y坐标。

-

width

-

number

-

指定矩形的宽度。

-

height

-

number

-

指定矩形的高度。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.fillRect(20, 20, 200, 150); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 指定矩形左上角点的x坐标。 | + | y | number | 指定矩形左上角点的y坐标。 | + | width | number | 指定矩形的宽度。 | + | height | number | 指定矩形的高度。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillRect(20, 20, 200, 150); } - ``` - - ![](figures/zh-cn_image_0000001214811029.png) + } + ``` + ![zh-cn_image_0000001214811029](figures/zh-cn_image_0000001214811029.png) -### clearRect +### clearRect -clearRect\(x: number, y: number, width:number, height: number\): void +clearRect(x: number, y: number, width:number, height: number): void 删除指定区域内的绘制内容。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

指定矩形上的左上角x坐标。

-

y

-

number

-

指定矩形上的左上角y坐标。

-

width

-

number

-

指定矩形的宽度。

-

height

-

number

-

指定矩形的高度。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.fillStyle = 'rgb(0,0,255)'; - ctx.fillRect(0, 0, 400, 200); - ctx.clearRect(20, 20, 150, 100); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 指定矩形上的左上角x坐标。 | + | y | number | 指定矩形上的左上角y坐标。 | + | width | number | 指定矩形的宽度。 | + | height | number | 指定矩形的高度。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillStyle = 'rgb(0,0,255)'; + ctx.fillRect(0, 0, 400, 200); + ctx.clearRect(20, 20, 150, 100); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001214619417.png) + ![zh-cn_image_0000001214619417](figures/zh-cn_image_0000001214619417.png) -### strokeRect +### strokeRect -strokeRect\(x: number, y: number, width:number, height: number\): void +strokeRect(x: number, y: number, width:number, height: number): void 绘制具有边框的矩形,矩形内部不填充。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

指定矩形的左上角x坐标。

-

y

-

number

-

指定矩形的左上角y坐标。

-

width

-

number

-

指定矩形的宽度。

-

height

-

number

-

指定矩形的高度。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.strokeRect(30, 30, 200, 150); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 指定矩形的左上角x坐标。 | + | y | number | 指定矩形的左上角y坐标。 | + | width | number | 指定矩形的宽度。 | + | height | number | 指定矩形的高度。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.strokeRect(30, 30, 200, 150); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001214822091.png) + ![zh-cn_image_0000001214822091](figures/zh-cn_image_0000001214822091.png) -### fillText +### fillText -fillText\(text: string, x: number, y: number\): void +fillText(text: string, x: number, y: number): void 绘制填充类文本。 -- 参数 - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

text

-

string

-

需要绘制的文本内容。

-

x

-

number

-

需要绘制的文本的左下角x坐标。

-

y

-

number

-

需要绘制的文本的左下角y坐标。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.font = '35px sans-serif'; - ctx.fillText("Hello World!", 10, 60); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | text | string | 需要绘制的文本内容。 | + | x | number | 需要绘制的文本的左下角x坐标。 | + | y | number | 需要绘制的文本的左下角y坐标。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.font = '35px sans-serif'; + ctx.fillText("Hello World!", 10, 60); } - ``` - - ![](figures/zh-cn_image_0000001214469787.png) + } + ``` + ![zh-cn_image_0000001214469787](figures/zh-cn_image_0000001214469787.png) -### strokeText +### strokeText -strokeText\(text: string, x: number, y: number\): void +strokeText(text: string, x: number, y: number): void 绘制描边类文本。 -- 参数 - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

text

-

string

-

需要绘制的文本内容。

-

x

-

number

-

需要绘制的文本的左下角x坐标。

-

y

-

number

-

需要绘制的文本的左下角y坐标。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.font = '25px sans-serif'; - ctx.strokeText("Hello World!", 10, 60); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | text | string | 需要绘制的文本内容。 | + | x | number | 需要绘制的文本的左下角x坐标。 | + | y | number | 需要绘制的文本的左下角y坐标。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.font = '25px sans-serif'; + ctx.strokeText("Hello World!", 10, 60); } - ``` - - ![](figures/zh-cn_image_0000001214460669.png) + } + ``` + ![zh-cn_image_0000001214460669](figures/zh-cn_image_0000001214460669.png) -### measureText +### measureText -measureText\(text: string\): TextMetrics +measureText(text: string): TextMetrics 该方法返回一个文本测算的对象,通过该对象可以获取指定文本的宽度值。 -- 参数 - - - - - - - - - - - -

参数

-

类型

-

描述

-

text

-

string

-

需要进行测量的文本。

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

TextMetrics

-

包含指定字体的宽度,该宽度可以通过TextMetrics.width来获取。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.font = '20px sans-serif'; - var txt = 'Hello World'; - ctx.fillText("width:" + ctx.measureText(txt).width, 20, 60); - ctx.fillText(txt, 20, 110); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | text | string | 需要进行测量的文本。 | + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | TextMetrics | 包含指定字体的宽度,该宽度可以通过TextMetrics.width来获取。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.font = '20px sans-serif'; + var txt = 'Hello World'; + ctx.fillText("width:" + ctx.measureText(txt).width, 20, 60); + ctx.fillText(txt, 20, 110); } - ``` - - ![](figures/zh-cn_image_0000001169142476.png) + } + ``` + ![zh-cn_image_0000001169142476](figures/zh-cn_image_0000001169142476.png) -### stroke -stroke\(\): void +### stroke +stroke(): void 进行边框绘制操作。 -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.moveTo(25, 25); - ctx.lineTo(25, 250); - ctx.lineWidth = '6'; - ctx.strokeStyle = 'rgb(0,0,255)'; - ctx.stroke(); - } +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.moveTo(25, 25); + ctx.lineTo(25, 250); + ctx.lineWidth = '6'; + ctx.strokeStyle = 'rgb(0,0,255)'; + ctx.stroke(); } - ``` - - ![](figures/zh-cn_image_0000001236697937.png) + } + ``` + ![zh-cn_image_0000001236697937](figures/zh-cn_image_0000001236697937.png) -### beginPath -beginPath\(\): void +### beginPath +beginPath(): void 创建一个新的绘制路径。 -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.beginPath(); - ctx.lineWidth = '6'; - ctx.strokeStyle = '#0000ff'; - ctx.moveTo(15, 80); - ctx.lineTo(280, 80); - ctx.stroke(); - } +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.lineWidth = '6'; + ctx.strokeStyle = '#0000ff'; + ctx.moveTo(15, 80); + ctx.lineTo(280, 80); + ctx.stroke(); } - ``` - - ![](figures/zh-cn_image_0000001214629745.png) + } + ``` + ![zh-cn_image_0000001214629745](figures/zh-cn_image_0000001214629745.png) -### moveTo -moveTo\(x: number, y: number\): void +### moveTo +moveTo(x: number, y: number): void 路径从当前点移动到指定点。 -- 参数 - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

指定位置的x坐标。

-

y

-

number

-

指定位置的y坐标。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.beginPath(); - ctx.moveTo(10, 10); - ctx.lineTo(280, 160); - ctx.stroke(); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 指定位置的x坐标。 | + | y | number | 指定位置的y坐标。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.moveTo(10, 10); + ctx.lineTo(280, 160); + ctx.stroke(); } - ``` - - ![](figures/zh-cn_image_0000001169309948.png) + } + ``` + ![zh-cn_image_0000001169309948](figures/zh-cn_image_0000001169309948.png) -### lineTo -lineTo\(x: number, y: number\): void +### lineTo +lineTo(x: number, y: number): void 从当前点到指定点进行路径连接。 -- 参数 - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

指定位置的x坐标。

-

y

-

number

-

指定位置的y坐标。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.beginPath(); - ctx.moveTo(10, 10); - ctx.lineTo(280, 160); - ctx.stroke(); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 指定位置的x坐标。 | + | y | number | 指定位置的y坐标。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.moveTo(10, 10); + ctx.lineTo(280, 160); + ctx.stroke(); } - ``` - - ![](figures/zh-cn_image_0000001169469914.png) + } + ``` + ![zh-cn_image_0000001169469914](figures/zh-cn_image_0000001169469914.png) -### closePath -closePath\(\): void +### closePath +closePath(): void 结束当前路径形成一个封闭路径。 -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.beginPath(); - ctx.moveTo(30, 30); - ctx.lineTo(110, 30); - ctx.lineTo(70, 90); - ctx.closePath(); - ctx.stroke(); - } +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.moveTo(30, 30); + ctx.lineTo(110, 30); + ctx.lineTo(70, 90); + ctx.closePath(); + ctx.stroke(); } - ``` - - ![](figures/zh-cn_image_0000001169151508.png) + } + ``` + ![zh-cn_image_0000001169151508](figures/zh-cn_image_0000001169151508.png) -### createPattern +### createPattern -createPattern\(image: Image, repetition: string\): Object +createPattern(image: Image, repetition: string): Object 通过指定图像和重复方式创建图片填充的模板。 -- 参数 - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

image

-

Image

-

图源对象,具体参考Image对象

-

repetition

-

string

-

设置图像重复的方式,取值为:'repeat'、'repeat-x'、 'repeat-y'、'no-repeat'。

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

Object

-

指定图像填充的Pattern对象。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var img = new Image(); - img.src = 'common/images/example.jpg'; - var pat = ctx.createPattern(img, 'repeat'); - ctx.fillStyle = pat; - ctx.fillRect(0, 0, 20, 20); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | image | Image | 图源对象,具体参考[Image对象](../arkui-js/js-components-canvas-image.md)。 | + | repetition | string | 设置图像重复的方式,取值为:'repeat'、'repeat-x'、 'repeat-y'、'no-repeat'。 | + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | Object | 指定图像填充的Pattern对象。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var img = new Image(); + img.src = 'common/images/example.jpg'; + var pat = ctx.createPattern(img, 'repeat'); + ctx.fillStyle = pat; + ctx.fillRect(0, 0, 20, 20); } - ``` - - ![](figures/zh-cn_image_0000001169301188.png) + } + ``` + ![zh-cn_image_0000001169301188](figures/zh-cn_image_0000001169301188.png) -### bezierCurveTo +### bezierCurveTo -bezierCurveTo\(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number\): void +bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void 创建三次贝赛尔曲线的路径。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

cp1x

-

number

-

第一个贝塞尔参数的x坐标值。

-

cp1y

-

number

-

第一个贝塞尔参数的y坐标值。

-

cp2x

-

number

-

第二个贝塞尔参数的x坐标值。

-

cp2y

-

number

-

第二个贝塞尔参数的y坐标值。

-

x

-

number

-

路径结束时的x坐标值。

-

y

-

number

-

路径结束时的y坐标值。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.beginPath(); - ctx.moveTo(10, 10); - ctx.bezierCurveTo(20, 100, 200, 100, 200, 20); - ctx.stroke(); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | cp1x | number | 第一个贝塞尔参数的x坐标值。 | + | cp1y | number | 第一个贝塞尔参数的y坐标值。 | + | cp2x | number | 第二个贝塞尔参数的x坐标值。 | + | cp2y | number | 第二个贝塞尔参数的y坐标值。 | + | x | number | 路径结束时的x坐标值。 | + | y | number | 路径结束时的y坐标值。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.moveTo(10, 10); + ctx.bezierCurveTo(20, 100, 200, 100, 200, 20); + ctx.stroke(); } - ``` - - ![](figures/zh-cn_image_0000001214621177.png) + } + ``` + ![zh-cn_image_0000001214621177](figures/zh-cn_image_0000001214621177.png) -### quadraticCurveTo +### quadraticCurveTo -quadraticCurveTo\(cpx: number, cpy: number, x: number, y: number\): void +quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void 创建二次贝赛尔曲线的路径。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

cpx

-

number

-

贝塞尔参数的x坐标值。

-

cpy

-

number

-

贝塞尔参数的y坐标值。

-

x

-

number

-

路径结束时的x坐标值。

-

y

-

number

-

路径结束时的y坐标值。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.beginPath(); - ctx.moveTo(20, 20); - ctx.quadraticCurveTo(100, 100, 200, 20); - ctx.stroke(); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | cpx | number | 贝塞尔参数的x坐标值。 | + | cpy | number | 贝塞尔参数的y坐标值。 | + | x | number | 路径结束时的x坐标值。 | + | y | number | 路径结束时的y坐标值。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.moveTo(20, 20); + ctx.quadraticCurveTo(100, 100, 200, 20); + ctx.stroke(); } - ``` - - ![](figures/zh-cn_image_0000001169461910.png) + } + ``` + ![zh-cn_image_0000001169461910](figures/zh-cn_image_0000001169461910.png) -### arc -arc\(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: boolean\): void +### arc +arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: boolean): void 绘制弧线路径。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

弧线圆心的x坐标值。

-

y

-

number

-

弧线圆心的y坐标值。

-

radius

-

number

-

弧线的圆半径。

-

startAngle

-

number

-

弧线的起始弧度。

-

endAngle

-

number

-

弧线的终止弧度。

-

anticlockwise

-

boolean

-

是否逆时针绘制圆弧。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.beginPath(); - ctx.arc(100, 75, 50, 0, 6.28); - ctx.stroke(); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 弧线圆心的x坐标值。 | + | y | number | 弧线圆心的y坐标值。 | + | radius | number | 弧线的圆半径。 | + | startAngle | number | 弧线的起始弧度。 | + | endAngle | number | 弧线的终止弧度。 | + | anticlockwise | boolean | 是否逆时针绘制圆弧。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.arc(100, 75, 50, 0, 6.28); + ctx.stroke(); } - ``` - - ![](figures/zh-cn_image_0000001169470288.png) + } + ``` + ![zh-cn_image_0000001169470288](figures/zh-cn_image_0000001169470288.png) -### arcTo +### arcTo -arcTo\(x1: number, y1: number, x2: number, y2: number, radius: number\): void +arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void 依据圆弧经过的点和圆弧半径创建圆弧路径。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x1

-

number

-

圆弧经过的第一个点的x坐标值。

-

y1

-

number

-

圆弧经过的第一个点的y坐标值。

-

x2

-

number

-

圆弧经过的第二个点的x坐标值。

-

y2

-

number

-

圆弧经过的第二个点的y坐标值。

-

radius

-

number

-

圆弧的圆半径值。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.moveTo(100, 20); - ctx.arcTo(150, 20, 150, 70, 50); // Create an arc - ctx.stroke(); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x1 | number | 圆弧经过的第一个点的x坐标值。 | + | y1 | number | 圆弧经过的第一个点的y坐标值。 | + | x2 | number | 圆弧经过的第二个点的x坐标值。 | + | y2 | number | 圆弧经过的第二个点的y坐标值。 | + | radius | number | 圆弧的圆半径值。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.moveTo(100, 20); + ctx.arcTo(150, 20, 150, 70, 50); // Create an arc + ctx.stroke(); } - ``` - - ![](figures/zh-cn_image_0000001169143586.png) + } + ``` + ![zh-cn_image_0000001169143586](figures/zh-cn_image_0000001169143586.png) -### ellipse6+ +### ellipse6+ -ellipse\(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise: number\): void +ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise: number): void 在规定的矩形区域绘制一个椭圆。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

椭圆圆心的x轴坐标。

-

y

-

number

-

椭圆圆心的y轴坐标。

-

radiusX

-

number

-

椭圆x轴的半径长度。

-

radiusY

-

number

-

椭圆y轴的半径长度。

-

rotation

-

number

-

椭圆的旋转角度,单位为弧度。

-

startAngle

-

number

-

椭圆绘制的起始点角度,以弧度表示。

-

endAngle

-

number

-

椭圆绘制的结束点角度,以弧度表示。

-

anticlockwise

-

number

-

是否以逆时针方向绘制椭圆,0为顺时针,1为逆时针。(可选参数,默认为0)

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.beginPath(); - ctx.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, 1); - ctx.stroke(); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 椭圆圆心的x轴坐标。 | + | y | number | 椭圆圆心的y轴坐标。 | + | radiusX | number | 椭圆x轴的半径长度。 | + | radiusY | number | 椭圆y轴的半径长度。 | + | rotation | number | 椭圆的旋转角度,单位为弧度。 | + | startAngle | number | 椭圆绘制的起始点角度,以弧度表示。 | + | endAngle | number | 椭圆绘制的结束点角度,以弧度表示。 | + | anticlockwise | number | 是否以逆时针方向绘制椭圆,0为顺时针,1为逆时针。(可选参数,默认为0) | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.beginPath(); + ctx.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, 1); + ctx.stroke(); } - ``` - - ![](figures/ellipse.png) + } + ``` + ![zh-cn_image_0000001214823665](figures/zh-cn_image_0000001214823665.png) -### rect -rect\(x: number, y: number, width: number, height: number\): void +### rect +rect(x: number, y: number, width: number, height: number): void 创建矩形路径。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

指定矩形的左上角x坐标值。

-

y

-

number

-

指定矩形的左上角y坐标值。

-

width

-

number

-

指定矩形的宽度。

-

height

-

number

-

指定矩形的高度。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.rect(20, 20, 100, 100); // Create a 100*100 rectangle at (20, 20) - ctx.stroke(); // Draw it - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 指定矩形的左上角x坐标值。 | + | y | number | 指定矩形的左上角y坐标值。 | + | width | number | 指定矩形的宽度。 | + | height | number | 指定矩形的高度。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.rect(20, 20, 100, 100); // Create a 100*100 rectangle at (20, 20) + ctx.stroke(); // Draw it } - ``` - - ![](figures/zh-cn_image_0000001214630783.png) + } + ``` + ![zh-cn_image_0000001214630783](figures/zh-cn_image_0000001214630783.png) -### fill +### fill -fill\(\): void +fill(): void 对封闭路径进行填充。 -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.rect(20, 20, 100, 100); // Create a 100*100 rectangle at (20, 20) - ctx.fill(); // Draw it in default setting - } +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.rect(20, 20, 100, 100); // Create a 100*100 rectangle at (20, 20) + ctx.fill(); // Draw it in default setting } - ``` - - ![](figures/zh-cn_image_0000001214703717.png) + } + ``` + ![zh-cn_image_0000001214703717](figures/zh-cn_image_0000001214703717.png) -### clip +### clip -clip\(\): void +clip(): void 设置当前路径为剪切路径。 -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.rect(0, 0, 200, 200); - ctx.stroke(); - ctx.clip(); - // Draw red rectangle after clip - ctx.fillStyle = "rgb(255,0,0)"; - ctx.fillRect(0, 0, 150, 150); - } +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.rect(0, 0, 200, 200); + ctx.stroke(); + ctx.clip(); + // Draw red rectangle after clip + ctx.fillStyle = "rgb(255,0,0)"; + ctx.fillRect(0, 0, 150, 150); } - ``` - - ![](figures/zh-cn_image_0000001169303414.png) + } + ``` + ![zh-cn_image_0000001169303414](figures/zh-cn_image_0000001169303414.png) -### rotate +### rotate -rotate\(rotate: number\): void +rotate(rotate: number): void 针对当前坐标轴进行顺时针旋转。 -- 参数 - - - - - - - - - - - -

参数

-

类型

-

描述

-

rotate

-

number

-

设置顺时针旋转的弧度值,可以通过Math.PI / 180将角度转换为弧度值。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.rotate(45 * Math.PI / 180); // Rotate the rectangle 45 degrees - ctx.fillRect(70, 20, 50, 50); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | rotate | number | 设置顺时针旋转的弧度值,可以通过Math.PI / 180将角度转换为弧度值。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.rotate(45 * Math.PI / 180); // Rotate the rectangle 45 degrees + ctx.fillRect(70, 20, 50, 50); } - ``` - - ![](figures/zh-cn_image_0000001169463368.png) + } + ``` + ![zh-cn_image_0000001169463368](figures/zh-cn_image_0000001169463368.png) -### scale +### scale -scale\(x: number, y: number\): void +scale(x: number, y: number): void 设置canvas画布的缩放变换属性,后续的绘制操作将按照缩放比例进行缩放。 -- 参数 - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

设置水平方向的缩放值。

-

y

-

number

-

设置垂直方向的缩放值。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.strokeRect(10, 10, 25, 25); - ctx.scale(2, 2);// Scale to 200% - ctx.strokeRect(10, 10, 25, 25); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 设置水平方向的缩放值。 | + | y | number | 设置垂直方向的缩放值。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.strokeRect(10, 10, 25, 25); + ctx.scale(2, 2);// Scale to 200% + ctx.strokeRect(10, 10, 25, 25); } - ``` - - ![](figures/zh-cn_image_0000001214463281.png) + } + ``` + ![zh-cn_image_0000001214463281](figures/zh-cn_image_0000001214463281.png) -### transform +### transform -transform\(scaleX: number, skewX: number, skewY: number, scale: number, translateX: number, translateY: number\): void +transform(scaleX: number, skewX: number, skewY: number, scale: number, translateX: number, translateY: number): void transform方法对应一个变换矩阵,想对一个图形进行变化的时候,只要设置此变换矩阵相应的参数,对图形的各个定点的坐标分别乘以这个矩阵,就能得到新的定点的坐标。矩阵变换效果可叠加。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->变换后的坐标计算方式(x和y为变换前坐标,x'和y'为变换后坐标): ->- x' = scaleX \* x + skewY \* y + translateX ->- y' = skewX \* x + scaleY \* y + translateY - -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

scaleX

-

number

-

指定水平缩放值。

-

skewX

-

number

-

指定水平倾斜值。

-

skewY

-

number

-

指定垂直倾斜值。

-

scaleY

-

number

-

指定垂直缩放值。

-

translateX

-

number

-

指定水平移动值。

-

translateY

-

number

-

指定垂直移动值。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.fillStyle = 'rgb(0,0,0)'; - ctx.fillRect(0, 0, 100, 100) - ctx.transform(1, 0.5, -0.5, 1, 10, 10); - ctx.fillStyle = 'rgb(255,0,0)'; - ctx.fillRect(0, 0, 100, 100); - ctx.transform(1, 0.5, -0.5, 1, 10, 10); - ctx.fillStyle = 'rgb(0,0,255)'; - ctx.fillRect(0, 0, 100, 100); - } +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 变换后的坐标计算方式(x和y为变换前坐标,x'和y'为变换后坐标): +> +> - x' = scaleX \* x + skewY \* y + translateX +> +> - y' = skewX \* x + scaleY \* y + translateY + +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | scaleX | number | 指定水平缩放值。 | + | skewX | number | 指定水平倾斜值。 | + | skewY | number | 指定垂直倾斜值。 | + | scaleY | number | 指定垂直缩放值。 | + | translateX | number | 指定水平移动值。 | + | translateY | number | 指定垂直移动值。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillStyle = 'rgb(0,0,0)'; + ctx.fillRect(0, 0, 100, 100) + ctx.transform(1, 0.5, -0.5, 1, 10, 10); + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(0, 0, 100, 100); + ctx.transform(1, 0.5, -0.5, 1, 10, 10); + ctx.fillStyle = 'rgb(0,0,255)'; + ctx.fillRect(0, 0, 100, 100); } - ``` - - ![](figures/zh-cn_image_0000001214623227.png) - - -### setTransform - -setTransform\(scaleX: number, skewX: number, skewY: number, scale: number, translateX: number, translateY: number\): void - -setTransfrom方法使用的参数和transform\(\)方法相同,但setTransform\(\)方法会重置现有的变换矩阵并创建新的变换矩阵。 - -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

scaleX

-

number

-

指定水平缩放值。

-

skewX

-

number

-

指定水平倾斜值。

-

skewY

-

number

-

指定垂直倾斜值。

-

scaleY

-

number

-

指定垂直缩放值。

-

translateX

-

number

-

指定水平移动值。

-

translateY

-

number

-

指定垂直移动值。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.fillStyle = 'rgb(255,0,0)'; - ctx.fillRect(0, 0, 100, 100) - ctx.setTransform(1,0.5, -0.5, 1, 10, 10); - ctx.fillStyle = 'rgb(0,0,255)'; - ctx.fillRect(0, 0, 100, 100); - } + } + ``` + + ![zh-cn_image_0000001214623227](figures/zh-cn_image_0000001214623227.png) + +### setTransform + +setTransform(scaleX: number, skewX: number, skewY: number, scale: number, translateX: number, translateY: number): void + +setTransfrom方法使用的参数和transform()方法相同,但setTransform()方法会重置现有的变换矩阵并创建新的变换矩阵。 + +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | scaleX | number | 指定水平缩放值。 | + | skewX | number | 指定水平倾斜值。 | + | skewY | number | 指定垂直倾斜值。 | + | scaleY | number | 指定垂直缩放值。 | + | translateX | number | 指定水平移动值。 | + | translateY | number | 指定垂直移动值。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillStyle = 'rgb(255,0,0)'; + ctx.fillRect(0, 0, 100, 100) + ctx.setTransform(1,0.5, -0.5, 1, 10, 10); + ctx.fillStyle = 'rgb(0,0,255)'; + ctx.fillRect(0, 0, 100, 100); } - ``` - - ![](figures/zh-cn_image_0000001168984880.png) + } + ``` + ![zh-cn_image_0000001168984880](figures/zh-cn_image_0000001168984880.png) -### translate +### translate -translate\(x: number, y: number\): void +translate(x: number, y: number): void 移动当前坐标系的原点。 -- 参数 - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

设置水平平移量。

-

y

-

number

-

设置竖直平移量。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.fillRect(10, 10, 50, 50); - ctx.translate(70, 70); - ctx.fillRect(10, 10, 50, 50); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 设置水平平移量。 | + | y | number | 设置竖直平移量。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.fillRect(10, 10, 50, 50); + ctx.translate(70, 70); + ctx.fillRect(10, 10, 50, 50); } - ``` - - ![](figures/zh-cn_image_0000001169144864.png) + } + ``` + ![zh-cn_image_0000001169144864](figures/zh-cn_image_0000001169144864.png) -### createPath2D6+ +### createPath2D6+ -createPath2D\(path: Path2D, cmds: string\): Path2D +createPath2D(path: Path2D, cmds: string): Path2D 创建一个Path2D对象。 -- 参数 - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

path

-

Path2D

-

Path2D对象。

-

cmds

-

string

-

SVG的Path描述字符串。

-
- -- 返回值 - - [Path2D对象](js-components-canvas-path2d.md) - -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var path1 = ctx.createPath2D(); - path1.moveTo(100, 100); - path1.lineTo(200, 100); - path1.lineTo(100, 200); - path1.closePath(); - ctx.stroke(path1); - var path2 = ctx.createPath2D("M150 150 L50 250 L250 250 Z"); - ctx.stroke(path2); - var path3 = ctx.createPath2D(path2); - ctx.stroke(path3); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | path | Path2D | Path2D对象。 | + | cmds | string | SVG的Path描述字符串。 | + +- 返回值 + [Path2D对象](../arkui-js/js-components-canvas-path2d.md) + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path1 = ctx.createPath2D(); + path1.moveTo(100, 100); + path1.lineTo(200, 100); + path1.lineTo(100, 200); + path1.closePath(); + ctx.stroke(path1); + var path2 = ctx.createPath2D("M150 150 L50 250 L250 250 Z"); + ctx.stroke(path2); + var path3 = ctx.createPath2D(path2); + ctx.stroke(path3); } - ``` - - ![](figures/zh-cn_image_0000001214824709.png) + } + ``` + ![zh-cn_image_0000001214824709](figures/zh-cn_image_0000001214824709.png) -### drawImage +### drawImage -drawImage\(image: Image, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number\):void +drawImage(image: Image, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number):void 进行图像绘制。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

image

-

Image

-

图片资源,请参考Image对象

-

sx

-

number

-

裁切源图像时距离源图像左上角的x坐标值。

-

sy

-

number

-

裁切源图像时距离源图像左上角的y坐标值。

-

sWidth

-

number

-

裁切源图像时需要裁切的宽度。

-

sHeight

-

number

-

裁切源图像时需要裁切的高度。

-

dx

-

number

-

绘制区域左上角在x轴的位置。

-

dy

-

number

-

绘制区域左上角在y 轴的位置。

-

dWidth

-

number

-

绘制区域的宽度。

-

dHeight

-

number

-

绘制区域的高度。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - var test = this.$element('drawImage'); - var ctx = test.getContext('2d'); - var img = new Image(); - img.src = 'common/image/test.jpg'; - ctx.drawImage(img, 50, 80, 80, 80); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | image | Image | 图片资源,请参考[Image对象](../arkui-js/js-components-canvas-image.md)。 | + | sx | number | 裁切源图像时距离源图像左上角的x坐标值。 | + | sy | number | 裁切源图像时距离源图像左上角的y坐标值。 | + | sWidth | number | 裁切源图像时需要裁切的宽度。 | + | sHeight | number | 裁切源图像时需要裁切的高度。 | + | dx | number | 绘制区域左上角在x轴的位置。 | + | dy | number | 绘制区域左上角在y 轴的位置。 | + | dWidth | number | 绘制区域的宽度。 | + | dHeight | number | 绘制区域的高度。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + var test = this.$element('drawImage'); + var ctx = test.getContext('2d'); + var img = new Image(); + img.src = 'common/image/test.jpg'; + ctx.drawImage(img, 50, 80, 80, 80); } - ``` - - ![](figures/zh-cn_image_0000001214704759.png) + } + ``` + ![zh-cn_image_0000001214704759](figures/zh-cn_image_0000001214704759.png) -### restore +### restore -restore\(\): void +restore(): void 对保存的绘图上下文进行恢复。 -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.restore(); - } +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.restore(); } - ``` - + } + ``` -### save +### save -save\(\): void +save(): void 对当前的绘图上下文进行保存。 -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.save(); - } +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.save(); } - ``` - - -### createLinearGradient6+ - -createLinearGradient\(x0: number, y0: number, x1: number, y1: number\): Object - -创建一个线性渐变色,返回CanvasGradient对象,请参考[CanvasGradient对象](js-components-canvas-canvasgradient.md)。 - -- 参数 - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x0

-

number

-

起点的x轴坐标。

-

y0

-

number

-

起点的y轴坐标。

-

x1

-

number

-

终点的x轴坐标。

-

y1

-

number

-

终点的y轴坐标。

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

Object

-

返回创建的CanvasGradient对象。

-
- -- 示例 - - ``` - -
- - -
- ``` - - ``` - // xxx.js - export default { - handleClick() { - const el = this.$refs.canvas; - const ctx = el.getContext('2d'); - // Linear gradient: start(50,0) end(300,100) - var gradient = ctx.createLinearGradient(50,0, 300,100); - // Add three color stops - gradient.addColorStop(0.0, 'red'); - gradient.addColorStop(0.5, 'white'); - gradient.addColorStop(1.0, 'green'); - // Set the fill style and draw a rectangle - ctx.fillStyle = gradient; - ctx.fillRect(0, 0, 500, 500); - } + } + ``` + +### createLinearGradient6+ + +createLinearGradient(x0: number, y0: number, x1: number, y1: number): Object + +创建一个线性渐变色,返回CanvasGradient对象,请参考[CanvasGradient对象](../arkui-js/js-components-canvas-canvasgradient.md)。 + +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x0 | number | 起点的x轴坐标。 | + | y0 | number | 起点的y轴坐标。 | + | x1 | number | 终点的x轴坐标。 | + | y1 | number | 终点的y轴坐标。 | + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | Object | 返回创建的CanvasGradient对象。 | + +- 示例 + ``` + +
+ + +
+ ``` + + ``` + // xxx.js + export default { + handleClick() { + const el = this.$refs.canvas; + const ctx = el.getContext('2d'); + // Linear gradient: start(50,0) end(300,100) + var gradient = ctx.createLinearGradient(50,0, 300,100); + // Add three color stops + gradient.addColorStop(0.0, 'red'); + gradient.addColorStop(0.5, 'white'); + gradient.addColorStop(1.0, 'green'); + // Set the fill style and draw a rectangle + ctx.fillStyle = gradient; + ctx.fillRect(0, 0, 500, 500); } - ``` - - ![](figures/zh-cn_image_0000001169303416.png) + } + ``` + ![zh-cn_image_0000001169303416](figures/zh-cn_image_0000001169303416.png) -### createRadialGradient6+ +### createRadialGradient6+ -createRadialGradient\(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number\): Object +createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): Object 创建一个径向渐变色,返回CanvasGradient对象,请参考CanvasGradient -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x0

-

number

-

起始圆的x轴坐标。

-

y0

-

number

-

起始圆的y轴坐标。

-

r0

-

number

-

起始圆的半径。必须是非负且有限的。

-

x1

-

number

-

终点圆的x轴坐标。

-

y1

-

number

-

终点圆的y轴坐标。

-

r1

-

number

-

终点圆的半径。必须为非负且有限的。

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

Object

-

返回创建的CanvasGradient对象。

-
- -- 示例 - - ``` - -
- - -
- ``` - - ``` - // xxx.js - export default { - handleClick() { - const el = this.$refs.canvas; - const ctx = el.getContext('2d'); - // Radial gradient: inner circle(200,200,r:50) outer circle(200,200,r:200) - var gradient = ctx.createRadialGradient(200,200,50, 200,200,200); - // Add three color stops - gradient.addColorStop(0.0, 'red'); - gradient.addColorStop(0.5, 'white'); - gradient.addColorStop(1.0, 'green'); - // Set the fill style and draw a rectangle - ctx.fillStyle = gradient; - ctx.fillRect(0, 0, 500, 500); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x0 | number | 起始圆的x轴坐标。 | + | y0 | number | 起始圆的y轴坐标。 | + | r0 | number | 起始圆的半径。必须是非负且有限的。 | + | x1 | number | 终点圆的x轴坐标。 | + | y1 | number | 终点圆的y轴坐标。 | + | r1 | number | 终点圆的半径。必须为非负且有限的。 | + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | Object | 返回创建的CanvasGradient对象。 | + +- 示例 + ``` + +
+ + +
+ ``` + + ``` + // xxx.js + export default { + handleClick() { + const el = this.$refs.canvas; + const ctx = el.getContext('2d'); + // Radial gradient: inner circle(200,200,r:50) outer circle(200,200,r:200) + var gradient = ctx.createRadialGradient(200,200,50, 200,200,200); + // Add three color stops + gradient.addColorStop(0.0, 'red'); + gradient.addColorStop(0.5, 'white'); + gradient.addColorStop(1.0, 'green'); + // Set the fill style and draw a rectangle + ctx.fillStyle = gradient; + ctx.fillRect(0, 0, 500, 500); } - ``` - - ![](figures/zh-cn_image_0000001169463370.png) - - -### createImageData - -createImageData\(width: number, height: number, imageData: Object\): Object - -创建新的ImageData 对象,请参考[ImageData对象](js-components-canvas-imagedata.md)。 - -- 参数 - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

width

-

number

-

ImageData的宽度。

-

height

-

number

-

ImageData的高度。

-

imagedata

-

Object

-

复制现有的ImageData对象。

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

Object

-

返回创建的ImageData对象。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - imageData = ctx.createImageData(50, 100); // Create ImageData with 50px width and 100px height - newImageData = ctx.createImageData(imageData); // Create ImageData using the input imageData - } + } + ``` + + ![zh-cn_image_0000001169463370](figures/zh-cn_image_0000001169463370.png) + +### createImageData + +createImageData(width: number, height: number, imageData: Object): Object + +创建新的ImageData 对象,请参考[ImageData对象](../arkui-js/js-components-canvas-imagedata.md)。 + +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | width | number | ImageData的宽度。 | + | height | number | ImageData的高度。 | + | imagedata | Object | 复制现有的ImageData对象。 | + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | Object | 返回创建的ImageData对象。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + imageData = ctx.createImageData(50, 100); // Create ImageData with 50px width and 100px height + newImageData = ctx.createImageData(imageData); // Create ImageData using the input imageData } - ``` - + } + ``` -### getImageData +### getImageData -getImageData\(sx: number, sy: number, sw: number, sh: number\): Object +getImageData(sx: number, sy: number, sw: number, sh: number): Object 以当前canvas指定区域内的像素创建ImageData对象。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

sx

-

number

-

需要输出的区域的左上角x坐标。

-

sy

-

number

-

需要输出的区域的左上角y坐标。

-

sw

-

number

-

需要输出的区域的宽度。

-

sh

-

number

-

需要输出的区域的高度。

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

Object

-

返回包含指定区域像素的ImageData对象。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - var test = this.$element('getImageData') - var ctx = test.getContext('2d'); - var imageData = ctx.getImageData(0, 0, 280, 300); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | sx | number | 需要输出的区域的左上角x坐标。 | + | sy | number | 需要输出的区域的左上角y坐标。 | + | sw | number | 需要输出的区域的宽度。 | + | sh | number | 需要输出的区域的高度。 | + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | Object | 返回包含指定区域像素的ImageData对象。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + var test = this.$element('getImageData') + var ctx = test.getContext('2d'); + var imageData = ctx.getImageData(0, 0, 280, 300); } - ``` - + } + ``` -### putImageData +### putImageData -putImageData\(imageData: Object, dx: number, dy: number, dirtyX: number, dirtyY: number, dirtyWidth: number, dirtyHeight: number\): void +putImageData(imageData: Object, dx: number, dy: number, dirtyX: number, dirtyY: number, dirtyWidth: number, dirtyHeight: number): void 使用ImageData数据填充新的矩形区域。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

imagedata

-

Object

-

包含像素值的ImageData对象。

-

dx

-

number

-

填充区域在x轴方向的偏移量。

-

dy

-

number

-

填充区域在y轴方向的偏移量。

-

dirtyX

-

number

-

源图像数据矩形裁切范围左上角距离源图像左上角的x轴偏移量。

-

dirtyY

-

number

-

源图像数据矩形裁切范围左上角距离源图像左上角的y轴偏移量。

-

dirtyWidth

-

number

-

源图像数据矩形裁切范围的宽度。

-

dirtyHeight

-

number

-

源图像数据矩形裁切范围的高度。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - var test = this.$element('getImageData') - var ctx = test.getContext('2d'); - var imgData = ctx.createImageData(100, 100); - for (var i = 0; i < imgData.data.length; i += 4) { - imgData.data[i + 0] = 255; - imgData.data[i + 1] = 0; - imgData.data[i + 2] = 0; - imgData.data[i + 3] = 255; - } - ctx.putImageData(imgData, 10, 10); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | imagedata | Object | 包含像素值的ImageData对象。 | + | dx | number | 填充区域在x轴方向的偏移量。 | + | dy | number | 填充区域在y轴方向的偏移量。 | + | dirtyX | number | 源图像数据矩形裁切范围左上角距离源图像左上角的x轴偏移量。 | + | dirtyY | number | 源图像数据矩形裁切范围左上角距离源图像左上角的y轴偏移量。 | + | dirtyWidth | number | 源图像数据矩形裁切范围的宽度。 | + | dirtyHeight | number | 源图像数据矩形裁切范围的高度。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + var test = this.$element('getImageData') + var ctx = test.getContext('2d'); + var imgData = ctx.createImageData(100, 100); + for (var i = 0; i < imgData.data.length; i += 4) { + imgData.data[i + 0] = 255; + imgData.data[i + 1] = 0; + imgData.data[i + 2] = 0; + imgData.data[i + 3] = 255; } - ``` - - ![](figures/zh-cn_image_0000001214463283.png) + ctx.putImageData(imgData, 10, 10); + } + } + ``` + ![zh-cn_image_0000001214463283](figures/zh-cn_image_0000001214463283.png) -### setLineDash +### setLineDash -setLineDash\(segments: Array\): void +setLineDash(segments: Array): void 设置画布的虚线样式。 -- 参数 - - - - - - - - - - - -

参数

-

类型

-

描述

-

segments

-

Array

-

作为数组用来描述线段如何交替和间距长度。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - ctx.arc(100, 75, 50, 0, 6.28); - ctx.setLineDash([10,20]); - ctx.stroke(); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | segments | Array | 作为数组用来描述线段如何交替和间距长度。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + ctx.arc(100, 75, 50, 0, 6.28); + ctx.setLineDash([10,20]); + ctx.stroke(); } - ``` - - ![](figures/zh-cn_image_0000001214623229.png) + } + ``` + ![zh-cn_image_0000001214623229](figures/zh-cn_image_0000001214623229.png) -### getLineDash +### getLineDash -getLineDash\(\): Array +getLineDash(): Array 获得当前画布的虚线样式。 -- 返回值 - - - - - - - - - -

类型

-

说明

-

Array

-

返回数组,该数组用来描述线段如何交替和间距长度。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var info = ctx.getLineDash(); - } +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | Array | 返回数组,该数组用来描述线段如何交替和间距长度。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var info = ctx.getLineDash(); } - ``` - + } + ``` -### transferFromImageBitmap7+ +### transferFromImageBitmap7+ -transferFromImageBitmap\(bitmap: ImageBitmap\): void +transferFromImageBitmap(bitmap: ImageBitmap): void 显示给定的ImageBitmap对象。 -- 参数 - - - - - - - - - - - -

参数

-

类型

-

描述

-

bitmap

-

ImageBitmap

-

待显示的ImageBitmap对象。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var canvas = this.$refs.canvas.getContext('2d'); - var offscreen = new OffscreenCanvas(500,500); - var offscreenCanvasCtx = offscreen.getContext("2d"); - offscreenCanvasCtx.fillRect(0, 0, 200, 200); - - var bitmap = offscreen.transferToImageBitmap(); - canvas.transferFromImageBitmap(bitmap); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | bitmap | ImageBitmap | 待显示的ImageBitmap对象。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var canvas = this.$refs.canvas.getContext('2d'); + var offscreen = new OffscreenCanvas(500,500); + var offscreenCanvasCtx = offscreen.getContext("2d"); + offscreenCanvasCtx.fillRect(0, 0, 200, 200); + + var bitmap = offscreen.transferToImageBitmap(); + canvas.transferFromImageBitmap(bitmap); } - ``` - - ![](figures/zh-cn_image_0000001168984882.png) - + } + ``` + ![zh-cn_image_0000001168984882](figures/zh-cn_image_0000001168984882.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-image.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-image.md index d8aba1786f5ddd8ecbca15912f4e11b643d283c1..622dd0360252037b579a424984fa8bcc89a720fa 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-image.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-image.md @@ -1,80 +1,23 @@ -# Image对象 +# Image对象 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 图片对象。 -## 属性 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

属性

-

类型

-

默认值

-

必填

-

描述

-

src

-

string

-

-

-

-

图片资源的路径。

-

width

-

<length>

-

0px

-

-

图片的宽度。

-

height

-

<length>

-

0px

-

-

图片的高度。

-

onload

-

Function

-

-

-

-

图片加载成功后触发该事件,无参数。

-

onerror

-

Function

-

-

-

-

图片加载失败后触发该事件,无参数。

-
+## 属性 + +| 属性 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| src | string | - | 是 | 图片资源的路径。 | +| width | <length> | 0px | 否 | 图片的宽度。 | +| height | <length> | 0px | 否 | 图片的高度。 | +| onload | Function | - | 否 | 图片加载成功后触发该事件,无参数。 | +| onerror | Function | - | 否 | 图片加载失败后触发该事件,无参数。 | + -## 示例 +## 示例 ``` @@ -87,7 +30,7 @@ //xxx.js export default { onShow(){ - const el =this.$refs.canvas + const el =this.$refs.canvas; var ctx =el.getContext('2d'); var img = new Image(); img.src = 'common/images/example.jpg'; @@ -102,5 +45,5 @@ export default { } ``` -![](figures/1-2.png) +![zh-cn_image_0000001198530395](figures/zh-cn_image_0000001198530395.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-imagebitmap.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-imagebitmap.md index 66e8c36f5edfe09b2b34108c4ac118f9caa09d18..cce0847efbc41c0783c5d24689fbcbc24aaad924 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-imagebitmap.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-imagebitmap.md @@ -1,34 +1,15 @@ -# ImageBitmap对象 +# ImageBitmap对象 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -ImageBitmap对象由OffscreenCanvas对象的transferToImageBitmap\(\)方法生成,存储了offscreen canvas渲染的像素数据。 -## 属性 +ImageBitmap对象由OffscreenCanvas对象的transferToImageBitmap()方法生成,存储了offscreen canvas渲染的像素数据。 - - - - - - - - - - - - - - -

属性

-

类型

-

描述

-

width

-

number

-

ImageBitmap的像素宽度。

-

height

-

number

-

ImageBitmap的像素高度。

-
+## 属性 + +| 属性 | 类型 | 描述 | +| -------- | -------- | -------- | +| width | number | ImageBitmap的像素宽度。 | +| height | number | ImageBitmap的像素高度。 | diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-imagedata.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-imagedata.md index 382c4ca9c498b4b4c21ed86342a812ab056c4c93..05ba230a16a58265f455072fba75091b737ccfdd 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-imagedata.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-imagedata.md @@ -1,42 +1,21 @@ -# ImageData对象 +# ImageData对象 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ImageData对象可以存储canvas渲染的像素数据。 -## 属性 - - - - - - - - - - - - - - - - - - -

属性

-

类型

-

描述

-

width

-

number

-

矩形区域实际像素宽度。

-

height

-

number

-

矩形区域实际像素高度。

-

data

-

<Uint8ClampedArray>

-

一维数组,保存了相应的颜色数据,数据值范围为0到255。

-
+## 属性 + +| 属性 | 类型 | 描述 | +| -------- | -------- | -------- | +| width | number | 矩形区域实际像素宽度。 | +| height | number | 矩形区域实际像素高度。 | +| data | <Uint8ClampedArray> | 一维数组,保存了相应的颜色数据,数据值范围为0到255。 | -## 示例 + +## 示例 ``` @@ -61,4 +40,3 @@ export default { } } ``` - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-offscreencanvas.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-offscreencanvas.md index 0b3f7f221330dda9bdd1b550f1ca3099816bd4e2..89277e85f4bf443312037c5f392fc624f77f6102 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-offscreencanvas.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-offscreencanvas.md @@ -1,175 +1,72 @@ -# OffscreenCanvas对象 +# OffscreenCanvas对象 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 可以离屏渲染的canvas对象。 -## 属性 - - - - - - - - - - - - - - - -

属性

-

类型

-

描述

-

width

-

number

-

offscreen canvas对象的宽度。

-

height

-

number

-

offscreen canvas对象的高度。

-
- -## 方法 - -### getContext - -getContext\(type: string, options?: CanvasRenderingContext2DSettings\): OffscreenCanvasRenderingContext2D + +## 属性 + +| 属性 | 类型 | 描述 | +| -------- | -------- | -------- | +| width | number | offscreen canvas对象的宽度。 | +| height | number | offscreen canvas对象的高度。 | + + +## 方法 + + +### getContext + +getContext(type: string, options?: CanvasRenderingContext2DSettings): OffscreenCanvasRenderingContext2D 获取offscreen canvas绘图上下文,返回值为2D绘制对象。 -- 参数 - - - - - - - - - - - - - - - - - - -

参数名

-

参数类型

-

必填

-

描述

-

contextId

-

string

-

-

仅支持 '2d'。

-

options

-

CanvasRenderingContext2DSettings

-

-

用于在离屏画布上进行绘制矩形、文本、图片等

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

OffscreenCanvasRenderingContext2D

-

2D绘制对象,用于在画布组件上绘制矩形、文本、图片等

-
- - -### toDataURL - -toDataURL\(type?: string, quality?:number\): +- 参数 + | 参数名 | 参数类型 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | + | contextId | string | 是 | 仅支持 '2d'。 | + | options | [CanvasRenderingContext2DSettings](../arkui-js/js-offscreencanvasrenderingcontext2d.md) | 否 | 用于在离屏画布上进行绘制矩形、文本、图片等。 | + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | [OffscreenCanvasRenderingContext2D](../arkui-js/js-offscreencanvasrenderingcontext2d.md) | 2D绘制对象,用于在画布组件上绘制矩形、文本、图片等。 | + + +### toDataURL + +toDataURL(type?: string, quality?:number): 生成一个包含图片展示的URL。 -- 参数 - - - - - - - - - - - - - - - - - - -

参数名

-

参数类型

-

必填

-

描述

-

type

-

string

-

-

可选参数,用于指定图像格式,默认格式为image/png。

-

quality

-

number

-

-

在指定图片格式为image/jpeg或image/webp的情况下,可以从0到1的区间内选择图片的质量。如果超出取值范围,将会使用默认值0.92。

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

string

-

图像的URL地址。

-
- - -### transferToImageBitmap - -transferToImageBitmap\(\): ImageBitmap +- 参数 + | 参数名 | 参数类型 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | + | type | string | 否 | 可选参数,用于指定图像格式,默认格式为image/png。 | + | quality | number | 否 | 在指定图片格式为image/jpeg或image/webp的情况下,可以从0到1的区间内选择图片的质量。如果超出取值范围,将会使用默认值0.92。 | -在离屏画布最近渲染的图像上创建一个ImageBitmap对象。 +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | string | 图像的URL地址。 | -- 返回值 - - - - - - - - -

类型

-

说明

-

ImageBitmap

-

存储离屏画布上渲染的像素数据。

-
+### transferToImageBitmap +transferToImageBitmap(): ImageBitmap -## 示例 +在离屏画布最近渲染的图像上创建一个ImageBitmap对象。 + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | [ImageBitmap](../arkui-js/js-components-canvas-imagebitmap.md) | 存储离屏画布上渲染的像素数据。 | + + +## 示例 ``` @@ -196,4 +93,3 @@ export default { } } ``` - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md index c2a05294bdca936607247241c14c5ae79c0926f8..d9b09a183da8c6bd7d4ef99e5a1519e4ee57057e 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-path2d.md @@ -1,796 +1,432 @@ -# Path2D对象 +# Path2D对象 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 6开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 路径对象,支持通过对象的接口进行路径的描述,并通过Canvas的stroke接口进行绘制。 -## addPath -addPath\(path: Object\): void +## addPath + +addPath(path: Object): void 将另一个路径添加到当前的路径对象中。 -- 参数 - - - - - - - - - - - -

参数

-

类型

-

描述

-

path

-

Object

-

需要添加到当前路径的路径对象

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var path1 = ctx.createPath2D("M250 150 L150 350 L350 350 Z"); - var path2 = ctx.createPath2D(); - path2.addPath(path1); - ctx.stroke(path2); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | path | Object | 需要添加到当前路径的路径对象 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path1 = ctx.createPath2D("M250 150 L150 350 L350 350 Z"); + var path2 = ctx.createPath2D(); + path2.addPath(path1); + ctx.stroke(path2); } - ``` - - ![](figures/zh-cn_image_0000001173164873.png) + } + ``` + ![zh-cn_image_0000001173164873](figures/zh-cn_image_0000001173164873.png) -## setTransform +## setTransform -setTransform\(scaleX: number, skewX: number, skewY: number, scaleY: number, translateX: number, translateY: number\): void +setTransform(scaleX: number, skewX: number, skewY: number, scaleY: number, translateX: number, translateY: number): void 设置路径变换矩阵。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

scaleX

-

number

-

x轴的缩放比例

-

skewX

-

number

-

x轴的倾斜角度

-

skewY

-

number

-

y轴的倾斜角度

-

scaleY

-

number

-

y轴的缩放比例

-

translateX

-

number

-

x轴的平移距离

-

translateY

-

number

-

y轴的平移距离

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var path = ctx.createPath2D("M250 150 L150 350 L350 350 Z"); - path.setTransform(0.8, 0, 0, 0.4, 0, 0); - ctx.stroke(path); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | scaleX | number | x轴的缩放比例 | + | skewX | number | x轴的倾斜角度 | + | skewY | number | y轴的倾斜角度 | + | scaleY | number | y轴的缩放比例 | + | translateX | number | x轴的平移距离 | + | translateY | number | y轴的平移距离 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D("M250 150 L150 350 L350 350 Z"); + path.setTransform(0.8, 0, 0, 0.4, 0, 0); + ctx.stroke(path); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001127125208.png) + ![zh-cn_image_0000001127125208](figures/zh-cn_image_0000001127125208.png) -## closePath +## closePath -closePath\(\): void +closePath(): void 将路径的当前点移回到路径的起点,当前点到起点间画一条直线。如果形状已经闭合或只有一个点,则此功能不执行任何操作。 -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var path = ctx.createPath2D(); - path.moveTo(200, 100); - path.lineTo(300, 100); - path.lineTo(200, 200); - path.closePath(); - ctx.stroke(path); - } +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.moveTo(200, 100); + path.lineTo(300, 100); + path.lineTo(200, 200); + path.closePath(); + ctx.stroke(path); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001127125202.png) + ![zh-cn_image_0000001127125202](figures/zh-cn_image_0000001127125202.png) -## moveTo +## moveTo -moveTo\(x: number, y: number\): void +moveTo(x: number, y: number): void 将路径的当前坐标点移动到目标点,移动过程中不绘制线条。 -- 参数 - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

目标点X轴坐标

-

y

-

number

-

目标点Y轴坐标

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var path = ctx.createPath2D(); - path.moveTo(50, 100); - path.lineTo(250, 100); - path.lineTo(150, 200); - path.closePath(); - ctx.stroke(path); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 目标点X轴坐标 | + | y | number | 目标点Y轴坐标 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.moveTo(50, 100); + path.lineTo(250, 100); + path.lineTo(150, 200); + path.closePath(); + ctx.stroke(path); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001173164869.png) + ![zh-cn_image_0000001173164869](figures/zh-cn_image_0000001173164869.png) -## lineTo +## lineTo -lineTo\(x: number, y: number\): void +lineTo(x: number, y: number): void 从当前点绘制一条直线到目标点。 -- 参数 - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

目标点X轴坐标

-

y

-

number

-

目标点Y轴坐标

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var path = ctx.createPath2D(); - path.moveTo(100, 100); - path.lineTo(100, 200); - path.lineTo(200, 200); - path.lineTo(200, 100); - path.closePath(); - ctx.stroke(path); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 目标点X轴坐标 | + | y | number | 目标点Y轴坐标 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.moveTo(100, 100); + path.lineTo(100, 200); + path.lineTo(200, 200); + path.lineTo(200, 100); + path.closePath(); + ctx.stroke(path); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001127285024.png) + ![zh-cn_image_0000001127285024](figures/zh-cn_image_0000001127285024.png) -## bezierCurveTo +## bezierCurveTo -bezierCurveTo\(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number\): void +bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void 创建三次贝赛尔曲线的路径。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

cp1x

-

number

-

第一个贝塞尔参数的x坐标值。

-

cp1y

-

number

-

第一个贝塞尔参数的y坐标值。

-

cp2x

-

number

-

第二个贝塞尔参数的x坐标值。

-

cp2y

-

number

-

第二个贝塞尔参数的y坐标值。

-

x

-

number

-

路径结束时的x坐标值。

-

y

-

number

-

路径结束时的y坐标值。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var path = ctx.createPath2D(); - path.moveTo(10, 10); - path.bezierCurveTo(20, 100, 200, 100, 200, 20); - ctx.stroke(path); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | cp1x | number | 第一个贝塞尔参数的x坐标值。 | + | cp1y | number | 第一个贝塞尔参数的y坐标值。 | + | cp2x | number | 第二个贝塞尔参数的x坐标值。 | + | cp2y | number | 第二个贝塞尔参数的y坐标值。 | + | x | number | 路径结束时的x坐标值。 | + | y | number | 路径结束时的y坐标值。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.moveTo(10, 10); + path.bezierCurveTo(20, 100, 200, 100, 200, 20); + ctx.stroke(path); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001173324783.png) + ![zh-cn_image_0000001173324783](figures/zh-cn_image_0000001173324783.png) -## quadraticCurveTo +## quadraticCurveTo -quadraticCurveTo\(cpx: number, cpy: number, x: number, y: number\): void +quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void 创建二次贝赛尔曲线的路径。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

cpx

-

number

-

贝塞尔参数的x坐标值。

-

cpy

-

number

-

贝塞尔参数的y坐标值。

-

x

-

number

-

路径结束时的x坐标值。

-

y

-

number

-

路径结束时的y坐标值。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var path = ctx.createPath2D(); - path.moveTo(10, 10); - path.quadraticCurveTo(100, 100, 200, 20); - ctx.stroke(path); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | cpx | number | 贝塞尔参数的x坐标值。 | + | cpy | number | 贝塞尔参数的y坐标值。 | + | x | number | 路径结束时的x坐标值。 | + | y | number | 路径结束时的y坐标值。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.moveTo(10, 10); + path.quadraticCurveTo(100, 100, 200, 20); + ctx.stroke(path); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001173164871.png) + ![zh-cn_image_0000001173164871](figures/zh-cn_image_0000001173164871.png) -## arc +## arc -arc\(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: number\): void +arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: number): void 绘制弧线路径。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

弧线圆心的x坐标值。

-

y

-

number

-

弧线圆心的y坐标值。

-

radius

-

number

-

弧线的圆半径。

-

startAngle

-

number

-

弧线的起始弧度。

-

endAngle

-

number

-

弧线的终止弧度。

-

anticlockwise

-

boolean

-

是否逆时针绘制圆弧。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var path = ctx.createPath2D(); - path.arc(100, 75, 50, 0, 6.28); - ctx.stroke(path); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 弧线圆心的x坐标值。 | + | y | number | 弧线圆心的y坐标值。 | + | radius | number | 弧线的圆半径。 | + | startAngle | number | 弧线的起始弧度。 | + | endAngle | number | 弧线的终止弧度。 | + | anticlockwise | boolean | 是否逆时针绘制圆弧。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.arc(100, 75, 50, 0, 6.28); + ctx.stroke(path); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001173164867.png) + ![zh-cn_image_0000001173164867](figures/zh-cn_image_0000001173164867.png) -## arcTo +## arcTo -arcTo\(x1: number, y1: number, x2: number, y2: number, radius: number\): void +arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void 依据圆弧经过的点和圆弧半径创建圆弧路径。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x1

-

number

-

圆弧经过的第一个点的x坐标值。

-

y1

-

number

-

圆弧经过的第一个点的y坐标值。

-

x2

-

number

-

圆弧经过的第二个点的x坐标值。

-

y2

-

number

-

圆弧经过的第二个点的y坐标值。

-

radius

-

number

-

圆弧的圆半径值。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var path = ctx.createPath2D(); - path.arcTo(150, 20, 150, 70, 50); - ctx.stroke(path); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x1 | number | 圆弧经过的第一个点的x坐标值。 | + | y1 | number | 圆弧经过的第一个点的y坐标值。 | + | x2 | number | 圆弧经过的第二个点的x坐标值。 | + | y2 | number | 圆弧经过的第二个点的y坐标值。 | + | radius | number | 圆弧的圆半径值。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.arcTo(150, 20, 150, 70, 50); + ctx.stroke(path); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001127125204.png) + ![zh-cn_image_0000001127125204](figures/zh-cn_image_0000001127125204.png) -## ellipse +## ellipse -ellipse\(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise: number\): void +ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise: number): void 在规定的矩形区域绘制一个椭圆。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

椭圆圆心的x轴坐标。

-

y

-

number

-

椭圆圆心的y轴坐标。

-

radiusX

-

number

-

椭圆x轴的半径长度。

-

radiusY

-

number

-

椭圆y轴的半径长度。

-

rotation

-

number

-

椭圆的旋转角度,单位为弧度。

-

startAngle

-

number

-

椭圆绘制的起始点角度,以弧度表示。

-

endAngle

-

number

-

椭圆绘制的结束点角度,以弧度表示。

-

anticlockwise

-

number

-

是否以逆时针方向绘制椭圆,0为顺时针,1为逆时针。(可选参数,默认为0)

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx =el.getContext('2d'); - var path = ctx.createPath2D(); - path.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, 1); - ctx.stroke(path); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 椭圆圆心的x轴坐标。 | + | y | number | 椭圆圆心的y轴坐标。 | + | radiusX | number | 椭圆x轴的半径长度。 | + | radiusY | number | 椭圆y轴的半径长度。 | + | rotation | number | 椭圆的旋转角度,单位为弧度。 | + | startAngle | number | 椭圆绘制的起始点角度,以弧度表示。 | + | endAngle | number | 椭圆绘制的结束点角度,以弧度表示。 | + | anticlockwise | number | 是否以逆时针方向绘制椭圆,0为顺时针,1为逆时针。(可选参数,默认为0) | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx =el.getContext('2d'); + var path = ctx.createPath2D(); + path.ellipse(200, 200, 50, 100, Math.PI * 0.25, Math.PI * 0.5, Math.PI, 1); + ctx.stroke(path); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001173324787.png) + ![zh-cn_image_0000001173324787](figures/zh-cn_image_0000001173324787.png) -## rect +## rect -rect\(x: number, y: number, width: number, height: number\): void +rect(x: number, y: number, width: number, height: number): void 创建矩形路径。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

描述

-

x

-

number

-

指定矩形的左上角x坐标值。

-

y

-

number

-

指定矩形的左上角y坐标值。

-

width

-

number

-

指定矩形的宽度。

-

height

-

number

-

指定矩形的高度。

-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow() { - const el =this.$refs.canvas; - const ctx = el.getContext('2d'); - var path = ctx.createPath2D(); - path.rect(20, 20, 100, 100); - ctx.stroke(path); - } +- 参数 + | 参数 | 类型 | 描述 | + | -------- | -------- | -------- | + | x | number | 指定矩形的左上角x坐标值。 | + | y | number | 指定矩形的左上角y坐标值。 | + | width | number | 指定矩形的宽度。 | + | height | number | 指定矩形的高度。 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow() { + const el =this.$refs.canvas; + const ctx = el.getContext('2d'); + var path = ctx.createPath2D(); + path.rect(20, 20, 100, 100); + ctx.stroke(path); } - ``` - - ![](figures/zh-cn_image_0000001127125212.png) - + } + ``` + ![zh-cn_image_0000001127125212](figures/zh-cn_image_0000001127125212.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas.md index 283c3b0aba8d368368f6d50565c40da31bb80326..b80397bf3c727f6826bac8db96a04cd76c5ebb0d 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas.md @@ -1,21 +1,21 @@ -# 画布组件 +# 画布组件 -- **[canvas组件](js-components-canvas-canvas.md)** -- **[CanvasRenderingContext2D对象](js-components-canvas-canvasrenderingcontext2d.md)** -- **[Image对象](js-components-canvas-image.md)** +- **[canvas组件](js-components-canvas-canvas.md)** -- **[CanvasGradient对象](js-components-canvas-canvasgradient.md)** +- **[CanvasRenderingContext2D对象](js-components-canvas-canvasrenderingcontext2d.md)** -- **[ImageData对象](js-components-canvas-imagedata.md)** +- **[Image对象](js-components-canvas-image.md)** -- **[Path2D对象](js-components-canvas-path2d.md)** +- **[CanvasGradient对象](js-components-canvas-canvasgradient.md)** -- **[ImageBitmap对象](js-components-canvas-imagebitmap.md)** +- **[ImageData对象](js-components-canvas-imagedata.md)** -- **[OffscreenCanvas对象](js-components-canvas-offscreencanvas.md)** +- **[Path2D对象](js-components-canvas-path2d.md)** -- **[OffscreenCanvasRenderingContext2D对象](js-offscreencanvasrenderingcontext2d.md)** +- **[ImageBitmap对象](js-components-canvas-imagebitmap.md)** +- **[OffscreenCanvas对象](js-components-canvas-offscreencanvas.md)** +- **[OffscreenCanvasRenderingContext2D对象](js-offscreencanvasrenderingcontext2d.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md index b9cc5bcd41a999b9d0746e19727f5915306022ac..b2e6324e549b96753d7e7a215684035823d47bb8 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md @@ -1,380 +1,65 @@ -# 动画样式 +# 动画样式 -组件支持动态的旋转、平移、缩放效果,可在style或css中设置。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

描述

-

transform-origin

-

string6+ | <percentage> | <length> string6+ | <percentage> | <length>

-

center center

-

变换对象的原点位置,支持px和百分比(相对于动画目标组件),如果仅设置一个值,另一个值为50%,第一个string的可选值为:left | center | right ,第二个string的可选值为:top | center | bottom。

-

示例:

-

transform-origin: 200px 30%。

-

transform-origin: 100px top。

-

transform-origin: center center。

-

transform

-

string

-

-

-

支持同时设置平移/旋转/缩放的属性。

-

详见表1

-

animation6+

-

string

-

0s ease 0s 1 normal none running none

-

格式:duration | timing-function | delay | iteration-count | direction | fill-mode | play-state | name,每个字段不区分先后,但是 duration / delay 按照出现的先后顺序解析。

-

animation-name

-

string

-

-

-

指定@keyframes,详见表2

-

animation-delay

-

<time>

-

0

-

定义动画播放的延迟时间。支持的单位为[s(秒)|ms(毫秒) ],默认单位为ms,格式为:1000ms或1s。

-

animation-duration

-

<time>

-

0

-

定义一个动画周期。支持的单位为[s(秒)|ms(毫秒) ],默认单位为ms,格式为:1000ms或1s。

-
说明:

animation-duration 样式必须设置,否则时长为 0,则不会播放动画。

-
-

animation-iteration-count

-

number | infinite

-

1

-

定义动画播放的次数,默认播放一次,可通过设置为infinite无限次播放。

-

animation-timing-function

-

string

-

ease

-

描述动画执行的速度曲线,用于使动画更为平滑。

-

可选项有:

-
  • linear:表示动画从头到尾的速度都是相同的。
  • ease:表示动画以低速开始,然后加快,在结束前变慢,cubic-bezier(0.25, 0.1, 0.25, 1.0)。
  • ease-in:表示动画以低速开始,cubic-bezier(0.42, 0.0, 1.0, 1.0)。
  • ease-out:表示动画以低速结束,cubic-bezier(0.0, 0.0, 0.58, 1.0)。
  • ease-in-out:表示动画以低速开始和结束,cubic-bezier(0.42, 0.0, 0.58, 1.0)。
  • friction:阻尼曲线,cubic-bezier(0.2, 0.0, 0.2, 1.0)。
  • extreme-deceleration:急缓曲线,cubic-bezier(0.0, 0.0, 0.0, 1.0)。
  • sharp:锐利曲线,cubic-bezier(0.33, 0.0, 0.67, 1.0)。
  • rhythm:节奏曲线,cubic-bezier(0.7, 0.0, 0.2, 1.0)。
  • smooth:平滑曲线,cubic-bezier(0.4, 0.0, 0.4, 1.0)。
  • cubic-bezier:在三次贝塞尔函数中定义动画变化过程,入参的x和y值必须处于0-1之间。
  • steps: 阶梯曲线6+。语法:steps(number[, end|start]);number必须设置,支持的类型为正整数。第二个参数可选,表示在每个间隔的起点或是终点发生阶跃变化,支持设置end或start,默认值为end。
-

animation-direction6+

-

string

-

normal

-

指定动画的播放模式:

-
  • normal: 动画正向循环播放。
  • reverse: 动画反向循环播放。
  • alternate:动画交替循环播放,奇数次正向播放,偶数次反向播放。
  • alternate-reverse:动画反向交替循环播放,奇数次反向播放,偶数次正向播放。
-

animation-fill-mode

-

string

-

none

-

指定动画开始和结束的状态:

-
  • none:在动画执行之前和之后都不会应用任何样式到目标上。
  • forwards:在动画结束后,目标将保留动画结束时的状态(在最后一个关键帧中定义)。
  • backwards6+:动画将在animation-delay期间应用第一个关键帧中定义的值。当animation-direction为"normal"或"alternate"时应用from关键帧中的值,当animation-direction为"reverse"或"alternate-reverse"时应用to关键帧中的值。
  • both6+:动画将遵循forwards和backwards的规则,从而在两个方向上扩展动画属性。
-

animation-play-state6+

-

string

-

running

-

指定动画的当前状态:

-
  • paused:动画状态为暂停。
  • running:动画状态为播放。
-

transition6+

-

string

-

all 0 ease 0

-

指定组件状态切换时的过渡效果,可以通过transition属性设置如下四个属性:

-
  • transition-property:规定设置过渡效果的 CSS 属性的名称,目前支持宽、高、背景色。
  • transition-duration:规定完成过渡效果需要的时间,单位秒。
  • transition-timing-function:规定过渡效果的时间曲线,支持样式动画提供的曲线。
  • transition-delay:规定过渡效果延时启动时间,单位秒。
-
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -**表 1** transform操作说明 +组件支持动态的旋转、平移、缩放效果,可在style或css中设置。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

描述

-

none6+

-

-

-

不进行任何转换。

-

matrix6+

-

<number>

-

入参为六个值的矩阵,6个值分别代表:scaleX, skewY, skewX, scaleY, translateX, translateY。

-

matrix3d6+

-

<number>

-

入参为十六个值的4X4矩阵。

-

translate

-

<length>| <percent>

-

平移动画属性,支持设置x轴和y轴两个维度的平移参数。

-

translate3d6+

-

<length>| <percent>

-

三个入参,分别代表X轴、Y轴、Z轴的平移距离。

-

translateX

-

<length>| <percent>

-

X轴方向平移动画属性。

-

translateY

-

<length>| <percent>

-

Y轴方向平移动画属性。

-

translateZ6+

-

<length>| <percent>

-

Z轴的平移距离。

-

scale

-

<number>

-

缩放动画属性,支持设置x轴和y轴两个维度的缩放参数。

-

scale3d6+

-

<number>

-

三个入参,分别代表X轴、Y轴、Z轴的缩放参数。

-

scaleX

-

<number>

-

X轴方向缩放动画属性。

-

scaleY

-

<number>

-

Y轴方向缩放动画属性。

-

scaleZ6+

-

<number>

-

Z轴的缩放参数。

-

rotate

-

<deg> | <rad> | <grad>6+ | <turn>6+

-

旋转动画属性,支持设置x轴和y轴两个维度的选中参数。

-

rotate3d6+

-

<deg> | <rad> | <grad> | <turn>

-

四个入参,前三个分别为X轴、Y轴、Z轴的旋转向量,第四个是旋转角度。

-

rotateX

-

<deg> | <rad> | <grad>6+ | <turn>6+

-

X轴方向旋转动画属性。

-

rotateY

-

<deg> | <rad> | <grad>6+ | <turn>6+

-

Y轴方向旋转动画属性。

-

rotateZ6+

-

<deg> | <rad> | <grad> | <turn>

-

Z轴方向的旋转角度。

-

skew6+

-

<deg> | <rad> | <grad> | <turn>

-

两个入参,分别为X轴和Y轴的2D倾斜角度。

-

skewX6+

-

<deg> | <rad> | <grad> | <turn>

-

X轴的2D倾斜角度。

-

skewY6+

-

<deg> | <rad> | <grad> | <turn>

-

Y轴的2D倾斜角度。

-

perspective6+

-

<number>

-

3D透视场景下镜头距离元素表面的距离。

-
-**表 2** @keyframes属性说明 +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| transform-origin | string6+ \| <percentage> \| <length> string6+ \| <percentage> \| <length> | center center | 变换对象的原点位置,支持px和百分比(相对于动画目标组件),如果仅设置一个值,另一个值为50%,第一个string的可选值为:left \| center \| right ,第二个string的可选值为:top \| center \| bottom。
示例:
transform-origin: 200px 30%。
transform-origin: 100px top。
transform-origin: center center。 | +| transform | string | - | 支持同时设置平移/旋转/缩放的属性。
详见表 transform操作说明。 | +| animation6+ | string | 0s ease 0s 1 normal none running none | 格式:duration \| timing-function \| delay \| iteration-count \| direction \| fill-mode \| play-state \| name,每个字段不区分先后,但是 duration / delay 按照出现的先后顺序解析。 | +| animation-name | string | - | 指定\@keyframes,详见表 @keyframes属性说明。 | +| animation-delay | <time> | 0 | 定义动画播放的延迟时间。支持的单位为[s(秒)\|ms(毫秒) ],默认单位为ms,格式为:1000ms或1s。 | +| animation-duration | <time> | 0 | 定义一个动画周期。支持的单位为[s(秒)\|ms(毫秒) ],默认单位为ms,格式为:1000ms或1s。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> animation-duration 样式必须设置,否则时长为 0,则不会播放动画。 | +| animation-iteration-count | number  \| infinite | 1 | 定义动画播放的次数,默认播放一次,可通过设置为infinite无限次播放。 | +| animation-timing-function | string | ease
| 描述动画执行的速度曲线,用于使动画更为平滑。
可选项有:
- linear:表示动画从头到尾的速度都是相同的。
- ease:表示动画以低速开始,然后加快,在结束前变慢,cubic-bezier(0.25, 0.1, 0.25, 1.0)。
- ease-in:表示动画以低速开始,cubic-bezier(0.42, 0.0, 1.0, 1.0)。
- ease-out:表示动画以低速结束,cubic-bezier(0.0, 0.0, 0.58, 1.0)。
- ease-in-out:表示动画以低速开始和结束,cubic-bezier(0.42, 0.0, 0.58, 1.0)。
- friction:阻尼曲线,cubic-bezier(0.2, 0.0, 0.2, 1.0)。
- extreme-deceleration:急缓曲线,cubic-bezier(0.0, 0.0, 0.0, 1.0)。
- sharp:锐利曲线,cubic-bezier(0.33, 0.0, 0.67, 1.0)。
- rhythm:节奏曲线,cubic-bezier(0.7, 0.0, 0.2, 1.0)。
- smooth:平滑曲线,cubic-bezier(0.4, 0.0, 0.4, 1.0)。
- cubic-bezier:在三次贝塞尔函数中定义动画变化过程,入参的x和y值必须处于0-1之间。
- steps: 阶梯曲线6+。语法:steps(number[, end\|start]);number必须设置,支持的类型为正整数。第二个参数可选,表示在每个间隔的起点或是终点发生阶跃变化,支持设置end或start,默认值为end。 | +| animation-direction6+ | string | normal | 指定动画的播放模式:
- normal: 动画正向循环播放。
- reverse: 动画反向循环播放。
- alternate:动画交替循环播放,奇数次正向播放,偶数次反向播放。
- alternate-reverse:动画反向交替循环播放,奇数次反向播放,偶数次正向播放。 | +| animation-fill-mode | string | none | 指定动画开始和结束的状态:
- none:在动画执行之前和之后都不会应用任何样式到目标上。
- forwards:在动画结束后,目标将保留动画结束时的状态(在最后一个关键帧中定义)。
- backwards6+:动画将在animation-delay期间应用第一个关键帧中定义的值。当animation-direction为"normal"或"alternate"时应用from关键帧中的值,当animation-direction为"reverse"或"alternate-reverse"时应用to关键帧中的值。
- both6+:动画将遵循forwards和backwards的规则,从而在两个方向上扩展动画属性。 | +| animation-play-state6+ | string | running | 指定动画的当前状态:
- paused:动画状态为暂停。
- running:动画状态为播放。 | +| transition6+ | string | all 0 ease 0 | 指定组件状态切换时的过渡效果,可以通过transition属性设置如下四个属性:
- transition-property:规定设置过渡效果的 CSS 属性的名称,目前支持宽、高、背景色。
- transition-duration:规定完成过渡效果需要的时间,单位秒。
- transition-timing-function:规定过渡效果的时间曲线,支持样式动画提供的曲线。
- transition-delay:规定过渡效果延时启动时间,单位秒。 | + + +**表1** transform操作说明 + +| 名称 | 类型 | 描述 | +| -------- | -------- | -------- | +| none6+ | - | 不进行任何转换。 | +| matrix6+ | <number> | 入参为六个值的矩阵,6个值分别代表:scaleX, skewY, skewX, scaleY, translateX, translateY。 | +| matrix3d6+ | <number> | 入参为十六个值的4X4矩阵。 | +| translate | <length>\| <percent> | 平移动画属性,支持设置x轴和y轴两个维度的平移参数。 | +| translate3d6+ | <length>\| <percent> | 三个入参,分别代表X轴、Y轴、Z轴的平移距离。 | +| translateX | <length>\| <percent> | X轴方向平移动画属性。 | +| translateY | <length>\| <percent> | Y轴方向平移动画属性。 | +| translateZ6+ | <length>\| <percent> | Z轴的平移距离。 | +| scale | <number> | 缩放动画属性,支持设置x轴和y轴两个维度的缩放参数。 | +| scale3d6+ | <number> | 三个入参,分别代表X轴、Y轴、Z轴的缩放参数。 | +| scaleX | <number> | X轴方向缩放动画属性。 | +| scaleY | <number> | Y轴方向缩放动画属性。 | +| scaleZ6+ | <number> | Z轴的缩放参数。 | +| rotate | <deg> \| <rad> \| <grad>6+ \| <turn>6+ | 旋转动画属性,支持设置x轴和y轴两个维度的选中参数。 | +| rotate3d6+ | <deg> \| <rad> \| <grad> \| <turn> | 四个入参,前三个分别为X轴、Y轴、Z轴的旋转向量,第四个是旋转角度。 | +| rotateX | <deg> \| <rad> \| <grad>6+ \| <turn>6+ | X轴方向旋转动画属性。 | +| rotateY | <deg> \| <rad> \| <grad>6+ \| <turn>6+ | Y轴方向旋转动画属性。 | +| rotateZ6+ | <deg> \| <rad> \| <grad> \| <turn> | Z轴方向的旋转角度。 | +| skew6+ | <deg> \| <rad> \| <grad> \| <turn> | 两个入参,分别为X轴和Y轴的2D倾斜角度。 | +| skewX6+ | <deg> \| <rad> \| <grad> \| <turn> | X轴的2D倾斜角度。 | +| skewY6+ | <deg> \| <rad> \| <grad> \| <turn> | Y轴的2D倾斜角度。 | +| perspective6+ | <number> | 3D透视场景下镜头距离元素表面的距离。 | + +**表2** @keyframes属性说明 + +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| background-color | <color> | - | 动画执行后应用到组件上的背景颜色。 | +| opacity | number | 1 | 动画执行后应用到组件上的不透明度值,为介于0到1间的数值,默认为1。 | +| width | <length> | - | 动画执行后应用到组件上的宽度值。 | +| height | <length> | - | 动画执行后应用到组件上的高度值。 | +| transform | string | - | 定义应用在组件上的变换类型,见表 transform操作说明。 | +| background-position6+ | string \| <percentage> \| <length> string \| <percentage> \| <length> | 50% 50% | 背景图位置。单位支持百分比和px,第一个值是水平位置,第二个值是垂直位置。如果仅设置一个值,另一个值为50%。第一个string的可选值为:left \| center \| right ,第二个string的可选值为:top \| center \| bottom。
示例:
- background-position: 200px 30%
- background-position: 100px top
- background-position: center center | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

描述

-

background-color

-

<color>

-

-

-

动画执行后应用到组件上的背景颜色。

-

opacity

-

number

-

1

-

动画执行后应用到组件上的不透明度值,为介于0到1间的数值,默认为1。

-

width

-

<length>

-

-

-

动画执行后应用到组件上的宽度值。

-

height

-

<length>

-

-

-

动画执行后应用到组件上的高度值。

-

transform

-

string

-

-

-

定义应用在组件上的变换类型,见表1

-

background-position6+

-

string | <percentage> | <length> string | <percentage> | <length>

-

50% 50%

-

背景图位置。单位支持百分比和px,第一个值是水平位置,第二个值是垂直位置。如果仅设置一个值,另一个值为50%。第一个string的可选值为:left | center | right ,第二个string的可选值为:top | center | bottom。

-

示例:

-
  • background-position: 200px 30%
  • background-position: 100px top
  • background-position: center center
-
对于不支持起始值或终止值缺省的情况,可以通过from和to显示指定起始和结束。可以通过百分比指定动画运行的中间状态6+。示例: @@ -403,11 +88,11 @@ background-color: #f76160; transform:translate(100px) rotate(0deg) scale(1.0); } - /* 可以通过百分比指定动画运行的中间状态6+ */ - 50% { - background-color: #f76160; - transform:translate(100px) rotate(60deg) scale(1.3); - } + /* 可以通过百分比指定动画运行的中间状态 */ + 50% { + background-color: \#f76160; + transform:translate(100px) rotate(60deg) scale(1.3); + } to { background-color: #09ba07; transform:translate(100px) rotate(180deg) scale(2.0); @@ -415,7 +100,8 @@ } ``` -![](figures/zh-cn_image_0000001173324797.gif) + +![zh-cn_image_0000001173324797](figures/zh-cn_image_0000001173324797.gif) ``` @@ -463,7 +149,8 @@ export default { } ``` -![](figures/zh-cn_image_0000001127285034.gif) + +![zh-cn_image_0000001127285034](figures/zh-cn_image_0000001127285034.gif) ``` @@ -521,10 +208,13 @@ export default { } ``` -![](figures/zh-cn_image_0000001152833768.gif) ->![](../../public_sys-resources/icon-note.gif) **说明:** ->@keyframes的from/to不支持动态绑定。 ->steps函数的end和start含义如下图所示。 ->![](figures/zh-cn_image_0000001127125220.png) +![zh-cn_image_0000001152833768](figures/zh-cn_image_0000001152833768.gif) + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> @keyframes的from/to不支持动态绑定。 +> +> steps函数的end和start含义如下图所示。 +> +> ![zh-cn_image_0000001127125220](figures/zh-cn_image_0000001127125220.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-atomic-layout.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-atomic-layout.md index 2e943c6b5d3e59aedefa2411a635905a4125c806..bd9563e724fdd5b5c42c5774ccf6d1168f0f465e 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-atomic-layout.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-atomic-layout.md @@ -1,84 +1,33 @@ -# 原子布局 +# 原子布局 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 在屏幕形态和规格不同等情况下,布局效果需要实现自适应,因此系统提供了面向不同屏幕尺寸界面自适应适配的布局能力,称为原子布局。设计师可以考虑使用原子能力,定义元素在不同形态的尺寸界面上体现的自适应规则。开发者可以使用原子布局能力,快速实现让应用在多形态屏幕上有与设计效果相匹配的自适应效果。 -## 隐藏能力 + +## 隐藏能力 在非折行flex布局基础上,增加了显示优先级标记,可以调整组件内元素水平/垂直方向的显示优先级,根据当前组件容器的可用空间来显示内容。 - - - - - - - - - - - - -

样式

-

类型

-

默认值

-

说明

-

display-index

-

number

-

0

-

适用于div等支持flex布局的容器组件中的子组件上,当容器组件在flex主轴上尺寸不足以显示全部内容时,按照display-index值从小到大的顺序进行隐藏,具有相同display-index值的组件同时隐藏,默认值为0,表示隐藏。

-
+| 样式 | 类型 | 默认值 | 说明 | +| -------- | -------- | -------- | -------- | +| display-index | number | 0 | 适用于div等支持flex布局的容器组件中的子组件上,当容器组件在flex主轴上尺寸不足以显示全部内容时,按照display-index值从小到大的顺序进行隐藏,具有相同display-index值的组件同时隐藏,默认值为0,表示隐藏。 | + -## 占比能力 +## 占比能力 在非折行的flex布局中,定义了占比能力的组件,保证指定元素始终在容器的某一个比例空间中进行布局。 - - - - - - - - - - - - -

样式

-

类型

-

默认值

-

说明

-

flex-weight

-

number

-

-

-

指明当前元素在flex主轴方向上尺寸权值,当且仅当容器组件中所有节点均设置此属性时生效,当前元素尺寸为: 容器主轴尺寸 * 当前权值 / 所有子元素权值和。

-
+| 样式 | 类型 | 默认值 | 说明 | +| -------- | -------- | -------- | -------- | +| flex-weight | number | - | 指明当前元素在flex主轴方向上尺寸权值。如果容器组件中所有节点均设置此属性,当前元素尺寸为: 容器主轴尺寸 \* 当前权值 / 所有子元素权值和。如果容器组件中某几个节点设置此属性,则容器会对其他未设置此属性的节点进行布局,再将剩余空间分配给设置了此属性的节点。设置了此属性的节点的尺寸为:容器剩余空间 \* 该元素权值 / 所有子元素权值和。 | -## 固定比例 -定义了组件固定比例调整尺寸的能力。 +## 固定比例 - - - - - - - - - - - - -

样式

-

类型

-

默认值

-

说明

-

aspect-ratio

-

number

-

-

-

1. 接受任意大于0的浮点值,定义为该节点的宽度与高度比,设置该属性后,该元素尺寸宽高比按照此属性值进行调整。

-

2. 遵守最大值与最小值的限制。

-

3. 在flex布局中,主轴尺寸先进行调整,后根据该尺寸调整交叉轴。

-
+定义了组件固定比例调整尺寸的能力。 +| 样式 | 类型 | 默认值 | 说明 | +| -------- | -------- | -------- | -------- | +| aspect-ratio | number | - | 1. 接受任意大于0的浮点值,定义为该节点的宽度与高度比,设置该属性后,该元素尺寸宽高比按照此属性值进行调整。
2. 遵守最大值与最小值的限制。
3. 在flex布局中,主轴尺寸先进行调整,后根据该尺寸调整交叉轴。 | diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-attributes.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-attributes.md index b5f1d04e26d2ebae7568c57049ea7260a78b2c7f..bb3542a30dcbe465fe29cde00d44cd7eff8c71f3 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-attributes.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-attributes.md @@ -1,173 +1,34 @@ -# 通用属性 +# 通用属性 -## 常规属性 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +## 常规属性 常规属性指的是组件普遍支持的用来设置组件基本标识和外观显示特征的属性。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

style

-

string

-

-

-

-

组件的样式声明。

-

class

-

string

-

-

-

-

组件的样式类,用于引用样式表。

-

ref

-

string

-

-

-

-

用来指定指向子元素或子组件的引用信息,该引用将注册到父组件的$refs 属性对象上。

-

disabled

-

boolean

-

false

-

-

当前组件是否被禁用,在禁用场景下,组件将无法响应用户交互。

-

data

-

string

-

-

-

-

给当前组件设置data属性,进行相应的数据存储和读取。JS文件中:

-
  • 在事件回调中使用 e.target.attr.data 读取数据,e为事件回调函数入参。
  • 使用$element或者$refs获取DOM元素后,通过attr.data 进行访问。
-
说明:

从API Version 6 开始,建议使用data-*。

-
-

data-*6+

-

string

-

-

-

-

给当前组件设置data-*属性,进行相应的数据存储和读取。大小写不敏感,如data-A和data-a默认相同。JS文件中:

-
  • 在事件回调中使用 e.target.dataSet.a读取数据,e为事件回调函数入参。
  • 使用$element或者$refs获取DOM元素后,通过dataSet.a进行访问。
-

click-effect5+

-

string

-

-

-

-

通过这个属性可以设置组件的弹性点击效果,当前支持如下三种效果:

-
  • spring-small:建议小面积组件设置,缩放(90%)。
  • spring-medium:建议中面积组件设置,缩放(95%)。
  • spring-large:建议大面积组件设置,缩放(95%)。
-

dir6+

-

string

-

auto

-

-

设置元素布局模式,支持设置rtl、ltr和auto三种属性值:

-
  • rtl:使用从右往左布局模式。
  • ltr:使用从左往右布局模式。
  • auto:跟随系统语言环境。
-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| style | string | - | 否 | 组件的样式声明。 | +| class | string | - | 否 | 组件的样式类,用于引用样式表。 | +| ref | string | - | 否 | 用来指定指向子元素或子组件的引用信息,该引用将注册到父组件的$refs 属性对象上。 | +| disabled | boolean | false | 否 | 当前组件是否被禁用,在禁用场景下,组件将无法响应用户交互。 | +| data | string | - | 否 | 给当前组件设置data属性,进行相应的数据存储和读取。JS文件中:
- 在事件回调中使用 e.target.attr.data 读取数据,e为事件回调函数入参。
- 使用$element或者$refs获取DOM元素后,通过attr.data 进行访问。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 从API Version 6 开始,建议使用data-\*。 | +| data-\*6+ | string | - | 否 | 给当前组件设置data-\*属性,进行相应的数据存储和读取。大小写不敏感,如data-A和data-a默认相同。JS文件中:
- 在事件回调中使用 e.target.dataSet.a读取数据,e为事件回调函数入参。
- 使用$element或者$refs获取DOM元素后,通过dataSet.a进行访问。 | +| click-effect5+ | string | - | 否 | 通过这个属性可以设置组件的弹性点击效果,当前支持如下三种效果:
- spring-small:建议小面积组件设置,缩放(90%)。
- spring-medium:建议中面积组件设置,缩放(95%)。
- spring-large:建议大面积组件设置,缩放(95%)。 | +| dir6+ | string | auto | 否 | 设置元素布局模式,支持设置rtl、ltr和auto三种属性值:
- rtl:使用从右往左布局模式。
- ltr:使用从左往右布局模式。
- auto:跟随系统语言环境。 | -## 渲染属性 -组件普遍支持的用来设置组件是否渲染的属性。 +## 渲染属性 - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

描述

-

for

-

Array

-

-

-

根据设置的数据列表,展开当前元素。

-

if

-

boolean

-

-

-

根据设置的boolean值,添加或移除当前元素。

-

show

-

boolean

-

-

-

根据设置的boolean值,显示或隐藏当前元素。

-
+组件普遍支持的用来设置组件是否渲染的属性。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->属性和样式不能混用,不能在属性字段中进行样式设置。 +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| for | Array | - | 根据设置的数据列表,展开当前元素。 | +| if | boolean | - | 根据设置的boolean值,添加或移除当前元素。 | +| show | boolean | - | 根据设置的boolean值,显示或隐藏当前元素。 | +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 属性和样式不能混用,不能在属性字段中进行样式设置。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-customizing-font.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-customizing-font.md index 1c8e89bc24595236acfa859c7e8abe19d00a6c57..e20ad7ff244b25b122747588495b00f17de9dcc6 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-customizing-font.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-customizing-font.md @@ -1,10 +1,15 @@ -# 自定义字体样式 +# 自定义字体样式 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 font-face用于定义字体样式。应用可以在style中定义font-face来指定相应的字体名和字体资源,然后在font-family样式中引用该字体。 + 自定义字体可以是从项目中的字体文件中加载的字体,字体格式支持ttf和otf。 -## 定义font-face + +## 定义font-face ``` @font-face { @@ -21,18 +26,18 @@ font-face用于定义字体样式。应用可以在style中定义font-face来指 自定义字体的来源,支持如下类别: -- 项目中的字体文件:通过url指定项目中的字体文件路径\(只支持绝对路径,详见[资源和文件访问规则](../../ui/js-framework-file.md)章节\)。 +- 项目中的字体文件:通过url指定项目中的字体文件路径(只支持绝对路径,详见[资源和文件访问规则](../../ui/js-framework-file.md)章节)。 -- 不支持设置多个src。 +- 不支持设置多个src。 -## 使用font-face + +## 使用font-face 可以在style中定义font-face,然后在font-family样式中指定该font-face的名称,从而应用font-face定义的字体。 **示例:** 页面布局: - ```
测试自定义字体 @@ -50,4 +55,3 @@ font-face用于定义字体样式。应用可以在style中定义font-face来指 font-family: HWfont; } ``` - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-events.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-events.md index 140f2a5aae21d94ab064d9bf9935df5fa89987d4..973948bf46b9df774fb2db3fe1ee0b54e86042e7 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-events.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-events.md @@ -1,462 +1,104 @@ -# 通用事件 +# 通用事件 -## 事件说明 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -- 事件绑定在组件上,当组件达到事件触发条件时,会执行JS中对应的事件回调函数,实现页面UI视图和页面JS逻辑层的交互; -- 事件回调函数中通过参数可以携带额外的信息,如组件上的数据对象dataset,事件特有的回调参数。 +## 事件说明 -相对于私有事件,大部分组件都可以绑定如下事件。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

是否支持冒泡

-

touchstart

-

TouchEvent

-

手指刚触摸屏幕时触发该事件。

-

5+

-

touchmove

-

TouchEvent

-

手指触摸屏幕后移动时触发该事件。

-

5+

-

touchcancel

-

TouchEvent

-

手指触摸屏幕中动作被打断时触发该事件。

-

5+

-

touchend

-

TouchEvent

-

手指触摸结束离开屏幕时触发该事件。

-

5+

-

click

-

-

-

点击动作触发该事件。

-

6+

-

doubleclick7+

-
  

双击动作触发该事件

-

-

longpress

-

-

-

长按动作触发该事件。

-

-

swipe5+

-

SwipeEvent

-

组件上快速滑动后触发该事件。

-

-

attached6+

-

-

-

当前组件节点挂载在渲染树后触发。

-

-

detached6+

-

-

-

当前组件节点从渲染树中移除后触发。

-

-

pinchstart7+

-

PinchEvent

-

手指开始执行捏合操作时触发该事件。

-

-

pinchupdate7+

-

PinchEvent

-

手指执行捏合操作过程中触发该事件。

-

-

pinchend7+

-

PinchEvent

-

手指捏合操作结束离开屏幕时触发该事件。

-

-

pinchcancel7+

-

PinchEvent

-

手指捏合操作被打断时触发该事件。

-

-

dragstart7+

-

DragEvent

-

用户开始拖拽时触发该事件。

-

-

drag7+

-

DragEvent

-

拖拽过程中触发该事件。

-

-

dragend7+

-

DragEvent

-

用户拖拽完成后触发。

-

-

dragenter7+

-

DragEvent

-

进入释放目标时触发该事件。

-

-

dragover7+

-

DragEvent

-

在释放目标内拖动时触发。

-

-

dragleave7+

-

DragEvent

-

离开释放目标区域时触发。

-

-

drop7+

-

DragEvent

-

在可释放目标区域内释放时触发。

-

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->除上述事件外,其他事件均为非冒泡事件,如[input的change事件](js-components-basic-input.md#section1721512551218),详见各个组件。 - -**表 1** BaseEvent对象属性列表 - - - - - - - - - - - - - - - -

属性

-

类型

-

说明

-

type

-

string

-

当前事件的类型,比如click、longpress等。

-

timestamp

-

number

-

该事件触发时的时间戳。

-
- -**表 2** TouchEvent对象属性列表\(继承BaseEvent\) - - - - - - - - - - - - - - - - -

属性

-

类型

-

说明

-

touches

-

Array<TouchInfo>

-

触摸事件时的属性集合,包含屏幕触摸点的信息数组。

-

changedTouches

-

Array<TouchInfo>

-

触摸事件时的属性集合,包括产生变化的屏幕触摸点的信息数组。数据格式和touches一样。该属性表示有变化的触摸点,如从无变有,位置变化,从有变无。例如用户手指刚接触屏幕时,touches数组中有数据,但changedTouches无数据。

-
+- 事件绑定在组件上,当组件达到事件触发条件时,会执行JS中对应的事件回调函数,实现页面UI视图和页面JS逻辑层的交互; -**表 3** TouchInfo +- 事件回调函数中通过参数可以携带额外的信息,如组件上的数据对象dataset,事件特有的回调参数。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

属性

-

类型

-

说明

-

globalX

-

number

-

距离屏幕左上角(不包括状态栏)横向距离。屏幕的左上角为原点。

-

globalY

-

number

-

距离屏幕左上角(不包括状态栏)纵向距离。屏幕的左上角为原点。

-

localX

-

number

-

距离被触摸组件左上角横向距离。组件的左上角为原点。

-

localY

-

number

-

距离被触摸组件左上角纵向距离。组件的左上角为原点。

-

size

-

number

-

触摸接触面积。

-

force6+

-

number

-

接触力信息。

-

identifier8+

-

number

-

接触点标识信息,表示接触表面与触摸点的唯一标识值,手指在屏幕表面上移动触发的每个事件中该值不变。

-
-**表 4** SwipeEvent 基础事件对象属性列表(继承BaseEvent) - - - - - - - - - - - - - - - - -

属性

-

类型

-

说明

-

direction

-

string

-

滑动方向,可能值有:

-
  1. left:向左滑动;
  2. right:向右滑动;
  3. up:向上滑动;
  4. down:向下滑动。
-

distance6+

-

number

-

在滑动方向上的滑动距离。

-
- -**表 5** PinchEvent 对象属性列表7+ - - - - - - - - - - - - - - - - - - - - -

属性

-

类型

-

说明

-

scale

-

number

-

缩放比例

-

pinchCenterX

-

number

-

捏合中心点X轴坐标,单位px

-

pinchCenterY

-

number

-

捏合中心点Y轴坐标,单位px

-
- -**表 6** DragEvent对象属性列表\(继承BaseEvent\)7+ +相对于私有事件,大部分组件都可以绑定如下事件。 - - - - - - - - - - - - - - - - - - - - - - - -

属性

-

类型

-

说明

-

type

-

string

-

事件名称。

-

globalX

-

number

-

距离屏幕左上角坐标原点横向距离。

-

globalY

-

number

-

距离屏幕左上角坐标原点纵向距离。

-

timestamp

-

number

-

时间戳。

-
-## 事件对象 +| 名称 | 参数 | 描述 | 是否支持冒泡 | +| -------- | -------- | -------- | -------- | +| touchstart | TouchEvent | 手指刚触摸屏幕时触发该事件。
> **说明:**TouchEvent具体可参考表2 TouchEvent对象属性列表 | 是5+ | +| touchmove | TouchEvent | 手指触摸屏幕后移动时触发该事件。 | 是5+ | +| touchcancel | TouchEvent | 手指触摸屏幕中动作被打断时触发该事件。 | 是5+ | +| touchend | TouchEvent | 手指触摸结束离开屏幕时触发该事件。 | 是5+ | +| click | - | 点击动作触发该事件。 | 是6+ | +| doubleclick7+ | - | 双击动作触发该事件 | 否 | +| longpress | - | 长按动作触发该事件。 | 否 | +| swipe5+ | SwipeEvent | 组件上快速滑动后触发该事件。
> **说明:**SwipeEvent具体可参考表6 SwipeEvent 基础事件对象属性列表 | 否 | +| attached6+ | - | 当前组件节点挂载在渲染树后触发。 | 否 | +| detached6+ | - | 当前组件节点从渲染树中移除后触发。 | 否 | +| pinchstart7+ | PinchEvent | 手指开始执行捏合操作时触发该事件。
> **说明:**PinchEvent具体可参考表7 PinchEvent 对象属性列表 | 否 | +| pinchupdate7+ | PinchEvent | 手指执行捏合操作过程中触发该事件。 | 否 | +| pinchend7+ | PinchEvent | 手指捏合操作结束离开屏幕时触发该事件。 | 否 | +| pinchcancel7+ | PinchEvent | 手指捏合操作被打断时触发该事件。 | 否 | +| dragstart7+ | DragEvent | 用户开始拖拽时触发该事件。
> **说明:**DragEvent具体可参考表8 DragEvent对象属性列表 | 否 | +| drag7+ | DragEvent | 拖拽过程中触发该事件。 | 否 | +| dragend7+ | DragEvent | 用户拖拽完成后触发。 | 否 | +| dragenter7+ | DragEvent | 进入释放目标时触发该事件。 | 否 | +| dragover7+ | DragEvent | 在释放目标内拖动时触发。 | 否 | +| dragleave7+ | DragEvent | 离开释放目标区域时触发。 | 否 | +| drop7+ | DragEvent | 在可释放目标区域内释放时触发。 | 否 | + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 除上述事件外,其他事件均为非冒泡事件,如[input的change事件](../arkui-js/js-components-basic-input.md#事件),详见各个组件。 + +**表1** BaseEvent对象属性列表 + +| 属性 | 类型 | 说明 | +| -------- | -------- | -------- | +| type | string | 当前事件的类型,比如click、longpress等。 | +| timestamp | number | 该事件触发时的时间戳。 | + +**表2** TouchEvent对象属性列表(继承BaseEvent) + +| 属性 | 类型 | 说明 | +| -------- | -------- | -------- | +| touches | Array<TouchInfo> | 触摸事件时的属性集合,包含屏幕触摸点的信息数组。 | +| changedTouches | Array<TouchInfo> | 触摸事件时的属性集合,包括产生变化的屏幕触摸点的信息数组。数据格式和touches一样。该属性表示有变化的触摸点,如从无变有,位置变化,从有变无。例如用户手指刚接触屏幕时,touches数组中有数据,但changedTouches无数据。 | + +**表3** TouchInfo + +| 属性 | 类型 | 说明 | +| -------- | -------- | -------- | +| globalX | number | 距离屏幕左上角(不包括状态栏)横向距离。屏幕的左上角为原点。 | +| globalY | number | 距离屏幕左上角(不包括状态栏)纵向距离。屏幕的左上角为原点。 | +| localX | number | 距离被触摸组件左上角横向距离。组件的左上角为原点。 | +| localY | number | 距离被触摸组件左上角纵向距离。组件的左上角为原点。 | +| size | number | 触摸接触面积。 | +| force6+ | number | 接触力信息。 | + +**表6** SwipeEvent 基础事件对象属性列表(继承BaseEvent) + +| 属性 | 类型 | 说明 | +| -------- | -------- | -------- | +| direction | string | 滑动方向,可能值有:
1. left:向左滑动;
2. right:向右滑动;
3. up:向上滑动;
4. down:向下滑动。 | +| distance6+ | number | 在滑动方向上的滑动距离。 | + +**表7** PinchEvent 对象属性列表7+ + +| 属性 | 类型 | 说明 | +| -------- | -------- | -------- | +| scale | number | 缩放比例 | +| pinchCenterX | number | 捏合中心点X轴坐标,单位px | +| pinchCenterY | number | 捏合中心点Y轴坐标,单位px | + +**表8** DragEvent对象属性列表(继承BaseEvent)7+ + +| 属性 | 类型 | 说明 | +| -------- | -------- | -------- | +| type | string | 事件名称。 | +| globalX | number | 距离屏幕左上角坐标原点横向距离。 | +| globalY | number | 距离屏幕左上角坐标原点纵向距离。 | +| timestamp | number | 时间戳。 | + +## 事件对象 当组件触发事件后,事件回调函数默认会收到一个事件对象,通过该事件对象可以获取相应的信息。 **target对象:** - - - - - - - - - - -

属性

-

类型

-

说明

-

dataSet6+

-

Object

-

组件上通过通用属性设置的data-*的自定义属性组成的集合。

-
+| 属性 | 类型 | 说明 | +| -------- | -------- | -------- | +| dataSet6+ | Object | 组件上通过通用属性设置的[data-*](../arkui-js/js-components-common-attributes.md)的自定义属性组成的集合。 | **示例:** @@ -477,4 +119,3 @@ export default { } } ``` - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-gradient.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-gradient.md index 9be8919e811899dbd404787581793fba45824400..d6de4eea95bcbf457421a57fafdbed403c7bfb5b 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-gradient.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-gradient.md @@ -1,120 +1,79 @@ -# 渐变样式 +# 渐变样式 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 组件普遍支持的在style或css中设置的 可以平稳过渡两个或多个指定的颜色。 -开发框架支持线性渐变 \(linear-gradient\)和重复线性渐变 \(repeating-linear-gradient\)两种渐变效果。 -## 线性渐变/重复线性渐变 +开发框架支持线性渐变 (linear-gradient)和重复线性渐变 (repeating-linear-gradient)两种渐变效果。 + + +## 线性渐变/重复线性渐变 使用渐变样式,需要定义过渡方向和过渡颜色。 -### 过渡方向 + +### 过渡方向 通过direction或者angle指定过渡方向。 +- direction:进行方向渐变。 -- direction:进行方向渐变。 -- angle:进行角度渐变。 +- angle:进行角度渐变。 ``` background: linear-gradient(direction/angle, color, color, ...); background: repeating-linear-gradient(direction/angle, color, color, ...); ``` -### 过渡颜色 - -支持以下四种方式:\#ff0000、\#ffff0000、rgb\(255, 0, 0\)、rgba\(255, 0, 0, 1\),需要指定至少两种颜色。 - -- 参数 - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

direction

-

to <side-or-corner> <side-or-corner> = [left | right] || [top | bottom]

-

to bottom (由上到下渐变)

-

-

指定过渡方向,如:to left (从右向左渐变) ;或者

-

to bottom right (从左上角到右下角)。

-

angle

-

<deg>

-

180deg

-

-

指定过渡方向,以元素几何中心为坐标原点,水平方向为X轴,angle指定了渐变线与Y轴的夹角(顺时针方向)。

-

color

-

<color> [<length>|<percentage>]

-

-

-

-

定义使用渐变样式区域内颜色的渐变效果。

-
- -- 示例 - - 1. 默认渐变方向为从上向下渐变 - - ``` - #gradient { - height: 300px; - width: 600px; - /* 从顶部开始向底部由红色向绿色渐变 */ - background: linear-gradient(red, #00ff00); - } - ``` - - ![](figures/111.png) - - 2. 45度夹角渐变 - - ``` - /* 45度夹角,从红色渐变到绿色 */ - background: linear-gradient(45deg, rgb(255,0,0),rgb(0, 255, 0)); - ``` - - ![](figures/222.png) - - 3. 设置方向从左向右渐变 - - ``` - /* 从左向右渐变,在距离左边90px和距离左边360px (600*0.6) 之间270px宽度形成渐变 */ - background: linear-gradient(to right, rgb(255,0,0) 90px, rgb(0, 255, 0) 60%); - ``` - - ![](figures/333.png) - - 4. 重复渐变 - - ``` - /* 从左向右重复渐变,重复渐变区域30px(60-30)透明度0.5 */ - background: repeating-linear-gradient(to right, rgba(255, 255, 0, 1) 30px,rgba(0, 0, 255, .5) 60px); - ``` - - ![](figures/444.png) +### 过渡颜色 + +支持以下四种方式:\#ff0000、\#ffff0000、rgb(255, 0, 0)、rgba(255, 0, 0, 1),需要指定至少两种颜色。 + +- 参数 + | 名称 | 类型 | 默认值 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | -------- | + | direction | to <side-or-corner>  <side-or-corner> = [left \| right] \|\| [top \| bottom] | to bottom (由上到下渐变) | 否 | 指定过渡方向,如:to left (从右向左渐变)  ;或者
to bottom right (从左上角到右下角)。 | + | angle | <deg> | 180deg | 否 | 指定过渡方向,以元素几何中心为坐标原点,水平方向为X轴,angle指定了渐变线与Y轴的夹角(顺时针方向)。 | + | color | <color> [<length>\|<percentage>] | - | 是 | 定义使用渐变样式区域内颜色的渐变效果。 | + +- 示例 + 1. 默认渐变方向为从上向下渐变 + ``` + #gradient { + height: 300px; + width: 600px; + /* 从顶部开始向底部由红色向绿色渐变 */ + background: linear-gradient(red, #00ff00); + } + ``` + + ![zh-cn_image_0000001190934502](figures/zh-cn_image_0000001190934502.png) + + 2. 45度夹角渐变 + + ``` + /* 45度夹角,从红色渐变到绿色 */ + background: linear-gradient(45deg, rgb(255,0,0),rgb(0, 255, 0)); + ``` + + ![zh-cn_image_0000001189854534](figures/zh-cn_image_0000001189854534.png) + + 3. 设置方向从左向右渐变 + + ``` + /* 从左向右渐变,在距离左边90px和距离左边360px (600*0.6) 之间270px宽度形成渐变 */ + background: linear-gradient(to right, rgb(255,0,0) 90px, rgb(0, 255, 0) 60%); + ``` + + ![zh-cn_image_0000001236694521](figures/zh-cn_image_0000001236694521.png) + + 4. 重复渐变 + + ``` + /* 从左向右重复渐变,重复渐变区域30px(60-30)透明度0.5 */ + background: repeating-linear-gradient(to right, rgba(255, 255, 0, 1) 30px,rgba(0, 0, 255, .5) 60px); + ``` + ![zh-cn_image_0000001237134475](figures/zh-cn_image_0000001237134475.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-mediaquery.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-mediaquery.md index 03af94ebe404f762f9ce9adff1b99df492ac9aa0..3b8c6099d96507e58f419c02042b462dc7f20679 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-mediaquery.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-mediaquery.md @@ -1,16 +1,23 @@ -# 媒体查询 +# 媒体查询 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - media属性值默认为设备的真实尺寸大小、物理像素和真实的屏幕分辨率。请勿与以720px为基准的项目配置宽度px混淆。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- media属性值默认为设备的真实尺寸大小、物理像素和真实的屏幕分辨率。请勿与以720px为基准的项目配置宽度px混淆。 媒体查询(Media Query)在移动设备上应用十分广泛,开发者经常需要根据设备的大致类型或者特定的特征和设备参数(例如屏幕分辨率)来修改应用的样式。为此媒体查询提供了如下功能: -1. 针对设备和应用的属性信息,可以设计出相匹配的布局样式。 -2. 当屏幕发生动态改变时(比如分屏、横竖屏切换),应用页面布局同步更新。 -## CSS语法规则 +1. 针对设备和应用的属性信息,可以设计出相匹配的布局样式。 + +2. 当屏幕发生动态改变时(比如分屏、横竖屏切换),应用页面布局同步更新。 + + +## CSS语法规则 -使用@media来引入查询语句,具体规则如下: +使用\@media来引入查询语句,具体规则如下: ``` @media [media-type] [and|not|only] [(media-feature)] { @@ -20,17 +27,18 @@ 例子: -@media screen and \(round-screen: true\) \{ … \} // 当设备屏幕是圆形时条件成立 +\@media screen and (round-screen: true) { … } // 当设备屏幕是圆形时条件成立 -@media \(max-height: 800\) \{ … \} // 范围查询,CSS level 3 写法 +\@media (max-height: 800) { … } // 范围查询,CSS level 3 写法 -@media \(height <= 800\) \{ … \} // 范围查询,CSS level 4 写法,与CSS level3写法等价 +\@media (height <= 800) { … } // 范围查询,CSS level 4 写法,与CSS level3写法等价 -@media screen and \(device-type: tv\) or \(resolution < 2\) \{ … \} // 同时包含媒体类型和多个媒体特征的多条件复杂语句查询 +\@media screen and (device-type: tv) or (resolution < 2) { … } // 同时包含媒体类型和多个媒体特征的多条件复杂语句查询 -## 页面中引用资源 -通过@import方式引入媒体查询,具体使用方法如下: +## 页面中引用资源 + +通过\@import方式引入媒体查询,具体使用方法如下: ``` @import url [media-type] [and|not|only] [(media-feature)]; @@ -42,228 +50,70 @@ @import '../common/style.css' screen and (min-width: 600) and (max-width: 1200); ``` -## 媒体类型 - - - - - - - - -

类型

-

说明

-

screen

-

按屏幕相关参数进行媒体查询。

-
+## 媒体类型 + +| 类型 | 说明 | +| -------- | -------- | +| screen | 按屏幕相关参数进行媒体查询。 | -## 媒体逻辑操作 + +## 媒体逻辑操作 媒体逻辑操作符:and、or、not、only用于构成复杂媒体查询,也可以通过comma(,)将其组合起来,详细解释说明如下表。 -**表 1** 媒体逻辑操作符 - - - - - - - - - - - - - - - - - - - - - -

类型

-

说明

-

and

-

将多个媒体特征(Media Feature)以“与”的方式连接成一个媒体查询,只有当所有媒体特征都为true,查询条件成立。另外,它还可以将媒体类型和媒体功能结合起来。

-

例如:screen and (device-type: wearable) and (max-height: 600) 表示当设备类型是智能穿戴同时应用的最大高度小于等于600个像素单位时成立。

-

not

-

取反媒体查询结果,媒体查询结果不成立时返回true,否则返回false。在媒体查询列表中应用not,则not仅取反应用它的媒体查询。

-

例如:not screen and (min-height: 50) and (max-height: 600) 表示当应用高度小于50个像素单位或者大于600个像素单位时成立。

-
说明:

使用not运算符时必须指定媒体类型。

-
-

only

-

当整个表达式都匹配时,才会应用选择的样式,可以应用在防止某些较早的版本的浏览器上产生歧义的场景。一些较早版本的浏览器对于同时包含了媒体类型和媒体特征的语句会产生歧义,比如:

-

screen and (min-height: 50)

-

老版本浏览器会将这句话理解成screen,从而导致仅仅匹配到媒体类型(screen),就应用了指定样式,使用only可以很好地规避这种情况。

-
说明:

使用only时必须指定媒体类型。

-
-

,(comma)

-

将多个媒体特征以“或”的方式连接成一个媒体查询,如果存在结果为true的媒体特征,则查询条件成立。其效果等同于or运算符。

-

例如:screen and (min-height: 1000), (round-screen:true) 表示当应用高度大于等于1000个像素单位或者设备屏幕是圆形时,条件成立。

-

or

-

将多个媒体特征以“或”的方式连接成一个媒体查询,如果存在结果为true的媒体特征,则查询条件成立。

-

例如:screen and (max-height: 1000) or (round-screen:true)表示当应用高度小于等于1000个像素单位或者设备屏幕是圆形时,条件成立。

-
- -在MediaQuery Level 4中引入了范围查询,使其能够使用max-,min-的同时,也支持了<=,\>=,<,\>操作符。 - -**表 2** 媒体逻辑范围操作符 - - - - - - - - - - - - - - - - - - -

类型

-

说明

-

<=

-

小于等于,例如:screen and (height <= 50)。

-

>=

-

大于等于,例如:screen and (height >= 600)。

-

<

-

小于,例如:screen and (height < 50)。

-

>

-

大于,例如:screen and (height > 600)。

-
- -## 媒体特征 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

类型

-

说明

-

height

-

应用页面显示区域的高度。

-

min-height

-

应用页面显示区域的最小高度。

-

max-height

-

应用页面显示区域的最大高度。

-

width

-

应用页面显示区域的宽度。

-

min-width

-

应用页面显示区域的最小宽度。

-

max-width

-

应用页面显示区域的最大宽度。

-

resolution

-

设备的分辨率,支持dpi,dppx和dpcm单位。其中:

-
  • dpi表示每英寸中物理像素个数,1dpi≈0.39dpcm;
  • dpcm表示每厘米上的物理像素个数,1dpcm ≈ 2.54dpi;
  • dppx表示每个px中的物理像素数(此单位按96px=1英寸为基准,与页面中的px单位计算方式不同),1dppx = 96dpi。
-

min-resolution

-

设备的最小分辨率。

-

max-resolution

-

设备的最大分辨率。

-

orientation

-

屏幕的方向。

-

可选值:

-
  • orientation: portrait(设备竖屏)
  • orientation: landscape(设备横屏)
-

aspect-ratio

-

应用页面显示区域的宽度与高度的比值。

-

例如:aspect-ratio:1/2

-

min-aspect-ratio

-

应用页面显示区域的宽度与高度的最小比值。

-

max-aspect-ratio

-

应用页面显示区域的宽度与高度的最大比值。

-

device-height

-

设备的高度。

-

min-device-height

-

设备的最小高度。

-

max-device-height

-

设备的最大高度。

-

device-width

-

设备的宽度。

-

min-device-width

-

设备的最小宽度。

-

max-device-width

-

设备的最大宽度。

-

round-screen

-

屏幕类型,圆形屏幕为true, 非圆形屏幕为 false。

-

dark-mode6+

-

系统为深色模式时为true,否则为false。

-
- -## 示例代码 - -- 通用媒体特征示例代码: +**表1** 媒体逻辑操作符 + +| 类型 | 说明 | +| -------- | -------- | +| and | 将多个媒体特征(Media Feature)以“与”的方式连接成一个媒体查询,只有当所有媒体特征都为true,查询条件成立。另外,它还可以将媒体类型和媒体功能结合起来。
例如:screen and (device-type: wearable) and (max-height: 600) 表示当设备类型是智能穿戴同时应用的最大高度小于等于600个像素单位时成立。 | +| not | 取反媒体查询结果,媒体查询结果不成立时返回true,否则返回false。在媒体查询列表中应用not,则not仅取反应用它的媒体查询。
例如:not screen and (min-height: 50) and (max-height: 600) 表示当应用高度小于50个像素单位或者大于600个像素单位时成立。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用not运算符时必须指定媒体类型。 | +| only | 当整个表达式都匹配时,才会应用选择的样式,可以应用在防止某些较早的版本的浏览器上产生歧义的场景。一些较早版本的浏览器对于同时包含了媒体类型和媒体特征的语句会产生歧义,比如:
screen and (min-height: 50)
老版本浏览器会将这句话理解成screen,从而导致仅仅匹配到媒体类型(screen),就应用了指定样式,使用only可以很好地规避这种情况。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用only时必须指定媒体类型。 | +| ,(comma) | 将多个媒体特征以“或”的方式连接成一个媒体查询,如果存在结果为true的媒体特征,则查询条件成立。其效果等同于or运算符。
例如:screen and (min-height: 1000),  (round-screen:true) 表示当应用高度大于等于1000个像素单位或者设备屏幕是圆形时,条件成立。 | +| or | 将多个媒体特征以“或”的方式连接成一个媒体查询,如果存在结果为true的媒体特征,则查询条件成立。
例如:screen and (max-height: 1000) or  (round-screen:true)表示当应用高度小于等于1000个像素单位或者设备屏幕是圆形时,条件成立。 | + +在MediaQuery Level 4中引入了范围查询,使其能够使用max-,min-的同时,也支持了<=,>=,<,>操作符。 + +**表2** 媒体逻辑范围操作符 + +| 类型 | 说明 | +| -------- | -------- | +| <= | 小于等于,例如:screen and (height <= 50)。 | +| >= | 大于等于,例如:screen and (height >= 600)。 | +| < | 小于,例如:screen and (height < 50)。 | +| > | 大于,例如:screen and (height > 600)。 | + + +## 媒体特征 + +| 类型 | 说明 | +| -------- | -------- | +| height | 应用页面显示区域的高度。 | +| min-height | 应用页面显示区域的最小高度。 | +| max-height | 应用页面显示区域的最大高度。 | +| width | 应用页面显示区域的宽度。 | +| min-width | 应用页面显示区域的最小宽度。 | +| max-width | 应用页面显示区域的最大宽度。 | +| resolution | 设备的分辨率,支持dpi,dppx和dpcm单位。其中:
- dpi表示每英寸中物理像素个数,1dpi≈0.39dpcm;
- dpcm表示每厘米上的物理像素个数,1dpcm ≈ 2.54dpi;
- dppx表示每个px中的物理像素数(此单位按96px=1英寸为基准,与页面中的px单位计算方式不同),1dppx = 96dpi。 | +| min-resolution | 设备的最小分辨率。 | +| max-resolution | 设备的最大分辨率。 | +| orientation | 屏幕的方向。
可选值:
- orientation: portrait(设备竖屏)
- orientation: landscape(设备横屏) | +| aspect-ratio | 应用页面显示区域的宽度与高度的比值。
例如:aspect-ratio:1/2 | +| min-aspect-ratio | 应用页面显示区域的宽度与高度的最小比值。 | +| max-aspect-ratio | 应用页面显示区域的宽度与高度的最大比值。 | +| device-height | 设备的高度。 | +| min-device-height | 设备的最小高度。 | +| max-device-height | 设备的最大高度。 | +| device-width | 设备的宽度。 | +| min-device-width | 设备的最小宽度。 | +| max-device-width | 设备的最大宽度。 | +| round-screen | 屏幕类型,圆形屏幕为true, 非圆形屏幕为 false。 | +| dark-mode6+ | 系统为深色模式时为true,否则为false。 | + + +## 示例代码 + +- 通用媒体特征示例代码: ``` @@ -296,4 +146,3 @@ } } ``` - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-methods.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-methods.md index 67a47db644489562f6f50e3aaab6b56425a29121..4450c65ca2ee789d92d7a13857fb160cca019ce2 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-methods.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-methods.md @@ -1,679 +1,255 @@ -# 通用方法 +# 通用方法 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 当组件通过id属性标识后,可以使用该id获取组件对象并调用相关组件方法。 -## animate - -animate\( keyframes: Keyframes, options: Options\):void - -- 参数 - - - - - - - - - - - - - - - - - - -

参数名

-

参数类型

-

必填

-

描述

-

keyframes

-

keyframes

-

-

设置动画样式

-

options

-

Options

-

-

用于设置动画属性的对象列表。options请见Options说明

-
- - **表 1** keyframes - - - - - - - - - - - - -

属性

-

类型

-

说明

-

frames

-

Array<Style>

-

用于设置动画样式的对象列表。Style类型说明请见Style类型说明

-
- - **表 2** Style类型说明 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

默认值

-

说明

-

width

-

number

-

-

-

动画执行过程中设置到组件上的宽度值。

-

height

-

number

-

-

-

动画执行过程中设置到组件上的高度值。

-

backgroundColor

-

<color>

-

none

-

动画执行过程中设置到组件上的背景颜色。

-

opacity

-

number

-

1

-

设置到组件上的透明度(介于0到1之间)。

-

backgroundPosition

-

string

-

-

-

格式为"x y",单位为百分号或者px。

-

第一个值是水平位置,第二个值是垂直位置。

-

如果仅规定了一个值,另一个值为 50%。

-

transformOrigin

-

string

-

'center center'

-

变换对象的中心点。

-

第一个参数表示x轴的值,可以设置为left、center、right、长度值或百分比值。

-

第二个参数表示y轴的值,可以设置为top、center、bottom、长度值或百分比值。

-

transform

-

Transform

-

-

-

设置到变换对象上的类型。

-

offset

-

number

-

-

-
  • offset值(如果提供)必须在0.0到1.0(含)之间,并以升序排列。
  • 若只有两帧,可以不填offset。
  • 若超过两帧,offset必填。
-
- - **表 3** Options说明 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

参数

-

类型

-

默认值

-

说明

-

duration

-

number

-

0

-

指定当前动画的运行时长(单位毫秒)。

-

easing

-

string

-

linear

-

描述动画的时间曲线,支持类型见easing有效值说明

-

delay

-

number

-

0

-

设置动画执行的延迟时间(默认值表示无延迟)。

-

iterations

-

number | string

-

1

-

设置动画执行的次数。number表示固定次数,Infinity枚举表示无限次数播放。

-

direction6+

-

string

-

normal

-

指定动画的播放模式:

-

normal: 动画正向循环播放;

-

reverse: 动画反向循环播放;

-

alternate:动画交替循环播放,奇数次正向播放,偶数次反向播放;

-

alternate-reverse:动画反向交替循环播放,奇数次反向播放,偶数次正向播放。

-

fill

-

string

-

none

-

指定动画开始和结束的状态:

-

none:在动画执行之前和之后都不会应用任何样式到目标上。

-

forwards:在动画结束后,目标将保留动画结束时的状态(在最后一个关键帧中定义)。

-

backwards6+:动画将在animation-delay期间应用第一个关键帧中定义的值。当animation-direction为"normal"或"alternate"时应用from关键帧中的值,当animation-direction为"reverse"或"alternate-reverse"时应用to关键帧中的值。

-

both6+:动画将遵循forwards和backwards的规则,从而在两个方向上扩展动画属性。

-
- - **表 4** easing有效值说明 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-

描述

-

linear

-

动画线性变化。

-

ease-in

-

动画速度先慢后快,cubic-bezier(0.42, 0.0, 1.0, 1.0)。

-

ease-out

-

动画速度先快后慢,cubic-bezier(0.0, 0.0, 0.58, 1.0)。

-

ease-in-out

-

动画先加速后减速,cubic-bezier(0.42, 0.0, 0.58, 1.0)。

-

friction

-

阻尼曲线,cubic-bezier(0.2, 0.0, 0.2, 1.0)。

-

extreme-deceleration

-

急缓曲线,cubic-bezier(0.0, 0.0, 0.0, 1.0)。

-

sharp

-

锐利曲线,cubic-bezier(0.33, 0.0, 0.67, 1.0)。

-

rhythm

-

节奏曲线,cubic-bezier(0.7, 0.0, 0.2, 1.0)。

-

smooth

-

平滑曲线,cubic-bezier(0.4, 0.0, 0.4, 1.0)。

-

cubic-bezier(x1, y1, x2, y2)

-

在三次贝塞尔函数中定义动画变化过程,入参的x和y值必须处于0-1之间。

-

steps(number, step-position)6+

-

Step曲线。

-

number必须设置,支持的类型为int。

-

step-position参数可选,支持设置start或end,默认值为end。

-
- -- 返回值 - - animation对象属性: - - - - - - - - - - - - - - - - - - - - - - - -

属性

-

类型

-

说明

-

finished

-

boolean

-

只读,用于表示当前动画是否已播放完成。

-

pending

-

boolean

-

只读,用于表示当前动画是否处于等待其他异步操作完成的等待状态(例如启动一个延时播放的动画)。

-

playState

-

string

-

可读可写,动画的执行状态:

-
  • idle:未执行状态,包括已结束或未开始。
  • running:动画正在运行。
  • paused:动画暂停。
  • finished:动画播放完成。
-

startTime

-

number

-

可读可写,动画播放开始的预定时间,用途类似于options参数中的delay。

-
- - animation对象方法: - - - - - - - - - - - - - - - - - - - - - - - - - - - -

方法

-

参数

-

说明

-

play

-

-

-

组件播放动画。

-

finish

-

-

-

组件完成动画。

-

pause

-

-

-

组件暂停动画。

-

cancel

-

-

-

组件取消动画。

-

reverse

-

-

-

组件倒播动画。

-
- - animation对象事件: - - - - - - - - - - - - - - - - - - -

事件

-

说明

-

start6+

-

动画开始事件。

-

cancel

-

动画被强制取消。

-

finish

-

动画播放完成。

-

repeat

-

动画重播事件。

-
- -- 示例 - - ``` - -
-
-
- - -
+ +## animate + +animate( keyframes: Keyframes, options: Options):void + +- 参数 + | 参数名 | 参数类型 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | + | keyframes | keyframes | 是 | 设置动画样式 | + | options | Options | 是 | 用于设置动画属性的对象列表。options请见表3 Options说明。 | + + **表1** keyframes + + | 属性 | 类型 | 说明 | + | -------- | -------- | -------- | + | frames | Array<Style> | 用于设置动画样式的对象列表。Style类型说明请见表2 Style类型说明。 | + + **表2** Style类型说明 + + | 参数 | 类型 | 默认值 | 说明 | + | -------- | -------- | -------- | -------- | + | width | number | - | 动画执行过程中设置到组件上的宽度值。 | + | height | number | - | 动画执行过程中设置到组件上的高度值。 | + | backgroundColor | <color> | none | 动画执行过程中设置到组件上的背景颜色。 | + | opacity | number | 1 | 设置到组件上的透明度(介于0到1之间)。 | + | backgroundPosition | string | - | 格式为"x y",单位为百分号或者px。
第一个值是水平位置,第二个值是垂直位置。
如果仅规定了一个值,另一个值为 50%。 | + | transformOrigin | string | 'center center' | 变换对象的中心点。
第一个参数表示x轴的值,可以设置为left、center、right、长度值或百分比值。
第二个参数表示y轴的值,可以设置为top、center、bottom、长度值或百分比值。 | + | transform | [Transform](../arkui-js/js-components-common-animation.md) | - | 设置到变换对象上的类型。 | + | offset | number | - | - offset值(如果提供)必须在0.0到1.0(含)之间,并以升序排列。
- 若只有两帧,可以不填offset。
- 若超过两帧,offset必填。 | + + **表3** Options说明 + + | 参数 | 类型 | 默认值 | 说明 | + | -------- | -------- | -------- | -------- | + | duration | number | 0 | 指定当前动画的运行时长(单位毫秒)。 | + | easing | string | linear | 描述动画的时间曲线,支持类型见表4 easing有效值说明。 | + | delay | number | 0 | 设置动画执行的延迟时间(默认值表示无延迟)。 | + | iterations | number \| string | 1 | 设置动画执行的次数。number表示固定次数,Infinity枚举表示无限次数播放。 | + | direction6+ | string | normal | 指定动画的播放模式:
normal: 动画正向循环播放;
reverse: 动画反向循环播放;
alternate:动画交替循环播放,奇数次正向播放,偶数次反向播放;
alternate-reverse:动画反向交替循环播放,奇数次反向播放,偶数次正向播放。 | + | fill | string | none | 指定动画开始和结束的状态:
none:在动画执行之前和之后都不会应用任何样式到目标上。
forwards:在动画结束后,目标将保留动画结束时的状态(在最后一个关键帧中定义)。
backwards6+:动画将在animation-delay期间应用第一个关键帧中定义的值。当animation-direction为"normal"或"alternate"时应用from关键帧中的值,当animation-direction为"reverse"或"alternate-reverse"时应用to关键帧中的值。
both:动画将遵循forwards和backwards的规则,从而在两个方向上扩展动画属性。 | + + **表4** easing有效值说明 + + | 值 | 描述 | + | -------- | -------- | + | linear | 动画线性变化。 | + | ease-in | 动画速度先慢后快,cubic-bezier(0.42, 0.0, 1.0, 1.0)。 | + | ease-out | 动画速度先快后慢,cubic-bezier(0.0, 0.0, 0.58, 1.0)。 | + | ease-in-out | 动画先加速后减速,cubic-bezier(0.42, 0.0, 0.58, 1.0)。 | + | friction | 阻尼曲线,cubic-bezier(0.2, 0.0, 0.2, 1.0)。 | + | extreme-deceleration | 急缓曲线,cubic-bezier(0.0, 0.0, 0.0, 1.0)。 | + | sharp | 锐利曲线,cubic-bezier(0.33, 0.0, 0.67, 1.0)。 | + | rhythm | 节奏曲线,cubic-bezier(0.7, 0.0, 0.2, 1.0)。 | + | smooth | 平滑曲线,cubic-bezier(0.4, 0.0, 0.4, 1.0)。 | + | cubic-bezier(x1, y1, x2, y2) | 在三次贝塞尔函数中定义动画变化过程,入参的x和y值必须处于0-1之间。 | + | steps(number, step-position)6+ | Step曲线。
number必须设置,支持的类型为int。
step-position参数可选,支持设置start或end,默认值为end。 | + +- 返回值 + animation对象属性: + + | 属性 | 类型 | 说明 | + | -------- | -------- | -------- | + | finished | boolean | 只读,用于表示当前动画是否已播放完成。 | + | pending | boolean | 只读,用于表示当前动画是否处于等待其他异步操作完成的等待状态(例如启动一个延时播放的动画)。 | + | playState | string | 可读可写,动画的执行状态:
- idle:未执行状态,包括已结束或未开始。
- running:动画正在运行。
- paused:动画暂停。
- finished:动画播放完成。 | + | startTime | number | 可读可写,动画播放开始的预定时间,用途类似于options参数中的delay。 | + + animation对象方法: + + | 方法 | 参数 | 说明 | + | -------- | -------- | -------- | + | play | - | 组件播放动画。 | + | finish | - | 组件完成动画。 | + | pause | - | 组件暂停动画。 | + | cancel | - | 组件取消动画。 | + | reverse | - | 组件倒播动画。 | + + animation对象事件: + + | 事件 | 说明 | + | -------- | -------- | + | start6+ | 动画开始事件。 | + | cancel | 动画被强制取消。 | + | finish | 动画播放完成。 | + | repeat | 动画重播事件。 | + +- 示例 + ``` + +
+
+
+ +
- ``` - - ``` - /* xxx.css */ - .container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - } - .box{ - width: 200px; - height: 200px; - background-color: #ff0000; - margin-top: 30px; - } - .buttonBox{ - margin-top: 30px; - width: 250px; - justify-content: space-between; - } - button{ - background-color: #8e8b89; - color: white; - width: 100px; - height: 40px; - font-size: 24px; +
+ ``` + + ``` + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 100%; + } + .box{ + width: 200px; + height: 200px; + background-color: #ff0000; + margin-top: 30px; + } + .buttonBox{ + margin-top: 30px; + width: 250px; + justify-content: space-between; + } + button{ + background-color: #8e8b89; + color: white; + width: 100px; + height: 40px; + font-size: 24px; + } + ``` + + ``` + // xxx.js + import prompt from '@system.prompt'; + export default{ + data:{ + animation:'', + }, + onInit(){ + }, + onShow(){ + var options = { + duration: 1500, + easing: 'friction', + delay: 500, + fill: 'forwards', + iterations: 2, + direction: 'normal', + }; + var frames = [ + {transform: {translate: '-120px -0px'}, opacity: 0.1, offset: 0.0}, + {transform: {translate: '120px 0px'}, opacity: 1.0, offset: 1.0} + ]; + this.animation = this.$element('idName').animate(frames, options); + // handle finish event + this.animation.onfinish = function(){ + prompt.showToast({ + message: "The animation is finished." + }); + }; + // handle cancel event + this.animation.oncancel = function(){ + prompt.showToast({ + message: "The animation is canceled." + }); + }; + // handle repeat event + this.animation.onrepeat = function(){ + prompt.showToast({ + message: "The animation is repeated." + }); + }; + }, + start(){ + this.animation.play(); + }, + cancel(){ + this.animation.cancel(); } - ``` - - ``` - // xxx.js - import prompt from '@system.prompt'; - export default{ - data:{ - animation:'', - }, - onInit(){ - }, - onShow(){ - var options = { - duration: 1500, - easing: 'friction', - delay: 500, - fill: 'forwards', - iterations: 2, - direction: 'normal', - }; - var frames = [ - {transform: {translate: '-120px -0px'}, opacity: 0.1, offset: 0.0}, - {transform: {translate: '120px 0px'}, opacity: 1.0, offset: 1.0} - ]; - this.animation = this.$element('idName').animate(frames, options); - // handle finish event - this.animation.onfinish = function(){ - prompt.showToast({ - message: "The animation is finished." - }); - }; - // handle cancel event - this.animation.oncancel = function(){ - prompt.showToast({ - message: "The animation is canceled." - }); - }; - // handle repeat event - this.animation.onrepeat = function(){ - prompt.showToast({ - message: "The animation is repeated." - }); - }; - }, - start(){ - this.animation.play(); - }, - cancel(){ - this.animation.cancel(); - } - } - ``` + } + ``` - ![](figures/AnimationAPI裁剪.gif) + ![zh-cn_image_0000001229677045](figures/zh-cn_image_0000001229677045.gif) -## getBoundingClientRect +## getBoundingClientRect -getBoundingClientRect\(\): [ ](#table1650917111414) +getBoundingClientRect(): \ 获取元素的大小及其相对于窗口的位置。 -- 返回值 - - **表 5** Rect对象说明6+ - - - - - - - - - - - - - - - - - - - - - - - - -

属性

-

类型

-

描述

-

width

-

number

-

该元素的宽度。

-

height

-

number

-

该元素的高度。

-

left

-

number

-

该元素左边界距离窗口的偏移。

-

top

-

number

-

该元素上边界距离窗口的偏移。

-
- -- 示例 - - ``` - // xxx.js - var rect = this.$element('id').getBoundingClientRect(); - console.info(`current element position is ${rect.left}, ${rect.top}`); - ``` - - -## createIntersectionObserver - -createIntersectionObserver\(param?:ObserverParam\): Observer) +- 返回值 + + **表5** Rect对象说明6+ + + | 属性 | 类型 | 描述 | + | -------- | -------- | -------- | + | width | number | 该元素的宽度。 | + | height | number | 该元素的高度。 | + | left | number | 该元素左边界距离窗口的偏移。 | + | top | number | 该元素上边界距离窗口的偏移。 | + +- 示例 + ``` + // xxx.js + var rect = this.$element('id').getBoundingClientRect(); + console.info(`current element position is ${rect.left}, ${rect.top}`); + ``` -监听元素在当前页面的可见范围。 -- 参数 - - - - - - - - - - - - - -

参数名

-

参数类型

-

必填

-

描述

-

param

-

ObserverParam

-

-

-

获取observer的回调。

-
- - **表 6** ObserverParam对象说明6+ - - - - - - - - - - - - -

属性

-

类型

-

描述

-

ratios

-

Array<number>

-

组件超出或小于范围时触发observer的回调。

-
- -- 返回值 - - **表 7** Observer对象支持的方法6+ - - - - - - - - - - - - - - - - -

方法

-

参数

-

描述

-

observe

-

callback: function

-

开启observer的订阅方法。超出或小于阈值时触发callback。

-

unobserve

-

-

-

取消observer的订阅方法。

-
- -- 示例 - - ``` - // xxx.js - let observer = this.$element('broad').createIntersectionObserver({ - ratios: [0.2, 0.5], // number - }); - - observer.observe((isVisible, ratio)=> { - console.info('this element is ' + isVisible + 'ratio is ' + ratio) - }) - - observer.unobserve() - ``` +## createIntersectionObserver +createIntersectionObserver(param?: ObserverParam): Observer + +监听元素在当前页面的可见范围。 +- 参数 + | 参数名 | 参数类型 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | + | param | ObserverParam | - | 获取observer的回调。 | + + **表6** ObserverParam对象说明6+ + + | 属性 | 类型 | 描述 | + | -------- | -------- | -------- | + | ratios | Array<number> | 组件超出或小于范围时触发observer的回调。 | + +- 返回值 + + **表7** Observer对象支持的方法6+ + + | 方法 | 参数 | 描述 | + | -------- | -------- | -------- | + | observe | callback: function | 开启observer的订阅方法。超出或小于阈值时触发callback。 | + | unobserve | - | 取消observer的订阅方法。 | + +- 示例 + ``` + // xxx.js + let observer = this.$element('broad').createIntersectionObserver({ + ratios: [0.2, 0.5], // number + }); + + observer.observe((isVisible, ratio)=> { + console.info('this element is ' + isVisible + 'ratio is ' + ratio) + }) + + observer.unobserve() + ``` diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md index 2cc5ed4fc8b0c660bb6caee345ab9a394b472837..395c073392a4752667b6f61f42752d6173a17f9b 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-styles.md @@ -1,616 +1,70 @@ -# 通用样式 +# 通用样式 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 组件普遍支持的可以在style或css中设置组件外观样式。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

描述

-

width

-

<length> | <percentage>

-

-

-

设置组件自身的宽度。

-

缺省时使用元素自身内容需要的宽度。

-

height

-

<length> | <percentage>

-

-

-

设置组件自身的高度。

-

缺省时使用元素自身内容需要的高度。

-

min-width5+

-

<length> | <percentage>6+

-

0

-

设置元素的最小宽度。

-

min-height5+

-

<length> | <percentage>6+

-

0

-

设置元素的最小高度。

-

max-width5+

-

<length> | <percentage>6+

-

-

-

设置元素的最大宽度。默认无限制。

-

max-height5+

-

<length> | <percentage>6+

-

-

-

设置元素的最大高度。默认无限制。

-

padding

-

<length> | <percentage>5+

-

0

-

使用简写属性设置所有的内边距属性。

-
该属性可以有1到4个值:
  • 指定一个值时,该值指定四个边的内边距。

    -
  • 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。

    -
  • 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。

    -
  • 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。

    -
-
-

padding-[left|top|right|bottom]

-

<length> | <percentage>5+

-

0

-

设置左、上、右、下内边距属性。

-

padding-[start|end]

-

<length> | <percentage>5+

-

0

-

设置起始和末端内边距属性。

-

margin

-

<length> | <percentage>5+

-

0

-

使用简写属性设置所有的外边距属性,该属性可以有1到4个值。

-
  • 只有一个值时,这个值会被指定给全部的四个边。

    -
  • 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。

    -
  • 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。

    -
  • 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。

    -
-

margin-[left|top|right|bottom]

-

<length> | <percentage>5+

-

0

-

设置左、上、右、下外边距属性。

-

margin-[start|end]

-

<length> | <percentage>5+

-

0

-

设置起始和末端外边距属性。

-

border

-

-

-

0

-

使用简写属性设置所有的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置时,各属性值为默认值。

-

border-style

-

string

-

solid

-

使用简写属性设置所有边框的样式,可选值为:

-
  • dotted:显示为一系列圆点,圆点半径为border-width的一半。
  • dashed:显示为一系列短的方形虚线。
-
  • solid:显示为一条实线。
-

border-[left|top|right|bottom]-style

-

string

-

solid

-

分别设置左、上、右、下四个边框的样式,可选值为dotted、dashed、solid。

-

border-[left|top|right|bottom]

-

-

-

-

-

使用简写属性设置对应位置的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置的值为默认值。

-

border-width

-

<length>

-

0

-

使用简写属性设置元素的所有边框宽度,或者单独为各边边框设置宽度

-

border-[left|top|right|bottom]-width

-

<length>

-

0

-

分别设置左、上、右、下四个边框的宽度。

-

border-color

-

<color>

-

black

-

使用简写属性设置元素的所有边框颜色,或者单独为各边边框设置颜色

-

border-[left|top|right|bottom]-color

-

<color>

-

black

-

分别设置左、上、右、下四个边框的颜色。

-

border-radius

-

<length>

-

-

-

border-radius属性设置元素的外边框圆角半径。设置border-radius时不能单独设置某一个方向的border-[left|top|right|bottom]-width,border-[left|top|right|bottom]-color ,border-[left|top|right|bottom]-style,如果要设置color、width和style,需要将四个方向一起设置(border-width、border-color、border-style)。

-
说明:

顺序为左下、右下、左上和右上。

-
-

border-[top|bottom]-[left|right]-radius

-

<length>

-

-

-

分别设置左上,右上,右下和左下四个角的圆角半径。

-

background

-

<linear-gradient>

-

-

-

仅支持设置渐变样式,与background-color、background-image不兼容。

-

background-color

-

<color>

-

-

-

设置背景颜色。

-

background-image

-

string

-

-

-

设置背景图片。与background-color、background不兼容,支持本地图片资源地址。

-

示例:

-
  • background-image: url("/common/background.png")
    说明:

    不支持svg格式图片。

    -
    -
-

background-size

-
  • string
  • <length> <length>
  • <percentage> <percentage>
-

auto

-

设置背景图片的大小。

-
  • string可选值:
    • contain:把图片扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
    • cover:把背景图片扩展至足够大,以使背景图片完全覆盖背景区域;背景图片的某些部分也许无法显示在背景定位区域中。
    • auto:保持原图的比例不变。
    -
  • length值参数方式:

    设置背景图片的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。

    -
  • 百分比参数方式:

    以父元素的百分比来设置背景图片的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。

    -
-

background-repeat

-

string

-

repeat

-

针对重复背景图片样式进行设置,背景图片默认在水平和垂直方向上重复。

-
  • repeat:在水平轴和竖直轴上同时重复绘制图片。
  • repeat-x:只在水平轴上重复绘制图片。
  • repeat-y:只在竖直轴上重复绘制图片。
  • no-repeat:不会重复绘制图片。
-

background-position

-
  • string string
  • <length> <length>
  • <percentage> <percentage>
-

0px 0px

-
  • 关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。
    • left:水平方向上最左侧。
    • right:水平方向上最右侧。
    • top:竖直方向上最顶部。
    • bottom:竖直方向上最底部。
    • center:水平方向或竖直方向上中间位置。
    -
-
  • length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px) 。如果仅规定了一个值,另外一个值将是50%。
  • 百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。
  • 可以混合使用<percentage>和<length>。
-

box-shadow5+

-

string

-

0

-

语法:box-shadow: h-shadow v-shadow blur spread color

-

通过这个样式可以设置当前组件的阴影样式,包括水平位置(必填)、垂直位置(必填)、模糊半径(可选,默认值为0)、阴影延展距离(可选,默认值为0)、阴影颜色(可选,默认值为黑色)。

-

示例:

-
  • box-shadow :10px 20px 5px 10px #888888
  • box-shadow :100px 100px 30px red
  • box-shadow :-100px -100px 0px 40px
-

filter5+

-

string

-

-

-

语法:filter: blur(px)

-

通过这个样式可以设置当前组件布局范围的内容模糊,参数用于指定模糊半径,如果没有设置值,则默认是0(不模糊),不支持百分比。

-

示例:

-
  • filter: blur(10px)
-

backdrop-filter5+

-

string

-

-

-

语法:backdrop-filter: blur(px)

-

通过这个样式可以设置当前组件布局范围的背景模糊,参数用于指定模糊半径,如果没有设置值,则默认是0(不模糊),不支持百分比。

-

示例:

-
  • backdrop-filter: blur(10px)
-

opacity

-

number

-

1

-

元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。

-

display

-

string

-

-

flex

-

确定一个元素所产生的框的类型,可选值为:

-
  • flex:弹性布局。
  • none:不渲染此元素。
-

visibility

-

string

-

-

visible

-

是否显示元素所产生的框。不可见的框会占用布局(将'display'属性设置为'none'来完全去除框),可选值为:

-
  • visible:元素正常显示。
  • hidden:隐藏元素,但是其他元素的布局不改变,相当于此元素变成透明。
-
说明:

visibility和display样式都设置时,仅display生效。

-
-

flex

-

number | string

-

-

-

规定当前组件如何适应父组件中的可用空间。

-

flex可以指定1个、2个5+或3个5+值。

-

单值语法:

-
  • 一个无单位数:用来设置组件的flex-grow。
  • 一个有效的宽度值5+:用来设置组件的flex-basis。
-

双值语法5+

-

第一个值必须是无单位数,用来设置组件的flex-grow。第二个值是以下之一:

-
  • 一个无单位数:用来设置组件的flex-shrink。
  • 一个有效的宽度值:用来设置组件的flex-basis。
-

三值语法5+

-

第一个值必须是无单位数,用来设置组件的flex-grow;第二个值必须是无单位数,用来设置组件的flex-shrink;第三个值必须是一个有效的宽度值,用来设置组件的flex-basis。

-
说明:

仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。

-
-

flex-grow

-

number

-

0

-

设置组件的拉伸样式,指定父组件容器主轴方向上剩余空间(容器本身大小减去所有flex子元素占用的大小)的分配权重。0为不伸展。

-
说明:

仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。

-
-

flex-shrink

-

number

-

1

-

设置组件的收缩样式,元素仅在默认宽度之和大于容器的时候才会发生收缩,0为不收缩。

-
说明:

仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。

-
-

flex-basis

-

<length>

-

-

-

-

设置组件在主轴方向上的初始大小。

-
说明:

仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。

-
-

align-self6+

-

string

-

-

-

设置自身在父元素交叉轴上的对齐方式,该样式会覆盖父元素的align-items样式,仅在父容器为div、list。可选值为:

-
  • stretch 弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
  • flex-start 元素向交叉轴起点对齐。
  • flex-end 元素向交叉轴终点对齐。
  • center 元素在交叉轴居中。
  • baseline 元素在交叉轴基线对齐。
-

position

-

string

-

relative

-

设置元素的定位类型,不支持动态变更。

-
  • fixed:相对与整个界面进行定位。
  • absolute:相对于父元素进行定位。
  • relative:相对于其正常位置进行定位。
-
说明:

absolute属性仅在父容器为<div>、<stack>时生效。

-
-

[left|top|right|bottom]

-

<length> | <percentage>6+

-

-

-

left|top|right|bottom需要配合position样式使用,来确定元素的偏移位置。

-
  • left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
  • top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。
  • right属性规定元素的右边缘。该属性定义了定位元素右外边距边界与其包含块右边界之间的偏移。
  • bottom属性规定元素的底部边缘。该属性定义了一个定位元素的下外边距边界与其包含块下边界之间的偏移。
-

[start | end]6+

-

<length> | <percentage>

-

-

-

start | end需要配合position样式使用,来确定元素的偏移位置。

-
  • start属性规定元素的起始边缘。该属性定义了定位元素起始外边距边界与其包含块起始边界之间的偏移。
  • end属性规定元素的结尾边缘。该属性定义了一个定位元素的结尾边距边界与其包含块结尾边界之间的偏移。
-

z-index6+

-

number

-

-

-

表示对于同一父节点其子节点的渲染顺序。数值越大,渲染数据越靠后。

-
说明:

z-index不支持auto,并且opacity等其他样式不会影响z-index的渲染顺序。

-
-

image-fill6+

-

<color>

-

-

-

为svg图片填充颜色,支持组件范围(与设置图片资源的属性):button(icon属性)、piece(icon属性)、search(icon属性)、input(headericon属性)、textarea(headericon属性)、image(src属性)、toolbar-item(icon属性)。

-

svg图片文件内的fill属性颜色值在渲染时将被替换为image-fill所配的颜色值,且仅对svg图片内显示声明的fill属性生效。

-

clip-path6+

-

[ <geometry-box> || <basic-shape> ] | none

-

-

-

设置组件的裁剪区域。区域内的部分显示,区域外的不显示。

-

<geometry-box>:表示裁剪区域的作用范围,默认为border-box。可选值为:

-
  • margin-box:margin计算入长宽尺寸内。
  • border-box:border计算入长宽尺寸内。
  • padding-box:padding计算入长宽尺寸内。
  • content-box:margin/border/padding不计算入长宽尺寸内。
-

<basic-shape>:表示裁剪的形状。包含以下类型:

-
  • inset,格式为:inset( <percentage>{1,4} [ round <'border-radius'> ]? )。
  • circle,格式为:circle( [ <percentage> ]? [ at <percentage> <percentage> ]? )。
  • ellipse,格式为:ellipse( [ <percentage>{2} ]? [ at <percentage> <percentage> ]? )。
  • polygon,格式为:polygon( [ <percentage> <percentage> ]# )
  • path,格式为:path( <string> )。
-

mask-image6+

-
  • <linear-gradient>
  • string
-

-

-

设置渐变色遮罩或本地图片设置。

-

设置渐变色遮罩,示例:

-

linear-gradient(to left, black, white)

-

设置纯色遮罩,示例:

-

linear-gradient(to right, grey , grey)

-

设置本地svg图片为遮罩,示例:url(common/mask.svg)

-

mask-size6+

-
  • string
  • <length><length>
  • <percentage> <percentage>
-

auto

-

设置遮罩图片显示大小,仅当mask-image为图片资源时有效。

-

string可选值:

-
  • contain:把图像扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
  • cover:把图像扩展至足够大,以使背景图像完全覆盖背景区域;背景图像的某些部分也许无法显示在背景定位区域中。
  • auto:保持原图的比例不变。
-

length值参数方式:设置图像的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。

-

百分比参数方式:以原图宽高的百分比来设置图像的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。

-

mask-position6+

-
  • string string
  • <length> <length>
  • <percentage> <percentage>
-

0px 0px

-

设置遮罩图片显示位置,仅当mask-image为图片资源时有效。关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。

-

string可选值:

-
  • left:水平方向上最左侧。
  • right:水平方向上最右侧。
  • top:竖直方向上最顶部。
  • bottom:竖直方向上最底部。
  • center:水平方向或竖直方向上中间位置。
-

length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px) 。如果仅规定了一个值,另外一个值将是50%。

-

百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。

-

可以混合使用<percentage>和<length>。

-

border-image-source7+

-

string

-

-

-

指定元素的边框图片。

-

示例:

-

border-image-source: url("/common/images/border.png")

-

border-image-slice7+

-

<length> | <percentage>

-

0

-

指定图片的边界内向偏移。

-

该属性可以有1到4个值:

-

指定一个值时,该值指定四个边的内偏移。

-

指定两个值时,第一个值指定上下两边的内偏移,第二个指定左右两边的内偏移。

-

指定三个值时,第一个指定上边的内偏移,第二个指定左右两边的内偏移,第三个指定下边的内偏移。

-

指定四个值时分别为上、右、下、左边的内偏移(顺时针顺序)。

-

border-image-width7+

-

<length> | <percentage>

-

0

-

指定图片边界的宽度。

-

指定一个值时,该值指定四个边的宽度。

-

指定两个值时,第一个值指定上下两边的宽度 ,第二个指定左右两边的宽度。

-

指定三个值时,第一个指定上边的宽度 ,第二个指定左右两边的宽度 ,第三个指定下边的宽度。

-

指定四个值时分别为上、右、下、左边的宽度 (顺时针顺序)。

-

border-image-outset7+

-

<length> | <percentage>

-

0

-

指定边框图像可超出边框的大小。

-

指定一个值时,边框图像在四个方向超出边框的距离。

-

指定两个值时,第一个值指定上下两边的边框图像超出边框的距离,第二个指定左右两边的 。

-

指定三个值时,第一个指定上边的边框图像超出边框的距离 ,第二个指定左右两边的边框图像超出边框的距离 ,第三个指定下边的边框图像超出边框的距离 。

-

指定四个值时分别为上、右、下、左边的边框图像超出边框的距离 (顺时针顺序)。

-

border-image-repeat7+

-

string

-

stretch

-

定义图片如何填充边框。

-

stretch: 拉伸图片以填充边框。

-

repeat:平铺图片以填充边框。

-

round:平铺图像。当不能整数次平铺时,根据情况放大或缩小图像。

-

border-image7+

-

string

-

-

-

简写属性,可以选择以下两种设置方式:

- -
  • 渐变色边框

    示例:

    -

    border-image: linear-gradient(red, yellow) 10px

    -
-
->![](../../public_sys-resources/icon-note.gif) **说明:** ->通用样式都不是必填项。 +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| width | <length> \| <percentage> | - | 设置组件自身的宽度。
缺省时使用元素自身内容需要的宽度。
| +| height | <length> \| <percentage> | - | 设置组件自身的高度。
缺省时使用元素自身内容需要的高度。
| +| min-width5+ | <length> \| <percentage>6+ | 0 | 设置元素的最小宽度。 | +| min-height5+ | <length> \| <percentage>6+ | 0 | 设置元素的最小高度。 | +| max-width5+ | <length> \| <percentage>6+ | - | 设置元素的最大宽度。默认无限制。 | +| max-height5+ | <length> \| <percentage>6+ | - | 设置元素的最大高度。默认无限制。 | +| padding | <length> \| <percentage>5+ | 0 | 使用简写属性设置所有的内边距属性。
该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 设置左、上、右、下内边距属性。 | +| padding-[start\|end] | <length> \| <percentage>5+ | 0 | 设置起始和末端内边距属性。 | +| margin | <length> \| <percentage>5+ | 0 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> \| <percentage>5+ | 0 | 设置左、上、右、下外边距属性。 | +| margin-[start\|end] | <length> \| <percentage>5+ | 0 | 设置起始和末端外边距属性。 | +| border | - | 0 | 使用简写属性设置所有的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置时,各属性值为默认值。 | +| border-style | string | solid | 使用简写属性设置所有边框的样式,可选值为:
- dotted:显示为一系列圆点,圆点半径为border-width的一半。
- dashed:显示为一系列短的方形虚线。
- solid:显示为一条实线。 | +| border-[left\|top\|right\|bottom]-style | string | solid | 分别设置左、上、右、下四个边框的样式,可选值为dotted、dashed、solid。 | +| border-[left\|top\|right\|bottom] | - | - | 使用简写属性设置对应位置的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置的值为默认值。 | +| border-width | <length> | 0 | 使用简写属性设置元素的所有边框宽度,或者单独为各边边框设置宽度。 | +| border-[left\|top\|right\|bottom]-width | <length> | 0 | 分别设置左、上、右、下四个边框的宽度。 | +| border-color | <color> | black | 使用简写属性设置元素的所有边框颜色,或者单独为各边边框设置颜色。 | +| border-[left\|top\|right\|bottom]-color | <color> | black | 分别设置左、上、右、下四个边框的颜色。 | +| border-radius | <length> | - | border-radius属性设置元素的外边框圆角半径。设置border-radius时不能单独设置某一个方向的border-[left\|top\|right\|bottom]-width,border-[left\|top\|right\|bottom]-color ,border-[left\|top\|right\|bottom]-style,如果要设置color、width和style,需要将四个方向一起设置(border-width、border-color、border-style)。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 顺序为左下、右下、左上和右上。 | +| border-[top\|bottom]-[left\|right]-radius | <length> | - | 分别设置左上,右上,右下和左下四个角的圆角半径。 | +| background | <linear-gradient> | - | 仅支持设置[渐变样式](../arkui-js/js-components-common-gradient.md),与background-color、background-image不兼容。 | +| background-color | <color> | - | 设置背景颜色。 | +| background-image | string | - | 设置背景图片。与background-color、background不兼容,支持网络图片资源和本地图片资源地址。
示例:
- background-image: url("/common/background.png")
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 不支持svg格式图片。 | +| background-size | - string
- <length> <length>
- <percentage> <percentage> | auto | 设置背景图片的大小。
- string可选值:
  - contain:把图片扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
  - cover:把背景图片扩展至足够大,以使背景图片完全覆盖背景区域;背景图片的某些部分也许无法显示在背景定位区域中。
  - auto:保持原图的比例不变。
- length值参数方式:
  设置背景图片的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。
- 百分比参数方式:
  以父元素的百分比来设置背景图片的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。 | +| background-repeat | string | repeat | 针对重复背景图片样式进行设置,背景图片默认在水平和垂直方向上重复。
- repeat:在水平轴和竖直轴上同时重复绘制图片。
- repeat-x:只在水平轴上重复绘制图片。
- repeat-y:只在竖直轴上重复绘制图片。
- no-repeat:不会重复绘制图片。 | +| background-position | - string string
- <length> <length>
- <percentage> <percentage> | 0px 0px | - 关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。
  - left:水平方向上最左侧。
  - right:水平方向上最右侧。
  - top:竖直方向上最顶部。
  - bottom:竖直方向上最底部。
  - center:水平方向或竖直方向上中间位置。
- length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px)  。如果仅规定了一个值,另外一个值将是50%。
- 百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。
- 可以混合使用<percentage>和<length>。 | +| box-shadow5+ | string | 0 | 语法:box-shadow: h-shadow v-shadow blur spread color
通过这个样式可以设置当前组件的阴影样式,包括水平位置(必填)、垂直位置(必填)、模糊半径(可选,默认值为0)、阴影延展距离(可选,默认值为0)、阴影颜色(可选,默认值为黑色)。
示例:
- box-shadow :10px 20px 5px 10px \#888888
- box-shadow :100px 100px 30px red
- box-shadow :-100px -100px 0px 40px | +| filter5+ | string | - | 语法:filter: blur(px)
通过这个样式可以设置当前组件布局范围的内容模糊,参数用于指定模糊半径,如果没有设置值,则默认是0(不模糊),不支持百分比。
示例:
- filter: blur(10px) | +| backdrop-filter5+ | string | - | 语法:backdrop-filter: blur(px)
通过这个样式可以设置当前组件布局范围的背景模糊,参数用于指定模糊半径,如果没有设置值,则默认是0(不模糊),不支持百分比。
示例:
- backdrop-filter: blur(10px) | +| window-filter5+ | string | - | 语法:window-filter: blur(percent), style5+
通过这个样式可以设置当前组件布局范围的窗口模糊程度和模糊样式,如果没有设置值,则默认是0%(不模糊),多块模糊区域时不支持设置不同的模糊值和模糊样式。style可选值:small_light(默认值), medium_light, large_light, xlarge_light, small_dark, medium_dark, large_dark, xlarge_dark。
示例:
- window-filter: blur(50%)
- window-filter: blur(10%), large_light
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅手机和平板设备支持。 | +| opacity | number | 1 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| display | string | flex | 确定一个元素所产生的框的类型,可选值为:
- flex:弹性布局。
- none:不渲染此元素。 | +| visibility | string | visible | 是否显示元素所产生的框。不可见的框会占用布局(将'display'属性设置为'none'来完全去除框),可选值为:
- visible:元素正常显示。
- hidden:隐藏元素,但是其他元素的布局不改变,相当于此元素变成透明。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> visibility和display样式都设置时,仅display生效。 | +| flex | number \| string | - | 规定当前组件如何适应父组件中的可用空间。
flex可以指定1个、2个5+或3个5+值。
单值语法:
- 一个无单位数:用来设置组件的flex-grow。
- 一个有效的宽度值5+:用来设置组件的flex-basis。
双值语法5+
第一个值必须是无单位数,用来设置组件的flex-grow。第二个值是以下之一:
- 一个无单位数:用来设置组件的flex-shrink。
- 一个有效的宽度值:用来设置组件的flex-basis。
三值语法5+
第一个值必须是无单位数,用来设置组件的flex-grow;第二个值必须是无单位数,用来设置组件的flex-shrink;第三个值必须是一个有效的宽度值,用来设置组件的flex-basis。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | +| flex-grow | number | 0 | 设置组件的拉伸样式,指定父组件容器主轴方向上剩余空间(容器本身大小减去所有flex子元素占用的大小)的分配权重。0为不伸展。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | +| flex-shrink | number | 1 | 设置组件的收缩样式,元素仅在默认宽度之和大于容器的时候才会发生收缩,0为不收缩。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | +| flex-basis | <length> | - | 设置组件在主轴方向上的初始大小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅父容器为<div>、<list-item>、<tabs>、<refresh>、<stepper-item>5+时生效。 | +| align-self6+ | string | - | 设置自身在父元素交叉轴上的对齐方式,该样式会覆盖父元素的align-items样式,仅在父容器为div、list。可选值为:
- stretch 弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
- flex-start 元素向交叉轴起点对齐。
- flex-end 元素向交叉轴终点对齐。
- center 元素在交叉轴居中。
- baseline 元素在交叉轴基线对齐。 | +| position | string | relative | 设置元素的定位类型,不支持动态变更。
- fixed:相对与整个界面进行定位。
- absolute:相对于父元素进行定位。
- relative:相对于其正常位置进行定位。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> absolute属性仅在父容器为<div>、<stack>时生效。 | +| [left\|top\|right\|bottom] | <length> \| <percentage>6+ | - | left\|top\|right\|bottom需要配合position样式使用,来确定元素的偏移位置。
- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。
- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。
- right属性规定元素的右边缘。该属性定义了定位元素右外边距边界与其包含块右边界之间的偏移。
- bottom属性规定元素的底部边缘。该属性定义了一个定位元素的下外边距边界与其包含块下边界之间的偏移。 | +| [start \| end]6+ | <length> \| <percentage> | - | start \| end需要配合position样式使用,来确定元素的偏移位置。
- start属性规定元素的起始边缘。该属性定义了定位元素起始外边距边界与其包含块起始边界之间的偏移。
- end属性规定元素的结尾边缘。该属性定义了一个定位元素的结尾边距边界与其包含块结尾边界之间的偏移。 | +| z-index6+ | number | - | 表示对于同一父节点其子节点的渲染顺序。数值越大,渲染数据越靠后。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> z-index不支持auto,并且opacity等其他样式不会影响z-index的渲染顺序。 | +| image-fill6+ | <color> | - | 为svg图片填充颜色,支持组件范围(与设置图片资源的属性):button(icon属性)、piece(icon属性)、search(icon属性)、input(headericon属性)、textarea(headericon属性)、image(src属性)、toolbar-item(icon属性)。
svg图片文件内的fill属性颜色值在渲染时将被替换为image-fill所配的颜色值,且仅对svg图片内显示声明的fill属性生效。 | +| clip-path6+ | [ <geometry-box> \|\| <basic-shape> ] \| none | - | 设置组件的裁剪区域。区域内的部分显示,区域外的不显示。
<geometry-box>:表示裁剪区域的作用范围,默认为border-box。可选值为:
- margin-box:margin计算入长宽尺寸内。
- border-box:border计算入长宽尺寸内。
- padding-box:padding计算入长宽尺寸内。
- content-box:margin/border/padding不计算入长宽尺寸内。
<basic-shape>:表示裁剪的形状。包含以下类型:
- inset,格式为:inset( <percentage>{1,4} [ round <'border-radius'> ]? )。
- circle,格式为:circle( [ <percentage> ]? [ at <percentage> <percentage> ]? )。
- ellipse,格式为:ellipse( [ <percentage>{2} ]? [ at <percentage> <percentage> ]? )。
- polygon,格式为:polygon( [ <percentage> <percentage> ]\# )
- path,格式为:path( <string> )。 | +| mask-image6+ | - <linear-gradient>
- string | - | 设置渐变色遮罩或本地图片设置。
设置渐变色遮罩,示例:
linear-gradient(to left, black, white)
设置纯色遮罩,示例:
linear-gradient(to right, grey , grey)
设置本地svg图片为遮罩,示例:url(common/mask.svg) | +| mask-size6+ | - string
- <length><length>
- <percentage> <percentage> | auto | 设置遮罩图片显示大小,仅当mask-image为图片资源时有效。
string可选值:
- contain:把图像扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
- cover:把图像扩展至足够大,以使背景图像完全覆盖背景区域;背景图像的某些部分也许无法显示在背景定位区域中。
- auto:保持原图的比例不变。
length值参数方式:设置图像的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。
百分比参数方式:以原图宽高的百分比来设置图像的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。 | +| mask-position6+ | - string string
- <length> <length>
- <percentage> <percentage> | 0px 0px | 设置遮罩图片显示位置,仅当mask-image为图片资源时有效。关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。
string可选值:
- left:水平方向上最左侧。
- right:水平方向上最右侧。
- top:竖直方向上最顶部。
- bottom:竖直方向上最底部。
- center:水平方向或竖直方向上中间位置。
length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px)  。如果仅规定了一个值,另外一个值将是50%。
百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。
可以混合使用<percentage>和<length>。 | +| border-image-source7+ | string | - | 指定元素的边框图片。
示例:
border-image-source: url("/common/images/border.png") | +| border-image-slice7+ | <length> \| <percentage> | 0 | 指定图片的边界内向偏移。
该属性可以有1到4个值:
指定一个值时,该值指定四个边的内偏移。
指定两个值时,第一个值指定上下两边的内偏移,第二个指定左右两边的内偏移。
指定三个值时,第一个指定上边的内偏移,第二个指定左右两边的内偏移,第三个指定下边的内偏移。
指定四个值时分别为上、右、下、左边的内偏移(顺时针顺序)。 | +| border-image-width7+ | <length> \| <percentage> | 0 | 指定图片边界的宽度。
指定一个值时,该值指定四个边的宽度。
指定两个值时,第一个值指定上下两边的宽度 ,第二个指定左右两边的宽度。
指定三个值时,第一个指定上边的宽度 ,第二个指定左右两边的宽度 ,第三个指定下边的宽度。
指定四个值时分别为上、右、下、左边的宽度 (顺时针顺序)。 | +| border-image-outset7+ | <length> \| <percentage> | 0 | 指定边框图像可超出边框的大小。
指定一个值时,边框图像在四个方向超出边框的距离。
指定两个值时,第一个值指定上下两边的边框图像超出边框的距离,第二个指定左右两边的 。
指定三个值时,第一个指定上边的边框图像超出边框的距离 ,第二个指定左右两边的边框图像超出边框的距离 ,第三个指定下边的边框图像超出边框的距离 。
指定四个值时分别为上、右、下、左边的边框图像超出边框的距离 (顺时针顺序)。 | +| border-image-repeat7+ | string | stretch | 定义图片如何填充边框。
stretch: 拉伸图片以填充边框。
repeat:平铺图片以填充边框。
round:平铺图像。当不能整数次平铺时,根据情况放大或缩小图像。
| +| border-image7+ | string | - | 简写属性,可以选择以下两种设置方式:
- 设置图片边框的每个属性。包含图像的边界向内偏移,图像边界的宽度,边框图像可超出边框盒的大小,图片如何填充边框,顺序设置为 border-image-source ,border-image-slice,border-image-width,border-image-outset,border-image-repeat,不设置的值为默认值。
- 渐变色边框
  示例:
  border-image: linear-gradient(red, yellow) 10px | + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 通用样式都不是必填项。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md index d7582ada79c53a9f195112517f7559d58a2f1a77..15900d8ce4f02e1bb4d93b39c51a75e52efc6749 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-transition.md @@ -1,82 +1,35 @@ -# 转场样式 - -## 共享元素转场 - -### 属性 - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

描述

-

shareid

-

string

-

-

进行共享元素转场时使用,若不配置,则转场样式不生效。共享元素转场当前支持的组件:list-item、image、text、button、label。

-
- -### 样式 - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

描述

-

shared-transition-effect

-

string

-

exchange

-

配置共享元素转场时的入场样式。

-
  • exchange(默认值):源页面元素移动到目的页元素位置,并进行适当缩放。
  • static:目的页元素位置不变,用户可配置透明度动画。当前仅跳转目标页配置的static效果生效。
-

shared-transition-name

-

string

-

-

-

转场时,目的页配置的样式优先生效。该样式用于配置共享元素的动画效果,一个由@keyframes定义的动画序列,支持transform和透明度动画。若共享元素效果与自定义的动画冲突,以自定义动画为准。

-

shared-transition-timing-function

-

string

-

friction

-

转场时,目的页配置的样式优先生效。该属性定义了共享元素转场时的差值曲线。若不配置,默认使用friction曲线。

-
- -### 注意事项 +# 转场样式 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +## 共享元素转场 + + +### 属性 + +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| shareid | string | 无 | 进行共享元素转场时使用,若不配置,则转场样式不生效。共享元素转场当前支持的组件:list-item、image、text、button、label。 | + + +### 样式 + +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| shared-transition-effect | string | exchange | 配置共享元素转场时的入场样式。
- exchange(默认值):源页面元素移动到目的页元素位置,并进行适当缩放。
- static:目的页元素位置不变,用户可配置透明度动画。当前仅跳转目标页配置的static效果生效。 | +| shared-transition-name | string | - | 转场时,目的页配置的样式优先生效。该样式用于配置共享元素的动画效果,一个由@keyframes定义的动画序列,支持transform和透明度动画。若共享元素效果与自定义的动画冲突,以自定义动画为准。 | +| shared-transition-timing-function | string | friction | 转场时,目的页配置的样式优先生效。该属性定义了共享元素转场时的差值曲线。若不配置,默认使用friction曲线。 | + + +### 注意事项 1. 若同时配置了共享元素转场和自定义页面转场样式,页面转场效果以自定义效果为准。 2. 共享元素的exchange效果类似下图。 -**图 1** 共享元素转场默认效果 -![](figures/共享元素转场默认效果.png "共享元素转场默认效果") +**图1** 共享元素转场默认效果 +![zh-cn_image_0000001238424309](figures/zh-cn_image_0000001238424309.png) 3. 共享元素动画对元素的边框、背景色不生效。 @@ -84,7 +37,8 @@ 5. 动态修改shareid5+:组件A的shareid被组件B的shareid覆盖,则组件A的共享元素效果失效,即使组件B的shareid被修改,此时组件A的共享元素效果也不会恢复。 -### 示例 + +### 示例 PageA跳转到PageB,跳转的共享元素为image, shareid为“shareImage”。 @@ -92,14 +46,12 @@ PageA跳转到PageB,跳转的共享元素为image, shareid为“shareImage
- - -
- - Click on picture to Jump to ths details -
-
-
+ + + + Click on picture to Jump to ths details + +
``` @@ -157,39 +109,23 @@ export default { } ``` -## 卡片转场样式 - ->![](../../public_sys-resources/icon-note.gif) **说明:** ->卡片转场无法和其他转场\(包括共享元素转场和自定义转场\)共同使用。 - -### 样式 - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

描述

-

transition-effect

-

string

-

-

-

用于配置当前页面中的某个组件在卡片转场过程中是否进行转场动效,当前支持如下配置:

-
  • unfold:配置这个属性的组件,如在卡片的上方,则向上移动一个卡片的高度,如在卡片的下方,则向下移动一个卡片的高度。
  • none:转场过程中没有动效。
-
- -### 示例 - -source\_page包含顶部内容以及卡片列表,点击卡片可以跳转到target\_page。 + +## 卡片转场样式 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 卡片转场无法和其他转场(包括共享元素转场和自定义转场)共同使用。 + + +### 样式 + +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| transition-effect | string | - | 用于配置当前页面中的某个组件在卡片转场过程中是否进行转场动效,当前支持如下配置:
- unfold:配置这个属性的组件,如在卡片的上方,则向上移动一个卡片的高度,如在卡片的下方,则向下移动一个卡片的高度。
- none:转场过程中没有动效。 | + + +### 示例 + +source_page包含顶部内容以及卡片列表,点击卡片可以跳转到target_page。 ``` @@ -270,73 +206,32 @@ export default { } ``` -![](figures/卡片转场.gif) - -## 页面转场样式 - -### 样式 - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

描述

-

transition-enter

-

string

-

-

-

与@keyframes配套使用,支持transform和透明度动画,详见表2

-

transition-exit

-

string

-

-

-

与@keyframes配套使用,支持transform和透明度动画,详见表2

-

transition-duration

-

string

-

跟随设备默认的页面转场时间

-

支持的单位为[s(秒)|ms(毫秒) ],默认单位为ms,未配置时使用系统默认值。

-

transition-timing-function

-

string

-

friction

-

描述转场动画执行的速度曲线,用于使转场更为平滑。详细参数见动画样式中“animation-timing-function”有效值说明。

-
- -### 注意事项 - -1. 配置自定义转场时,建议配置页面背景色为不透明颜色,否则在转场过程中可能会出现衔接不自然的现象。 -2. transition-enter和transition-exit可单独配置,没有配置时使用系统默认的参数。 -3. transition-enter/transition-exit说明如下: - 1. push场景下:进入页面栈的Page2.js应用transition-enter描述的动画配置;进入页面栈第二位置的Page1.js应用transition-exit描述的动画配置。 - - ![](figures/zh-cn_image_0000001193704354.png) - - 2. back场景下:退出页面栈的Page2.js应用transition-enter描述的动画配置,并进行倒播;从页面栈第二位置进入栈顶位置的Page1.js应用transition-exit描述的动画配置,并进行倒播。 - - ![](figures/zh-cn_image_0000001238184345.png) +![zh-cn_image_0000001193544358](figures/zh-cn_image_0000001193544358.gif) + + +## 页面转场样式 + + +### 样式 + +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| transition-enter | string | - | 与@keyframes配套使用,支持transform和透明度动画,详见[动画样式 表 @keyframes属性说明](../arkui-js/js-components-common-animation.md)。 | +| transition-exit | string | - | 与\@keyframes配套使用,支持transform和透明度动画,详见[动画样式 表 @keyframes属性说明](../arkui-js/js-components-common-animation.md)。 | +| transition-duration | string | 跟随设备默认的页面转场时间 | 支持的单位为[s(秒)\|ms(毫秒) ],默认单位为ms,未配置时使用系统默认值。 | +| transition-timing-function | string | friction | 描述转场动画执行的速度曲线,用于使转场更为平滑。详细参数见[动画样式](../arkui-js/js-components-common-animation.md)中“animation-timing-function”有效值说明。 | + + +### 注意事项 + +1. 配置自定义转场时,建议配置页面背景色为不透明颜色,否则在转场过程中可能会出现衔接不自然的现象。 + +2. transition-enter和transition-exit可单独配置,没有配置时使用系统默认的参数。 +3. transition-enter/transition-exit说明如下: + a. push场景下:进入页面栈的Page2.js应用transition-enter描述的动画配置;进入页面栈第二位置的Page1.js应用transition-exit描述的动画配置。 + ![zh-cn_image_0000001193704354](figures/zh-cn_image_0000001193704354.png) + b. back场景下:退出页面栈的Page2.js应用transition-enter描述的动画配置,并进行倒播;从页面栈第二位置进入栈顶位置的Page1.js应用transition-exit描述的动画配置,并进行倒播。 + ![zh-cn_image_0000001238184345](figures/zh-cn_image_0000001238184345.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common.md b/zh-cn/application-dev/reference/arkui-js/js-components-common.md index 44ae48f1a10f5c7d26c5295ffa70408a2a826448..549f6c67a66bd2a5fcef3df79b23b300dd3fe865 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common.md @@ -1,23 +1,23 @@ -# 通用 +# 通用 -- **[通用属性](js-components-common-attributes.md)** -- **[通用样式](js-components-common-styles.md)** -- **[通用事件](js-components-common-events.md)** +- **[通用属性](js-components-common-attributes.md)** -- **[通用方法](js-components-common-methods.md)** +- **[通用样式](js-components-common-styles.md)** -- **[动画样式](js-components-common-animation.md)** +- **[通用事件](js-components-common-events.md)** -- **[渐变样式](js-components-common-gradient.md)** +- **[通用方法](js-components-common-methods.md)** -- **[转场样式](js-components-common-transition.md)** +- **[动画样式](js-components-common-animation.md)** -- **[媒体查询](js-components-common-mediaquery.md)** +- **[渐变样式](js-components-common-gradient.md)** -- **[自定义字体样式](js-components-common-customizing-font.md)** +- **[转场样式](js-components-common-transition.md)** -- **[原子布局](js-components-common-atomic-layout.md)** +- **[媒体查询](js-components-common-mediaquery.md)** +- **[自定义字体样式](js-components-common-customizing-font.md)** +- **[原子布局](js-components-common-atomic-layout.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-badge.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-badge.md index 0087e65fdafdcf31230dce9ae353877ef4399570..ae68f510ba661d06fb827f19eee5166bc1385eb2 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-badge.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-badge.md @@ -1,188 +1,66 @@ -# badge +# badge + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 应用中如果有需用户关注的新事件提醒,可以采用新事件标记来标识。 -## 权限列表 + +## 权限列表 无 -## 子组件 + +## 子组件 支持单个子组件。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->仅支持单子组件节点,如果使用多子组件节点,默认使用第一个子组件节点。 - -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

placement

-

string

-

rightTop

-

-

事件提醒的数字标记或者圆点标记的位置,可选值为:

-
  • right:位于组件右边框。
  • rightTop:位于组件边框右上角。
  • left:位于组件左边框。
-

count

-

number

-

0

-

-

设置提醒的消息数,默认为0。当设置相应的提醒消息数大于0时,消息提醒会变成数字标记类型,未设置消息数或者消息数不大于0时,消息提醒将采用圆点标记。

-
说明:

当数字设置为大于maxcount时,将使用maxcount显示。

-

count属性最大支持整数值为2147483647。

-
-

visible

-

boolean

-

false

-

-

是否显示消息提醒,当收到新信息提醒时可以设置该属性为true,显示相应的消息提醒,如果需要使用数字标记类型,同时需要设置相应的count属性。

-

maxcount

-

number

-

99

-

-

最大消息数限制,当收到新信息提醒大于该限制时,标识数字会进行省略,仅显示maxcount+。

-
说明:

maxcount属性最大支持整数值为2147483647。

-
-

config

-

BadgeConfig

-

-

-

-

设置新事件标记相关配置属性。

-

label6+

-

string

-

-

-

-

设置新事件提醒的文本值。

-
说明:

使用该属性时,count和maxcount属性不生效。

-
-
- -**表 1** BadgeConfig - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

badgeColor

-

<color>

-

#fa2a2d

-

-

新事件标记背景色。

-

textColor

-

<color>

-

#ffffff

-

-

数字标记的数字文本颜色。

-

textSize

-

<length>

-

10px

-

-

数字标记的数字文本大小。

-

badgeSize

-

<length>

-

6px

-

-

圆点标记的默认大小

-
- -## 样式 - -支持[通用样式](js-components-common-styles.md)。 - ->![](../../public_sys-resources/icon-note.gif) **说明:** ->badge组件的子组件大小不能超过badge组件本身的大小,否则子组件不会绘制。 - -## 事件 - -支持[通用事件](js-components-common-events.md)。 - -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 仅支持单子组件节点,如果使用多子组件节点,默认使用第一个子组件节点。 + + +## 属性 + +除支持[通用属性](../reference/arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| placement | string | rightTop | 否 | 事件提醒的数字标记或者圆点标记的位置,可选值为:
- right:位于组件右边框。
- rightTop:位于组件边框右上角。
- left:位于组件左边框。 | +| count | number | 0 | 否 | 设置提醒的消息数,默认为0。当设置相应的提醒消息数大于0时,消息提醒会变成数字标记类型,未设置消息数或者消息数不大于0时,消息提醒将采用圆点标记。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 当数字设置为大于maxcount时,将使用maxcount显示。
> count属性最大支持整数值为2147483647。 | +| visible | boolean | false | 否 | 是否显示消息提醒,当收到新信息提醒时可以设置该属性为true,显示相应的消息提醒,如果需要使用数字标记类型,同时需要设置相应的count属性。 | +| maxcount | number | 99 | 否 | 最大消息数限制,当收到新信息提醒大于该限制时,标识数字会进行省略,仅显示maxcount+。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> maxcount属性最大支持整数值为2147483647。 | +| config | BadgeConfig | - | 否 | 设置新事件标记相关配置属性。 | +| label6+ | string | - | 否 | 设置新事件提醒的文本值。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 使用该属性时,count和maxcount属性不生效。 | + +**表1** BadgeConfig + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| badgeColor | <color> | \#fa2a2d | 否 | 新事件标记背景色。 | +| textColor | <color> | \#ffffff | 否 | 数字标记的数字文本颜色。 | +| textSize | <length> | 10px | 否 | 数字标记的数字文本大小。 | +| badgeSize | <length> | 6px | 否 | 圆点标记的默认大小 | + + +## 样式 + +支持[通用样式](../arkui-js/js-components-common-styles.md)。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> badge组件的子组件大小不能超过badge组件本身的大小,否则子组件不会绘制。 + + +## 事件 + +支持[通用事件](../arkui-js/js-components-common-events.md)。 + + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -229,5 +107,4 @@ export default { } ``` -![](figures/捕获.png) - +![zh-cn_image_0000001177265268](figures/zh-cn_image_0000001177265268.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-dialog.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-dialog.md index 8a50995941162a98688c554f8b9340b764f3ba3d..3a5e23868d8e342c261f6e6ae1440ff2be1148db 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-dialog.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-dialog.md @@ -1,121 +1,63 @@ -# dialog +# dialog + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 自定义弹窗容器。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持单个子组件。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,支持如下属性: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

dragable7+

-

boolean

-

false

-

-

设置对话框是否支持拖拽。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 弹窗类组件不支持focusable、click-effect属性。 - -## 样式 - -仅支持[通用样式](js-components-common-styles.md)中的width、height、margin、margin-\[left|top|right|bottom\]、margin-\[start|end\]样式。 - -## 事件 - -不支持[通用事件](js-components-common-events.md),仅支持如下事件: - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

cancel

-

-

-

用户点击非dialog区域触发取消弹窗时触发的事件。

-

show7+

-

-

-

对话框弹出时触发该事件。

-

close7+

-

-

-

对话框关闭时触发该事件。

-
- -## 方法 - -不支持[通用方法](js-components-common-methods.md),仅支持如下方法。 - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

show

-

-

-

弹出对话框。

-

close

-

-

-

关闭对话框。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->dialog属性、样式均不支持动态更新。 - -## 示例 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| dragable7+ | boolean | false | 否 | 设置对话框是否支持拖拽。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 弹窗类组件不支持focusable、click-effect属性。 + + +## 样式 + +仅支持[通用样式](../arkui-js/js-components-common-styles.md)中的width、height、margin、margin-[left|top|right|bottom]、margin-[start|end]样式。 + + +## 事件 + +不支持[通用事件](../arkui-js/js-components-common-events.md),仅支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| cancel | - | 用户点击非dialog区域触发取消弹窗时触发的事件。 | +| show7+ | - | 对话框弹出时触发该事件。 | +| close7+ | - | 对话框关闭时触发该事件。 | + + +## 方法 + +不支持[通用方法](../arkui-js/js-components-common-methods.md),仅支持如下方法。 + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| show | - | 弹出对话框。 | +| close | - | 关闭对话框。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> dialog属性、样式均不支持动态更新。 + + +## 示例 ``` @@ -218,5 +160,4 @@ export default { } ``` -![](figures/4.gif) - +![zh-cn_image_0000001167846062](figures/zh-cn_image_0000001167846062.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-div.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-div.md index 63a626f9d7dd24147c7863071cbb37933d8a3fd1..18aa7a8f97668cf23e4cddc2dda2ad3818053c38 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-div.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-div.md @@ -1,702 +1,410 @@ -# div +# div + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 基础容器,用作页面结构的根节点或将内容进行分组。 -## 权限列表 +## 权限列表 无 -## 子组件 - -支持。 -## 属性 - -支持[通用属性](js-components-common-attributes.md)。 - -## 样式 - -除支持[组件通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

flex-direction

-

string

-

row

-

-

flex容器主轴方向。可选项有:

-
  • column:垂直方向从上到下。
  • row:水平方向从左到右。
-

flex-wrap

-

string

-

nowrap

-

-

flex容器是单行还是多行显示,该值暂不支持动态修改。可选项有:

-
  • nowrap:不换行,单行显示。
  • wrap:换行,多行显示。
-

justify-content

-

string

-

flex-start

-

-

flex容器当前行的主轴对齐格式。可选项有:

-
  • flex-start:项目位于容器的开头。
  • flex-end:项目位于容器的结尾。
  • center:项目位于容器的中心。
  • space-between:项目位于各行之间留有空白的容器内。
  • space-around:项目位于各行之前、之间、之后都留有空白的容器内。
  • space-evenly5+: 均匀排列每个元素,每个元素之间的间隔相等。
-

align-items

-

string

-

stretch

-

-

flex容器当前行的交叉轴对齐格式,可选值为:

-
  • stretch:弹性元素在交叉轴方向被拉伸到与容器相同的高度或宽度。
  • flex-start:元素向交叉轴起点对齐。
  • flex-end:元素向交叉轴终点对齐。
  • center:元素在交叉轴居中。
-

align-content

-

string

-

flex-start

-

-

交叉轴中有额外的空间时,多行内容对齐格式,可选值为:

-
  • flex-start:所有行从交叉轴起点开始填充。第一行的交叉轴起点边和容器的交叉轴起点边对齐。接下来的每一行紧跟前一行。
  • flex-end:所有行从交叉轴末尾开始填充。最后一行的交叉轴终点和容器的交叉轴终点对齐。同时所有后续行与前一个对齐。
  • center:所有行朝向容器的中心填充。每行互相紧挨,相对于容器居中对齐。容器的交叉轴起点边和第一行的距离相等于容器的交叉轴终点边和最后一行的距离。
  • space-between:所有行在容器中平均分布。相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的边对齐。
  • space-around:所有行在容器中平均分布,相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的距离是相邻两行间距的一半。
-

display

-

string

-

flex

-

-

确定该元素视图框的类型,该值暂不支持动态修改。可选值为:

-
  • flex:弹性布局
  • grid:网格布局
  • none:不渲染此元素
-

grid-template-[columns|rows]

-

string

-

1行1列

-

-

用于设置当前网格布局行和列的数量,不设置时默认1行1列,仅当display为grid时生效。

-

示例:如设置grid-template-columns为:

-
  • 50px 100px 60px:分三列,第一列50px,第二列100px,第三列60px;
  • 1fr 1fr 2fr:分三列,将父组件允许的宽分为4等份,第一列占1份,第二列占一份,第三列占2份;
  • 30% 20% 50%:分三列,将父组件允许的宽为基准,第一列占30%,第二列占20%,第三列占50%;
  • repeat(2,100px):分两列,第一列100px,第二列100px;
  • repeat(auto-fill,100px)5+:按照每列100px的大小和交叉轴大小计算最大正整数重复次数,按照该重复次数布满交叉轴;
  • auto 1fr 1fr:分三列,第一列自适应内部子组件所需宽度,剩余空间分为两等份,第二列占一份,第三列占一份。
-

grid-[columns|rows]-gap

-

<length>

-

0

-

-

用于设置行与行的间距或者列与列的间距,也可以支持通过grid-gap设置相同的行列间距,仅当display为grid时生效。

-

grid-row-[start|end]

-

number

-

-

-

-

用于设置当前元素在网格布局中的起止行号,仅当父组件display样式为grid时生效(仅div支持display样式设置为grid)。

-

grid-column-[start|end]

-

number

-

-

-

-

用于设置当前元素在网格布局中的起止列号,仅当父组件display样式为grid时生效(仅div支持display样式设置为grid)。

-

grid-auto-flow5+

-

string

-

-

-

-

使用框架自动布局算法进行网格的布局,可选值为:

-
  • row:逐行填充元素,如果行空间不够,则新增行;
  • column:逐列填充元素,如果列空间不够,则新增列。
-

overflow6+

-

string

-

visible

-

-

设置元素内容区超过元素本身大小时的表现形式。

-
  • visible:多个子元素内容超过元素大小时,显示在元素外面;
  • hidden:元素内容超过元素大小时,进行裁切显示;
  • scroll:元素内容超过元素大小时,进行滚动显示并展示滚动条(当前只支持纵向)。
-
说明:
  • overflow: scroll样式需要元素设置固定的大小。
-
-

align-items6+

-

string

-

-

-

-

设置容器中元素交叉轴上的对齐方式:

-
  • stretch:Flex容器内容在交叉轴方向被拉伸到与容器相同的高度或宽度;
  • flex-start:Flex布局容器内元素向交叉轴起点对齐;
  • flex-end:Flex布局容器内元素向交叉轴终点对齐;
  • center:Flex布局容器内元素在交叉轴居中对齐;
  • baseline:如Flex布局纵向排列,则该值与'flex-start'等效。横向布局时,内容元素存在文本时按照文本基线对齐,否则底部对齐。
-

scrollbar-color6+

-

<color>

-

-

-

-

设置滚动条的颜色。

-

scrollbar-width6+

-

<length>

-

-

-

-

设置滚动条的宽度。

-

overscroll-effect6+

-

string

-

-

-

-

设置滚动边缘效果,可选值为:

-
  • spring:弹性物理动效,滑动到边缘后可以根据初始速度或通过触摸事件继续滑动一段距离,松手后回弹;
  • fade:渐隐物理动效,滑动到边缘后展示一个波浪形的渐隐,根据速度和滑动距离的变化渐隐也会发送一定的变化;
  • none:滑动到边缘后无效果
-
- -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

reachstart6+

-

-

-

当页面滑动到最开始的点时触发的事件回调,当flex-direction: row时才会触发。

-

reachend6+

-

-

-

当页面滑动到最末尾的点时触发的事件回调,当flex-direction: row时才会触发。

-

reachtop6+

-

-

-

当页面滑动到最上部的点时触发的事件回调,当flex-direction: column时才会触发。

-

reachbottom6+

-

-

-

当页面滑动到最下部的点时触发的事件回调,当flex-direction: column时才会触发。

-
- -## 方法 - -除支持[通用方法](js-components-common-methods.md)外,还支持如下方法: - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

返回值

-

描述

-

getScrollOffset6+

-

-

-

ScrollOffset

-

获取元素内容的滚动偏移。

-
说明:
  • 需要设置overflow样式为scroll。
-
-

scrollBy6+

-

ScrollParam

-

-

-

指定元素内容的滚动偏移。

-
说明:
  • 需要设置overflow样式为scroll。
-
-
- -**表 1** ScrollOffset6+ - - - - - - - - - - - - - - - - -

名称

-

类型

-

描述

-

x

-

number

-

在x轴方向的偏移,单位为px。

-

y

-

number

-

在y轴方向的偏移,单位为px。

-
- -**表 2** ScrollParam6+ - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

描述

-

dx

-

number

-

水平方向滑动的偏移量,单位px。

-

dy

-

number

-

垂直方向滑动的偏移量,单位px。

-

smooth

-

boolean

-

是否平滑处理。

-
- -## 示例 - -1. Flex样式 - - ``` - -
-
-
-
-
-
-
- ``` - - ``` - /* xxx.css */ - .container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 454px; - height: 454px; - } - .flex-box { - justify-content: space-around; - align-items: center; - width: 400px; - height: 140px; - background-color: #ffffff; - } - .flex-item { - width: 120px; - height: 120px; - border-radius: 16px; - } - .color-primary { - background-color: #007dff; - } - .color-warning { - background-color: #ff7500; - } - .color-success { - background-color: #41ba41; - } - ``` - - ![](figures/zh-cn_image_0000001127285076.png) - -2. Flex Wrap样式 - - ``` - -
-
-
-
-
-
-
- ``` - - ``` - /* xxx.css */ - .container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 454px; - height: 454px; - } - .flex-box { - justify-content: space-around; - align-items: center; - flex-wrap: wrap; - width: 300px; - height: 250px; - background-color: #ffffff; - } - .flex-item { - width: 120px; - height: 120px; - border-radius: 16px; - } - .color-primary { - background-color: #007dff; - } - .color-warning { - background-color: #ff7500; - } - .color-success { - background-color: #41ba41; - } - ``` - - ![](figures/22.png) - -3. Grid样式 - - ``` - -
-
-
-
-
-
- ``` - - ``` - /* xxx.css */ - .common { - width: 400px; - height: 400px; - background-color: #ffffff; - align-items: center; - justify-content: center; - margin: 24px; - } - .grid-parent { - display: grid; - grid-template-columns: 35% 35%; - grid-columns-gap: 24px; - grid-rows-gap: 24px; - grid-template-rows: 35% 35%; - } - .grid-child { - width: 100%; - height: 100%; - border-radius: 8px; - } - .grid-left-top { - grid-row-start: 0; - grid-column-start: 0; - grid-row-end: 0; - grid-column-end: 0; - background-color: #3f56ea; - } - .grid-left-bottom { - grid-row-start: 1; - grid-column-start: 0; - grid-row-end: 1; - grid-column-end: 0; - background-color: #00aaee; - } - .grid-right-top { - grid-row-start: 0; - grid-column-start: 1; - grid-row-end: 0; - grid-column-end: 1; - background-color: #00bfc9; - } - .grid-right-bottom { - grid-row-start: 1; - grid-column-start: 1; - grid-row-end: 1; - grid-column-end: 1; - background-color: #47cc47; - } - ``` - - ![](figures/11.png) - -4. 拖拽7+ - - ``` - -
-
-
-
- ``` - - ``` - /* xxx.css */ - .container { - flex-direction: column; - } - .content{ - width: 200px; - height: 200px; - background-color: red; - } - ``` - - ``` - // xxx.js - import prompt from '@system.prompt'; - export default { - data:{ - left:0, - top:0, - }, - dragstart(e){ - prompt.showToast({ - message: 'Start to be dragged' - }) - }, - drag(e){ - this.left = e.globalX; - this.top = e.globalY; - }, - dragend(e){ - prompt.showToast({ - message: 'End Drag' - }) - }, - } - ``` - - ![](figures/9.gif) - - ``` - -
-
-
-
-
- ``` - - ``` - /* xxx.css */ - .container { - flex-direction: column; - width: 100%; - position: relative; - max-width: 100%; - } - .content{ - width: 200px; - height: 200px; - background-color: red; - position: absolute; - } - ``` - - ``` - // xxx.js - import prompt from '@system.prompt'; - export default { - data:{ - left:0, - top:0, - }, - drag(e){ - this.left = e.globalX; - this.top = e.globalY; - }, - dragenter(e){ - prompt.showToast({ - message: 'enter' - }) - }, - dragover(e){ - prompt.showToast({ - message: 'over' - }) - }, - dragleave(e){ - prompt.showToast({ - message: 'leave' - }) - }, - drop(e){ - prompt.showToast({ - message: 'drop' - }) - } - } - ``` - - ![](figures/6.gif) - -5. 手指捏合7+ - - ``` - -
-
-
-
- ``` - - ``` - /* xxx.css */ - .container { - flex-direction: column; - justify-content: center; - align-items: center; - width: 454px; - height: 454px;} - .content{ - width: 400px; - height: 400px; - background-color: aqua; - margin:30px - } - ``` - - ``` - // xxx.js - import prompt from '@system.prompt'; - export default { - pinchstart(e){ - prompt.showToast({ - message: 'pinchstart!!!' - }) - }, - pinchupdate(e){ - prompt.showToast({ - message: 'Two-finger pinch update' - }) - }, - pinchend(e){ - prompt.showToast({ - message: 'Finished with two fingers pinching' - }) - }, - pinchcancel(e){ - prompt.showToast({ - message: 'Finger pinching is interrupted' - }) - } - } - ``` +## 子组件 - ![](figures/5.gif) +支持。 +## 属性 + +支持[通用属性](../arkui-js/js-components-common-attributes.md)。 + + +## 样式 + +除支持[组件通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| flex-direction | string | row | 否 | flex容器主轴方向。可选项有:
- column:垂直方向从上到下。
- row:水平方向从左到右。 | +| flex-wrap | string | nowrap | 否 | flex容器是单行还是多行显示,该值暂不支持动态修改。可选项有:
- nowrap:不换行,单行显示。
- wrap:换行,多行显示。 | +| justify-content | string | flex-start | 否 | flex容器当前行的主轴对齐格式。可选项有:
- flex-start:项目位于容器的开头。
- flex-end:项目位于容器的结尾。
- center:项目位于容器的中心。
- space-between:项目位于各行之间留有空白的容器内。
- space-around:项目位于各行之前、之间、之后都留有空白的容器内。
- space-evenly5+:  均匀排列每个元素,每个元素之间的间隔相等。 | +| align-items | string | stretch
| 否 | flex容器当前行的交叉轴对齐格式,可选值为:
- stretch:弹性元素在交叉轴方向被拉伸到与容器相同的高度或宽度。
- flex-start:元素向交叉轴起点对齐。
- flex-end:元素向交叉轴终点对齐。
- center:元素在交叉轴居中。 | +| align-content | string | flex-start | 否 | 交叉轴中有额外的空间时,多行内容对齐格式,可选值为:
- flex-start:所有行从交叉轴起点开始填充。第一行的交叉轴起点边和容器的交叉轴起点边对齐。接下来的每一行紧跟前一行。
- flex-end:所有行从交叉轴末尾开始填充。最后一行的交叉轴终点和容器的交叉轴终点对齐。同时所有后续行与前一个对齐。
- center:所有行朝向容器的中心填充。每行互相紧挨,相对于容器居中对齐。容器的交叉轴起点边和第一行的距离相等于容器的交叉轴终点边和最后一行的距离。
- space-between:所有行在容器中平均分布。相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的边对齐。
- space-around:所有行在容器中平均分布,相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的距离是相邻两行间距的一半。 | +| display | string | flex | 否 | 确定该元素视图框的类型,该值暂不支持动态修改。可选值为:
- flex:弹性布局
- grid:网格布局
- none:不渲染此元素 | +| grid-template-[columns\|rows] | string | 1行1列 | 否 | 用于设置当前网格布局行和列的数量,不设置时默认1行1列,仅当display为grid时生效。
示例:如设置grid-template-columns为:
- 50px 100px 60px:分三列,第一列50px,第二列100px,第三列60px;
- 1fr 1fr 2fr:分三列,将父组件允许的宽分为4等份,第一列占1份,第二列占一份,第三列占2份;
- 30% 20% 50%:分三列,将父组件允许的宽为基准,第一列占30%,第二列占20%,第三列占50%;
- repeat(2,100px):分两列,第一列100px,第二列100px;
- repeat(auto-fill,100px)5+:按照每列100px的大小和交叉轴大小计算最大正整数重复次数,按照该重复次数布满交叉轴;
- auto 1fr 1fr:分三列,第一列自适应内部子组件所需宽度,剩余空间分为两等份,第二列占一份,第三列占一份。 | +| grid-[columns\|rows]-gap | <length> | 0 | 否 | 用于设置行与行的间距或者列与列的间距,也可以支持通过grid-gap设置相同的行列间距,仅当display为grid时生效。 | +| grid-row-[start\|end] | number | - | 否 | 用于设置当前元素在网格布局中的起止行号,仅当父组件display样式为grid时生效(仅div支持display样式设置为grid)。 | +| grid-column-[start\|end] | number | - | 否 | 用于设置当前元素在网格布局中的起止列号,仅当父组件display样式为grid时生效(仅div支持display样式设置为grid)。 | +| grid-auto-flow5+ | string | - | 否 | 使用框架自动布局算法进行网格的布局,可选值为:
- row:逐行填充元素,如果行空间不够,则新增行;
- column:逐列填充元素,如果列空间不够,则新增列。 | +| overflow6+ | string | visible | 否 | 设置元素内容区超过元素本身大小时的表现形式。
- visible:多个子元素内容超过元素大小时,显示在元素外面;
- hidden:元素内容超过元素大小时,进行裁切显示;
- scroll:元素内容超过元素大小时,进行滚动显示并展示滚动条(当前只支持纵向)。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> overflow: scroll样式需要元素设置固定的大小,默认滚动方向与容器方向一致。 | +| align-items6+ | string | - | 否 | 设置容器中元素交叉轴上的对齐方式:
- stretch:Flex容器内容在交叉轴方向被拉伸到与容器相同的高度或宽度;
- flex-start:Flex布局容器内元素向交叉轴起点对齐;
- flex-end:Flex布局容器内元素向交叉轴终点对齐;
- center:Flex布局容器内元素在交叉轴居中对齐;
- baseline:如Flex布局纵向排列,则该值与'flex-start'等效。横向布局时,内容元素存在文本时按照文本基线对齐,否则底部对齐。 | +| scrollbar-color6+ | <color> | - | 否 | 设置滚动条的颜色。 | +| scrollbar-width6+ | <length> | - | 否 | 设置滚动条的宽度。 | +| overscroll-effect6+ | string | - | 否 | 设置滚动边缘效果,可选值为:
- spring:弹性物理动效,滑动到边缘后可以根据初始速度或通过触摸事件继续滑动一段距离,松手后回弹;
- fade:渐隐物理动效,滑动到边缘后展示一个波浪形的渐隐,根据速度和滑动距离的变化渐隐也会发送一定的变化;
- none:滑动到边缘后无效果 | + + +## 事件 + + + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| reachstart6+ | - | 当页面滑动到最开始的点时触发的事件回调,当flex-direction: row时才会触发。 | +| reachend6+ | - | 当页面滑动到最末尾的点时触发的事件回调,当flex-direction: row时才会触发。 | +| reachtop6+ | - | 当页面滑动到最上部的点时触发的事件回调,当flex-direction: column时才会触发。 | +| reachbottom6+ | - | 当页面滑动到最下部的点时触发的事件回调,当flex-direction: column时才会触发。 | + +## 方法 + +除支持[通用方法](../reference/arkui-js/js-components-common-methods.md)外,还支持如下方法: + +| 名称 | 参数 | 返回值 | 描述 | +| -------- | -------- | -------- | -------- | +| getScrollOffset6+ | - | ScrollOffset | 获取元素内容的滚动偏移。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 需要设置overflow样式为scroll。 | +| scrollBy6+ | ScrollParam | - | 指定元素内容的滚动偏移。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 需要设置overflow样式为scroll。 | + +**表1** ScrollOffset6+ + +| 名称 | 类型 | 描述 | +| -------- | -------- | -------- | +| x | number | 在x轴方向的偏移,单位为px。 | +| y | number | 在y轴方向的偏移,单位为px。 | + +**表2** ScrollParam6+ + +| 名称 | 类型 | 描述 | +| -------- | -------- | -------- | +| dx | number | 水平方向滑动的偏移量,单位px。 | +| dy | number | 垂直方向滑动的偏移量,单位px。 | +| smooth | boolean | 是否平滑处理。 | + + +## 示例 + +1. Flex样式 + ``` + +
+
+
+
+
+
+
+ ``` + + ``` + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 454px; + height: 454px; + } + .flex-box { + justify-content: space-around; + align-items: center; + width: 400px; + height: 140px; + background-color: #ffffff; + } + .flex-item { + width: 120px; + height: 120px; + border-radius: 16px; + } + .color-primary { + background-color: #007dff; + } + .color-warning { + background-color: #ff7500; + } + .color-success { + background-color: #41ba41; + } + ``` + + ![zh-cn_image_0000001127285076](figures/zh-cn_image_0000001127285076.png) + +2. Flex Wrap样式 + ``` + +
+
+
+
+
+
+
+ ``` + + ``` + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 454px; + height: 454px; + } + .flex-box { + justify-content: space-around; + align-items: center; + flex-wrap: wrap; + width: 300px; + height: 250px; + background-color: #ffffff; + } + .flex-item { + width: 120px; + height: 120px; + border-radius: 16px; + } + .color-primary { + background-color: #007dff; + } + .color-warning { + background-color: #ff7500; + } + .color-success { + background-color: #41ba41; + } + ``` + + ![zh-cn_image_0000001213396721](figures/zh-cn_image_0000001213396721.png) + +3. Grid样式 + + ``` + +
+
+
+
+
+
+ ``` + + ``` + /* xxx.css */ + .common { + width: 400px; + height: 400px; + background-color: #ffffff; + align-items: center; + justify-content: center; + margin: 24px; + } + .grid-parent { + display: grid; + grid-template-columns: 35% 35%; + grid-columns-gap: 24px; + grid-rows-gap: 24px; + grid-template-rows: 35% 35%; + } + .grid-child { + width: 100%; + height: 100%; + border-radius: 8px; + } + .grid-left-top { + grid-row-start: 0; + grid-column-start: 0; + grid-row-end: 0; + grid-column-end: 0; + background-color: #3f56ea; + } + .grid-left-bottom { + grid-row-start: 1; + grid-column-start: 0; + grid-row-end: 1; + grid-column-end: 0; + background-color: #00aaee; + } + .grid-right-top { + grid-row-start: 0; + grid-column-start: 1; + grid-row-end: 0; + grid-column-end: 1; + background-color: #00bfc9; + } + .grid-right-bottom { + grid-row-start: 1; + grid-column-start: 1; + grid-row-end: 1; + grid-column-end: 1; + background-color: #47cc47; + } + ``` + + ![zh-cn_image_0000001213276619](figures/zh-cn_image_0000001213276619.png) + +4. 拖拽7+ + ``` + +
+
+
+
+ ``` + + ``` + /* xxx.css */ + .container { + flex-direction: column; + } + .content{ + width: 200px; + height: 200px; + background-color: red; + } + ``` + + ``` + // xxx.js + import prompt from '@system.prompt'; + export default { + data:{ + left:0, + top:0, + }, + dragstart(e){ + prompt.showToast({ + message: 'Start to be dragged' + }) + }, + drag(e){ + this.left = e.globalX; + this.top = e.globalY; + }, + dragend(e){ + prompt.showToast({ + message: 'End Drag' + }) + }, + } + ``` + + ![zh-cn_image_0000001213284927](figures/zh-cn_image_0000001213284927.gif) + + ``` + +
+
+
+
+
+ ``` + + ``` + /* xxx.css */ + .container { + flex-direction: column; + width: 100%; + position: relative; + max-width: 100%; + } + .content{ + width: 200px; + height: 200px; + background-color: red; + position: absolute; + } + ``` + + ``` + // xxx.js + import prompt from '@system.prompt'; + export default { + data:{ + left:0, + top:0, + }, + drag(e){ + this.left = e.globalX; + this.top = e.globalY; + }, + dragenter(e){ + prompt.showToast({ + message: 'enter' + }) + }, + dragover(e){ + prompt.showToast({ + message: 'over' + }) + }, + dragleave(e){ + prompt.showToast({ + message: 'leave' + }) + }, + drop(e){ + prompt.showToast({ + message: 'drop' + }) + } + } + ``` + + ![zh-cn_image_0000001168005276](figures/zh-cn_image_0000001168005276.gif) + +5. 手指捏合7+ + ``` + +
+
+
+
+ ``` + + ``` + /* xxx.css */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; + width: 454px; + height: 454px;} + .content{ + width: 400px; + height: 400px; + background-color: aqua; + margin:30px + } + ``` + + ``` + // xxx.js + import prompt from '@system.prompt'; + export default { + pinchstart(e){ + prompt.showToast({ + message: 'pinchstart!!!' + }) + }, + pinchupdate(e){ + prompt.showToast({ + message: 'Two-finger pinch update' + }) + }, + pinchend(e){ + prompt.showToast({ + message: 'Finished with two fingers pinching' + }) + }, + pinchcancel(e){ + prompt.showToast({ + message: 'Finger pinching is interrupted' + }) + } + } + ``` + + ![zh-cn_image_0000001168440692](figures/zh-cn_image_0000001168440692.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-form.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-form.md index a8923bd74431a19768d72bf54fa5fa90a55d794b..6c5360b474d06233a65fb3959659baf2a873cef3 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-form.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-form.md @@ -1,78 +1,53 @@ -# form +# form + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 6开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 表单容器,支持容器内input元素的内容提交和重置。 -## 权限列表 + +## 权限列表 无 -## 子组件 + +## 子组件 支持。 -## 属性 - -支持[通用属性](js-components-common-attributes.md)。 - -## 样式 - -支持[组件通用样式](js-components-common-styles.md)。 - -## 事件 - -处支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

submit

-

FormResult

-

点击提交按钮,进行表单提交时,触发该事件。

-

reset

-

-

-

点击重置按钮后,触发该事件。

-
- -**表 1** FormResult - - - - - - - - - - - - -

名称

-

类型

-

描述

-

value

-

Object

-

input元素的name和value的值。

-
- -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 + +## 属性 + +支持[通用属性](../arkui-js/js-components-common-attributes.md)。 + + +## 样式 + +支持[组件通用样式](../arkui-js/js-components-common-styles.md)。 + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| submit | FormResult | 点击提交按钮,进行表单提交时,触发该事件。 | +| reset | - | 点击重置按钮后,触发该事件。 | + +**表1** FormResult + +| 名称 | 类型 | 描述 | +| -------- | -------- | -------- | +| value | Object | input元素的name和value的值。 | + + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -105,5 +80,4 @@ export default{ } ``` -![](figures/001.gif) - +![zh-cn_image_0000001180658376](figures/zh-cn_image_0000001180658376.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item-group.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item-group.md index ec3bb6aca1c56ac99a0831a20d279fcad1f8ed65..89b93114ef1b03e466d2b2bb42cbd6f8e90d159a 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item-group.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item-group.md @@ -1,140 +1,65 @@ -# list-item-group +# list-item-group -<[list](js-components-container-list.md)\>的子组件,用来展示分组,宽度默认充满list组件。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -- 使用该组件时父元素list组件的样式columns必须为1,否则功能异常。 -- 由于父元素list组件的align-items默认样式为stretch,该组件宽度默认充满list组件。设置父元素list组件的align-items样式为非stretch来生效自定义宽度。 +<[list](../arkui-js/js-components-container-list.md)>的子组件,用来展示分组,宽度默认充满list组件。 -## 权限列表 + +- 使用该组件时父元素list组件的样式columns必须为1,否则功能异常。 + +- 由于父元素list组件的align-items默认样式为stretch,该组件宽度默认充满list组件。设置父元素list组件的align-items样式为非stretch来生效自定义宽度。 + +## 权限列表 无 -## 子组件 - -仅支持<[list-item](js-components-container-list-item.md)\>。 - -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

type

-

string

-

default

-

-

list-item-group类型,同一list支持多种type的list-item-group,相同type的list-item-group需要确保渲染后的视图布局也完全相同,当type固定时,使用show属性代替if属性,确保视图布局不变。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 通用属性中的id用来标识一个group。list中相关的函数的入参以及事件的信息皆以此标识一个唯一的group。 - -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

flex-direction

-

string

-

row

-

-

flex容器主轴方向。可选项有:

-
  • column:垂直方向从上到下
  • row:水平方向从左到右
-

justify-content

-

string

-

flex-start

-

-

flex容器当前行的主轴对齐格式。可选项有:

-
  • flex-start:项目位于容器的开头。
  • flex-end:项目位于容器的结尾。
  • center:项目位于容器的中心。
  • space-between:项目位于各行之间留有空白的容器内。
  • space-around:项目位于各行之前、之间、之后都留有空白的容器内。
  • space-evenly5+: 均匀排列每个元素,每个元素之间的间隔相等。
-
- -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

groupclick

-

{ groupid: string }

-

group点击事件。

-

groupid:被点击的group的id。

-

groupcollapse

-

{ groupid: string }

-

group收拢事件。

-

groupid:收拢的group的id。

-

当不输入参数或者groupid为空时收拢所有分组。

-

groupexpand

-

{ groupid: string }

-

group展开事件。

-

groupid:展开的group的id。

-

当不输入参数或者groupid为空时展开所有分组。

-
- -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 + +## 子组件 + +仅支持<[list-item](../arkui-js/js-components-container-list-item.md)>。 + + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string | default | 否 | list-item-group类型,同一list支持多种type的list-item-group,相同type的list-item-group需要确保渲染后的视图布局也完全相同,当type固定时,使用show属性代替if属性,确保视图布局不变。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 通用属性中的id用来标识一个group。list中相关的函数的入参以及事件的信息皆以此标识一个唯一的group。 + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| flex-direction | string | row | 否 | flex容器主轴方向。可选项有:
- column:垂直方向从上到下
- row:水平方向从左到右 | +| justify-content | string | flex-start | 否 | flex容器当前行的主轴对齐格式。可选项有:
- flex-start:项目位于容器的开头。
- flex-end:项目位于容器的结尾。
- center:项目位于容器的中心。
- space-between:项目位于各行之间留有空白的容器内。
- space-around:项目位于各行之前、之间、之后都留有空白的容器内。
- space-evenly5+:  均匀排列每个元素,每个元素之间的间隔相等。 | + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| groupclick | { groupid: string } | group点击事件。
groupid:被点击的group的id。 | +| groupcollapse | { groupid: string } | group收拢事件。
groupid:收拢的group的id。
当不输入参数或者groupid为空时收拢所有分组。 | +| groupexpand | { groupid: string } | group展开事件。
groupid:展开的group的id。
当不输入参数或者groupid为空时展开所有分组。 | + + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -243,5 +168,4 @@ export default { } ``` -![](figures/list6.gif) - +![zh-cn_image_0000001127284978](figures/zh-cn_image_0000001127284978.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item.md index 45606b6518929c62f927c6b73da7784c972ef461..16bec43dd90db69c8e08e18e79b901d62efb93bd 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-list-item.md @@ -1,151 +1,59 @@ -# list-item +# list-item -<[list](js-components-container-list.md)\>的子组件,用来展示列表具体item。由于父元素list组件的align-items默认样式为stretch,该组件宽度默认充满list组件。设置父元素list组件的align-items样式为非stretch来生效自定义宽度。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 +<[list](../arkui-js/js-components-container-list.md)>的子组件,用来展示列表具体item。由于父元素list组件的align-items默认样式为stretch,该组件宽度默认充满list组件。设置父元素list组件的align-items样式为非stretch来生效自定义宽度。 + +## 权限列表 无 -## 子组件 + +## 子组件 支持单个子组件。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

type

-

string

-

default

-

-

list-item类型,默认值为default,同一list中可以包含多种type的list-item,相同type的list-item需要确保渲染后的视图布局也相同,如果type固定,则使用show属性代替if属性,确保视图布局不变。

-

primary

-

boolean

-

false

-

-

设置为true表示该item是group中的主item,即收拢时显示的item。如果有多个primary,以第一个为准。如果没有标记为primary的item,则以第一个item为主item。

-

section

-

string

-

-

-

-

当前item的匹配字符串,如不设置则为空。不支持动态修改。group内只有主item设置有效。

-

sticky

-

string

-

none

-

-

设置当前item是否为吸顶item以及其吸顶消失的效果,当前仅支持纵向list,group内部的item不可吸顶,设置该属性无效。

-
  • none:当前item不吸顶。
  • normal:当前item吸顶,消失效果滑动消失。
  • opacity:当前item吸顶,消失效果渐隐消失,仅在智能穿戴上支持。
-

clickeffect5+

-

boolean

-

true

-

-

设置当前item是否有点击动效。

-
  • false:item点击时无点击动效。
  • true:item点击时有点击动效。
-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

column-span

-

<number>

-

1

-

-

当前的list-item需要在list中占据的列的数量,默认占一列,仅在list为多列时生效。

-
- -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - -

名称

-

参数

-

描述

-

sticky

-

{ state: boolean }

-

吸顶组件回调事件。

-

value: false表示当前item处于非吸顶状态;

-

value: true表示当前item处于吸顶状态;

-

说明:仅当item设置sticky属性时支持注册此事件。

-
- -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 - -详见[List示例](js-components-container-list.md#示例)。 +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string | default | 否 | list-item类型,默认值为default,同一list中可以包含多种type的list-item,相同type的list-item需要确保渲染后的视图布局也相同,如果type固定,则使用show属性代替if属性,确保视图布局不变。 | +| primary | boolean | false | 否 | 设置为true表示该item是group中的主item,即收拢时显示的item。如果有多个primary,以第一个为准。如果没有标记为primary的item,则以第一个item为主item。 | +| section | string | - | 否 | 当前item的匹配字符串,如不设置则为空。不支持动态修改。group内只有主item设置有效。 | +| sticky | string | none | 否 | 设置当前item是否为吸顶item以及其吸顶消失的效果,当前仅支持纵向list,group内部的item不可吸顶,设置该属性无效。
- none:当前item不吸顶。
- normal:当前item吸顶,消失效果滑动消失。
- opacity:当前item吸顶,消失效果渐隐消失,仅在智能穿戴上支持。 | +| clickeffect5+ | boolean | true | 否 | 设置当前item是否有点击动效。
- false:item点击时无点击动效。
- true:item点击时有点击动效。 | + + +## 样式 + + + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| column-span | <number> | 1 | 否 | 当前的list-item需要在list中占据的列的数量,默认占一列,仅在list为多列时生效。 | + + +## 事件 + + + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| sticky | { state: boolean } | 吸顶组件回调事件。
value: false表示当前item处于非吸顶状态;
value: true表示当前item处于吸顶状态;
说明:仅当item设置sticky属性时支持注册此事件。 | + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 + +详见[List示例](../arkui-js/js-components-container-list.md#示例)。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md index 620ba233854166ba77682590d43ffcab6bc0cc4e..c2fb21c57dddff95a9ea352ed5af449da408b7b1 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-list.md @@ -1,674 +1,155 @@ -# list +# list + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 列表包含一系列相同宽度的列表项。适合连续、多行呈现同类数据,例如图片和文本。 -## 权限列表 +## 权限列表 无 -## 子组件 -仅支持<[list-item-group](js-components-container-list-item-group.md)\>和<[list-item](js-components-container-list-item.md)\>。 +## 子组件 + +仅支持<[list-item-group](../arkui-js/js-components-container-list-item-group.md)>和<[list-item](../arkui-js/js-components-container-list-item.md)>。 + -## 属性 +## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

scrollpage

-

boolean

-

false

-

-

设置为true时,将 list 顶部页面中非 list 部分随 list 一起滑出可视区域,当list方向为row时,不支持此属性。

-

cachedcount

-

number

-

0

-

-

长列表延迟加载时list-item最少缓存数量。

-

可视区域外缓存的list-item数量少于该值时,会触发requestitem事件。

-

scrollbar

-

string

-

off

-

-

侧边滑动栏的显示模式(当前只支持纵向):

-
  • off:不显示。
  • auto:按需显示(触摸时显示,2s后消失)。
  • on:常驻显示。
-

scrolleffect

-

string

-

spring

-

-

滑动效果,目前支持如下滑动效果:

-
  • spring:弹性物理动效,滑动到边缘后可以根据初始速度或通过触摸事件继续滑动一段距离,松手后回弹。
  • fade:渐隐物理动效,滑动到边缘后展示一个波浪形的渐隐,根据速度和滑动距离的变化渐隐也会发送一定的变化。
  • no:滑动到边缘后无效果。
-

indexer

-

boolean | Array<string>

-

false

-

-

是否展示侧边栏快速字母索引栏。设置为true或者自定义索引时,索引栏会显示在列表右边界处。示例:

-

"indexer" : "true"表示使用默认字母索引表。

-

"indexer" : "false"表示无索引。

-

"indexer" : ['#',‘1’,'2',‘3’,'4',‘5’,'6',‘7’,'8']表示自定义索引表。自定义时"#"必须要存在。

-
说明:
  • indexer属性生效需要flex-direction属性配合设置为column,且columns属性设置为1。
  • 点击索引条进行列表项索引需要list-item子组件配合设置相应的section属性
-
-

indexercircle5+

-

boolean

-

-

-

-

是否为环形索引。

-

穿戴设备默认为true,其他为false。indexer为false时不生效。

-

indexermulti5+

-

boolean

-

false

-

-

是否开启索引条多语言功能。

-

indexer为false时不生效。

-

indexerbubble5+

-

boolean

-

true

-

-

是否开启索引切换的气泡提示。

-

indexer为false时不生效。

-

divider5+

-

boolean

-

false

-

-

item是否自带分隔线。

-

其样式参考样式列表的divider-color、divider-height、divider-length、divider-origin。

-

shapemode

-

string

-

default

-

-

侧边滑动栏的形状类型。

-
  • default:不指定,跟随主题;
  • rect:矩形;
  • round:圆形。
-

updateeffect

-

boolean

-

false

-

-

用于设置当list内部的item发生删除或新增时是否支持动效。

-
  • false:新增删除item时无过渡动效。
  • true:新增删除item时播放过程动效。
-

chainanimation5+

-

boolean

-

false

-

-

用于设置当前list是否启用链式联动动效,开启后列表滑动以及顶部和底部拖拽时会有链式联动的效果。链式联动效果:list内的list-item间隔一定距离,在基本的滑动交互行为下,主动对象驱动从动对象进行联动,驱动效果遵循弹簧物理动效。

-
  • false:不启用链式联动
  • true:启用链式联动
    说明:
    • 不支持动态修改。
    • 如同时配置了indexer,链式动效不生效。
    • 如配置了链式动效,list-item的sticky不生效。
    -
    -
-

initialindex

-

number

-

0

-

-

用于设置当前List初次加载时视口起始位置显示的item,默认为0,即显示第一个item,如设置的序号超过了最后一个item的序号,则设置不生效,当同时设置了initialoffset属性时,当前属性不生效。当indexer为true或者scrollpage为true时,不生效。

-

initialoffset

-

<length>

-

0

-

-

用于设置当前List初次加载时视口的起始偏移量,偏移量无法超过当前List可滑动的范围,如果超过会被截断为可滑动范围的极限值。当indexer为true或者scrollpage为true时,不生效。

-

selected5+

-

string

-

-

-

-

指定当前列表中被选中激活的项,可选值为list-item的section属性值。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| scrollpage | boolean | false | 否 | 设置为true时,将 list 顶部页面中非 list 部分随 list 一起滑出可视区域,当list方向为row时,不支持此属性。 | +| cachedcount | number | 0 | 否 | 长列表延迟加载时list-item最少缓存数量。
可视区域外缓存的list-item数量少于该值时,会触发requestitem事件。 | +| scrollbar | string | off | 否 | 侧边滑动栏的显示模式(当前只支持纵向):
- off:不显示。
- auto:按需显示(触摸时显示,2s后消失)。
- on:常驻显示。 | +| scrolleffect | string | spring | 否 | 滑动效果,目前支持如下滑动效果:
- spring:弹性物理动效,滑动到边缘后可以根据初始速度或通过触摸事件继续滑动一段距离,松手后回弹。
- fade:渐隐物理动效,滑动到边缘后展示一个波浪形的渐隐,根据速度和滑动距离的变化渐隐也会发送一定的变化。
- no:滑动到边缘后无效果。 | +| indexer | boolean \| Array<string> | false | 否 | 是否展示侧边栏快速字母索引栏。设置为true或者自定义索引时,索引栏会显示在列表右边界处。示例:
"indexer" : "true"表示使用默认字母索引表。
"indexer" : "false"表示无索引。
"indexer" : ['\#',‘1’,'2',‘3’,'4',‘5’,'6',‘7’,'8']表示自定义索引表。自定义时"\#"必须要存在。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - indexer属性生效需要flex-direction属性配合设置为column,且columns属性设置为1。

> - 点击索引条进行列表项索引需要list-item子组件配合设置相应的[section属性](../arkui-js/js-components-container-list-item.md#属性)。 | +| indexercircle5+ | boolean | - | 否 | 是否为环形索引。
穿戴设备默认为true,其他为false。indexer为false时不生效。 | +| indexermulti5+ | boolean | false | 否 | 是否开启索引条多语言功能。
indexer为false时不生效。 | +| indexerbubble5+ | boolean | true | 否 | 是否开启索引切换的气泡提示。
indexer为false时不生效。 | +| divider5+ | boolean | false | 否 | item是否自带分隔线。
其样式参考样式列表的divider-color、divider-height、divider-length、divider-origin。 | +| shapemode | string | default | 否 | 侧边滑动栏的形状类型。
- default:不指定,跟随主题;
- rect:矩形;
- round:圆形。 | +| updateeffect | boolean | false | 否 | 用于设置当list内部的item发生删除或新增时是否支持动效。
- false:新增删除item时无过渡动效。
- true:新增删除item时播放过程动效。 | +| chainanimation5+ | boolean | false | 否 | 用于设置当前list是否启用链式联动动效,开启后列表滑动以及顶部和底部拖拽时会有链式联动的效果。链式联动效果:list内的list-item间隔一定距离,在基本的滑动交互行为下,主动对象驱动从动对象进行联动,驱动效果遵循弹簧物理动效。
- false:不启用链式联动
- true:启用链式联动
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > - 不支持动态修改。
  > - 如同时配置了indexer,链式动效不生效。
  > - 如配置了链式动效,list-item的sticky不生效。 | +| initialindex | number | 0 | 否 | 用于设置当前List初次加载时视口起始位置显示的item,默认为0,即显示第一个item,如设置的序号超过了最后一个item的序号,则设置不生效,当同时设置了initialoffset属性时,当前属性不生效。当indexer为true或者scrollpage为true时,不生效。 | +| initialoffset | <length> | 0 | 否 | 用于设置当前List初次加载时视口的起始偏移量,偏移量无法超过当前List可滑动的范围,如果超过会被截断为可滑动范围的极限值。当indexer为true或者scrollpage为true时,不生效。 | +| selected5+ | string | - | 否 | 指定当前列表中被选中激活的项,可选值为list-item的section属性值。 | -## 样式 -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: +## 样式 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

divider-color5+

-

<color>

-

transparent

-

-

item分隔线颜色,仅当list的divider属性为true时生效。

-

divider-height5+

-

<length>

-

1

-

-

item分隔线高度,仅当list的divider属性为true时生效。

-

divider-length5+

-

<length>

-

主轴宽度

-

-

item分隔线长度,不设置时最大长度为主轴宽度,具体长度取决于divider-origin,仅当list的divider属性为true时生效。

-

divider-origin5+

-

<length>

-

0

-

-

item分隔线相对于item主轴起点位置的偏移量,仅当list的divider属性为true时生效。

-

flex-direction

-

string

-

-

column

-

-

设置flex容器主轴的方向,指定flex项如何放置在flex容器中,可选值为:

-
  • column:主轴为纵向。
  • row:主轴为横向。
-

其他组件默认值为row,在list组件中默认值为column。

-

columns

-

number

-

1

-

-

list交叉轴方向的显示列数,默认为1列。

-
说明:

设置多列时,在list交叉轴上进行均分,每一列大小相同。

-
-

align-items

-

string

-

stretch

-

-

list每一列交叉轴上的对齐格式,可选值为:

-
  • stretch:弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
  • flex-start:元素向交叉轴起点对齐。
  • flex-end:元素向交叉轴终点对齐。
  • center:元素在交叉轴居中。
    说明:

    align-items样式作用在每一列的子元素上,列与列之间采用均分方式布局。

    -
    -
-

item-extent

-

<length> | <percentage>

-

-

-

-

设置内部item为固定大小,设置为百分比格式时,指相对于list的视口主轴方向长度的百分比。

-

fade-color

-

<color>

-

grey

-

-

设置渐隐物理动效的颜色。当滑动效果设置为渐隐物理动效时生效。

-

scrollbar-color6+

-

<color>

-

-

-

-

设置滚动条的颜色。

-

scrollbar-width6+

-

<length>

-

-

-

-

设置滚动条的宽度。

-

scrollbar-offset6+

-

<length>

-

0

-

-

设置滚动条距离List默认位置的偏移量,只支持正数,默认位置在List右边缘,可以通过这个偏移量调整滚动条的水平位置,如果滚动条绘制在list外部,而list父组件有裁剪,会导致滚动条被裁剪。

-
+除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: -## 事件 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| divider-color5+ | <color> | transparent | 否 | item分隔线颜色,仅当list的divider属性为true时生效。 | +| divider-height5+ | <length> | 1 | 否 | item分隔线高度,仅当list的divider属性为true时生效。 | +| divider-length5+ | <length> | 主轴宽度 | 否 | item分隔线长度,不设置时最大长度为主轴宽度,具体长度取决于divider-origin,仅当list的divider属性为true时生效。 | +| divider-origin5+ | <length> | 0 | 否 | item分隔线相对于item主轴起点位置的偏移量,仅当list的divider属性为true时生效。 | +| flex-direction | string | column | 否 | 设置flex容器主轴的方向,指定flex项如何放置在flex容器中,可选值为:
- column:主轴为纵向。
- row:主轴为横向。
其他组件默认值为row,在list组件中默认值为column。 | +| columns | number | 1 | 否 | list交叉轴方向的显示列数,默认为1列。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 设置多列时,在list交叉轴上进行均分,每一列大小相同。 | +| align-items | string | stretch | 否 | list每一列交叉轴上的对齐格式,可选值为:
- stretch:弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
- flex-start:元素向交叉轴起点对齐。
- flex-end:元素向交叉轴终点对齐。
- center:元素在交叉轴居中。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > align-items样式作用在每一列的子元素上,列与列之间采用均分方式布局。 | +| item-extent | <length> \| <percentage> | - | 否 | 设置内部item为固定大小,设置为百分比格式时,指相对于list的视口主轴方向长度的百分比。 | +| fade-color | <color> | grey | 否 | 设置渐隐物理动效的颜色。当滑动效果设置为渐隐物理动效时生效。 | +| scrollbar-color6+ | <color> | - | 否 | 设置滚动条的颜色。 | +| scrollbar-width6+ | <length> | - | 否 | 设置滚动条的宽度。 | +| scrollbar-offset6+ | <length> | 0 | 否 | 设置滚动条距离List默认位置的偏移量,只支持正数,默认位置在List右边缘,可以通过这个偏移量调整滚动条的水平位置,如果滚动条绘制在list外部,而list父组件有裁剪,会导致滚动条被裁剪。 | -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

indexerchange5+

-

{ local: booleanValue }

-

多语言索引条切换事件,仅当indexer属性为true,indexermulti为true时生效。booleanValue可能值为true或者false:

-
  • true: 当前展示本地索引。
  • false: 当前展示字母索引。
-

scroll

-

{ scrollX: scrollXValue, scrollY: scrollYValue, scrollState: stateValue }

-

列表滑动的偏移量和状态回调。

-

stateValue: 0表示列表滑动已经停止。

-

stateValue: 1表示列表正在用户触摸状态下滑动。

-

stateValue: 2表示列表正在用户松手状态下滑动。

-

scrollbottom

-

-

-

当前列表已滑动到底部位置。

-

scrolltop

-

-

-

当前列表已滑动到顶部位置。

-

scrollend

-

-

-

列表滑动已经结束。

-

scrolltouchup

-

-

-

手指已经抬起且列表仍在惯性滑动。

-

requestitem

-

-

-

请求创建新的list-item。

-

长列表延迟加载时,可视区域外缓存的list-item数量少于cachedcount时,会触发该事件。

-

rotate7+

-

{ rotateValue: number }

-

返回表冠旋转角度增量值,仅智能穿戴支持。

-
+## 事件 -## 方法 +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: -支持[通用方法](js-components-common-methods.md)外,还支持如下方法: +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| indexerchange5+ | { local: booleanValue } | 多语言索引条切换事件,仅当indexer属性为true,indexermulti为true时生效。booleanValue可能值为true或者false:
- true: 当前展示本地索引。
- false: 当前展示字母索引。 | +| scroll | { scrollX: scrollXValue, scrollY: scrollYValue, scrollState: stateValue } | 列表滑动的偏移量和状态回调。
stateValue: 0表示列表滑动已经停止。
stateValue: 1表示列表正在用户触摸状态下滑动。
stateValue: 2表示列表正在用户松手状态下滑动。 | +| scrollbottom | - | 当前列表已滑动到底部位置。 | +| scrolltop | - | 当前列表已滑动到顶部位置。 | +| scrollend | - | 列表滑动已经结束。 | +| scrolltouchup | - | 手指已经抬起且列表仍在惯性滑动。 | +| requestitem | - | 请求创建新的list-item。
长列表延迟加载时,可视区域外缓存的list-item数量少于cachedcount时,会触发该事件。 | +| rotate7+ | { rotateValue: number } | 返回表冠旋转角度增量值,仅智能穿戴支持。 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

scrollTo

-

{ index: number(指定位置) }

-

list滑动到指定index的item位置。

-

scrollBy

-

ScrollParam

-

触发list滑动一段距离。

-

智慧屏特有方法。

-

scrollTop

-

{ smooth: boolean }

-

smooth缺省为false,表示直接滚动到顶部。

-

smooth为true,表示平滑滚动到顶部。

-

scrollBottom

-

{ smooth: boolean }

-

smooth缺省为false,表示直接滚动到底部。

-

smooth为true,表示平滑滚动到底部。

-

scrollPage

-

{ reverse: boolean, smooth: boolean }

-

reverse缺省值为false,表示下一页,无完整页则滚动到底部。

-

reverse为true,表示上一页,无完整页则滚动到顶部。

-

smooth缺省值为false,表示直接滚动一页。

-

smooth为true,表示平滑滚动一页。

-

scrollArrow

-

{ reverse: boolean, smooth: boolean }

-

reverse缺省值为false,表示向底部方向滑动一段距离,无足够距离则滚动到底部。

-

reverse为true,表示向顶部方向滑动一段距离,无足够距离则滚动到顶部。

-

smooth缺省值为false,表示直接滚动。

-

smooth为true,表示平滑滚动。

-

collapseGroup

-

{ groupid: string }

-

收拢指定的group。

-

groupid:需要收拢的group的id。

-

当groupid未指定时收拢所有的group。

-

expandGroup

-

{ groupid: string }

-

展开指定的group。

-

groupid:需要展开的group的id。

-

当groupid未指定时展开所有的group。

-

currentOffset

-

-

-

返回当前滑动的偏移量。返回值类型是Object,返回值说明请见表2

-
-**表 1** ScrollParam +## 方法 - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

是否必选

-

默认值

-

备注

-

dx

-

number

-

-

0

-

水平方向滑动的偏移量,单位为px。

-

dy

-

number

-

-

0

-

垂直方向滑动的偏移量,单位为px。

-

smooth

-

boolean

-

-

true

-

列表位置跳转时是否有滑动动画。

-
+支持[通用方法](../arkui-js/js-components-common-methods.md)外,还支持如下方法: -**表 2** currentOffset返回对象属性说明 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| scrollTo | { index: number(指定位置) } | list滑动到指定index的item位置。 | +| scrollTop | { smooth: boolean } | smooth缺省为false,表示直接滚动到顶部。
smooth为true,表示平滑滚动到顶部。 | +| scrollBottom | { smooth: boolean } | smooth缺省为false,表示直接滚动到底部。
smooth为true,表示平滑滚动到底部。 | +| scrollPage | { reverse: boolean, smooth: boolean } | reverse缺省值为false,表示下一页,无完整页则滚动到底部。
reverse为true,表示上一页,无完整页则滚动到顶部。
smooth缺省值为false,表示直接滚动一页。
smooth为true,表示平滑滚动一页。 | +| scrollArrow | { reverse: boolean, smooth: boolean } | reverse缺省值为false,表示向底部方向滑动一段距离,无足够距离则滚动到底部。
reverse为true,表示向顶部方向滑动一段距离,无足够距离则滚动到顶部。
smooth缺省值为false,表示直接滚动。
smooth为true,表示平滑滚动。 | +| collapseGroup | { groupid: string } | 收拢指定的group。
groupid:需要收拢的group的id。
当groupid未指定时收拢所有的group。 | +| expandGroup | { groupid: string } | 展开指定的group。
groupid:需要展开的group的id。
当groupid未指定时展开所有的group。 | +| currentOffset | - | 返回当前滑动的偏移量。返回值类型是Object,返回值说明请见表 currentOffset返回对象属性说明。 | + +**表1** currentOffset返回对象属性说明 + +| 名称 | 类型 | 备注 | +| -------- | -------- | -------- | +| x | number | 当前x轴滑动偏移量,单位为px。 | +| y | number | 当前y轴滑动偏移量,单位为px。 | - - - - - - - - - - - - - - - -

名称

-

类型

-

备注

-

x

-

number

-

当前x轴滑动偏移量,单位为px。

-

y

-

number

-

当前y轴滑动偏移量,单位为px。

-
## 示例 ``` -!-- index.hml --> -
- - -
- {{$item.title}} - {{$item.date}} -
-
-
+ +
+ + +
+ {{$item.title}} + {{$item.date}} +
+
+
+
``` ``` // index.js export default { - data: { - todolist: [{ - title: '刷题', - date: '2021-12-31 10:00:00', - }, { - title: '看电影', - date: '2021-12-31 20:00:00', - }], + data: { + todolist: [{ + title: '刷题', + date: '2021-12-31 10:00:00', + }, { + title: '看电影', + date: '2021-12-31 20:00:00', + }], }, } ``` ``` /* index.css */ -.container { - display: flex; - justify-content: center; - align-items: center; - width: 100%; +.container { + display: flex; + justify-content: center; + align-items: center; + width: 100%; height: 100%; } -.todo-wrapper { - width: 100%; +.todo-wrapper { + width: 100%; height: 300px; } -.todo-item { - width: 100%; - height: 120px; +.todo-item { + width: 100%; + height: 120px; justify-content:center; } -.todo-title { - width: 100%; - height: 80px; +.todo-title { + width: 100%; + height: 80px; text-align: center; } ``` -![](figures/list.png) - +![zh-cn_image_0000001185033226](figures/zh-cn_image_0000001185033226.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-panel.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-panel.md index c961452d696b142b659a519dcb391d0e6519d569..e68ebaa5625b4ab2ac95e19af110f116f4989369 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-panel.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-panel.md @@ -1,457 +1,86 @@ -# panel +# panel + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 可滑动面板。提供一种轻量的内容展示的窗口,可方便的在不同尺寸中切换。属于弹出式组件。 -## 子组件 + +## 子组件 支持 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

type

-

string

-

foldable

-

-

设置可滑动面板类型,不可动态变更,可选值有:

-
  • minibar:提供minibar和类全屏展示切换效果。

    -
  • foldable:内容永久展示类,提供大(类全屏)、中(类半屏)、小三种尺寸展示切换效果。

    -
  • temporary:内容临时展示区,提供大(类全屏)、中(类半屏)两种尺寸展示切换效果。

    -
-

mode

-

string

-

full

-

-

设置初始状态,mode参数可选值为:

-
  1. mini:类型为minibar和foldable时,为最小状态;类型为temporary,则不生效。

    -
  2. half: 类型为foldable和temporary时,为类半屏状态;类型为minibar,则不生效。

    -
  3. full: 类全屏状态。

    -
-

dragbar

-

boolean

-

true

-

-

设置是否存在dragbar,true表示存在,false表示不存在。

-

fullheight

-

<length>

-

-

-

-

指定full状态下的高度,默认为屏幕尺寸 - 8px。

-

halfheight

-

<length>

-

-

-

-

指定half状态下的高度,默认为屏幕尺寸的一半。

-

miniheight

-

<length>

-

-

-

-

指定mini状态下的高度,默认为48px。

-
+除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 不支持渲染属性,包括for、if和show。 ->- 不支持focusable和disabled属性。 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | string | foldable | 是 | 设置可滑动面板类型,不可动态变更,可选值有:
- minibar:提供minibar和类全屏展示切换效果。
- foldable:内容永久展示类,提供大(类全屏)、中(类半屏)、小三种尺寸展示切换效果。
- temporary:内容临时展示区,提供大(类全屏)、中(类半屏)两种尺寸展示切换效果。 | +| mode | string | full | 否 | 设置初始状态,mode参数可选值为:
1. mini:类型为minibar和foldable时,为最小状态;类型为temporary,则不生效。
2. half: 类型为foldable和temporary时,为类半屏状态;类型为minibar,则不生效。
3. full: 类全屏状态。 | +| dragbar | boolean | true | 否 | 设置是否存在dragbar,true表示存在,false表示不存在。 | +| fullheight | <length> | - | 否 | 指定full状态下的高度,默认为屏幕尺寸 - 8px。 | +| halfheight | <length> | - | 否 | 指定half状态下的高度,默认为屏幕尺寸的一半。 | +| miniheight | <length> | - | 否 | 指定mini状态下的高度,默认为48px。 | -## 样式 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 不支持渲染属性,包括for、if和show。 +> +> - 不支持focusable和disabled属性。 -仅支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

padding

-

<length>

-

0

-

-
该属性可以有1到4个值:
  • 指定一个值时,该值指定四个边的内边距。

    -
  • 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。

    -
  • 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。

    -
  • 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。

    -
-
-

padding-[left|top|right|bottom]

-

<length>

-

0

-

-

设置左、上、右、下内边距属性。

-

padding-[start|end]

-

<length>

-

0

-

-

设置起始和末端内边距属性。

-

margin

-

<length>

-

0

-

-

使用简写属性设置所有的外边距属性,该属性可以有1到4个值。

-
  • 只有一个值时,这个值会被指定给全部的四个边。

    -
  • 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。

    -
  • 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。

    -
  • 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。

    -
-

margin-[left|top|right|bottom]

-

<length>

-

0

-

-

设置左、上、右、下外边距属性。

-

margin-[start|end]

-

<length>

-

0

-

-

设置起始和末端外边距属性。

-

border

-

-

-

0

-

-

使用简写属性设置所有的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置时,各属性值为默认值。

-

border-style

-

string

-

solid

-

-

使用简写属性设置所有边框的样式,可选值为:

-
  • dotted:显示为一系列圆点,圆点半径为border-width的一半。
  • dashed:显示为一系列短的方形虚线。
-
  • solid:显示为一条实线。
-

border-[left|top|right|bottom]-style

-

string

-

solid

-

-

分别设置左、上、右、下四个边框的样式,可选值为dotted、dashed、solid。

-

border-[left|top|right|bottom]

-

-

-

-

-

-

使用简写属性设置对应位置的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置的值为默认值。

-

border-width

-

<length>

-

0

-

-

使用简写属性设置元素的所有边框宽度,或者单独为各边边框设置宽度

-

border-[left|top|right|bottom]-width

-

<length>

-

0

-

-

分别设置左、上、右、下四个边框的宽度。

-

border-color

-

<color>

-

black

-

-

使用简写属性设置元素的所有边框颜色,或者单独为各边边框设置颜色

-

border-[left|top|right|bottom]-color

-

<color>

-

black

-

-

分别设置左、上、右、下四个边框的颜色。

-

border-radius

-

<length>

-

-

-

-

border-radius属性是设置元素的外边框圆角半径。设置border-radius时不能单独设置某一个方向的border-[left|top|right|bottom]-width,border-[left|top|right|bottom]-color ,如果要设置color和width,需要将四个方向一起设置(border-width、border-color)。

-

border-[top|bottom]-[left|right]-radius

-

<length>

-

-

-

-

分别设置左上,右上,右下和左下四个角的圆角半径。

-

background

-

<linear-gradient>

-

-

-

-

仅支持设置渐变样式,与background-color、background-image不兼容。

-

background-color

-

<color>

-

-

-

-

设置背景颜色。

-

background-image

-

string

-

-

-

-

设置背景图片。与background-color、background不兼容;支持本地图片资源地址。

-

background-size

-
  • string
  • <length> <length>
  • <percentage> <percentage>
-

auto

-

-

设置背景图片的大小。

-
  • string可选值:
    • contain:把图像扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
    • cover:把背景图像扩展至足够大,以使背景图像完全覆盖背景区域;背景图像的某些部分也许无法显示在背景定位区域中。
    • auto:保持原图的比例不变。
    -
  • length值参数方式:

    设置背景图像的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。

    -
  • 百分比参数方式:

    以父元素的百分比来设置背景图像的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。

    -
-

background-repeat

-

string

-

repeat

-

-

针对重复背景图像样式进行设置,背景图像默认在水平和垂直方向上重复。

-
  • repeat:在水平轴和竖直轴上同时重复绘制图片。
  • repeat-x:只在水平轴上重复绘制图片。
  • repeat-y:只在竖直轴上重复绘制图片。
  • no-repeat:不会重复绘制图片。
-

background-position

-
  • string string
  • <length> <length>
  • <percentage> <percentage>
-

0px 0px

-

-
  • 关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。
    • left:水平方向上最左侧。
    • right:水平方向上最右侧。
    • top:竖直方向上最顶部。
    • bottom:竖直方向上最底部。
    • center:水平方向或竖直方向上中间位置。
    -
-
  • length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px) 。如果仅规定了一个值,另外一个值将是50%。
  • 百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。
  • 可以混合使用<percentage>和<length>
-

opacity

-

number

-

1

-

-

元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。

-
+## 样式 -## 事件 +仅支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| padding | <length> | 0 | 否 | 该属性可以有1到4个值:
- 指定一个值时,该值指定四个边的内边距。
- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。
- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。
- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | +| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | +| padding-[start\|end] | <length> | 0 | 否 | 设置起始和末端内边距属性。 | +| margin | <length> | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。
- 只有一个值时,这个值会被指定给全部的四个边。
- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。
- 三个值时,第一个值被匹配给上, 第二个值被匹配给左和右,第三个值被匹配给下。
- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | +| margin-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下外边距属性。 | +| margin-[start\|end] | <length> | 0 | 否 | 设置起始和末端外边距属性。 | +| border | - | 0 | 否 | 使用简写属性设置所有的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置时,各属性值为默认值。 | +| border-style | string | solid | 否 | 使用简写属性设置所有边框的样式,可选值为:
- dotted:显示为一系列圆点,圆点半径为border-width的一半。
- dashed:显示为一系列短的方形虚线。
- solid:显示为一条实线。 | +| border-[left\|top\|right\|bottom]-style | string | solid | 否 | 分别设置左、上、右、下四个边框的样式,可选值为dotted、dashed、solid。 | +| border-[left\|top\|right\|bottom] | - | - | 否 | 使用简写属性设置对应位置的边框属性,包含边框的宽度,样式,颜色属性,顺序设置为border-width、border-style、border-color,不设置的值为默认值。 | +| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度,或者单独为各边边框设置宽度。 | +| border-[left\|top\|right\|bottom]-width | <length> | 0 | 否 | 分别设置左、上、右、下四个边框的宽度。 | +| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色,或者单独为各边边框设置颜色。 | +| border-[left\|top\|right\|bottom]-color | <color> | black | 否 | 分别设置左、上、右、下四个边框的颜色。 | +| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。设置border-radius时不能单独设置某一个方向的border-[left\|top\|right\|bottom]-width,border-[left\|top\|right\|bottom]-color ,如果要设置color和width,需要将四个方向一起设置(border-width、border-color)。 | +| border-[top\|bottom]-[left\|right]-radius | <length> | - | 否 | 分别设置左上,右上,右下和左下四个角的圆角半径。 | +| background | <linear-gradient> | - | 否 | 仅支持设置[渐变样式](../arkui-js/js-components-common-gradient.md),与background-color、background-image不兼容。 | +| background-color | <color> | - | 否 | 设置背景颜色。 | +| background-image | string | - | 否 | 设置背景图片。与background-color、background不兼容;支持本地图片资源地址。 | +| background-size | - string
- <length> <length>
- <percentage> <percentage> | auto | 否 | 设置背景图片的大小。
- string可选值:
  - contain:把图像扩展至最大尺寸,以使其高度和宽度完全适用内容区域。
  - cover:把背景图像扩展至足够大,以使背景图像完全覆盖背景区域;背景图像的某些部分也许无法显示在背景定位区域中。
  - auto:保持原图的比例不变。
- length值参数方式:
  设置背景图像的高度和宽度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。
- 百分比参数方式:
  以父元素的百分比来设置背景图像的宽度和高度。第一个值设置宽度,第二个值设置高度。如果只设置一个值,则第二个值会被设置为 "auto"。 | +| background-repeat | string | repeat | 否 | 针对重复背景图像样式进行设置,背景图像默认在水平和垂直方向上重复。
- repeat:在水平轴和竖直轴上同时重复绘制图片。
- repeat-x:只在水平轴上重复绘制图片。
- repeat-y:只在竖直轴上重复绘制图片。
- no-repeat:不会重复绘制图片。 | +| background-position | - string string
- <length> <length>
- <percentage> <percentage> | 0px 0px | 否 | - 关键词方式:如果仅规定了一个关键词,那么第二个值为"center"。两个值分别定义水平方向位置和竖直方向位置。
  - left:水平方向上最左侧。
  - right:水平方向上最右侧。
  - top:竖直方向上最顶部。
  - bottom:竖直方向上最底部。
  - center:水平方向或竖直方向上中间位置。
- length值参数方式:第一个值是水平位置,第二个值是垂直位置。 左上角是 0 0。单位是像素 (0px 0px)  。如果仅规定了一个值,另外一个值将是50%。
- 百分比参数方式:第一个值是水平位置,第二个值是垂直位置。左上角是 0% 0%。右下角是 100% 100%。如果仅规定了一个值,另外一个值为50%。
- 可以混合使用<percentage>和<length> | +| opacity | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | + + +## 事件 仅支持如下事件: - - - - - - - - - - -

名称

-

参数

-

描述

-

sizechange

-

{ size: { height: heightLength, width: widthLength }, mode: modeStr }

-

当可滑动面板发生状态变化时触发,mode参数可选值为:

-
  1. mini:类型为minibar和foldable时,处于最小状态;

    -
  2. half: 类型为foldable时,处于类半屏状态;

    -
  3. full: 类全屏状态。

    -
    说明:

    返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。

    -
    -
-
+| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| sizechange | { size: { height: heightLength, width: widthLength }, mode: modeStr } | 当可滑动面板发生状态变化时触发,mode参数可选值为:
1. mini:类型为minibar和foldable时,处于最小状态;
2. half: 类型为foldable时,处于类半屏状态;
3. full: 类全屏状态。
   > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
   > 返回的height值为内容区高度值,当dragbar属性为true时,panel本身的高度值为dragbar高度加上内容区高度。 | + -## 方法 +## 方法 仅支持如下方法: - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

show

-

-

-

弹出panel可滑动面板。

-

close

-

-

-

关闭panel可滑动面板。

-
+| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| show | - | 弹出panel可滑动面板。 | +| close | - | 关闭panel可滑动面板。 | -## 示例 + +## 示例 ``` @@ -529,5 +158,4 @@ export default { } ``` -![](figures/panel6.gif) - +![zh-cn_image_0000001173164785](figures/zh-cn_image_0000001173164785.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-popup.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-popup.md index f38f0c4908afea5d258dad4856b5cb5eb117a4fd..c429f43f6206e954d0ce718eabbaac90f05c119f 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-popup.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-popup.md @@ -1,184 +1,79 @@ -# popup +# popup + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 气泡指示。在点击绑定的控件后会弹出相应的气泡提示来引导用户进行操作。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持单个子组件节点5+。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性:↵ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

target

-

string

-

-

-

-

目标元素的id属性值,不支持动态切换。

-

placement

-

string

-

bottom

-

-

弹出窗口位置。可选值为:

-
  • left:位于目标元素左边;
  • right:位于目标元素右边;
  • top:位于目标元素上边;
  • bottom:位于目标元素下边;
  • topLeft:位于目标元素左上角;
  • topRight:位于目标元素右上角;
  • bottomLeft:位于目标元素左下角;
  • bottomRight:位于目标元素右下角。
-

keepalive5+

-

boolean

-

false

-

-

设置当前popup是否需要保留。设置为true时,点击屏幕区域或者页面切换气泡不会消失,需调用气泡组件的hide方法才可让气泡消失;设置为false时,点击屏幕区域或者页面切换气泡会自动消失。

-

clickable5+

-

boolean

-

true

-

-

popup是否使用点击弹窗,当设置为false时,只支持方法调用显示。

-

arrowoffset5+

-

<length>

-

0

-

-

popup箭头在弹窗处的偏移,默认居中,正值按照语言方向进行偏移,负值相反。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 不支持focusable属性。 - -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

mask-color

-

<color>

-

-

-

-

遮罩层的颜色,默认值为全透明。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 不支持position相关样式。 - -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - -

名称

-

参数

-

描述

-

visibilitychange

-

{ visibility: boolean }

-

当气泡弹出和消失时会触发该回调函数。

-
- -## 方法 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| target | string | - | 是 | 目标元素的id属性值,不支持动态切换。 | +| placement | string | bottom | 否 | 弹出窗口位置。可选值为:
- left:位于目标元素左边;
- right:位于目标元素右边;
- top:位于目标元素上边;
- bottom:位于目标元素下边;
- topLeft:位于目标元素左上角;
- topRight:位于目标元素右上角;
- bottomLeft:位于目标元素左下角;
- bottomRight:位于目标元素右下角。 | +| keepalive5+ | boolean | false | 否 | 设置当前popup是否需要保留。设置为true时,点击屏幕区域或者页面切换气泡不会消失,需调用气泡组件的hide方法才可让气泡消失;设置为false时,点击屏幕区域或者页面切换气泡会自动消失。 | +| clickable5+ | boolean | true | 否 | popup是否使用点击弹窗,当设置为false时,只支持方法调用显示。 | +| arrowoffset5+ | <length> | 0 | 否 | popup箭头在弹窗处的偏移,默认居中,正值按照语言方向进行偏移,负值相反。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 不支持focusable属性。 + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| mask-color | <color> | - | 否 | 遮罩层的颜色,默认值为全透明。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 不支持position相关样式。 + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| visibilitychange | { visibility: boolean } | 当气泡弹出和消失时会触发该回调函数。 | + + +## 方法 仅支持如下方法: - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

show5+

-

-

-

弹出气泡提示。

-

hide5+

-

-

-

取消气泡提示。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->1. popup气泡弹窗属性、样式均不支持动态更新。 ->2. popup气泡弹窗的margin样式是相对于target元素进行生效的,如popup在target元素下方,此时只生效margin-top样式,popup在target元素左上方,此时只生效margin-bottom和margin-right样式。 ->3. popup的border四边样式需一致,若四边设置不一致且圆角为零,则按左、上、右、下的顺序取第一个被设置的样式,否则border不生效。 ->4. popup的target组件的click事件不生效。 - -## 示例 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| show5+ | - | 弹出气泡提示。 | +| hide5+ | - | 取消气泡提示。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 1. popup气泡弹窗属性、样式均不支持动态更新。 +> +> 2. popup气泡弹窗的margin样式是相对于target元素进行生效的,如popup在target元素下方,此时只生效margin-top样式,popup在target元素左上方,此时只生效margin-bottom和margin-right样式。 +> +> 3. popup的border四边样式需一致,若四边设置不一致且圆角为零,则按左、上、右、下的顺序取第一个被设置的样式,否则border不生效。 +> +> 4. popup的target组件的click事件不生效。 + + +## 示例 ``` @@ -232,5 +127,4 @@ export default { } ``` -![](figures/zh-cn_image_0000001178886129.png) - +![zh-cn_image_0000001178886129](figures/zh-cn_image_0000001178886129.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-refresh.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-refresh.md index c026bdcaead2a1a83e35fb552b52a58344cac98e..c931d65811fbc3a27795028578e32a57849ac370 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-refresh.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-refresh.md @@ -1,180 +1,60 @@ -# refresh +# refresh + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 下拉刷新容器。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

offset

-

<length>

-

-

-

-

刷新组件静止时距离父组件顶部的距离。

-

refreshing

-

boolean

-

false

-

-

用于标识刷新组件当前是否正在刷新。

-

type

-

string

-

auto

-

-

设置组件刷新时的动效。两个可选值,不支持动态修改。

-
  • auto: 默认效果,列表界面拉到顶后,列表不移动,下拉后有转圈弹出。
  • pulldown: 列表界面拉到顶后,可以继续往下滑动一段距离触发刷新,刷新完成后有回弹效果(如果子组件含有list,防止下拉效果冲突,需将list的scrolleffect设置为no)。
-

lasttime

-

boolean

-

false

-

-

是否显示上次更新时间,字符串格式为:“上次更新时间:XXXX ”,XXXX 按照时间日期显示规范显示,不可动态修改(建议type为pulldown时使用,固定距离位于内容下拉区域底部,使用时注意offset属性设置,防止出现重叠)。

-

timeoffset6+

-

<length>

-

-

-

-

设置更新时间距离父组件顶部的距离。

-

friction

-

number

-

42

-

-

下拉摩擦系数,取值范围:0-100,数值越大refresh组件跟手性高,数值越小refresh跟手性低。

-
说明:

仅手机、平板和智能穿戴设备支持。

-
-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

background-color

-

<color>

-

white

-

-

用于设置刷新组件的背景颜色。

-

progress-color

-

<color>

-

black

-

-

用于设置刷新组件的loading颜色。

-
- -## 事件 + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| offset | <length> | - | 否 | 刷新组件静止时距离父组件顶部的距离。 | +| refreshing | boolean | false | 否 | 用于标识刷新组件当前是否正在刷新。 | +| type | string | auto | 否 | 设置组件刷新时的动效。两个可选值,不支持动态修改。
- auto: 默认效果,列表界面拉到顶后,列表不移动,下拉后有转圈弹出。
- pulldown: 列表界面拉到顶后,可以继续往下滑动一段距离触发刷新,刷新完成后有回弹效果(如果子组件含有list,防止下拉效果冲突,需将list的scrolleffect设置为no)。 | +| lasttime | boolean | false | 否 | 是否显示上次更新时间,字符串格式为:“上次更新时间:XXXX ”,XXXX 按照时间日期显示规范显示,不可动态修改(建议type为pulldown时使用,固定距离位于内容下拉区域底部,使用时注意offset属性设置,防止出现重叠)。 | +| timeoffset6+ | <length> | - | 否 | 设置更新时间距离父组件顶部的距离。 | +| friction | number | 42 | 否 | 下拉摩擦系数,取值范围:0-100,数值越大refresh组件跟手性高,数值越小refresh跟手性低。 | + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| background-color | <color> | white
| 否 | 用于设置刷新组件的背景颜色。 | +| progress-color | <color> | black
| 否 | 用于设置刷新组件的loading颜色。 | + + +## 事件 仅支持如下事件: - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

refresh

-

{ refreshing: refreshingValue }

-

下拉刷新状态变化时触发。可能值:

-
  • false:当前处于下拉刷新过程中。
  • true:当前未处于下拉刷新过程中。
-

pulldown

-

{ state: string }

-

下拉开始和松手时触发。可能值:

-
  • start:表示开始下拉。
  • end:表示结束下拉。
-
- -## 方法 - -不支持[通用方法](js-components-common-methods.md)。 - -## 示例 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| refresh | { refreshing: refreshingValue } | 下拉刷新状态变化时触发。可能值:
- false:当前处于下拉刷新过程中。
- true:当前未处于下拉刷新过程中。 | +| pulldown | { state: string } | 下拉开始和松手时触发。可能值:
- start:表示开始下拉。
- end:表示结束下拉。 | + + +## 方法 + +不支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -257,5 +137,4 @@ export default { } ``` -![](figures/zh-cn_image_0000001150719520.gif) - +![zh-cn_image_0000001150719520](figures/zh-cn_image_0000001150719520.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-stack.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-stack.md index efeb410e1f73ce35b0e919641377d49468689b03..7cd91997c65a3a4036a23d1a9f290e8c12a2af80 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-stack.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-stack.md @@ -1,32 +1,40 @@ -# stack +# stack + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 堆叠容器,子组件按照顺序依次入栈,后一个子组件覆盖前一个子组件。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持。 -## 属性 -支持[通用属性](js-components-common-attributes.md)。 +## 属性 + +支持[通用属性](../arkui-js/js-components-common-attributes.md)。 + -## 样式 +## 样式 -支持[通用样式](js-components-common-styles.md)。 +支持[通用样式](../arkui-js/js-components-common-styles.md)。 -## 事件 -支持[通用事件](js-components-common-events.md)。 +## 事件 -## 方法 +支持[通用事件](../arkui-js/js-components-common-events.md)。 -支持[通用方法](js-components-common-methods.md)。 +## 方法 -## 示例 +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -68,5 +76,4 @@ } ``` -![](figures/zh-cn_image_0000001127284958.png) - +![zh-cn_image_0000001127284958](figures/zh-cn_image_0000001127284958.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper-item.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper-item.md index be9790a514403b09fde99a0c55258a4bc5bff300..972b8f94f023f1ab3bc9562a905922eca6d58842 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper-item.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper-item.md @@ -1,227 +1,73 @@ -# stepper-item +# stepper-item + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 步骤导航器子组件,作为步骤导航器某一个步骤的内容展示组件。 -## 权限列表 + +## 权限列表 无 -## 子组件 + +## 子组件 支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

label

-

Label

-

-

-

-

自定义步骤导航器底部步骤提示文本按钮属性,不支持动态修改。如果没有定义该属性,步骤导航器在中文语言环境下,使用“返回”和“下一步”文本按钮,在非中文语言环境下,使用“BACK”和“NEXT”文本按钮。针对第一个步骤,没有回退文本按钮,针对最后一个步骤,下一步文本按钮文本使用“开始”(中文语言)或者“START”(非中文语言)。

-
- -**表 1** Label对象定义 - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

描述

-

prevLabel

-

string

-

-

-

步骤导航器底部回退文本按钮的描述文本。

-

nextLabel

-

string

-

-

-

步骤导航器底部下一步文本按钮的描述文本。

-

status

-

string

-

normal

-

步骤导航器当前步骤的初始状态,可选值为:

-
  • normal:正常状态,右侧文本按钮正常显示,可点击进入下一个步骤。
-
  • disabled:不可用状态,右侧文本按钮灰度显示,不可点击进入下一个步骤。
-
  • waiting:等待状态,右侧文本按钮不显示,使用等待进度条,不可点击进入下一个步骤。
-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

color

-

<color>

-

-

-

-

文本颜色。

-

font-size

-

<length>

-

-

-

-

文本大小。

-

allow-scale

-

boolean

-

true

-

-

文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。

-

font-style

-

string

-

normal

-

-

文本字体样式,可选值为:

-
  • normal: 标准的字体样式;
  • italic: 斜体的字体样式。
-

font-weight

-

number|string

-

normal

-

-

文本字体粗细,number类型取值[100, 900]的整数(被100整除),默认为400,取值越大,字体越粗。string类型取值为:lighter、normal、bold、bolder。

-

text-decoration

-

string

-

none

-

-

文本修饰,可选值为:

-
  • underline: 文本下划线修饰。
  • line-through: 穿过文本的修饰线。
  • none: 标准文本。
-

font-family

-

string

-

sans-serif

-

-

字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过自定义字体指定的字体,会被选中作为文本的字体。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 不支持长宽样式,宽和父容器stepper一样,高是父容器stepper减去底部导航按钮的高度。 ->- 不支持posit样式。 - -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

appear

-

-

-

当该步骤出现时触发。

-

disappear

-

-

-

当该步骤消失时触发。

-
- -## 方法 - -不支持[通用方法](js-components-common-methods.md)。 - -## 示例 - -详见[stepper示例](js-components-container-stepper.md)。 +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| label | Label | - | 否 | 自定义步骤导航器底部步骤提示文本按钮属性,不支持动态修改。如果没有定义该属性,步骤导航器在中文语言环境下,使用“返回”和“下一步”文本按钮,在非中文语言环境下,使用“BACK”和“NEXT”文本按钮。针对第一个步骤,没有回退文本按钮,针对最后一个步骤,下一步文本按钮文本使用“开始”(中文语言)或者“START”(非中文语言)。 | + +**表1** Label对象定义 + +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| prevLabel | string | - | 步骤导航器底部回退文本按钮的描述文本。 | +| nextLabel | string | - | 步骤导航器底部下一步文本按钮的描述文本。 | +| status | string | normal | 步骤导航器当前步骤的初始状态,可选值为:
- normal:正常状态,右侧文本按钮正常显示,可点击进入下一个步骤。
- disabled:不可用状态,右侧文本按钮灰度显示,不可点击进入下一个步骤。
- waiting:等待状态,右侧文本按钮不显示,使用等待进度条,不可点击进入下一个步骤。 | + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| color | <color> | - | 否 | 文本颜色。 | +| font-size | <length> | - | 否 | 文本大小。 | +| allow-scale | boolean | true | 否 | 文本尺寸是否跟随系统设置字体缩放尺寸进行放大缩小。 | +| font-style | string | normal | 否 | 文本字体样式,可选值为:
- normal: 标准的字体样式;
- italic: 斜体的字体样式。 | +| font-weight | number\|string | normal | 否 | 文本字体粗细,number类型取值[100, 900]的整数(被100整除),默认为400,取值越大,字体越粗。string类型取值为:lighter、normal、bold、bolder。 | +| text-decoration | string | none | 否 | 文本修饰,可选值为:
- underline: 文本下划线修饰。
- line-through: 穿过文本的修饰线。
- none: 标准文本。 | +| font-family | string | sans-serif | 否 | 字体列表,用逗号分隔,每个字体用字体名或者字体族名设置。列表中第一个系统中存在的或者通过[自定义字体](../arkui-js/js-components-common-customizing-font.md)指定的字体,会被选中作为文本的字体。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 不支持长宽样式,宽和父容器stepper一样,高是父容器stepper减去底部导航按钮的高度。 +> +> - 不支持posit样式。 + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| appear | - | 当该步骤出现时触发。 | +| disappear | - | 当该步骤消失时触发。 | + + +## 方法 + +不支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 + +详见[stepper示例](../arkui-js/js-components-container-stepper.md)。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md index b41c50933e92d8cc97bc7527cc79defa6a8e5532..9013c0a9d49a0eebdaed3f178df6810a89db1676 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md @@ -1,125 +1,64 @@ -# stepper +# stepper + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 步骤导航器。当完成一个任务需要多个步骤时,可以使用步骤导航器展示当前进展。 -## 权限列表 + +## 权限列表 无 -## 子组件 - -仅支持子组件。 - ->![](../../public_sys-resources/icon-note.gif) **说明:** ->步骤导航器内的步骤顺序按照子组件的顺序进行排序。 - -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

描述

-

index

-

number

-

-

-

设置步骤导航器步骤显示第几个stepper-item子组件。

-
- -## 样式 - -支持[通用样式](js-components-common-styles.md)。 - ->![](../../public_sys-resources/icon-note.gif) **说明:** ->stepper组件默认占满父容器大小,建议父组件使用应用窗口大小(或者父组件为根节点)来优化体验。 - -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

finish

-

-

当步骤导航器最后一个步骤完成时触发该事件。

-

skip

-

-

当通过setNextButtonStatus方法设置当前步骤导航器可跳过时,点击右侧跳过按钮触发该事件。

-

change

-

{ prevIndex:prevIndex, index: index}

-

当步骤导航器点击左边或者右边文本按钮进行步骤切换时触发该事件,prevIndex表示老步骤的序号,index表示新步骤的序号。

-

next

-

{ index:index, pendingIndex: pendingIndex }

-

当用户点击下一步按钮时触发该事件,index表示当前步骤序号,pendingIndex表示将于跳转的序号,该事件有返回值,返回值格式为:{ pendingIndex:pendingIndex },可以通过指定pendingIndex来修改下一个步骤使用哪个stepper-item子组件。

-

back

-

{ index:index, pendingIndex: pendingIndex }

-

当用户点击上一步按钮时触发该事件,index表示当前步骤序号,pendingIndex表示将于跳转的序号,该事件有返回值,返回值格式为Object:{ pendingIndex:pendingIndex },可以通过指定pendingIndex来修改上一个步骤使用哪个stepper-item子组件。

-
- -## 方法 - -除支持[通用方法](js-components-common-methods.md)外,支持如下方法: - - - - - - - - - - - -

名称

-

参数

-

描述

-

setNextButtonStatus

-

{ status: string, label: label }

-

设置当前步骤导航器下一步文本按钮的状态,参数中status类型为string,可选值为:

-
  1. normal:正常状态,下一步文本按钮正常显示,可点击进入下一个步骤;
  2. disabled:不可用状态,下一步文本按钮灰度显示,不可点击进入下一个步骤;
  3. waiting:等待状态,下一步文本按钮不显示,使用等待进度条,不可点击进入下一个步骤。
  4. skip:跳过状态,下一步文本按钮显示跳过按钮,点击时会跳过剩下步骤。
-
- -## 示例 + +## 子组件 + +仅支持<stepper-item>子组件。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 步骤导航器内的步骤顺序按照子组件<stepper-item>的顺序进行排序。 + + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 描述 | +| -------- | -------- | -------- | -------- | +| index | number | - | 设置步骤导航器步骤显示第几个stepper-item子组件。 | + + +## 样式 + +支持[通用样式](../arkui-js/js-components-common-styles.md)。 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> stepper组件默认占满父容器大小,建议父组件使用应用窗口大小(或者父组件为根节点)来优化体验。 + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| finish | 无 | 当步骤导航器最后一个步骤完成时触发该事件。 | +| skip | 无 | 当通过setNextButtonStatus方法设置当前步骤导航器可跳过时,点击右侧跳过按钮触发该事件。 | +| change | { prevIndex:prevIndex, index: index} | 当步骤导航器点击左边或者右边文本按钮进行步骤切换时触发该事件,prevIndex表示老步骤的序号,index表示新步骤的序号。 | +| next | { index:index, pendingIndex: pendingIndex } | 当用户点击下一步按钮时触发该事件,index表示当前步骤序号,pendingIndex表示将于跳转的序号,该事件有返回值,返回值格式为:{ pendingIndex:pendingIndex },可以通过指定pendingIndex来修改下一个步骤使用哪个stepper-item子组件。 | +| back | { index:index, pendingIndex: pendingIndex } | 当用户点击上一步按钮时触发该事件,index表示当前步骤序号,pendingIndex表示将于跳转的序号,该事件有返回值,返回值格式为Object:{ pendingIndex:pendingIndex },可以通过指定pendingIndex来修改上一个步骤使用哪个stepper-item子组件。 | + + +## 方法 + +除支持[通用方法](../arkui-js/js-components-common-methods.md)外,支持如下方法: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| setNextButtonStatus | { status: string, label: label } | 设置当前步骤导航器下一步文本按钮的状态,参数中status类型为string,可选值为:
1. normal:正常状态,下一步文本按钮正常显示,可点击进入下一个步骤;
2. disabled:不可用状态,下一步文本按钮灰度显示,不可点击进入下一个步骤;
3. waiting:等待状态,下一步文本按钮不显示,使用等待进度条,不可点击进入下一个步骤。
4. skip:跳过状态,下一步文本按钮显示跳过按钮,点击时会跳过剩下步骤。 | + + +## 示例 ``` @@ -212,5 +151,4 @@ export default { } ``` -![](figures/Video_2021-03-26_154549.gif) - +![zh-cn_image_0000001127125114](figures/zh-cn_image_0000001127125114.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-swiper.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-swiper.md index cfa71c0ab71af766d8068b4dd5eb3493b1867c71..b017870ad7902efcdddb87bb6ca136bc1faefcf8 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-swiper.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-swiper.md @@ -1,318 +1,75 @@ -# swiper +# swiper + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 滑动容器,提供切换子组件显示的能力。 -## 权限列表 +## 权限列表 无 -## 子组件 -支持除之外的子组件。 +## 子组件 + +支持除<list>之外的子组件。 + + +## 属性 -## 属性 +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| index | number | 0 | 否 | 当前在容器中显示的子组件的索引值。 | +| autoplay | boolean | false | 否 | 子组件是否自动播放,自动播放状态下,导航点不可操作5+。 | +| interval | number | 3000 | 否 | 使用自动播放时播放的时间间隔,单位为ms。 | +| indicator | boolean | true | 否 | 是否启用导航点指示器,默认true。 | +| digital5+ | boolean | false | 否 | 是否启用数字导航点,默认为false。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 必须设置indicator时才能生效数字导航点。 | +| indicatordisabled5+ | boolean | false | 否 | 指示器是否禁止用户手势操作,设置为true时,指示器不会响应用户的点击拖拽。 | +| loop | boolean | true | 否 | 是否开启循环滑动。 | +| duration | number | - | 否 | 子组件切换的动画时长。 | +| vertical | boolean | false | 否 | 是否为纵向滑动,纵向滑动时采用纵向的指示器。 | +| cachedsize7+ | number | -1 | 否 | swiper延迟加载时item最少缓存数量。-1表示全部缓存。 | +| scrolleffect7+ | string | spring | 否 | 滑动效果。目前支持如下:
- spring:弹性物理动效,滑动到边缘后可以根据初始速度或通过触摸事件继续滑动一段距离,松手后回弹。
- fade:渐隐物理动效,滑动到边缘后展示一个波浪形的渐隐,根据速度和滑动距离的变化渐隐也会发送一定的变化
- none:滑动到边缘后无效果。
  > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
  > 该属性仅在loop属性为false时生效。 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

index

-

number

-

0

-

-

当前在容器中显示的子组件的索引值。

-

autoplay

-

boolean

-

false

-

-

子组件是否自动播放,自动播放状态下,导航点不可操作5+

-

interval

-

number

-

3000

-

-

使用自动播放时播放的时间间隔,单位为ms。

-

indicator

-

boolean

-

true

-

-

是否启用导航点指示器,默认true。

-

digital5+

-

boolean

-

false

-

-

是否启用数字导航点,默认为false。

-
说明:

必须设置indicator时才能生效数字导航点。

-
-

indicatordisabled5+

-

boolean

-

false

-

-

指示器是否禁止用户手势操作,设置为true时,指示器不会响应用户的点击拖拽。

-

loop

-

boolean

-

true

-

-

是否开启循环滑动。

-

duration

-

number

-

-

-

-

子组件切换的动画时长。

-

vertical

-

boolean

-

false

-

-

是否为纵向滑动,纵向滑动时采用纵向的指示器。

-

cachedsize7+

-

number

-

-1

-

-

swiper延迟加载时item最少缓存数量。-1表示全部缓存。

-

scrolleffect7+

-

string

-

spring

-

-

滑动效果。目前支持如下:

-
  • spring:弹性物理动效,滑动到边缘后可以根据初始速度或通过触摸事件继续滑动一段距离,松手后回弹。
  • fade:渐隐物理动效,滑动到边缘后展示一个波浪形的渐隐,根据速度和滑动距离的变化渐隐也会发送一定的变化
  • none:滑动到边缘后无效果。
    说明:

    该属性仅在loop属性为false时生效。

    -
    -
-
-## 样式 +## 样式 -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

indicator-color

-

<color>

-

-

-

-

导航点指示器的填充颜色。

-

indicator-selected-color

-

<color>

-

#ff007dff

-

-

导航点指示器选中的颜色。

-

indicator-size

-

<length>

-

4px

-

-

导航点指示器的直径大小。

-

indicator-top|left|right|bottom

-

<length> | <percentage>

-

-

-

-

导航点指示器在swiper中的相对位置。

-

next-margin7+

-

<length> | <percentage>

-

-

-

-

后边距,用于露出后一项的一小部分。

-

previous-margin7+

-

<length> | <percentage>

-

-

-

-

前边距,用于露出前一项的一小部分。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| indicator-color | <color> | - | 否 | 导航点指示器的填充颜色。 | +| indicator-selected-color | <color> | \#ff007dff | 否 | 导航点指示器选中的颜色。 | +| indicator-size | <length> | 4px | 否 | 导航点指示器的直径大小。 | +| indicator-top\|left\|right\|bottom | <length> \| <percentage> | - | 否 | 导航点指示器在swiper中的相对位置。 | +| next-margin7+ | <length> \| <percentage> | - | 否 | 后边距,用于露出后一项的一小部分。 | +| previous-margin7+ | <length> \| <percentage> | - | 否 | 前边距,用于露出前一项的一小部分。 | -## 事件 -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: +## 事件 - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ index: currentIndex }

-

当前显示的组件索引变化时触发该事件。

-

rotation

-

{ value: rotationValue }

-

智能穿戴表冠旋转事件触发时的回调。

-

animationfinish7+

-

-

-

动画结束时触发该事件。

-
+除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: -## 方法 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { index: currentIndex } | 当前显示的组件索引变化时触发该事件。 | +| rotation | { value: rotationValue } | 智能穿戴表冠旋转事件触发时的回调。 | +| animationfinish7+ | - | 动画结束时触发该事件。 | -除支持[通用方法](js-components-common-methods.md)外,还支持如下方法: +## 方法 - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

swipeTo

-

{ index: number(指定位置) }

-

切换到index位置的子组件。

-

showNext

-

-

显示下一个子组件。

-

showPrevious

-

-

显示上一个子组件。

-
+除支持[通用方法](../arkui-js/js-components-common-methods.md)外,还支持如下方法: -## 示例 +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| swipeTo | { index: number(指定位置) } | 切换到index位置的子组件。 | +| showNext | 无 | 显示下一个子组件。 | +| showPrevious | 无 | 显示上一个子组件。 | + + +## 示例 ``` @@ -397,5 +154,6 @@ export default { } ``` -![](figures/4-0.gif) +![zh-cn_image_0000001167823326](figures/zh-cn_image_0000001167823326.gif) + diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-bar.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-bar.md index 6234c0678915521727aa08dbf301aeaf5d1057db..1d3a494dd2077d1fedccd6e3a07bcf07f97399b8 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-bar.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-bar.md @@ -1,59 +1,44 @@ -# tab-bar +# tab-bar -<[tabs](js-components-container-tabs.md)\>的子组件,用来展示tab的标签区,子组件排列方式为横向排列。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 +<[tabs](../arkui-js/js-components-container-tabs.md)>的子组件,用来展示tab的标签区,子组件排列方式为横向排列。 + +## 权限列表 无 -## 子组件 + +## 子组件 支持。 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| mode | string | scrollable | 否 | 设置组件宽度的可延展性。可选值为:
- scrollable:子组件宽度为实际设置的宽度,当宽度之和(包括margin边距)大于tab-bar的宽度时,子组件可以横向滑动。
- fixed:子组件宽度均分tab-bar的宽度。 | + + +## 样式 - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

mode

-

string

-

scrollable

-

-

设置组件宽度的可延展性。可选值为:

-
  • scrollable:子组件宽度为实际设置的宽度,当宽度之和(包括margin边距)大于tab-bar的宽度时,子组件可以横向滑动。
  • fixed:子组件宽度均分tab-bar的宽度。
-
+支持[通用样式](../arkui-js/js-components-common-styles.md)。 -## 样式 -支持[通用样式](js-components-common-styles.md)。 +## 事件 -## 事件 +支持[通用事件](../arkui-js/js-components-common-events.md)。 -支持[通用事件](js-components-common-events.md)。 -## 方法 +## 方法 -支持[通用方法](js-components-common-methods.md)。 +支持[通用方法](../arkui-js/js-components-common-methods.md)。 -## 示例 -详见[tabs示例](js-components-container-tabs.md#section14993155318710)。 +## 示例 +详见[tabs示例](../arkui-js/js-components-container-tabs.md#示例)。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-content.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-content.md index 0fc30eb91f185f8feac2191e068dcd32324bf753..fe4a72df6b7c96013d4ce252e914d9a06034c83a 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-content.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-tab-content.md @@ -1,54 +1,39 @@ -# tab-content +# tab-content -<[tabs](js-components-container-tabs.md)\>的子组件,用来展示tab的内容区,高度默认充满tabs剩余空间,子组件排列方式为横向排列,当作为容器组件的子元素时在主轴方向需要设置tab-content的确定长度,否则无法显示。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 权限列表 +<[tabs](../arkui-js/js-components-container-tabs.md)>的子组件,用来展示tab的内容区,高度默认充满tabs剩余空间,子组件排列方式为横向排列,当作为容器组件的子元素时在主轴方向需要设置tab-content的确定长度,否则无法显示。 + +## 权限列表 无 -## 子组件 + +## 子组件 支持。 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| scrollable | boolean | true | 否 | 是否可以通过左右滑动进行页面切换。默认为true,设置为false后,页面的切换只能通过tab-bar的点击实现。 | + - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

scrollable

-

boolean

-

true

-

-

是否可以通过左右滑动进行页面切换。默认为true,设置为false后,页面的切换只能通过tab-bar的点击实现。

-
+## 样式 -## 样式 +支持[通用样式](../arkui-js/js-components-common-styles.md)。 -支持[通用样式](js-components-common-styles.md)。 -## 事件 +## 事件 -支持[通用事件](js-components-common-events.md)。 +支持[通用事件](../arkui-js/js-components-common-events.md)。 -## 示例 -详见[tabs示例](js-components-container-tabs.md#section14993155318710)。 +## 示例 +详见[tabs示例](../arkui-js/js-components-container-tabs.md#示例)。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-tabs.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-tabs.md index 73d2d2daaaf7fe72e81e184feb2795bfdc5d1beb..93ce100f89815bdad0f1ce4fdf8795d6a067743a 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-tabs.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-tabs.md @@ -1,86 +1,45 @@ -# tabs +# tabs + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 tab页签容器。 -## 权限列表 +## 权限列表 无 -## 子组件 - -仅支持最多一个<[tab-bar](js-components-container-tab-bar.md)\>和最多一个<[tab-content](js-components-container-tab-content.md)\>。 - -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

index

-

number

-

0

-

-

当前处于激活态的tab索引。

-

vertical

-

boolean

-

false

-

-

是否为纵向的tab,默认为false,可选值为:

-
  • false:tabbar和tabcontent上下排列。
  • true:tabbar和tabcontent左右排列。
-
- -## 样式 - -支持[通用样式](js-components-common-styles.md)。 - -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - -

名称

-

参数

-

描述

-

change

-

{ index: indexValue }

-

tab页签切换后触发。

-
说明:

动态修改index值不会触发该回调。

-
-
- -## 示例 + +## 子组件 + +仅支持最多一个<[tab-bar](../arkui-js/js-components-container-tab-bar.md)>和最多一个<[tab-content](../arkui-js/js-components-container-tab-content.md)>。 + + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| index | number | 0 | 否 | 当前处于激活态的tab索引。 | +| vertical | boolean | false | 否 | 是否为纵向的tab,默认为false,可选值为:
- false:tabbar和tabcontent上下排列。
- true:tabbar和tabcontent左右排列。 | + + +## 样式 + +支持[通用样式](../arkui-js/js-components-common-styles.md)。 + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| change | { index: indexValue } | tab页签切换后触发。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 动态修改index值不会触发该回调。 | + + +## 示例 ``` @@ -149,5 +108,4 @@ export default { } ``` -![](figures/tab.gif) - +![zh-cn_image_0000001127125116](figures/zh-cn_image_0000001127125116.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container.md b/zh-cn/application-dev/reference/arkui-js/js-components-container.md index 99afacd50843e05e926f5e3d30edc33e4cbac539..b3a1fada257c961a99359701dd10c804a6fcdf3e 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container.md @@ -1,37 +1,37 @@ -# 容器组件 +# 容器组件 -- **[badge](js-components-container-badge.md)** -- **[dialog](js-components-container-dialog.md)** -- **[div](js-components-container-div.md)** +- **[badge](js-components-container-badge.md)** -- **[form](js-components-container-form.md)** +- **[dialog](js-components-container-dialog.md)** -- **[list](js-components-container-list.md)** +- **[div](js-components-container-div.md)** -- **[list-item](js-components-container-list-item.md)** +- **[form](js-components-container-form.md)** -- **[list-item-group](js-components-container-list-item-group.md)** +- **[list](js-components-container-list.md)** -- **[panel](js-components-container-panel.md)** +- **[list-item](js-components-container-list-item.md)** -- **[popup](js-components-container-popup.md)** +- **[list-item-group](js-components-container-list-item-group.md)** -- **[refresh](js-components-container-refresh.md)** +- **[panel](js-components-container-panel.md)** -- **[stack](js-components-container-stack.md)** +- **[popup](js-components-container-popup.md)** -- **[stepper](js-components-container-stepper.md)** +- **[refresh](js-components-container-refresh.md)** -- **[stepper-item](js-components-container-stepper-item.md)** +- **[stack](js-components-container-stack.md)** -- **[swiper](js-components-container-swiper.md)** +- **[stepper](js-components-container-stepper.md)** -- **[tabs](js-components-container-tabs.md)** +- **[stepper-item](js-components-container-stepper-item.md)** -- **[tab-bar](js-components-container-tab-bar.md)** +- **[swiper](js-components-container-swiper.md)** -- **[tab-content](js-components-container-tab-content.md)** +- **[tabs](js-components-container-tabs.md)** +- **[tab-bar](js-components-container-tab-bar.md)** +- **[tab-content](js-components-container-tab-content.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md index 8ac685f138c7c4b31388b86a69814b67dae1769c..1d70ef0cf7611959c54d33e941dda4ace6326f28 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-basic-usage.md @@ -1,7 +1,6 @@ -# 基本用法 +# 基本用法 自定义组件是用户根据业务需求,将已有的组件组合,封装成的新组件,可以在工程中多次调用,从而提高代码的可读性。自定义组件通过element引入到宿主页面,使用方法如下: - ```
@@ -9,8 +8,8 @@
``` -结合if-else使用自定义组件的示例: +结合if-else使用自定义组件的示例: ``` @@ -20,45 +19,17 @@
``` -- name属性指自定义组件名称\(非必填\),组件名称对大小写不敏感,默认使用小写。src属性指自定义组件hml文件路径\(必填\),若没有设置name属性,则默认使用hml文件名作为组件名。 -- 事件绑定:自定义组件中绑定子组件事件使用\(on|@\)child1语法,子组件中通过this.$emit\('child1', \{ params: '传递参数' \}\)触发事件并进行传值,父组件执行bindParentVmMethod方法并接收子组件传递的参数。 - - >![](../../public_sys-resources/icon-note.gif) **说明:** - >子组件中使用驼峰命名法命名的事件,在父组件中绑定时需要使用短横线分隔命名形式,例如:@children-event表示绑定子组件的childrenEvent事件,如 @children-event="bindParentVmMethod"。 +- name属性指自定义组件名称(非必填),组件名称对大小写不敏感,默认使用小写。src属性指自定义组件hml文件路径(必填),若没有设置name属性,则默认使用hml文件名作为组件名。 -**表 1** 对象 +- 事件绑定:自定义组件中绑定子组件事件使用(on|@)child1语法,子组件中通过this.$emit('child1', { params: '传递参数' })触发事件并进行传值,父组件执行bindParentVmMethod方法并接收子组件传递的参数。 + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 子组件中使用驼峰命名法命名的事件,在父组件中绑定时需要使用短横线分隔命名形式,例如:\@children-event表示绑定子组件的childrenEvent事件,如 \@children-event="bindParentVmMethod"。 - - - - - - - - - - - - - - - - - - -

属性

-

类型

-

描述

-

data

-

Object/Function

-

页面的数据模型,类型是对象或者函数,如果类型是函数,返回值必须是对象。属性名不能以$或_开头,不要使用保留字for, if, show, tid。

-

data与private和public不能重合使用。(Rich)

-

props

-

Array/Object

-

props用于组件之间的通信,可以通过<tag xxxx='value'>方式传递给组件;props名称必须用小写,不能以$或_开头,不要使用保留字for, if, show, tid。目前props的数据类型不支持Function。

-

computed

-

Object

-

计算属性,用于在读取或设置时,进行预先处理,其结果会被缓存。计算属性名不能以$或_开头,不要使用保留字。

-
+**表1** 对象 +| 属性 | 类型 | 描述 | +| -------- | -------- | -------- | +| data | Object/Function | 页面的数据模型,类型是对象或者函数,如果类型是函数,返回值必须是对象。属性名不能以$或_开头,不要使用保留字for, if, show, tid。
data与private和public不能重合使用。(Rich) | +| props | Array/Object | props用于组件之间的通信,可以通过<tag xxxx='value'>方式传递给组件;props名称必须用小写,不能以$或_开头,不要使用保留字for, if, show, tid。目前props的数据类型不支持Function。 | +| computed | Object | 计算属性,用于在读取或设置时,进行预先处理,其结果会被缓存。计算属性名不能以$或_开头,不要使用保留字。 | diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-event-parameter.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-event-parameter.md index 2d90c7f8884e0d71c2bab15c203d06291630c969..2127b2ab2029d8f79667e3b613a51c40a0e9ce32 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-event-parameter.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-event-parameter.md @@ -1,7 +1,8 @@ -# 事件参数 +# 事件参数 子组件也可以通过绑定的事件向上传递参数,在自定义事件上添加传递参数的示例如下: + ```
@@ -10,6 +11,7 @@
``` + ``` // comp.js export default { @@ -20,8 +22,10 @@ export default { } ``` + 子组件向上传递参数text,父组件接收时通过e.detail来获取参数: + ```
@@ -30,6 +34,7 @@ export default {
``` + ``` // xxx.js export default { @@ -41,4 +46,3 @@ export default { }, } ``` - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-events.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-events.md index 37859f0bdc844ce60933aa8af7f9567866f2b68d..1f717b06caf73930e4bd415c68d6a301839ed43d 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-events.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-events.md @@ -1,7 +1,8 @@ -# 自定义事件 +# 自定义事件 子组件comp定义如下: + ```
@@ -10,6 +11,7 @@
``` + ``` /* comp.css */ .item { @@ -26,6 +28,7 @@ } ``` + ``` // comp.js export default { @@ -39,8 +42,10 @@ export default { } ``` + 引入子组件的示例如下: + ``` @@ -49,6 +54,7 @@ export default {
``` + ``` /* xxx.css */ .container { @@ -59,10 +65,10 @@ export default { } ``` + ``` // xxx.js export default { textClicked () {}, } ``` - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md index e4f6ad79419a23bf61e5dfbc7df524224ae47bf4..959fa1d089e8c60221555fae000d2dd4f3d896e1 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-lifecycle.md @@ -1,87 +1,24 @@ -# 生命周期定义 +# 生命周期定义 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API Version 5 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->从API Version 5 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 我们为自定义组件提供了一系列生命周期回调方法,便于开发者管理自定义组件的内部逻辑。生命周期主要包括:onInit,onAttached,onDetached,onLayoutReady,onDestroy,onPageShow和onPageHide。下面我们依次介绍一下各个生命周期回调的时机。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

属性

-

类型

-

描述

-

触发时机

-

onInit

-

Function

-

初始化自定义组件

-

自定义组件初始化生命周期回调,当自定义组件创建时,触发该回调,主要用于自定义组件中必须使用的数据初始化,该回调只会触发一次调用。

-

onAttached

-

Function

-

自定义组件装载

-

自定义组件被创建后,加入到Page组件树时,触发该回调,该回调触发时,表示组件将被进行显示,该生命周期可用于初始化显示相关数据,通常用于加载图片资源、开始执行动画等场景。

-

onLayoutReady

-

Function

-

自定义组件布局完成

-

自定义组件插入Page组件树后,将会对自定义组件进行布局计算,调整其内容元素尺寸与位置,当布局计算结束后触发该回调。

-

onDetached

-

Function

-

自定义组件摘除

-

自定义组件摘除时,触发该回调,常用于停止动画或异步逻辑停止执行的场景。

-

onDestroy

-

Function

-

自定义组件销毁

-

自定义组件销毁时,触发该回调,常用于资源释放。

-

onPageShow

-

Function

-

自定义组件Page显示

-

自定义组件所在Page显示后,触发该回调。

-

onPageHide

-

Function

-

自定义组件Page隐藏

-

自定义组件所在Page隐藏后,触发该回调。

-
-## 示例 +| 属性 | 类型 | 描述 | 触发时机 | +| -------- | -------- | -------- | -------- | +| onInit | Function | 初始化自定义组件 | 自定义组件初始化生命周期回调,当自定义组件创建时,触发该回调,主要用于自定义组件中必须使用的数据初始化,该回调只会触发一次调用。 | +| onAttached | Function | 自定义组件装载 | 自定义组件被创建后,加入到Page组件树时,触发该回调,该回调触发时,表示组件将被进行显示,该生命周期可用于初始化显示相关数据,通常用于加载图片资源、开始执行动画等场景。 | +| onLayoutReady | Function | 自定义组件布局完成 | 自定义组件插入Page组件树后,将会对自定义组件进行布局计算,调整其内容元素尺寸与位置,当布局计算结束后触发该回调。 | +| onDetached | Function | 自定义组件摘除 | 自定义组件摘除时,触发该回调,常用于停止动画或异步逻辑停止执行的场景。 | +| onDestroy | Function | 自定义组件销毁 | 自定义组件销毁时,触发该回调,常用于资源释放。 | +| onPageShow | Function | 自定义组件Page显示 | 自定义组件所在Page显示后,触发该回调。 | +| onPageHide | Function | 自定义组件Page隐藏 | 自定义组件所在Page隐藏后,触发该回调。 | + + +## 示例 ``` @@ -113,4 +50,3 @@ export default { } } ``` - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md index 6e48255e0e20b5e727d291c39dd00f9039ffa75b..c92c4399ead3451fae3f0cf306a22f706601514a 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-props.md @@ -1,6 +1,7 @@ -# Props +# Props + +自定义组件可以通过props声明属性,父组件通过设置属性向子组件传递参数,props支持类型包括:String,Number,Boolean,Array,Object,Function。camelCase (驼峰命名法) 的 prop 名,在外部父组件传递参数时需要使用 kebab-case (短横线分隔命名) 形式,即当属性compProp在父组件引用时需要转换为comp-prop。给自定义组件添加props,通过父组件向下传递参数的示例如下: -自定义组件可以通过props声明属性,父组件通过设置属性向子组件传递参数,props支持类型包括:String,Number,Boolean,Array,Object,Function。camelCase \(驼峰命名法\) 的 prop 名,在外部父组件传递参数时需要使用 kebab-case \(短横线分隔命名\) 形式,即当属性compProp在父组件引用时需要转换为comp-prop。给自定义组件添加props,通过父组件向下传递参数的示例如下: ``` @@ -9,6 +10,7 @@
``` + ``` // comp.js export default { @@ -16,6 +18,7 @@ export default { } ``` + ``` @@ -24,10 +27,12 @@ export default {
``` ->![](../../public_sys-resources/icon-note.gif) **说明:** ->自定义属性命名时禁止以on、@、on:、grab: 等保留关键字为开头。 -## 添加默认值 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 自定义属性命名时禁止以on、@、on:、grab: 等保留关键字为开头。 + + +## 添加默认值 子组件可以通过固定值default设置默认值,当父组件没有设置该属性时,将使用其默认值。此情况下props属性必须为对象形式,不能用数组形式,示例如下: @@ -59,7 +64,8 @@ export default { ``` -## 数据单向性 + +## 数据单向性 父子组件之间数据的传递是单向的,只能从父组件传递给子组件,子组件不能直接修改父组件传递下来的值,可以将props传入的值用data接收后作为默认值,再对data的值进行修改。 @@ -78,7 +84,8 @@ export default { } ``` -## $watch 感知数据改变 + +## $watch 感知数据改变 如果需要观察组件中属性变化,可以通过$watch方法增加属性变化回调。使用方法如下: @@ -95,7 +102,8 @@ export default { } ``` -## computed 计算属性 + +## computed 计算属性 自定义组件中经常需要在读取或设置某个属性时进行预先处理,提高开发效率,此种情况就需要使用computed字段。computed字段中可通过设置属性的getter和setter方法在属性读写的时候进行触发,使用方式如下: @@ -130,4 +138,3 @@ export default { ``` 这里声明的第一个计算属性message默认只有getter函数,message的值会取决于objTitle的值的变化。getter函数只能读取不能改变设值,当需要赋值给计算属性的时候可以提供一个setter函数,如示例中的notice。 - diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md index 2a8c3934e4996dda2caa395e5270e1abfe917937..a318bbf7355eb926977a1809f8631f1a475b7541 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom-slot.md @@ -1,9 +1,10 @@ -# slot插槽 +# slot插槽 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->从API Version 7 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API Version 7 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 -## 默认插槽 + +## 默认插槽 自定义组件中通过slot标签来承载父组件中定义的内容,使用slot标签可以更加灵活的控制自定义组件的内容元素,使用方式如下: @@ -16,7 +17,6 @@ ``` 引用该自定义组件方式如下: - ``` @@ -27,7 +27,8 @@ ``` -## 具名插槽 + +## 具名插槽 当自定义组件中需要使用多个插槽时,可通过对插槽命名的方式进行区分,当填充插槽内容时,通过声明插槽名称,将内容加到对应的插槽中。 @@ -41,7 +42,6 @@ ``` 引用该自定义组件方式如下: - ``` @@ -53,6 +53,5 @@ ``` ->![](../../public_sys-resources/icon-note.gif) **说明:** ->name 和 slot 属性不支持绑定动态数据。 - +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> name 和 slot 属性不支持绑定动态数据。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-custom.md b/zh-cn/application-dev/reference/arkui-js/js-components-custom.md index 4b91521dce6e38f3a24b4c9c4b172fa90ede5602..04d47d810da15e6231acdfabb016d5ee00ed6439 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-custom.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-custom.md @@ -1,15 +1,15 @@ -# 自定义组件 +# 自定义组件 -- **[基本用法](js-components-custom-basic-usage.md)** -- **[自定义事件](js-components-custom-events.md)** -- **[Props](js-components-custom-props.md)** +- **[基本用法](js-components-custom-basic-usage.md)** -- **[事件参数](js-components-custom-event-parameter.md)** +- **[自定义事件](js-components-custom-events.md)** -- **[slot插槽](js-components-custom-slot.md)** +- **[Props](js-components-custom-props.md)** -- **[生命周期定义](js-components-custom-lifecycle.md)** +- **[事件参数](js-components-custom-event-parameter.md)** +- **[slot插槽](js-components-custom-slot.md)** +- **[生命周期定义](js-components-custom-lifecycle.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-grid-basic-concepts.md b/zh-cn/application-dev/reference/arkui-js/js-components-grid-basic-concepts.md index ae70830fb1c0f98cf1e8e910e839cf067daf4aa8..8c15ecf94c577e1e547f7b6f652f95a39d58367e 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-grid-basic-concepts.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-grid-basic-concepts.md @@ -1,44 +1,44 @@ -# 基本概念 +# 基本概念 -提供栅格布局效果,通过栅格系统进行元素布局,主要提供栅格容器组件。 +提供栅格布局效果,通过栅格系统进行元素布局,主要提供<grid-container><grid-row><grid-col>栅格容器组件。 -栅格系统作为一种辅助布局的定位工具,在平面设计和网站设计都起到了很好的作用,对移动设备对界面设计有较好的借鉴作用。总结栅格系统对于移动设备的优势主要有: -1. 给布局提供一种可循的规律,解决多尺寸多设备的动态布局问题。 +栅格系统作为一种辅助布局的定位工具,在平面设计和网站设计都起到了很好的作用,对移动设备对界面设计有较好的借鉴作用。总结栅格系统对于移动设备的优势主要有: -2. 给系统提供一种统一的定位标注,保证各模块各设备的布局一致性。 -3. 给应用提供一种灵活的间距调整方法,满足特殊场景布局调整的可能性。 +1. 给布局提供一种可循的规律,解决多尺寸多设备的动态布局问题。 +2. 给系统提供一种统一的定位标注,保证各模块各设备的布局一致性。 -## 栅格系统的概念 +3. 给应用提供一种灵活的间距调整方法,满足特殊场景布局调整的可能性。 -栅格系统有Margins、Gutters、Columns三个属性。 -1. Margins: +## 栅格系统的概念 - 是用来控制元素距离屏幕最边缘的距离关系,可以根据设备的不同尺寸,定义不同的Margin值作为断点系统中的统一规范。 +栅格系统有Margins、Gutters、Columns三个属性。 -2. Gutters: +1. Margins: - 是用来控制元素和元素之间的距离关系,可以根据设备的不同尺寸,定义不同的Gutters值作为断点系统中的统一规范。为了保证较好的视觉效果,Gutters通常的取值不会大于Margins的取值。 + 是用来控制元素距离屏幕最边缘的距离关系,可以根据设备的不同尺寸,定义不同的Margin值作为断点系统中的统一规范。 -3. Columns: +2. Gutters: - 是用来辅助布局的主要定位工具,不同的屏幕尺寸匹配不同的Columns数量来辅助布局定位。Columns的宽度在保证Margins和Gutters符合规范的情况下,根据实际设备的宽度和Columns数量自动计算每一个Columns的宽度。![](figures/zh-cn_image_0000001127125136.png) + 是用来控制元素和元素之间的距离关系,可以根据设备的不同尺寸,定义不同的Gutters值作为断点系统中的统一规范。为了保证较好的视觉效果,Gutters通常的取值不会大于Margins的取值。 - **栅格断点系统** +3. Columns: - 栅格系统定义了不同水平宽度设备对应Columns的数量关系,形成了一套断点规则定义。 + 是用来辅助布局的主要定位工具,不同的屏幕尺寸匹配不同的Columns数量来辅助布局定位。Columns的宽度在保证Margins和Gutters符合规范的情况下,根据实际设备的宽度和Columns数量自动计算每一个Columns的宽度。![zh-cn_image_0000001127125136](figures/zh-cn_image_0000001127125136.png) - 栅格系统以水平分辨率值作为断点依据,不同的设备根据自身当前水平宽度px值\(配置了autoDesignWidth为true\)在不同的断点范围内的情况,显示不同数量的栅格数。 + **栅格断点系统** - xs: 0<水平分辨率<320时:2 Columns栅格; + 栅格系统定义了不同水平宽度设备对应Columns的数量关系,形成了一套断点规则定义。 - sm: 320<=水平分辨率<600时:4 Columns栅格; + 栅格系统以水平分辨率值作为断点依据,不同的设备根据自身当前水平宽度px值(配置了autoDesignWidth为true)在不同的断点范围内的情况,显示不同数量的栅格数。 - md: 600<=水平分辨率<840时:8 Columns栅格; + xs: 0<水平分辨率<320时:2 Columns栅格; - lg: 840<=水平分辨率时:12 Columns栅格; + sm: 320<=水平分辨率<600时:4 Columns栅格; + md: 600<=水平分辨率<840时:8 Columns栅格; + lg: 840<=水平分辨率时:12 Columns栅格; diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-grid-col.md b/zh-cn/application-dev/reference/arkui-js/js-components-grid-col.md index 76a19eae4f7615deab2bd5c4551cf6fcd87af18e..288ddd88a9923a9ca6a68973802993b10fe5b336 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-grid-col.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-grid-col.md @@ -1,253 +1,66 @@ -# grid-col +# grid-col + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 grid-col是栅格布局容器grid-row的子容器组件。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持。 -## 属性 -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| xs | number\|object | - | 否 | 在分辨率为xs模式下,设置该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0} | +| sm | number\|object | - | 否 | 在分辨率为sm模式下,该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0} | +| md | number\|object | - | 否 | 在分辨率为md模式下,该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0} | +| lg | number\|object | - | 否 | 在分辨率为lg模式下,该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0} | +| span | number | 1 | 否 | 在未设置明确断点时,默认占用列数 | +| offset | number | 0 | 否 | 未设置具体分辨率模式下偏移时,当前元素延容器布局方向,默认偏移的列数 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

xs

-

number|object

-

-

-

-

在分辨率为xs模式下,设置该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0}

-

sm

-

number|object

-

-

-

-

在分辨率为sm模式下,该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0}

-

md

-

number|object

-

-

-

-

在分辨率为md模式下,该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0}

-

lg

-

number|object

-

-

-

-

在分辨率为lg模式下,该项占用列数与偏移列数,当值为number类型时,仅设置列数,也可通过object同时设置占用列数与偏移列数,如{"span": 1, "offset": 0}

-

span

-

number

-

1

-

-

在未设置明确断点时,默认占用列数

-

offset

-

number

-

0

-

-

未设置具体分辨率模式下偏移时,当前元素延容器布局方向,默认偏移的列数

-
-## 样式 +## 样式 -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

flex-direction

-

string

-

row

-

-

flex容器主轴方向。可选项有:

-
  • column:垂直方向从上到下
  • row:水平方向从左到右
-

flex-wrap

-

string

-

nowrap

-

-

flex容器是单行还是多行显示,该值暂不支持动态修改。可选项有:

-
  • nowrap:不换行,单行显示。
  • wrap:换行,多行显示。
-

justify-content

-

string

-

flex-start

-

-

flex容器当前行的主轴对齐格式。可选项有:

-
  • flex-start:项目位于容器的开头。
  • flex-end:项目位于容器的结尾。
  • center:项目位于容器的中心。
  • space-between:项目位于各行之间留有空白的容器内。
  • space-around:项目位于各行之前、之间、之后都留有空白的容器内。
-

align-items

-

string

-

stretch

-

-

flex容器当前行的交叉轴对齐格式,可选值为:

-
  • stretch:弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
  • flex-start:元素向交叉轴起点对齐。
  • flex-end:元素向交叉轴终点对齐。
  • center:元素在交叉轴居中。
-

align-content

-

string

-

flex-start

-

-

交叉轴中有额外的空间时,多行内容对齐格式,可选值为:

-
  • flex-start:所有行从交叉轴起点开始填充。第一行的交叉轴起点边和容器的交叉轴起点边对齐。接下来的每一行紧跟前一行。
  • flex-end:所有行从交叉轴末尾开始填充。最后一行的交叉轴终点和容器的交叉轴终点对齐。同时所有后续行与前一个对齐。
  • center:所有行朝向容器的中心填充。每行互相紧挨,相对于容器居中对齐。容器的交叉轴起点边和第一行的距离相等于容器的交叉轴终点边和最后一行的距离。
  • space-between:所有行在容器中平均分布。相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的边对齐。
  • space-around:所有行在容器中平均分布,相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的距离是相邻两行间距的一半。
-

display

-

string

-

flex

-

-

确定该元素视图框的类型,该值暂不支持动态修改。可选值为:

-
  • flex:弹性布局
  • grid:网格布局
  • none:不渲染此元素
-

grid-template-[columns|rows]

-

string

-

1行1列

-

-

用于设置当前网格布局行和列的数量,不设置时默认1行1列,仅当display为grid时生效。

-

示例:如设置grid-template-columns为:

-

(1) 50px 100px 60px:分三列,第一列50px,第二列100px,第三列60px;

-

(2) 1fr 1fr 2fr:分三列,将父组件允许的宽分为4等份,第一列占1份,第二列占一份,第三列占2份;

-

(3) 30% 20% 50%:分三列,将父组件允许的宽为基准,第一列占30%,第二列占20%,第三列占50%;

-

(4) repeat(2,100px):分两列,第一列100px,第二列100px;

-

(5) auto 1fr 1fr:分三列,第一列自适应内部子组件所需宽度,剩余空间分为两等份,第二列占一份,第三列占一份。

-

grid-[columns|rows]-gap

-

<length>

-

0

-

-

用于设置行与行的间距或者列与列的间距,也可以支持通过grid-gap设置相同的行列间距,仅当display为grid时生效。

-

grid-row-[start|end]

-

number

-

-

-

-

用于设置当前元素在网格布局中的起止行号,仅当父组件display样式为grid时生效(仅div支持display样式设置为grid)。

-

grid-column-[start|end]

-

number

-

-

-

-

用于设置当前元素在网格布局中的起止列号,仅当父组件display样式为grid时生效(仅div支持display样式设置为grid)。

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| flex-direction | string | row | 否 | flex容器主轴方向。可选项有:
- column:垂直方向从上到下
- row:水平方向从左到右 | +| flex-wrap | string | nowrap | 否 | flex容器是单行还是多行显示,该值暂不支持动态修改。可选项有:
- nowrap:不换行,单行显示。
- wrap:换行,多行显示。 | +| justify-content | string | flex-start | 否 | flex容器当前行的主轴对齐格式。可选项有:
- flex-start:项目位于容器的开头。
- flex-end:项目位于容器的结尾。
- center:项目位于容器的中心。
- space-between:项目位于各行之间留有空白的容器内。
- space-around:项目位于各行之前、之间、之后都留有空白的容器内。 | +| align-items | string | stretch | 否 | flex容器当前行的交叉轴对齐格式,可选值为:
- stretch:弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
- flex-start:元素向交叉轴起点对齐。
- flex-end:元素向交叉轴终点对齐。
- center:元素在交叉轴居中。 | +| align-content | string | flex-start | 否 | 交叉轴中有额外的空间时,多行内容对齐格式,可选值为:
- flex-start:所有行从交叉轴起点开始填充。第一行的交叉轴起点边和容器的交叉轴起点边对齐。接下来的每一行紧跟前一行。
- flex-end:所有行从交叉轴末尾开始填充。最后一行的交叉轴终点和容器的交叉轴终点对齐。同时所有后续行与前一个对齐。
- center:所有行朝向容器的中心填充。每行互相紧挨,相对于容器居中对齐。容器的交叉轴起点边和第一行的距离相等于容器的交叉轴终点边和最后一行的距离。
- space-between:所有行在容器中平均分布。相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的边对齐。
- space-around:所有行在容器中平均分布,相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的距离是相邻两行间距的一半。 | +| display | string | flex | 否 | 确定该元素视图框的类型,该值暂不支持动态修改。可选值为:
- flex:弹性布局
- grid:网格布局
- none:不渲染此元素 | +| grid-template-[columns\|rows] | string | 1行1列 | 否 | 用于设置当前网格布局行和列的数量,不设置时默认1行1列,仅当display为grid时生效。
示例:如设置grid-template-columns为:
(1) 50px 100px 60px:分三列,第一列50px,第二列100px,第三列60px;
(2) 1fr 1fr 2fr:分三列,将父组件允许的宽分为4等份,第一列占1份,第二列占一份,第三列占2份;
(3) 30% 20% 50%:分三列,将父组件允许的宽为基准,第一列占30%,第二列占20%,第三列占50%;
(4) repeat(2,100px):分两列,第一列100px,第二列100px;
(5) auto 1fr 1fr:分三列,第一列自适应内部子组件所需宽度,剩余空间分为两等份,第二列占一份,第三列占一份。 | +| grid-[columns\|rows]-gap | <length> | 0 | 否 | 用于设置行与行的间距或者列与列的间距,也可以支持通过grid-gap设置相同的行列间距,仅当display为grid时生效。 | +| grid-row-[start\|end] | number | - | 否 | 用于设置当前元素在网格布局中的起止行号,仅当父组件display样式为grid时生效(仅div支持display样式设置为grid)。 | +| grid-column-[start\|end] | number | - | 否 | 用于设置当前元素在网格布局中的起止列号,仅当父组件display样式为grid时生效(仅div支持display样式设置为grid)。 | ->![](../../public_sys-resources/icon-note.gif) **说明:** ->不支持宽度相关样式。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 不支持宽度相关样式。 -## 事件 -支持[通用事件](js-components-common-events.md)。 +## 事件 -## 方法 +支持[通用事件](../arkui-js/js-components-common-events.md)。 -支持[通用方法](js-components-common-methods.md)。 -## 示例 +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 ``` @@ -300,5 +113,4 @@ export default { } ``` -![](figures/grid.gif) - +![zh-cn_image_0000001192960596](figures/zh-cn_image_0000001192960596.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-grid-container.md b/zh-cn/application-dev/reference/arkui-js/js-components-grid-container.md index 3e76f756fc28f489f9623b63933e5795942a15b4..eeac8459fa3584f5bc22adb03ed213f1b0051933 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-grid-container.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-grid-container.md @@ -1,275 +1,76 @@ -# grid-container +# grid-container + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 栅格布局容器根节点,使用grid-row与grid-col进行栅格布局。 -## 权限列表 +## 权限列表 无 -## 子组件 -仅支持。 +## 子组件 + +仅支持<grid-row>。 + + +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下属性: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| columns | string \| number | auto | 否 | 设置当前布局总列数,使用string类型时仅支持auto,配置为auto时按照当前的sizetype决定总列数:
- xs:2列
- sm:4列
- md:8列
- lg:12列 | +| sizetype | string | auto | 否 | 设置当前栅格使用的响应尺寸类型,支持xs, sm, md, lg类型,使用auto时按照当前容器大小自动选择xs, sm, md, lg类型。 | +| gutter | <length> | 24px | 否 | 设置Gutter宽度 | +| gridtemplate6+ | string | default | 否 | 当设置了columns和sizetype属性为auto时,可以设置栅格容器的布局模板,通过布局模块设置不同响应尺寸下的Columns、Gutters和Margins,详见表 gridtemplate可选值说明。 | -## 属性 +**表1** gridtemplate可选值说明6+ -除支持[通用属性](js-components-common-attributes.md)外,还支持如下属性: +| | 模板值 | 可响应的**栅格断点系统** | Columns | Margins(px) | Gutters(px) | +| -------- | -------- | -------- | -------- | -------- | -------- | +| 默认栅格 | default | xs | 2 | 12 | 12 | +| | | sm | 4 | 24 | 24 | +| | | md | 8 | 32 | 24 | +| | | lg | 12 |48|24| +| 宫格布局栅格 | grid | sm(0<设备水平分辨率<600px) | 4 | 24 | 12 | +| | | md | 8 |32|12| +| | | lg | 12 |48|12| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

columns

-

string | number

-

auto

-

-

设置当前布局总列数,使用string类型时仅支持auto,配置为auto时按照当前的sizetype决定总列数:

-
  • xs:2列
  • sm:4列
  • md:8列
  • lg:12列
-

sizetype

-

string

-

auto

-

-

设置当前栅格使用的响应尺寸类型,支持xs, sm, md, lg类型,使用auto时按照当前容器大小自动选择xs, sm, md, lg类型。

-

gutter

-

<length>

-

24px

-

-

设置Gutter宽度

-

gridtemplate6+

-

string

-

default

-

-

当设置了columns和sizetype属性为auto时,可以设置栅格容器的布局模板,通过布局模块设置不同响应尺寸下的Columns、Gutters和Margins,详见可选值说明

-
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> 本章中px单位是在js标签中配置了autoDesignWidth为true。6+ -**表 1** gridtemplate可选值说明6+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  

模板值

-

可响应的栅格断点系统

-

Columns

-

Margins(px)

-

Gutters(px)

-

默认栅格

-

default

-

xs

-

2

-

12

-

12

-

sm

-

4

-

24

-

24

-

md

-

8

-

32

-

24

-

lg

-

12

-

48

-

24

-

宫格布局栅格

-

grid

-

sm(0<设备水平分辨率<600px)

-

4

-

24

-

12

-

md

-

8

-

32

-

12

-

lg

-

12

-

48

-

12

-
+## 样式 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 本章中px单位是在js标签中配置了autoDesignWidth为true。6+ +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: -## 样式 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| justify-content | string | flex-start | 否 | flex容器当前行的主轴对齐格式。可选项有:
- flex-start:项目位于容器的开头。
- flex-end:项目位于容器的结尾。
- center:项目位于容器的中心。
- space-between:项目位于各行之间留有空白的容器内。
- space-around:项目位于各行之前、之间、之后都留有空白的容器内。 | +| align-items | string | stretch | 否 | flex容器当前行的交叉轴对齐格式,可选值为:
- stretch:弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
- flex-start:元素向交叉轴起点对齐。
- flex-end:元素向交叉轴终点对齐。
- center:元素在交叉轴居中。 | +| align-content | string | flex-start | 否 | 交叉轴中有额外的空间时,多行内容对齐格式,可选值为:
- flex-start:所有行从交叉轴起点开始填充。第一行的交叉轴起点边和容器的交叉轴起点边对齐。接下来的每一行紧跟前一行。
- flex-end:所有行从交叉轴末尾开始填充。最后一行的交叉轴终点和容器的交叉轴终点对齐。同时所有后续行与前一个对齐。
- center:所有行朝向容器的中心填充。每行互相紧挨,相对于容器居中对齐。容器的交叉轴起点边和第一行的距离相等于容器的交叉轴终点边和最后一行的距离。
- space-between:所有行在容器中平均分布。相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的边对齐。
- space-around:所有行在容器中平均分布,相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的距离是相邻两行间距的一半。 | -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

justify-content

-

string

-

flex-start

-

-

flex容器当前行的主轴对齐格式。可选项有:

-
  • flex-start:项目位于容器的开头。
  • flex-end:项目位于容器的结尾。
  • center:项目位于容器的中心。
  • space-between:项目位于各行之间留有空白的容器内。
  • space-around:项目位于各行之前、之间、之后都留有空白的容器内。
-

align-items

-

string

-

stretch

-

-

flex容器当前行的交叉轴对齐格式,可选值为:

-
  • stretch:弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
  • flex-start:元素向交叉轴起点对齐。
  • flex-end:元素向交叉轴终点对齐。
  • center:元素在交叉轴居中。
-

align-content

-

string

-

flex-start

-

-

交叉轴中有额外的空间时,多行内容对齐格式,可选值为:

-
  • flex-start:所有行从交叉轴起点开始填充。第一行的交叉轴起点边和容器的交叉轴起点边对齐。接下来的每一行紧跟前一行。
  • flex-end:所有行从交叉轴末尾开始填充。最后一行的交叉轴终点和容器的交叉轴终点对齐。同时所有后续行与前一个对齐。
  • center:所有行朝向容器的中心填充。每行互相紧挨,相对于容器居中对齐。容器的交叉轴起点边和第一行的距离相等于容器的交叉轴终点边和最后一行的距离。
  • space-between:所有行在容器中平均分布。相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的边对齐。
  • space-around:所有行在容器中平均分布,相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的距离是相邻两行间距的一半。
-
+## 事件 -## 事件 +支持[通用事件](../arkui-js/js-components-common-events.md)。 -支持[通用事件](js-components-common-events.md)。 -## 方法 +## 方法 -除支持[通用方法](js-components-common-methods.md)外,还支持如下方法: +除支持[通用方法](../arkui-js/js-components-common-methods.md)外,还支持如下方法: - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

getColumns

-

-

-

返回栅格容器列数

-

getColumnWidth

-

-

-

返回栅格容器column宽度

-

getGutterWidth

-

-

-

返回栅格容器gutter宽度

-

getSizeType

-

-

-

返回当前容器响应尺寸类型(xs|sm|md|lg)

-
+| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| getColumns | - | 返回栅格容器列数 | +| getColumnWidth | - | 返回栅格容器column宽度 | +| getGutterWidth | - | 返回栅格容器gutter宽度 | +| getSizeType | - | 返回当前容器响应尺寸类型(xs\|sm\|md\|lg) | -## 示例 -详见[grid-col示例](js-components-grid-col.md#section2021865273710)。 +## 示例 +详见[grid-col示例](../arkui-js/js-components-grid-col.md#示例)。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-grid-row.md b/zh-cn/application-dev/reference/arkui-js/js-components-grid-row.md index 8e83bc573eec1279ca838f14a77762408b2d9b21..ffd6bb56ea2f26a5b596d323ff8f28e00a2033f5 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-grid-row.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-grid-row.md @@ -1,98 +1,50 @@ -# grid-row +# grid-row + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 5开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 grid-row是栅格布局容器grid-container的子容器组件,使用flex横向布局,排列每个grid-col容器,justify-content与align-items默认为flex-start,支持折行显示。 -## 权限列表 +## 权限列表 无 -## 子组件 - -仅支持。 - -## 属性 - -支持[通用属性](js-components-common-attributes.md)。 - -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

flex-wrap

-

string

-

nowrap

-

-

flex容器是单行还是多行显示,该值暂不支持动态修改。可选项有:

-
  • nowrap:不换行,单行显示。
  • wrap:换行,多行显示。
-

justify-content

-

string

-

flex-start

-

-

flex容器当前行的主轴对齐格式。可选项有:

-
  • flex-start:项目位于容器的开头。
  • flex-end:项目位于容器的结尾。
  • center:项目位于容器的中心。
  • space-between:项目位于各行之间留有空白的容器内。
  • space-around:项目位于各行之前、之间、之后都留有空白的容器内。
-

align-items

-

string

-

flex-start

-

-

flex容器当前行的交叉轴对齐格式,可选值为:

-
  • stretch:弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
  • flex-start:元素向交叉轴起点对齐。
  • flex-end:元素向交叉轴终点对齐。
  • center:元素在交叉轴居中。
-

align-content

-

string

-

flex-start

-

-

交叉轴中有额外的空间时,多行内容对齐格式,可选值为:

-
  • flex-start:所有行从交叉轴起点开始填充。第一行的交叉轴起点边和容器的交叉轴起点边对齐。接下来的每一行紧跟前一行。
  • flex-end:所有行从交叉轴末尾开始填充。最后一行的交叉轴终点和容器的交叉轴终点对齐。同时所有后续行与前一个对齐。
  • center:所有行朝向容器的中心填充。每行互相紧挨,相对于容器居中对齐。容器的交叉轴起点边和第一行的距离相等于容器的交叉轴终点边和最后一行的距离。
  • space-between:所有行在容器中平均分布。相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的边对齐。
  • space-around:所有行在容器中平均分布,相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的距离是相邻两行间距的一半。
-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->不支持宽度相关样式。 - -## 事件 - -支持[通用事件](js-components-common-events.md)。 - -## 方法 - -支持[通用方法](js-components-common-methods.md)。 - -## 示例 - -详见[grid-col示例](js-components-grid-col.md#section2021865273710)。 +## 子组件 + +仅支持<grid-col>。 + + +## 属性 + +支持[通用属性](../arkui-js/js-components-common-attributes.md)。 + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| flex-wrap | string | nowrap | 否 | flex容器是单行还是多行显示,该值暂不支持动态修改。可选项有:
- nowrap:不换行,单行显示。
- wrap:换行,多行显示。 | +| justify-content | string | flex-start | 否 | flex容器当前行的主轴对齐格式。可选项有:
- flex-start:项目位于容器的开头。
- flex-end:项目位于容器的结尾。
- center:项目位于容器的中心。
- space-between:项目位于各行之间留有空白的容器内。
- space-around:项目位于各行之前、之间、之后都留有空白的容器内。 | +| align-items | string | flex-start | 否 | flex容器当前行的交叉轴对齐格式,可选值为:
- stretch:弹性元素被在交叉轴方向被拉伸到与容器相同的高度或宽度。
- flex-start:元素向交叉轴起点对齐。
- flex-end:元素向交叉轴终点对齐。
- center:元素在交叉轴居中。 | +| align-content | string | flex-start | 否 | 交叉轴中有额外的空间时,多行内容对齐格式,可选值为:
- flex-start:所有行从交叉轴起点开始填充。第一行的交叉轴起点边和容器的交叉轴起点边对齐。接下来的每一行紧跟前一行。
- flex-end:所有行从交叉轴末尾开始填充。最后一行的交叉轴终点和容器的交叉轴终点对齐。同时所有后续行与前一个对齐。
- center:所有行朝向容器的中心填充。每行互相紧挨,相对于容器居中对齐。容器的交叉轴起点边和第一行的距离相等于容器的交叉轴终点边和最后一行的距离。
- space-between:所有行在容器中平均分布。相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的边对齐。
- space-around:所有行在容器中平均分布,相邻两行间距相等。容器的交叉轴起点边和终点边分别与第一行和最后一行的距离是相邻两行间距的一半。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 不支持宽度相关样式。 + + +## 事件 + +支持[通用事件](../arkui-js/js-components-common-events.md)。 + + +## 方法 + +支持[通用方法](../arkui-js/js-components-common-methods.md)。 + + +## 示例 + +详见[grid-col示例](../arkui-js/js-components-grid-col.md#示例)。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-grid.md b/zh-cn/application-dev/reference/arkui-js/js-components-grid.md index f0657b7133f688ba305e6bd005ccb00dd156d078..03adf7973f4891cd858fd6d68ecb3503de07066a 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-grid.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-grid.md @@ -1,11 +1,11 @@ -# 栅格组件 +# 栅格组件 -- **[基本概念](js-components-grid-basic-concepts.md)** -- **[grid-container](js-components-grid-container.md)** -- **[grid-row](js-components-grid-row.md)** +- **[基本概念](js-components-grid-basic-concepts.md)** -- **[grid-col](js-components-grid-col.md)** +- **[grid-container](js-components-grid-container.md)** +- **[grid-row](js-components-grid-row.md)** +- **[grid-col](js-components-grid-col.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md b/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md index d026b711485c8e93fa21e8e315979ced3528b210..90071c93594d6a2ddbe6726a3f44ae49da643cb5 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-media-video.md @@ -1,236 +1,75 @@ -# video +# video -视频播放组件。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 需要在config.json配置 -> ``` -> "configChanges": ["orientation"] -> ``` +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> +> - 从API version 4开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - 需要在config.json配置 +> ``` +> "configChanges": ["orientation"] +> ``` + +视频播放组件。 -## 权限列表 -## 子组件 +## 子组件 不支持。 -## 属性 - -除支持[通用属性](js-components-common-attributes.md)外,还支持如下样式: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

muted

-

boolean

-

false

-

-

视频是否静音播放。

-

src

-

string

-

-

-

-

播放视频内容的路径。

-

autoplay

-

boolean

-

false

-

-

视频是否自动播放。

-

controls

-

boolean

-

true

-

-

控制视频播放的控制栏是否显示,如果设置为false,则不显示控制栏。默认为true,由系统决定显示或隐藏控制栏。

-
- -## 样式 - -除支持[通用样式](js-components-common-styles.md)外,还支持如下样式: - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

object-fit

-

string

-

contain

-

-

视频源的缩放类型,如果poster设置了值,那么此配置还会影响视频海报的缩放类型,可选值参考表1

-
- -**表 1** object-fit 类型说明 - - - - - - - - - - -

类型

-

描述

-

fill

-

不保持宽高比进行放大缩小,使得图片填充满显示边界。

-
- -## 事件 - -除支持[通用事件](js-components-common-events.md)外,还支持如下事件: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

prepared

-

{ duration: value }5+

-

视频准备完成时触发该事件,通过duration可以获取视频时长,单位为s。

-

start

-

-

-

播放时触发该事件。

-

pause

-

-

-

暂停时触发该事件。

-

finish

-

-

-

播放结束时触发该事件。

-

error

-

-

-

播放失败时触发该事件。

-

seeking

-

{ currenttime: value }

-

操作进度条过程时上报时间信息,单位为s。

-

seeked

-

{ currenttime: value }

-

操作进度条完成后,上报播放时间信息,单位为s。

-

timeupdate

-

{ currenttime: value }

-

播放进度变化时触发该事件,单位为s,更新时间间隔为250ms。

-
- -## 方法 - -除支持[通用方法](js-components-common-methods.md)外,还支持如下方法: - - - - - - - - - - - - - - - - - - - -

名称

-

参数

-

描述

-

start

-

-

-

请求播放视频。

-

pause

-

-

-

请求暂停播放视频。

-

setCurrentTime

-

{ currenttime: value }

-

指定视频播放的进度位置,单位为s。

-
- ->![](../../public_sys-resources/icon-note.gif) **说明:** ->在attached组件生命周期回调后,可以调用上述组件方法。 +## 属性 + +除支持[通用属性](../arkui-js/js-components-common-attributes.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| muted | boolean | false | 否 | 视频是否静音播放。 | +| src | string | - | 否 | 播放视频内容的路径。 | +| autoplay | boolean | false | 否 | 视频是否自动播放。 | +| controls | boolean | true | 否 | 控制视频播放的控制栏是否显示,如果设置为false,则不显示控制栏。默认为true,由系统决定显示或隐藏控制栏。 | + + +## 样式 + +除支持[通用样式](../arkui-js/js-components-common-styles.md)外,还支持如下样式: + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| object-fit | string | contain | 否 | 视频源的缩放类型,如果poster设置了值,那么此配置还会影响视频海报的缩放类型,可选值参考表 object-fit 类型说明。 | + +**表1** object-fit 类型说明 + +| 类型 | 描述 | +| -------- | -------- | +| fill | 不保持宽高比进行放大缩小,使得图片填充满显示边界。 | + + +## 事件 + +除支持[通用事件](../arkui-js/js-components-common-events.md)外,还支持如下事件: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| prepared | { duration: value }5+ | 视频准备完成时触发该事件,通过duration可以获取视频时长,单位为s。 | +| start | - | 播放时触发该事件。 | +| pause | - | 暂停时触发该事件。 | +| finish | - | 播放结束时触发该事件。 | +| error | - | 播放失败时触发该事件。 | +| seeking | { currenttime: value } | 操作进度条过程时上报时间信息,单位为s。 | +| seeked | { currenttime: value } | 操作进度条完成后,上报播放时间信息,单位为s。 | +| timeupdate | { currenttime: value } | 播放进度变化时触发该事件,单位为s,更新时间间隔为250ms。 | + + +## 方法 + +除支持[通用方法](../arkui-js/js-components-common-methods.md)外,还支持如下方法: + +| 名称 | 参数 | 描述 | +| -------- | -------- | -------- | +| start | - | 请求播放视频。 | +| pause | - | 请求暂停播放视频。 | +| setCurrentTime | { currenttime: value } | 指定视频播放的进度位置,单位为s。 | + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 在attached组件生命周期回调后,可以调用上述组件方法。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-media.md b/zh-cn/application-dev/reference/arkui-js/js-components-media.md index 3f561002ae7651e323b68aebb88077649738e20c..ab7993298a082ac12e1ebcc2223238794f11d296 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-media.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-media.md @@ -1,5 +1,5 @@ -# 媒体组件 +# 媒体组件 -- **[video](js-components-media-video.md)** +- **[video](js-components-media-video.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animate.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animate.md index b0d01e9f97f8139c573318340e9ac73ab03a3cea..0a9654cadd1bd4bd616663e8abc0362c3a6a3bcb 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animate.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animate.md @@ -1,198 +1,42 @@ -# animate +# animate -设置svg组件的属性动画。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +设置svg组件的属性动画。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

attributeName

-

string

-

-

-

-

设置需要进行动效的属性名。

-

begin

-

<time>

-

0

-

-

设置动效的延迟时间。

-

支持输入ms(毫秒)、s(秒)、m(分),默认为s(秒),其他格式不支持

-

dur

-

<time>

-

0

-

-

设置动效持续时间,如果dur没设置,按照end-begin的结果作为持续时间,小于等于0时,动效不触发。

-

支持输入ms(毫秒)、s(秒)、m(分),默认为s(秒),其他格式不支持

-

end

-

<time>

-

0

-

-

设置动效多久时间后结束。支持输入ms(毫秒)、s(秒)、m(分),默认为s(秒),其他格式不支持

-

repeatCount

-

<number | indefinite>

-

1

-

-

设置动画播放的次数,默认无限次播放(indefinite),可通过设置为数值1仅播放一次。

-

fill

-

<freeze | remove>

-

remove

-

-

设置动画结束时的状态。

-

calcMode

-

<discrete | linear | paced | spline>

-

linear

-

-

设置动画的插值模式。

-

discrete:阶跃,from值直接跳转到to的值;

-

linear:线性;

-

paced:线性,设置此项后keyTimes和keyPoints值无效

-

spline:自定义贝塞尔曲线,spline点定义在keyTimes属性中,每个时间间隔控制点由keySplines定义

-

keyTimes

-

string

-

-

-

-

设置关键帧动画的开始时间,值为0~1之间的数值用分号隔开,比如0;0.3;0.8;1。keyTimes、keySplines、values组合设置关键帧动画。keyTimes和values的个数保持一致。keySplines个数为keyTimes个数减一

-

keySplines

-

string

-

-

-

-

与keyTimes相关联的一组贝塞尔控制点。定义每个关键帧的贝塞尔曲线,曲线之间用分号隔开。曲线内的两个控制掉格式为x1 y1 x2 y2。比如0.5 0 0.5 1; 0.5 0 0.5 1;0.5 0 0.5 1

-

by

-

number

-

-

-

-

在动画中对某一指定属性,添加相对偏移值,from默认为原属性值。

-

from

-

string

-

-

-

-

设置需要进行动画的属性的开始值。

-

如果已经设置了values属性,则from失效。

-

to

-

string

-

-

-

-

设置需要进行动画的属性的结束值。

-

如果已经设置了values属性,则to都失效。

-

values

-

string

-

-

-

-

设置一组动画的变化值。格式为value1;value2;value3。

-
+## 属性 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| attributeName | string | - | 否 | 设置需要进行动效的属性名。 | +| begin | <time> | 0 | 否 | 设置动效的延迟时间。
支持输入ms(毫秒)、s(秒)、m(分),默认为s(秒),其他格式不支持 | +| dur | <time> | 0 | 否 | 设置动效持续时间,如果dur没设置,按照end-begin的结果作为持续时间,小于等于0时,动效不触发。
支持输入ms(毫秒)、s(秒)、m(分),默认为s(秒),其他格式不支持 | +| end | <time> | 0 | 否 | 设置动效多久时间后结束。支持输入ms(毫秒)、s(秒)、m(分),默认为s(秒),其他格式不支持 | +| repeatCount | <number \| indefinite> | 1 | 否 | 设置动画播放的次数,默认无限次播放(indefinite),可通过设置为数值1仅播放一次。 | +| fill | <freeze \| remove> | remove | 否 | 设置动画结束时的状态。 | +| calcMode | <discrete \| linear \| paced \| spline> | linear | 否 | 设置动画的插值模式。
discrete:阶跃,from值直接跳转到to的值;
linear:线性;
paced:线性,设置此项后keyTimes和keyPoints值无效
spline:自定义贝塞尔曲线,spline点定义在keyTimes属性中,每个时间间隔控制点由keySplines定义 | +| keyTimes | string | - | 否 | 设置关键帧动画的开始时间,值为0~1之间的数值用分号隔开,比如0;0.3;0.8;1。keyTimes、keySplines、values组合设置关键帧动画。keyTimes和values的个数保持一致。keySplines个数为keyTimes个数减一 | +| keySplines | string | - | 否 | 与keyTimes相关联的一组贝塞尔控制点。定义每个关键帧的贝塞尔曲线,曲线之间用分号隔开。曲线内的两个控制掉格式为x1 y1 x2 y2。比如0.5 0 0.5 1; 0.5 0 0.5 1;0.5 0 0.5 1 | +| by | number | - | 否 | 在动画中对某一指定属性,添加相对偏移值,from默认为原属性值。 | +| from | string | - | 否 | 设置需要进行动画的属性的开始值。
如果已经设置了values属性,则from失效。 | +| to | string | - | 否 | 设置需要进行动画的属性的结束值。
如果已经设置了values属性,则to都失效。 | +| values | string | - | 否 | 设置一组动画的变化值。格式为value1;value2;value3。 | + -## 示例 +## 示例 ``` @@ -206,7 +50,9 @@ ``` -![](figures/animate-1.gif) + +![zh-cn_image_0000001173324703](figures/zh-cn_image_0000001173324703.gif) + ``` @@ -220,7 +66,9 @@ ``` -![](figures/1-3.gif) + +![zh-cn_image_0000001167662852](figures/zh-cn_image_0000001167662852.gif) + ``` @@ -233,7 +81,9 @@ ``` -![](figures/animate-3.gif) + +![zh-cn_image_0000001127284938](figures/zh-cn_image_0000001127284938.gif) + ``` @@ -265,5 +115,5 @@ ``` -![](figures/animate-4.gif) +![zh-cn_image_0000001127125126](figures/zh-cn_image_0000001127125126.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md index ddb8f30d57873b357fcd5034c0f8839ec3ac21be..0c6874915cdc24d394332d087e97a38b9ff26a05 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatemotion.md @@ -1,71 +1,33 @@ -# animateMotion +# animateMotion -路径动效。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +路径动效。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 - -支持animate属性\(values不生效\)和以下表格中的属性。 - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

keyPoints

-

string

-

-

-

-

一组关键帧的点位置,每帧的值为对象沿路径的距离比例。功能与animate属性中的values相同。

-

path

-

string

-

-

-

-

定义运动的路径,使用与path组件d属性相同的语法。

-

rotate

-

[auto | auto-reverse | <number>]

-

auto

-

-

-

设置动画对象的旋转方向

-
- -## 示例 + +## 属性 + +支持animate属性(values不生效)和以下表格中的属性。 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| keyPoints | string | - | 是 | 一组关键帧的点位置,每帧的值为对象沿路径的距离比例。功能与animate属性中的values相同。 | +| path | string | - | 是 | 定义运动的路径,使用与path组件d属性相同的语法。 | +| rotate | [auto \| auto-reverse \| <number>] | auto | - | 设置动画对象的旋转方向 | + + +## 示例 ``` @@ -89,5 +51,5 @@ ``` -![](figures/2-4.gif) +![zh-cn_image_0000001213381209](figures/zh-cn_image_0000001213381209.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md index 47f29efe330e6aa6b675c73793b682223b910f31..cae336c9b05042825aac304e7d661c443e38829f 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-animatetransform.md @@ -1,51 +1,34 @@ -# animateTransform +# animateTransform + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 transform动效,支持的组件范围: -, , , , , , , ->![](../../public_sys-resources/icon-note.gif) **说明:** ->该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +<circle>, <ellipse>, <line>, <path>, <polygon>, <polyline>, <rect>, <text> -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 不支持。 -## 属性 + +## 属性 支持animate属性和以下表格中的属性。 - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

type

-

[translate | scale | rotate | skewX | skewY]

-

-

-

-

设置transform动画的类型

-
- -## 示例 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| type | [translate \| scale \| rotate \| skewX \| skewY] | - | 是 | 设置transform动画的类型 | + + +## 示例 ``` @@ -106,10 +89,13 @@ transform动效,支持的组件范围: } ``` -![](figures/animate-transform.gif) + +![zh-cn_image_0000001127285004](figures/zh-cn_image_0000001127285004.gif) + 动画叠加 + ```
@@ -144,6 +130,7 @@ transform动效,支持的组件范围:
``` + ``` /* xxx.css */ .container { @@ -161,10 +148,13 @@ transform动效,支持的组件范围: } ``` -![](figures/animate-transform2.gif) + +![zh-cn_image_0000001127125192](figures/zh-cn_image_0000001127125192.gif) + 涉及组件示例 + ```
@@ -211,6 +201,7 @@ transform动效,支持的组件范围:
``` + ``` /* xxx.css */ .container { @@ -228,5 +219,6 @@ transform动效,支持的组件范围: } ``` -![](figures/animate-transform3.gif) + +![zh-cn_image_0000001173324765](figures/zh-cn_image_0000001173324765.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-circle.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-circle.md index ddbd7afe877068b275c2358e052566f7ead8538d..7ee5c552aa7540d8d2be194c726cc3e675e38c48 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-circle.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-circle.md @@ -1,82 +1,34 @@ -# circle +# circle -圆形形状。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +圆形形状。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持animate、animateMotion、animateTransform。 -## 属性 - -支持Svg组件[通用属性](js-components-svg-common-attributes.md)和以下属性。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

cx

-

<length>|<percentage>

-

0

-

-

设置圆心的x轴坐标。支持属性动画

-

cy

-

<length>|<percentage>

-

0

-

-

设置圆心的y轴坐标。支持属性动画

-

r

-

<length>|<percentage>

-

0

-

-

设置圆的半径。支持属性动画

-
- -## 示例 + +## 属性 + +支持Svg组件[通用属性](../arkui-js/js-components-svg-common-attributes.md)和以下属性。 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| cx | <length>\|<percentage> | 0 | 否 | 设置圆心的x轴坐标。支持属性动画。 | +| cy | <length>\|<percentage> | 0 | 否 | 设置圆心的y轴坐标。支持属性动画。 | +| r | <length>\|<percentage> | 0 | 否 | 设置圆的半径。支持属性动画。 | + + +## 示例 ``` @@ -88,5 +40,5 @@ ``` -![](figures/zh-cn_image_0000001173164853.png) +![zh-cn_image_0000001173164853](figures/zh-cn_image_0000001173164853.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-common-attributes.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-common-attributes.md index 83a90a2823b2153fe91d6950e8e83f525e148a43..4a07df766144fb030132dbf03a0eaa061896542d 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-common-attributes.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-common-attributes.md @@ -1,175 +1,21 @@ -# 通用属性 +# 通用属性 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

fill

-

<color>

-

black

-

-

使用简写属性设置元素的填充色。支持属性动画。

-

fill-opacity

-

number

-

1

-

-

填充色的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。

-

fill-rule

-

nonzero | evenodd

-

nonzero

-

-

nonzero:非零规则; evenodd:奇偶规则

-

opacity

-

number

-

1

-

-

元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。

-

stroke

-

<color>

-

-

-

-

设置形状轮廓的颜色。支持属性动画。

-

stroke-dasharray

-

<string>

-

-

-

-

指定短划线和缺口的长度。格式为[length length length length],短划线和缺口的长度中间空格隔开成对出现。

-

stroke-dashoffset

-

<length>

-

0

-

-

设置关联虚线数组渲染时的偏移量。支持属性动画

-

stroke-linejoin

-

[bevel | miter | round]

-

miter

-

-

进行描边时在路径的拐角处使用的形状。

-

bevel:使用斜角连接路径段;

-

miter:使用尖角连接路径段;

-

round:使用圆角连接路径段。

-

stroke-linecap

-

[butt | round | square]

-

butt

-

-

路径描边时在它们的结尾处使用的形状。

-

butt:不在路径两端扩展;

-

round:在路径的末端延伸半个圆,直径等于线度。

-

square:在路径的末端延伸半个圆,宽度等于线宽的一半,高度等于线宽。

-

stroke-miterlimit

-

number

-

4

-

-

设置将锐角绘制成斜角的极限值。支持属性动画

-

stroke-opacity

-

number

-

1

-

-

轮廓线条的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画

-

stroke-width

-

<length>

-

1px

-

-

设置轮廓线条的宽度。支持属性动画

-

transform

-

<string>

-

-

-

-

设置组件以及子组件的坐标变换参数。

-

支持以下格式:

-

translate(<x> [<y>]) :沿x[y]轴方向平移

-

scale(<x> [<y>]) :沿x[y]轴缩放

-

rotate(<a> [<x> <y>]) :以(x,y)点进行旋转a度角

-

skewX(<a>) :沿x轴倾斜a度角的变换

-

skewY(<a>) :沿y轴倾斜a度角的变换

-
+| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| fill | <color> | black | 否 | 使用简写属性设置元素的填充色。支持属性动画。 | +| fill-opacity | number | 1 | 否 | 填充色的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。 | +| fill-rule | nonzero \| evenodd | nonzero | 否 | nonzero:非零规则; evenodd:奇偶规则 | +| opacity | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。 | +| stroke | <color> | - | 否 | 设置形状轮廓的颜色。支持属性动画。 | +| stroke-dasharray | <string> | - | 否 | 指定短划线和缺口的长度。格式为[length length length length],短划线和缺口的长度中间空格隔开成对出现。 | +| stroke-dashoffset | <length> | 0 | 否 | 设置关联虚线数组渲染时的偏移量。支持属性动画 | +| stroke-linejoin | [bevel \| miter \| round] | miter | 否 | 进行描边时在路径的拐角处使用的形状。
bevel:使用斜角连接路径段;
miter:使用尖角连接路径段;
round:使用圆角连接路径段。 | +| stroke-linecap | [butt \| round \| square] | butt | 否 | 路径描边时在它们的结尾处使用的形状。
butt:不在路径两端扩展;
round:在路径的末端延伸半个圆,直径等于线度。
square:在路径的末端延伸半个圆,宽度等于线宽的一半,高度等于线宽。 | +| stroke-miterlimit | number | 4 | 否 | 设置将锐角绘制成斜角的极限值。支持属性动画 | +| stroke-opacity | number | 1 | 否 | 轮廓线条的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画 | +| stroke-width | <length> | 1px | 否 | 设置轮廓线条的宽度。支持属性动画 | +| transform | <string> | - | 否 | 设置组件以及子组件的坐标变换参数。
支持以下格式:
translate(<x> [<y>]) :沿x[y]轴方向平移
scale(<x> [<y>]) :沿x[y]轴缩放
rotate(<a> [<x> <y>]) :以(x,y)点进行旋转a度角
skewX(<a>) :沿x轴倾斜a度角的变换
skewY(<a>) :沿y轴倾斜a度角的变换 | diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-ellipse.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-ellipse.md index 46fd26dd93fee920c9c7606af6eab6b98528c9e2..9c69504f6a8a8488958f9c088fc7755359c5ae65 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-ellipse.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-ellipse.md @@ -1,93 +1,35 @@ -# ellipse +# ellipse -椭圆形状。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +椭圆形状。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持animate、animateMotion、animateTransform。 -## 属性 - -支持Svg组件[通用属性](js-components-svg-common-attributes.md)和以下属性。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

cx

-

<length>|<percentage>

-

0

-

-

设置椭圆的x轴坐标。支持属性动画

-

cy

-

<length>|<percentage>

-

0

-

-

设置椭圆的y轴坐标。支持属性动画

-

rx

-

<length>|<percentage>

-

0

-

-

设置椭圆x轴的半径。支持属性动画

-

ry

-

<length>|<percentage>

-

0

-

-

设置椭圆y轴的半径。支持属性动画

-
- -## 示例 + +## 属性 + +支持Svg组件[通用属性](../arkui-js/js-components-svg-common-attributes.md)和以下属性。 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| cx | <length>\|<percentage> | 0 | 否 | 设置椭圆的x轴坐标。支持属性动画 | +| cy | <length>\|<percentage> | 0 | 否 | 设置椭圆的y轴坐标。支持属性动画 | +| rx | <length>\|<percentage> | 0 | 否 | 设置椭圆x轴的半径。支持属性动画 | +| ry | <length>\|<percentage> | 0 | 否 | 设置椭圆y轴的半径。支持属性动画 | + + +## 示例 ``` @@ -99,5 +41,5 @@ ``` -![](figures/zh-cn_image_0000001173164793.png) +![zh-cn_image_0000001173164793](figures/zh-cn_image_0000001173164793.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-line.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-line.md index 78b0f4c506ec7fecaa21fbf93196b0c9fe62590c..ae898c10942f3eb31793a5cfcaeb4705fd94fc2c 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-line.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-line.md @@ -1,93 +1,35 @@ -# line +# line -绘制线条。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +绘制线条。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持animate、animateMotion、animateTransform。 -## 属性 + +## 属性 支持所列的Svg组件通用属性和以下表格的属性。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

x1

-

<length>|<percentage>

-

-

-

-

设置线条起点的x轴坐标。支持属性动画

-

y1

-

<length>|<percentage>

-

-

-

-

设置线条起点的y轴坐标。支持属性动画

-

x2

-

<length>|<percentage>

-

-

-

-

设置线条终点的x轴坐标。支持属性动画

-

y2

-

<length>|<percentage>

-

-

-

-

设置线条终点的y轴坐标。支持属性动画

-
- -## 示例 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| x1 | <length>\|<percentage> | - | 否 | 设置线条起点的x轴坐标。支持属性动画。 | +| y1 | <length>\|<percentage> | - | 否 | 设置线条起点的y轴坐标。支持属性动画。 | +| x2 | <length>\|<percentage> | - | 否 | 设置线条终点的x轴坐标。支持属性动画。 | +| y2 | <length>\|<percentage> | - | 否 | 设置线条终点的y轴坐标。支持属性动画。 | + + +## 示例 ``` @@ -103,5 +45,5 @@ ``` -![](figures/zh-cn_image_0000001127284954.png) +![zh-cn_image_0000001127284954](figures/zh-cn_image_0000001127284954.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-path.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-path.md index 287f8897618ef53411a5b1e9b6ca600dd8a78136..ba7ba55af69649a3eeb813b18b6e24a5111726c4 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-path.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-path.md @@ -1,62 +1,32 @@ -# path +# path -绘制路径。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +绘制路径。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持animate、animateMotion、animateTransform。 -## 属性 - -支持Svg组件[通用属性](js-components-svg-common-attributes.md)和以下属性,设置的通用属性会传递给子组件。 - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

d

-

string

-

-

-

-

设置路径的形状。包含一组字符指令,大写字母为绝对路径,小写字符为相对路径。

-

字母指令表示的意义如下:

-
  • M/m = moveto
  • L/l = lineto
  • H/h = horizontal lineto
  • V/v = vertical lineto
  • C/c = curveto
  • S/s = smooth curveto
  • Q/q = quadratic Belzier curve
  • T/t = smooth quadratic Belzier curveto
  • A/a = elliptical Arc
  • Z/z = closepath
-
- -## 示例 + +## 属性 + +支持Svg组件[通用属性](../arkui-js/js-components-svg-common-attributes.md)和以下属性,设置的通用属性会传递给子组件。 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| d | string | - | 否 | 设置路径的形状。包含一组字符指令,大写字母为绝对路径,小写字符为相对路径。
字母指令表示的意义如下:
- M/m = moveto
- L/l = lineto
- H/h = horizontal lineto
- V/v = vertical lineto
- C/c = curveto
- S/s = smooth curveto
- Q/q = quadratic Belzier curve
- T/t = smooth quadratic Belzier curveto
- A/a = elliptical Arc
- Z/z = closepath | + + +## 示例 ``` @@ -69,5 +39,5 @@ ``` -![](figures/zh-cn_image_0000001173164891.png) +![zh-cn_image_0000001173164891](figures/zh-cn_image_0000001173164891.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-polygon.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-polygon.md index edd2d806a4d385c2c9710d13d500164e0d4888db..1f4c4870badaeef483b402e52a2ba7ff5cb280df 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-polygon.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-polygon.md @@ -1,62 +1,32 @@ -# polygon +# polygon -绘制多边形。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +绘制多边形。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持animate、animateMotion、animateTransform。 -## 属性 - -支持Svg组件[通用属性](js-components-svg-common-attributes.md)和以下属性。 - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

points

-

string

-

-

-

-

设置多边形的多个坐标点

-

格式为[x1,y1 x2,y2 x3,y3]。

-

支持属性动画,如果属性动画里设置的动效变化值的坐标个数与原始points的格式不一样,则无效

-
- -## 示例 + +## 属性 + +支持Svg组件[通用属性](../arkui-js/js-components-svg-common-attributes.md)和以下属性。 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| points | string | - | 否 | 设置多边形的多个坐标点
格式为[x1,y1 x2,y2 x3,y3]。
支持属性动画,如果属性动画里设置的动效变化值的坐标个数与原始points的格式不一样,则无效 | + + +## 示例 ``` @@ -68,5 +38,5 @@ ``` -![](figures/zh-cn_image_0000001173324721.png) +![zh-cn_image_0000001173324721](figures/zh-cn_image_0000001173324721.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-polyline.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-polyline.md index 1d34290e28c8fdbbbf6a6ce227a85922f61a1b24..4b39e2e6192a6f6b12914fa9a2fcf0efeb752a4b 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-polyline.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-polyline.md @@ -1,62 +1,32 @@ -# polyline +# polyline -绘制折线。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +绘制折线。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持animate、animateMotion、animateTransform。 -## 属性 + +## 属性 支持所列的Svg组件通用属性和以下表格的属性。 - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

points

-

string

-

-

-

-

设置折线的多个坐标点

-

格式为[x1,y1 x2,y2 x3,y3]。

-

支持属性动画,如果属性动画里设置的动效变化值的坐标个数与原始points的格式不一样,则无效

-
- -## 示例 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| points | string | - | 否 | 设置折线的多个坐标点
格式为[x1,y1 x2,y2 x3,y3]。
支持属性动画,如果属性动画里设置的动效变化值的坐标个数与原始points的格式不一样,则无效 | + + +## 示例 ``` @@ -68,5 +38,5 @@ ``` -![](figures/zh-cn_image_0000001173164845.png) +![zh-cn_image_0000001173164845](figures/zh-cn_image_0000001173164845.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-rect.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-rect.md index 06b2c9bf17b8b55e5d68996e7052c9d600f1a0d6..5acb102656db19d94b4aa713cf78725e49318504 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-rect.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-rect.md @@ -1,115 +1,37 @@ -# rect +# rect -用于绘制矩形、圆角矩形。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +用于绘制矩形、圆角矩形。 -## 权限列表 +## 权限列表 无 -## 子组件 + +## 子组件 支持animate、animateMotion、animateTransform。 -## 属性 - -支持Svg组件[通用属性](js-components-svg-common-attributes.md)和以下属性。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

width

-

<length>|<percentage>

-

0

-

-

设置矩形的宽度。支持属性动画

-

height

-

<length>|<percentage>

-

0

-

-

设置矩形的高度。支持属性动画

-

x

-

<length>|<percentage>

-

0

-

-

设置矩形左上角x轴坐标。支持属性动画

-

y

-

<length>|<percentage>

-

0

-

-

设置矩形左上角y轴坐标。支持属性动画

-

rx

-

<length>|<percentage>

-

0

-

-

设置矩形圆角x方向半径。支持属性动画

-

ry

-

<length>|<percentage>

-

0

-

-

设置矩形圆角y方向半径。支持属性动画

-
- -## 示例 + +## 属性 + +支持Svg组件[通用属性](../arkui-js/js-components-svg-common-attributes.md)和以下属性。 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| width | <length>\|<percentage> | 0 | 否 | 设置矩形的宽度。支持属性动画 | +| height | <length>\|<percentage> | 0 | 否 | 设置矩形的高度。支持属性动画 | +| x | <length>\|<percentage> | 0 | 否 | 设置矩形左上角x轴坐标。支持属性动画 | +| y | <length>\|<percentage> | 0 | 否 | 设置矩形左上角y轴坐标。支持属性动画 | +| rx | <length>\|<percentage> | 0 | 否 | 设置矩形圆角x方向半径。支持属性动画 | +| ry | <length>\|<percentage> | 0 | 否 | 设置矩形圆角y方向半径。支持属性动画 | + + +## 示例 ``` @@ -124,5 +46,5 @@ ``` -![](figures/0.png) +![zh-cn_image_0000001212053183](figures/zh-cn_image_0000001212053183.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-text.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-text.md index 778a5a80b4fd16ef350e80fee55a81172fe58d6c..34b96424911c9594abf9762fe4ccbef11ef9e741 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-text.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-text.md @@ -1,184 +1,49 @@ -# text +# text 文本,用于呈现一段信息。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ->- 文本的展示内容需要写在元素标签内,可嵌套tspan子元素标签分段,可嵌套textPath子元素标签按指定路径绘制。 ->- 只支持被父元素标签svg嵌套。 ->- 只支持默认字体sans-serif。 -## 权限列表 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - 文本的展示内容需要写在元素标签内,可嵌套tspan子元素标签分段,可嵌套textPath子元素标签按指定路径绘制。 +> +> - 只支持被父元素标签svg嵌套。 +> +> - 只支持默认字体sans-serif。 + +## 权限列表 无 -## 子组件 + +## 子组件 支持tspan、textpath、animate、animateTransform。 -## 属性 -支持以下表格中的属性。 +## 属性 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

x

-

<length>|<percentage>

-

0

-

-

设置组件左上角x轴坐标

-

y

-

<length>|<percentage>

-

0

-

-

设置组件左上角y轴坐标

-

dx

-

<length>|<percentage>

-

0

-

-

设置文本x轴偏移

-

dy

-

<length>|<percentage>

-

0

-

-

设置文本y轴偏移

-

rotate

-

number

-

0

-

-

字体以左下角为圆心旋转角度,正数顺时针,负数逆时针

-

font-size

-

<length>

-

30px

-

-

设置文本的尺寸。

-

fill

-

<color>

-

black

-

-

字体填充颜色

-

fill-opacity

-

number

-

1.0

-

-

字体填充透明度

-

opacity

-

number

-

1

-

-

元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。

-

stroke

-

<color>

-

black

-

-

绘制字体边框并指定颜色

-

stroke-width

-

number

-

1px

-

-

字体边框宽度

-

stroke-opacity

-

number

-

1.0

-

-

字体边框透明度

-
+支持以下表格中的属性。 -## 示例 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| x | <length>\|<percentage> | 0 | 否 | 设置组件左上角x轴坐标 | +| y | <length>\|<percentage> | 0 | 否 | 设置组件左上角y轴坐标 | +| dx | <length>\|<percentage> | 0 | 否 | 设置文本x轴偏移 | +| dy | <length>\|<percentage> | 0 | 否 | 设置文本y轴偏移 | +| rotate | number | 0 | 否 | 字体以左下角为圆心旋转角度,正数顺时针,负数逆时针 | +| font-size | <length> | 30px | 否 | 设置文本的尺寸。 | +| fill | <color> | black | 否 | 字体填充颜色 | +| fill-opacity | number | 1.0 | 否 | 字体填充透明度 | +| opacity | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。 | +| stroke | <color> | black | 否 | 绘制字体边框并指定颜色 | +| stroke-width | number | 1px | 否 | 字体边框宽度 | +| stroke-opacity | number | 1.0 | 否 | 字体边框透明度 | + + +## 示例 ``` /* xxx.css */ @@ -209,7 +74,7 @@ ``` -![](figures/text-part1.png) +![zh-cn_image_0000001173324697](figures/zh-cn_image_0000001173324697.png) 属性动画示例 @@ -238,7 +103,7 @@ ``` -![](figures/text-animate-part1.gif) +![zh-cn_image_0000001173324699](figures/zh-cn_image_0000001173324699.gif) ``` @@ -253,7 +118,7 @@ ``` -![](figures/text-animate-part2.gif) +![zh-cn_image_0000001173164783](figures/zh-cn_image_0000001173164783.gif) ``` @@ -272,5 +137,4 @@ ``` -![](figures/text-animate-part3.gif) - +![zh-cn_image_0000001127125122](figures/zh-cn_image_0000001127125122.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md index 083819fcf9490f8c4715e01a2905c787dcc4ebaa..eb9ffb6b56a46074c29f4017ba3a0b2fcd78ade6 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-textpath.md @@ -1,165 +1,49 @@ -# textPath +# textPath 沿路径绘制文本。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ->- 按指定的路径绘制文本,可嵌套子标签tspan分段。 ->- 只支持被父元素标签text嵌套。 -## 权限列表 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - 按指定的路径绘制文本,可嵌套子标签tspan分段。 +> +> - 只支持被父元素标签text嵌套。 + +## 权限列表 无 -## 子组件 + +## 子组件 tspan。 -## 属性 + +## 属性 + 支持以下表格中的属性。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

path

-

string

-

0

-

-

设置路径的形状。

-

字母指令表示的意义如下:

-
  • M = moveto
  • L = lineto
  • H = horizontal lineto
  • V = vertical lineto
  • C = curveto
  • S = smooth curveto
  • Q = quadratic Belzier curve
  • T = smooth quadratic Belzier curveto
  • A = elliptical Arc
  • Z = closepath
-

startOffset

-

<length>|<percentage>

-

0

-

-

设置文本沿path绘制的起始偏移。

-

font-size

-

<length>

-

30px

-

-

设置文本的尺寸。

-

fill

-

<color>

-

black

-

-

字体填充颜色

-

by

-

number

-

-

-

-

相对被指定动画的属性偏移值,from默认为原属性值。

-

opacity

-

number

-

1

-

-

元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。

-

fill-opacity

-

number

-

1.0

-

-

字体填充透明度

-

stroke

-

<color>

-

black

-

-

绘制字体边框并指定颜色

-

stroke-width

-

number

-

1px

-

-

字体边框宽度

-

stroke-opacity

-

number

-

1.0

-

-

字体边框透明度

-
- -## 示例 - -textspan属性示例,textpath文本内容沿着属性path中的路径绘制文本,起点偏移20%的path长度。(绘制的元素曲线仅做参照) + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| path | string | 0 | 是 | 设置路径的形状。
字母指令表示的意义如下:
- M = moveto
- L = lineto
- H = horizontal lineto
- V = vertical lineto
- C = curveto
- S = smooth curveto
- Q = quadratic Belzier curve
- T = smooth quadratic Belzier curveto
- A = elliptical Arc
- Z = closepath | +| startOffset | <length>\|<percentage> | 0 | 否 | 设置文本沿path绘制的起始偏移。 | +| font-size | <length> | 30px | 否 | 设置文本的尺寸。 | +| fill | <color> | black | 否 | 字体填充颜色 | +| by | number | - | 否 | 相对被指定动画的属性偏移值,from默认为原属性值。 | +| opacity | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。 | +| fill-opacity | number | 1.0 | 否 | 字体填充透明度 | +| stroke | <color> | black | 否 | 绘制字体边框并指定颜色 | +| stroke-width | number | 1px | 否 | 字体边框宽度 | +| stroke-opacity | number | 1.0 | 否 | 字体边框透明度 | + + +## 示例 + +textspan属性示例,textpath文本内容沿着属性path中的路径绘制文本,起点偏移20%的path长度。(绘制的元素<path>曲线仅做参照) ``` /* xxx.css */ @@ -186,7 +70,7 @@ textspan属性示例,textpath文本内容沿着属性path中的路径绘制文 ``` -![](figures/textPath-part1.png) +![zh-cn_image_0000001173164775](figures/zh-cn_image_0000001173164775.png) textpath与tspan组合示例与效果图 @@ -206,7 +90,7 @@ textpath与tspan组合示例与效果图 ``` -![](figures/textPath-part2.png) +![zh-cn_image_0000001173324691](figures/zh-cn_image_0000001173324691.png) ``` @@ -226,7 +110,7 @@ textpath与tspan组合示例与效果图 ``` -![](figures/textPath-part3.png) +![zh-cn_image_0000001173324689](figures/zh-cn_image_0000001173324689.png) ``` @@ -247,7 +131,7 @@ textpath与tspan组合示例与效果图 ``` -![](figures/textPath-part4.png) +![zh-cn_image_0000001127284930](figures/zh-cn_image_0000001127284930.png) startOffset属性动画,文本绘制时起点偏移从10%运动到40%,不绘制超出path长度范围的文本。 @@ -279,7 +163,7 @@ startOffset属性动画,文本绘制时起点偏移从10%运动到40%,不绘 ``` -![](figures/textpath-animate1.gif) +![zh-cn_image_0000001127125118](figures/zh-cn_image_0000001127125118.gif) textpath与tspan组合属性动画与效果图 @@ -310,13 +194,13 @@ textpath与tspan组合属性动画与效果图 ``` -![](figures/textpath-animate2.gif) +![zh-cn_image_0000001173324693](figures/zh-cn_image_0000001173324693.gif) -\(1\) "tspan attribute x|rotate" 文本绘制起点偏移从50px运动到100px,顺时针旋转0度到360度。 +(1) "tspan attribute x|rotate" 文本绘制起点偏移从50px运动到100px,顺时针旋转0度到360度。 -\(2\) "tspan attribute dx|opacity" 在 "tspan static." 绘制结束后再开始绘制,向后偏移量从0%运动到30%,透明度从浅到深变化。 +(2) "tspan attribute dx|opacity" 在 "tspan static." 绘制结束后再开始绘制,向后偏移量从0%运动到30%,透明度从浅到深变化。 -\(3\) "tspan move" 在上一段tspan绘制完成后,向后偏移5%的距离进行绘制,呈现跟随前一段tspan运动的效果。 +(3) "tspan move" 在上一段tspan绘制完成后,向后偏移5%的距离进行绘制,呈现跟随前一段tspan运动的效果。 textpath与tspan组合属性动画与效果图 @@ -346,15 +230,15 @@ textpath与tspan组合属性动画与效果图 ``` -![](figures/textpath-animate3.gif) +![zh-cn_image_0000001173164779](figures/zh-cn_image_0000001173164779.gif) -\(1\) "This is TextPath." 在path上无偏移绘制第一段文本内容,大小30px,颜色"\#D2691E"。 +(1) "This is TextPath." 在path上无偏移绘制第一段文本内容,大小30px,颜色"\#D2691E"。 -\(2\) "tspan attribute fill|fill-opacity" 相对上一段文本结束后偏移20px,颜色从蓝到红,透明度从浅到深。 +(2) "tspan attribute fill|fill-opacity" 相对上一段文本结束后偏移20px,颜色从蓝到红,透明度从浅到深。 -\(3\) "tspan attribute font-size" 绘制起点相对上一段结束后偏移20px,起点静止,字体大小从10px到50px,整体长度持续拉长。 +(3) "tspan attribute font-size" 绘制起点相对上一段结束后偏移20px,起点静止,字体大小从10px到50px,整体长度持续拉长。 -\(4\) "Single tspan" 在上一段的尾部做水平绘制,呈现跟随上一段运动的效果。 +(4) "Single tspan" 在上一段的尾部做水平绘制,呈现跟随上一段运动的效果。 textpath与tspan组合属性动画与效果图 @@ -383,9 +267,8 @@ textpath与tspan组合属性动画与效果图 ``` -![](figures/textpath-animate4.gif) - -\(1\) "tspan attribute stroke" 轮廓颜色从红色逐渐转变成绿色。 +![zh-cn_image_0000001127284924](figures/zh-cn_image_0000001127284924.gif) -\(2\) "tspan attribute stroke-width-opacity" 轮廓宽度从细1px转变粗5px,透明度从浅到深。 +(1) "tspan attribute stroke" 轮廓颜色从红色逐渐转变成绿色。 +(2) "tspan attribute stroke-width-opacity" 轮廓宽度从细1px转变粗5px,透明度从浅到深。 diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg-tspan.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg-tspan.md index c89915027092da110534ea95b9a39942eb23c092..0a1cb24abbce6d468d31e08aba802c1d1c4b3367 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg-tspan.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg-tspan.md @@ -1,179 +1,46 @@ -# tspan +# tspan ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ->- 文本的展示内容需要写在元素标签内,可嵌套子元素标签tspan分段。 ->- 文本分段,只支持被父元素标签svg嵌套。 +添加文本样式。 -## 权限列表 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - 文本的展示内容需要写在元素标签内,可嵌套子元素标签tspan分段。 +> +> - 文本分段,只支持被父元素标签svg嵌套。 + +## 权限列表 无 -## 子组件 + +## 子组件 支持tspan。 + 支持以下表格中的属性。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

x

-

<length>|<percentage>

-

0

-

-

设置组件左上角x轴坐标

-

y

-

<length>|<percentage>

-

0

-

-

设置组件左上角y轴坐标。作为textpath子组件时失效。

-

dx

-

<length>|<percentage>

-

0

-

-

设置文本x轴偏移

-

dy

-

<length>|<percentage>

-

0

-

-

设置文本y轴偏移。作为textpath子组件时失效。

-

rotate

-

number

-

0

-

-

字体以左下角为圆心旋转角度,正数顺时针,负数逆时针

-

font-size

-

<length>

-

30px

-

-

设置文本的尺寸。

-

fill

-

<color>

-

black

-

-

字体填充颜色

-

opacity

-

number

-

1

-

-

元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。

-

fill-opacity

-

number

-

1.0

-

-

字体填充透明度

-

stroke

-

<color>

-

black

-

-

绘制字体边框并指定颜色

-

stroke-width

-

number

-

1px

-

-

字体边框宽度

-

stroke-opacity

-

number

-

1.0

-

-

字体边框透明度

-
-## 示例 +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| x | <length>\|<percentage> | 0 | 否 | 设置组件左上角x轴坐标。 | +| y | <length>\|<percentage> | 0 | 否 | 设置组件左上角y轴坐标。作为textpath子组件时失效。 | +| dx | <length>\|<percentage> | 0 | 否 | 设置文本x轴偏移。 | +| dy | <length>\|<percentage> | 0 | 否 | 设置文本y轴偏移。作为textpath子组件时失效。 | +| rotate | number | 0 | 否 | 字体以左下角为圆心旋转角度,正数顺时针,负数逆时针。 | +| font-size | <length> | 30px | 否 | 设置文本的尺寸。 | +| fill | <color> | black | 否 | 字体填充颜色。 | +| opacity | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。支持属性动画。 | +| fill-opacity | number | 1.0 | 否 | 字体填充透明度。 | +| stroke | <color> | black | 否 | 绘制字体边框并指定颜色。 | +| stroke-width | number | 1px | 否 | 字体边框宽度。 | +| stroke-opacity | number | 1.0 | 否 | 字体边框透明度。 | + + +## 示例 ``` /* xxx.css */ @@ -206,7 +73,7 @@ ``` -![](figures/tspan-part1.png) +![zh-cn_image_0000001127125196](figures/zh-cn_image_0000001127125196.png) 属性动画示例 @@ -244,7 +111,7 @@ ``` -![](figures/tspan-animate-part1.gif) +![zh-cn_image_0000001127285008](figures/zh-cn_image_0000001127285008.gif) ``` @@ -261,7 +128,7 @@ ``` -![](figures/tspan-animate-part2.gif) +![zh-cn_image_0000001127125198](figures/zh-cn_image_0000001127125198.gif) ``` @@ -277,7 +144,7 @@ ``` -![](figures/tspan-animate-part3.gif) +![zh-cn_image_0000001173164863](figures/zh-cn_image_0000001173164863.gif) ``` @@ -300,5 +167,4 @@ ``` -![](figures/tspan-animate-part4.gif) - +![zh-cn_image_0000001127125200](figures/zh-cn_image_0000001127125200.gif) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-svg.md b/zh-cn/application-dev/reference/arkui-js/js-components-svg.md index 261829752b595e3c5a294a7a285f455786490b13..85eeaf0f798849d7f018066e8f7344d6339e2d40 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-svg.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-svg.md @@ -1,104 +1,38 @@ -# svg +# svg 基础容器,主要作为svg的根节点使用,也可以在svg中嵌套使用。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->- 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ->- svg父组件或者svg组件需要定义宽高值,否则不进行绘制。 -## 权限列表 +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> - 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +> +> - svg父组件或者svg组件需要定义宽高值,否则不进行绘制。 + +## 权限列表 无 -## 子组件 + +## 子组件 支持svg、rect、circle、ellipse、path、line、polygon、polyline、text、animate、animateTransform。 -## 属性 - -支持Svg组件[通用属性](js-components-svg-common-attributes.md)和以下属性,设置的通用属性会传递给子组件。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

名称

-

类型

-

默认值

-

必填

-

描述

-

id

-

string

-

-

-

-

组件的唯一标识。

-

width

-

<length>|<percentage>

-

-

-

-

设置组件的宽度

-

height

-

<length>|<percentage>

-

-

-

-

设置组件的高度

-

x

-

<length>|<percentage>

-

-

-

-

设置当前svg的x轴坐标,根svg节点无效

-

y

-

<length>|<percentage>

-
  

-

设置当前svg的y轴坐标,根svg节点无效

-

viewBox

-

string

-

-

-

-

设置当前svg的视口。支持的格式为<number number number number>,4个参数分别表示min-x, min-y, width and height,viewBox的宽高和svg的宽高不一致,会以中心对齐进行缩放。

-
- -## 示例 + +## 属性 + +支持Svg组件[通用属性](../arkui-js/js-components-svg-common-attributes.md)和以下属性,设置的通用属性会传递给子组件。 + +| 名称 | 类型 | 默认值 | 必填 | 描述 | +| -------- | -------- | -------- | -------- | -------- | +| id | string | - | 否 | 组件的唯一标识。 | +| width | <length>\|<percentage> | - | 否 | 设置组件的宽度。 | +| height | <length>\|<percentage> | - | 否 | 设置组件的高度。 | +| x | <length>\|<percentage> | - | 否 | 设置当前svg的x轴坐标,根svg节点无效。 | +| y | <length>\|<percentage> | | 否 | 设置当前svg的y轴坐标,根svg节点无效。 | +| viewBox | string | - | 否 | 设置当前svg的视口。支持的格式为<number number number number>,4个参数分别表示min-x, min-y, width and height,viewBox的宽高和svg的宽高不一致,会以中心对齐进行缩放。 | + + +## 示例 ``` @@ -118,5 +52,5 @@ ``` -![](figures/zh-cn_image_0000001173164789.png) +![zh-cn_image_0000001173164789](figures/zh-cn_image_0000001173164789.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-components.md b/zh-cn/application-dev/reference/arkui-js/js-components.md index 611910fda1fbd94fb415ad74e628255f01c1b5bf..c6f4fa44f91fae98d13f762a9a4133a68d17f395 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components.md @@ -1,17 +1,17 @@ -# 组件 +# 组件 -- **[通用](js-components-common.md)** -- **[容器组件](js-components-container.md)** -- **[基础组件](js-components-basic.md)** +- **[通用](js-components-common.md)** -- **[媒体组件](js-components-media.md)** +- **[容器组件](js-components-container.md)** -- **[画布组件](js-components-canvas.md)** +- **[基础组件](js-components-basic.md)** -- **[栅格组件](js-components-grid.md)** +- **[媒体组件](js-components-media.md)** -- **[svg组件](js-svg.md)** +- **[画布组件](js-components-canvas.md)** +- **[栅格组件](js-components-grid.md)** +- **[svg组件](js-svg.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md index 3839b5cfc0ca3c7efdb5384a16673c5f02a45267..d653c4fd91115bae20695536326c9e2563aeb7c7 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-js/js-offscreencanvasrenderingcontext2d.md @@ -1,333 +1,223 @@ -# OffscreenCanvasRenderingContext2D对象 +# OffscreenCanvasRenderingContext2D对象 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 ->![](../../public_sys-resources/icon-note.gif) **说明:** ->从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 使用OffscreenCanvasRenderingContext2D在offscreen canvas上进行绘制,绘制对象可以是矩形、文本、图片等 -## 属性 + +## 属性 除支持与CanvasRenderingContext2D对象相同的属性外,还支持如下属性: - - - - - - - - - - -

属性

-

类型

-

描述

-

filter

-

string

-

设置图像的滤镜。

-

支持的滤镜效果如下:

-
  • blur:给图像设置高斯模糊
  • brightness:给图片应用一种线性乘法,使其看起来更亮或更暗
  • contrast:调整图像的对比度
  • drop-shadow:给图像设置一个阴影效果
  • grayscale:将图像转换为灰度图像
  • hue-rotate:给图像应用色相旋转
  • invert:反转输入图像
  • opacity:转化图像的透明程度
  • saturate:转换图像饱和度
  • sepia:将图像转换为深褐色
-
- -- 示例 - - ``` - -
- -
- ``` - - ``` - //xxx.js - export default { - onShow(){ - var ctx = this.$refs.canvasId.getContext('2d'); - var offscreen = new OffscreenCanvas(360, 500); - var offCanvas2 = offscreen.getContext("2d"); - var img = new Image(); - img.src = 'common/images/flower.jpg'; - offCanvas2.drawImage(img, 0, 0, 100, 100); - offCanvas2.filter = 'blur(5px)'; - offCanvas2.drawImage(img, 100, 0, 100, 100); - - offCanvas2.filter = 'grayscale(50%)'; - offCanvas2.drawImage(img, 200, 0, 100, 100); - - offCanvas2.filter = 'hue-rotate(90deg)'; - offCanvas2.drawImage(img, 0, 100, 100, 100); - - offCanvas2.filter = 'invert(100%)'; - offCanvas2.drawImage(img, 100, 100, 100, 100); - - offCanvas2.filter = 'drop-shadow(8px 8px 10px green)'; - offCanvas2.drawImage(img, 200, 100, 100, 100); - - offCanvas2.filter = 'brightness(0.4)'; - offCanvas2.drawImage(img, 0, 200, 100, 100); - - offCanvas2.filter = 'opacity(25%)'; - offCanvas2.drawImage(img, 100, 200, 100, 100); - - offCanvas2.filter = 'saturate(30%)'; - offCanvas2.drawImage(img, 200, 200, 100, 100); - - offCanvas2.filter = 'sepia(60%)'; - offCanvas2.drawImage(img, 0, 300, 100, 100); - - offCanvas2.filter = 'contrast(200%)'; - offCanvas2.drawImage(img, 100, 300, 100, 100); - var bitmap = offscreen.transferToImageBitmap(); - ctx.transferFromImageBitmap(bitmap); - } +| 属性 | 类型 | 描述 | +| -------- | -------- | -------- | +| filter | string | 设置图像的滤镜。
支持的滤镜效果如下:
- blur:给图像设置高斯模糊
- brightness:给图片应用一种线性乘法,使其看起来更亮或更暗
- contrast:调整图像的对比度
- drop-shadow:给图像设置一个阴影效果
- grayscale:将图像转换为灰度图像
- hue-rotate:给图像应用色相旋转
- invert:反转输入图像
- opacity:转化图像的透明程度
- saturate:转换图像饱和度
- sepia:将图像转换为深褐色 | + +- 示例 + ``` + +
+ +
+ ``` + + ``` + //xxx.js + export default { + onShow(){ + var ctx = this.$refs.canvasId.getContext('2d'); + var offscreen = new OffscreenCanvas(360, 500); + var offCanvas2 = offscreen.getContext("2d"); + var img = new Image(); + img.src = 'common/images/flower.jpg'; + offCanvas2.drawImage(img, 0, 0, 100, 100); + offCanvas2.filter = 'blur(5px)'; + offCanvas2.drawImage(img, 100, 0, 100, 100); + + offCanvas2.filter = 'grayscale(50%)'; + offCanvas2.drawImage(img, 200, 0, 100, 100); + + offCanvas2.filter = 'hue-rotate(90deg)'; + offCanvas2.drawImage(img, 0, 100, 100, 100); + + offCanvas2.filter = 'invert(100%)'; + offCanvas2.drawImage(img, 100, 100, 100, 100); + + offCanvas2.filter = 'drop-shadow(8px 8px 10px green)'; + offCanvas2.drawImage(img, 200, 100, 100, 100); + + offCanvas2.filter = 'brightness(0.4)'; + offCanvas2.drawImage(img, 0, 200, 100, 100); + + offCanvas2.filter = 'opacity(25%)'; + offCanvas2.drawImage(img, 100, 200, 100, 100); + + offCanvas2.filter = 'saturate(30%)'; + offCanvas2.drawImage(img, 200, 200, 100, 100); + + offCanvas2.filter = 'sepia(60%)'; + offCanvas2.drawImage(img, 0, 300, 100, 100); + + offCanvas2.filter = 'contrast(200%)'; + offCanvas2.drawImage(img, 100, 300, 100, 100); + var bitmap = offscreen.transferToImageBitmap(); + ctx.transferFromImageBitmap(bitmap); } - ``` + } + ``` - ![](figures/c3.png) + ![zh-cn_image_0000001152773860](figures/zh-cn_image_0000001152773860.png) -## 方法 +## 方法 除支持与CanvasRenderingContext2D对象相同的方法外,还支持如下方法: -### isPointInPath -isPointInPath\(path?: Path2D, x: number, y: number\): boolean +### isPointInPath + +isPointInPath(path?: Path2D, x: number, y: number): boolean 判断指定点是否在路径的区域内。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - -

参数名

-

参数类型

-

必填

-

描述

-

path

-

Path2D

-

-

可选对象,指定用来判断的路径。若没有设置,则使用当前路径。

-

x

-

number

-

-

待判断点的x轴坐标。

-

y

-

number

-

-

待判断点的y轴坐标。

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

boolean

-

指定点是否在路径的区域内。

-
- -- 示例 - - ``` - -
- In path:{{textValue}} - -
- ``` - - ``` - // xxx.js - export default { - data: { - textValue: 0 - }, - onShow(){ - var canvas = this.$refs.canvas.getContext('2d'); - var offscreen = new OffscreenCanvas(500,500); - var offscreenCanvasCtx = offscreen.getContext("2d"); - - offscreenCanvasCtx.rect(10, 10, 100, 100); - offscreenCanvasCtx.fill(); - this.textValue = offscreenCanvasCtx.isPointInPath(30, 70); - - var bitmap = offscreen.transferToImageBitmap(); - canvas.transferFromImageBitmap(bitmap); - } +- 参数 + | 参数名 | 参数类型 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | + | path | Path2D | 否 | 可选对象,指定用来判断的路径。若没有设置,则使用当前路径。 | + | x | number | 是 | 待判断点的x轴坐标。 | + | y | number | 是 | 待判断点的y轴坐标。 | + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | boolean | 指定点是否在路径的区域内。 | + +- 示例 + ``` + +
+ In path:{{textValue}} + +
+ ``` + + ``` + // xxx.js + export default { + data: { + textValue: 0 + }, + onShow(){ + var canvas = this.$refs.canvas.getContext('2d'); + var offscreen = new OffscreenCanvas(500,500); + var offscreenCanvasCtx = offscreen.getContext("2d"); + + offscreenCanvasCtx.rect(10, 10, 100, 100); + offscreenCanvasCtx.fill(); + this.textValue = offscreenCanvasCtx.isPointInPath(30, 70); + + var bitmap = offscreen.transferToImageBitmap(); + canvas.transferFromImageBitmap(bitmap); } - ``` + } + ``` - ![](figures/zh-cn_image_0000001224354967.png) + ![zh-cn_image_0000001224354967](figures/zh-cn_image_0000001224354967.png) -### isPointInStroke +### isPointInStroke -isPointInStroke\(path?: Path2D, x: number, y: number\): boolean +isPointInStroke(path?: Path2D, x: number, y: number): boolean 判断指定点是否在路径的边缘线上。 -- 参数 - - - - - - - - - - - - - - - - - - - - - - - -

参数名

-

参数类型

-

必填

-

描述

-

path

-

Path2D

-

-

可选对象,指定用来判断的路径。若没有设置,则使用当前路径。

-

x

-

number

-

-

待判断点的x轴坐标。

-

y

-

number

-

-

待判断点的y轴坐标。

-
- -- 返回值 - - - - - - - - - -

类型

-

说明

-

boolean

-

指定点是否在路径的区域内。

-
- -- 示例 - - ``` - -
- In path:{{textValue}} - -
- ``` - - ``` - // xxx.js - export default { - data: { - textValue: 0 - }, - onShow(){ - var canvas = this.$refs.canvas.getContext('2d'); - var offscreen = new OffscreenCanvas(500,500); - var offscreenCanvasCtx = offscreen.getContext("2d"); - - offscreenCanvasCtx.rect(10, 10, 100, 100); - offscreenCanvasCtx.stroke(); - this.textValue = offscreenCanvasCtx.isPointInStroke(50, 10); - - var bitmap = offscreen.transferToImageBitmap(); - canvas.transferFromImageBitmap(bitmap); - } - } - ``` - - ![](figures/zh-cn_image_0000001178875308.png) - - -### resetTransform - -resetTransform\(\): void - -- 示例 - - ``` - -
- In path:{{textValue}} - -
- ``` - - ``` - //xxx.js - export default { - data:{ - textValue:0 - }, - onShow(){ - var canvas = this.$refs.canvas.getContext('2d'); - var offscreen = new OffscreenCanvas(500,500); - var offscreenCanvasCtx = offscreen.getContext("2d"); - - offscreenCanvasCtx.transform(1, 0, 1.7, 1, 0, 0); - offscreenCanvasCtx.fillStyle = 'gray'; - offscreenCanvasCtx.fillRect(40, 40, 50, 20); - offscreenCanvasCtx.fillRect(40, 90, 50, 20); - - // Non-skewed rectangles - offscreenCanvasCtx.resetTransform(); - offscreenCanvasCtx.fillStyle = 'red'; - offscreenCanvasCtx.fillRect(40, 40, 50, 20); - offscreenCanvasCtx.fillRect(40, 90, 50, 20); - - var bitmap = offscreen.transferToImageBitmap(); - canvas.transferFromImageBitmap(bitmap); - } - } - ``` - - ![](figures/zh-cn_image_0000001179035242.png) - +- 参数 + | 参数名 | 参数类型 | 必填 | 描述 | + | -------- | -------- | -------- | -------- | + | path | Path2D | 否 | 可选对象,指定用来判断的路径。若没有设置,则使用当前路径。 | + | x | number | 是 | 待判断点的x轴坐标。 | + | y | number | 是 | 待判断点的y轴坐标。 | + +- 返回值 + | 类型 | 说明 | + | -------- | -------- | + | boolean | 指定点是否在路径的区域内。 | + +- 示例 + ``` + +
+ In path:{{textValue}} + +
+ ``` + + ``` + // xxx.js + export default { + data: { + textValue: 0 + }, + onShow(){ + var canvas = this.$refs.canvas.getContext('2d'); + var offscreen = new OffscreenCanvas(500,500); + var offscreenCanvasCtx = offscreen.getContext("2d"); + + offscreenCanvasCtx.rect(10, 10, 100, 100); + offscreenCanvasCtx.stroke(); + this.textValue = offscreenCanvasCtx.isPointInStroke(50, 10); + + var bitmap = offscreen.transferToImageBitmap(); + canvas.transferFromImageBitmap(bitmap); + } + } + ``` + + ![zh-cn_image_0000001178875308](figures/zh-cn_image_0000001178875308.png) + + +### resetTransform + +resetTransform(): void + +- 示例 + ``` + +
+ In path:{{textValue}} + +
+ ``` + + ``` + //xxx.js + export default { + data:{ + textValue:0 + }, + onShow(){ + var canvas = this.$refs.canvas.getContext('2d'); + var offscreen = new OffscreenCanvas(500,500); + var offscreenCanvasCtx = offscreen.getContext("2d"); + + offscreenCanvasCtx.transform(1, 0, 1.7, 1, 0, 0); + offscreenCanvasCtx.fillStyle = 'gray'; + offscreenCanvasCtx.fillRect(40, 40, 50, 20); + offscreenCanvasCtx.fillRect(40, 90, 50, 20); + + // Non-skewed rectangles + offscreenCanvasCtx.resetTransform(); + offscreenCanvasCtx.fillStyle = 'red'; + offscreenCanvasCtx.fillRect(40, 40, 50, 20); + offscreenCanvasCtx.fillRect(40, 90, 50, 20); + + var bitmap = offscreen.transferToImageBitmap(); + canvas.transferFromImageBitmap(bitmap); + } + } + ``` + + ![zh-cn_image_0000001179035242](figures/zh-cn_image_0000001179035242.png) diff --git a/zh-cn/application-dev/reference/arkui-js/js-svg.md b/zh-cn/application-dev/reference/arkui-js/js-svg.md index b308a4d49cffb56963874cb9f9c5643d83da14bf..ee133a95eaf926f2964a0fafe3fa75e4d1551fe8 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-svg.md +++ b/zh-cn/application-dev/reference/arkui-js/js-svg.md @@ -1,33 +1,33 @@ -# svg组件 +# svg组件 -- **[通用属性](js-components-svg-common-attributes.md)** -- **[svg](js-components-svg.md)** -- **[rect](js-components-svg-rect.md)** +- **[通用属性](js-components-svg-common-attributes.md)** -- **[circle](js-components-svg-circle.md)** +- **[svg](js-components-svg.md)** -- **[ellipse](js-components-svg-ellipse.md)** +- **[rect](js-components-svg-rect.md)** -- **[path](js-components-svg-path.md)** +- **[circle](js-components-svg-circle.md)** -- **[line](js-components-svg-line.md)** +- **[ellipse](js-components-svg-ellipse.md)** -- **[polyline](js-components-svg-polyline.md)** +- **[path](js-components-svg-path.md)** -- **[polygon](js-components-svg-polygon.md)** +- **[line](js-components-svg-line.md)** -- **[text](js-components-svg-text.md)** +- **[polyline](js-components-svg-polyline.md)** -- **[tspan](js-components-svg-tspan.md)** +- **[polygon](js-components-svg-polygon.md)** -- **[textPath](js-components-svg-textpath.md)** +- **[text](js-components-svg-text.md)** -- **[animate](js-components-svg-animate.md)** +- **[tspan](js-components-svg-tspan.md)** -- **[animateMotion](js-components-svg-animatemotion.md)** +- **[textPath](js-components-svg-textpath.md)** -- **[animateTransform](js-components-svg-animatetransform.md)** +- **[animate](js-components-svg-animate.md)** +- **[animateMotion](js-components-svg-animatemotion.md)** +- **[animateTransform](js-components-svg-animatetransform.md)** \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-caution.gif b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-caution.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-caution.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-danger.gif b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-danger.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-danger.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-note.gif b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-note.gif new file mode 100644 index 0000000000000000000000000000000000000000..6314297e45c1de184204098efd4814d6dc8b1cda Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-note.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-notice.gif b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-notice.gif new file mode 100644 index 0000000000000000000000000000000000000000..86024f61b691400bea99e5b1f506d9d9aef36e27 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-notice.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-tip.gif b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-tip.gif new file mode 100644 index 0000000000000000000000000000000000000000..93aa72053b510e456b149f36a0972703ea9999b7 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-tip.gif differ diff --git a/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-warning.gif b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-warning.gif new file mode 100644 index 0000000000000000000000000000000000000000..6e90d7cfc2193e39e10bb58c38d01a23f045d571 Binary files /dev/null and b/zh-cn/application-dev/reference/arkui-js/public_sys-resources/icon-warning.gif differ diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index 61d0b41a286338e50499afa987dfdee14afcbac0..3155278159c44740e43e0b9d01c885f313059975 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -1,4 +1,4 @@ -# reference/arkui-ts +# 基于TS扩展的声明式开发范式 - 组件 - 通用 @@ -57,21 +57,22 @@ - [Divider](ts-basic-components-divider.md) - [Image](ts-basic-components-image.md) - [ImageAnimator](ts-basic-components-imageanimator.md) + - [LoadingProgress](ts-basic-components-loadingprogress.md) - [Progress](ts-basic-components-progress.md) - [QRCode](ts-basic-components-qrcode.md) - [Radio](ts-basic-components-radio.md) - [Rating](ts-basic-components-rating.md) - - [Span](ts-basic-components-span.md) + - [Select](ts-basic-components-select.md) - [Slider](ts-basic-components-slider.md) + - [Span](ts-basic-components-span.md) - [Text](ts-basic-components-text.md) - [TextArea](ts-basic-components-textarea.md) - [TextInput](ts-basic-components-textinput.md) - [TextPicker](ts-basic-components-textpicker.md) - [TextTimer](ts-basic-components-texttimer.md) - [Toggle](ts-basic-components-toggle.md) - - [Select](ts-basic-components-select.md) - [TextClock](ts-basic-components-textclock.md) - - [LoadingProgress](ts-basic-components-loadingprogress.md) + - [Web](ts-basic-components-web.md) - 容器组件 - [AlphabetIndexer](ts-container-alphabet-indexer.md) - [Badge](ts-container-badge.md) @@ -100,7 +101,6 @@ - [Refresh](ts-container-refresh.md) - 媒体组件 - [Video](ts-media-components-video.md) - - [Web](ts-media-components-web.md) - 绘制组件 - [Circle](ts-drawing-components-circle.md) - [Ellipse](ts-drawing-components-ellipse.md) @@ -138,5 +138,6 @@ - [自定义弹窗](ts-methods-custom-dialog-box.md) - [日期时间选择弹窗](ts-methods-datepicker-dialog.md) - [文本选择弹窗](ts-methods-textpicker-dialog.md) + - [菜单](ts-methods-menu.md) - 附录 - [文档中涉及到的内置枚举值](ts-appendix-enums.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md index fc850b8b669cfdc6316f811b838465d6df2b6efb..ca29204c7a19c79ff353057ed7a45b3a7bbef05e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md @@ -33,7 +33,7 @@ Span(content: string) | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype枚举说明),
color?: Color
} | {
type: TextDecorationType.None
} | 设置文本装饰线样式及其颜色。 | +| decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype枚举说明),
color?: Color
} | {
type: TextDecorationType.None
color:Color.Black
} | 设置文本装饰线样式及其颜色。 | | textCase | [TextCase](ts-appendix-enums.md#textcase枚举说明) | Normal | 设置文本大小写。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-web.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md old mode 100644 new mode 100755 similarity index 52% rename from zh-cn/application-dev/reference/arkui-ts/ts-media-components-web.md rename to zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md index c729b54fb4eace90c68b489443cc6e7ca2ebd6da..3373cce20b1a2db2f17e43da873de94587523b68 --- a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-web.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -34,16 +34,17 @@ ohos.permission.READ_USER_STORAGE > - 不支持横竖屏事件。 ## 属性 -| 名称 | 参数类型 | 默认值 | 描述 | -| ----------------- | --------- | -------------- | ---------------------------------------- | -| domStorageAccess | boolean | false | 设置是否开启DOM Storage API权限,默认未开启。 | -| fileAccess | boolean | true | 设置是否开启Web中通过FILE方式访问应用中的本地文件, 默认启用。 | -| geolocationAccess | boolean | true | 设置是否允许访问地理位置, 默认允许访问。 | -| imageAccess | boolean | true | 设置是否允许自动加载图片资源,默认允许。 | -| javaScriptAccess | boolean | true | 设置是否允许执行JavaScript脚本,默认允许执行。 | -| mixedMode | MixedMode | MixedMode.None | 设置是否允许加载HTTP和HTTPS混合内容,默认不允许加载HTTP和HTTPS混合内容。 | -| onlineImageAccess | boolean | true | 设置是否允许从网络加载图片资源(通过HTTP和HTTPS访问的资源),默认允许访问。 | -| zoomAccess | boolean | true | 设置是否支持使用屏幕控件或手势进行缩放,默认允许执行缩放。 | +| 名称 | 参数类型 | 默认值 | 描述 | +| ----------------- | ------------------------------------------------------------ | -------------- | ------------------------------------------------------------ | +| domStorageAccess | boolean | false | 设置是否开启DOM Storage API权限,默认未开启。 | +| fileAccess | boolean | true | 设置是否开启Web中通过FILE方式访问应用中的本地文件, 默认启用。 | +| geolocationAccess | boolean | true | 设置是否允许访问地理位置, 默认允许访问。 | +| imageAccess | boolean | true | 设置是否允许自动加载图片资源,默认允许。 | +| javaScriptAccess | boolean | true | 设置是否允许执行JavaScript脚本,默认允许执行。 | +| mixedMode | MixedMode | MixedMode.None | 设置是否允许加载HTTP和HTTPS混合内容,默认不允许加载HTTP和HTTPS混合内容。 | +| onlineImageAccess | boolean | true | 设置是否允许从网络加载图片资源(通过HTTP和HTTPS访问的资源),默认允许访问。 | +| zoomAccess | boolean | true | 设置是否支持使用屏幕控件或手势进行缩放,默认允许执行缩放。 | +| javaScriptProxy | {
obj: object,
name: string,
methodList: Array,
controller: [WebController](#WebController)
} | - | 注入ArkUI对象到HTML中,并在HTML中调用该对象的方法,参数不支持更新。
-obj: 参与注册的对象。
-name: 注册对象的名称,与HTML中调用的对象名一致。
-methodList: 参与注册的方法。
-controller: 控制器。 | > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > @@ -60,15 +61,32 @@ ohos.permission.READ_USER_STORAGE 通用事件仅支持onFocus。 -| 名称 | 功能描述 | -| ---------------------------------------- | ---------------------------------------- | +| 名称 | 功能描述 | +| ------------------------------------------------------------ | ------------------------------------------------------------ | | onDownloadStart(callback: (event?: { url: string, userAgent: string, contentDisposition: string, mimetype: string, contentLength: number }) => void) |

下载开始时触发该回调。
url:Web引擎返回的下载URL。
userAgent:Web引擎返回的用户代理名称。
contentDisposition:Web引擎返回的响应头。
mimetype:Web引擎返回的mimetype信息。
contentLength:Web引擎返回的内容长度。

| -| onGeolocationHide(callback: () => void) |

调用onGeolocationShow时发出的地理位置权限请求被取消后触发该回调。

| +| onGeolocationHide(callback: () => void) |

调用onGeolocationShow时发出的地理位置权限请求被取消后触发该回调。

| | onGeolocationShow(callback: (event?: { origin: string, geolocation: JsGeolocation }) => void) |

应用尝试使用地理位置时触发该回调,并向用户请求权限。
origin:尝试获取地理位置的Web内容的来源。
geolocation:用于请求地理位置权限。

| -| onPageBegin(callback: (event?: { url: string }) => void) |

网页加载时触发该回调。
url:Web引擎返回的URL。

| -| onPageEnd(callback: (event?: { url: string }) => void) |

网页加载结束时触发该回调。
url:Web引擎返回的URL。

| +| onPageBegin(callback: (event?: { url: string }) => void) |

网页加载时触发该回调。
url:Web引擎返回的URL。

| +| onPageEnd(callback: (event?: { url: string }) => void) |

网页加载结束时触发该回调。
url:Web引擎返回的URL。

| | onProgressChange(callback: (event?: { newProgress: number }) => void) |

网页加载进度变化时触发该回调。
newProgress:加载进度,取值范围为0到100的整数。

| -| onTitleReceive(callback: (event?: { title: string }) => void) |

网页主页面标题更改时触发该回调。
title:标题内容。

| +| onTitleReceive(callback: (event?: { title: string }) => void) |

网页主页面标题更改时触发该回调。
title:标题内容。

| +| onErrorReceive(callback: (event?: { request: WebResourceRequest, error: WebResourceError }) => void) |

网页加载错误时触发该回调。
request:网页的请求信息。
error:网页的错误信息 。

| +| onHttpErrorReceive(callback: (event?: { request: WebResourceRequest, response: WebResourceResponse }) => void) |

网页加载出现网络错误时触发该回调。
request:网页的请求信息。
response:网页的响应信息

| +| onConsole(callback: (event?: { message: ConsoleMessage }) => boolean) |

向主应用报告JavaScript控制台消息时触发该回调。
message:触发的控制台信息。

| +| onAlert(callback: (event?: { url: string; message: string; result: JsResult }) => boolean) |

网页触发alert()告警弹窗时触发。
url:Web引擎返回的下载URL。
message:Web引擎返回的信息。
JsResult:Web引擎返回的弹窗确认或弹窗取消功能对象。

| +| onBeforeUnload(callback: (event?: { url: string; message: string; result: JsResult }) => boolean) |

网页重新加载或关闭时触发。
url:Web引擎返回的下载URL。
message:Web引擎返回的信息。
JsResult:Web引擎返回的弹窗确认或弹窗取消功能对象。

| +| onConfirm(callback: (event?: { url: string; message: string; result: JsResult }) => boolean) |

即将离开当前页面(刷新或关闭)时触发。
url:Web引擎返回的下载URL。
message:Web引擎返回的信息。
JsResult:Web引擎返回的弹窗确认或弹窗取消功能对象。

| + +### JsResult 对象说明 + +Web引擎返回的弹窗确认或弹窗取消功能对象。 + +- 接口 + + | 接口名称 | 功能描述 | + | --------------------- | ----------------- | + | handleCancel(): void |

取消弹窗。

| + | handleConfirm(): void |

确认弹窗。

| ### JsGeolocation 对象说明 @@ -76,10 +94,65 @@ ohos.permission.READ_USER_STORAGE - 接口 - | 接口名称 | 功能描述 | - | ---------------------------------------- | ---------------------------------------- | + | 接口名称 | 功能描述 | + | ------------------------------------------------------------ | ------------------------------------------------------------ | | invoke(origin: string, allow: boolean, retain: boolean): void |

通知系统用户是否批准该应用使用地理位置权限。
origin:尝试获取地理位置的Web内容的来源。
allow:用户是否批准该应用使用地理位置权限。true: 允许访问,false: 不允许访问。
retain:是否允许将地理位置权限状态保存到系统中。true: 允许,false: 不允许。

| +### WebResourceRequest对象说明 + +- 接口 + + | 接口名称 | 功能描述 | + | --------------------------------- | ------------------------------------ | + | getRequestUrl(): string | 获取请求的url信息。 | + | isRequestGesture(): boolean | 获取请求是否与手势关联。 | + | isMainFrame(): boolean | 获取请求是否时为了获取主窗口的信息。 | + | isRedirect(): boolean | 获取请求是否重定向。 | + | getRequestHeader(): Array
| 获取请求头信息。 | + +### WebResourceError对象说明 + +- 接口 + + | 接口名称 | 功能描述 | + | ---------------------- | ------------------------ | + | getErrorInfo(): string | 获取加载资源的错误信息。 | + | getErrorCode(): number | 获取加载资源的错误码。 | + +### WebResourceResponse对象说明 + +- 接口 + + | 接口名称 | 功能描述 | + | ---------------------------------- | ---------------------- | + | getResponseData(): string | 获取响应数据。 | + | getResponseEncoding(): string | 获取响应的编码。 | + | getResponseMimeType(): string | 获取响应的MIME类型。 | + | getResponseCode(): number | 获取响应的状态码。 | + | getReasonMessage(): string | 获取响应的状态码描述。 | + | getResponseHeader(): Array
| 获取响应头信息。 | + +### ConsoleMessage对象说明 + +- 接口 + + | 接口名称 | 功能描述 | + | ------------------------------- | ------------------------------ | + | getMessage(): string | 获取ConsoleMessage的日志信息。 | + | getSourceId(): string | 获取ConsoleMessage的源的Id。 | + | getLineNumber(): number | 获取ConsoleMessage的行数。 | + | getMessageLevel(): MessageLevel | 获取ConsoleMessage的信息级别。 | + +- MessageLevel枚举说明 + + | 名称 | 描述 | + | ----- | :--------- | + | Debug | 调试级别。 | + | Error | 错误级别。 | + | Info | 消息级别。 | + | Log | 日志级别。 | + | Warn | 警告级别。 | + ## WebController Web 组件的控制器。 @@ -116,11 +189,11 @@ accessStep(step: number): boolean ### deleteJavaScriptRegister -deleteJavaScriptRegister(options: { name: string }): void +deleteJavaScriptRegister(name: string): void 清空指定对象已注册的JavaScript方法。 -- options参数说明 +- 参数 | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | ---- | ------ | ---- | ---- | ----------------------- | @@ -175,11 +248,11 @@ loadData(options: { data: string, mimeType: string, encoding: string, baseUrl?: ### loadUrl -loadUrl(url: string, additionalHttpHeaders?: Array<{ key: string, value: string }>): void +loadUrl(options:{ url: string, headers?: Array<{ key: string, value: string }> }): void 加载URL。 -- 参数 +- options参数说明 | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | --------------------- | ------------------------------------- | ---- | ---- | ---------- | @@ -220,11 +293,11 @@ registerJavaScriptProxy(options: { obj: object, name: string, methodList: string ### runJavaScript -runJavaScript(script: string, callback?: (result: string) => void): void +runJavaScript(options: { script: string, callback?: (result: string) => void }): void 执行JavaScript脚本。 -- 参数 +- options参数说明 | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | -------- | ------------------------ | ---- | ---- | ------------------------------------ | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md index 89205a74d14de964f9cbd475dfef7163e63b91fd..ebe9c8c1293e0b0f76fa8ce8077beba41df38597 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md @@ -29,7 +29,7 @@ LongPressGesture(options?: { fingers?: number, repeat?: boolean, duration?: numb | onActionEnd((event?: LongPressGestureEvent) => void) | LongPress手势识别成功,手指抬起后触发回调。 | | onActionCancel(event: () => void) | LongPress手势识别成功,接收到触摸取消事件触发回调。 | -- LongPressGestureEvent对象说明8+ +- LongPressGestureEvent8+对象说明 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | repeat | boolean | 事件是否为重复触发事件。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md index b2a9218cb63bcd350efc30d993ad0e2755d344bc..d6ef7f4010f2e86e385c86b05b66564ccd50b828 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pangesture.md @@ -59,7 +59,7 @@ PanGestureOption(options?: { fingers?: number, direction?: PanDirection, distanc | onActionEnd(callback: (event?: PanGestureEvent) => void) | Pan手势识别成功,手指抬起后触发回调。 | | onActionCancel(callback: () => void) | Pan手势识别成功,接收到触摸取消事件触发回调。 | -- PanGestureEvent对象说明8+ +- PanGestureEvent8+对象说明 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | offsetX | number | 手势事件偏移量,单位为vp。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md index 95279db007e7b3ca92c62a04771ae1ee39978d9e..4d87009b040266175c255110a0e36dff25199492 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-pinchgesture.md @@ -29,7 +29,7 @@ PinchGesture(options?: { fingers?: number, distance?: number }) | onActionEnd((event?: PinchGestureEvent) => void) | Pinch手势识别成功,手指抬起后触发回调。 | | onActionCancel(event: () => void) | Pinch手势识别成功,接收到触摸取消事件触发回调。 | -- PinchGestureEvent对象说明8+ +- PinchGestureEvent8+对象说明 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | scale | number | 缩放比例,用于PinchGesture手势触发场景。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md index f9d55455044fa873cb1042ad6f32cecc75fc2dfb..5c2a2d1d7615ab495b6fe380530464f8496f4860 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-rotationgesture.md @@ -29,7 +29,7 @@ RotationGesture(options?: { fingers?: number, angle?: number }) | onActionEnd((event?: RotationGestureEvent) => void) | Rotation手势识别成功,手指抬起后触发回调。 | | onActionCancel(event: () => void) | Rotation手势识别成功,接收到触摸取消事件触发回调。 | -- RotationGestureEvent对象说明8+ +- RotationGestureEvent8+对象说明 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | angle | number | 旋转角度。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md index 02fcaf26213ed0cd8a11549e95bd2b0a281e0634..d2568f09ba7fefe59c27753e4702f084b72b45c6 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-scroll.md @@ -38,6 +38,13 @@ Scroll(scroller?: Scroller) | Vertical | 仅支持竖直方向滚动。 | | None | 不可滚动。 | +## 事件 + +| 名称 | 功能描述 | +| -------- | -------- | +| onScroll(xOffset: number, yOffset: number) => void | 滚动事件回调, 返回滚动时水平、竖直方向偏移量。 | +| onScrollEdge(side: Edge) => void | 滚动到边缘事件回调。 | +| onScrollEnd() => void | 滚动停止事件回调。 | ## Scroller @@ -51,7 +58,7 @@ scroller: Scroller = new Scroller() ``` -### scroller.scrollTo +### scrollTo scrollTo(value: { xOffset: number | string, yOffset: number | string, animation?: { duration: number, curve: Curve } }): void @@ -67,7 +74,7 @@ scrollTo(value: { xOffset: number | string, yOffset: number | string, animation? | animation | {
duration: number,
curve: [Curve](ts-animatorproperty.md) \|
CubicBezier \|
SpringCurve
} | 否 | | 动画配置:
- duration: 滚动时长设置。
- curve: 滚动曲线设置。 | -### scroller.scrollEdge +### scrollEdge scrollEdge(value: Edge): void @@ -81,7 +88,7 @@ scrollEdge(value: Edge): void | value | Edge | 是 | - | 滚动到的边缘位置。 | -### scroller.scrollPage +### scrollPage scrollPage(value: { next: boolean, direction?: Axis }): void @@ -93,7 +100,7 @@ scrollPage(value: { next: boolean, direction?: Axis }): void | next | boolean | 是 | - | 是否向下翻页。true表示向下翻页,false表示向上翻页。 | -### scroller.currentOffset +### currentOffset scroller.currentOffset(): Object @@ -107,7 +114,7 @@ scroller.currentOffset(): Object | {
xOffset: number,
yOffset: number
} | xOffset: 水平滑动偏移;
yOffset: 竖直滑动偏移。 | -### scroller.scrollToIndex +### scrollToIndex scroller.scrollToIndex(value: number): void @@ -125,15 +132,6 @@ scroller.scrollToIndex(value: number): void | value | number | 是 | - | 要滑动到的列表项在列表中的索引值。 | -## 事件 - -| 名称 | 功能描述 | -| -------- | -------- | -| onScroll(xOffset: number, yOffset: number) => void | 滚动事件回调, 返回滚动时水平、竖直方向偏移量。 | -| onScrollEdge(side: Edge) => void | 滚动到边缘事件回调。 | -| onScrollEnd() => void | 滚动停止事件回调。 | - - ## 示例 ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md index aa7d64c8a4331b6fe8ef75f456003885429da50f..d3f5d40f7d5787bb830f89ee4a82d57e67ff2072 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -77,7 +77,7 @@ struct SideBarContainerExample { @State current: number = 1 build() { - SideBarContainer({ type: SideBarContainerType.Embed }) + SideBarContainer(SideBarContainerType.Embed) { Column() { ForEach(this.arr, (item, index) => { diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md b/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md index ea36bb58f044a95072acd1d68d8a2c2ed769111f..fe0e8e92dbbcb024fe7400043d7385fa6b7c2fb7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md @@ -25,7 +25,7 @@ Video(value: VideoOption) | controller | [VideoController](#videocontroller) | 否 | - | 控制器。 | -- PlaybackSpeed类型接口说明8+ +- PlaybackSpeed8+类型接口说明 | 名称 | 描述 | | -------- | -------- | | Speed_Forward_0_75_X | 0.75倍速播放。 | @@ -73,7 +73,7 @@ Video(value: VideoOption) | setCurrentTime(value: number) | 指定视频播放的进度位置。 | | setCurrentTime(value: number, seekMode: SeekMode | 指定视频播放的进度位置,并指定跳转模式。 | -- SeekMode类型接口说明8+ +- SeekMode8+类型接口说明 | 名称 | 描述 | | -------- | -------- | | PreviousKeyframe | 跳转到前一个最近的关键帧。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index 0978b45c9e6211d7417c109d4c3b27865e3d3053..494d326a3bc512c27531570b5d8ce02ab716ded5 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -37,21 +37,23 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, aut | BottomEnd8+ | 右下对齐。 | -### CustomDialogController +## CustomDialogController -创建对象 +### 导入对象 ``` dialogController : CustomDialogController = new CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, autoCancel?: boolean}) ``` -open() +### open() +open(): void 显示自定义弹窗内容,若已显示,则不生效。 -close() +### close +close(): void 关闭显示的自定义弹窗,若已关闭,则不生效。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md new file mode 100644 index 0000000000000000000000000000000000000000..df97249f6d38576b79f604df4aab7d277c7118f9 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-menu.md @@ -0,0 +1,39 @@ +# 菜单 + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 从 API Version 8 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 + +## ContextMenu.close + +close(): void + +可以通过该方法在页面范围内关闭通过[bindContextMenu](./ts-universal-attributes-menu.md#属性)给组件绑定的菜单。 + +- 示例 + ``` + @Entry + @Component + struct Index { + @Builder MenuBuilder(){ + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('close') + .fontSize(30) + .fontWeight(FontWeight.Bold) + .onClick(() => { + ContextMenu.close(); + }) + }.height(400) + .backgroundColor(Color.Pink) + + } + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) { + Column(){ + Text("Text") + }.bindContextMenu(this.MenuBuilder, ResponseType.LongPress) + } + .width('100%') + .height('100%') + } + } + ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md index 334636f603d2bd67f3b0f7a4e9488b85e4798232..8dfcbfc08201b7f2a9550f457d7754f9004db715 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md @@ -14,12 +14,12 @@ | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| linearGradient | {
angle?: [Angle](../../ui/ts-types.md#角度类型),
direction?: GradientDirection,
colors: Array<[ColorStop](../../ui/ts-types.md#角度类型/ts-types.md#colorstop类型)>
repeating?: boolean
} | - | 线性渐变。
angle: 线性渐变的角度。
direction: 线性渐变的方向。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | -| sweepGradient | {
center: Point,
start?: angle,
end?: angle,
colors: Array<[ColorStop](../../ui/ts-types.md#colorstop类型)>
repeating?: boolean
} | - | 角度渐变。
center:为角度渐变的中心点。
start:角度渐变的起点。
end:角度渐变的终点。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | -| radialGradient | {
center: Point,
radius: Length,
colors: Array<[ColorStop](../../ui//ts-types.md#colorstop类型)>
repeating: boolean
} | - | 径向渐变。
center:径向渐变的中心点。
radius:径向渐变的半径。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | +| linearGradient | {
angle?: [Angle](../../ui/ts-types.md),
direction?: GradientDirection,
colors: Array<[ColorStop](../../ui/ts-types.md)>
repeating?: boolean
} | - | 线性渐变。
angle: 线性渐变的角度。
direction: 线性渐变的方向。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | +| sweepGradient | {
center: Point,
start?: angle,
end?: angle,
colors: Array<[ColorStop](../../ui/ts-types.md)>
repeating?: boolean
} | - | 角度渐变。
center:为角度渐变的中心点。
start:角度渐变的起点。
end:角度渐变的终点。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | +| radialGradient | {
center: Point,
radius: Length,
colors: Array<[ColorStop](../../ui/ts-types.md)>
repeating: boolean
} | - | 径向渐变。
center:径向渐变的中心点。
radius:径向渐变的半径。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | -- GradientDirection枚举说明 +- GradientDirection枚举说明
GradientDirection用于描述渐变方向。 | 名称 | 描述 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md index ac768804a52d97e332ec964f02b190425ac5e609..71c1273bb276dca02d9708a0bbd85601c98f1a31 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md @@ -14,18 +14,26 @@ | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| bindMenu | Array8+ | - | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 | +| bindMenu | Array8+ | - | 给组件绑定菜单,点击后弹出菜单。弹出菜单项支持文本和自定义两种功能。 | +| bindContextMenu8+ | content: [CustomBuilder](../../ui/ts-types.md)
responseType: ResponseType | - | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 | - MenuItem - | 名称 | 类型 | 描述 | + | 名称 | 类型 | 描述 | | -------- | -------- | -------- | - | value | string | 菜单项文本。 | - | action | () => void | 点击菜单项的事件回调。 | + | value | string | 菜单项文本。 | + | action | () => void | 点击菜单项的事件回调。 | +- ResponseType8+ + | 参数值 | 描述 | + | -------- | -------- | + | LongPress | 通过长按触发菜单弹出。 | + | RightClick | 通过鼠标右键触发菜单弹出。 | ## 示例 +#### 普通菜单 + ``` @Entry @Component @@ -56,6 +64,8 @@ struct MenuExample { ![zh-cn_image_0000001174582862](figures/zh-cn_image_0000001174582862.gif) +#### 自定义内容菜单 + ``` import router from '@system.router'; @@ -103,3 +113,36 @@ struct MenuExample { ``` ![zh-cn_image_0000001186807708](figures/zh-cn_image_0000001186807708.gif) + +#### 菜单(右键触发显示) + +``` +@Entry +@Component +struct ContextMenuExample { + @Builder MenuBuilder() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text('Test menu item 1') + .fontSize(20) + .width(100) + .height(50) + .textAlign(TextAlign.Center) + Divider().height(10) + Text('Test menu item 2') + .fontSize(20) + .width(100) + .height(50) + .textAlign(TextAlign.Center) + }.width(100) + } + + build() { + Column() { + Text('rightclick for menu') + } + .width('100%') + .margin({ top: 5 }) + .bindContextMenu(this.MenuBuilder, ResponseType.RightClick) + } +} +``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index 1f10a1a0a9ea896ce8e727159f47343430682981..ad1873ea00073974a129ca8d303813ba42b46c90 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -26,7 +26,7 @@ | secondaryButton | {
value: string,
action: () => void
} | 否 | - | 第二个按钮。
value: 弹窗里辅助按钮的文本。
action: 点击辅助按钮的回调函数。 | | onStateChange | (isVisible: boolean) => void | 否 | - | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 | -- CustomPopupOption类型接口说明8+ +- CustomPopupOption8+类型接口说明 | 名称 | 类型 | 必填 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -------- | | builder | () => any | 是 | - | 提示气泡内容的构造器。 | @@ -37,7 +37,7 @@ | autoCancel | boolean | 否 | true | 页面有操作时,是否自动关闭气泡 | | onStateChange | (isVisible: boolean) => void | 否 | - | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 | -- Placement枚举说明8+ +- Placement8+枚举说明 | 名称 | 描述 | | -------- | -------- | | Left | 气泡提示位于组件左侧。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md index a8259660569efac407d788477dbf4f8cfd5fcd3b..2af9b5be1fb516d1c58c40c7f4e949a6f9b0a6a7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md @@ -20,7 +20,7 @@ | responseRegion | Array<Rectangle> \| Rectangle | {
x:0,
y:0,
width:'100%',
height:'100%'
} | 设置一个或多个触摸热区,包括位置和大小。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> -百分比是相对于组件本身来度量的。
> -x和y可以设置正负值百分比。当x设置为'100%'时表示热区往右偏移组件本身宽度大小,当x设置为'-100%'时表示热区往左偏移组件本身宽度大小。当y设置为'100%'时表示热区往下偏移组件本身高度大小,当y设置为'-100%'时表示热区往上偏移组件本身高度大小。
> -width和height只能设置正值百分比。width:'100%'表示热区宽度设置为该组件本身的宽度。比如组件本身宽度是100vp,那么'100%'表示热区宽度也为100vp。height:'100%'表示热区高度设置为该组件本身的高度。 | -- Rectangle对象说明 +### Rectangle对象说明 | 名称 | 类型 | 必填 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -------- | | x | Length | 否 | 0vp | 触摸点相对于组件本身左边沿的X坐标。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md index 25770999ace02b3124ce54b48045cfc416fca41c..ea96a956ce8f33539295b72969e2e4617f44f4bd 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md @@ -15,7 +15,7 @@ | -------- | -------- | -------- | | onClick(callback: (event?: ClickEvent) => void) | 否 | 点击动作触发该方法调用,event参数见ClickEvent介绍。 | -- ClickEvent对象说明 +### ClickEvent对象说明 | 属性名称 | 类型 | 描述 | | -------- | -------- | -------- | | screenX | number | 点击点相对于设备屏幕左边沿的X坐标。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md index b8f35086cf464d11191a8604497f9f3bba51fd33..988437562c8fc9ac11f0fcfd3edc61a0fa5d5954 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md @@ -3,31 +3,31 @@ > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 从API Version 8开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 +## 事件 | 名称 | 支持冒泡 | 功能描述 | | -------- | -------- | -------- | -| onDragStart(callback: (event: DragEvent, extraParams?: string) =>  [CustomBuilder](../../ui/ts-types.md#custombuilder类型8+)) | 否 | 第一次拖拽此事件绑定的组件时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。
返回值:当前跟手效果所拖拽的对象,用于显示拖拽时的提示组件。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 长按150毫秒(ms)可触发拖拽事件。
> - 优先级:长按手势配置时间小于等于150毫秒(ms)时,长按手势优先触发,否则拖拽事件优先触发。 | +| onDragStart(callback: (event: DragEvent, extraParams?: string) =>  [CustomBuilder](../../ui/ts-types.md)) | 否 | 第一次拖拽此事件绑定的组件时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。
返回值:当前跟手效果所拖拽的对象,用于显示拖拽时的提示组件。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 长按150毫秒(ms)可触发拖拽事件。
> - 优先级:长按手势配置时间小于等于150毫秒(ms)时,长按手势优先触发,否则拖拽事件优先触发。 | | onDragEnter(callback: (event: DragEvent, extraParams?: string) => void) | 否 | 拖拽进入组件范围内时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 当监听了onDrop事件时,此事件才有效。 | | onDragMove(callback: (event: DragEvent, extraParams?: string) => void) | 否 | 拖拽在组件范围内移动时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 当监听了onDrop事件时,此事件才有效。 | | onDragLeave(callback: (event: DragEvent, extraParams?: string) => void) | 否 | 拖拽离开组件范围内时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 当监听了onDrop事件时,此事件才有效。 | | onDrop(callback: (event: DragEvent, extraParams?: string) => void) | 否 | 绑定此事件的组件可作为拖拽释放目标,当在本组件范围内停止拖拽行为时,触发回调。
event:拖拽事件信息,包括拖拽点坐标。
extraParams:拖拽事件额外信息,详见extraParam类型描述。 | - -- DragEvent对象说明 - | 名称 | 返回值类型 | 功能描述 | - | -------- | -------- | -------- | - | getX() | number | 当前拖拽点x轴坐标,单位为vp。 | - | getY() | number | 当前拖拽点y轴坐标,单位为vp。 | - -- extraParam说明 +- extraParam说明
用于返回组件在拖拽中需要用到的额外信息。 - extraParam是Json对象转换的string字符串,可以通过Json.parse转换的Json对象获取如下属性。 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | selectedIndex | number | 当拖拽事件设在父容器的子元素时,selectedIndex表示当前被拖拽子元素是父容器第selectedIndex个子元素,selectedIndex从0开始。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅在ListItem组件中生效。 | | insertIndex | number | 当前拖拽元素在List组件中放下时,insertIndex表示被拖拽元素插入该组件的第insertIndex个位置,insertIndex从0开始。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 仅在List组件的拖拽事件中生效。 | +### DragEvent对象说明 +- 接口 + | 名称 | 返回值类型 | 功能描述 | + | -------- | -------- | -------- | + | getX() | number | 当前拖拽点x轴坐标,单位为vp。 | + | getY() | number | 当前拖拽点y轴坐标,单位为vp。 | + ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md index 63f31446e6c55b67754e7a0de693abc22ad15ae3..6c310bc063b24a73dc1d8fae1f6d596b2a1ae049 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-key.md @@ -16,7 +16,7 @@ | onKeyEvent(event: (event?: KeyEvent) => void) | 是 | 按键动作触发该方法调用,event参数见[KeyEvent](#keyevent对象说明)介绍。 | -## KeyEvent对象说明 +### KeyEvent对象说明 - 属性 | 属性名称 | 类型 | 描述 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md index 2dd02c00eac219a07c2fa369635d6bac8731005a..ca49bfc099d772425df32ccf6d9eb05c77a99e0f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-touch.md @@ -16,7 +16,7 @@ | onTouch(callback: (event?: TouchEvent) => void) | 是 | 触摸动作触发该方法调用,event参数见[TouchEvent](#touchevent对象说明)介绍。 -## TouchEvent对象说明 +### TouchEvent对象说明 - 属性 | 属性名称 | 类型 | 描述 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md index 26d34ecc321f5e3b63371a5fea75efeb21416a5a..61fd6b4dd9ea40f60dd470fd4387f019fe943f2b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-mouse-key.md @@ -17,7 +17,7 @@ | onMouse(callback: (event?: MouseEvent) => void) | 是 | 当前组件被鼠标按键点击时或者鼠标在组件上移动时,触发该回调,event参数包含触发事件时的时间戳、鼠标按键、动作、点击触点在整个屏幕上的坐标和点击触点相对于当前组件的坐标。 | -- MouseEvent对象说明 +### MouseEvent对象说明 | 属性名称 | 属性类型 | 描述 | | -------- | -------- | -------- | | timestamp | number | 触发事件时的时间戳。 | diff --git a/zh-cn/application-dev/security/Readme-CN.md b/zh-cn/application-dev/security/Readme-CN.md index 57303b1522c8b35de1e69bb73abcb5bfc482e56b..37cd1817e37ebba14d1f6692269355dabe02523b 100644 --- a/zh-cn/application-dev/security/Readme-CN.md +++ b/zh-cn/application-dev/security/Readme-CN.md @@ -10,3 +10,7 @@ - Hap包签名工具 - [Hap包签名工具开发指导](hapsigntool-guidelines.md) + +- 访问控制 + - [访问控制开发概述](accesstoken-overview.md) + - [访问控制开发指导](accesstoken-guidelines.md) diff --git a/zh-cn/application-dev/security/accesstoken-guidelines.md b/zh-cn/application-dev/security/accesstoken-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..398795358ba49a54922a6caad8ba4b245b5294b4 --- /dev/null +++ b/zh-cn/application-dev/security/accesstoken-guidelines.md @@ -0,0 +1,45 @@ +# 访问控制开发指导 + +## 场景介绍 + +当应用申请的权限需要用户授权,即申请的权限为user_grant权限时,可以通过权限校验,判断当前调用者是否具备相应权限。 + +## 接口说明 +接口的具体说明可以查阅[API参考](../reference/apis/js-apis-abilityAccessCtrl.md) +| 接口名 | 描述 | +| ------------------------------------------------------------ | ---------------- | +| verifyAccessToken(tokenID: number, permissionName: string): Promise<GrantStatus> | 校验应用是否授予权限,使用Promise方式异步返回结果。 | + +## 开发步骤 +对访问者进行权限校验的开发步骤为: + +1. 获取调用者的身份标识: tokenId +2. 识别需要校验的权限: permissionNameUser +3. 对当前调用者进行权限校验 + +代码示例如下: + +```js + import {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index' + import abilityAccessCtrl from '@ohos.abilityAccessCtrl' + import bundle from '@ohos.bundle' + + var permissionNameUser = "ohos.permission.ALPHA"; + var bundleFlag = 0; + var tokenID = undefined; + var userID = 100; + var appInfo = await bundle.getApplicationInfo('ohos.acts.security.access_token.normal', bundleFlag, userID); + tokenID = appInfo.accessTokenId; + console.log("AccessTokenTest accessTokenId:" + appInfo.accessTokenId + ", name:" + appInfo.name + + ", bundleName:" + appInfo.bundleName) + var atManager = abilityAccessCtrl.createAtManager(); + var result = await atManager.verifyAccessToken(tokenID, permissionNameUser); + if (result == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { + // 执行操作 + } else { + // 申请动态授权,使用接口:requestPermissionsFromUser + } + +``` +> **说明:** +动态授权申请接口的使用详见[API参考](../reference/apis/js-apis-ability-context.md) \ No newline at end of file diff --git a/zh-cn/application-dev/security/accesstoken-overview.md b/zh-cn/application-dev/security/accesstoken-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..1fef21e91a1c5433d117a72d485bec3dce90e278 --- /dev/null +++ b/zh-cn/application-dev/security/accesstoken-overview.md @@ -0,0 +1,18 @@ +# 访问控制开发指南 + +## 功能简介 +ATM(AccessTokenManager)是OpenHarmony上基于AccessToken构建的统一的应用权限管理能力。 + +当前,ATM模块对应用提供了权限校验功能,应用可以检查当前访问者是否具有所需的权限。 + + +## 基本概念 + +当前,ATM提供的应用权限校验功能是基于统一管理的TokenID(Token identity)。 + +- TokenID:32bits的设备内唯一标识符,用于标识每个应用的Accestoken信息。 +- Accestoken信息:主要包括应用身份标识APPID、用户ID、应用分身索引、应用APL(Ability Privilege Level)、应用权限信息等。 + +## 约束与限制 + + - 应用不允许自定义权限,系统权限定义信息详见[权限定义信息](https://gitee.com/openharmony/resources/blob/master/systemres/main/config.json) \ No newline at end of file diff --git a/zh-cn/application-dev/security/hapsigntool-guidelines.md b/zh-cn/application-dev/security/hapsigntool-guidelines.md index 4fe2c34d3df809abfcd41ae4e47eae61d04bb102..6063e42503a056cb67974c7a5563695d9b05a26f 100644 --- a/zh-cn/application-dev/security/hapsigntool-guidelines.md +++ b/zh-cn/application-dev/security/hapsigntool-guidelines.md @@ -20,7 +20,7 @@ Hap包签名工具支持本地签名需求的开发,为OpenHarmony应用提供 - 证书 OpenHarmony采用RFC5280标准构建X509证书信任体系。用于应用签名的OpenHarmony证书按层级可分为:根CA证书、子CA证书、三级实体证书,其中三级实体证书分为应用签名证书和profile签名证书。应用签名证书表示应用开发者的身份,可保证系统上安装的应用来源可追溯,profile签名证书实现对profile文件的签名进行验签,保证profile文件的完整性。 - HAP包 -HAP(HarmonyOS Ability Package)是Ability的部署包,OpenHarmony应用代码围绕Ability组件展开,它是由一个或者多个Ability组成。 +HAP(OpenHarmony Ability Package)是Ability的部署包,OpenHarmony应用代码围绕Ability组件展开,它是由一个或者多个Ability组成。 - profile文件 hap包中的描述文件,该描述文件描述了已授权的证书权限和设备ID信息等信息。 ### 约束与限制 @@ -354,6 +354,7 @@ java -jar hap-sign-tool.jar sign-app -keyAlias "oh-app1-key-v1" -signAlg "SHA256 + ## 常见问题 **1.执行[生成应用签名证书](#生成应用签名证书)命令时,控制台打印结果,无文件输出** diff --git a/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md index 48308666b73d34cef7f83c3438da881b89edadb2..52fdd30c2330f6e9787db6d3cd7aefa26e4bcbba 100644 --- a/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md +++ b/zh-cn/application-dev/ui/ts-custom-component-lifecycle-callbacks.md @@ -17,6 +17,7 @@ ## 示例 ``` +@Entry @Component struct CountDownTimerComponent { @State countDownFrom: number = 10 diff --git a/zh-cn/application-dev/ui/ui-ts-components-web.md b/zh-cn/application-dev/ui/ui-ts-components-web.md new file mode 100644 index 0000000000000000000000000000000000000000..f17a05c89d7a1d5388af9ac57b8d6868186d633e --- /dev/null +++ b/zh-cn/application-dev/ui/ui-ts-components-web.md @@ -0,0 +1,195 @@ +# Web + +Web是提供网页显示能力的组件,具体用法请参考 [Web API](../reference/arkui-ts/ts-basic-components-web.md)。 + +## 创建组件 + +在main/ets/MainAbility/pages目录下的ets文件中创建一个Web组件。在web组件中通过src指定引用的网页路径,controller为组件的控制器,通过controller绑定Web组件,用于调用Web组件的方法。 + + ``` + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + build() { + Column() { + Web({ src: 'https://www.example.com', controller: this.controller }) + } + } + } + ``` + +## 设置样式和属性 + +Web组件的使用需要添加丰富的页面样式和功能属性。设置height、padding样式可为Web组件添加高和内边距,设置fileAccess属性可为Web组件添加文件访问权限,设置javaScriptAccess属性为true使Web组件具有执行JavaScript代码的能力。 + +``` +// xxx.ets +@Entry +@Component +struct WebComponent { + fileAccess: boolean = true; + controller: WebController = new WebController(); + build() { + Column() { + Text('Hello world!') + .fontSize(20) + Web({ src: 'https://www.example.com', controller: this.controller }) + // 设置高和内边距 + .height(500) + .padding(20) + // 设置文件访问权限和脚本执行权限 + .fileAccess(this.fileAccess) + .javaScriptAccess(true) + Text('End') + .fontSize(20) + } + } +} +``` +## 添加事件和方法 + +为Web组件添加onProgressChange事件,该事件回调Web引擎加载页面的进度值。将该进度值赋值给Progress组件的value,控制Progress组件的状态。当进度为100%时隐藏Progress组件,Web页面加载完成。 + +``` +// xxx.ets +@Entry +@Component +struct WebComponent { + @State progress: number = 0; + @State hideProgress: boolean = true; + fileAccess: boolean = true; + controller: WebController = new WebController(); + build() { + Column() { + Text('Hello world!') + .fontSize(20) + Progress({value: this.progress, total: 100}) + .color('#0000ff') + .visibility(this.hideProgress ? Visibility.None : Visibility.Visible) + Web({ src: 'https://www.example.com', controller: this.controller }) + .fileAccess(this.fileAccess) + .javaScriptAccess(true) + .height(500) + .padding(20) + // 添加onProgressChange事件 + .onProgressChange(e => { + this.progress = e.newProgress; + // 当进度100%时,进度条消失 + if (this.progress === 100) { + this.hideProgress = true; + } else { + this.hideProgress = false; + } + }) + Text('End') + .fontSize(20) + } + } +} +``` +在onPageEnd事件中添加runJavaScript方法。onPageEnd事件是网页加载完成时的回调,runJavaScript方法可以执行HTML中的JavaScript脚本。当页面加载完成时,触发onPageEnd事件,调用HTML文件中的test方法,在控制台打印信息。 + +``` +// xxx.ets +@Entry +@Component +struct WebComponent { + @State progress: number = 0; + @State hideProgress: boolean = true; + fileAccess: boolean = true; + // 定义Web组件的控制器controller + controller: WebController = new WebController(); + build() { + Column() { + Text('Hello world!') + .fontSize(20) + Progress({value: this.progress, total: 100}) + .color('#0000ff') + .visibility(this.hideProgress ? Visibility.None : Visibility.Visible) + // 初始化Web组件,并绑定controller + Web({ src: $rawfile('index.html'), controller: this.controller }) + .fileAccess(this.fileAccess) + .javaScriptAccess(true) + .height(500) + .padding(20) + .onProgressChange(e => { + this.progress = e.newProgress; + if (this.progress === 100) { + this.hideProgress = true; + } else { + this.hideProgress = false; + } + }) + .onPageEnd(e => { + // test()在index.html中定义 + this.controller.runJavaScript({ script: 'test()' }); + console.info('url: ', e.url); + }) + Text('End') + .fontSize(20) + } + } +} +``` + +在main/resources/rawfile目录下创建一个HTML文件。 + +``` + + + + + + Hello world! + + + +``` +## 场景示例 + +​该场景实现了Web组件中视频的动态播放。首先在HTML页面内嵌入视频资源,再使用Web组件的控制器调用onActive和onInactive方法激活和暂停页面渲染。页面消失时,Web组件停止渲染,视频暂停播放;页面显示时,激活Web组件,视频继续播放。 + + ``` + // xxx.ets + @Entry + @Component + struct WebComponent { + controller: WebController = new WebController(); + build() { + Column() { + Web({ src: $rawfile('index.html'), controller: this.controller }) + .fileAccess(true) + } + } + + onPageHide() { + // 页面消失时调用 + this.controller.onInactive(); + } + + onPageShow() { + // 页面显示时调用 + this.controller.onActive(); + } + } + ``` + + ``` + + + + + + + + + ``` diff --git a/zh-cn/application-dev/webgl/figures/zh-cn_image_0000001238544451.png b/zh-cn/application-dev/webgl/figures/zh-cn_image_0000001238544451.png index 007ac6263648c83671d4b085cfc9103f6391be6d..9d953fc57d179bd67edebd43c2a247585bad7bbe 100644 Binary files a/zh-cn/application-dev/webgl/figures/zh-cn_image_0000001238544451.png and b/zh-cn/application-dev/webgl/figures/zh-cn_image_0000001238544451.png differ diff --git a/zh-cn/application-dev/work-scheduler/work-scheduler-dev-guide.md b/zh-cn/application-dev/work-scheduler/work-scheduler-dev-guide.md index d61b52a6d54568481e7730f2f12618e9d573bbd6..4d72584bf0f4e08d169877942f8c5a1ef7ba386f 100644 --- a/zh-cn/application-dev/work-scheduler/work-scheduler-dev-guide.md +++ b/zh-cn/application-dev/work-scheduler/work-scheduler-dev-guide.md @@ -13,7 +13,7 @@ import workScheduler from '@ohos.workScheduler'; 回调相关接口包导入: ```js -import WorkSchedulerExtension from '@ohos.WorkSchedulerExtension'; +import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility'; ``` ### 延迟任务调度 @@ -60,14 +60,14 @@ function onWorkStop(work: WorkInfo): void; | 延迟调度任务结束回调 **开发对应的Extension** - import WorkSchedulerExtension from '@ohos.WorkSchedulerExtension'; + import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility'; - export default class MyWorkSchedulerExtension extends WorkSchedulerExtension { + export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { onWorkStart(workInfo) { - console.log('MyWorkSchedulerExtension onWorkStart' + JSON.stringify(workInfo)); + console.log('MyWorkSchedulerExtensionAbility onWorkStart' + JSON.stringify(workInfo)); } onWorkStop(workInfo) { - console.log('MyWorkSchedulerExtension onWorkStop' + JSON.stringify(workInfo)); + console.log('MyWorkSchedulerExtensionAbility onWorkStop' + JSON.stringify(workInfo)); } } diff --git a/zh-cn/contribute/template/guide-template.md b/zh-cn/contribute/template/guide-template.md index 8305f34c38fb741f6202736171d7563d8d80f022..e01c26119b390ec888e910b55dbd9bbbf5475141 100644 --- a/zh-cn/contribute/template/guide-template.md +++ b/zh-cn/contribute/template/guide-template.md @@ -123,4 +123,13 @@ | 仅进行最后的业务调测,每个小任务的操作结果,在开发步骤执行完成后,及时验证操作结果。 | | | 明确开发成功标准。 | | +## 开发实例 +** *【写作要求】*** + +*提供完整的sample示例,同时简要描述示例原理和实现,并链接到源码仓。* + +针对xxx开发,有以下示例工程可供参考: + +- xxx(此处请提供源码超链接) +本示例xxxx。 diff --git "a/zh-cn/contribute/\350\264\241\347\214\256\346\214\207\345\215\227.md" "b/zh-cn/contribute/\350\264\241\347\214\256\346\214\207\345\215\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..49a74323ed7b037c285c218295b0ad471a8fa2ef --- /dev/null +++ "b/zh-cn/contribute/\350\264\241\347\214\256\346\214\207\345\215\227.md" @@ -0,0 +1,17 @@ +# 贡献指南 + +- **[参与贡献](参与贡献.md)** + +- **[行为准则](行为准则.md)** + +- **[贡献代码](贡献代码.md)** + +- **[贡献流程](贡献流程.md)** + +- **[FAQ](FAQ.md)** + +- **[贡献文档](贡献文档.md)** + +- **[写作规范](写作规范.md)** + +- **[社区沟通与交流](社区沟通与交流.md)** diff --git a/zh-cn/device-dev/Readme-CN.md b/zh-cn/device-dev/Readme-CN.md index 992ec8d7ec53e5c9da385a1d46503b9d5992be80..978bdbf97ff456359c349659ae4a8567ab6e73d7 100644 --- a/zh-cn/device-dev/Readme-CN.md +++ b/zh-cn/device-dev/Readme-CN.md @@ -90,7 +90,7 @@ OpenHarmony也提供了一系列可选的系统组件,方便设备开发者按

OpenHarmony贡献功能组件

- +

参考

@@ -160,7 +160,7 @@ OpenHarmony也提供了一系列可选的系统组件,方便设备开发者按

OpenHarmony贡献功能组件

- +

参考

diff --git a/zh-cn/device-dev/bundles/Readme-CN.md b/zh-cn/device-dev/bundles/Readme-CN.md index 20c3daa088f62dd2d0b8a59271eb7eb81a94c695..6ddc8aac75a079e08b239c65442eaf5c8afc45cb 100755 --- a/zh-cn/device-dev/bundles/Readme-CN.md +++ b/zh-cn/device-dev/bundles/Readme-CN.md @@ -1,6 +1,6 @@ # Bundle开发指南 -- [开发规范](oem_bundle_standard_des.md) +- [开发规范](bundles-standard-rules.md ) - [开发指南](bundles-guide.md) - [概述](bundles-guide-overview.md) - [安装hpm命令行工具](bundles-guide-prepare.md) diff --git a/zh-cn/device-dev/bundles/bundles-standard-rules.md b/zh-cn/device-dev/bundles/bundles-standard-rules.md index d52a49caa4597cff733216a2d31e5229494ecafe..8560d653ac577ac0d65b15b06a306b3a4edde851 100644 --- a/zh-cn/device-dev/bundles/bundles-standard-rules.md +++ b/zh-cn/device-dev/bundles/bundles-standard-rules.md @@ -182,7 +182,7 @@ hpm install username@server MINGW64 /f/showcase/demo/demo $ hpm list +--demo@1.0.0 -| +--@huawei/media@1.0.2 +| +--@demo/media@1.0.2 | +--@demo/sport_hi3518ev300_liteos_a@1.0.0 | | +--@demo/app@4.0.1 | | | +--@demo/build@4.0.1 diff --git a/zh-cn/device-dev/driver/driver-peripherals-light-des.md b/zh-cn/device-dev/driver/driver-peripherals-light-des.md index 64a5dc58301c536e45a2c317553c9e075c74bb46..e7cb03ef7df0d69f33549d5bb01ee9870a8887e6 100644 --- a/zh-cn/device-dev/driver/driver-peripherals-light-des.md +++ b/zh-cn/device-dev/driver/driver-peripherals-light-des.md @@ -45,11 +45,11 @@ Light驱动模型以标准系统Hi3516DV300为例,介绍整个驱动加载及 ### 场景介绍 -灯设备的控制,在实际生活中比比皆是,例如短信通知时闪灯、手机电量不足是预警、充电时根据充电进度变换灯的颜色等等。这些动作的实现,都需要使用Light驱动模型提供的接口,动态配置点灯模式、配置灯闪烁效果、点灯、熄灯等。 +灯设备的控制,在实际生活中比比皆是,例如短信通知时闪灯、手机电量不足时预警、充电时根据充电进度变换灯的颜色等等。这些动作的实现,都需要使用Light驱动模型提供的接口,动态配置点灯模式、配置灯闪烁效果、点灯、熄灯等。 ### 接口说明 -Light驱动模型支持获取系统中所有灯的信息,动态配置闪烁模式和闪烁时间的能力。Light硬件服务调用GetLightInfo获取Light设备的基本信息;调用TurnOnLight接口启动配置的闪烁效果。Light驱动模型对HDI开放的API接口能力,参考[表1](#Light驱动模型对外API接口能力介绍)。 +Light驱动模型支持获取系统中所有灯的信息,动态配置闪烁模式和闪烁时间的能力。Light硬件服务调用GetLightInfo获取Light设备的基本信息;调用TurnOnLight接口启动配置的闪烁效果。Light驱动模型对外开放的API接口能力,参考[表1](#Light驱动模型对外API接口能力介绍)。 **表1** Light驱动模型对外API接口能力介绍 diff --git a/zh-cn/device-dev/faqs/Readme-CN.md b/zh-cn/device-dev/faqs/Readme-CN.md index 3cc4b5009fa7fd9f673866a3b647a10ef2273333..dd6d4efe122a3e31ff94511db3fb603927896996 100644 --- a/zh-cn/device-dev/faqs/Readme-CN.md +++ b/zh-cn/device-dev/faqs/Readme-CN.md @@ -6,6 +6,6 @@ - [烧录常见问题](faqs-burning.md) - [内核常见问题](faqs-kernel.md) - [移植常见问题](faqs-porting.md) -- [启动恢复常见问题](faqs-startup-and-recovery.md) +- [启动恢复常见问题](faqs-startup.md) - [系统应用常见问题](faqs-system-applications.md) diff --git a/zh-cn/device-dev/faqs/faqs-startup-and-recovery.md b/zh-cn/device-dev/faqs/faqs-startup.md similarity index 100% rename from zh-cn/device-dev/faqs/faqs-startup-and-recovery.md rename to zh-cn/device-dev/faqs/faqs-startup.md diff --git a/zh-cn/device-dev/faqs/faqs-system-applications.md b/zh-cn/device-dev/faqs/faqs-system-applications.md index a78ff419666cd091e4c647a091f205d8ca65f41c..b8f34e907fbd1735e40ab63333e71bf4ad21c5e6 100644 --- a/zh-cn/device-dev/faqs/faqs-system-applications.md +++ b/zh-cn/device-dev/faqs/faqs-system-applications.md @@ -43,7 +43,7 @@ LiteOS-A内核\(Hi3516、Hi3518平台\)直接调用KV存储提供的接口,各 显示调用KV存储的UtilsSetEnv接口,设置数据存储路径。 ``` -UtilsSetEnv("/storage/com.huawei.kv"); +UtilsSetEnv("/storage/com.example.kv"); ``` ## 视觉应用常见问题 diff --git a/zh-cn/device-dev/get-code/gettools-acquire.md b/zh-cn/device-dev/get-code/gettools-acquire.md index 830c6001e9482c4a04bdc64629f5dbfbc95c2452..a20b03121461491c3b3418809273b93f7e25ff63 100644 --- a/zh-cn/device-dev/get-code/gettools-acquire.md +++ b/zh-cn/device-dev/get-code/gettools-acquire.md @@ -43,7 +43,7 @@ OpenHarmony为开发者提供了两种Docker环境,以帮助开发者快速完

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker

-

0.0.7

+

1.0.0

标准系统

@@ -52,7 +52,7 @@ OpenHarmony为开发者提供了两种Docker环境,以帮助开发者快速完

swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard

-

0.0.8

+

1.0.0

HPM Docker环境

@@ -75,6 +75,7 @@ OpenHarmony为开发者提供了两种Docker环境,以帮助开发者快速完 + ## 环境准备 在使用docker环境前需要先完成以下操作: @@ -95,7 +96,7 @@ OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud 1. 获取Docker镜像。 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境。 @@ -103,13 +104,13 @@ OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud ubuntu下执行: ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` windows下执行(假设源码目录为D:\\OpenHarmony): ``` - docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` @@ -121,7 +122,6 @@ OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud ``` hb set - . ``` **图 1** 设置编译界面 @@ -150,13 +150,13 @@ hb set 1. 获取Docker镜像。 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境。 ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/zh-cn/device-dev/kernel/Readme-CN.md b/zh-cn/device-dev/kernel/Readme-CN.md index 69a2a9ca7c64c75bcff96f63590bc4662480bd38..66f6c859f7d474fa1b393f9019ab0d6c75dde107 100755 --- a/zh-cn/device-dev/kernel/Readme-CN.md +++ b/zh-cn/device-dev/kernel/Readme-CN.md @@ -178,3 +178,6 @@ - [Linux内核概述](kernel-standard-overview.md) - [开发板Patch使用指导](kernel-standard-patch.md) - [Linux内核编译与构建指导](kernel-standard-build.md) + - [内核增强特性](kernel-standard-enhanced-features.md) + - [内存管理](kernel-standard-mm.md) + - [Enhanced SWAP特性介绍](kernel-standard-mm-eswap.md) diff --git a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md index 255a6ae25947791c174927d407b111f2e66158c6..3fc9e2fe3f784837b5833861f8b1688a8152d56d 100644 --- a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md +++ b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-kill.md @@ -55,7 +55,6 @@ kill [-l [_signo_] | _-s signo_ | _-signo_] _pid..._ 6 1 6 0 Pending 0x688000 0x137000 0x11bca0 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa1cdf 0.88 wms_server 8 1 8 2 Pending 0x1f5000 0x48000 0x47dc2 0.2 mksh - 10 5 5 101 Pending 0x11ec000 0x2f9000 0x206047 0.93 com.huawei.launcher 12 1 12 0 Pending 0x4d4000 0x112000 0xe0882 0.0 deviceauth_service 13 1 13 0 Pending 0x34f000 0xbd000 0x51799 0.0 sensor_service 14 1 14 2 Pending 0x34e000 0xb3000 0x52184 0.0 ai_server @@ -80,7 +79,6 @@ kill [-l [_signo_] | _-s signo_ | _-signo_] _pid..._ 6 1 6 0 Pending 0x688000 0x137000 0x11c1ba 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa21f9 0.89 wms_server 8 1 8 2 Pending 0x1f5000 0x48000 0x482dc 0.2 mksh - 10 5 5 101 Pending 0x11ec000 0x2f9000 0x206561 0.93 com.huawei.launcher 12 1 12 0 Pending 0x4d4000 0x112000 0xe0d9c 0.0 deviceauth_service 13 1 13 0 Pending 0x34f000 0xbd000 0x51cb3 0.0 sensor_service 14 1 14 2 Pending 0x34e000 0xb3000 0x5269e 0.0 ai_server diff --git a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-task.md b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-task.md index 2cb47608d3460c025d87b23eeaa201ba4ff87a2f..b169474cf33f6046b49dd8cec51a74cb66d8cfec 100644 --- a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-task.md +++ b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-task.md @@ -52,7 +52,6 @@ OHOS # task 6 1 6 0 Pending 0x688000 0x137000 0x11c518 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa1ddf 0.89 wms_server 8 1 1 1000 Running 0x2bf000 0x8f000 0x2a8c6 0.0 shell - 9 5 5 101 Pending 0x11ea000 0x2f9000 0x20429d 0.97 com.huawei.launcher 11 1 11 0 Pending 0x4d4000 0x112000 0xe0ad7 0.0 deviceauth_service 12 1 12 0 Pending 0x34f000 0xbd000 0x519ee 0.0 sensor_service 13 1 13 2 Pending 0x34e000 0xb3000 0x523d9 0.0 ai_server diff --git a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-top.md b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-top.md index e6465cac25560bf76d48c1fd1cd3fa45b6a857fd..4507fc19cc3e57cecf66ec0d2e138b27474de1b5 100644 --- a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-top.md +++ b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-top.md @@ -52,7 +52,6 @@ OHOS:/$ top 6 1 6 0 Pending 0x688000 0x137000 0x11c1ba 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa21f9 0.87 wms_server 8 1 8 2 Pending 0x1f5000 0x48000 0x462dc 0.0 mksh - 9 5 5 101 Pending 0x11ea000 0x2f9000 0x204561 0.94 com.huawei.launcher 11 1 11 0 Pending 0x4d4000 0x112000 0xe0d9c 0.0 deviceauth_service 12 1 12 0 Pending 0x34f000 0xbd000 0x51cb3 0.0 sensor_service 13 1 13 2 Pending 0x34e000 0xb3000 0x5269e 0.0 ai_server diff --git a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md index 0d9f9fe060ec3149a2fa5f8e5776bfcd3db29c68..0279282d1f36122a41222ab1973cf424594bddd6 100644 --- a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md +++ b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-uname.md @@ -52,7 +52,7 @@ uname [_-a | -s | -r | -m | -n | -v | --help_] ``` OHOS:/$ uname -a -Huawei LiteOS hisilicon 2.0.0.37 Huawei LiteOS 2.0.0.37 Oct 21 2021 17:39:32 Cortex-A7 +LiteOS hisilicon 2.0.0.37 Huawei LiteOS 2.0.0.37 Oct 21 2021 17:39:32 Cortex-A7 OHOS:/$ ``` @@ -60,6 +60,6 @@ OHOS:/$ ``` OHOS:/$ uname -ms -Huawei LiteOS Cortex-A7 +LiteOS Cortex-A7 OHOS:/$ ``` diff --git a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md index 7798cb435eda6b001dcc9c5e026bf319110a7880..559d76ec8558e5e75fb9ab4d3592bf76d42bdbe1 100644 --- a/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md +++ b/zh-cn/device-dev/kernel/kernel-small-debug-shell-cmd-watch.md @@ -59,7 +59,6 @@ OHOS # 6 1 6 0 Pending 0x688000 0x137000 0x11c518 0.0 media_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa1ddf 0.95 wms_server 8 1 1 1000 Running 0x2bf000 0x8f000 0x2a8c6 0.0 shell - 9 5 5 101 Pending 0x11ea000 0x2f9000 0x20429d 1.2 com.huawei.launcher 11 1 11 0 Pending 0x4d4000 0x112000 0xe0ad7 0.0 deviceauth_service 12 1 12 0 Pending 0x34f000 0xbd000 0x519ee 0.0 sensor_service 13 1 13 2 Pending 0x34e000 0xb3000 0x523d9 0.0 ai_server diff --git a/zh-cn/device-dev/kernel/kernel-standard-enhanced-features.md b/zh-cn/device-dev/kernel/kernel-standard-enhanced-features.md new file mode 100644 index 0000000000000000000000000000000000000000..348cf8bd68185bea940b47160c780db8c0ac03d3 --- /dev/null +++ b/zh-cn/device-dev/kernel/kernel-standard-enhanced-features.md @@ -0,0 +1,3 @@ +# 内核增强特性 + +- **[内存管理](kernel-standard-mm.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/kernel/kernel-standard-mm-eswap.md b/zh-cn/device-dev/kernel/kernel-standard-mm-eswap.md new file mode 100644 index 0000000000000000000000000000000000000000..ef358a73ff013109d626c7f739e2a2b84698f027 --- /dev/null +++ b/zh-cn/device-dev/kernel/kernel-standard-mm-eswap.md @@ -0,0 +1,234 @@ +# Enhanced SWAP特性介绍 + + +## 基本概念 + +ESwap(Enhanced Swap)提供了自定义新增存储分区作为内存交换分区的能力,并创建了一个常驻进程zswapd将压缩后的匿名页加密换出到ESwap存储分区,从而能完全的空出一块可用内存,以此来达到维持Memavailable水线的目标。同时,配合这个回收机制,在整个内存框架上进行改进,优化匿名页和文件页的回收效率,并且使两者的回收比例更加合理以避免过度回收导致的refault问题造成卡顿现象。 + + +## ZRAM与ESwap配置指导 + +### 使能ESwap +1. 打开相关配置项及依赖 + + 启用ESwap,需要通过编译内核时打开相应的配置项及依赖,ESwap相关CONFIG如下: + + ``` + CONFIG_HYPERHOLD=y + CONFIG_HYPERHOLD_DEBUG=y + CONFIG_HYPERHOLD_ZSWAPD=y + CONFIG_HYPERHOLD_FILE_LRU=y + CONFIG_HYPERHOLD_MEMCG=y + CONFIG_ZRAM_GROUP=y + CONFIG_ZRAM_GROUP_DEBUG=y + CONFIG_ZLIST_DEBUG=y + CONFIG_ZRAM_GROUP_WRITEBACK=y + ``` + + 另有部分CONFIG被依赖: + + ``` + CONFIG_MEMCG=y + CONFIG_SWAP=y + CONFIG_ZSMALLOC=y + CONFIG_ZRAM=y + ``` + +2. 创建ESwap设备 + + 可以使用任意block设备作为ESwap交换设备,这里创建一个文件hpdisk挂载为loop6设备: + + ```Bash + // 通过dd命令创建一个文件hpdisk用于ESwap换出,具体大小需根据产品及需求调整,此处设置为512MB。 + dd if=/dev/random of=/data/hpdisk bs=4096 count=131072 + // 将上一步创建的hpdisk与ESwap device进行绑定。 + losetup /dev/block/loop6 hpdisk + ``` + +3. 配置ESwap + + 将2中创建的设备绑定为ESwap换出设备: + + ```Bash + echo /dev/block/loop6 > /proc/sys/kernel/hyperhold/device + ``` + + ESwap默认对换出数据使用软件加密,如果2中创建的ESwap设备支持inline加密,可以关闭ESwap的软件加密功能: + + ```Bash + // 需确认是否支持并开启硬加密,否则不要执行该操作。 + echo 0 > /proc/sys/kernel/hyperhold/soft_crypt + ``` + + > ![icon-caution.gif](public_sys-resources/icon-caution.gif) **注意:** + > 出于安全考虑,所有换出内容均需加密。因此若当前配置ESwap的设备不支持inline加密,或编译时未打开inline加密宏,则在关闭软加密时,ESwap无法enable。 + +4. 使能ESwap + + 使能ESwap,使能后无法更改上述配置: + + ```Bash + echo enable > /proc/sys/kernel/hyperhold/enable + ``` + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** +> 使能ESwap需要在使能ZRAM之前,不需要使用ESwap时, 也可以仅使能ZRAM。如部分设备不包括用于换出的存储设备,也没有新建相应的存储分区,那么可以仅使能ZRAM来通过zswapd进行内存回收。 + +### 使能ZRAM + +1. 初始化ZRAM + + ```Bash + // 打开ZRAM到eswap的换入换出功能,该步骤必须要在配置ZRAM大小之前。 + echo readwrite > /sys/block/zram0/group + // 配置ZRAM的大小,具体大小需根据产品及需求调整,此处设置为512MB。 + echo 512M > /sys/block/zram0/disksize + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > /sys/block/zram0/group可接受参数及作用为: + > + > - none:表示disable; + > - readonly:表示只记录数据的cgroup信息,并不换出; + > - readwrite:表示打开ZRAM到eswap的换入换出功能。 + +2. 使能ZRAM + + ```Bash + mkswap /dev/block/zram0 + swapon /dev/block/zram0 + ``` + + +### 关闭ESwap与ZRAM + +1. 关闭ESwap + + ```Bash + echo disable > /proc/sys/kernel/hyperhold/enable + 或 + echo force_disable > /proc/sys/kernel/hyperhold/enable + ``` + + > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** + > 两者的区别在于: + > + > - disable:表示如果ESwap中没有数据,则完全关闭,否则变为只读模式; + > - force_disable:表示如果没有数据,完全关闭,否则变为只读模式,并同步等待ESwap中数据完全读出,然后完全关闭。 + +2. 关闭ZRAM及ZRAM group + + ```Bash + echo 1 > /sys/block/zram0/reset + ``` + + +## ESwap相关接口 + +ESwap提供了一些接口用于控制换入换出策略以及记录当前状态,这些接口位于memcg所挂载的目录当中,如`/dev/memcg/`。 + +| 功能分类 | 接口名 | 描述 | +| -------- | -------- | -------- | +| 控制接口 | [avail_buffers](#avail_buffers) | 设置buffer区间 | +| | [zswapd_single_memcg_param](#zswapd_single_memcg_param) | 设置当前memcg相关配置 | +| | [zswapd_wm_ratio](#zswapd_wm_ratio) | 设置zram换出水线 | +| 状态接口 | [zswapd_pressure_show](#zswapd_pressure_show) | 记录当前buffer以及refault | +| | [stat](#stat) | 检测ESwap实时情况 | +| | [zswapd_vmstat_show](#zswapd_vmstat_show) | 记录zswapd运行过程中各种事件 | + +> ![icon-caution.gif](public_sys-resources/icon-caution.gif) **注意:** +> 除avail_buffers会因为调整了buffer水线而会主动去唤醒zswapd外,其余控制接口并不会主动唤醒zswapd,只是其配置需在zswapd所被唤醒后方可生效。 + +各接口的具体描述如下: + +### avail_buffers + +avail_buffers接口用于设置buffer区间[min_avail_buffers, high_avail_buffers],当检测到当前的buffer低于min_avail_buffers时则会唤醒zswapd进行匿名页回收,期望的回收量为high_avail_buffers与当前系统buffer值的差值,实际可能会因为无法回收等原因而未回收那么多内存。avail_buffers为期望的内存正常状态buffer值,free_swap_threshold则是设置交换分区空闲容量的阈值,当zswapd唤醒并进行内存回收之后,会根据当前系统情况以及两者的设置记录当前内存压力事件,如medium press,critical press等。可主动调整来触发zswapd回收,如`echo 1000 950 1050 0 > /dev/memcg/memory.avail_buffers`。 + +默认值: + +``` + avail_buffers: 0 + min_avail_buffers: 0 + high_avail_buffers: 0 + free_swap_threshold: 0 +``` + +限制: + +0<=min_avail_buffers<=avail_buffers<=high_avail_buffers + +0<=free_swap_threashold + +取值均为整型。 + +### zswapd_single_memcg_param + +设置当前memcg的相关配置。score为当前memcg回收优先级,ub_mem2zram_ratio为内存压缩到ZRAM的比率,ub_zram2ufs_ratio为ZRAM换出到ESwap的比率,refault_threshold为refault的阈值,可通过调整比率来控制ZRAM压缩以及ESwap换出情况,如`echo 60 10 50 > memory.zswapd_single_memcg_param`。 + +默认值: + +``` + memcg score: 300 + memcg ub_mem2zram_ratio: 60 + memcg ub_zram2ufs_ratio: 10 + memcg refault_threshold: 50 +``` + +限制: + +0<=ub_mem2zram_ratio<=100 + +0<=ub_zram2ufs_ratio<=100 + +0<=refault_threshold<=100 + +取值均为整型。 + +### zram_wm_ratio + +设置ZRAM换出水线,即当当前ZRAM中压缩的匿名页大于ZRAM总大小*zram_wm_ratio时,会开始向ESwap进行换出,但是具体换出时间为zswapd因buffer水线而唤醒之后。设置为0时系统默认为37,可进行调整,如`echo 30 > /dev/memcg/memory.zram_wm_ratio`。 + +默认值: + +``` + zram_wm_ratio: 0 +``` + +限制: + +0<=zram_wm_ratio<=100 + +取值为整型。 + +### zswapd_pressure_show + +记录当前zswapd所需相关状态,buffer_size为当前系统的buffer值,recent_refault为最近产生的refault次数。 + + +### stat + +在原有memcg.stat的基础上新增了Anon,File,zram,Eswap等项,用以监测ESwap的实时情况。 + + +### zswapd_vmstat_show + +记录zswapd运行过程中的各种事件。 + + +## 触发zswapd回收 + +可先通过`cat /dev/memcg/memory.zswapd_pressure_show`查看当前buffer值,比如当前为1200,那么便可通过主动调整buffer区间,来主动唤醒zswapd。 + +```Bash +echo 1300 1250 1350 0 > /dev/memcg/memory.avail_buffers +``` + + +## ESwap配置大小示例 + +ZRAM与ESwap的大小配置需根据实际使用场景以及产品硬件特点进行适配。目前在rk3568板子上使用时,其ram为2G,因此设置的ZRAM与ESwap大小均为512MB。 + + + diff --git a/zh-cn/device-dev/kernel/kernel-standard-mm.md b/zh-cn/device-dev/kernel/kernel-standard-mm.md new file mode 100644 index 0000000000000000000000000000000000000000..2c54cc79301396553a1573f6ffd75e2c9f2b65ea --- /dev/null +++ b/zh-cn/device-dev/kernel/kernel-standard-mm.md @@ -0,0 +1,3 @@ +# 内存管理 + +- **[Enhanced SWAP特性介绍](kernel-standard-mm-eswap.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/kernel/kernel-standard.md b/zh-cn/device-dev/kernel/kernel-standard.md index d642451274aac47aef7519c49b60bab328525730..73034025e7f08827766813caf81e604ae4cacf70 100644 --- a/zh-cn/device-dev/kernel/kernel-standard.md +++ b/zh-cn/device-dev/kernel/kernel-standard.md @@ -7,3 +7,5 @@ - **[Linux内核编译与构建指导](kernel-standard-build.md)** +- **[内核增强特性](kernel-standard-enhanced-features.md)** + diff --git a/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md b/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md index f2725ccc22379214adc7003b25463a1850aacc5d..b65533df179d3078518e6d089a5f662f5e93c75a 100644 --- a/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md +++ b/zh-cn/device-dev/porting/porting-bes2600w-on-minisystem-display-demo.md @@ -410,7 +410,6 @@ static int32_t FsDriverInit(struct HdfDeviceObject *object) fs[i].lfs_cfg.lookahead_size = 16; fs[i].lfs_cfg.block_cycles = 1000; - SetDefaultMountPath(i, fs[i].mount_point); int ret = mount(NULL, fs[i].mount_point, "littlefs", 0, &fs[i].lfs_cfg); HDF_LOGI("%s: mount fs on '%s' %s\n", __func__, fs[i].mount_point, (ret == 0) ? "succeed" : "failed"); } diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-docker-environment.md b/zh-cn/device-dev/quick-start/quickstart-lite-docker-environment.md index a81005a338f33cbf35f011222b3f78d7f5b70f6c..0618477f49c778435cc98ff6624cb93700ab74ae 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-docker-environment.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-docker-environment.md @@ -24,11 +24,11 @@ OpenHarmony的Docker镜像托管在[HuaweiCloud SWR](https://console.huaweicloud 1. 获取Docker镜像。 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. 进入OpenHarmony代码根目录执行如下命令,从而进入Docker构建环境。 ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.7 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md b/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md index dfbbfd4a90a433d852b06b796937251f4ba9cb3f..afd8bf414e2434f55a029860e2679a92ec4d2564 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.md @@ -17,7 +17,7 @@ 使用如下apt-get命令安装编译所需的必要的库和工具: ``` -sudo apt-get install build-essential gcc g++ make zlib* libffi-dev e2fsprogs pkg-config flex bison perl bc openssl libssl-dev libelf-dev libc6-dev-amd64 binutils binutils-dev libdwarf-dev u-boot-tools mtd-utils gcc-arm-linux-gnueabi cpio device-tree-compiler +sudo apt-get install build-essential gcc g++ make libffi-dev e2fsprogs pkg-config flex bison perl bc openssl libssl-dev libelf-dev libc6-dev-amd64 binutils binutils-dev libdwarf-dev u-boot-tools mtd-utils gcc-arm-linux-gnueabi cpio device-tree-compiler ``` ## 安装hb diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md index 5bb3128a4361d1b41e3d5f2ed999f0514dcb5534..47f745e8c9cd4ae5ebeff637099c46d9e3914408 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-hi3516-build.md @@ -41,13 +41,13 @@ bash build/prebuilts_download.sh 1. 获取Docker镜像。 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` 2. 进入源码根目录执行如下命令,从而进入Docker构建环境。 ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md index 781ce3a9e2b69b7928816c71108f37a46f37fae7..2b414676249d306a6f1717ca220822836f7f0d13 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-build.md @@ -41,13 +41,13 @@ bash build/prebuilts_download.sh 1. 获取Docker镜像。 ``` - docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:1.0.0 ``` 2. 进入源码根目录执行如下命令,从而进入Docker构建环境。 ``` - docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker-standard:0.0.8 + docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 ``` diff --git a/zh-cn/device-dev/subsystems/Readme-CN.md b/zh-cn/device-dev/subsystems/Readme-CN.md index 40e9f6ae1fd4573fb8003c92ea24398c6ee8fbbf..ab753e77a09f5589873f7e363a7a47cfb636662b 100755 --- a/zh-cn/device-dev/subsystems/Readme-CN.md +++ b/zh-cn/device-dev/subsystems/Readme-CN.md @@ -4,6 +4,7 @@ - [轻量和小型系统编译构建指导](subsys-build-mini-lite.md) - [标准系统编译构建指导](subsys-build-standard-large.md) - [构建系统编码规范和最佳实践指导](subsys-build-gn-coding-style-and-best-practice.md) + - [编译构建Kconfig可视化配置指导](subsys-build-gn-kconfig-visual-config-guid.md) - [分布式远程启动](subsys-remote-start.md) - [图形图像](subsys-graphics.md) - [图形图像概述](subsys-graphics-overview.md) diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md index b42a258f2c716c1a1d5b36e337341547f89eef4b..01bb60ea61e09e854ab1e25c7bf702cb3f94091f 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-listening.md @@ -77,7 +77,7 @@ HiSysEvent提供了跨进程订阅机制,开发者可以通过注册订阅接 void OnServiceDied(); }; - #endif DEMO_LISTENER_H + #endif // DEMO_LISTENER_H ``` 增加DemoListener.cpp文件,在DemoListener类中根据实际需求自定义订阅回调接口的实现逻辑: diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md index 426b6117382fc656a5d2d061c79aa8aa9c69813c..60ffefa6e229e360586778fcd78155086a7619bd 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-query.md @@ -17,7 +17,7 @@ HiSysEvent提供了查询接口,支持开发者设置条件查询HiSysEvent事 | 接口名称 | 描述 | | -------- | --------- | -| bool HiSysEventManager::QueryHiSysEvent(struct QueryArg& queryArg, std::vector<struct QueryRule>& queryRules, std::shared_ptr<HiSysEventQueryCallBack> queryCallBack) | 接口功能:
  支持设置查询时间段,事件领域,事件名称等,查询满足条件的HiSysEvent事件。

输入参数:
  • queryArg:查询参数。
  • queryRules:事件过滤规则。
  • queryCallBack:查询接口回调对象。
返回值:
  • true:查询成功。
  • false:查询失败。
| +| bool HiSysEventManager::QueryHiSysEvent(struct QueryArg& queryArg, std::vector<QueryRule>& queryRules, std::shared_ptr<HiSysEventQueryCallBack> queryCallBack) | 接口功能:
  支持设置查询时间段,事件领域,事件名称等,查询满足条件的HiSysEvent事件。

输入参数:
  • queryArg:查询参数。
  • queryRules:事件过滤规则。
  • queryCallBack:查询接口回调对象。
返回值:
  • true:查询成功。
  • false:查询失败。
| **表 2** QueryArg查询参数对象 @@ -30,11 +30,9 @@ HiSysEvent提供了查询接口,支持开发者设置条件查询HiSysEvent事 **表 3** QueryRule查询规则对象 -| 属性名称 | 描述 | +| 接口名称 | 描述 | | -------- | --------- | -| ruleType | uint32_t类型,用来标识查询规则对象的规则类型,默认是0。 | -| domain | string类型,用来标识查询规则对象的事件所属领域,如果传入的是空字符串,则默认事件领域字段匹配成功。 | -| eventList | std::vector<std::string>类型,事件名称的列表,如果传入的是空字符串,则默认事件名称字段匹配成功。 | +| QueryRule(const std::string& domain, const std::vector<std::string>& eventList) | 接口功能:查询规则构造函数,创建查询规则对象。

输入参数:
  • domain:string类型,用来标识查询规则对象的事件所属领域,如果传入的是空字符串,则默认事件领域字段匹配成功。
  • eventList:std::vector<std::string>类型,事件名称的列表,如果传入的是空字符串,则默认事件名称字段匹配成功。
| **表 4** HiSysEventQueryCallBack查询回调对象 @@ -55,13 +53,13 @@ C++接口实例。 - 实现对应的查询回调接口: - void HiSysEventQueryCallBack::OnQuery\(const ::std::vector& sysEvent, const ::std::vector& seq\) + void HiSysEventQueryCallBack::OnQuery\(const ::std::vector<std::string>& sysEvent, const ::std::vector& seq\) void HiSysEventQueryCallBack::OnComplete\(int32\_t reason, int32\_t total\) - 在相应的业务逻辑里面调用查询接口: - HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector& queryRules, std::shared\_ptr queryCallBack\) + HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector& queryRules, std::shared\_ptr queryCallBack\) ``` @@ -90,7 +88,7 @@ C++接口实例。 // 调用查询接口获取HiSysEvent事件 auto queryCallBack = std::make_shared(); struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents); - std::vector mRules; + std::vector mRules; HiSysEventManager::QueryHiSysEvent(args, mRules, queryCallBack); ``` diff --git a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-tool.md b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-tool.md index 7f27de82e6fc0d33f934193f0bb496ac7736919c..a71dcc312d7027c21495891c3096c381201d5d8d 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-tool.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx-hisysevent-tool.md @@ -37,15 +37,28 @@ - 通过事件标签方式实时订阅HiSysEvent事件: ``` - hisysevnet -r -t [-c [WHOLE_WORD|PREFIX|REGULAR]] + hisysevent -r -t [-c [WHOLE_WORD|PREFIX|REGULAR]] ``` 选项说明: | 选项名称 | 功能说明 | | -------- | --------- | - | -t  | 设置实时订阅的HiSysEvent事件标签,用来过滤订阅的HiSysEvent事件 | - | -c  | 设置实时订阅的HiSysEvent事件标签匹配规则,有“WHOLE_WORD”、“PREFIX”、“REGULAR”三种匹配规则| + | -t  | 设置实时订阅的HiSysEvent事件标签,用来过滤订阅的HiSysEvent事件。 | + | -c  | 设置实时订阅的HiSysEvent事件标签匹配规则,有“WHOLE_WORD”、“PREFIX”、“REGULAR”三种匹配规则。 | + + 命令实例: + + ``` + # hisysevent -r -t "TAG" -c PREFIX + {"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""} + # hisysevent -r -t "TA\w{0,1}" -c REGULAR + {"domain_":"WINDOWMANAGER","name_":"NO_FOCUS_WINDOW","type_":1,"time_":1501940269802,"tz_":"+0000","tag_":"TAG","pid_":1428,"tid_":1433,"uid_":10001,"level_":"CRITICAL","info_":""} + {"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""} + # hisysevent -r -t "TA\w+" -c REGULAR + {"domain_":"WINDOWMANAGER","name_":"NO_FOCUS_WINDOW","type_":1,"time_":1501940269802,"tz_":"+0000","tag_":"TAG","pid_":1428,"tid_":1433,"uid_":10001,"level_":"CRITICAL","info_":""} + {"domain_":"ACE","name_":"UI_BLOCK_6S","type_":1,"time_":1501940269812,"tz_":"+0000","tag_":"TAG1","pid_":1428,"tid_":1452,"uid_":10001,"level_":"CRITICAL","info_":""} + ``` - 通过事件领域及事件名称的方式实时订阅HiSysEvent事件: @@ -53,11 +66,27 @@ hisysevent -r -o -n [-c [WHOLE_WORD|PREFIX|REGULAR]] ``` + 选项说明: + | 选项名称 | 功能说明 | | -------- | --------- | - | -o | 设置实时订阅的HiSysEvent事件领域,用来过滤订阅的HiSysEvent事件 | - | -n | 设置实时订阅的HiSysEvent事件名称,用来过滤订阅的HiSysEvent事件| - | -c | 设置实时订阅的HiSysEvent事件领域及事件名称的匹配规则,有“WHOLE_WORD”、“PREFIX”、“REGULAR”三种匹配规则| + | -o | 设置实时订阅的HiSysEvent事件领域,用来过滤订阅的HiSysEvent事件。 | + | -n | 设置实时订阅的HiSysEvent事件名称,用来过滤订阅的HiSysEvent事件。 | + | -c | 设置实时订阅的HiSysEvent事件领域及事件名称的匹配规则,有“WHOLE_WORD”、“PREFIX”、“REGULAR”三种匹配规则。 | + + 命令实例: + + ``` + # hisysevent -r -o "DOMAINA" -n "EVENTNAMEA" + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + # hisysevent -r -o "DOMA\w{0,10}" -n "EVENT\w+" -c REULAR + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINABC","name_":"EVENTNAMEABC","type_":1,"time_":1501940269938,"tz_":"+0000","pid_":1428,"tid_":1336,"uid_":10002,"level_":"CRITICAL","info_":""} + # hisysevent -r -o "DOMA\w{0,10}" -c REGULAR + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":1501940269802,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINABC","name_":"EVENTNAMEABC","type_":1,"time_":1501940269938,"tz_":"+0000","pid_":1428,"tid_":1336,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINABC","name_":"EVENTNAMEB","type_":1,"time_":1501940279938,"tz_":"+0000","pid_":1428,"tid_":1344,"uid_":10002,"level_":"CRITICAL","info_":""} + ``` >![](../public_sys-resources/icon-note.gif) **说明:** >当同时通过-t、-o及-n指定了相关订阅规则参数设置,则判断设置的事件标签是否为空,若不为空,则使用事件标签规则进行订阅,否则使用事件领域及事件名称订阅规则进行订阅。 @@ -74,7 +103,7 @@ | 选项名称 | 功能说明 | | -------- | --------- | - | -l | 以缺省设置查询历史HiSysEvent事件,此次查询会返回最近不多于1000条的HiSysEvent事件 | + | -l | 以缺省设置查询历史HiSysEvent事件,此次查询会返回最近不多于1000条的HiSysEvent事件。 | - 通过设置开始/结束时间,过滤查询历史HiSysEvent事件的结果的命令: @@ -86,8 +115,18 @@ | 选项名称 | 功能说明 | | -------- | --------- | - | -s | 设置查询历史HiSysEvent事件的开始时间,此次查询只会返回不早于该时间点的HiSysEvent事件 | - | -e | 设置查询历史HiSysEvent事件的结束时间,此次查询只会返回不晚于该时间点的HiSysEvent事件 | + | -s | 设置查询历史HiSysEvent事件的开始时间,此次查询只会返回不早于该时间点的HiSysEvent事件。 | + | -e | 设置查询历史HiSysEvent事件的结束时间,此次查询只会返回不晚于该时间点的HiSysEvent事件。 | + + 命令实例: + + ``` + # hisysevent -l -s 20207388633 -e 20207389000 + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388633,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388900,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207389000,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + ``` - 通过设置最大数量值,限制查询历史HiSysEvent事件的数量: @@ -100,3 +139,15 @@ | 选项名称 | 功能说明 | | -------- | --------- | | -m | 设置查询历史HiSysEvent事件的数量,有效值范围[0,1000],此次查询返回的HiSysEvent事件数目不会多于此值。 | + + 命令实例: + + ``` + # hisysevent -l -s 20207388633 -e 20207389000 -m 3 + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388900,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207389000,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + # hisysevent -l -m 2 + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388633,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + {"domain_":"DOMAINA","name_":"EVENTNAMEA","type_":1,"time_":20207388634,"tz_":"+0000","pid_":1428,"tid_":1333,"uid_":10002,"level_":"CRITICAL","info_":""} + ``` diff --git a/zh-cn/device-dev/subsystems/subsys-dfx.md b/zh-cn/device-dev/subsystems/subsys-dfx.md index 4c74132f820e5daea13e5a48d162cf93475d1e6f..2fdce0127f362ed08c6148f268b6585aaaa55ea9 100644 --- a/zh-cn/device-dev/subsystems/subsys-dfx.md +++ b/zh-cn/device-dev/subsystems/subsys-dfx.md @@ -6,9 +6,13 @@ - **[HiLog\_Lite开发指导](subsys-dfx-hilog-lite.md)** +- **[HiTrace开发指导](subsys-dfx-hitrace.md)** + +- **[HiCollie开发指导](subsys-dfx-hicollie.md)** + - **[HiSysEvent开发指导](subsys-dfx-hisysevent.md)** - -[HiSysEvent打点配置指导](subsys-dfx-hisysevent-logging-config.md) + - [HiSysEvent打点配置指导](subsys-dfx-hisysevent-logging-config.md) - [HiSysEvent打点指导](subsys-dfx-hisysevent-logging.md) diff --git a/zh-cn/device-dev/subsystems/subsys-utils-faqs.md b/zh-cn/device-dev/subsystems/subsys-utils-faqs.md index c991e43c15fe5dd550c7d42c9707d738c4b44673..c3f3e2da63e5426589b7ddafcb5d88921af19ade 100755 --- a/zh-cn/device-dev/subsystems/subsys-utils-faqs.md +++ b/zh-cn/device-dev/subsystems/subsys-utils-faqs.md @@ -17,6 +17,6 @@ LiteOS-A内核\(Hi3516、Hi3518平台\)直接调用KV存储提供的接口,各 显示调用KV存储的UtilsSetEnv接口,设置数据存储路径。 ``` -UtilsSetEnv("/storage/com.huawei.kv"); +UtilsSetEnv("/storage/com.example.kv"); ``` diff --git a/zh-cn/device-dev/subsystems/subsys-utils-guide.md b/zh-cn/device-dev/subsystems/subsys-utils-guide.md index 98866eec08eed9f7693172402a20e0ae81e6e557..0986cbb6a11294806309e5143b68013f5369949e 100644 --- a/zh-cn/device-dev/subsystems/subsys-utils-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-utils-guide.md @@ -177,8 +177,8 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); ``` { "app": { - "bundleName": "com.huawei.launcher", - "vendor": "huawei", + "bundleName": "com.example.launcher", + "vendor": "example", "version": { "code": 1, "name": "1.0" @@ -201,7 +201,7 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); } }, "module": { - "package": "com.huawei.launcher", + "package": "com.example.launcher", "name": ".MyHarmonyAbilityPackage", "deviceType": [ "phone", "tv","tablet", "pc","car","smartWatch","sportsWatch","smartCamera" @@ -254,7 +254,7 @@ printf("UtilsDeleteValue delete ret = %d\n", ret); 3. 通过串口向单板发送运行KV存储native应用的命令。 ``` - ./nfs/dev_tools/bin/aa start -p com.huawei.launcher -n ServiceAbility + ./nfs/dev_tools/bin/aa start -p com.example.launcher -n ServiceAbility ``` diff --git a/zh-cn/figures/1.png b/zh-cn/figures/1.png index 6bde46d324c6d9da612d5070a99481ee11aab047..5910b98a0fb9b950b402b93be2cdf35e1b64d638 100644 Binary files a/zh-cn/figures/1.png and b/zh-cn/figures/1.png differ diff --git "a/zh-cn/readme/\345\205\250\347\220\203\345\214\226\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\345\205\250\347\220\203\345\214\226\345\255\220\347\263\273\347\273\237.md" index 19c3e0812df2b200c59dc8b656fb941a7bd20214..539168f4a3c7fe8180617c541aa98e76ea8f097e 100755 --- "a/zh-cn/readme/\345\205\250\347\220\203\345\214\226\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\345\205\250\347\220\203\345\214\226\345\255\220\347\263\273\347\273\237.md" @@ -50,13 +50,6 @@ │ │ │ └── src # 实现代码 │ ├── interfaces # 资源管理框架接口 │ │ └── innerkits # 资源管理框架对子系统间接口 -├── cust_lite # 定制框架代码仓 -│ ├── frameworks # 定制框架核心代码 -│ │ ├── cust_lite # 定制框架模块 -│ │ │ ├── src # 实现代码 -│ │ │ └── test # 测试代码 -│ ├── interfaces # 定制框架接口 -│ │ └── innerkits # 定制框架子系统间接口 ``` 标准系统的目录结构如下所示: @@ -83,8 +76,6 @@ **全球化子系统** -global\_cust\_lite - global\_i18n\_lite global\_i18n\_standard diff --git "a/zh-cn/readme/\347\252\227\345\217\243\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\347\252\227\345\217\243\345\255\220\347\263\273\347\273\237.md" index 77182df54102070b645f388d8e247732f8fb169a..7813ab5c8c166a9fa7523cca05815b2b8bc89d52 100644 --- "a/zh-cn/readme/\347\252\227\345\217\243\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\347\252\227\345\217\243\345\255\220\347\263\273\347\273\237.md" @@ -1,4 +1,4 @@ -# windowmanager +# 窗口子系统 - [简介](#简介) - [目录](#目录) @@ -8,15 +8,14 @@ ## 简介 -**窗口子系统** 提供窗口管理和Display管理的基础能力,是系统图形界面显示所需的基础子系统 - -其主要的结构如下图所示: +**窗口子系统** 提供窗口管理和Display管理的基础能力,是系统图形界面显示所需的基础子系统。其主要的结构如图1所示。 +**图 1** 窗口子系统架构图 ![窗口子系统架构图](./figures/WindowManager.png) - **Window Manager Client** - 应用进程窗口管理接口层,提供窗口对对象抽象和窗口管理接口,对接原能力和UI框架。 + 应用进程窗口管理接口层,提供窗口对象抽象和窗口管理接口,对接元能力和UI框架。 - **Display Manager Client** @@ -24,17 +23,17 @@ - **Window Manager Server** - 窗口管理服务,提供窗口布局、Z序控制、窗口树结构、窗口拖拽、窗口快照等能力,并提供窗口布局和焦点窗口给多模输入 + 窗口管理服务,提供窗口布局、Z序控制、窗口树结构、窗口拖拽、窗口快照等能力,并提供窗口布局和焦点窗口给多模输入。 - **Display Manager Server** - Display管理服务,提供Display信息、屏幕截图、屏幕亮灭和亮度处理控制,并处理Display与Screen映射关系 + Display管理服务,提供Display信息、屏幕截图、屏幕亮灭和亮度处理控制,并处理Display与Screen映射关系。 ## 目录 ``` foundation/windowmanager/ ├── dm # Dislplay Manager Client实现代码 -├── dmserver # Dislplay Manager Service实现代码 +├── dmserver # Dislplay Manager Server实现代码 ├── interfaces # 对外接口存放目录 │   ├── innerkits # native接口存放目录 │   └── kits # js/napi接口存放目录 @@ -43,7 +42,7 @@ foundation/windowmanager/ ├── snapshot # 截屏命令行工具实现代码 ├── utils # 工具类存放目录 ├── wm # Window Manager Client实现代码 -├── wmserver # Window Manager Service实现代码 +├── wmserver # Window Manager Server实现代码 ``` ## 约束 diff --git a/zh-cn/release-notes/Readme.md b/zh-cn/release-notes/Readme.md index aa3297ec73218f6add3f87b8e905cc39c8c60d70..b4f5de9c3a291d9a08d943cff32e30969e5d8343 100644 --- a/zh-cn/release-notes/Readme.md +++ b/zh-cn/release-notes/Readme.md @@ -7,7 +7,7 @@ ## OpenHarmony 2.x Releases - [OpenHarmony v2.2 beta2 (2021-08-04)](OpenHarmony-v2.2-beta2.md) -- [OpenHarmony 2.0 Canary (2021-06-02)](OpenHarmony-2-0-Canary.md) +- [OpenHarmony 2.0 Canary (2021-06-01)](OpenHarmony-2-0-Canary.md) ## OpenHarmony 1.x Releases - [OpenHarmony v1.1.4 LTS (2022-02-11)](OpenHarmony-v1-1-4-LTS.md) - [OpenHarmony v1.1.3 LTS (2021-09-30)](OpenHarmony-v1-1-3-LTS.md)