Fix param setting bugs
This commit is contained in:
parent
d80dceb0c9
commit
4d1d8a1789
|
@ -7,16 +7,20 @@ function listPoint(props) {
|
||||||
const qrcode = props.qrcode;
|
const qrcode = props.qrcode;
|
||||||
const nCount = qrcode.getModuleCount();
|
const nCount = qrcode.getModuleCount();
|
||||||
const pointList = new Array(nCount);
|
const pointList = new Array(nCount);
|
||||||
const params = props.params;
|
|
||||||
|
|
||||||
|
let type = props.params[1];
|
||||||
|
let size = props.params[0];
|
||||||
let id = 0;
|
let id = 0;
|
||||||
|
|
||||||
|
if (size <= 0) size = 1.0
|
||||||
|
|
||||||
for (let row = 0; row < nCount; row++) {
|
for (let row = 0; row < nCount; row++) {
|
||||||
for (let col = 0; col < nCount; col++) {
|
for (let col = 0; col < nCount; col++) {
|
||||||
if (qrcode.isDark(row, col)) {
|
if (qrcode.isDark(row, col)) {
|
||||||
if (params[1] == 0)
|
if (type == 0)
|
||||||
pointList.push(<rect width={params[0]} height={params[0]} key={id++} fill="black" x={row} y={col}/>)
|
pointList.push(<rect width={size} height={size} key={id++} fill="black" x={row} y={col}/>)
|
||||||
else if (params[1] == 1)
|
else if (type == 1)
|
||||||
pointList.push(<circle r={params[0]} key={id++} fill="black" cx={row} cy={col}/>)
|
pointList.push(<circle r={size} key={id++} fill="black" cx={row} cy={col}/>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,8 +143,9 @@ class Qrcode extends React.Component {
|
||||||
type="number"
|
type="number"
|
||||||
className="Qr-input small-input"
|
className="Qr-input small-input"
|
||||||
placeholder="10"
|
placeholder="10"
|
||||||
value={this.state.paramValue[this.state.selectedIndex][index]}
|
defaultValue={this.state.paramValue[this.state.selectedIndex][index]}
|
||||||
onChange={(e) => this.setParamValue(index, e.target.value)}/>
|
onBlur={(e) => this.setParamValue(index, e.target.value)}
|
||||||
|
onKeyPress={(e) => {if(e.key === 'Enter') {this.setParamValue(index, e.target.value); e.target.blur()}}}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +165,6 @@ class Qrcode extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
console.log(1)
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="Qr-Centered">
|
<div className="Qr-Centered">
|
||||||
|
|
Loading…
Reference in New Issue