From 1d458f586f8aa261cf3f34e0719320ae560e349b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Cleehom6666=E2=80=9D?=
Date: Thu, 7 Nov 2024 17:41:00 +0800
Subject: [PATCH] =?UTF-8?q?docs:=20[#IB2SB0]=E4=BF=AE=E6=94=B9react-native?=
=?UTF-8?q?-sensors=E6=8C=87=E5=AF=BC=E6=96=87=E6=A1=A3=E4=B8=BAgitee?=
=?UTF-8?q?=E7=89=88=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: “leehom6666”
---
en/react-native-sensors.md | 59 +++++++++++++++++++++++++++++------
zh-cn/react-native-sensors.md | 58 ++++++++++++++++++++++++++++------
2 files changed, 97 insertions(+), 20 deletions(-)
diff --git a/en/react-native-sensors.md b/en/react-native-sensors.md
index 374ded84..21165aaa 100644
--- a/en/react-native-sensors.md
+++ b/en/react-native-sensors.md
@@ -1,4 +1,4 @@
-> Template version: v0.2.2
+> Template version: v0.3.0
react-native-sensors
@@ -12,11 +12,18 @@
-> [!TIP] [Github address](https://github.com/react-native-oh-library/react-native-sensors)
+> [Gitee Repository](https://gitee.com/openharmony-sig/rntpc_react-native-sensors)
+
+> [Gitee Releases: @react-native-ohos/react-native-sensors ](https://gitee.com/openharmony-sig/rntpc_react-native-sensors/releases)
+
+> [Github Repository(deprecated)](https://github.com/react-native-oh-library/react-native-sensors)
+
+> [Github Releases(<= 7.2.1-rc.2-0.0.1): @react-native-ohos/react-native-sensors](https://github.com/react-native-oh-library/react-native-sensors/releases)
+
## Installation and Usage
-Find the matching version information in the release address of a third-party library and download an applicable .tgz package: [@react-native-oh-tpl/react-native-sensors Releases](https://github.com/react-native-oh-library/react-native-sensors/releases).
+`This third-party library has been migrated to Gitee and is now available for direct download from npm, the new package name is: @react-native-ohos/react-native-sensors`
Go to the project directory and execute the following instruction:
@@ -28,13 +35,13 @@ Go to the project directory and execute the following instruction:
#### **npm**
```bash
-npm install @react-native-oh-tpl/react-native-sensors@file:#
+npm install @react-native-ohos/react-native-sensors@file:#
```
#### **yarn**
```bash
-yarn add @react-native-oh-tpl/react-native-sensors@file:#
+yarn add @react-native-ohos/react-native-sensors@file:#
```
@@ -121,7 +128,7 @@ Open `entry/oh-package.json5` file and add the following dependencies:
```json
"dependencies": {
"@rnoh/react-native-openharmony": "file:../react_native_openharmony",
- "@react-native-oh-tpl/react-native-sensors": "file:../../node_modules/@react-native-oh-tpl/react-native-sensors/harmony/sensors.har"
+ "@react-native-ohos/react-native-sensors": "file:../../node_modules/@react-native-ohos/react-native-sensors/harmony/sensors.har"
}
```
@@ -138,14 +145,44 @@ Method 2: Directly link to the source code.
> [!TIP] For details, see [Directly Linking Source Code](/zh-cn/link-source-code.md).
-### 3. Introducing SensorsPackage Component to ArkTS
+### 3. Configuring CMakeLists and Introducing SensorsPackage Package
+
+Open entry/src/main/cpp/CMakeLists.txt and add the following code:
+
+```diff
++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
+
+# RNOH_BEGIN: manual_package_linking_1
++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-sensors/src/main/cpp" ./sensors)
+# RNOH_END: manual_package_linking_1
+
+# RNOH_BEGIN: manual_package_linking_2
++ target_link_libraries(rnoh_app PUBLIC rnoh_sensors)
+# RNOH_END: manual_package_linking_2
+```
+
+Open entry/src/main/cpp/PackageProvider.cpp and add the following code:
+```diff
+#include "RNOH/PackageProvider.h"
+#include "generated/RNOHGeneratedPackage.h"
++ #include "SensorsPackage.h"
+
+using namespace rnoh;
+
+std::vector> PackageProvider::getPackages(Package::Context ctx) {
+ return {
+ std::make_shared(ctx),
++ std::make_shared(ctx)
+ };
+}
+```
Open the `entry/src/main/ets/RNPackagesFactory.ts` file and add the following code:
```diff
...
-+ import {SensorsPackage} from '@react-native-oh-tpl/react-native-sensors/ts';
++ import {SensorsPackage} from '@react-native-ohos/react-native-sensors/ts';
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
return [
@@ -174,7 +211,7 @@ Then build and run the code.
To use this repository, you need to use the correct React-Native and RNOH versions. In addition, you need to use DevEco Studio and the ROM on your phone.
-Check the release version information in the release address of the third-party library: [@react-native-oh-tpl/react-native-sensors Releases](https://github.com/react-native-oh-library/react-native-sensors/releases)
+Check the release version information in the release address of the third-party library: [@react-native-ohos/react-native-sensors Releases](https://gitee.com/openharmony-sig/rntpc_react-native-sensors/releases)
This document is verified based on the following versions:
@@ -212,4 +249,6 @@ gyroscope Required permissions: ohos.permission.GYROSCOPE
## License
-This project is licensed under [The MIT License (MIT)](https://github.com/react-native-sensors/react-native-sensors/blob/master/LICENSE), Please enjoy and participate freely in open source.
+
+This project is licensed under [The MIT License (MIT)](https://gitee.com/openharmony-sig/rntpc_react-native-sensors/blob/master/LICENSE).
+
diff --git a/zh-cn/react-native-sensors.md b/zh-cn/react-native-sensors.md
index 098fc8a4..01eb9b46 100644
--- a/zh-cn/react-native-sensors.md
+++ b/zh-cn/react-native-sensors.md
@@ -1,4 +1,4 @@
-> 模板版本:v0.2.2
+> 模板版本:v0.3.0
react-native-sensors
@@ -12,11 +12,18 @@
-> [!TIP] [Github 地址](https://github.com/react-native-oh-library/react-native-sensors)
+> [Gitee 仓库](https://gitee.com/openharmony-sig/rntpc_react-native-sensors)
+
+> [Gitee Releases: @react-native-ohos/react-native-sensors ](https://gitee.com/openharmony-sig/rntpc_react-native-sensors/releases)
+
+> [Github 仓库(已废弃)](https://github.com/react-native-oh-library/react-native-sensors)
+
+> [Github Releases(<= 7.2.1-rc.2-0.0.1): @react-native-ohos/react-native-sensors](https://github.com/react-native-oh-library/react-native-sensors/releases)
## 安装与使用
-请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-oh-tpl/react-native-sensors Releases](https://github.com/react-native-oh-library/react-native-sensors/releases),并下载适用版本的 tgz 包。
+`该第三方库已迁移至 Gitee,且支持直接从 npm 下载,新的包名为:@react-native-ohos/react-native-sensors`
+
进入到工程目录并输入以下命令:
@@ -27,13 +34,13 @@
#### **npm**
```bash
-npm install @react-native-oh-tpl/react-native-sensors@file:#
+npm install @react-native-ohos/react-native-sensors@file:#
```
#### **yarn**
```bash
-yarn add @react-native-oh-tpl/react-native-sensors@file:#
+yarn add @react-native-ohos/react-native-sensors@file:#
```
@@ -123,7 +130,7 @@ setUpdateIntervalForType(SensorTypes.accelerometer, 100);
```json
"dependencies": {
"@rnoh/react-native-openharmony": "file:../react_native_openharmony",
- "@react-native-oh-tpl/react-native-sensors": "file:../../node_modules/@react-native-oh-tpl/react-native-sensors/harmony/sensors.har"
+ "@react-native-ohos/react-native-sensors": "file:../../node_modules/@react-native-ohos/react-native-sensors/harmony/sensors.har"
}
```
@@ -140,13 +147,44 @@ ohpm install
> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md)
-### 3.在 ArkTs 侧引入 SensorsPackage
+### 3.配置 CMakeLists 和引入 SensorsPackage
+
+打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
+
+```diff
++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
+
+# RNOH_BEGIN: manual_package_linking_1
++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-sensors/src/main/cpp" ./sensors)
+# RNOH_END: manual_package_linking_1
+
+# RNOH_BEGIN: manual_package_linking_2
++ target_link_libraries(rnoh_app PUBLIC rnoh_sensors)
+# RNOH_END: manual_package_linking_2
+```
+
+打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
+
+```diff
+#include "RNOH/PackageProvider.h"
+#include "generated/RNOHGeneratedPackage.h"
++ #include "SensorsPackage.h"
+
+using namespace rnoh;
+
+std::vector> PackageProvider::getPackages(Package::Context ctx) {
+ return {
+ std::make_shared(ctx),
++ std::make_shared(ctx)
+ };
+}
+```
打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
```diff
...
-+ import {SensorsPackage} from '@react-native-oh-tpl/react-native-sensors/ts';
++ import {SensorsPackage} from '@react-native-ohos/react-native-sensors/ts';
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
return [
@@ -175,7 +213,7 @@ ohpm install
要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
-请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/react-native-sensors Releases](https://github.com/react-native-oh-library/react-native-sensors/releases)
+请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[[@react-native-ohos/react-native-sensors Releases](https://gitee.com/openharmony-sig/rntpc_react-native-sensors/releases)
本文档内容基于以下版本验证通过:
@@ -212,4 +250,4 @@ gyroscope 需要的权限:ohos.permission.GYROSCOPE
## 开源协议
-本项目基于 [The MIT License (MIT)](https://github.com/react-native-sensors/react-native-sensors/blob/master/LICENSE) ,请自由地享受和参与开源。
+本项目基于 [The MIT License (MIT)](https://gitee.com/openharmony-sig/rntpc_react-native-sensors/blob/master/LICENSE) ,请自由地享受和参与开源。
--
Gitee