Skip to content

Commit

Permalink
feat: 二维码新增尺寸设置
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiiu committed Aug 28, 2023
1 parent 3c81edb commit f898df6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/common/editor_edit_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,20 @@ class EditorField extends React.Component {
onChange={this.handleChangeBlock.bind(this, 'style')}
/>
)}
{type === 'image' && (
{(type === 'image' || type === 'qrcode' || type === 'qrcode_trace') && (
<div>
<Size
style={style}
onChange={this.handleChangeBlock.bind(this, 'style')}
/>
<Gap />

<Textarea
value={link}
placeholder={i18next.t('请输入链接')}
onChange={this.handleChangeBlock.bind(this, 'link')}
/>
{type === 'image' && (
<Textarea
value={link}
placeholder={i18next.t('请输入链接')}
onChange={this.handleChangeBlock.bind(this, 'link')}
/>
)}
</div>
)}
<TipInfo
Expand Down
7 changes: 6 additions & 1 deletion src/printer/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ class Block extends React.Component {
</>
)
} else if (type === 'qrcode' || type === 'qrcode_trace') {
content = <QrCode value={printerStore.template(text)} />
content = (
<QrCode
value={printerStore.template(text)}
size={parseInt(style.height)}
/>
)
} else if (type === 'remark') {
content = (
<div
Expand Down
5 changes: 3 additions & 2 deletions src/printer/qrcode.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react'
import QRCode from 'qrcode.react'
import PropTypes from 'prop-types'
import _ from 'lodash'

const QrCode = props => {
const { value } = props
return <QRCode value={value} size={75} />
const { value, size } = props
return <QRCode value={value} size={_.isFinite(size) ? size : 75} />
}

QrCode.propTypes = {
Expand Down

0 comments on commit f898df6

Please sign in to comment.