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/selector.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,
@@ -4867,6 +4943,8 @@ var WebSocket = function () {
4867
4943
  this.connects = 1;
4868
4944
  this.recon = false;
4869
4945
  this.sendTimeout = null;
4946
+ this.socket = null;
4947
+ this.subscription = null;
4870
4948
  }
4871
4949
 
4872
4950
  /** socket连接 */
@@ -4877,14 +4955,12 @@ var WebSocket = function () {
4877
4955
 
4878
4956
  if (!this.client) {
4879
4957
  // 连接SockJS
4880
- var socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url);
4881
- // 获取STOMP子协议的客户端对象
4882
- this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(socket);
4958
+ this.socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url, { timeout: 60000 });
4959
+ this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(this.socket);
4883
4960
  }
4884
4961
 
4885
4962
  // 日志不打印
4886
4963
  if (!this.debug) {
4887
- console.log(111);
4888
4964
  this.client.debug = function () {};
4889
4965
  }
4890
4966
 
@@ -4896,9 +4972,10 @@ var WebSocket = function () {
4896
4972
  // 订阅消息
4897
4973
  _this.subscribe();
4898
4974
  }, function (error) {
4975
+ _this.unsubscribe();
4976
+ _this.client = null;
4899
4977
  var diffSecond = parseInt((new Date() - _this.nextDate) / 1000, 10);
4900
4978
  if (_this.connects > 5 && diffSecond < _this.interval) {
4901
- _this.client.disconnect();
4902
4979
  _this.error && _this.error(error);
4903
4980
  } else {
4904
4981
  _this.reconTimeout = setTimeout(function () {
@@ -4907,6 +4984,14 @@ var WebSocket = function () {
4907
4984
  }, 5000);
4908
4985
  }
4909
4986
  });
4987
+ }; // 清除订阅
4988
+
4989
+
4990
+ WebSocket.prototype.unsubscribe = function unsubscribe() {
4991
+ if (this.subscription) {
4992
+ this.subscription.unsubscribe();
4993
+ this.subscription = null;
4994
+ }
4910
4995
  };
4911
4996
  /** 订阅服务端 */
4912
4997
 
@@ -4915,7 +5000,7 @@ var WebSocket = function () {
4915
5000
  var _this2 = this;
4916
5001
 
4917
5002
  // 订阅服务端提供的某个topic
4918
- this.client.subscribe(this.take, function (response) {
5003
+ this.subscription = this.client.subscribe(this.take, function (response) {
4919
5004
  if (response && (_this2.callback || _this2.success)) {
4920
5005
  var callback = _this2.callback || _this2.success;
4921
5006
  callback(JSON.parse(response.body));
@@ -4956,6 +5041,7 @@ var WebSocket = function () {
4956
5041
 
4957
5042
  WebSocket.prototype.destroy = function destroy() {
4958
5043
  // 断开连接,清除定时器
5044
+ this.unsubscribe();
4959
5045
  if (this.client) {
4960
5046
  this.client.disconnect();
4961
5047
  };
package/lib/sizer.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,
@@ -4115,6 +4191,8 @@ var WebSocket = function () {
4115
4191
  this.connects = 1;
4116
4192
  this.recon = false;
4117
4193
  this.sendTimeout = null;
4194
+ this.socket = null;
4195
+ this.subscription = null;
4118
4196
  }
4119
4197
 
4120
4198
  /** socket连接 */
@@ -4125,14 +4203,12 @@ var WebSocket = function () {
4125
4203
 
4126
4204
  if (!this.client) {
4127
4205
  // 连接SockJS
4128
- var socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url);
4129
- // 获取STOMP子协议的客户端对象
4130
- this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(socket);
4206
+ this.socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url, { timeout: 60000 });
4207
+ this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(this.socket);
4131
4208
  }
4132
4209
 
4133
4210
  // 日志不打印
4134
4211
  if (!this.debug) {
4135
- console.log(111);
4136
4212
  this.client.debug = function () {};
4137
4213
  }
4138
4214
 
@@ -4144,9 +4220,10 @@ var WebSocket = function () {
4144
4220
  // 订阅消息
4145
4221
  _this.subscribe();
4146
4222
  }, function (error) {
4223
+ _this.unsubscribe();
4224
+ _this.client = null;
4147
4225
  var diffSecond = parseInt((new Date() - _this.nextDate) / 1000, 10);
4148
4226
  if (_this.connects > 5 && diffSecond < _this.interval) {
4149
- _this.client.disconnect();
4150
4227
  _this.error && _this.error(error);
4151
4228
  } else {
4152
4229
  _this.reconTimeout = setTimeout(function () {
@@ -4155,6 +4232,14 @@ var WebSocket = function () {
4155
4232
  }, 5000);
4156
4233
  }
4157
4234
  });
4235
+ }; // 清除订阅
4236
+
4237
+
4238
+ WebSocket.prototype.unsubscribe = function unsubscribe() {
4239
+ if (this.subscription) {
4240
+ this.subscription.unsubscribe();
4241
+ this.subscription = null;
4242
+ }
4158
4243
  };
4159
4244
  /** 订阅服务端 */
4160
4245
 
@@ -4163,7 +4248,7 @@ var WebSocket = function () {
4163
4248
  var _this2 = this;
4164
4249
 
4165
4250
  // 订阅服务端提供的某个topic
4166
- this.client.subscribe(this.take, function (response) {
4251
+ this.subscription = this.client.subscribe(this.take, function (response) {
4167
4252
  if (response && (_this2.callback || _this2.success)) {
4168
4253
  var callback = _this2.callback || _this2.success;
4169
4254
  callback(JSON.parse(response.body));
@@ -4204,6 +4289,7 @@ var WebSocket = function () {
4204
4289
 
4205
4290
  WebSocket.prototype.destroy = function destroy() {
4206
4291
  // 断开连接,清除定时器
4292
+ this.unsubscribe();
4207
4293
  if (this.client) {
4208
4294
  this.client.disconnect();
4209
4295
  };
package/lib/steps.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,
@@ -4009,6 +4085,8 @@ var WebSocket = function () {
4009
4085
  this.connects = 1;
4010
4086
  this.recon = false;
4011
4087
  this.sendTimeout = null;
4088
+ this.socket = null;
4089
+ this.subscription = null;
4012
4090
  }
4013
4091
 
4014
4092
  /** socket连接 */
@@ -4019,14 +4097,12 @@ var WebSocket = function () {
4019
4097
 
4020
4098
  if (!this.client) {
4021
4099
  // 连接SockJS
4022
- var socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url);
4023
- // 获取STOMP子协议的客户端对象
4024
- this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(socket);
4100
+ this.socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url, { timeout: 60000 });
4101
+ this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(this.socket);
4025
4102
  }
4026
4103
 
4027
4104
  // 日志不打印
4028
4105
  if (!this.debug) {
4029
- console.log(111);
4030
4106
  this.client.debug = function () {};
4031
4107
  }
4032
4108
 
@@ -4038,9 +4114,10 @@ var WebSocket = function () {
4038
4114
  // 订阅消息
4039
4115
  _this.subscribe();
4040
4116
  }, function (error) {
4117
+ _this.unsubscribe();
4118
+ _this.client = null;
4041
4119
  var diffSecond = parseInt((new Date() - _this.nextDate) / 1000, 10);
4042
4120
  if (_this.connects > 5 && diffSecond < _this.interval) {
4043
- _this.client.disconnect();
4044
4121
  _this.error && _this.error(error);
4045
4122
  } else {
4046
4123
  _this.reconTimeout = setTimeout(function () {
@@ -4049,6 +4126,14 @@ var WebSocket = function () {
4049
4126
  }, 5000);
4050
4127
  }
4051
4128
  });
4129
+ }; // 清除订阅
4130
+
4131
+
4132
+ WebSocket.prototype.unsubscribe = function unsubscribe() {
4133
+ if (this.subscription) {
4134
+ this.subscription.unsubscribe();
4135
+ this.subscription = null;
4136
+ }
4052
4137
  };
4053
4138
  /** 订阅服务端 */
4054
4139
 
@@ -4057,7 +4142,7 @@ var WebSocket = function () {
4057
4142
  var _this2 = this;
4058
4143
 
4059
4144
  // 订阅服务端提供的某个topic
4060
- this.client.subscribe(this.take, function (response) {
4145
+ this.subscription = this.client.subscribe(this.take, function (response) {
4061
4146
  if (response && (_this2.callback || _this2.success)) {
4062
4147
  var callback = _this2.callback || _this2.success;
4063
4148
  callback(JSON.parse(response.body));
@@ -4098,6 +4183,7 @@ var WebSocket = function () {
4098
4183
 
4099
4184
  WebSocket.prototype.destroy = function destroy() {
4100
4185
  // 断开连接,清除定时器
4186
+ this.unsubscribe();
4101
4187
  if (this.client) {
4102
4188
  this.client.disconnect();
4103
4189
  };