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/nav.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,
@@ -3495,6 +3571,13 @@ module.exports = require("sm-crypto");
3495
3571
 
3496
3572
  /***/ }),
3497
3573
 
3574
+ /***/ 11:
3575
+ /***/ (function(module, exports) {
3576
+
3577
+ module.exports = require("throttle-debounce");
3578
+
3579
+ /***/ }),
3580
+
3498
3581
  /***/ 2:
3499
3582
  /***/ (function(module, exports) {
3500
3583
 
@@ -3628,7 +3711,7 @@ module.exports = require("axios");
3628
3711
  // ESM COMPAT FLAG
3629
3712
  __webpack_require__.r(__webpack_exports__);
3630
3713
 
3631
- // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/nav/src/main.vue?vue&type=template&id=7b4319fb&
3714
+ // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/nav/src/main.vue?vue&type=template&id=ccb38c80&
3632
3715
  var render = function () {
3633
3716
  var _vm = this
3634
3717
  var _h = _vm.$createElement
@@ -3692,15 +3775,15 @@ var render = function () {
3692
3775
  {
3693
3776
  name: "show",
3694
3777
  rawName: "v-show",
3695
- value: _vm.biserial ? _vm.subMenu.length : _vm.menu.length,
3696
- expression: "biserial ? subMenu.length : menu.length",
3778
+ value: _vm.showMenu,
3779
+ expression: "showMenu",
3697
3780
  },
3698
3781
  ],
3699
3782
  staticClass: "es-nav-main",
3700
3783
  class: { "es-nav-overlap": _vm.overlap },
3701
3784
  style: {
3702
3785
  width: _vm.biserial ? _vm.width : _vm.boxWidth,
3703
- left: _vm.show ? "15px" : _vm.navWidth,
3786
+ left: _vm.biserial ? (_vm.show ? "15px" : _vm.navWidth) : "",
3704
3787
  },
3705
3788
  attrs: { biserial: _vm.biserial },
3706
3789
  },
@@ -3819,11 +3902,14 @@ var staticRenderFns = []
3819
3902
  render._withStripped = true
3820
3903
 
3821
3904
 
3822
- // CONCATENATED MODULE: ./packages/nav/src/main.vue?vue&type=template&id=7b4319fb&
3905
+ // CONCATENATED MODULE: ./packages/nav/src/main.vue?vue&type=template&id=ccb38c80&
3823
3906
 
3824
3907
  // EXTERNAL MODULE: ./src/utils/util.js
3825
3908
  var util = __webpack_require__(0);
3826
3909
 
3910
+ // EXTERNAL MODULE: external "throttle-debounce"
3911
+ var external_throttle_debounce_ = __webpack_require__(11);
3912
+
3827
3913
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/nav/src/main.vue?vue&type=script&lang=js&
3828
3914
  //
3829
3915
  //
@@ -3918,6 +4004,7 @@ var util = __webpack_require__(0);
3918
4004
  //
3919
4005
 
3920
4006
 
4007
+
3921
4008
  /* harmony default export */ var mainvue_type_script_lang_js_ = ({
3922
4009
  name: 'EsNav',
3923
4010
  inheritAttrs: false,
@@ -3958,7 +4045,9 @@ var util = __webpack_require__(0);
3958
4045
  type: Boolean,
3959
4046
  default: true
3960
4047
  },
3961
- overlap: Boolean
4048
+ overlap: Boolean,
4049
+ //隐藏菜单
4050
+ hideSubMenu: Boolean
3962
4051
  },
3963
4052
  computed: {
3964
4053
  show: function show() {
@@ -3995,7 +4084,7 @@ var util = __webpack_require__(0);
3995
4084
  return this.navWidth;
3996
4085
  }
3997
4086
  }
3998
- return this.subMenu && this.subMenu.length && this.isShow && !this.overlap ? parseInt(this.width, 10) + parseInt(this.navWidth, 10) + 'px' : this.navWidth;
4087
+ return this.subMenu && this.subMenu.length && this.isShow && !this.overlap && !this.hideSubMenu ? parseInt(this.width, 10) + parseInt(this.navWidth, 10) + 'px' : this.navWidth;
3999
4088
  },
4000
4089
  _navWidth: function _navWidth() {
4001
4090
  return this.overlap ? parseInt(this.navWidth, 10) - 30 + 'px' : this.navWidth;
@@ -4010,11 +4099,14 @@ var util = __webpack_require__(0);
4010
4099
  this.headline = val;
4011
4100
  }
4012
4101
  },
4102
+ boxWidth: function boxWidth() {
4103
+ this.getHeight();
4104
+ },
4013
4105
 
4014
4106
  biserial: {
4015
4107
  handler: function handler(val) {
4016
4108
  this.isShow = !val;
4017
- this.resetHeight();
4109
+ this.getHeight();
4018
4110
  }
4019
4111
  },
4020
4112
  defaultActive: {
@@ -4065,8 +4157,10 @@ var util = __webpack_require__(0);
4065
4157
  this.subMenu = [];
4066
4158
  }
4067
4159
  },
4068
- showMenu: function showMenu() {
4069
- this.resetHeight();
4160
+ showMenu: function showMenu(val) {
4161
+ if (val) {
4162
+ this.getHeight();
4163
+ }
4070
4164
  }
4071
4165
  },
4072
4166
  data: function data() {
@@ -4081,15 +4175,22 @@ var util = __webpack_require__(0);
4081
4175
  subMenu: []
4082
4176
  };
4083
4177
  },
4178
+ beforeCreate: function beforeCreate() {
4179
+ var _this3 = this;
4180
+
4181
+ this.getHeight = Object(external_throttle_debounce_["debounce"])(500, function () {
4182
+ _this3.resetHeight();
4183
+ });
4184
+ },
4084
4185
  mounted: function mounted() {
4085
- this.resetHeight();
4186
+ this.getHeight();
4086
4187
  this.move();
4087
4188
  },
4088
4189
 
4089
4190
  methods: {
4090
4191
  //设置按钮拖动
4091
4192
  move: function move() {
4092
- var _this3 = this;
4193
+ var _this4 = this;
4093
4194
 
4094
4195
  var area = this.$refs.area.$el;
4095
4196
  var box = this.$refs.box;
@@ -4141,7 +4242,7 @@ var util = __webpack_require__(0);
4141
4242
  var isClick = eTime - sTime < 200;
4142
4243
  if (isClick) {
4143
4244
  var onArea = function onArea() {
4144
- _this3.subMenu = [];
4245
+ _this4.subMenu = [];
4145
4246
  area.removeEventListener('click', onArea);
4146
4247
  };
4147
4248
  area.addEventListener('click', onArea);
@@ -4187,12 +4288,12 @@ var util = __webpack_require__(0);
4187
4288
  this.$emit('close', res);
4188
4289
  },
4189
4290
  resetHeight: function resetHeight() {
4190
- var _this4 = this;
4291
+ var _this5 = this;
4191
4292
 
4192
4293
  this.$nextTick(function () {
4193
- var height = _this4.$refs.esNav.parentNode.offsetHeight;
4194
- Array.from(_this4.$refs.esNav.parentNode.children).forEach(function (item) {
4195
- if (item !== _this4.$refs.esNav) {
4294
+ var height = _this5.$refs.esNav.parentNode.offsetHeight;
4295
+ Array.from(_this5.$refs.esNav.parentNode.children).forEach(function (item) {
4296
+ if (item !== _this5.$refs.esNav) {
4196
4297
  var mt = util["a" /* default */].getStyle(item, 'margin-top');
4197
4298
  var mb = util["a" /* default */].getStyle(item, 'margin-bottom');
4198
4299
  mt = mt ? parseInt(mt, 10) : 0;
@@ -4200,15 +4301,15 @@ var util = __webpack_require__(0);
4200
4301
  height -= item.offsetHeight + mt + mb;
4201
4302
  }
4202
4303
  });
4203
- if (_this4.overlap) {
4304
+ if (_this5.overlap) {
4204
4305
  height -= 15;
4205
4306
  }
4206
- _this4.height = height + 'px';
4207
- if (_this4.showTitle) {
4208
- var theight = _this4.$refs.navTitle.offsetHeight;
4209
- _this4.menuHeight = height - theight + 'px';
4307
+ _this5.height = height + 'px';
4308
+ if (_this5.showTitle) {
4309
+ var theight = _this5.$refs.navTitle.offsetHeight;
4310
+ _this5.menuHeight = height - theight + 'px';
4210
4311
  } else {
4211
- _this4.menuHeight = height + 'px';
4312
+ _this5.menuHeight = height + 'px';
4212
4313
  }
4213
4314
  });
4214
4315
  }
@@ -4287,6 +4388,8 @@ var WebSocket = function () {
4287
4388
  this.connects = 1;
4288
4389
  this.recon = false;
4289
4390
  this.sendTimeout = null;
4391
+ this.socket = null;
4392
+ this.subscription = null;
4290
4393
  }
4291
4394
 
4292
4395
  /** socket连接 */
@@ -4297,14 +4400,12 @@ var WebSocket = function () {
4297
4400
 
4298
4401
  if (!this.client) {
4299
4402
  // 连接SockJS
4300
- var socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url);
4301
- // 获取STOMP子协议的客户端对象
4302
- this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(socket);
4403
+ this.socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url, { timeout: 60000 });
4404
+ this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(this.socket);
4303
4405
  }
4304
4406
 
4305
4407
  // 日志不打印
4306
4408
  if (!this.debug) {
4307
- console.log(111);
4308
4409
  this.client.debug = function () {};
4309
4410
  }
4310
4411
 
@@ -4316,9 +4417,10 @@ var WebSocket = function () {
4316
4417
  // 订阅消息
4317
4418
  _this.subscribe();
4318
4419
  }, function (error) {
4420
+ _this.unsubscribe();
4421
+ _this.client = null;
4319
4422
  var diffSecond = parseInt((new Date() - _this.nextDate) / 1000, 10);
4320
4423
  if (_this.connects > 5 && diffSecond < _this.interval) {
4321
- _this.client.disconnect();
4322
4424
  _this.error && _this.error(error);
4323
4425
  } else {
4324
4426
  _this.reconTimeout = setTimeout(function () {
@@ -4327,6 +4429,14 @@ var WebSocket = function () {
4327
4429
  }, 5000);
4328
4430
  }
4329
4431
  });
4432
+ }; // 清除订阅
4433
+
4434
+
4435
+ WebSocket.prototype.unsubscribe = function unsubscribe() {
4436
+ if (this.subscription) {
4437
+ this.subscription.unsubscribe();
4438
+ this.subscription = null;
4439
+ }
4330
4440
  };
4331
4441
  /** 订阅服务端 */
4332
4442
 
@@ -4335,7 +4445,7 @@ var WebSocket = function () {
4335
4445
  var _this2 = this;
4336
4446
 
4337
4447
  // 订阅服务端提供的某个topic
4338
- this.client.subscribe(this.take, function (response) {
4448
+ this.subscription = this.client.subscribe(this.take, function (response) {
4339
4449
  if (response && (_this2.callback || _this2.success)) {
4340
4450
  var callback = _this2.callback || _this2.success;
4341
4451
  callback(JSON.parse(response.body));
@@ -4376,6 +4486,7 @@ var WebSocket = function () {
4376
4486
 
4377
4487
  WebSocket.prototype.destroy = function destroy() {
4378
4488
  // 断开连接,清除定时器
4489
+ this.unsubscribe();
4379
4490
  if (this.client) {
4380
4491
  this.client.disconnect();
4381
4492
  };
package/lib/page.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,
@@ -4084,6 +4160,8 @@ var WebSocket = function () {
4084
4160
  this.connects = 1;
4085
4161
  this.recon = false;
4086
4162
  this.sendTimeout = null;
4163
+ this.socket = null;
4164
+ this.subscription = null;
4087
4165
  }
4088
4166
 
4089
4167
  /** socket连接 */
@@ -4094,14 +4172,12 @@ var WebSocket = function () {
4094
4172
 
4095
4173
  if (!this.client) {
4096
4174
  // 连接SockJS
4097
- var socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url);
4098
- // 获取STOMP子协议的客户端对象
4099
- this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(socket);
4175
+ this.socket = new sockjs_client__WEBPACK_IMPORTED_MODULE_0___default.a(this.host + this.url, { timeout: 60000 });
4176
+ this.client = stompjs__WEBPACK_IMPORTED_MODULE_1___default.a.over(this.socket);
4100
4177
  }
4101
4178
 
4102
4179
  // 日志不打印
4103
4180
  if (!this.debug) {
4104
- console.log(111);
4105
4181
  this.client.debug = function () {};
4106
4182
  }
4107
4183
 
@@ -4113,9 +4189,10 @@ var WebSocket = function () {
4113
4189
  // 订阅消息
4114
4190
  _this.subscribe();
4115
4191
  }, function (error) {
4192
+ _this.unsubscribe();
4193
+ _this.client = null;
4116
4194
  var diffSecond = parseInt((new Date() - _this.nextDate) / 1000, 10);
4117
4195
  if (_this.connects > 5 && diffSecond < _this.interval) {
4118
- _this.client.disconnect();
4119
4196
  _this.error && _this.error(error);
4120
4197
  } else {
4121
4198
  _this.reconTimeout = setTimeout(function () {
@@ -4124,6 +4201,14 @@ var WebSocket = function () {
4124
4201
  }, 5000);
4125
4202
  }
4126
4203
  });
4204
+ }; // 清除订阅
4205
+
4206
+
4207
+ WebSocket.prototype.unsubscribe = function unsubscribe() {
4208
+ if (this.subscription) {
4209
+ this.subscription.unsubscribe();
4210
+ this.subscription = null;
4211
+ }
4127
4212
  };
4128
4213
  /** 订阅服务端 */
4129
4214
 
@@ -4132,7 +4217,7 @@ var WebSocket = function () {
4132
4217
  var _this2 = this;
4133
4218
 
4134
4219
  // 订阅服务端提供的某个topic
4135
- this.client.subscribe(this.take, function (response) {
4220
+ this.subscription = this.client.subscribe(this.take, function (response) {
4136
4221
  if (response && (_this2.callback || _this2.success)) {
4137
4222
  var callback = _this2.callback || _this2.success;
4138
4223
  callback(JSON.parse(response.body));
@@ -4173,6 +4258,7 @@ var WebSocket = function () {
4173
4258
 
4174
4259
  WebSocket.prototype.destroy = function destroy() {
4175
4260
  // 断开连接,清除定时器
4261
+ this.unsubscribe();
4176
4262
  if (this.client) {
4177
4263
  this.client.disconnect();
4178
4264
  };