From d91d9d06c006b773e4981ff45a2859183a7e7e50 Mon Sep 17 00:00:00 2001
From: wang-yuanbai <603970629@qq.com>
Date: Fri, 12 Jan 2024 17:44:51 +0800
Subject: [PATCH 1/3] =?UTF-8?q?[Issues:=20#I8T6IX]=20=20=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?view-shot=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
zh-cn/react-native-view-shot.md | 258 ++++++++++++++++++++++++++++++++
1 file changed, 258 insertions(+)
create mode 100644 zh-cn/react-native-view-shot.md
diff --git a/zh-cn/react-native-view-shot.md b/zh-cn/react-native-view-shot.md
new file mode 100644
index 00000000..027e964e
--- /dev/null
+++ b/zh-cn/react-native-view-shot.md
@@ -0,0 +1,258 @@
+> 模板版本:v0.1.2
+
+
+
react-native-view-shot
+
+
+
+
+
+
+
+
+
+
+> [!tip] [Github 地址](https://github.com/react-native-oh-library/react-native-view-shot)
+
+## 安装与使用
+
+进入到工程目录并输入以下命令:
+
+
+
+**正在 npm 发布中,当前请先从仓库[Releases](https://github.com/react-native-oh-library/react-native-view-shot/releases)中获取库 tgz,通过使用本地依赖来安装本库。**
+
+#### **yarn**
+
+```bash
+yarn add xxx
+```
+
+#### **npm**
+
+```bash
+npm install xxx
+```
+
+
+
+快速使用:
+
+```js
+import React from "react";
+import { View, Text, Button } from "react-native";
+import { captureRef, captureScreen } from "react-native-view-shot";
+
+export default function App() {
+ const view = React.useRef < View > null;
+ return (
+
+
+
+ Hello OpenHarmony
+
+ Hello HarmonyOS
+
+ Hello HarmonyOS Next
+
+ Hello World
+
+
+
+
+ );
+}
+```
+
+## Link
+
+目前鸿蒙暂不支持 AutoLink,所以 Link 步骤需要手动配置。
+
+首先需要使用 DevEco Studio 打开项目里的鸿蒙工程 `harmony`
+
+### 引入原生端代码
+
+目前有两种方法:
+
+1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
+2. 直接链接源码。
+
+方法一:通过 har 包引入
+打开 `entry/oh-package.json5`,添加以下依赖
+
+```json
+"dependencies": {
+ "rnoh": "file:../rnoh",
+ "rnoh-view-shot": "file:../../node_modules/@react-native-oh-tpl/react-native-view-shot/harmony/view_shot.har"
+ }
+```
+
+点击右上角的 `sync` 按钮
+
+或者在终端执行:
+
+```bash
+cd entry
+ohpm install
+```
+
+方法二:直接链接源码
+打开 `entry/oh-package.json5`,添加以下依赖
+
+```json
+"dependencies": {
+ "rnoh": "file:../rnoh",
+ "rnoh-view-shot": "file:../../node_modules/@react-native-oh-tpl/react-native-view-shot/harmony/view_shot"
+ }
+```
+
+打开终端,执行:
+
+```bash
+cd entry
+ohpm install --no-link
+```
+
+### 配置 CMakeLists 和引入 ViewShotPackage
+
+打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
+
+```diff
+project(rnapp)
+cmake_minimum_required(VERSION 3.4.1)
+set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
+set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
+
+add_subdirectory("${RNOH_CPP_DIR}" ./rn)
+
+# RNOH_BEGIN: add_package_subdirectories
+add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
++ add_subdirectory("${OH_MODULE_DIR}/rnoh-view-shot/src/main/cpp" ./view-shot)
+# RNOH_END: add_package_subdirectories
+
+add_library(rnoh_app SHARED
+ "./PackageProvider.cpp"
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
+)
+
+target_link_libraries(rnoh_app PUBLIC rnoh)
+
+# RNOH_BEGIN: link_packages
+target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
++ target_link_libraries(rnoh_app PUBLIC rnoh_view_shot)
+# RNOH_END: link_packages
+```
+
+打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
+
+```diff
+#include "RNOH/PackageProvider.h"
+#include "SamplePackage.h"
++ #include "ViewShotPackage.h"
+
+using namespace rnoh;
+
+std::vector> PackageProvider::getPackages(Package::Context ctx) {
+ return {
+ std::make_shared(ctx),
++ std::make_shared(ctx)
+ };
+}
+```
+
+### 在 ArkTs 侧引入 ViewShotPackage
+
+打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
+
+```diff
+...
++ import { ViewShotPackage } from 'rnoh-view-shot/ts';
+
+export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
+ return [
+ new SamplePackage(ctx),
++ new ViewShotPackage(ctx),
+ ];
+}
+```
+
+### 应用权限申请
+
+> [!tip] "ohos.permission.WRITE_IMAGEVIDEO"权限等级为system_basic,授权方式为user_grant,[使用 ACL 签名的配置指导](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/signing-0000001587684945-V3#section157591551175916)
+
+在 `YourProject/entry/src/main/module.json5`补上配置
+
+```diff
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+
+ ···
+
+ "requestPermissions": [
++ { "name": "ohos.permission.WRITE_IMAGEVIDEO" }
+ ]
+ }
+}
+```
+
+### 运行
+
+点击右上角的 `sync` 按钮
+
+或者在终端执行:
+
+```bash
+cd entry
+ohpm install
+```
+
+然后编译、运行即可。
+
+## 约束与限制
+
+### 兼容性
+
+要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
+
+请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-oh-tpl/view-shot Releases](https://github.com/react-native-oh-library/react-native-view-shot/releases)
+
+## API
+
+> [!tip] "Platform"列表示该属性在原三方库上支持的平台。
+
+> [!tip] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
+| ------ | ------------ | ----- | -------- | -------- | ----------------- |
+| `captureRef` | 组件截图 | function | no | android, ios | yes |
+| `captureScreen` | 屏幕截图 | function | no | android, ios | yes |
+| `releaseCapture` | 资源释放 | function | no | android, ios | no |
+
+## 遗留问题
+
+- [ ] harmony 资源释放验证未通过
+
+## 其他
+
+## 开源协议
+
+本项目基于 [The MIT License (MIT)](https://github.com/react-native-oh-library/react-native-view-shot/blob/harmony/LICENSE) ,请自由地享受和参与开源。
--
Gitee
From 6548b145132c04d785aef133581824bd2f57485d Mon Sep 17 00:00:00 2001
From: wang-yuanbai <603970629@qq.com>
Date: Fri, 12 Jan 2024 17:54:42 +0800
Subject: [PATCH 2/3] =?UTF-8?q?[Issues:=20#I8T6IX]=20=20=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=E9=81=97=E7=95=99=E9=97=AE=E9=A2=98=E6=8F=8F=E8=BF=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
zh-cn/react-native-view-shot.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/zh-cn/react-native-view-shot.md b/zh-cn/react-native-view-shot.md
index 027e964e..38583f7d 100644
--- a/zh-cn/react-native-view-shot.md
+++ b/zh-cn/react-native-view-shot.md
@@ -249,7 +249,7 @@ ohpm install
## 遗留问题
-- [ ] harmony 资源释放验证未通过
+- [ ] harmonyOS 资源释放接口验证未通过
## 其他
--
Gitee
From b0be550bd2cdc315d64d9178c7b3a83d68fb1721 Mon Sep 17 00:00:00 2001
From: wang-yuanbai <603970629@qq.com>
Date: Fri, 12 Jan 2024 18:16:21 +0800
Subject: [PATCH 3/3] =?UTF-8?q?[Issues:=20#I8T6IX]=20=20=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=E9=81=97=E7=95=99=E9=97=AE=E9=A2=98=E6=8F=8F=E8=BF=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
zh-cn/react-native-view-shot.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/zh-cn/react-native-view-shot.md b/zh-cn/react-native-view-shot.md
index 38583f7d..43fd6178 100644
--- a/zh-cn/react-native-view-shot.md
+++ b/zh-cn/react-native-view-shot.md
@@ -249,7 +249,7 @@ ohpm install
## 遗留问题
-- [ ] harmonyOS 资源释放接口验证未通过
+- [ ] harmonyOS 资源释放接口验证未通过 [issues#2](https://github.com/react-native-oh-library/react-native-view-shot/issues/2)。
## 其他
--
Gitee