gm-util 5.12.6 → 5.12.8

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-util",
3
- "version": "5.12.6",
3
+ "version": "5.12.8",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -43,4 +43,4 @@
43
43
  "query-string": "^6.1.0",
44
44
  "react": "^16.12.0"
45
45
  }
46
- }
46
+ }
package/src/isZoom2.js CHANGED
@@ -1,85 +1,125 @@
1
1
  /**
2
2
  * 检测浏览器缩放
3
3
  */
4
- export default function isZoom2 () {
4
+ export default function isZoom2() {
5
5
  const detectZoomFunc = {
6
- ie: () => { return window.screen.deviceXDPI / window.screen.logicalXDPI },
7
- firefox: () => { return window.devicePixelRatio ? window.devicePixelRatio : n('min--moz-device-pixel-ratio', '', 0, 10, 20, 1e-4) },
8
- opera: () => { return window.outerWidth / window.innerWidth },
6
+ ie: () => {
7
+ return window.screen.deviceXDPI / window.screen.logicalXDPI;
8
+ },
9
+ firefox: () => {
10
+ return window.devicePixelRatio
11
+ ? window.devicePixelRatio
12
+ : n("min--moz-device-pixel-ratio", "", 0, 10, 20, 1e-4);
13
+ },
14
+ opera: () => {
15
+ return window.outerWidth / window.innerWidth;
16
+ },
9
17
  chrome: () => {
10
18
  if (window.devicePixelRatio) {
11
- return window.devicePixelRatio
19
+ return window.devicePixelRatio;
12
20
  }
13
- const o = window.document
14
- const t = o.createElement('div')
15
- t.innerHTML = '1'
16
- t.setAttribute('style', 'font:100px/1em sans-serif-webkit-text-size-adjust:noneposition: absolutetop:-100%')
17
- o.body.appendChild(t)
18
- let n = 1e3 / t.clientHeight
19
- n = Math.round(100 * n) / 100
20
- o.body.removeChild(t)
21
- return n
21
+ const o = window.document;
22
+ const t = o.createElement("div");
23
+ t.innerHTML = "1";
24
+ t.setAttribute(
25
+ "style",
26
+ "font:100px/1em sans-serif-webkit-text-size-adjust:noneposition: absolutetop:-100%"
27
+ );
28
+ o.body.appendChild(t);
29
+ let n = 1e3 / t.clientHeight;
30
+ n = Math.round(100 * n) / 100;
31
+ o.body.removeChild(t);
32
+ return n;
22
33
  },
23
- safari: () => { return window.outerWidth / window.innerWidth }
24
- }
34
+ safari: () => {
35
+ return window.outerWidth / window.innerWidth;
36
+ }
37
+ };
25
38
 
26
- function round2 (number, fractionDigits) {
27
- return Math.round(number * Math.pow(10, fractionDigits)) / Math.pow(10, fractionDigits)
39
+ function round2(number, fractionDigits) {
40
+ return (
41
+ Math.round(number * Math.pow(10, fractionDigits)) /
42
+ Math.pow(10, fractionDigits)
43
+ );
28
44
  }
29
45
 
30
- function n (t, n, i, a, s, c) {
31
- function l (e, o, i) {
32
- const a = (e + o) / 2
33
- if (i <= 0 || o - e < c) return a
34
- const s = '(' + t + ':' + a + n + ')'
35
- return r(s).matches ? l(a, o, i - 1) : l(e, a, i - 1)
46
+ function n(t, n, i, a, s, c) {
47
+ function l(e, o, i) {
48
+ const a = (e + o) / 2;
49
+ if (i <= 0 || o - e < c) return a;
50
+ const s = "(" + t + ":" + a + n + ")";
51
+ return r(s).matches ? l(a, o, i - 1) : l(e, a, i - 1);
36
52
  }
37
- let r, d, m, p
38
- let e = window; let o = window.document
53
+ let r, d, m, p;
54
+ let e = window;
55
+ let o = window.document;
39
56
  if (e.matchMedia) {
40
- r = e.matchMedia
57
+ r = e.matchMedia;
41
58
  } else {
42
- d = o.getElementsByTagName('head')[0]
43
- m = o.createElement('style')
44
- d.appendChild(m)
45
- p = o.createElement('div')
46
- p.className = 'mediaQueryBinarySearch'
47
- p.style.display = 'none'
48
- o.body.appendChild(p)
59
+ d = o.getElementsByTagName("head")[0];
60
+ m = o.createElement("style");
61
+ d.appendChild(m);
62
+ p = o.createElement("div");
63
+ p.className = "mediaQueryBinarySearch";
64
+ p.style.display = "none";
65
+ o.body.appendChild(p);
49
66
  r = function (e) {
50
- m.sheet.insertRule('@media ' + e + '{.mediaQueryBinarySearch {text-decoration: underline} }', 0)
51
- const t = window.getComputedStyle(p, null).textDecoration === 'underline'
52
- m.sheet.deleteRule(0)
53
- return { matches: t }
54
- }
67
+ m.sheet.insertRule(
68
+ "@media " +
69
+ e +
70
+ "{.mediaQueryBinarySearch {text-decoration: underline} }",
71
+ 0
72
+ );
73
+ const t =
74
+ window.getComputedStyle(p, null).textDecoration === "underline";
75
+ m.sheet.deleteRule(0);
76
+ return { matches: t };
77
+ };
55
78
  }
56
79
 
57
- let u = l(i, a, s)
80
+ let u = l(i, a, s);
58
81
  if (p) {
59
- d.removeChild(m)
60
- o.body.removeChild(p)
82
+ d.removeChild(m);
83
+ o.body.removeChild(p);
61
84
  }
62
- return u
85
+ return u;
63
86
  }
64
87
 
65
- function system () {
66
- let ua = navigator.userAgent.toLowerCase()
67
- return ua.indexOf('win') >= 0 ? 'win' : ua.indexOf('mac') >= 0 ? 'mac' : false
88
+ function system() {
89
+ let ua = navigator.userAgent.toLowerCase();
90
+ return ua.indexOf("win") >= 0
91
+ ? "win"
92
+ : ua.indexOf("mac") >= 0
93
+ ? "mac"
94
+ : false;
68
95
  }
69
96
 
70
- function getBrowser () {
71
- let ua = navigator.userAgent.toLowerCase()
72
- return window.ActiveXObject || 'ActiveXObject' in window ? 'ie' : ua.indexOf('firefox') >= 0 ? 'firefox' : ua.indexOf('chrome') >= 0 ? 'chrome' : ua.indexOf('opera') >= 0 ? 'opera' : ua.indexOf('safari') >= 0 ? 'safari' : void 0
97
+ function getBrowser() {
98
+ let ua = navigator.userAgent.toLowerCase();
99
+ return window.ActiveXObject || "ActiveXObject" in window
100
+ ? "ie"
101
+ : ua.indexOf("firefox") >= 0
102
+ ? "firefox"
103
+ : ua.indexOf("chrome") >= 0
104
+ ? "chrome"
105
+ : ua.indexOf("opera") >= 0
106
+ ? "opera"
107
+ : ua.indexOf("safari") >= 0
108
+ ? "safari"
109
+ : void 0;
73
110
  }
74
111
 
75
- function detectZoom () {
76
- return detectZoomFunc[getBrowser()]()
112
+ function detectZoom() {
113
+ return detectZoomFunc[getBrowser() || "chrome"]();
77
114
  }
78
115
 
79
- function iszoom (e) {
80
- return (e.system === 'win' && e.zoom !== 1) || (e.system === 'mac' && e.zoom % 1 !== 0 && e.zoom % 2 !== 0)
116
+ function iszoom(e) {
117
+ return (
118
+ (e.system === "win" && e.zoom !== 1) ||
119
+ (e.system === "mac" && e.zoom % 1 !== 0 && e.zoom % 2 !== 0)
120
+ );
81
121
  }
82
122
 
83
- const zoomData = { zoom: round2(detectZoom(), 2), system: system() }
84
- return iszoom(zoomData)
123
+ const zoomData = { zoom: round2(detectZoom(), 2), system: system() };
124
+ return iszoom(zoomData);
85
125
  }
@@ -19,7 +19,7 @@ const pinYinFilter = (list, filterText, what) => {
19
19
  if (!_.isString(w)) {
20
20
  w = ''
21
21
  }
22
- return w.indexOf(filterText) > -1
22
+ return w.toLowerCase().indexOf(filterText) > -1
23
23
  })
24
24
  }
25
25