From 57ca41d4b5330606fe5cf9ea295f9cbe55cbe6f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=84=9A=E6=98=A7?= <906751526@qq.com> Date: Thu, 29 Feb 2024 19:38:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[Issues:=20#I94U70]=20=E6=B7=BB=E5=8A=A0qrc?= =?UTF-8?q?ode-generator=E6=93=8D=E4=BD=9C=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh-cn/qrcode.md | 169 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 zh-cn/qrcode.md diff --git a/zh-cn/qrcode.md b/zh-cn/qrcode.md new file mode 100644 index 00000000..effc402f --- /dev/null +++ b/zh-cn/qrcode.md @@ -0,0 +1,169 @@ +模板版本:v0.1.3 + +

+

qrcode-generator

+

+

+ + Supported platforms + + + License + + +

+ +[Github 地址](https://github.com/kazuhikoarase/qrcode-generator) +安装与使用 +------------------------------------------------------------------------------------------------------------------------------- + +进入到工程目录并输入以下命令: + +**npm** + +```bash +npm install qrcode-generator +``` + +**yarn** + +```bash +yarn add qrcode-generator +``` + +快速使用: + +```js +import React,{useState,useEffect} from "react"; +import{View,Text,Image} from "react-native" +import QRCode from 'qrcode-generator' + +export const CustomQrCode = ({text,style}) => { + const [base64Img,setBase64Img] = useState('hello word') + useEffect(() => { + const typeNumber = 4 + const errorCorrectionLevel = 'L' + const qr = QRCode(typeNumber,errorCorrectionLevel) + qr.addData(text) + qr.make() + setBase64Img(qr.createDataURL(4,10)) + },[text]) + + return( + base64Img ? : null + ) +} +``` + +约束与限制 +------------------------------------------------------------------------------------------------------------------------------- + +#### 兼容性 + + + +在下述版本验证通过: + + + +1. RNOH:0.72.11; SDK:OpenHarmony(api11) 4.1.0.53; IDE:DevEco Studio 4.1.3.412; ROM:2.0.0.52; +2. RNOH:0.72.13; SDK:HarmonyOS NEXT Developer Preview1; IDE:DevEco Studio 4.1.3.500; ROM:2.0.0.58; + +API列表 +------------------------------------------------------------------------------------------------------- + +**以下 `QRCode` 均为qrcode-generator导出的对象,即:** + +```js +import QRCode from 'qrcode-generator'; +``` + +#### Base + +**静态方法** + +"HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 + + + +| Name | Description | Type | Required | HarmonyOS Support | +| --------------------------------------- | ----------- | -------- | -------- | ----------------- | +| QRCode(typeNumber,errorCorrectionLevel) | 创建二维码对象 | function | Yes | Yes | + +**api** + +| Name | Description | Type | Required | HarmonyOS Support | +| -------------------- | ---------------------- | ------ | -------- | ----------------- | +| typeNumber | 二维码类型(1~40,输入 0 以自动检测) | number | Yes | Yes | +| errorCorrectionLevel | 容错级别(L、M、Q、H) | string | Yes | Yes | + +**静态方法** + +| Name | Description | Type | Required | HarmonyOS Support | +| ----------------------- | ----------------------------------------------------- | -------- | -------- | ----------------- | +| QRCode.stringToBytes(s) | 将任意字符集的字符串编译成字节序列。这个函数是internal的,重写这个函数可在多字节字符集下编译字符串 | function | Yes | Yes | + +api + +| Name | Description | Type | Required | HarmonyOS Support | +| ---- | ----------- | ------ | -------- | ----------------- | +| s | 待编译的字符串 | string | Yes | Yes | + +**静态方法** + +| Name | Description | Type | Required | HarmonyOS Support | +| ------------------------- | ----------- | -------- | -------- | ----------------- | +| QRCode.addData(data,mode) | 添加二维码信息 | function | Yes | Yes | + +api + +| Name | Description | Type | Required | HarmonyOS Support | +| ---- | ----------------------------------------------------------------------------------------------------------------- | ------ | -------- | ----------------- | +| data | 二维码信息 | string | Yes | Yes | +| mode | 信息编译模式,可设置为:
Numeric   数字
Alphanumeric 文字数字混合
Byte 字节(默认)
Kanji 日语汉字 | string | No | Yes | + +**静态方法** + +| Name | Description | Type | Required | HarmonyOS Support | +| ----------------------- | ---------------------------- | -------- | -------- | ----------------- | +| QRCode.make() | 生成二维码对象(并不显示) | function | Yes | Yes | +| QRCode.getModuleCount() | 获取二维码每行(orientation)的 cell 数 | function | Yes | Yes | +| QRCode.isDark(row,col) | 返回指定行列上的 cell 是否有信息(黑色) | function | Yes | Yes | + +api + +| Name | Description | Type | Required | HarmonyOS Support | +| ---- | -------------------- | ------ | -------- | ----------------- | +| row | 行坐标(0~moduleCount-1) | number | Yes | Yes | +| col | 列坐标(0~moduleCount-1) | number | Yes | Yes | + + + +**静态方法** + +| Name | Description | Type | Required | HarmonyOS Support | +| ----------------------------------------- | ------------------------- | -------- | -------- | ----------------- | +| QRCode.createDataURL(cellSize, margin) | 生成base64格式的二维码内容 | function | Yes | Yes | +| QRCode.createImgTag(cellSize, margin,alt) | 生成img标签格式的HTML Helper函数 | function | Yes | Yes | +| QRCode.createSvgTag(cellSize, margin) | 生成svg标签格式的HTML Helper函数 | function | Yes | Yes | +| QRCode.createTableTag(cellSize, margin) | 生成table标签格式的HTML Helper函数 | function | Yes | Yes | +| QRCode.createASCII(cellSize, margin) | 生成ASCII码 | function | Yes | Yes | + +api + +| Name | Description | Type | Required | HarmonyOS Support | +| -------- | --------------------- | -------- | -------- | ----------------- | +| cellSize | cell 像素宽度,默认为 2 | function | No | Yes | +| margin | 补白像素宽度,默认为 cellSize*4 | function | No | Yes | +| alt | image 的提示 | function | No | Yes | + +遗留问题 +--------------------------------------------------------------------------------------------------------------------- + +其他 +------------------------------------------------------------------------------------------------- + +开源协议 +--------------------------------------------------------------------------------------------------------------------- + +本项目基于 [MIT License](https://github.com/brix/crypto-js/blob/4.2.0/LICENSE) ,请自由地享受和参与开源。 -- Gitee From 2a56c3aa3a1dbff022257e58fc499726cb25615f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=84=9A=E6=98=A7?= <906751526@qq.com> Date: Fri, 1 Mar 2024 11:23:00 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Issues:=20#I94U70]=20=E6=B7=BB=E5=8A=A0qrc?= =?UTF-8?q?ode-generator=E6=93=8D=E4=BD=9C=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh-cn/{qrcode.md => qrcode-generator.md} | 121 +++++++++++------------ 1 file changed, 56 insertions(+), 65 deletions(-) rename zh-cn/{qrcode.md => qrcode-generator.md} (36%) diff --git a/zh-cn/qrcode.md b/zh-cn/qrcode-generator.md similarity index 36% rename from zh-cn/qrcode.md rename to zh-cn/qrcode-generator.md index effc402f..1398c1a9 100644 --- a/zh-cn/qrcode.md +++ b/zh-cn/qrcode-generator.md @@ -1,31 +1,29 @@ -模板版本:v0.1.3 +> 模板版本:v0.1.2

qrcode-generator

- - Supported platforms - - + License -

-[Github 地址](https://github.com/kazuhikoarase/qrcode-generator) -安装与使用 -------------------------------------------------------------------------------------------------------------------------------- +> [!tip] [Github 地址](https://github.com/kazuhikoarase/qrcode-generator) + +## 安装与使用 + + 进入到工程目录并输入以下命令: -**npm** +#### **npm** ```bash npm install qrcode-generator ``` -**yarn** +#### **yarn** ```bash yarn add qrcode-generator @@ -58,13 +56,9 @@ export const CustomQrCode = ({text,style}) => { 约束与限制 ------------------------------------------------------------------------------------------------------------------------------- -#### 兼容性 - - - -在下述版本验证通过: - +### 兼容性 +在下述版本验证通过: 1. RNOH:0.72.11; SDK:OpenHarmony(api11) 4.1.0.53; IDE:DevEco Studio 4.1.3.412; ROM:2.0.0.52; 2. RNOH:0.72.13; SDK:HarmonyOS NEXT Developer Preview1; IDE:DevEco Studio 4.1.3.500; ROM:2.0.0.58; @@ -86,84 +80,81 @@ import QRCode from 'qrcode-generator'; -| Name | Description | Type | Required | HarmonyOS Support | -| --------------------------------------- | ----------- | -------- | -------- | ----------------- | -| QRCode(typeNumber,errorCorrectionLevel) | 创建二维码对象 | function | Yes | Yes | +| Name | Description | Type | Required | HarmonyOS Support | +| --------------------------------------- | ----------------------- | -------- | -------- | ----------------- | +| QRCode(typeNumber,errorCorrectionLevel) | Create a QRCode Object. | function | Yes | Yes | **api** -| Name | Description | Type | Required | HarmonyOS Support | -| -------------------- | ---------------------- | ------ | -------- | ----------------- | -| typeNumber | 二维码类型(1~40,输入 0 以自动检测) | number | Yes | Yes | -| errorCorrectionLevel | 容错级别(L、M、Q、H) | string | Yes | Yes | +| Name | Description | Type | Required | HarmonyOS Support | +| -------------------- | ---------------------------------------------- | ------ | -------- | ----------------- | +| typeNumber | Type number (1 ~ 40), or 0 for auto detection. | number | Yes | Yes | +| errorCorrectionLevel | Error correction level ('L', 'M', 'Q', 'H') | string | Yes | Yes | **静态方法** -| Name | Description | Type | Required | HarmonyOS Support | -| ----------------------- | ----------------------------------------------------- | -------- | -------- | ----------------- | -| QRCode.stringToBytes(s) | 将任意字符集的字符串编译成字节序列。这个函数是internal的,重写这个函数可在多字节字符集下编译字符串 | function | Yes | Yes | +| Name | Description | Type | Required | HarmonyOS Support | +| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- | ----------------- | +| QRCode.stringToBytes(s) | Encodes a string into an array of number(byte) using any charset. This function is used by internal. Overwrite this function to encode using a multibyte charset. | function | Yes | Yes | api -| Name | Description | Type | Required | HarmonyOS Support | -| ---- | ----------- | ------ | -------- | ----------------- | -| s | 待编译的字符串 | string | Yes | Yes | +| Name | Description | Type | Required | HarmonyOS Support | +| ---- | ---------------- | ------ | -------- | ----------------- | +| s | string to encode | string | Yes | Yes | **静态方法** -| Name | Description | Type | Required | HarmonyOS Support | -| ------------------------- | ----------- | -------- | -------- | ----------------- | -| QRCode.addData(data,mode) | 添加二维码信息 | function | Yes | Yes | +| Name | Description | Type | Required | HarmonyOS Support | +| ------------------------- | --------------------- | -------- | -------- | ----------------- | +| QRCode.addData(data,mode) | Add a data to encode. | function | Yes | Yes | api -| Name | Description | Type | Required | HarmonyOS Support | -| ---- | ----------------------------------------------------------------------------------------------------------------- | ------ | -------- | ----------------- | -| data | 二维码信息 | string | Yes | Yes | -| mode | 信息编译模式,可设置为:
Numeric   数字
Alphanumeric 文字数字混合
Byte 字节(默认)
Kanji 日语汉字 | string | No | Yes | +| Name | Description | Type | Required | HarmonyOS Support | +| ---- | ---------------------------------------------------------- | ------ | -------- | ----------------- | +| data | string to encode | string | Yes | Yes | +| mode | Mode ('Numeric', 'Alphanumeric', 'Byte'(default), 'Kanji') | Yes | | | **静态方法** -| Name | Description | Type | Required | HarmonyOS Support | -| ----------------------- | ---------------------------- | -------- | -------- | ----------------- | -| QRCode.make() | 生成二维码对象(并不显示) | function | Yes | Yes | -| QRCode.getModuleCount() | 获取二维码每行(orientation)的 cell 数 | function | Yes | Yes | -| QRCode.isDark(row,col) | 返回指定行列上的 cell 是否有信息(黑色) | function | Yes | Yes | +| Name | Description | Type | Required | HarmonyOS Support | +| ----------------------- | ------------------------------------------------------------------------------------------- | -------- | -------- | ----------------- | +| QRCode.make() | Make a QR Code. | function | Yes | Yes | +| QRCode.getModuleCount() | The number of modules(cells) for each orientation. [Note] call make() before this function. | function | Yes | Yes | +| QRCode.isDark(row,col) | The module at row and col is dark or not. [Note] call make() before this function. | function | Yes | Yes | -api +**api** -| Name | Description | Type | Required | HarmonyOS Support | -| ---- | -------------------- | ------ | -------- | ----------------- | -| row | 行坐标(0~moduleCount-1) | number | Yes | Yes | -| col | 列坐标(0~moduleCount-1) | number | Yes | Yes | +| Name | Description | Type | Required | HarmonyOS Support | +| ---- | ------------------- | ------ | -------- | ----------------- | +| row | 0 ~ moduleCount - 1 | number | Yes | Yes | +| col | 0 ~ moduleCount - 1 | number | Yes | Yes | **静态方法** -| Name | Description | Type | Required | HarmonyOS Support | -| ----------------------------------------- | ------------------------- | -------- | -------- | ----------------- | -| QRCode.createDataURL(cellSize, margin) | 生成base64格式的二维码内容 | function | Yes | Yes | -| QRCode.createImgTag(cellSize, margin,alt) | 生成img标签格式的HTML Helper函数 | function | Yes | Yes | -| QRCode.createSvgTag(cellSize, margin) | 生成svg标签格式的HTML Helper函数 | function | Yes | Yes | -| QRCode.createTableTag(cellSize, margin) | 生成table标签格式的HTML Helper函数 | function | Yes | Yes | -| QRCode.createASCII(cellSize, margin) | 生成ASCII码 | function | Yes | Yes | +| Name | Description | Type | Required | HarmonyOS Support | +| ----------------------------------------- | ------------------------------------------------------------------------------------------------------ | -------- | -------- | ----------------- | +| QRCode.createDataURL(cellSize, margin) | Generate base64 links,Helper functions for HTML. [Note] call make() before these functions. | function | Yes | Yes | +| QRCode.createImgTag(cellSize, margin,alt) | Generate img tag QR code,Helper functions for HTML. [Note] call make() before these functions. | function | Yes | Yes | +| QRCode.createSvgTag(cellSize, margin) | Generate QR codes for svg tags,Helper functions for HTML. [Note] call make() before these functions. | function | Yes | Yes | +| QRCode.createTableTag(cellSize, margin) | Generate QR codes for table tags,Helper functions for HTML. [Note] call make() before these functions. | function | Yes | Yes | +| QRCode.createASCII(cellSize, margin) | Generate ASCII code,Helper functions for HTML. [Note] call make() before these functions. | function | Yes | Yes | -api +**api** | Name | Description | Type | Required | HarmonyOS Support | | -------- | --------------------- | -------- | -------- | ----------------- | -| cellSize | cell 像素宽度,默认为 2 | function | No | Yes | -| margin | 补白像素宽度,默认为 cellSize*4 | function | No | Yes | -| alt | image 的提示 | function | No | Yes | +| cellSize | default: 2 | function | No | Yes | +| margin | default: cellSize * 4 | function | No | Yes | +| alt | (optional) | function | No | Yes | -遗留问题 ---------------------------------------------------------------------------------------------------------------------- +## 遗留问题 -其他 -------------------------------------------------------------------------------------------------- +## 其他 -开源协议 ---------------------------------------------------------------------------------------------------------------------- +## 开源协议 -本项目基于 [MIT License](https://github.com/brix/crypto-js/blob/4.2.0/LICENSE) ,请自由地享受和参与开源。 +本项目基于 [The MIT License (MIT)](https://github.com/facebook/prop-types/blob/v15.8.1/LICENSE) ,请自由地享受和参与开源。 -- Gitee