gm-printer 10.33.1 → 10.33.2

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/.eslintcache ADDED
@@ -0,0 +1 @@
1
+ [{"/Users/maoxuanlong/Desktop/guanmai/code/gm-printer1/src/components/tip/index.js":"1"},{"size":1293,"mtime":1760773799171,"results":"2","hashOfConfig":"3"},{"filePath":"4","messages":"5","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1esol1r","/Users/maoxuanlong/Desktop/guanmai/code/gm-printer1/src/components/tip/index.js",[]]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-printer",
3
- "version": "10.33.1",
3
+ "version": "10.33.2",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -7,38 +7,50 @@ import _ from 'lodash'
7
7
 
8
8
  const tips = []
9
9
 
10
- const Tip = (props) => {
10
+ const Tip = props => {
11
11
  const { list } = props
12
12
 
13
- return <React.Fragment>
14
- {_.map(list, (item, index) => {
15
- return (
16
- <div key={index} className='gm-animated gm-animated-fade-in-right-100'>
17
- <Flex alignCenter className='gm-tip'>
18
- <SvgInfoCircle className='gm-svg-info'/>
19
- <div style={{ paddingLeft: '10px' }}>
20
- <div>{item}</div>
21
- </div>
22
- </Flex>
23
- </div>
24
- )
25
- })}
26
- </React.Fragment>
13
+ return (
14
+ <>
15
+ {_.map(list, (item, index) => {
16
+ return (
17
+ <div
18
+ key={index}
19
+ className='gm-animated gm-animated-fade-in-right-100'
20
+ >
21
+ <Flex alignCenter className='gm-tip'>
22
+ <SvgInfoCircle className='gm-svg-info' />
23
+ <div style={{ paddingLeft: '10px' }}>
24
+ <div>{item}</div>
25
+ </div>
26
+ </Flex>
27
+ </div>
28
+ )
29
+ })}
30
+ </>
31
+ )
27
32
  }
28
33
 
29
- function getTipDOM (id) {
30
- return window.shadowRoot.getElementById(id)
34
+ function getTipDOM(id) {
35
+ return window?.shadowRoot?.getElementById(id)
31
36
  }
32
37
 
33
38
  Tip.warning = (message = '') => {
34
39
  tips.push(message)
35
-
40
+ // TODO 这里要判断是否有dom 避免报错
36
41
  setTimeout(() => {
42
+ const dom = getTipDOM('gm-printer-tip')
37
43
  tips.shift()
38
- ReactDOM.render(<Tip list={tips}/>, getTipDOM('gm-printer-tip'))
44
+ if (!dom) {
45
+ return
46
+ }
47
+ ReactDOM.render(<Tip list={tips} />)
39
48
  }, 3000)
40
-
41
- ReactDOM.render(<Tip list={tips}/>, getTipDOM('gm-printer-tip'))
49
+ const dom = getTipDOM('gm-printer-tip')
50
+ if (!dom) {
51
+ return
52
+ }
53
+ ReactDOM.render(<Tip list={tips} />, getTipDOM('gm-printer-tip'))
42
54
  }
43
55
 
44
56
  Tip.propTypes = {