diff --git a/zh-cn/react-native-exception-handler.md b/zh-cn/react-native-exception-handler.md
index 33ee988d7a154ddd9439408d29857efbf57cc738..a613b71cdf07c932cfb03a542a667054f5e0c80e 100644
--- a/zh-cn/react-native-exception-handler.md
+++ b/zh-cn/react-native-exception-handler.md
@@ -1,5 +1,5 @@
-> 模板版本:v0.1.3
+> 模板版本:v0.2.2
react-native-exception-handler
@@ -120,17 +120,17 @@ setNativeExceptionHandler(
1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
2. 直接链接源码。
-方法一:通过 har 包引入
+方法一:通过 har 包引入(推荐)
> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
打开 `entry/oh-package.json5`,添加以下依赖
-```diff
+```json
"dependencies": {
"@rnoh/react-native-openharmony": "file:../react_native_openharmony",
-+ "rnoh-exception-handler": "file:../../node_modules/@react-native-oh-tpl/react-native-exception-handler/harmony/exception_handler.har",
+ "@react-native-oh-tpl/react-native-exception-handler": "file:../../node_modules/@react-native-oh-tpl/react-native-exception-handler/harmony/exception_handler.har",
}
```
@@ -154,28 +154,37 @@ ohpm install
```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(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
+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: add_package_subdirectories
+# RNOH_BEGIN: manual_package_linking_1
add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
-+ add_subdirectory("${OH_MODULE_DIR}/rnoh-exception-handler/src/main/cpp" ./exception_handler)
-# RNOH_END: add_package_subdirectories
++ add_subdirectory("${OH_MODULES}/@react-native-oh-tpl/react-native-exception-handler/src/main/cpp" ./exception-handler)
+# 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: link_packages
+# RNOH_BEGIN: manual_package_linking_2
target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
+ target_link_libraries(rnoh_app PUBLIC rnoh_exception_handler)
-# RNOH_END: link_packages
+# RNOH_END: manual_package_linking_2
```
打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
@@ -200,9 +209,8 @@ std::vector> PackageProvider::getPackages(Package::Cont
打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
```diff
-import type {RNPackageContext, RNPackage} from 'rnoh/ts';
-import {SamplePackage} from 'rnoh-sample-package/ts';
-+ import {ExceptionHandlerPackage} from 'rnoh-exception-handler/ts';
+...
++ import {ExceptionHandlerPackage} from '@react-native-oh-tpl/react-native-exception-handler/ts';
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
return [
@@ -217,7 +225,7 @@ export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
在 `YourProject/entry/src/main/ets/pages` 目录下,新建文件`ExceptionView.ets`
```typescript
-import { ExceptionComponent } from 'rnoh-exception-handler';
+import { ExceptionComponent } from '@react-native-oh-tpl/react-native-exception-handler';
import router from '@ohos.router';
interface RouterParam {
@@ -346,8 +354,8 @@ ohpm install
| Name | Description | Type | Required | Platform | HarmonyOS Support |
| ----------------------- | -------------------- | -------- | -------- | -------- | ----------------- |
-| `setJSExceptionHandler` | 设置 JS 异常处理方法 | function | no | All | yes |
-| `getJSExceptionHandler` | 获取 JS 异常处理方法 | function | no | All | yes |
+| `setJSExceptionHandler` | 设置 JS 异常处理方法 | function | no | Android, iOS | yes |
+| `getJSExceptionHandler` | 获取 JS 异常处理方法 | function | no | Android, iOS | yes |
## API
@@ -357,7 +365,7 @@ ohpm install
| Name | Description | Type | Required | Platform | HarmonyOS Support |
| --------------------------- | ------------------------ | -------- | -------- | -------- | ----------------- |
-| `setNativeExceptionHandler` | 设置 native 异常处理方法 | function | no | All | yes |
+| `setNativeExceptionHandler` | 设置 native 异常处理方法 | function | no | Android, iOS | yes |
## 遗留问题