Merged
docs: upgrade README and README_en to v0.4.2 template #33
docs: upgrade README and README_en to v0.4.2 template #33
Merged
gbwAdd on 1 day ago
Total: 2 files changed+1212-7
MREADME.md+603-7
@@ -1,13 +1,609 @@
1-# @react-native-oh-tpl/react-native-background-fetch1+> 文档模板:v0.4.2
2 2 
3-This project is based on [react-native-background-fetch](https://github.com/transistorsoft/react-native-background-fetch)3+<p align="center">
4+ <h1 align="center"> <code>react-native-background-fetch</code> </h1>
5+</p>
4 6 
5-## Documentation7+[English](README_en.md) | **简体中文**
cpf-manager
cpf-managercpf-manager1 day ago

【AI-Review】【一般】【编码规范】【其他编码规范】 ● 问题: 根目录 README.md 被改为中文版本,不符合"根目录 README.md 和文档默认首页/默认语言必须为英文"的文档规范。该 PR 将原为英文的 README.md(base 版本标题为 # @react-native-oh-tpl/react-native-background-fetch,正文为英文)替换为全中文内容,同时新增 README_en.md 作为英文版。README.md 第 7 行 [English](README_en.md) | **简体中文** 将简体中文加粗标记为默认语言,第 601 行目录结构中也将 README.md 标注为"中文安装使用方法",README_en.md 标注为"英文安装使用方法"。这导致中文成为项目的默认文档入口。

● 影响: 国际用户和贡献者打开仓库首先看到的是中文 README,无法直接以英文了解项目,降低了项目的国际化可访问性。按文档语言规范,根目录 README.md 必须为英文,中文应作为切换版本提供。

● 建议: 交换两个文件的内容与命名:将 README_en.md 的英文内容放入 README.md(作为默认英文入口),将当前 README.md 的中文内容移至 README_zh.md(或 README_zh-CN.md),并相应更新第 7 行的语言切换链接为 [简体中文](README_zh.md) | **English**,同时更新目录结构中对 README 文件的标注。

likedislike
gbw
gbw
1 day ago Comments:
likedislike
6 8 
7-[中文](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/zh-cn/react-native-background-fetch.md)9+本项目基于 [react-native-background-fetch](https://github.com/transistorsoft/react-native-background-fetch) 开发。
8 10 
9-[English](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/en/react-native-background-fetch.md)11+该第三方库的仓库已迁移至 AtomGit,且支持直接从 npm 下载,新的包名为:`@react-native-ohos/react-native-background-fetch`,版本所属关系如下:
10 12 
11-## License13+| 三方库名称 | 三方库版本(npm地址) | 发布信息 | 支持RN版本 | Autolink | 编译API版本 | 社区基线版本 | 源码地址 |
14+| --- | --- | --- | --- | --- | --- | --- | --- |
15+| @react-native-ohos/react-native-background-fetch | [~4.4.0(开发中)](https://www.npmjs.com/package/@react-native-ohos/react-native-background-fetch) | [AtomGit Releases](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/releases) | 0.82.* | 是 | API12+ | 4.2.8 | [br_rnoh0.82](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/tree/br_rnoh0.82) |
16+| @react-native-ohos/react-native-background-fetch | [~4.3.0](https://www.npmjs.com/package/@react-native-ohos/react-native-background-fetch) | [AtomGit Releases](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/releases) | 0.77.* | 否 | API12+ | 4.2.8 | [br_rnoh0.77](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/tree/br_rnoh0.77) |
17+| @react-native-ohos/react-native-background-fetch | [~4.2.7](https://www.npmjs.com/package/@react-native-ohos/react-native-background-fetch) | [AtomGit Releases](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/releases) | 0.72.* | 是 | API12+ | 4.2.5 | [br_rnoh0.72](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/tree/br_rnoh0.72) |
18+| @react-native-oh-tpl/react-native-background-fetch | [<= 4.2.5-0.0.2@deprecated](https://www.npmjs.com/package/@react-native-oh-tpl/react-native-background-fetch) | [Github Releases(deprecated)](https://github.com/react-native-oh-library/react-native-background-fetch/releases) | 0.72.* | 否 | API12+ | 4.2.5 | [sig](https://github.com/react-native-oh-library/react-native-background-fetch) |
12 19 
13-This project is based on [MIT License (MIT)](https://github.com/transistorsoft/react-native-background-fetch/blob/master/LICENSE)20+## 简介
21+ 
22+react-native-background-fetch 是一个 React Native 后台任务调度库,为应用提供 iOS/Android 上的周期性后台拉取(Background Fetch)能力。<br/>
23+OpenHarmony 侧基于系统延迟调度(workScheduler)机制实现,支持配置最小拉取间隔以及网络类型、充电状态、存储空间、设备空闲等任务约束,并要求在任务完成后调用 BackgroundFetch.finish 通知系统。
24+ 
25+## 下载安装
26+ 
27+进入到工程目录并输入以下命令:
28+ 
29+**npm**
30+ 
31+```bash
32+npm install @react-native-ohos/react-native-background-fetch
33+```
34+ 
35+**yarn**
36+ 
37+```bash
38+yarn add @react-native-ohos/react-native-background-fetch
39+```
40+ 
41+## Link
42+ 
43+| | 是否支持Autolink | RN框架版本 |
44+| ------- | ---------------- | ---------- |
45+| ~ 4.4.0 | 是 | 0.82.* |
46+ 
47+使用 Autolink 的工程需要根据该文档配置,Autolink 框架指导文档:https://atomgit.com/CPF-RN/ohos_react_native/blob/main/docs/zh-cn/02-开发/02-开发指南/Autolinking.md
48+ 
49+如您使用的版本支持 Autolink,无需进行下述操作,可跳过本章。
50+<details>
51+ <summary>ManualLink: 此步骤为手动配置原生依赖项的指导</summary>
52+ 
53+首先需要使用 DevEco Studio 打开项目里的 OpenHarmony 工程 `harmony`。
54+ 
55+### 1. Overrides RN SDK
56+ 
57+为了让工程依赖同一个版本的 RN SDK,需要在工程根目录的 `oh-package.json5` 添加 overrides 字段,指向工程需要使用的 RN SDK 版本。替换的版本既可以是一个具体的版本号,也可以是一个模糊版本,还可以是本地存在的 HAR 包或源码目录。
58+ 
59+关于该字段的作用请阅读[官方说明](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ide-oh-package-json5-V5#zh-cn_topic_0000001792256137_overrides)
60+ 
61+```json
62+{
63+ "overrides": {
64+ "@rnoh/react-native-openharmony" : "file:../node_modules/@react-native-oh/react-native-harmony/react_native_openharmony.har" // 指向本地 har 包的路径
65+ // "@rnoh/react-native-openharmony": "~0.82.18" // ohpm 在线版本
66+ // "@rnoh/react-native-openharmony" : "./react_native_openharmony" // 指向源码路径
67+ }
68+}
69+```
70+ 
71+### 2. 引入原生端代码
72+ 
73+目前有两种方法:
74+ 
75+- 通过 har 包引入。
76+- 直接链接源码。
77+ 
78+方法一:通过 har 包引入(推荐)
79+ 
80+> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
81+ 
82+打开 `entry/oh-package.json5`,添加以下依赖
83+ 
84+```json
85+"dependencies": {
86+ "@react-native-ohos/react-native-background-fetch": "file:../../node_modules/@react-native-ohos/react-native-background-fetch/harmony/background_fetch.har"
87+ }
88+```
89+ 
90+点击右上角的 `sync` 按钮
91+ 
92+或者在命令行终端执行:
93+ 
94+```bash
95+cd entry
96+ohpm install
97+```
98+ 
99+方法二:直接链接源码
100+ 
@@ -0,0 +1,609 @@
1+> Document Template: v0.4.2
2+ 
3+<p align="center">
4+ <h1 align="center"> <code>react-native-background-fetch</code> </h1>
5+</p>
6+ 
7+**English** | [简体中文](README.md)
8+ 
9+This project is based on [react-native-background-fetch](https://github.com/transistorsoft/react-native-background-fetch).
10+ 
11+The repository for this third-party library has been migrated to AtomGit, and it now supports direct download from npm. The new package name is: `@react-native-ohos/react-native-background-fetch`. The specific version relationships are as follows:
12+ 
13+| Name | Version(Npm Address) | Release Information | Supported RN Version | Supported Autolink | Compile API Version | Community Baseline Version | Source code address |
14+| --- | --- | --- | --- | --- | --- | --- | --- |
15+| @react-native-ohos/react-native-background-fetch | [~4.4.0 (In development)](https://www.npmjs.com/package/@react-native-ohos/react-native-background-fetch) | [AtomGit Releases](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/releases) | 0.82.* | Yes | API12+ | 4.2.8 | [br_rnoh0.82](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/tree/br_rnoh0.82) |
16+| @react-native-ohos/react-native-background-fetch | [~4.3.0](https://www.npmjs.com/package/@react-native-ohos/react-native-background-fetch) | [AtomGit Releases](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/releases) | 0.77.* | No | API12+ | 4.2.8 | [br_rnoh0.77](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/tree/br_rnoh0.77) |
17+| @react-native-ohos/react-native-background-fetch | [~4.2.7](https://www.npmjs.com/package/@react-native-ohos/react-native-background-fetch) | [AtomGit Releases](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/releases) | 0.72.* | Yes | API12+ | 4.2.5 | [br_rnoh0.72](https://atomgit.com/CPF-RN/rntpc_react-native-background-fetch/tree/br_rnoh0.72) |
18+| @react-native-oh-tpl/react-native-background-fetch | [<= 4.2.5-0.0.2@deprecated](https://www.npmjs.com/package/@react-native-oh-tpl/react-native-background-fetch) | [Github Releases(deprecated)](https://github.com/react-native-oh-library/react-native-background-fetch/releases) | 0.72.* | No | API12+ | 4.2.5 | [sig](https://github.com/react-native-oh-library/react-native-background-fetch) |
19+ 
20+## Introduction
21+ 
22+react-native-background-fetch is a React Native background task scheduling library that provides periodic Background Fetch capabilities on iOS and Android.<br/>
23+The OpenHarmony side is implemented based on the system Work Scheduler (workScheduler) mechanism. It supports configuring the minimum fetch interval and task constraints such as network type, charging status, storage space, and device idle state, and requires calling BackgroundFetch.finish to notify the system when a task is complete.
24+ 
25+## Installation
26+ 
27+Go to the project directory and execute the following instruction:
28+ 
29+**npm**
30+ 
31+```bash
32+npm install @react-native-ohos/react-native-background-fetch
33+```
34+ 
35+**yarn**
36+ 
37+```bash
38+yarn add @react-native-ohos/react-native-background-fetch
39+```
40+ 
41+## Link
42+ 
43+| | Supported Autolink | Supported RN Version |
44+| ------- | ------------------ | -------------------- |
45+| ~ 4.4.0 | Yes | 0.82.* |
46+ 
47+Projects using Autolink need to be configured according to this document, Autolink framework guide: https://atomgit.com/CPF-RN/ohos_react_native/blob/main/docs/en/02-development/02-development-guide/autolinking.md
48+ 
49+If the version you are using supports Autolink, no further operations are required, and you can skip this chapter.
50+<details>
51+ <summary>ManualLink: This step provides guidance for manually configuring native dependencies.</summary>
52+ 
53+Open the `harmony` directory of the OpenHarmony project in DevEco Studio.
54+ 
55+### 1. Overrides RN SDK
56+ 
57+To ensure the project relies on the same version of the RN SDK, you need to add an `overrides` field in the project's root `oh-package.json5` file, specifying the RN SDK version to be used. The replacement version can be a specific version number, a semver range, or a locally available HAR package or source directory.
58+ 
59+For more information about the purpose of this field, please refer to the [official documentation](https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V5/ide-oh-package-json5-V5#en-us_topic_0000001792256137_overrides).
60+ 
61+```json
62+{
63+ "overrides": {
64+ "@rnoh/react-native-openharmony" : "file:../node_modules/@react-native-oh/react-native-harmony/react_native_openharmony.har" // a locally available HAR package
65+ // "@rnoh/react-native-openharmony": "~0.82.18" // ohpm version
66+ // "@rnoh/react-native-openharmony" : "./react_native_openharmony" // source code directory
67+ }
68+}
69+```
70+ 
71+### 2. Introducing Native Code
72+ 
73+Currently, two methods are available:
74+ 
75+- Introduce through the har package.
76+- Directly link to the source code.
77+ 
78+Method 1 (recommended): Introduce through the har package.
79+ 
80+> [!TIP] The har package is located in the `harmony` folder of the third-party library installation path.
81+ 
82+Open `entry/oh-package.json5` file and add the following dependencies:
83+ 
84+```json
85+"dependencies": {
86+ "@react-native-ohos/react-native-background-fetch": "file:../../node_modules/@react-native-ohos/react-native-background-fetch/harmony/background_fetch.har"
87+ }
88+```
89+ 
90+Click the `sync` button in the upper right corner.
91+ 
92+Alternatively, run the following instruction on the terminal:
93+ 
94+```bash
95+cd entry
96+ohpm install
97+```
98+ 
99+Method 2: Directly link to the source code.
100+