gm-printer 10.36.2 → 10.36.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-printer",
3
- "version": "10.36.2",
3
+ "version": "10.36.5",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -38,12 +38,20 @@ function getTipDOM(id) {
38
38
  Tip.warning = (message = '') => {
39
39
  tips.push(message)
40
40
 
41
+ const tipDOM = getTipDOM('gm-printer-tip')
42
+ if (!tipDOM) {
43
+ // 打印 iframe 场景下不存在 gm-printer-tip 容器,用 alert 兜底
44
+ window.alert(message)
45
+ tips.pop()
46
+ return
47
+ }
48
+
41
49
  setTimeout(() => {
42
50
  tips.shift()
43
- ReactDOM.render(<Tip list={tips} />, getTipDOM('gm-printer-tip'))
51
+ ReactDOM.render(<Tip list={tips} />, tipDOM)
44
52
  }, 3000)
45
53
 
46
- ReactDOM.render(<Tip list={tips} />, getTipDOM('gm-printer-tip'))
54
+ ReactDOM.render(<Tip list={tips} />, tipDOM)
47
55
  }
48
56
 
49
57
  Tip.propTypes = {
@@ -1,5 +1,5 @@
1
1
  import i18next from '../../locales'
2
- import { action, observable, computed, toJS } from 'mobx'
2
+ import { action, observable, computed } from 'mobx'
3
3
  import {
4
4
  getSumTrHeight,
5
5
  isMultiTable,
@@ -530,7 +530,7 @@ class PrinterStore {
530
530
  })({
531
531
  ...this.data.common,
532
532
  [i18next.t('当前页码')]: pageIndex + 1,
533
- [i18next.t('页码总数')]: this.pages.length,
533
+ [i18next.t('页码总数')]: Math.max(1, this.pages.length),
534
534
  price: price
535
535
  })
536
536
  } catch (err) {
@@ -604,7 +604,7 @@ class PrinterStore {
604
604
 
605
605
  [i18next.t('列')]: list[index],
606
606
  [i18next.t('当前页码')]: pageIndex + 1,
607
- [i18next.t('页码总数')]: this.pages.length,
607
+ [i18next.t('页码总数')]: Math.max(1, this.pages.length),
608
608
  price: price // 提供一个价格处理函数
609
609
  })
610
610
  } catch (err) {
@@ -626,7 +626,7 @@ class PrinterStore {
626
626
  ...this.data.common,
627
627
  [i18next.t('列')]: list[index],
628
628
  [i18next.t('当前页码')]: pageIndex + 1,
629
- [i18next.t('页码总数')]: this.pages.length,
629
+ [i18next.t('页码总数')]: Math.max(1, this.pages.length),
630
630
  price: price // 提供一个价格处理函数
631
631
  })
632
632
  res =