From 218b10189df6d522b22136aa506fa6ee3b02c858 Mon Sep 17 00:00:00 2001 From: 18673122732 Date: Wed, 12 Nov 2025 14:02:33 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A00.77=2010=E4=B8=AA?= =?UTF-8?q?=E4=B8=89=E6=96=B9=E5=BA=93=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh-cn/react-native-QRCode.md | 26 ++++- ...eact-native-async-storage-async-storage.md | 53 +++++++++- zh-cn/react-native-community-netinfo.md | 50 ++++++++- ...t-native-community-progress-bar-android.md | 41 ++++++- zh-cn/react-native-exit-app.md | 83 ++++++++++++++- zh-cn/react-native-image-picker.md | 53 +++++++++- zh-cn/react-native-mlkit-ocr.md | 42 +++++++- zh-cn/react-native-network-info.md | 97 +++++++++++++++-- zh-cn/react-native-orientation.md | 98 +++++++++++++++-- zh-cn/react-native-randombytes.md | 100 +++++++++++++++++- 10 files changed, 596 insertions(+), 47 deletions(-) diff --git a/zh-cn/react-native-QRCode.md b/zh-cn/react-native-QRCode.md index 818b6da9..db198cb5 100644 --- a/zh-cn/react-native-QRCode.md +++ b/zh-cn/react-native-QRCode.md @@ -17,7 +17,14 @@ ## 安装与使用 -1、请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-qrcode](https://github.com/react-native-oh-library/react-native-qrcode/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ----------- | ------------------------------------------------------------ | ---------- | +| 0.2.7 | [@react-native-oh-tpl/react-native-qrcode Releases](https://github.com/react-native-oh-library/react-native-qrcode/releases) | 0.72 | +| 0.2.8 | @react-native-ohos/react-native-qrcode Releases | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](https://gitee.com/react-native-oh-library/usage-docs/blob/000c9a56a4c5ed4e8bcc5c8a849ee18bba92a374/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -26,13 +33,19 @@ #### **npm** ```bash +# V0.2.7 npm install @react-native-oh-tpl/react-native-qrcode +# V0.2.8 +npm install @react-native-ohos/react-native-qrcode ``` #### **yarn** ```bash -yarn add @react-native-oh-tpl/react-native-qrcode +# V0.2.7 +yarn install @react-native-oh-tpl/react-native-qrcode +# V0.2.8 +yarn install @react-native-ohos/react-native-qrcode ``` @@ -110,12 +123,17 @@ const styles = StyleSheet.create({ 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-qrcode](https://github.com/react-native-oh-library/react-native-qrcode/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 0.2.7 | [@react-native-oh-tpl/react-native-qrcode Releases](https://github.com/react-native-oh-library/react-native-qrcode/releases) | 0.72 | +| 0.2.8 | @react-native-ohos/react-native-qrcode Releases | 0.77 | ## 属性 > [!TIP] "Platform"列表示该属性在原三方库上支持的平台。 - + > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 ### QRCode diff --git a/zh-cn/react-native-async-storage-async-storage.md b/zh-cn/react-native-async-storage-async-storage.md index 8e6ad4ce..c0787249 100644 --- a/zh-cn/react-native-async-storage-async-storage.md +++ b/zh-cn/react-native-async-storage-async-storage.md @@ -24,7 +24,15 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-ohos/async-storage Releases](https://gitcode.com/openharmony-sig/rntpc_async-storage/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-ohos/async-storage Releases](https://gitcode.com/openharmony-sig/rntpc_async-storage/release) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.21.0 | [@react-native-oh-tpl/async-storage Releases](https://github.com/react-native-oh-library/async-storage/releases) | 0.72 | +| 2.2.1 | [@react-native-ohos/async-storage Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -33,12 +41,20 @@ #### **npm** ```bash +# V1.21.0 +npm install @react-native-oh-tpl/async-storage + +# V2.2.1 npm install @react-native-ohos/async-storage ``` #### **yarn** ```bash +# V1.21.0 +yarn add @react-native-oh-tpl/async-storage + +# V2.2.1 yarn add @react-native-ohos/async-storage ``` @@ -116,7 +132,7 @@ export default function App() { ## Link -Version >= @react-native-ohos/async-storage@1.21.1,已支持 Autolink,无需手动配置,目前只支持72框架。 +Version >= @react-native-ohos/async-storage@1.21.1,已支持 Autolink,无需手动配置。 Autolink框架指导文档:https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md Version <= @react-native-oh-tpl/async-storage@1.21.0-0.2.2@deprecated 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 @@ -147,6 +163,18 @@ Version <= @react-native-oh-tpl/async-storage@1.21.0-0.2.2@deprecated 暂不支 打开 `entry/oh-package.json5`,添加以下依赖 +- V1.21.0 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + + "@react-native-ohos/async-storage": "file:../../node_modules/@react-native-ohos/async-storage/harmony/async_storage.har" + } +``` + +- V2.2.1 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -190,7 +218,13 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V1.21.0 ++ add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/async-storage/src/main/cpp" ./async-storage) + +# V2.2.1 + add_subdirectory("${OH_MODULES}/@react-native-ohos/async-storage/src/main/cpp" ./async-storage) + # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -231,6 +265,11 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff ... + +# V1.21.0 ++ import {AsyncStoragePackage} from '@react-native-oh-tpl/async-storage/ts'; + +# V2.2.1 + import {AsyncStoragePackage} from '@react-native-ohos/async-storage/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { @@ -259,7 +298,13 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-ohos/async-storage Releases](https://gitcode.com/openharmony-sig/rntpc_async-storage/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-ohos/async-storage Releases](https://gitcode.com/openharmony-sig/rntpc_async-storage/release) +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.21.0 | [@react-native-oh-tpl/async-storage Releases](https://github.com/react-native-oh-library/async-storage/releases) | 0.72 | +| 2.2.1 | [@react-native-ohos/async-storage Releases]() | 0.77 | ## API @@ -275,7 +320,7 @@ ohpm install | `removeItem` | Removes item for a key, invokes (optional) callback once completed. | function(key: string, [callback]: ?(error: ?Error) => void): Promise | No | All | yes | | `getAllKeys` | Returns all keys known to your App, for all callers, libraries, etc. Once completed, invokes callback with errors (if any) and array of keys. | function([callback]: ?(error: ?Error, keys: ?Array) => void): Promise | No | All | yes | | `multiGet` | Fetches multiple key-value pairs for given array of keys in a batch. Once completed, invokes callback with errors (if any) and results. | function(keys: Array, [callback]: ?(errors: ?Array, result: ?Array>) => void): Promise | No | All | yes | -| `multiSet` | Stores multiple key-value pairs in a batch. Once completed, callback with any errors will be called. | function(keyValuePairs: Array>, [callback]: ?(errors: ?Array) => void): Promise | No | All | yes | +| `multiSet`2.2.1+ | Stores multiple key-value pairs in a batch. Once completed, callback with any errors will be called . >1.21.0:multiSet: (keyValuePairs: [string,string][],callback?:MultiCallback)=>Promise 2.2.1: multiSet: ( keyValuePairs: ReadonlyArray, callback?: MultiCallback ) => Promise; | function(keyValuePairs: Array, [callback]: ?(errors: ?Array) => void): Promise | No | All | yes | | `multiMerge` | Multiple merging of existing and new values in a batch. Assumes that values are stringified JSON. Once completed, invokes callback with errors (if any). | function(keyValuePairs: Array>, [callback]: ?(errors: ?Array) => void): Promise | No | All | yes | | `multiRemove` | Clears multiple key-value entries for given array of keys in a batch. Once completed, invokes a callback with errors (if any). | function(keys: Array, [callback]: ?(errors: ?Array) => void) | No | All | yes | | `clear` | Removes whole AsyncStorage data, for all clients, libraries, etc. You probably want to use removeItem or multiRemove to clear only your App's keys. | function([callback]: ?(error: ?Error) => void): Promise | No | All | yes | diff --git a/zh-cn/react-native-community-netinfo.md b/zh-cn/react-native-community-netinfo.md index 5e2ed279..4b5687fc 100644 --- a/zh-cn/react-native-community-netinfo.md +++ b/zh-cn/react-native-community-netinfo.md @@ -24,6 +24,14 @@ ## 安装与使用 请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-ohos/netinfo Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-netinfo/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 11.1.0 | [@react-native-oh-tpl/netinfo Releases](https://github.com/react-native-oh-library/react-native-netinfo/releases) | 0.72 | +| 11.4.2 | [@react-native-ohos/netinfo Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -32,12 +40,20 @@ #### **npm** ```bash +# V11.1.0 +npm install @react-native-oh-tpl/netinfo + +# V11.4.2 npm install @react-native-ohos/netinfo ``` #### **yarn** ```bash +# V11.1.0 +yarn add @react-native-oh-tpl/netinfo + +# V11.4.2 yarn add @react-native-ohos/netinfo ``` @@ -80,7 +96,7 @@ export default App; ## Link -Version >= @react-native-ohos/netinfo@11.1.1,已支持 Autolink,无需手动配置,目前只支持72框架。 +Version >= @react-native-ohos/netinfo@11.1.1,已支持 Autolink,无需手动配置。 Autolink框架指导文档:https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md Version <= @react-native-oh-tpl/netinfo@11.1.0-0.0.8@deprecated 暂不支持 AutoLink,所以 Link 步骤需要手动配置。 @@ -111,6 +127,17 @@ Version <= @react-native-oh-tpl/netinfo@11.1.0-0.0.8@deprecated 暂不支持 Aut 打开 `entry/oh-package.json5`,添加以下依赖 +- V11.1.0 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/netinfo": "file:../../node_modules/@react-native-ohos/netinfo/harmony/netinfo.har" + } +``` + +- V11.4.2 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -153,7 +180,13 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V11.1.0 ++ add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/netinfo/src/main/cpp" ./netinfo) + +# V11.4.2 + add_subdirectory("${OH_MODULES}/@react-native-ohos/netinfo/src/main/cpp" ./netinfo) + # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -196,6 +229,11 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff ... + +# V11.1.0 ++ import {NetInfoPackage} from '@react-native-oh-tpl/netinfo/ts'; + +# V11.4.2 + import {NetInfoPackage} from '@react-native-ohos/netinfo/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { @@ -226,6 +264,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-ohos/netinfo Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-netinfo/releases) +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 11.1.0 | [@react-native-oh-tpl/netinfo Releases](https://github.com/react-native-oh-library/react-native-netinfo/releases) | 0.72 | +| 11.4.2 | [@react-native-ohos/netinfo Releases]() | 0.77 | ## 属性 @@ -263,8 +307,8 @@ ohpm install | Name | Description | Type | Required | Platform | HarmonyOS Support | |-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|----------|-------------|-------------------| | `type` | The type of the current connection. | NetInfoStateType | yes | iOS Android | yes | -| `isConnected` | If there is an active network connection.
Defaults to null on most platforms for unknown networks.
Note: Web browsers report network type unknown for many otherwise valid networks (https://caniuse.com/netinfo),
so isConnected may be true or false and represent a real connection status even for unknown network types in certain cases. | boolean, null | yes | iOS Android | yes | -| `isInternetReachable` | If the internet is reachable with the currently active network connection.
If unknown defaults to null | boolean, null | yes | iOS Android | yes | +| `isConnected`11.4.2+ | If there is an active network connection.
Defaults to null on most platforms for unknown networks.
Note: Web browsers report network type unknown for many otherwise valid networks (https://caniuse.com/netinfo),
so isConnected may be true or false and represent a real connection status even for unknown network types in certain cases.
> 11.1.0 :连接时:isConnected:true;断开时:isConnected:false
11.4.2 : 不论连接还是断开:isConnected:boolean | boolean, null | yes | iOS Android | yes | +| `isInternetReachable`11.4.2+ | If the internet is reachable with the currently active network connection.
If unknown defaults to null
> 11.1.0 :连接时:isConnected:true;断开时:isInternetReachable:false
11.4.2 : 不论连接还是断开:isInternetReachable:boolean | boolean, null | yes | iOS Android | yes | | `isWifiEnabled` | (Android only) Whether the device's WiFi is ON or OFF. | boolean | yes | iOS Android | yes | | `details` | The value depends on the type value. See below. | object | yes | iOS Android | yes | diff --git a/zh-cn/react-native-community-progress-bar-android.md b/zh-cn/react-native-community-progress-bar-android.md index a1d4543f..ef881861 100644 --- a/zh-cn/react-native-community-progress-bar-android.md +++ b/zh-cn/react-native-community-progress-bar-android.md @@ -16,7 +16,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.0.4 | [@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases) | 0.72 | +| 1.0.6 | @react-native-ohos/progress-bar-android Releases | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -25,13 +32,19 @@ #### **yarn** ```bash +# V1.0.4 yarn add @react-native-oh-tpl/progress-bar-android +# V1.0.6 +yarn add @react-native-ohos/progress-bar-android ``` #### **npm** ```bash +# V1.0.4 npm install @react-native-oh-tpl/progress-bar-android +# V1.0.6 +npm install @react-native-ohos/progress-bar-android ``` @@ -84,11 +97,21 @@ export default function ProgressBarExample() { 打开 `entry/oh-package.json5`,添加以下依赖 +* V1.0.4 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-oh-tpl/progress-bar-android": "file:../../node_modules/@react-native-oh-tpl/progress-bar-android/harmony/progress_bar_android.har" + } +``` + +* V1.0.6 - "@react-native-oh-tpl/progress-bar-android": "file:../../node_modules/@react-native-oh-tpl/progress-bar-android/harmony/progress_bar_android.har" +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/progress-bar-android": "file:../../node_modules/@react-native-ohos/progress-bar-android/harmony/progress_bar_android.har" } ``` @@ -128,7 +151,10 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) +# V1.0.4 + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/progress-bar-android/src/main/cpp" ./progress-bar-android) +# V1.0.6 ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/progress-bar-android/src/main/cpp" ./progress-bar-android) # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -171,8 +197,10 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff ... +# V1.0.4 + import { ProgressBarAndroid, PROGRESS_BAR_TYPE } from "@react-native-oh-tpl/progress-bar-android" - +# V1.0.6 ++ import { ProgressBarAndroid, PROGRESS_BAR_TYPE } from "@react-native-ohos/progress-bar-android" @Builder export function buildCustomRNComponent(ctx: ComponentBuilderContext) { ... @@ -220,7 +248,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 1.0.4 | [@react-native-oh-tpl/progress-bar-android Releases](https://github.com/react-native-oh-library/progress-bar-android/releases) | 0.72 | +| 1.0.6 | @react-native-ohos/progress-bar-android Releases | 0.77 | ## 属性 diff --git a/zh-cn/react-native-exit-app.md b/zh-cn/react-native-exit-app.md index e9627566..0c6f342b 100644 --- a/zh-cn/react-native-exit-app.md +++ b/zh-cn/react-native-exit-app.md @@ -17,7 +17,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-exit-app Releases](https://github.com/react-native-oh-library/react-native-exit-app/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-exit-app Releases](https://github.com/react-native-oh-library/react-native-exit-app/releases) 。 + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 2.0.0 | [@react-native-oh-tpl/react-native-exit-app Releases](https://github.com/react-native-oh-library/react-native-exit-app/releases) | 0.72 | +| 2.0.1 | @react-native-ohos/react-native-exit-app Releases Releases | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -25,13 +32,19 @@ #### **npm** ```bash +# V2.0.0 npm install @react-native-oh-tpl/react-native-exit-app +# V2.0.1 +npm install @react-native-ohos/react-native-exit-app ``` #### **yarn** ```bash +# V2.0.0 yarn add @react-native-oh-tpl/react-native-exit-app +# V2.0.1 +yarn add @react-native-ohos/react-native-exit-app ``` @@ -110,6 +123,8 @@ export default App; 打开 `entry/oh-package.json5`,添加以下依赖 +* V2.0.0 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -117,6 +132,15 @@ export default App; } ``` +* V2.0.1 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-exit-app": "file:../../node_modules/@react-native-ohos/react-native-exit-app/harmony/exit_app.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -130,14 +154,58 @@ ohpm install > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) -### 3.在 ArkTs 侧引入 ExitAppPackage +### 3.配置 CMakeLists 和引入 RNMlkitOcrPackage + +[!TIP] 版本 `2.0.1 ` 及以上需要 + +打开 `entry/src/main/cpp/CMakeLists.txt`,添加: + +```diff +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(CMAKE_SKIP_BUILD_RPATH TRUE) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") ++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") +set(LOG_VERBOSITY_LEVEL 1) +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use +add_compile_definitions(WITH_HITRACE_SYSTRACE) + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) + +# RNOH_BEGIN: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-exit-app/src/main/cpp" ./exit_app) +# RNOH_END: manual_package_linking_1 + +file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") + +add_library(rnoh_app SHARED + ${GENERATED_CPP_FILES} + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) +target_link_libraries(rnoh_app PUBLIC rnoh) + +# RNOH_BEGIN: manual_package_linking_2 +target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) ++ target_link_libraries(rnoh_app PUBLIC rnoh_exit_app) +# RNOH_END: manual_package_linking_2 +``` + +### 4.在 ArkTs 侧引入 ExitAppPackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff ... - + # V2.0.0 + import { ExitAppPackage } from '@react-native-oh-tpl/react-native-exit-app/ts'; + # V2.0.1 ++ import { ExitAppPackage } from '@react-native-ohos/react-native-exit-app/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ @@ -147,7 +215,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -166,7 +234,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-exit-app Releases](https://github.com/react-native-oh-library/react-native-exit-app/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 2.0.0 | [@react-native-oh-tpl/react-native-exit-app Releases](https://github.com/react-native-oh-library/react-native-exit-app/releases) | 0.72 | +| 2.0.1 | @react-native-ohos/react-native-exit-app Releases Releases | 0.77 | ## 静态方法 diff --git a/zh-cn/react-native-image-picker.md b/zh-cn/react-native-image-picker.md index cb295b9c..154d0e4a 100644 --- a/zh-cn/react-native-image-picker.md +++ b/zh-cn/react-native-image-picker.md @@ -16,7 +16,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-image-picker Releases](https://github.com/react-native-oh-library/react-native-image-picker/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 7.0.3 | [@react-native-oh-tpl/react-native-image-picker Releases](https://github.com/react-native-oh-library/react-native-image-picker/releases) | 0.72 | +| 8.2.2 | [@react-native-ohos/react-native-image-picker Releases]() | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -25,13 +32,21 @@ #### **npm** ```bash +# V7.0.3 npm install @react-native-oh-tpl/react-native-image-picker + +# V8.2.2 +npm install @react-native-ohos/react-native-image-picker ``` #### **yarn** ```bash +# V7.0.3 yarn add @react-native-oh-tpl/react-native-image-picker + +# V8.2.2 +yarn add @react-native-ohos/react-native-image-picker ``` @@ -103,6 +118,8 @@ export default App; 打开 `entry/oh-package.json5`,添加以下依赖 +- V7.0.3 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -111,6 +128,16 @@ export default App; } ``` +- V8.2.2 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + + "@react-native-ohos/react-native-image-picker": "file:../../node_modules/@react-native-ohos/react-native-image-picker/harmony/image_picker.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -146,7 +173,13 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) + +# V7.0.3 + add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-image-picker/src/main/cpp" ./image_picker) + +# V8.2.2 ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-image-picker/src/main/cpp" ./image_picker) + # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -189,8 +222,13 @@ std::vector> PackageProvider::getPackages(Package::Cont ```diff ... + +# V7.0.3 + import { ImagePickerViewPackage } from '@react-native-oh-tpl/react-native-image-picker/ts'; +# V8.2.2 ++ import { ImagePickerViewPackage } from '@react-native-ohos/react-native-image-picker/ts'; + export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -218,7 +256,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-image-picker Releases](https://github.com/react-native-oh-library/react-native-image-picker/releases) +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 7.0.3 | [@react-native-oh-tpl/react-native-image-picker Releases](https://github.com/react-native-oh-library/react-native-image-picker/releases) | 0.72 | +| 8.2.2 | [@react-native-ohos/react-native-image-picker Releases]() | 0.77 | ## 属性 @@ -231,11 +274,13 @@ ohpm install | Name | Description | Type | Required | Platform | HarmonyOS Support | | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------- | --------------- | ----------------- | | mediaType | photo or video or mixed(launchCamera on Android does not support 'mixed'). Web only supports 'photo' for now. | string | yes | iOS Android Web | yes | +| restrictMimeTypes8.2.2+ | Array containing the mime-types allowed to be picked. Default is empty (everything). | string | no | Android | yes | | maxWidth | To resize the image. | number | no | iOS Android | no | | maxHeight | To resize the image. | number | no | iOS Android | no | | videoQuality | low, medium, or high on iOS, low or high on Android. | string | no | iOS Android | no | | durationLimit | Video max duration (in seconds). | number | no | iOS Android | no | | quality | 0 to 1, photos. | number | no | iOS Android | no | +| conversionQuality8.2.2+ | For conversion from HEIC/HEIF to JPEG, 0 to 1. Default is `0.92` (everything). | number | no | Android | yes | | cameraType | 'back' or 'front' (May not be supported in few android devices). | string | no | iOS Android | yes | | includeBase64 | If true, creates base64 string of the image (Avoid using on large image files due to performance). | boolean | no | iOS Android Web | yes | | includeExtra | If true, will include extra data which requires library permissions to be requested (i.e. exif data). | boolean | no | iOS Android | no | @@ -277,6 +322,10 @@ ohpm install | ------------------ | -------------------------------------- | -------- | -------- | --------------- | ----------------- | | launchCamera | Launch camera to take photo or video. | function | yes | iOS Android Web | yes | | launchImageLibrary | Launch gallery to pick image or video. | function | yes | iOS Android Web | yes | +| openCamera8.2.2+ | Implement the photo-taking function of the webcam on the web. | function | yes | Web | no | +| stopCamera8.2.2+ | Used to release resources | function | yes | Web | no | + + ## 遗留问题 diff --git a/zh-cn/react-native-mlkit-ocr.md b/zh-cn/react-native-mlkit-ocr.md index 5bdecace..3fef591a 100644 --- a/zh-cn/react-native-mlkit-ocr.md +++ b/zh-cn/react-native-mlkit-ocr.md @@ -16,7 +16,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-mlkit-ocr Releases](https://github.com/react-native-oh-library/react-native-mlkit-ocr/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 0.3.0 | [@react-native-oh-tpl/react-native-mlkit-ocr Releases](https://github.com/react-native-oh-library/react-native-mlkit-ocr/releases) | 0.72 | +| 0.3.1 | @react-native-ohos/react-native-mlkit-ocr Releases | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -25,13 +32,19 @@ #### **npm** ```bash +# V0.3.0 npm install @react-native-oh-tpl/react-native-mlkit-ocr +# V0.3.1 +npm install @react-native-ohos/react-native-mlkit-ocr ``` #### **yarn** ```bash +# V0.3.0 yarn add @react-native-oh-tpl/react-native-mlkit-ocr +# V0.3.1 +yarn add @react-native-ohos/react-native-mlkit-ocr ``` @@ -166,14 +179,24 @@ export const OcrTest = () => { 打开 `entry/oh-package.json5`,添加以下依赖 +* V0.3.0 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", - "@react-native-oh-tpl/react-native-mlkit-ocr": "file:../../node_modules/@react-native-oh-tpl/react-native-mlkit-ocr/harmony/rn_mlkit_ocr.har" } ``` +* V0.3.1 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-mlkit-ocr": "file:../../node_modules/@react-native-ohos/react-native-mlkit-ocr/harmony/rn_mlkit_ocr.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -209,7 +232,10 @@ add_subdirectory("${RNOH_CPP_DIR}" ./rn) # RNOH_BEGIN: manual_package_linking_1 add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) +# V0.3.0 + add_subdirectory("${OH_MODULE_DIR}/@react-native-oh-tpl/react-native-mlkit-ocr/src/main/cpp" ./rn_mlkit_ocr) +# V0.3.1 ++ add_subdirectory("${OH_MODULE_DIR}/@react-native-ohos/react-native-mlkit-ocr/src/main/cpp" ./rn_mlkit_ocr) # RNOH_END: manual_package_linking_1 file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") @@ -249,7 +275,10 @@ std::vector> PackageProvider::getPackages(Package::Cont 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff +# 0.3.0 + import { RNMlkitOcrPackage } from '@react-native-oh-tpl/react-native-mlkit-ocr/ts'; +# 0.3.1 ++ import { RNMlkitOcrPackage } from '@react-native-ohos/react-native-mlkit-ocr/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ @@ -303,9 +332,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-mlkit-ocr Releases](https://github.com/react-native-oh-library/react-native-mlkit-ocr/releases) - +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 0.3.0 | [@react-native-oh-tpl/react-native-mlkit-ocr Releases](https://github.com/react-native-oh-library/react-native-mlkit-ocr/releases) | 0.72 | +| 0.3.1 | @react-native-ohos/react-native-mlkit-ocr Releases | 0.77 | ## API @@ -317,7 +349,7 @@ ohpm install | ---------------- | ------------------------------------------ |--------------------------------- | ------ | -------- | -------- | | detectFromUri(uri)| 传入网络图片地址 | Function |Yes| All | Yes | | detectFromFile(path) | 传入本地图片地址 | Function |Yes| All | Yes | - +> [!TIP] [HTTP错误码-错误码-Network Kit(网络服务)-网络-系统 - 华为HarmonyOS开发者](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/errorcode-net-http#section2300023-向磁盘应用程序写入接收数据失败) 本地图片的内存不能超过5MB ## 遗留问题 diff --git a/zh-cn/react-native-network-info.md b/zh-cn/react-native-network-info.md index 307b4d8e..f2b89165 100644 --- a/zh-cn/react-native-network-info.md +++ b/zh-cn/react-native-network-info.md @@ -18,7 +18,14 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 5.2.1 | [@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases) | 0.72 | +| 5.2.2 | @react-native-ohos/react-native-network-info Releases | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 进入到工程目录并输入以下命令: @@ -27,13 +34,19 @@ #### **npm** ```bash +# V5.2.1 npm install @react-native-oh-tpl/react-native-network-info +# V5.2.2 +npm install @react-native-ohos/react-native-network-info ``` #### **yarn** ```bash -yarn add @react-native-oh-tpl/react-native-network-info +# V5.2.1 +yarn install @react-native-oh-tpl/react-native-network-info +# V5.2.2 +yarn install @react-native-ohos/react-native-network-info ``` @@ -185,6 +198,8 @@ const styles = StyleSheet.create({ 打开 `entry/oh-package.json5`,添加以下依赖 +* V5.2.1 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -192,6 +207,15 @@ const styles = StyleSheet.create({ } ``` +* V5.2.2 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-network-info": "file:../../node_modules/@react-native-ohos/react-native-network-info/harmony/rn_network_info.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -205,15 +229,67 @@ ohpm install > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) -### 3.在 ArkTs 侧引入 RNNetworkInfoPackage +### 3.配置 CMakeLists 和引入 RNOrientationPackage + +> [!TIP] 版本 `5.2.2` 及以上需要 + +打开 `entry/src/main/cpp/CMakeLists.txt`,添加: + +```diff +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") ++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) + +# RNOH_BEGIN: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-network-info/src/main/cpp" ./rn_network_info) +# RNOH_END: manual_package_linking_1 + +add_library(rnoh_app SHARED + ${GENERATED_CPP_FILES} + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) + +target_link_libraries(rnoh_app PUBLIC rnoh) + +# RNOH_BEGIN: manual_package_linking_2 +target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) ++ target_link_libraries(rnoh_app PUBLIC rnoh_network_info) +# RNOH_END: manual_package_linking_2 +``` + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" +#include "SamplePackage.h" ++ #include "NetworkInfoPackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { + std::make_shared(ctx), ++ std::make_shared(ctx), + }; +} +``` + +### 4.在 ArkTs 侧引入 RNNetworkInfoPackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff ... - -+ import { RNNetworkInfoPackage } from '@react-native-oh-tpl/react-native-network-info/ts'; - + # V5.2.1 ++ import { RNNetworkInfoPackage } from '@react-native-oh-tpl/react-native-network-infoo/ts'; + # V5.2.2 ++ import { RNNetworkInfoPackage } from '@react-native-ohos/react-native-network-info/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ new SamplePackage(ctx), @@ -222,7 +298,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -241,7 +317,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 5.2.1 | [@react-native-oh-tpl/react-native-network-info Releases](https://github.com/react-native-oh-library/react-native-network-info/releases) | 0.72 | +| 5.2.2 | @react-native-ohos/react-native-network-info Releases | 0.77 | ### 权限要求 diff --git a/zh-cn/react-native-orientation.md b/zh-cn/react-native-orientation.md index 8862a51a..6a29080b 100644 --- a/zh-cn/react-native-orientation.md +++ b/zh-cn/react-native-orientation.md @@ -16,23 +16,35 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-library/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: -进入到工程目录并输入以下命令: +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.1.3 | [@react-native-oh-tpl/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases) | 0.72 | +| 3.1.4 | @react-native-ohos/react-native-orientation Releases | 0.77 | + +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +进入到工程目录并输入以下命令: #### npm ```bash +# V3.1.3 npm install @react-native-oh-tpl/react-native-orientation +# V3.1.4 +npm install @react-native-ohos/react-native-orientation ``` #### yarn ```bash -yarn add @react-native-oh-tpl/react-native-orientation +# V3.1.3 +yarn install @react-native-oh-tpl/react-native-orientation +# V3.1.4 +yarn install @react-native-ohos/react-native-orientation ``` @@ -183,7 +195,7 @@ const styles = StyleSheet.create({ 首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony` -### 在工程根目录的 `oh-package.json5` 添加 overrides字段 +### 1.在工程根目录的 `oh-package.json5` 添加 overrides字段 ```json { @@ -206,6 +218,8 @@ const styles = StyleSheet.create({ 打开 `entry/oh-package.json5`,添加以下依赖 +* V3.1.3 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -213,6 +227,17 @@ const styles = StyleSheet.create({ } ``` +* V3.1.4 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-orientation": "file:../../node_modules/@react-native-ohos/react-native-orientation/harmony/rn_orientation.har", + } +``` + + + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -233,13 +258,67 @@ cd entry ohpm install --no-link ``` -### 3.在 ArkTs 侧引入 RNOrientationPackage +### 3.配置 CMakeLists 和引入 RNOrientationPackage + +> [!TIP] 版本 `3.1.4` 及以上需要 + +打开 `entry/src/main/cpp/CMakeLists.txt`,添加: + +```diff +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") ++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) + +# RNOH_BEGIN: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-orientation/src/main/cpp" ./rn_orientation) +# RNOH_END: manual_package_linking_1 + +add_library(rnoh_app SHARED + ${GENERATED_CPP_FILES} + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) + +target_link_libraries(rnoh_app PUBLIC rnoh) + +# RNOH_BEGIN: manual_package_linking_2 +target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) ++ target_link_libraries(rnoh_app PUBLIC rnoh_orientation) +# RNOH_END: manual_package_linking_2 +``` + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" +#include "SamplePackage.h" ++ #include "RNOritentionPackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { + std::make_shared(ctx), ++ std::make_shared(ctx), + }; +} +``` + +### 4.在 ArkTs 侧引入 RNOrientationPackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff ... + # V3.1.3 + import { RNOrientationPackage } from '@react-native-oh-tpl/react-native-orientation/ts'; + # V3.1.4 ++ import { RNOrientationPackage } from '@react-native-ohos/react-native-orientation/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ @@ -249,7 +328,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -268,7 +347,12 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-library/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.1.3 | [@react-native-oh-tpl/react-native-orientation Releases](https://github.com/react-native-oh-library/react-native-orientation/releases) | 0.72 | +| 3.1.4 | @react-native-ohos/react-native-orientation Releases | 0.77 | ## API diff --git a/zh-cn/react-native-randombytes.md b/zh-cn/react-native-randombytes.md index 5fa1ecbf..575ba4d7 100644 --- a/zh-cn/react-native-randombytes.md +++ b/zh-cn/react-native-randombytes.md @@ -19,24 +19,35 @@ ## 安装与使用 -请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-library/react-native-randombytes Releases](https://github.com/react-native-oh-library/react-native-randombytes/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +请到三方库的 Releases 发布地址查看配套的版本信息: -进入到工程目录并输入以下命令: +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.6.1 | [@react-native-oh-library/react-native-randombytes Releases](https://github.com/react-native-oh-library/react-native-randombytes/releases) | 0.72 | +| 3.6.3 | @react-native-ohos/react-native-randombytes Releases | 0.77 | +对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。 +进入到工程目录并输入以下命令: #### npm ```bash +V3.6.1 npm install @react-native-oh-tpl/react-native-randombytes +V3.6.3 +npm install @react-native-ohos/react-native-randombytes ``` #### yarn ```bash +V3.6.1 yarn add @react-native-oh-tpl/react-native-randombytes +V3.6.3 +yarn add @react-native-ohos/react-native-randombytes ``` @@ -135,6 +146,8 @@ const styles = StyleSheet.create({ 打开 `entry/oh-package.json5`,添加以下依赖 +* V3.6.1 + ```json "dependencies": { "@rnoh/react-native-openharmony": "file:../react_native_openharmony", @@ -142,6 +155,15 @@ const styles = StyleSheet.create({ } ``` +* V3.6.3 + +```json +"dependencies": { + "@rnoh/react-native-openharmony": "file:../react_native_openharmony", + "@react-native-ohos/react-native-randombytes": "file:../../node_modules/@react-native-ohos/react-native-randombytes/harmony/random_bytes.har" + } +``` + 点击右上角的 `sync` 按钮 或者在终端执行: @@ -155,13 +177,75 @@ ohpm install > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md) -### 3.在 ArkTs 侧引入 RandomBytesPackage +### 3.配置 CMakeLists 和引入 RNMlkitOcrPackage + +> [!TIP] 版本 `3.6.3` 及以上需要 + +打开 `entry/src/main/cpp/CMakeLists.txt`,添加: + +```diff +project(rnapp) +cmake_minimum_required(VERSION 3.4.1) +set(CMAKE_SKIP_BUILD_RPATH TRUE) +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}") +set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules") ++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules") +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp") +set(LOG_VERBOSITY_LEVEL 1) +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments") +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie") +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use +add_compile_definitions(WITH_HITRACE_SYSTRACE) + +add_subdirectory("${RNOH_CPP_DIR}" ./rn) + +# RNOH_BEGIN: manual_package_linking_1 +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package) ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-randombytes/src/main/cpp" ./random_bytes) +# RNOH_END: manual_package_linking_1 + +file(GLOB GENERATED_CPP_FILES "./generated/*.cpp") + +add_library(rnoh_app SHARED + ${GENERATED_CPP_FILES} + "./PackageProvider.cpp" + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp" +) +target_link_libraries(rnoh_app PUBLIC rnoh) + +# RNOH_BEGIN: manual_package_linking_2 +target_link_libraries(rnoh_app PUBLIC rnoh_sample_package) ++ target_link_libraries(rnoh_app PUBLIC rnoh_random_bytes) +# RNOH_END: manual_package_linking_2 +``` + +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加: + +```diff +#include "RNOH/PackageProvider.h" +#include "SamplePackage.h" ++ #include "RandomBytesNativePackage.h" + +using namespace rnoh; + +std::vector> PackageProvider::getPackages(Package::Context ctx) { + return { + std::make_shared(ctx), ++ std::make_shared(ctx) + }; +} +``` + +### 4.在 ArkTs 侧引入 RandomBytesPackage 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加: ```diff ... + # V3.6.1 + import { RandomBytesPackage } from '@react-native-oh-tpl/react-native-randombytes/ts'; + # V3.6.3 ++ import { RandomBytesPackage } from '@react-native-ohos/react-native-randombytes/ts'; export function createRNPackages(ctx: RNPackageContext): RNPackage[] { return [ @@ -171,7 +255,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] { } ``` -### 4.运行 +### 5.运行 点击右上角的 `sync` 按钮 @@ -190,9 +274,15 @@ ohpm install 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。 -请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-library/react-native-randombytes Releases](https://github.com/react-native-oh-library/react-native-randombytes/releases) +请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息: + +| 三方库版本 | 发布信息 | 支持RN版本 | +| ---------- | ------------------------------------------------------------ | ---------- | +| 3.6.1 | [@react-native-oh-library/react-native-randombytes Releases](https://github.com/react-native-oh-library/react-native-randombytes/releases) | 0.72 | +| 3.6.3 | @react-native-ohos/react-native-randombytes Releases | 0.77 | 本文档内容基于以下版本验证通过: + 1. RNOH: 0.72.20-CAPI; SDK: HarmonyOS NEXT Developer Beta1; IDE: DevEco Studio 5.0.3.200; ROM: 3.0.0.18; ## API -- Gitee