eoss-ui 0.5.74 → 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 (65) hide show
  1. package/lib/button-group.js +99 -23
  2. package/lib/button.js +99 -23
  3. package/lib/checkbox-group.js +99 -23
  4. package/lib/data-table-form.js +99 -23
  5. package/lib/data-table.js +114 -29
  6. package/lib/date-picker.js +99 -23
  7. package/lib/dialog.js +99 -23
  8. package/lib/eoss-ui.common.js +170 -52
  9. package/lib/flow-group.js +99 -23
  10. package/lib/flow-list.js +99 -23
  11. package/lib/flow.js +99 -23
  12. package/lib/form.js +99 -23
  13. package/lib/handle-user.js +99 -23
  14. package/lib/handler.js +99 -23
  15. package/lib/index.js +1 -1
  16. package/lib/input-number.js +98 -22
  17. package/lib/input.js +115 -29
  18. package/lib/login.js +123 -26
  19. package/lib/main.js +99 -23
  20. package/lib/nav.js +99 -23
  21. package/lib/page.js +99 -23
  22. package/lib/player.js +99 -23
  23. package/lib/qr-code.js +99 -23
  24. package/lib/radio-group.js +99 -23
  25. package/lib/retrial-auth.js +99 -23
  26. package/lib/select-ganged.js +99 -23
  27. package/lib/select.js +114 -28
  28. package/lib/selector-panel.js +99 -23
  29. package/lib/selector.js +99 -23
  30. package/lib/sizer.js +99 -23
  31. package/lib/steps.js +99 -23
  32. package/lib/switch.js +98 -22
  33. package/lib/table-form.js +99 -23
  34. package/lib/tabs.js +99 -23
  35. package/lib/theme-chalk/base.css +1 -1
  36. package/lib/theme-chalk/index.css +1 -1
  37. package/lib/theme-chalk/login.css +1 -1
  38. package/lib/theme-chalk/main.css +1 -1
  39. package/lib/theme-chalk/menu.css +1 -1
  40. package/lib/theme-chalk/sizer.css +1 -1
  41. package/lib/theme-chalk/upload.css +1 -1
  42. package/lib/tips.js +99 -23
  43. package/lib/tree-group.js +99 -23
  44. package/lib/tree.js +99 -23
  45. package/lib/upload.js +99 -23
  46. package/lib/utils/util.js +98 -22
  47. package/lib/wujie.js +99 -23
  48. package/lib/wxlogin.js +98 -22
  49. package/package.json +2 -2
  50. package/packages/data-table/src/main.vue +10 -1
  51. package/packages/input/src/main.vue +7 -6
  52. package/packages/login/src/main.vue +13 -0
  53. package/packages/select/src/main.vue +6 -5
  54. package/packages/theme-chalk/lib/base.css +1 -1
  55. package/packages/theme-chalk/lib/index.css +1 -1
  56. package/packages/theme-chalk/lib/login.css +1 -1
  57. package/packages/theme-chalk/lib/main.css +1 -1
  58. package/packages/theme-chalk/lib/menu.css +1 -1
  59. package/packages/theme-chalk/lib/sizer.css +1 -1
  60. package/packages/theme-chalk/lib/upload.css +1 -1
  61. package/packages/theme-chalk/src/base.scss +3 -0
  62. package/packages/theme-chalk/src/login.scss +175 -171
  63. package/packages/theme-chalk/src/main.scss +5 -2
  64. package/src/index.js +1 -1
  65. package/src/utils/util.js +112 -23
package/lib/qr-code.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,
@@ -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,
@@ -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,
@@ -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,