已合并
docs: update README document for 0.82 branch of react-native-restart library #29
docs: update README document for 0.82 branch of react-native-restart library #29
已合并
fanwangah创建于 8月4日
2 个文件变更+114-56
MREADME.md+56-27
@@ -1,14 +1,16 @@
1-> 文档模板:v0.4.11+> 文档模板:v0.4.2
2 2 
3-# <center>react-native-restart</center>3+<p align="center">
4+ <h1 align="center"> <code>react-native-restart</code> </h1>
5+</p>
4 6 
5本项目基于 [react-native-restart](https://github.com/avishayil/react-native-restart) 开发。7本项目基于 [react-native-restart](https://github.com/avishayil/react-native-restart) 开发。
6 8 
7该第三方库的仓库已迁移至 Gitcode,且支持直接从 npm 下载,新的包名为:`@react-native-ohos/react-native-restart` 版本所属关系如下:9该第三方库的仓库已迁移至 Gitcode,且支持直接从 npm 下载,新的包名为:`@react-native-ohos/react-native-restart` 版本所属关系如下:
8 10 
9-| 三方库名称 | 三方库版本 | 发布信息 | 支持RN版本 | Autolink | 编译API版本 | 社区基线版本 | npm地址 |11+| 三方库名称 | 三方库版本(npm地址) | 发布信息 | 支持RN版本 | AutoLink | 编译API版本 | 社区基线版本 | 源码地址 |
10-| ------------ | ------------ | ------------------------------ | ------------- | ------------- |------------------------ | ------------- | ------------- |12+| - | - | - | - | - | - | - | - |
11-| @react-native-ohos/react-native-restart | ~ 0.2.0(开发中) | [Gitcode Releases](https://gitcode.com/CPF-RN/rntpc_react-native-restart/releases) | 0.82.* | 是 | API12+ | 0.0.27 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-restart) | 13+| @react-native-ohos/react-native-restart | [~ 0.2.0(开发中)](https://www.npmjs.com/package/@react-native-ohos/react-native-restart) | [Gitcode Releases](https://gitcode.com/CPF-RN/rntpc_react-native-restart/releases) | 0.82.* | 是 | API12+ | 0.0.27 | [br_rnoh0.82](https://gitcode.com/CPF-RN/rntpc_react-native-restart/tree/br_rnoh0.82) |
12 14 
13## 简介15## 简介
14 16 
@@ -195,27 +197,55 @@ ohpm install
195 197 
196> [!WARNING] 使用时 import 的库名不变。198> [!WARNING] 使用时 import 的库名不变。
197 199 
198-```js200+```tsx
199-import React from 'react';201+import { useState } from "react";
200-import {Text, View, StyleSheet} from 'react-native';202+import { StyleSheet, Text } from "react-native";
201-import RNRestart from 'react-native-restart';203+import RNRestart from "react-native-restart";
204+import { Tester, TestSuite, TestCase } from "@rnoh/testerino";
cpf-manager
cpf-managercpf-manager9 天前

【AI-Review】【一般】【基础代码问题】【验证问题】使用示例引入了未声明的 @rnoh/testerino 依赖

● 问题:README.md 第 204 行的使用示例导入了 @rnoh/testerinoimport { Tester, TestSuite, TestCase } from "@rnoh/testerino";),但"下载安装"章节(第 19-33 行)仅说明安装 @react-native-ohos/react-native-restart,未提及 @rnoh/testerino。同时仓库 package.jsondependencies/peerDependencies/devDependencies 中均不包含 @rnoh/testerino,该包并非 @react-native-ohos/react-native-restart 的依赖项。对比官方模板 usage-docs/zh-cn/model-0.4.2.md 第 292-310 行的示例,模板仅导入 reactreact-native 和三方库本身,不引入 @rnoh/testerino

● 影响:用户按照"下载安装"章节执行 npm install @react-native-ohos/react-native-restart 后,直接复制"使用示例"中的代码会导致编译/运行失败(报错 Cannot find module '@rnoh/testerino'),违反 usage-docs/zh-cn/usage-docs-checklist.md 第 20 项"文档里面的 demo 是否没有代码错误,直接可跑通"的要求。

● 建议:二选一:

  1. 在"使用示例"中改用与官方模板 model-0.4.2.md 一致的简单写法(仅使用 react-nativeView/Text 等基础组件和 RNRestart),去掉 @rnoh/testerinoTester/TestSuite/TestCase 包装;
  2. 若需保留 testerino 测试示例,则在"下载安装"章节补充 npm install @rnoh/testerino(或说明该包来自 RNOH 测试工程)。
likedislike
202 205 
203export default function RestartDemo() {206export default function RestartDemo() {
207+ const [restartReason, setRestartReason] = useState("");
208+ 
204 return (209 return (
205- <View>210+ <Tester>
206- <Text>重启restart</Text>211+ <TestSuite name="restart">
207- <Text style={styles.button} onPress={() => RNRestart.restart()}>212+ <TestCase tags={["C_API"]} itShould="restart">
208- 重启(restart)213+ <Text
209- </Text>214+ style={styles.button}
210- <Text>重启Restart</Text>215+ onPress={() => RNRestart.restart("restart_a")}
211- <Text style={styles.button} onPress={() => RNRestart.Restart()}>216+ >
212- 重启(Restart)217+ restart
213- </Text>218+ </Text>
214- <Text>上次restart的原因(getReason)</Text>219+ </TestCase>
215- <Text style={styles.button} onPress={() => RNRestart.getReason()}>220+ <TestCase
216- getReason221+ tags={["C_API"]}
217- </Text>222+ itShould="getReason"
218- </View>223+ initialState={"reason"}
224+ arrange={({ setState }) => {
225+ return (
226+ <Text
227+ style={styles.button}
228+ onPress={async () => {
229+ try {
230+ const reason = await RNRestart.getReason();
231+ setRestartReason(reason);
232+ setState(reason);
233+ } catch (e) {
234+ setRestartReason("");
235+ setState("");
236+ }
237+ }}
238+ >
239+ getReason{restartReason ? `(原因:${restartReason})` : ""}
240+ </Text>
241+ );
242+ }}
243+ assert={async ({ expect, state }) => {
244+ expect(state).include("restart_");
245+ }}
246+ />
247+ </TestSuite>
248+ </Tester>
219 );249 );
220}250}
221 251 
@@ -223,9 +253,9 @@ const styles = StyleSheet.create({
223 button: {253 button: {
224 paddingVertical: 6,254 paddingVertical: 6,
225 paddingHorizontal: 12,255 paddingHorizontal: 12,
226- backgroundColor: 'hsl(193, 95%, 68%)',256+ backgroundColor: "hsl(193, 95%, 68%)",
227 borderWidth: 2,257 borderWidth: 2,
228- borderColor: 'hsl(193, 95%, 30%)',258+ borderColor: "hsl(193, 95%, 30%)",
229 },259 },
230});260});
231 261 
@@ -242,7 +272,6 @@ const styles = StyleSheet.create({
242| Name | Description | Type | Required | Platform | HarmonyOS Support |272| Name | Description | Type | Required | Platform | HarmonyOS Support |
243| --------- | --------------------------------- | -------- | -------- | -------- | ----------------- |273| --------- | --------------------------------- | -------- | -------- | -------- | ----------------- |
244| restart | 重启RN工程 | Function | no | All | yes |274| restart | 重启RN工程 | Function | no | All | yes |
245-| Restart | 重启RN工程 | Function | no | All | yes |
246| getReason | 获取重启原因 | Function | no | All | yes |275| getReason | 获取重启原因 | Function | no | All | yes |
247 276 
248## 遗留问题277## 遗留问题
@@ -256,7 +285,7 @@ const styles = StyleSheet.create({
256├── harmony # 鸿蒙适配代码285├── harmony # 鸿蒙适配代码
257│ └─ rn_restart.har # har包286│ └─ rn_restart.har # har包
258│ └─ restart # 鸿蒙适配核心代码287│ └─ restart # 鸿蒙适配核心代码
259-│ └─ index.ets # 鸿蒙适配代码入口 288+│ └─ Index.ets # 鸿蒙适配代码入口
260│ └─ src/main/ets 289│ └─ src/main/ets
261│ └─ RNRestartTurboModule.ts # Restart核心实现 290│ └─ RNRestartTurboModule.ts # Restart核心实现
262├── src # RN代码291├── src # RN代码
@@ -1,14 +1,16 @@
1-> Document Template:v0.4.11+> Document Template:v0.4.2
2 2 
3-# <center>react-native-restart</center>3+<p align="center">
4+ <h1 align="center"> <code>react-native-restart</code> </h1>
5+</p>
4 6 
5This project is based on [react-native-restart](https://github.com/avishayil/react-native-restart).7This project is based on [react-native-restart](https://github.com/avishayil/react-native-restart).
6 8 
7-This third-party library supports direct installation from npm, the new package name is: `@react-native-ohos/react-native-restart`, The version correspondence details are as follows:9+The repository of this third-party library has been migrated to Gitcode, and it supports direct installation from npm. The new package name is: `@react-native-ohos/react-native-restart`. The version correspondence details are as follows:
8 10 
9-| Name | Version | Release Information | Supported RN Version | Supported Autolink | Compile API Version | Community Baseline Version | npm Address |11+| Name | Version(Npm Address) | Release Information | Supported RN Version | Supported Autolink | Compile API Version | Community Baseline Version | Source code address |
10-| - | - | - | - | - | - | - | - |12+| --------------| -------------- | ------------------------------ | ------------- | ------------- |------------------------ | ------------ | ------------- |
11-| @react-native-ohos/react-native-restart | ~ 0.2.0 (In development) | [Gitcode Releases](https://gitcode.com/CPF-RN/rntpc_react-native-restart/releases) | 0.82.* | Yes | API12+ | 0.0.27 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-restart) | 13+| @react-native-ohos/react-native-restart | [~ 0.2.0 (In development)](https://www.npmjs.com/package/@react-native-ohos/react-native-restart) | [Gitcode Releases](https://gitcode.com/CPF-RN/rntpc_react-native-restart/releases) | 0.82.* | Yes | API12+ | 0.0.27 | [br_rnoh0.82](https://gitcode.com/CPF-RN/rntpc_react-native-restart/tree/br_rnoh0.82) |
12 14 
13## Introduction15## Introduction
14 16 
@@ -196,27 +198,55 @@ The following code shows the basic use scenario of the repository:
196 198 
197> [!WARNING] The name of the imported repository remains unchanged.199> [!WARNING] The name of the imported repository remains unchanged.
198 200 
199-```js201+```tsx
200-import React from 'react';202+import { useState } from "react";
201-import {Text, View, StyleSheet} from 'react-native';203+import { StyleSheet, Text } from "react-native";
202-import RNRestart from 'react-native-restart';204+import RNRestart from "react-native-restart";
205+import { Tester, TestSuite, TestCase } from "@rnoh/testerino";
cpf-manager
cpf-managercpf-manager9 天前

【AI-Review】【一般】【基础代码问题】【验证问题】Example 引入了未声明的 @rnoh/testerino 依赖

● 问题:README_en.md 第 205 行的 Example 导入了 @rnoh/testerinoimport { Tester, TestSuite, TestCase } from "@rnoh/testerino";),但"Installation"章节(第 19-33 行)仅说明安装 @react-native-ohos/react-native-restart,未提及 @rnoh/testerino。同时仓库 package.jsondependencies/peerDependencies/devDependencies 中均不包含 @rnoh/testerino,该包并非 @react-native-ohos/react-native-restart 的依赖项。对比官方模板 usage-docs/zh-cn/model-0.4.2.md 第 292-310 行的示例,模板仅导入 reactreact-native 和三方库本身,不引入 @rnoh/testerino

● 影响:用户按照"Installation"章节执行 npm install @react-native-ohos/react-native-restart 后,直接复制"Example"中的代码会导致编译/运行失败(报错 Cannot find module '@rnoh/testerino'),违反 usage-docs/zh-cn/usage-docs-checklist.md 第 20 项"文档里面的 demo 是否没有代码错误,直接可跑通"的要求。

● 建议:二选一:

  1. 在"Example"中改用与官方模板 model-0.4.2.md 一致的简单写法(仅使用 react-nativeView/Text 等基础组件和 RNRestart),去掉 @rnoh/testerinoTester/TestSuite/TestCase 包装;
  2. 若需保留 testerino 测试示例,则在"Installation"章节补充 npm install @rnoh/testerino(或说明该包来自 RNOH 测试工程)。
likedislike
203 206 
204export default function RestartDemo() {207export default function RestartDemo() {
208+ const [restartReason, setRestartReason] = useState("");
209+ 
205 return (210 return (
206- <View>211+ <Tester>
207- <Text>restart</Text>212+ <TestSuite name="restart">
208- <Text style={styles.button} onPress={() => RNRestart.restart()}>213+ <TestCase tags={["C_API"]} itShould="restart">
209- restart214+ <Text
210- </Text>215+ style={styles.button}
211- <Text>Restart</Text>216+ onPress={() => RNRestart.restart("restart_a")}
212- <Text style={styles.button} onPress={() => RNRestart.Restart()}>217+ >
213- Restart218+ restart
214- </Text>219+ </Text>
215- <Text>The reason for the last restart(getReason)</Text>220+ </TestCase>
216- <Text style={styles.button} onPress={() => RNRestart.getReason()}>221+ <TestCase
217- getReason222+ tags={["C_API"]}
218- </Text>223+ itShould="getReason"
219- </View>224+ initialState={"reason"}
225+ arrange={({ setState }) => {
226+ return (
227+ <Text
228+ style={styles.button}
229+ onPress={async () => {
230+ try {
231+ const reason = await RNRestart.getReason();
232+ setRestartReason(reason);
233+ setState(reason);
234+ } catch (e) {
235+ setRestartReason("");
236+ setState("");
237+ }
238+ }}
239+ >
240+ getReason{restartReason ? ` (reason: ${restartReason})` : ""}
241+ </Text>
242+ );
243+ }}
244+ assert={async ({ expect, state }) => {
245+ expect(state).include("restart_");
246+ }}
247+ />
248+ </TestSuite>
249+ </Tester>
220 );250 );
221}251}
222 252 
@@ -224,9 +254,9 @@ const styles = StyleSheet.create({
224 button: {254 button: {
225 paddingVertical: 6,255 paddingVertical: 6,
226 paddingHorizontal: 12,256 paddingHorizontal: 12,
227- backgroundColor: 'hsl(193, 95%, 68%)',257+ backgroundColor: "hsl(193, 95%, 68%)",
228 borderWidth: 2,258 borderWidth: 2,
229- borderColor: 'hsl(193, 95%, 30%)',259+ borderColor: "hsl(193, 95%, 30%)",
230 },260 },
231});261});
232 262 
@@ -243,7 +273,6 @@ const styles = StyleSheet.create({
243| Name | Description | Type | Required | Platform | HarmonyOS Support |273| Name | Description | Type | Required | Platform | HarmonyOS Support |
244| --------- | --------------------------------- | -------- | -------- | -------- | ----------------- |274| --------- | --------------------------------- | -------- | -------- | -------- | ----------------- |
245| restart | restart your react native project | Function | no | All | yes |275| restart | restart your react native project | Function | no | All | yes |
246-| Restart | restart your react native project | Function | no | All | yes |
247| getReason | get the cause of the last restart | Function | no | All | yes |276| getReason | get the cause of the last restart | Function | no | All | yes |
248 277 
249## Known Issues278## Known Issues
@@ -256,9 +285,9 @@ const styles = StyleSheet.create({
256├── harmony # HarmonyOS adaptation code285├── harmony # HarmonyOS adaptation code
257│ └─ rn_restart.har # har package286│ └─ rn_restart.har # har package
258│ └─ restart # HarmonyOS adaptation core code287│ └─ restart # HarmonyOS adaptation core code
259-│ └─ index.ets # HarmonyOS adaptation code entry point 288+│ └─ Index.ets # HarmonyOS adaptation code entry point
260│ └─ src/main/ets 289│ └─ src/main/ets
261-│ └─ RNRestartTurboModule.ts # Restart component implementation 290+│ └─ RNRestartTurboModule.ts # Restart core implementation
262├── src # React Native code291├── src # React Native code
263│ └─ index.tsx # Entry file 292│ └─ index.tsx # Entry file
264│ └─ NativeRestart.ts # Type file 293│ └─ NativeRestart.ts # Type file