From 24f138826816b2a659f5a196d5417b61d7648165 Mon Sep 17 00:00:00 2001 From: CPunisher <1343316114@qq.com> Date: Wed, 6 May 2020 13:08:01 +0800 Subject: [PATCH] [Correct Level adjustment] --- src/components/Footer.js | 20 ++++++++++++++++++++ src/components/Qrcode.js | 41 +++++++++++++++++++++++----------------- 2 files changed, 44 insertions(+), 17 deletions(-) create mode 100644 src/components/Footer.js diff --git a/src/components/Footer.js b/src/components/Footer.js new file mode 100644 index 0000000..69e2ed8 --- /dev/null +++ b/src/components/Footer.js @@ -0,0 +1,20 @@ +import React from "react"; +import './Qrcode.css'; + +const currentYear = new Date().getFullYear(); + +class Footer extends React.Component { + render() { + return ( +
+
+
作者ciaochaosCPunisher
+
Copyright © {currentYear} QRBTF. 保留所有权利。
+
浙 ICP 备 19005869 号
+
+
+ ); + } +} + +export default Footer diff --git a/src/components/Qrcode.js b/src/components/Qrcode.js index 4937c38..e613130 100644 --- a/src/components/Qrcode.js +++ b/src/components/Qrcode.js @@ -8,6 +8,7 @@ import {isWeiXin} from "../utils/util"; import './Qrcode.css'; import logo from '../qrbtf-logo.svg'; +import Footer from "./Footer"; import QrItem from "./QrItem"; import QrRendererBase from "./QrRendererBase"; import QrRendererRound from "./QrRendererRound"; @@ -32,7 +33,6 @@ const styleList = [ {value: "D2", renderer: QrRendererBlank}, ]; -const currentYear = new Date().getFullYear(); class Qrcode extends React.Component { paramInfoBuffer; @@ -53,7 +53,8 @@ class Qrcode extends React.Component { options: {text: ''}, qrcode: null, paramInfo: [], - paramValue: [] + paramValue: [], + correctLevel: 0 }; this.paramInfoBuffer = new Array(16).fill(new Array(16)); this.paramValueBuffer = new Array(16).fill(new Array(16)); @@ -66,7 +67,7 @@ class Qrcode extends React.Component { paramValue: this.paramValueBuffer, text: text, options: {text: text}, - qrcode: getQrcodeData({text: text}) + qrcode: getQrcodeData({text: text, correctLevel: this.state.correctLevel}) }); } @@ -95,13 +96,8 @@ class Qrcode extends React.Component { handleCreate(e) { let text = this.state.text - - if (text.length > 0) - this.setState({options: {text: text}, qrcode: getQrcodeData({text: text})}); - else { - text = 'https://qrbtf.com/'; - this.setState({text: text, options: {text: text}, qrcode: getQrcodeData({text: text})}); - } + if (text.length <= 0) text = 'https://qrbtf.com/'; + this.setState({text: text, options: {text: text}, qrcode: getQrcodeData({text: text, correctLevel: this.state.correctLevel})}); if (e) e.target.blur(); } @@ -219,6 +215,23 @@ class Qrcode extends React.Component {
+ + + + {this.renderAdjustment()}
容错率 + +
@@ -258,13 +271,7 @@ class Qrcode extends React.Component {
-
-
-
作者ciaochaosCPunisher
-
Copyright © {currentYear} QRBTF. 保留所有权利。
-
浙 ICP 备 19005869 号
-
-
+