已合并
docs: update README document for 0.77 branch of react-native-restart library #28
docs: update README document for 0.77 branch of react-native-restart library #28
已合并
fanwangah创建于 8月4日
2 个文件变更+114-56
MREADME.md+56-27
@@ -1,14 +1,16 @@
1-> 文档模板:v0.4.11+> 文档模板:v0.4.2
2 2 
yangweiping
yangweipingyangweiping8月4日

模板做了一些变更,后续的文档需要按照新的去更改

变更点:

  1. 版本号由0.4.1更新为0.4.2
  2. 顶部所属关系映射表,三方库版本修改为三方库版本(npm地址),链接修改为原先npm地址的链接,同时删除npm地址字段
  3. 增加源码地址字段,值为对应分支,并添加对应分支跳转链接

另外这些也一并修改下: 1.openahrmony-sig的链接修改为CPF-RN。 2.

不再支持居中,修改为p align="center"方式居中。 3.部分库链接到usage-docs,迁移后相对路径不存在,应该使用完整路径。 例如:对于未发布到npm的旧版本,请参考安装指南安装tgz包。链接应该修改为 https://gitcode.com/CPF-RN/usage-docs/blob/master/zh-cn/tgz-usage.md 例如:> [!TIP] 如需使用直接链接源码,请参考直接链接源码说明。链接应该修改为 https://gitcode.com/CPF-RN/usage-docs/blob/master/zh-cn/link-source-code.md

likedislike
fanwangah
15 天前 评论:
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.1.0 | [Gitcode Releases](https://gitcode.com/CPF-RN/rntpc_react-native-restart/releases) | 0.77.* | 否 | 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.1.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.77.* | 否 | API12+ | 0.0.27 | [br_rnoh0.77](https://gitcode.com/CPF-RN/rntpc_react-native-restart/tree/br_rnoh0.77) |
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";
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 |
cpf-manager
cpf-managercpf-manager8月4日

【AI-Review】【一般】【软件设计】【其他软件设计问题】API 文档与代码实现不一致:Restart 方法已从文档移除但代码仍保留

● 问题:本次变更将 Restart 方法从 API 表中删除,但实际代码中 Restart 方法仍然存在并可被调用:

  • src/NativeRestart.ts 第 26 行:TurboModule Spec 接口中仍声明 Restart(reason?: string): void;
  • harmony/restart/src/main/ets/RNRestartTurboModule.ts:仍实现 public Restart = this.restart;(作为 restart 的别名)

通过 src/index.tsxexport default RNRestartRNRestart.Restart() 对用户仍可见可调用。

● 影响:文档与代码不一致。用户查阅 API 表时只能看到 restartgetReason 两个方法,但实际调用 RNRestart.Restart() 仍可正常工作。这会导致:1)用户阅读源码时发现未文档化的 API,产生困惑;2)文档无法准确反映模块对外暴露的完整接口,影响可维护性。

● 建议:二选一:

  1. Restart 已废弃,应在代码中同步移除 NativeRestart.ts 中的 Spec 声明和 RNRestartTurboModule.ts 中的 public Restart = this.restart; 实现;
  2. 若保留 Restart 用于向后兼容,应在 API 表中保留该行并标注"已废弃,推荐使用 restart"。
likedislike
fanwangah
15 天前 评论:
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.1.0 | [Gitcode Releases](https://gitcode.com/CPF-RN/rntpc_react-native-restart/releases) | 0.77.* | No | 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.1.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.77.* | No | API12+ | 0.0.27 | [br_rnoh0.77](https://gitcode.com/CPF-RN/rntpc_react-native-restart/tree/br_rnoh0.77) |
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";
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 |
cpf-manager
cpf-managercpf-manager8月4日

【AI-Review】【一般】【软件设计】【其他软件设计问题】API 文档与代码实现不一致:Restart 方法已从文档移除但代码仍保留

● 问题:本次变更将 Restart 方法从 API 表中删除,但实际代码中 Restart 方法仍然存在并可被调用:

  • src/NativeRestart.ts 第 26 行:TurboModule Spec 接口中仍声明 Restart(reason?: string): void;
  • harmony/restart/src/main/ets/RNRestartTurboModule.ts:仍实现 public Restart = this.restart;(作为 restart 的别名)

通过 src/index.tsxexport default RNRestartRNRestart.Restart() 对用户仍可见可调用。

● 影响:文档与代码不一致。用户查阅 API 表时只能看到 restartgetReason 两个方法,但实际调用 RNRestart.Restart() 仍可正常工作。这会导致:1)用户阅读源码时发现未文档化的 API,产生困惑;2)文档无法准确反映模块对外暴露的完整接口,影响可维护性。

● 建议:二选一:

  1. Restart 已废弃,应在代码中同步移除 NativeRestart.ts 中的 Spec 声明和 RNRestartTurboModule.ts 中的 public Restart = this.restart; 实现;
  2. 若保留 Restart 用于向后兼容,应在 API 表中保留该行并标注"已废弃,推荐使用 restart"。
likedislike
fanwangah
15 天前 评论:
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