gm-printer 10.42.4-beta.2 → 10.42.4-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/demo.js +9 -9
- package/package.json +1 -1
- package/src/common/editor_select.js +26 -2
- package/src/common/editor_store.js +27 -0
- package/src/config.js +12 -0
- package/src/editor/editor.js +1 -1
- package/src/editor/editor_menu_config.js +1 -1
- package/src/printer/page.js +3 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import React from 'react'
|
|
|
3
3
|
import { observer, inject } from 'mobx-react'
|
|
4
4
|
import { Flex, Option, Select, RadioGroup, Radio } from '../components'
|
|
5
5
|
import { InputWithUnit } from '../common/component'
|
|
6
|
-
import { pageTypeMap, printDirectionList, LONG_PRINT } from '../config'
|
|
6
|
+
import { pageTypeMap, printDirectionList, fontFamilyList, LONG_PRINT } from '../config'
|
|
7
7
|
import _ from 'lodash'
|
|
8
8
|
import { dispatchMsg } from '../util'
|
|
9
9
|
import PropTypes from 'prop-types'
|
|
@@ -31,6 +31,10 @@ class EditorSelector extends React.Component {
|
|
|
31
31
|
this.props.editStore.setPagePrintDirection(value)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
handleFontFamily = value => {
|
|
35
|
+
this.props.editStore.setPageFontFamily(value)
|
|
36
|
+
}
|
|
37
|
+
|
|
34
38
|
handleSelectedRegion = selected => {
|
|
35
39
|
dispatchMsg('gm-printer-select-region', { selected })
|
|
36
40
|
}
|
|
@@ -52,6 +56,7 @@ class EditorSelector extends React.Component {
|
|
|
52
56
|
computedSelectedRegionTip,
|
|
53
57
|
selectedRegion
|
|
54
58
|
} = this.props.editStore
|
|
59
|
+
const { showFontFamily } = this.props
|
|
55
60
|
const isDIY = page.type === 'DIY'
|
|
56
61
|
const isLongPrint = page.type === LONG_PRINT
|
|
57
62
|
return (
|
|
@@ -121,6 +126,23 @@ class EditorSelector extends React.Component {
|
|
|
121
126
|
</Flex>
|
|
122
127
|
)}
|
|
123
128
|
|
|
129
|
+
{showFontFamily && (
|
|
130
|
+
<Flex alignCenter className='gm-padding-top-5'>
|
|
131
|
+
<div>{i18next.t('打印字体')}:</div>
|
|
132
|
+
<Select
|
|
133
|
+
className='gm-printer-edit-select'
|
|
134
|
+
value={page.fontFamily || ''}
|
|
135
|
+
onChange={this.handleFontFamily}
|
|
136
|
+
>
|
|
137
|
+
{_.map(fontFamilyList, v => (
|
|
138
|
+
<Option key={v.value} value={v.value}>
|
|
139
|
+
{v.text}
|
|
140
|
+
</Option>
|
|
141
|
+
))}
|
|
142
|
+
</Select>
|
|
143
|
+
</Flex>
|
|
144
|
+
)}
|
|
145
|
+
|
|
124
146
|
<Flex alignCenter className='gm-padding-top-5'>
|
|
125
147
|
<div>{i18next.t('选择区域')}:</div>
|
|
126
148
|
<Select
|
|
@@ -190,10 +212,12 @@ class EditorSelector extends React.Component {
|
|
|
190
212
|
|
|
191
213
|
EditorSelector.propTypes = {
|
|
192
214
|
isPurchase: PropTypes.bool,
|
|
215
|
+
showFontFamily: PropTypes.bool,
|
|
193
216
|
editStore: PropTypes.object
|
|
194
217
|
}
|
|
195
218
|
EditorSelector.defaultProps = {
|
|
196
|
-
isPurchase: false
|
|
219
|
+
isPurchase: false,
|
|
220
|
+
showFontFamily: false
|
|
197
221
|
}
|
|
198
222
|
|
|
199
223
|
export default EditorSelector
|
|
@@ -537,6 +537,33 @@ class EditorStore {
|
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
539
|
|
|
540
|
+
// 模板级打印字体(page.fontFamily),空值清掉字段恢复默认字体
|
|
541
|
+
@action
|
|
542
|
+
setPageFontFamily(value) {
|
|
543
|
+
this.config.page = {
|
|
544
|
+
...this.config.page,
|
|
545
|
+
fontFamily: value || undefined
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// 模板级打印字体(page.fontFamily),空值清掉字段恢复默认字体
|
|
550
|
+
@action
|
|
551
|
+
setPageFontFamily(value) {
|
|
552
|
+
this.config.page = {
|
|
553
|
+
...this.config.page,
|
|
554
|
+
fontFamily: value || undefined
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// 模板级打印字体(page.fontFamily),空值清掉字段恢复默认字体
|
|
559
|
+
@action
|
|
560
|
+
setPageFontFamily(value) {
|
|
561
|
+
this.config.page = {
|
|
562
|
+
...this.config.page,
|
|
563
|
+
fontFamily: value || undefined
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
540
567
|
@action
|
|
541
568
|
setSelected(selected = null) {
|
|
542
569
|
this.selected = selected
|
package/src/config.js
CHANGED
|
@@ -116,6 +116,18 @@ export const printDirectionList = [
|
|
|
116
116
|
{ value: 'horizontal', text: i18next.t('横向') }
|
|
117
117
|
]
|
|
118
118
|
|
|
119
|
+
// 模板级打印字体(配送单等产品需求:整页字体自定义)。
|
|
120
|
+
// 只收系统字体,避免自定义字体文件的网络加载与打印时机问题。
|
|
121
|
+
// 值为三段 fallback:Windows 名 + macOS 名 + 中文名,双平台都能命中
|
|
122
|
+
export const fontFamilyList = [
|
|
123
|
+
{ value: '', text: i18next.t('默认字体') },
|
|
124
|
+
{ value: 'SimSun, Songti SC, 宋体', text: i18next.t('宋体') },
|
|
125
|
+
{ value: 'KaiTi, Kaiti SC, 楷体', text: i18next.t('楷体') },
|
|
126
|
+
{ value: 'SimHei, Heiti SC, 黑体', text: i18next.t('黑体') },
|
|
127
|
+
{ value: 'Microsoft YaHei, PingFang SC, 微软雅黑', text: i18next.t('微软雅黑') },
|
|
128
|
+
{ value: 'FangSong, STFangsong, 仿宋', text: i18next.t('仿宋') }
|
|
129
|
+
]
|
|
130
|
+
|
|
119
131
|
export const borderStyleList = [
|
|
120
132
|
{ value: 'solid', text: i18next.t('实线') },
|
|
121
133
|
{ value: 'dashed', text: i18next.t('虚线') },
|
package/src/editor/editor.js
CHANGED
|
@@ -85,7 +85,7 @@ class Editor extends React.Component {
|
|
|
85
85
|
<span>{':' + i18next.t('商户配送单')}</span>
|
|
86
86
|
</>
|
|
87
87
|
<Gap height='10px' />
|
|
88
|
-
<EditorSelect />
|
|
88
|
+
<EditorSelect showFontFamily />
|
|
89
89
|
<Gap height='5px' />
|
|
90
90
|
<SpecialField addFields={addFields} mockData={mockData} />
|
|
91
91
|
<SpecialOtherField addFields={addFields} mockData={mockData} />
|
|
@@ -84,7 +84,7 @@ class Editor extends React.Component {
|
|
|
84
84
|
<span>{':' + i18next.t('商户配送单')}</span>
|
|
85
85
|
</>
|
|
86
86
|
<Gap height='10px' />
|
|
87
|
-
<EditorSelect />
|
|
87
|
+
<EditorSelect showFontFamily />
|
|
88
88
|
<Gap height='5px' />
|
|
89
89
|
<SpecialField addFields={addFields} mockData={mockData} />
|
|
90
90
|
<SpecialOtherField addFields={addFields} mockData={mockData} />
|
package/src/printer/page.js
CHANGED
|
@@ -31,6 +31,7 @@ class Page extends React.Component {
|
|
|
31
31
|
const {
|
|
32
32
|
size: { width, height },
|
|
33
33
|
pageStyle,
|
|
34
|
+
fontFamily,
|
|
34
35
|
type
|
|
35
36
|
} = printerStore.config.page
|
|
36
37
|
// 统一减2毫米,防止计算误差溢出
|
|
@@ -43,6 +44,8 @@ class Page extends React.Component {
|
|
|
43
44
|
})}
|
|
44
45
|
style={{
|
|
45
46
|
...pageStyle,
|
|
47
|
+
// 模板级自定义字体(station 配送单模板 page.fontFamily):整页生效,未配置时保持浏览器默认
|
|
48
|
+
...(fontFamily ? { fontFamily } : undefined),
|
|
46
49
|
boxSizing: 'content-box',
|
|
47
50
|
width: `calc(${width} - ${paddingLeft} - ${paddingRight})`,
|
|
48
51
|
padding: `${paddingTop} ${paddingRight} ${paddingBottom} ${paddingLeft}`,
|