已合并
docs(Docs): fix typos in usage FAQs and common scenarios #3658
fangzhen创建于 16 天前
docs(Docs): fix typos in usage FAQs and common scenarios #3658
已合并
共 4 个文件变更+820-759
| @@ -468,25 +468,25 @@ To convert the bundle to .hbc format, perform the following steps: | |||
| 468 | 468 | ||
| 469 | 4. The following describes a demo script file for compiling `Hermes`. | 469 | 4. The following describes a demo script file for compiling `Hermes`. |
| 470 | 470 | ||
| 471 | - ```vim | 471 | + ```bash |
| 472 | - // Use Hermes to convert the bundle to .hbc format. | 472 | + # Use Hermes to convert the bundle to .hbc format. |
| 473 | echo "*************************** start hermesc *********************************" | 473 | echo "*************************** start hermesc *********************************" |
| 474 | 474 | ||
| 475 | - // Prompt the user to enter the directory of the JavaScript bundle, and save the entered directory in the dir variable. | 475 | + # Prompt the user to enter the directory of the JavaScript bundle, and save the entered directory in the dir variable. |
| 476 | read -p "Enter the JS bundle directory: "dir | 476 | read -p "Enter the JS bundle directory: "dir |
| 477 | 477 | ||
| 478 | - // Define a read-only variable bundle_hbc to store the directory of the translated Hermes bytecode file. It is used to create a folder named bundle_hbc in the parent directory of the input dir. | 478 | + # Define a read-only variable bundle_hbc to store the directory of the translated Hermes bytecode file. It is used to create a folder named bundle_hbc in the parent directory of the input dir. |
| 479 | readonly bundle_hbc=$dir/../bundle_hbc | 479 | readonly bundle_hbc=$dir/../bundle_hbc |
| 480 | 480 | ||
| 481 | - // Recursively delete the directory that stores the Hermes bytecode to ensure that a new bytecode file is generated from the beginning each time the script is executed. | 481 | + # Recursively delete the directory that stores the Hermes bytecode to ensure that a new bytecode file is generated from the beginning each time the script is executed. |
| 482 | rm -rf $bundle_hbc | 482 | rm -rf $bundle_hbc |
| 483 | - // Create a directory for storing the Hermes bytecode file. | 483 | + # Create a directory for storing the Hermes bytecode file. |
| 484 | mkdir -p $bundle_hbc | 484 | mkdir -p $bundle_hbc |
| 485 | - // Create a file to store different types of bundles. | 485 | + # Create a file to store different types of bundles. |
| 486 | mkdir -p $bundle_hbc/basic | 486 | mkdir -p $bundle_hbc/basic |
| 487 | mkdir -p $bundle_hbc/cp | 487 | mkdir -p $bundle_hbc/cp |
| 488 | 488 | ||
| 489 | - // Run the hermesc command to convert the specified JavaScript bundle file into a Hermes bytecode file (.hbc format). | 489 | + # Run the hermesc command to convert the specified JavaScript bundle file into a Hermes bytecode file (.hbc format). |
| 490 | hermesc --emit-binary $dir/basic/basic.harmony.bundle -out $bundle_hbc/basic/basic.harmony.hbc | 490 | hermesc --emit-binary $dir/basic/basic.harmony.bundle -out $bundle_hbc/basic/basic.harmony.hbc |
| 491 | hermesc --emit-binary $dir/cp/goods.harmony.bundle -out $bundle_hbc/cp/goods.harmony.hbc | 491 | hermesc --emit-binary $dir/cp/goods.harmony.bundle -out $bundle_hbc/cp/goods.harmony.hbc |
| 492 | hermesc --emit-binary $dir/cp/homepage.harmony.bundle -out $bundle_hbc/cp/homepage.harmony.hbc | 492 | hermesc --emit-binary $dir/cp/homepage.harmony.bundle -out $bundle_hbc/cp/homepage.harmony.hbc |
| @@ -443,7 +443,7 @@ | |||
| 443 | 443 | ||
| 444 | - 原因 | 444 | - 原因 |
| 445 | 445 | ||
| 446 | - 主要是c++编译较慢 | 446 | + 主要是c++编译较慢。 |
| 447 | 447 | ||
| 448 | - 解决 | 448 | - 解决 |
| 449 | 449 | ||
| @@ -451,7 +451,7 @@ | |||
| 451 | 451 | ||
| 452 | - [release包使用](../01-环境与工具/环境搭建.md#release包使用) | 452 | - [release包使用](../01-环境与工具/环境搭建.md#release包使用) |
| 453 | 453 | ||
| 454 | -1. ⽤DevEco打开鸿蒙⼯程,右键->New->Module->Static Library,填写模块名。 | 454 | +1. ⽤DevEco打开鸿蒙⼯程,右键->New->Module->Static Library,填写模块名。 |
| 455 | 2. 解压华为公司提供的react_native_openharmony-x.x.x.xxx.har。 | 455 | 2. 解压华为公司提供的react_native_openharmony-x.x.x.xxx.har。 |
| 456 | 3. 将解压后的src/main/cpp⽂件夹、ets.ets⽂件、ts.ts⽂件复制粘贴到新模块。 | 456 | 3. 将解压后的src/main/cpp⽂件夹、ets.ets⽂件、ts.ts⽂件复制粘贴到新模块。 |
| 457 | 4. ⽤解压后的src/main/ets⽂件夹替换掉新模块的src/main/ets⽂件夹。 | 457 | 4. ⽤解压后的src/main/ets⽂件夹替换掉新模块的src/main/ets⽂件夹。 |
| @@ -565,17 +565,17 @@ | |||
| 565 | 565 | ||
| 566 | - 现象 | 566 | - 现象 |
| 567 | 567 | ||
| 568 | - 使用Linking.canOpenURL()拉起其他应用时一直返回false | 568 | + 使用Linking.canOpenURL()拉起其他应用时一直返回false。 |
| 569 | 569 | ||
| 570 | - 原因 | 570 | - 原因 |
| 571 | 571 | ||
| 572 | - 指定应用的scheme需要在module.json5文件中配置,否则查询不到 | 572 | + 指定应用的scheme需要在module.json5文件中配置,否则查询不到。 |
| 573 | 573 | ||
| 574 | - 解决 | 574 | - 解决 |
| 575 | 575 | ||
| 576 | - 在`module.json5`文件内的[querySchemes](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V13/canopenlink-V13#%E6%93%8D%E4%BD%9C%E6%AD%A5%E9%AA%A4)字段配上想要拉起的应用的scheme | 576 | + 在`module.json5`文件内的[querySchemes](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V13/canopenlink-V13#%E6%93%8D%E4%BD%9C%E6%AD%A5%E9%AA%A4)字段配上想要拉起的应用的scheme。 |
| 577 | 577 | ||
| 578 | - 例如:想要拉起浏览器访问网页,则需要配http或https | 578 | + 例如:想要拉起浏览器访问网页,则需要配http或https: |
| 579 | 579 | ||
| 580 | ```json5 | 580 | ```json5 |
| 581 | "querySchemes": ["http", "https"], | 581 | "querySchemes": ["http", "https"], |
| @@ -593,7 +593,7 @@ | |||
| 593 | 593 | ||
| 594 | - 方案 | 594 | - 方案 |
| 595 | 595 | ||
| 596 | - 当遇到类似问题时,可以在原生滚动组件上设置 `onScroll` 事件。在该事件的处理逻辑中,调被封装的 React Native 组件 `rnInstance` 或者 `rnohCoreContext` 的 `cancelTouches` 方法,以阻止滑动过程中 React Native 内部触摸的触发。 | 596 | + 当遇到类似问题时,可以在原生滚动组件上设置 `onScroll` 事件。在该事件的处理逻辑中,调用被封装的 React Native 组件 `rnInstance` 或者 `rnohCoreContext` 的 `cancelTouches` 方法,以阻止滑动过程中 React Native 内部触摸的触发。 |
| 597 | 597 | ||
| 598 | - 示例代码 | 598 | - 示例代码 |
| 599 | 599 | ||
| @@ -610,7 +610,7 @@ | |||
| 610 | 610 | ||
| 611 | - 现象 | 611 | - 现象 |
| 612 | 612 | ||
| 613 | - 开启语音播报功能后开白位置也能被选中。 | 613 | + 开启语音播报功能后空白位置也能被选中。 |
| 614 | 614 | ||
| 615 | - 原因 | 615 | - 原因 |
| 616 | 616 | ||
| @@ -628,9 +628,9 @@ | |||
| 628 | 628 | ||
| 629 | 在 HarmonyOS 平台上使用 React Native 的 `StatusBar` 相关接口时,部分场景下可能出现状态栏样式与当前页面预期不一致的情况,例如: | 629 | 在 HarmonyOS 平台上使用 React Native 的 `StatusBar` 相关接口时,部分场景下可能出现状态栏样式与当前页面预期不一致的情况,例如: |
| 630 | 630 | ||
| 631 | - - 页面切换后,状态栏样式未如预期发生变化 | 631 | + - 页面切换后,状态栏样式未如预期发生变化。 |
| 632 | - - 返回某个页面时,状态栏样式未恢复为该页面期望的状态 | 632 | + - 返回某个页面时,状态栏样式未恢复为该页面期望的状态。 |
| 633 | - - RN 页面与原生页面切换后,状态栏表现不符合页面自身配置 | 633 | + - RN 页面与原生页面切换后,状态栏表现不符合页面自身配置。 |
| 634 | 634 | ||
| 635 | 上述现象通常表现为:**状态栏未严格随页面切换而变化**。 | 635 | 上述现象通常表现为:**状态栏未严格随页面切换而变化**。 |
| 636 | 636 | ||
| @@ -643,9 +643,9 @@ | |||
| 643 | **平台能力模型差异:** | 643 | **平台能力模型差异:** |
| 644 | 644 | ||
| 645 | - 在 Android / iOS 平台中,状态栏能力与页面级容器(**Activity** / **ViewController**)生命周期强绑定 | 645 | - 在 Android / iOS 平台中,状态栏能力与页面级容器(**Activity** / **ViewController**)生命周期强绑定 |
| 646 | - 页面创建与销毁天然对应状态栏样式的生效与回退 | 646 | + 页面创建与销毁天然对应状态栏样式的生效与回退。 |
| 647 | - 在 HarmonyOS 中,StatusBar 属于**系统级 UI 能力** | 647 | - 在 HarmonyOS 中,StatusBar 属于**系统级 UI 能力** |
| 648 | - 状态栏配置由系统统一管理,不与单个页面生命周期绑定 | 648 | + 状态栏配置由系统统一管理,不与单个页面生命周期绑定。 |
| 649 | 649 | ||
| 650 | 在此基础上,以下两类场景更容易暴露差异: | 650 | 在此基础上,以下两类场景更容易暴露差异: |
| 651 | 651 | ||
| @@ -665,8 +665,8 @@ | |||
| 665 | 665 | ||
| 666 | **场景说明:** | 666 | **场景说明:** |
| 667 | 667 | ||
| 668 | - - 页面 A:业务页面,需要沉浸式效果,主动设置了 `StatusBar` | 668 | + - 页面 A:业务页面,需要沉浸式效果,主动设置了 `StatusBar`。 |
| 669 | - - 页面 B:普通页面,未显式设置 `StatusBar`,期望使用系统默认状态栏样式 | 669 | + - 页面 B:普通页面,未显式设置 `StatusBar`,期望使用系统默认状态栏样式。 |
| 670 | 670 | ||
| 671 | **示例流程:** | 671 | **示例流程:** |
| 672 | 672 | ||
| @@ -681,8 +681,8 @@ | |||
| 681 | 681 | ||
| 682 | 需要注意的是: | 682 | 需要注意的是: |
| 683 | 683 | ||
| 684 | - - 该“默认状态”并非系统原生默认状态 | 684 | + - 该“默认状态”并非系统原生默认状态。 |
| 685 | - - 而是 RN 定义的一组默认配置(如 `barStyle: "default"`、`hidden: false` 等) | 685 | + - 而是 RN 定义的一组默认配置(如 `barStyle: "default"`、`hidden: false` 等)。 |
| 686 | 686 | ||
| 687 | **HarmonyOS 上的实际结果** | 687 | **HarmonyOS 上的实际结果** |
| 688 | 688 | ||
| @@ -693,9 +693,9 @@ | |||
| 693 | 693 | ||
| 694 | 最终导致: | 694 | 最终导致: |
| 695 | 695 | ||
| 696 | - - 页面 B 本身并未显式设置任何 `StatusBar` 相关逻辑 | 696 | + - 页面 B 本身并未显式设置任何 `StatusBar` 相关逻辑。 |
| 697 | - - 但系统状态栏已在页面 A 卸载时被应用了 RN 的默认回退配置 | 697 | + - 但系统状态栏已在页面 A 卸载时被应用了 RN 的默认回退配置。 |
| 698 | - - 页面 B 实际展示的状态栏样式与其页面设计预期不一致 | 698 | + - 页面 B 实际展示的状态栏样式与其页面设计预期不一致。 |
| 699 | 699 | ||
| 700 | --- | 700 | --- |
| 701 | 701 | ||
| @@ -710,13 +710,13 @@ | |||
| 710 | 710 | ||
| 711 | - 使用建议 | 711 | - 使用建议 |
| 712 | 712 | ||
| 713 | - - HarmonyOS 场景下,**优先使用系统默认状态栏策略** | 713 | + - HarmonyOS 场景下,**优先使用系统默认状态栏策略**。 |
| 714 | - - 避免在多个页面中频繁或动态控制 `StatusBar` | 714 | + - 避免在多个页面中频繁或动态控制 `StatusBar`。 |
| 715 | - 若业务确有特殊需求(如沉浸式页面),建议: | 715 | - 若业务确有特殊需求(如沉浸式页面),建议: |
| 716 | 716 | ||
| 717 | - - 将 `StatusBar` 的使用范围限制在封闭页面内 | 717 | + - 将 `StatusBar` 的使用范围限制在封闭页面内。 |
| 718 | - - 明确页面进入与退出时的状态栏预期 | 718 | + - 明确页面进入与退出时的状态栏预期。 |
| 719 | - - 不依赖页面卸载自动恢复状态栏样式 | 719 | + - 不依赖页面卸载自动恢复状态栏样式。 |
| 720 | 720 | ||
| 721 | --- | 721 | --- |
| 722 | 722 | ||
| @@ -727,8 +727,8 @@ | |||
| 727 | - **平台适配封装(推荐)** | 727 | - **平台适配封装(推荐)** |
| 728 | 在封装组件内部根据平台判断: | 728 | 在封装组件内部根据平台判断: |
| 729 | 729 | ||
| 730 | - - Android / iOS:正常使用 RN `StatusBar` | 730 | + - Android / iOS:正常使用 RN `StatusBar`。 |
| 731 | - - HarmonyOS:不渲染或直接返回空组件 | 731 | + - HarmonyOS:不渲染或直接返回空组件。 |
| 732 | 732 | ||
| 733 | 该方式可避免 HarmonyOS 上的全局状态污染,同时保持业务代码一致性。 | 733 | 该方式可避免 HarmonyOS 上的全局状态污染,同时保持业务代码一致性。 |
| 734 | 734 | ||
| @@ -742,9 +742,9 @@ | |||
| 742 | 742 | ||
| 743 | RNOH框架使用HarmonyOS Network Kit的 `HttpRequestOptions.remoteValidation` 字段来控制HTTPS证书校验行为。该字段支持三种模式: | 743 | RNOH框架使用HarmonyOS Network Kit的 `HttpRequestOptions.remoteValidation` 字段来控制HTTPS证书校验行为。该字段支持三种模式: |
| 744 | 744 | ||
| 745 | - - `'system'`:使用系统默认CA校验 | 745 | + - `'system'`:使用系统默认CA校验。 |
| 746 | - - `'skip'`:跳过证书校验(仅用于开发测试) | 746 | + - `'skip'`:跳过证书校验(仅用于开发测试)。 |
| 747 | - - `ValidationCallback`:自定义校验回调(API >= 26) | 747 | + - `ValidationCallback`:自定义校验回调(API >= 26)。 |
| 748 | 748 | ||
| 749 | - 解决 | 749 | - 解决 |
| 750 | 750 | ||
| @@ -784,7 +784,7 @@ | |||
| 784 | }; | 784 | }; |
| 785 | 785 | ||
| 786 | setupRNOHWorker({ | 786 | setupRNOHWorker({ |
| 787 | - createWorkerRNInstanceConfig: _rnInstanceName => { | 787 | + createWorkerRNInstanceConfig: (_rnInstanceName) => { |
| 788 | return { | 788 | return { |
| 789 | thirdPartyPackagesFactory: getRNOHPackages, | 789 | thirdPartyPackagesFactory: getRNOHPackages, |
| 790 | remoteValidation: createRemoteValidation(), | 790 | remoteValidation: createRemoteValidation(), |
| @@ -824,7 +824,7 @@ | |||
| 824 | pingInterval: 0, | 824 | pingInterval: 0, |
| 825 | }, | 825 | }, |
| 826 | }, | 826 | }, |
| 827 | - }) | 827 | + }); |
| 828 | ``` | 828 | ``` |
| 829 | 829 | ||
| 830 | **2. 单连接配置**:JS 侧写在 `new WebSocket` 第三参的 `headers` 内,优先于全局配置。 | 830 | **2. 单连接配置**:JS 侧写在 `new WebSocket` 第三参的 `headers` 内,优先于全局配置。 |
| @@ -850,7 +850,7 @@ | |||
| 850 | ``` | 850 | ``` |
| 851 | Reason:Signal:SIGABRT(SI_TKILL)@0x01317be100004a4f from:19023:20020193 | 851 | Reason:Signal:SIGABRT(SI_TKILL)@0x01317be100004a4f from:19023:20020193 |
| 852 | LastFatalMessage:RNOHAppNapiBridge.cpp:330> RNInstance with the following id 0 has been already created | 852 | LastFatalMessage:RNOHAppNapiBridge.cpp:330> RNInstance with the following id 0 has been already created |
| 853 | - | 853 | + |
| 854 | Fault thread info: | 854 | Fault thread info: |
| 855 | Tid:19023, Name:ample.harmony01 | 855 | Tid:19023, Name:ample.harmony01 |
| 856 | #00 pc 00000000001b86d0 /system/lib/ld-musl-aarch64.so.1(raise+216) | 856 | #00 pc 00000000001b86d0 /system/lib/ld-musl-aarch64.so.1(raise+216) |