eoss-ui 0.5.73 → 0.5.75

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.
Files changed (75) hide show
  1. package/lib/button-group.js +115 -29
  2. package/lib/button.js +115 -29
  3. package/lib/checkbox-group.js +115 -29
  4. package/lib/clients.js +16 -7
  5. package/lib/data-table-form.js +115 -29
  6. package/lib/data-table.js +130 -35
  7. package/lib/date-picker.js +115 -29
  8. package/lib/dialog.js +115 -29
  9. package/lib/eoss-ui.common.js +345 -133
  10. package/lib/flow-group.js +115 -29
  11. package/lib/flow-list.js +115 -29
  12. package/lib/flow.js +115 -29
  13. package/lib/form.js +115 -29
  14. package/lib/handle-user.js +115 -29
  15. package/lib/handler.js +115 -29
  16. package/lib/index.js +1 -1
  17. package/lib/input-number.js +114 -28
  18. package/lib/input.js +131 -35
  19. package/lib/login.js +147 -40
  20. package/lib/main.js +197 -51
  21. package/lib/nav.js +163 -52
  22. package/lib/page.js +115 -29
  23. package/lib/player.js +115 -29
  24. package/lib/qr-code.js +115 -29
  25. package/lib/radio-group.js +115 -29
  26. package/lib/retrial-auth.js +115 -29
  27. package/lib/select-ganged.js +115 -29
  28. package/lib/select.js +130 -34
  29. package/lib/selector-panel.js +115 -29
  30. package/lib/selector.js +115 -29
  31. package/lib/sizer.js +115 -29
  32. package/lib/steps.js +115 -29
  33. package/lib/switch.js +114 -28
  34. package/lib/table-form.js +115 -29
  35. package/lib/tabs.js +115 -29
  36. package/lib/theme-chalk/base.css +1 -1
  37. package/lib/theme-chalk/index.css +1 -1
  38. package/lib/theme-chalk/login.css +1 -1
  39. package/lib/theme-chalk/main.css +1 -1
  40. package/lib/theme-chalk/menu.css +1 -1
  41. package/lib/theme-chalk/nav.css +1 -1
  42. package/lib/theme-chalk/sizer.css +1 -1
  43. package/lib/theme-chalk/upload.css +1 -1
  44. package/lib/tips.js +115 -29
  45. package/lib/tree-group.js +115 -29
  46. package/lib/tree.js +115 -29
  47. package/lib/upload.js +115 -29
  48. package/lib/utils/util.js +98 -22
  49. package/lib/utils/webSocket.js +16 -6
  50. package/lib/wujie.js +115 -29
  51. package/lib/wxlogin.js +114 -28
  52. package/package.json +2 -2
  53. package/packages/clients/src/main.vue +3 -1
  54. package/packages/data-table/src/main.vue +10 -1
  55. package/packages/input/src/main.vue +7 -6
  56. package/packages/login/src/main.vue +13 -0
  57. package/packages/login/src/resetPassword.vue +1 -1
  58. package/packages/main/src/main.vue +44 -10
  59. package/packages/nav/src/main.vue +25 -8
  60. package/packages/select/src/main.vue +6 -5
  61. package/packages/theme-chalk/lib/base.css +1 -1
  62. package/packages/theme-chalk/lib/index.css +1 -1
  63. package/packages/theme-chalk/lib/login.css +1 -1
  64. package/packages/theme-chalk/lib/main.css +1 -1
  65. package/packages/theme-chalk/lib/menu.css +1 -1
  66. package/packages/theme-chalk/lib/nav.css +1 -1
  67. package/packages/theme-chalk/lib/sizer.css +1 -1
  68. package/packages/theme-chalk/lib/upload.css +1 -1
  69. package/packages/theme-chalk/src/base.scss +3 -0
  70. package/packages/theme-chalk/src/login.scss +175 -171
  71. package/packages/theme-chalk/src/main.scss +5 -2
  72. package/packages/theme-chalk/src/nav.scss +4 -1
  73. package/src/index.js +1 -1
  74. package/src/utils/util.js +112 -23
  75. package/src/utils/webSocket.js +14 -7
package/lib/upload.js CHANGED
@@ -620,6 +620,35 @@ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
620
620
  return workdays;
621
621
  };
622
622
 
623
+ /**
624
+ * chunkToChinese
625
+ * @desc 将四位数的整数转换为中文大写
626
+ * @param {number} chunk - 数字
627
+ **/
628
+ function chunkToChinese(chunk) {
629
+ var numberToChinese = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
630
+ var capitalDigits = ['', '拾', '佰', '仟'];
631
+
632
+ var result = '';
633
+ var digitIndex = 0;
634
+
635
+ while (chunk > 0) {
636
+ var digit = chunk % 10;
637
+ if (digit > 0) {
638
+ result = numberToChinese[digit] + capitalDigits[digitIndex] + result;
639
+ } else {
640
+ // 当前数字是零,需要判断是否需要添加零
641
+ if (result.charAt(0) !== '零') {
642
+ result = '零' + result;
643
+ }
644
+ }
645
+ chunk = Math.floor(chunk / 10);
646
+ digitIndex++;
647
+ }
648
+
649
+ return result;
650
+ }
651
+
623
652
  /**
624
653
  * concatenate
625
654
  * @desc 指定连接符合并文本
@@ -1815,6 +1844,31 @@ var getWeekday = function getWeekday(date) {
1815
1844
  return adjustedDay === 0 ? 7 : adjustedDay;
1816
1845
  };
1817
1846
 
1847
+ /**
1848
+ * getZoom
1849
+ * @desc 获取缩放比
1850
+ * @param {number} n - 可选参数,表示星期的起始日,0 表示星期天,1 表示星期一,以此类推,默认为 0
1851
+ **/
1852
+ var getZoom = function getZoom() {
1853
+ var ratio = 0;
1854
+ var screen = window.screen;
1855
+ var ua = navigator.userAgent.toLowerCase();
1856
+ if (window.devicePixelRatio !== undefined) {
1857
+ ratio = window.devicePixelRatio;
1858
+ } else if (~ua.indexOf('msie')) {
1859
+ if (screen.deviceXDPI && screen.logicalXDPI) {
1860
+ ratio = screen.deviceXDPI / screen.logicalXDPI;
1861
+ }
1862
+ } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
1863
+ ratio = window.outerWidth / window.innerWidth;
1864
+ }
1865
+
1866
+ if (ratio) {
1867
+ ratio = Math.round(ratio * 100);
1868
+ }
1869
+
1870
+ return ratio / 100;
1871
+ };
1818
1872
  /**
1819
1873
  * handlerUrl
1820
1874
  * @desc:更新url参数中的时间戳
@@ -2557,32 +2611,53 @@ var rmbToCapital = function rmbToCapital(number) {
2557
2611
 
2558
2612
  return result;
2559
2613
  };
2560
-
2561
- // 辅助函数,将四位数的整数转换为中文大写
2562
- function chunkToChinese(chunk) {
2563
- var numberToChinese = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
2564
- var capitalDigits = ['', '拾', '佰', '仟'];
2565
-
2566
- var result = '';
2567
- var digitIndex = 0;
2568
-
2569
- while (chunk > 0) {
2570
- var digit = chunk % 10;
2571
- if (digit > 0) {
2572
- result = numberToChinese[digit] + capitalDigits[digitIndex] + result;
2614
+ /**
2615
+ * setScale
2616
+ * @desc 设置缩放
2617
+ * @param {number} width - 分辨率宽度
2618
+ * @param {number} height - 分辨率高度
2619
+ **/
2620
+ var setScale = function setScale() {
2621
+ var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1920;
2622
+ var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1080;
2623
+
2624
+ var n = 1;
2625
+ var isMac = /macintosh|mac os x/i.test(navigator.userAgent);
2626
+ var zoom = getZoom();
2627
+ if (isMac) {
2628
+ n = 2;
2629
+ } else {
2630
+ n = 1;
2631
+ }
2632
+ if (zoom === 1) {
2633
+ document.body.style.removeProperty('transform');
2634
+ document.body.style.removeProperty('width');
2635
+ document.body.style.removeProperty('height');
2636
+ document.body.style.removeProperty('transform-origin');
2637
+ return;
2638
+ }
2639
+ if (Math.abs(parseInt(width - window.innerWidth * zoom / n, 10)) > 15 && window.innerWidth * zoom / n !== width) {
2640
+ var scale = 'scale(' + window.innerWidth * zoom / width / zoom + ',' + window.innerHeight * zoom / height / zoom + ')';
2641
+ document.body.style.transform = scale;
2642
+ document.body.style.width = width + 'px';
2643
+ document.body.style.height = height + 'px';
2644
+ document.body.style.transformOrigin = '0 0';
2645
+ } else {
2646
+ if (isMac) {
2647
+ var _scale = 'scale(' + 1 * n / zoom + ')';
2648
+ document.body.style.transform = _scale;
2649
+ document.body.style.width = parseInt(window.innerWidth * zoom / n, 10) + 'px';
2650
+ document.body.style.height = parseInt(window.innerHeight * zoom / n, 10) + 'px';
2651
+ document.body.style.transformOrigin = '0 0';
2573
2652
  } else {
2574
- // 当前数字是零,需要判断是否需要添加零
2575
- if (result.charAt(0) !== '零') {
2576
- result = '零' + result;
2577
- }
2653
+ var _scale2 = 'scale(' + 1 * n / zoom + ')';
2654
+ document.body.style.transform = _scale2;
2655
+ document.body.style.width = parseInt(window.innerWidth * zoom / n, 10) + 'px';
2656
+ document.body.style.height = parseInt(window.innerHeight * zoom / n, 10) + 'px';
2657
+ document.body.style.transformOrigin = '0 0';
2578
2658
  }
2579
- chunk = Math.floor(chunk / 10);
2580
- digitIndex++;
2581
2659
  }
2582
-
2583
- return result;
2584
- }
2585
-
2660
+ };
2586
2661
  /**
2587
2662
  * sendMessage
2588
2663
  * @desc:向iframe发送信息
@@ -3118,6 +3193,7 @@ var watermark = function watermark(option) {
3118
3193
  rmbToCapital: rmbToCapital,
3119
3194
  sendMessage: sendMessage,
3120
3195
  setFavicon: setFavicon,
3196
+ setScale: setScale,
3121
3197
  setStorage: setStorage,
3122
3198
  socket: socket,
3123
3199
  startWith: startWith,
@@ -3643,6 +3719,8 @@ var WebSocket = function () {
3643
3719
  this.connects = 1;
3644
3720
  this.recon = false;
3645
3721
  this.sendTimeout = null;
3722
+ this.socket = null;
3723
+ this.subscription = null;
3646
3724
  }
3647
3725
 
3648
3726
  /** socket连接 */
@@ -3653,14 +3731,12 @@ var WebSocket = function () {
3653
3731
 
3654
3732
  if (!this.client) {
3655
3733
  // 连接SockJS
3656
- var socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url);
3657
- // 获取STOMP子协议的客户端对象
3658
- this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(socket);
3734
+ this.socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url, { timeout: 60000 });
3735
+ this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(this.socket);
3659
3736
  }
3660
3737
 
3661
3738
  // 日志不打印
3662
3739
  if (!this.debug) {
3663
- console.log(111);
3664
3740
  this.client.debug = function () {};
3665
3741
  }
3666
3742
 
@@ -3672,9 +3748,10 @@ var WebSocket = function () {
3672
3748
  // 订阅消息
3673
3749
  _this.subscribe();
3674
3750
  }, function (error) {
3751
+ _this.unsubscribe();
3752
+ _this.client = null;
3675
3753
  var diffSecond = parseInt((new Date() - _this.nextDate) / 1000, 10);
3676
3754
  if (_this.connects > 5 && diffSecond < _this.interval) {
3677
- _this.client.disconnect();
3678
3755
  _this.error && _this.error(error);
3679
3756
  } else {
3680
3757
  _this.reconTimeout = setTimeout(function () {
@@ -3683,6 +3760,14 @@ var WebSocket = function () {
3683
3760
  }, 5000);
3684
3761
  }
3685
3762
  });
3763
+ }; // 清除订阅
3764
+
3765
+
3766
+ WebSocket.prototype.unsubscribe = function unsubscribe() {
3767
+ if (this.subscription) {
3768
+ this.subscription.unsubscribe();
3769
+ this.subscription = null;
3770
+ }
3686
3771
  };
3687
3772
  /** 订阅服务端 */
3688
3773
 
@@ -3691,7 +3776,7 @@ var WebSocket = function () {
3691
3776
  var _this2 = this;
3692
3777
 
3693
3778
  // 订阅服务端提供的某个topic
3694
- this.client.subscribe(this.take, function (response) {
3779
+ this.subscription = this.client.subscribe(this.take, function (response) {
3695
3780
  if (response && (_this2.callback || _this2.success)) {
3696
3781
  var callback = _this2.callback || _this2.success;
3697
3782
  callback(JSON.parse(response.body));
@@ -3732,6 +3817,7 @@ var WebSocket = function () {
3732
3817
 
3733
3818
  WebSocket.prototype.destroy = function destroy() {
3734
3819
  // 断开连接,清除定时器
3820
+ this.unsubscribe();
3735
3821
  if (this.client) {
3736
3822
  this.client.disconnect();
3737
3823
  };
package/lib/utils/util.js CHANGED
@@ -538,6 +538,35 @@ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
538
538
  return workdays;
539
539
  };
540
540
 
541
+ /**
542
+ * chunkToChinese
543
+ * @desc 将四位数的整数转换为中文大写
544
+ * @param {number} chunk - 数字
545
+ **/
546
+ function chunkToChinese(chunk) {
547
+ var numberToChinese = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
548
+ var capitalDigits = ['', '拾', '佰', '仟'];
549
+
550
+ var result = '';
551
+ var digitIndex = 0;
552
+
553
+ while (chunk > 0) {
554
+ var digit = chunk % 10;
555
+ if (digit > 0) {
556
+ result = numberToChinese[digit] + capitalDigits[digitIndex] + result;
557
+ } else {
558
+ // 当前数字是零,需要判断是否需要添加零
559
+ if (result.charAt(0) !== '零') {
560
+ result = '零' + result;
561
+ }
562
+ }
563
+ chunk = Math.floor(chunk / 10);
564
+ digitIndex++;
565
+ }
566
+
567
+ return result;
568
+ }
569
+
541
570
  /**
542
571
  * concatenate
543
572
  * @desc 指定连接符合并文本
@@ -1733,6 +1762,31 @@ var getWeekday = function getWeekday(date) {
1733
1762
  return adjustedDay === 0 ? 7 : adjustedDay;
1734
1763
  };
1735
1764
 
1765
+ /**
1766
+ * getZoom
1767
+ * @desc 获取缩放比
1768
+ * @param {number} n - 可选参数,表示星期的起始日,0 表示星期天,1 表示星期一,以此类推,默认为 0
1769
+ **/
1770
+ var getZoom = function getZoom() {
1771
+ var ratio = 0;
1772
+ var screen = window.screen;
1773
+ var ua = navigator.userAgent.toLowerCase();
1774
+ if (window.devicePixelRatio !== undefined) {
1775
+ ratio = window.devicePixelRatio;
1776
+ } else if (~ua.indexOf('msie')) {
1777
+ if (screen.deviceXDPI && screen.logicalXDPI) {
1778
+ ratio = screen.deviceXDPI / screen.logicalXDPI;
1779
+ }
1780
+ } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
1781
+ ratio = window.outerWidth / window.innerWidth;
1782
+ }
1783
+
1784
+ if (ratio) {
1785
+ ratio = Math.round(ratio * 100);
1786
+ }
1787
+
1788
+ return ratio / 100;
1789
+ };
1736
1790
  /**
1737
1791
  * handlerUrl
1738
1792
  * @desc:更新url参数中的时间戳
@@ -2475,32 +2529,53 @@ var rmbToCapital = function rmbToCapital(number) {
2475
2529
 
2476
2530
  return result;
2477
2531
  };
2532
+ /**
2533
+ * setScale
2534
+ * @desc 设置缩放
2535
+ * @param {number} width - 分辨率宽度
2536
+ * @param {number} height - 分辨率高度
2537
+ **/
2538
+ var setScale = function setScale() {
2539
+ var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1920;
2540
+ var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1080;
2478
2541
 
2479
- // 辅助函数,将四位数的整数转换为中文大写
2480
- function chunkToChinese(chunk) {
2481
- var numberToChinese = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
2482
- var capitalDigits = ['', '拾', '佰', '仟'];
2483
-
2484
- var result = '';
2485
- var digitIndex = 0;
2486
-
2487
- while (chunk > 0) {
2488
- var digit = chunk % 10;
2489
- if (digit > 0) {
2490
- result = numberToChinese[digit] + capitalDigits[digitIndex] + result;
2542
+ var n = 1;
2543
+ var isMac = /macintosh|mac os x/i.test(navigator.userAgent);
2544
+ var zoom = getZoom();
2545
+ if (isMac) {
2546
+ n = 2;
2547
+ } else {
2548
+ n = 1;
2549
+ }
2550
+ if (zoom === 1) {
2551
+ document.body.style.removeProperty('transform');
2552
+ document.body.style.removeProperty('width');
2553
+ document.body.style.removeProperty('height');
2554
+ document.body.style.removeProperty('transform-origin');
2555
+ return;
2556
+ }
2557
+ if (Math.abs(parseInt(width - window.innerWidth * zoom / n, 10)) > 15 && window.innerWidth * zoom / n !== width) {
2558
+ var scale = 'scale(' + window.innerWidth * zoom / width / zoom + ',' + window.innerHeight * zoom / height / zoom + ')';
2559
+ document.body.style.transform = scale;
2560
+ document.body.style.width = width + 'px';
2561
+ document.body.style.height = height + 'px';
2562
+ document.body.style.transformOrigin = '0 0';
2563
+ } else {
2564
+ if (isMac) {
2565
+ var _scale = 'scale(' + 1 * n / zoom + ')';
2566
+ document.body.style.transform = _scale;
2567
+ document.body.style.width = parseInt(window.innerWidth * zoom / n, 10) + 'px';
2568
+ document.body.style.height = parseInt(window.innerHeight * zoom / n, 10) + 'px';
2569
+ document.body.style.transformOrigin = '0 0';
2491
2570
  } else {
2492
- // 当前数字是零,需要判断是否需要添加零
2493
- if (result.charAt(0) !== '零') {
2494
- result = '零' + result;
2495
- }
2571
+ var _scale2 = 'scale(' + 1 * n / zoom + ')';
2572
+ document.body.style.transform = _scale2;
2573
+ document.body.style.width = parseInt(window.innerWidth * zoom / n, 10) + 'px';
2574
+ document.body.style.height = parseInt(window.innerHeight * zoom / n, 10) + 'px';
2575
+ document.body.style.transformOrigin = '0 0';
2496
2576
  }
2497
- chunk = Math.floor(chunk / 10);
2498
- digitIndex++;
2499
2577
  }
2500
-
2501
- return result;
2502
- }
2503
-
2578
+ };
2504
2579
  /**
2505
2580
  * sendMessage
2506
2581
  * @desc:向iframe发送信息
@@ -3036,6 +3111,7 @@ exports.default = {
3036
3111
  rmbToCapital: rmbToCapital,
3037
3112
  sendMessage: sendMessage,
3038
3113
  setFavicon: setFavicon,
3114
+ setScale: setScale,
3039
3115
  setStorage: setStorage,
3040
3116
  socket: socket,
3041
3117
  startWith: startWith,
@@ -29,6 +29,8 @@ var WebSocket = function () {
29
29
  this.connects = 1;
30
30
  this.recon = false;
31
31
  this.sendTimeout = null;
32
+ this.socket = null;
33
+ this.subscription = null;
32
34
  }
33
35
 
34
36
  /** socket连接 */
@@ -39,14 +41,12 @@ var WebSocket = function () {
39
41
 
40
42
  if (!this.client) {
41
43
  // 连接SockJS
42
- var socket = new _sockjsClient2.default(this.host + this.url);
43
- // 获取STOMP子协议的客户端对象
44
- this.client = _stompjs2.default.over(socket);
44
+ this.socket = new _sockjsClient2.default(this.host + this.url, { timeout: 60000 });
45
+ this.client = _stompjs2.default.over(this.socket);
45
46
  }
46
47
 
47
48
  // 日志不打印
48
49
  if (!this.debug) {
49
- console.log(111);
50
50
  this.client.debug = function () {};
51
51
  }
52
52
 
@@ -58,9 +58,10 @@ var WebSocket = function () {
58
58
  // 订阅消息
59
59
  _this.subscribe();
60
60
  }, function (error) {
61
+ _this.unsubscribe();
62
+ _this.client = null;
61
63
  var diffSecond = parseInt((new Date() - _this.nextDate) / 1000, 10);
62
64
  if (_this.connects > 5 && diffSecond < _this.interval) {
63
- _this.client.disconnect();
64
65
  _this.error && _this.error(error);
65
66
  } else {
66
67
  _this.reconTimeout = setTimeout(function () {
@@ -69,6 +70,14 @@ var WebSocket = function () {
69
70
  }, 5000);
70
71
  }
71
72
  });
73
+ }; // 清除订阅
74
+
75
+
76
+ WebSocket.prototype.unsubscribe = function unsubscribe() {
77
+ if (this.subscription) {
78
+ this.subscription.unsubscribe();
79
+ this.subscription = null;
80
+ }
72
81
  };
73
82
  /** 订阅服务端 */
74
83
 
@@ -77,7 +86,7 @@ var WebSocket = function () {
77
86
  var _this2 = this;
78
87
 
79
88
  // 订阅服务端提供的某个topic
80
- this.client.subscribe(this.take, function (response) {
89
+ this.subscription = this.client.subscribe(this.take, function (response) {
81
90
  if (response && (_this2.callback || _this2.success)) {
82
91
  var callback = _this2.callback || _this2.success;
83
92
  callback(JSON.parse(response.body));
@@ -118,6 +127,7 @@ var WebSocket = function () {
118
127
 
119
128
  WebSocket.prototype.destroy = function destroy() {
120
129
  // 断开连接,清除定时器
130
+ this.unsubscribe();
121
131
  if (this.client) {
122
132
  this.client.disconnect();
123
133
  };
package/lib/wujie.js CHANGED
@@ -621,6 +621,35 @@ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
621
621
  return workdays;
622
622
  };
623
623
 
624
+ /**
625
+ * chunkToChinese
626
+ * @desc 将四位数的整数转换为中文大写
627
+ * @param {number} chunk - 数字
628
+ **/
629
+ function chunkToChinese(chunk) {
630
+ var numberToChinese = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
631
+ var capitalDigits = ['', '拾', '佰', '仟'];
632
+
633
+ var result = '';
634
+ var digitIndex = 0;
635
+
636
+ while (chunk > 0) {
637
+ var digit = chunk % 10;
638
+ if (digit > 0) {
639
+ result = numberToChinese[digit] + capitalDigits[digitIndex] + result;
640
+ } else {
641
+ // 当前数字是零,需要判断是否需要添加零
642
+ if (result.charAt(0) !== '零') {
643
+ result = '零' + result;
644
+ }
645
+ }
646
+ chunk = Math.floor(chunk / 10);
647
+ digitIndex++;
648
+ }
649
+
650
+ return result;
651
+ }
652
+
624
653
  /**
625
654
  * concatenate
626
655
  * @desc 指定连接符合并文本
@@ -1816,6 +1845,31 @@ var getWeekday = function getWeekday(date) {
1816
1845
  return adjustedDay === 0 ? 7 : adjustedDay;
1817
1846
  };
1818
1847
 
1848
+ /**
1849
+ * getZoom
1850
+ * @desc 获取缩放比
1851
+ * @param {number} n - 可选参数,表示星期的起始日,0 表示星期天,1 表示星期一,以此类推,默认为 0
1852
+ **/
1853
+ var getZoom = function getZoom() {
1854
+ var ratio = 0;
1855
+ var screen = window.screen;
1856
+ var ua = navigator.userAgent.toLowerCase();
1857
+ if (window.devicePixelRatio !== undefined) {
1858
+ ratio = window.devicePixelRatio;
1859
+ } else if (~ua.indexOf('msie')) {
1860
+ if (screen.deviceXDPI && screen.logicalXDPI) {
1861
+ ratio = screen.deviceXDPI / screen.logicalXDPI;
1862
+ }
1863
+ } else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
1864
+ ratio = window.outerWidth / window.innerWidth;
1865
+ }
1866
+
1867
+ if (ratio) {
1868
+ ratio = Math.round(ratio * 100);
1869
+ }
1870
+
1871
+ return ratio / 100;
1872
+ };
1819
1873
  /**
1820
1874
  * handlerUrl
1821
1875
  * @desc:更新url参数中的时间戳
@@ -2558,32 +2612,53 @@ var rmbToCapital = function rmbToCapital(number) {
2558
2612
 
2559
2613
  return result;
2560
2614
  };
2561
-
2562
- // 辅助函数,将四位数的整数转换为中文大写
2563
- function chunkToChinese(chunk) {
2564
- var numberToChinese = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
2565
- var capitalDigits = ['', '拾', '佰', '仟'];
2566
-
2567
- var result = '';
2568
- var digitIndex = 0;
2569
-
2570
- while (chunk > 0) {
2571
- var digit = chunk % 10;
2572
- if (digit > 0) {
2573
- result = numberToChinese[digit] + capitalDigits[digitIndex] + result;
2615
+ /**
2616
+ * setScale
2617
+ * @desc 设置缩放
2618
+ * @param {number} width - 分辨率宽度
2619
+ * @param {number} height - 分辨率高度
2620
+ **/
2621
+ var setScale = function setScale() {
2622
+ var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1920;
2623
+ var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1080;
2624
+
2625
+ var n = 1;
2626
+ var isMac = /macintosh|mac os x/i.test(navigator.userAgent);
2627
+ var zoom = getZoom();
2628
+ if (isMac) {
2629
+ n = 2;
2630
+ } else {
2631
+ n = 1;
2632
+ }
2633
+ if (zoom === 1) {
2634
+ document.body.style.removeProperty('transform');
2635
+ document.body.style.removeProperty('width');
2636
+ document.body.style.removeProperty('height');
2637
+ document.body.style.removeProperty('transform-origin');
2638
+ return;
2639
+ }
2640
+ if (Math.abs(parseInt(width - window.innerWidth * zoom / n, 10)) > 15 && window.innerWidth * zoom / n !== width) {
2641
+ var scale = 'scale(' + window.innerWidth * zoom / width / zoom + ',' + window.innerHeight * zoom / height / zoom + ')';
2642
+ document.body.style.transform = scale;
2643
+ document.body.style.width = width + 'px';
2644
+ document.body.style.height = height + 'px';
2645
+ document.body.style.transformOrigin = '0 0';
2646
+ } else {
2647
+ if (isMac) {
2648
+ var _scale = 'scale(' + 1 * n / zoom + ')';
2649
+ document.body.style.transform = _scale;
2650
+ document.body.style.width = parseInt(window.innerWidth * zoom / n, 10) + 'px';
2651
+ document.body.style.height = parseInt(window.innerHeight * zoom / n, 10) + 'px';
2652
+ document.body.style.transformOrigin = '0 0';
2574
2653
  } else {
2575
- // 当前数字是零,需要判断是否需要添加零
2576
- if (result.charAt(0) !== '零') {
2577
- result = '零' + result;
2578
- }
2654
+ var _scale2 = 'scale(' + 1 * n / zoom + ')';
2655
+ document.body.style.transform = _scale2;
2656
+ document.body.style.width = parseInt(window.innerWidth * zoom / n, 10) + 'px';
2657
+ document.body.style.height = parseInt(window.innerHeight * zoom / n, 10) + 'px';
2658
+ document.body.style.transformOrigin = '0 0';
2579
2659
  }
2580
- chunk = Math.floor(chunk / 10);
2581
- digitIndex++;
2582
2660
  }
2583
-
2584
- return result;
2585
- }
2586
-
2661
+ };
2587
2662
  /**
2588
2663
  * sendMessage
2589
2664
  * @desc:向iframe发送信息
@@ -3119,6 +3194,7 @@ var watermark = function watermark(option) {
3119
3194
  rmbToCapital: rmbToCapital,
3120
3195
  sendMessage: sendMessage,
3121
3196
  setFavicon: setFavicon,
3197
+ setScale: setScale,
3122
3198
  setStorage: setStorage,
3123
3199
  socket: socket,
3124
3200
  startWith: startWith,
@@ -3893,6 +3969,8 @@ var WebSocket = function () {
3893
3969
  this.connects = 1;
3894
3970
  this.recon = false;
3895
3971
  this.sendTimeout = null;
3972
+ this.socket = null;
3973
+ this.subscription = null;
3896
3974
  }
3897
3975
 
3898
3976
  /** socket连接 */
@@ -3903,14 +3981,12 @@ var WebSocket = function () {
3903
3981
 
3904
3982
  if (!this.client) {
3905
3983
  // 连接SockJS
3906
- var socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url);
3907
- // 获取STOMP子协议的客户端对象
3908
- this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(socket);
3984
+ this.socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url, { timeout: 60000 });
3985
+ this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(this.socket);
3909
3986
  }
3910
3987
 
3911
3988
  // 日志不打印
3912
3989
  if (!this.debug) {
3913
- console.log(111);
3914
3990
  this.client.debug = function () {};
3915
3991
  }
3916
3992
 
@@ -3922,9 +3998,10 @@ var WebSocket = function () {
3922
3998
  // 订阅消息
3923
3999
  _this.subscribe();
3924
4000
  }, function (error) {
4001
+ _this.unsubscribe();
4002
+ _this.client = null;
3925
4003
  var diffSecond = parseInt((new Date() - _this.nextDate) / 1000, 10);
3926
4004
  if (_this.connects > 5 && diffSecond < _this.interval) {
3927
- _this.client.disconnect();
3928
4005
  _this.error && _this.error(error);
3929
4006
  } else {
3930
4007
  _this.reconTimeout = setTimeout(function () {
@@ -3933,6 +4010,14 @@ var WebSocket = function () {
3933
4010
  }, 5000);
3934
4011
  }
3935
4012
  });
4013
+ }; // 清除订阅
4014
+
4015
+
4016
+ WebSocket.prototype.unsubscribe = function unsubscribe() {
4017
+ if (this.subscription) {
4018
+ this.subscription.unsubscribe();
4019
+ this.subscription = null;
4020
+ }
3936
4021
  };
3937
4022
  /** 订阅服务端 */
3938
4023
 
@@ -3941,7 +4026,7 @@ var WebSocket = function () {
3941
4026
  var _this2 = this;
3942
4027
 
3943
4028
  // 订阅服务端提供的某个topic
3944
- this.client.subscribe(this.take, function (response) {
4029
+ this.subscription = this.client.subscribe(this.take, function (response) {
3945
4030
  if (response && (_this2.callback || _this2.success)) {
3946
4031
  var callback = _this2.callback || _this2.success;
3947
4032
  callback(JSON.parse(response.body));
@@ -3982,6 +4067,7 @@ var WebSocket = function () {
3982
4067
 
3983
4068
  WebSocket.prototype.destroy = function destroy() {
3984
4069
  // 断开连接,清除定时器
4070
+ this.unsubscribe();
3985
4071
  if (this.client) {
3986
4072
  this.client.disconnect();
3987
4073
  };