fix param bug
This commit is contained in:
parent
12e506fcd2
commit
f5983dcaa8
|
@ -1,7 +1,7 @@
|
|||
import React from "react";
|
||||
import './Qrcode.css'
|
||||
import {getTypeTable, QRPointType} from "../utils/qrcodeHandler";
|
||||
import {rand} from "../utils/util";
|
||||
import {defaultRenderer, rand} from "../utils/util";
|
||||
|
||||
function listPoint(props) {
|
||||
if (!props.qrcode) return []
|
||||
|
@ -16,7 +16,6 @@ function listPoint(props) {
|
|||
let opacity = props.params[2] / 100;
|
||||
let posType = props.params[3];
|
||||
let id = 0;
|
||||
console.log(posType)
|
||||
|
||||
const vw = [3, -3];
|
||||
const vh = [3, -3];
|
||||
|
@ -71,13 +70,6 @@ function listPoint(props) {
|
|||
return pointList;
|
||||
}
|
||||
|
||||
function calViewBox(props) {
|
||||
if (!props.qrcode) return '0 0 0 0';
|
||||
|
||||
const nCount = props.qrcode.getModuleCount();
|
||||
return String(-nCount / 5) + ' ' + String(-nCount / 5) + ' ' + String(nCount + nCount / 5 * 2) + ' ' + String(nCount + nCount / 5 * 2);
|
||||
}
|
||||
|
||||
class QrRendererBase extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -115,12 +107,7 @@ class QrRendererBase extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<svg className="Qr-item-svg" width="100%" height="100%" viewBox={calViewBox(this.props)} fill="white"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink">
|
||||
{listPoint(this.props)}
|
||||
</svg>
|
||||
);
|
||||
return defaultRenderer(this.props.qrcode, listPoint(this.props));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
import React from "react";
|
||||
import './Qrcode.css'
|
||||
import {defaultRenderer} from "../utils/util";
|
||||
|
||||
class QrRendererBlank extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<svg className="Qr-item-svg" width="100%" height="100%" viewBox="0 0 0 0" fill="white"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink">
|
||||
</svg>
|
||||
);
|
||||
return defaultRenderer(this.props.qrcode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React from "react";
|
||||
import './Qrcode.css'
|
||||
import {rand, randRGB} from "../utils/util";
|
||||
import {defaultRenderer, rand, randRGB} from "../utils/util";
|
||||
|
||||
function listPoint(props) {
|
||||
if (!props.qrcode) return []
|
||||
|
@ -38,21 +38,9 @@ function listPoint(props) {
|
|||
return pointList;
|
||||
}
|
||||
|
||||
function calViewBox(props) {
|
||||
if (!props.qrcode) return '0 0 0 0';
|
||||
|
||||
const nCount = props.qrcode.getModuleCount();
|
||||
return String(-nCount / 5) + ' ' + String(-nCount / 5) + ' ' + String(nCount + nCount / 5 * 2) + ' ' + String(nCount + nCount / 5 * 2);
|
||||
}
|
||||
|
||||
class QrRendererRandRect extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<svg className="Qr-item-svg" width="100%" height="100%" viewBox={calViewBox(this.props)} fill="white"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink">
|
||||
{listPoint(this.props)}
|
||||
</svg>
|
||||
);
|
||||
return defaultRenderer(this.props.qrcode, listPoint(this.props));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React from "react";
|
||||
import './Qrcode.css'
|
||||
import {getTypeTable, QRPointType} from "../utils/qrcodeHandler";
|
||||
import {rand} from "../utils/util";
|
||||
import {rand, defaultRenderer} from "../utils/util";
|
||||
|
||||
function listPoint(props) {
|
||||
if (!props.qrcode) return []
|
||||
|
@ -16,7 +16,6 @@ function listPoint(props) {
|
|||
let opacity = props.params[2] / 100;
|
||||
let posType = props.params[3];
|
||||
let id = 0;
|
||||
console.log(posType)
|
||||
|
||||
const vw = [3, -3];
|
||||
const vh = [3, -3];
|
||||
|
@ -71,13 +70,6 @@ function listPoint(props) {
|
|||
return pointList;
|
||||
}
|
||||
|
||||
function calViewBox(props) {
|
||||
if (!props.qrcode) return '0 0 0 0';
|
||||
|
||||
const nCount = props.qrcode.getModuleCount();
|
||||
return String(-nCount / 5) + ' ' + String(-nCount / 5) + ' ' + String(nCount + nCount / 5 * 2) + ' ' + String(nCount + nCount / 5 * 2);
|
||||
}
|
||||
|
||||
class QrRendererRandRound extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -115,12 +107,7 @@ class QrRendererRandRound extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<svg className="Qr-item-svg" width="100%" height="100%" viewBox={calViewBox(this.props)} fill="white"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink">
|
||||
{listPoint(this.props)}
|
||||
</svg>
|
||||
);
|
||||
return defaultRenderer(this.props.qrcode, listPoint(this.props));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React from "react";
|
||||
import './Qrcode.css'
|
||||
import {getTypeTable, QRPointType} from "../utils/qrcodeHandler";
|
||||
import {rand} from "../utils/util";
|
||||
import {defaultRenderer, rand} from "../utils/util";
|
||||
|
||||
function listPoint(props) {
|
||||
if (!props.qrcode) return []
|
||||
|
@ -16,7 +16,6 @@ function listPoint(props) {
|
|||
let opacity = props.params[2] / 100;
|
||||
let posType = props.params[3];
|
||||
let id = 0;
|
||||
console.log(posType)
|
||||
|
||||
const vw = [3, -3];
|
||||
const vh = [3, -3];
|
||||
|
@ -71,13 +70,6 @@ function listPoint(props) {
|
|||
return pointList;
|
||||
}
|
||||
|
||||
function calViewBox(props) {
|
||||
if (!props.qrcode) return '0 0 0 0';
|
||||
|
||||
const nCount = props.qrcode.getModuleCount();
|
||||
return String(-nCount / 5) + ' ' + String(-nCount / 5) + ' ' + String(nCount + nCount / 5 * 2) + ' ' + String(nCount + nCount / 5 * 2);
|
||||
}
|
||||
|
||||
class QrRendererRound extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -115,12 +107,7 @@ class QrRendererRound extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<svg className="Qr-item-svg" width="100%" height="100%" viewBox={calViewBox(this.props)} fill="white"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink">
|
||||
{listPoint(this.props)}
|
||||
</svg>
|
||||
);
|
||||
return defaultRenderer(this.props.qrcode, listPoint(this.props));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@ const logoStyle = {
|
|||
backgroundPosition: 'left'
|
||||
};
|
||||
|
||||
const date = new Date();
|
||||
const currentYear = date.getFullYear();
|
||||
|
||||
const styleList = [
|
||||
{value: "A1", renderer: QrRendererBase},
|
||||
{value: "A2", renderer: QrRendererRound},
|
||||
|
@ -35,6 +32,8 @@ const styleList = [
|
|||
{value: "D2", renderer: QrRendererBlank},
|
||||
];
|
||||
|
||||
const currentYear = new Date().getFullYear();
|
||||
|
||||
class Qrcode extends React.Component {
|
||||
paramInfoBuffer;
|
||||
paramValueBuffer;
|
||||
|
@ -56,8 +55,8 @@ class Qrcode extends React.Component {
|
|||
paramInfo: [],
|
||||
paramValue: []
|
||||
};
|
||||
this.paramInfoBuffer = new Array(10).fill(new Array(10));
|
||||
this.paramValueBuffer = new Array(10).fill(new Array(10));
|
||||
this.paramInfoBuffer = new Array(16).fill(new Array(16));
|
||||
this.paramValueBuffer = new Array(16).fill(new Array(16));
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
@ -123,6 +122,7 @@ class Qrcode extends React.Component {
|
|||
return (
|
||||
<select
|
||||
className="Qr-select"
|
||||
key={"select_" + this.state.selectedIndex + "_" + index}
|
||||
value={this.state.paramValue[this.state.selectedIndex][index]}
|
||||
onChange={(e) => this.setParamValue(index, e.target.value)}>
|
||||
{
|
||||
|
@ -142,6 +142,7 @@ class Qrcode extends React.Component {
|
|||
return (
|
||||
<input
|
||||
type="number"
|
||||
key={"input_" + this.state.selectedIndex + "_" + index}
|
||||
className="Qr-input small-input"
|
||||
placeholder="10"
|
||||
defaultValue={this.state.paramValue[this.state.selectedIndex][index]}
|
||||
|
|
|
@ -26,7 +26,7 @@ export function getQrcodeData(options) {
|
|||
width : 256,
|
||||
height : 256,
|
||||
typeNumber : -1,
|
||||
correctLevel : 0,
|
||||
correctLevel : 1,
|
||||
background : "#ffffff",
|
||||
foreground : "#000000"
|
||||
}, options);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import React from "react";
|
||||
|
||||
let seed = 0;
|
||||
|
||||
export function srand(sd) {
|
||||
|
@ -13,6 +15,22 @@ export function randRGB(minR, maxR, minG, maxG, minB, maxB) {
|
|||
return 'rgb(' + parseInt(minR, maxR) + ',' + parseInt(minG, maxG) + ',' + parseInt(minB, maxB) + ')';
|
||||
}
|
||||
|
||||
export function defaultViewBox(qrcode) {
|
||||
if (!qrcode) return '0 0 0 0';
|
||||
|
||||
const nCount = qrcode.getModuleCount();
|
||||
return String(-nCount / 5) + ' ' + String(-nCount / 5) + ' ' + String(nCount + nCount / 5 * 2) + ' ' + String(nCount + nCount / 5 * 2);
|
||||
}
|
||||
|
||||
export function defaultRenderer(qrcode, points) {
|
||||
return (
|
||||
<svg className="Qr-item-svg" width="100%" height="100%" viewBox={defaultViewBox(qrcode)} fill="white"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink">
|
||||
{points}
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function isWeiXin(){
|
||||
const ua = window.navigator.userAgent.toLowerCase();
|
||||
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
|
||||
|
|
Loading…
Reference in New Issue