mazey 3.3.7 → 3.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts CHANGED
@@ -79,13 +79,13 @@ export function calLongestCommonSubsequence(
79
79
  * @returns {string} value
80
80
  */
81
81
  export function getQueryParam(param: string): string {
82
- const reg = new RegExp("(^|&)" + param + "=([^&]*)(&|$)");
82
+ const reg = new RegExp('(^|&)' + param + '=([^&]*)(&|$)');
83
83
  const r = location.search.substr(1).match(reg);
84
84
  if (r !== null) {
85
85
  // return decodeURIComponent(unescape(r[2]));
86
86
  return decodeURIComponent(r[2]);
87
87
  }
88
- return "";
88
+ return '';
89
89
  }
90
90
 
91
91
  /**
@@ -113,7 +113,7 @@ export function getUrlParam(url: string, param: string): string | string[] {
113
113
  // } else {
114
114
  // return result[param] || '';
115
115
  // }
116
- return result[param] || "";
116
+ return result[param] || '';
117
117
  }
118
118
 
119
119
  /**
@@ -129,12 +129,12 @@ export function updateQueryParam(
129
129
  param: string,
130
130
  value: string
131
131
  ): string {
132
- const re = new RegExp("([?&])" + param + "=.*?(&|$)", "i");
133
- const separator = url.indexOf("?") !== -1 ? "&" : "?";
132
+ const re = new RegExp('([?&])' + param + '=.*?(&|$)', 'i');
133
+ const separator = url.indexOf('?') !== -1 ? '&' : '?';
134
134
  if (url.match(re)) {
135
- return url.replace(re, "$1" + param + "=" + value + "$2");
135
+ return url.replace(re, '$1' + param + '=' + value + '$2');
136
136
  } else {
137
- return url + separator + param + "=" + value;
137
+ return url + separator + param + '=' + value;
138
138
  }
139
139
  }
140
140
 
@@ -145,13 +145,13 @@ export function updateQueryParam(
145
145
  * @returns {string} value
146
146
  */
147
147
  export function getHashQueryParam(param: string): string {
148
- const hashs = location.hash.split("?");
148
+ const hashs = location.hash.split('?');
149
149
  if (hashs.length === 1) {
150
- return "";
150
+ return '';
151
151
  }
152
152
  const reg = new RegExp(`(^|&)${param}=([^&]*)(&|$)`);
153
153
  const ret = hashs[1].match(reg);
154
- return ret ? ret[2] : "";
154
+ return ret ? ret[2] : '';
155
155
  }
156
156
 
157
157
  /**
@@ -160,13 +160,13 @@ export function getHashQueryParam(param: string): string {
160
160
  * @param {string} url
161
161
  * @param {array} rules Object.keys(location), ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
162
162
  */
163
- export function getDomain(url: string, rules = ["hostname"]): string {
164
- const aEl: any = document.createElement("a");
163
+ export function getDomain(url: string, rules = ['hostname']): string {
164
+ const aEl: any = document.createElement('a');
165
165
  aEl.href = url;
166
166
  return rules.reduce((ret, v) => {
167
167
  ret += aEl[v];
168
168
  return ret;
169
- }, "");
169
+ }, '');
170
170
  }
171
171
 
172
172
  /**
@@ -176,8 +176,8 @@ export function getDomain(url: string, rules = ["hostname"]): string {
176
176
  * @returns {string} 'a-b-c'
177
177
  */
178
178
  export function camelCaseToKebabCase(camelCase: string): string {
179
- const kebabCase = camelCase.replace(/([A-Z])/g, "-$1").toLowerCase();
180
- return kebabCase[0] === "-" ? kebabCase.substr(1) : kebabCase;
179
+ const kebabCase = camelCase.replace(/([A-Z])/g, '-$1').toLowerCase();
180
+ return kebabCase[0] === '-' ? kebabCase.substr(1) : kebabCase;
181
181
  }
182
182
 
183
183
  /**
@@ -187,8 +187,8 @@ export function camelCaseToKebabCase(camelCase: string): string {
187
187
  * @returns {string} 'a_b_c'
188
188
  */
189
189
  export function camelCase2Underscore(camelCase: string): string {
190
- const kebabCase = camelCase.replace(/([A-Z])/g, "_$1").toLowerCase();
191
- return kebabCase[0] === "_" ? kebabCase.substr(1) : kebabCase;
190
+ const kebabCase = camelCase.replace(/([A-Z])/g, '_$1').toLowerCase();
191
+ return kebabCase[0] === '_' ? kebabCase.substr(1) : kebabCase;
192
192
  }
193
193
 
194
194
  /**
@@ -198,7 +198,7 @@ export function camelCase2Underscore(camelCase: string): string {
198
198
  * @returns {string} Trimmed string.
199
199
  */
200
200
  export function mTrim(str: string): string {
201
- str = str.replace(/^\s+/, ""); // 去除头部空格
201
+ str = str.replace(/^\s+/, ''); // 去除头部空格
202
202
  let end = str.length - 1;
203
203
  const ws = /\s/;
204
204
  while (ws.test(str.charAt(end))) {
@@ -215,10 +215,10 @@ export function mTrim(str: string): string {
215
215
  */
216
216
  export function newLine(str: string): string {
217
217
  if (!str) {
218
- return "";
218
+ return '';
219
219
  }
220
- const reg = new RegExp("\\n", "g");
221
- return str.replace(reg, "<br />");
220
+ const reg = new RegExp('\\n', 'g');
221
+ return str.replace(reg, '<br />');
222
222
  }
223
223
 
224
224
  /**
@@ -239,7 +239,7 @@ export function deepCopyObject(obj: any): any {
239
239
  */
240
240
  export function isJsonString(str: string): boolean {
241
241
  try {
242
- if (typeof JSON.parse(str) === "object") {
242
+ if (typeof JSON.parse(str) === 'object') {
243
243
  return true;
244
244
  }
245
245
  } catch (e) {
@@ -255,7 +255,7 @@ export function isJsonString(str: string): boolean {
255
255
  * @returns {string} Return the random string.
256
256
  */
257
257
  export function generateRndNum(n = 5): string {
258
- let ret = "";
258
+ let ret = '';
259
259
  while (n--) {
260
260
  ret += Math.floor(Math.random() * 10);
261
261
  }
@@ -279,7 +279,7 @@ export function generateUniqueNum(n = 3): string {
279
279
  * @param {number} fixSize 保留几位浮点数
280
280
  */
281
281
  export function floatToPercent(num: number, fixSize = 0): string {
282
- let ret = "";
282
+ let ret = '';
283
283
  if (fixSize) {
284
284
  ret = (num * 100).toFixed(fixSize);
285
285
  } else {
@@ -330,10 +330,10 @@ export function hasClass(obj: any, cls: string): boolean {
330
330
  */
331
331
  export function addClass(obj: any, cls: string): void {
332
332
  const oriCls = obj.className;
333
- let space = "";
334
- let newCls = ""; // 获取对象的class值
335
- if (oriCls !== "") {
336
- space = " "; // 若原来的class不为空,跟一个空格
333
+ let space = '';
334
+ let newCls = ''; // 获取对象的class值
335
+ if (oriCls !== '') {
336
+ space = ' '; // 若原来的class不为空,跟一个空格
337
337
  }
338
338
  newCls = oriCls + space + cls; // 将新的class加进去
339
339
  obj.className = newCls; // 替换新class
@@ -345,10 +345,10 @@ export function addClass(obj: any, cls: string): void {
345
345
  export function removeClass(obj: any, cls: string): void {
346
346
  const oriCls = obj.className;
347
347
  let newCls; // 获取对象的class值
348
- newCls = " " + oriCls + " "; // 前后加空格
349
- newCls = newCls.replace(/(\s+)/gi, " "); // 将多余的空格替换成一个空格
350
- newCls = newCls.replace(" " + cls + " ", " "); // 将加了前后空格的cls替换成空格' '
351
- newCls = newCls.replace(/(^\s+)|(\s+$)/g, ""); // 去掉前后空格
348
+ newCls = ' ' + oriCls + ' '; // 前后加空格
349
+ newCls = newCls.replace(/(\s+)/gi, ' '); // 将多余的空格替换成一个空格
350
+ newCls = newCls.replace(' ' + cls + ' ', ' '); // 将加了前后空格的cls替换成空格' '
351
+ newCls = newCls.replace(/(^\s+)|(\s+$)/g, ''); // 去掉前后空格
352
352
  obj.className = newCls;
353
353
  }
354
354
 
@@ -467,13 +467,13 @@ export function debounce(func: any, wait: number, immediate?: any): any {
467
467
  export function friendlyInterval(
468
468
  start = 0,
469
469
  end = 0,
470
- options: { type?: string } = { type: "d" }
470
+ options: { type?: string } = { type: 'd' }
471
471
  ): number | string {
472
472
  const { type } = options;
473
473
  if (!isNumber(start)) start = new Date(start).getTime();
474
474
  if (!isNumber(end)) end = new Date(end).getTime();
475
475
  const t = end - start;
476
- let ret = "";
476
+ let ret = '';
477
477
  let [d, h, m, s] = new Array(4).fill(0);
478
478
  if (t >= 0) {
479
479
  d = Math.floor(t / 1000 / 60 / 60 / 24);
@@ -481,15 +481,15 @@ export function friendlyInterval(
481
481
  m = Math.floor(t / 1000 / 60);
482
482
  s = Math.floor(t / 1000);
483
483
  switch (type) {
484
- case "d":
484
+ case 'd':
485
485
  ret = d;
486
486
  break;
487
- case "text":
487
+ case 'text':
488
488
  d = Math.floor(t / 1000 / 60 / 60 / 24);
489
489
  h = Math.floor((t / 1000 / 60 / 60) % 24);
490
490
  m = Math.floor((t / 1000 / 60) % 60);
491
491
  s = Math.floor((t / 1000) % 60);
492
- ret = d + " 天 " + h + " 时 " + m + " 分 " + s + " 秒";
492
+ ret = d + ' 天 ' + h + ' 时 ' + m + ' 分 ' + s + ' 秒';
493
493
  break;
494
494
  default:
495
495
  ret = s;
@@ -519,7 +519,7 @@ export function isNumber(
519
519
  );
520
520
  let ret = true;
521
521
  // 数字类型
522
- if (typeof num !== "number") {
522
+ if (typeof num !== 'number') {
523
523
  ret = false;
524
524
  }
525
525
  // 无限值
@@ -542,7 +542,7 @@ export function isNumber(
542
542
  */
543
543
  export function doFn(fn: any, ...params: any[]): any {
544
544
  let ret = null;
545
- if (fn && typeof fn === "function") {
545
+ if (fn && typeof fn === 'function') {
546
546
  ret = fn(...params);
547
547
  }
548
548
  return ret;
@@ -615,7 +615,7 @@ export function getLocalStorage(key: string): any {
615
615
  */
616
616
  export function loadCSS(
617
617
  url: string,
618
- options: { id?: string } = { id: "" }
618
+ options: { id?: string } = { id: '' }
619
619
  ): Promise<boolean | Error | any> {
620
620
  const { id } = options;
621
621
  let success: (v: boolean) => void;
@@ -628,22 +628,22 @@ export function loadCSS(
628
628
  // doFn(success, true);
629
629
  success(true);
630
630
  };
631
- let node: any = document.createElement("link");
632
- const supportOnload = "onload" in node;
631
+ let node: any = document.createElement('link');
632
+ const supportOnload = 'onload' in node;
633
633
  const isOldWebKit =
634
634
  +navigator.userAgent.replace(
635
635
  /.*(?:AppleWebKit|AndroidWebKit)\/?(\d+).*/i,
636
- "$1"
636
+ '$1'
637
637
  ) < 536; // webkit旧内核做特殊处理
638
638
  const protectNum = 300000; // 阈值10分钟,一秒钟执行pollCss 500次
639
639
 
640
- node.rel = "stylesheet";
641
- node.type = "text/css";
640
+ node.rel = 'stylesheet';
641
+ node.type = 'text/css';
642
642
  node.href = url;
643
- if (typeof id !== "undefined") {
643
+ if (typeof id !== 'undefined') {
644
644
  node.id = id;
645
645
  }
646
- document.getElementsByTagName("head")[0].appendChild(node);
646
+ document.getElementsByTagName('head')[0].appendChild(node);
647
647
 
648
648
  // for Old WebKit and Old Firefox
649
649
  if (isOldWebKit || !supportOnload) {
@@ -718,7 +718,7 @@ export function loadCSS(
718
718
  // The value of `ex.name` is changed from "NS_ERROR_DOM_SECURITY_ERR"
719
719
  // to "SecurityError" since Firefox 13.0. But Firefox is less than 9.0
720
720
  // in here, So it is ok to just rely on "NS_ERROR_DOM_SECURITY_ERR"
721
- if ((ex as any).name === "NS_ERROR_DOM_SECURITY_ERR") {
721
+ if ((ex as any).name === 'NS_ERROR_DOM_SECURITY_ERR') {
722
722
  isLoaded = true;
723
723
  }
724
724
  }
@@ -754,7 +754,7 @@ export function loadScript(
754
754
  timeout: number;
755
755
  isDefer: boolean;
756
756
  } = {
757
- id: "",
757
+ id: '',
758
758
  callback: function() {
759
759
  /* pass */
760
760
  },
@@ -764,7 +764,7 @@ export function loadScript(
764
764
  ): Promise<boolean | string | Error> {
765
765
  const { id, callback, timeout, isDefer } = Object.assign(
766
766
  {
767
- id: "",
767
+ id: '',
768
768
  callback: function() {
769
769
  /* pass */
770
770
  },
@@ -775,12 +775,12 @@ export function loadScript(
775
775
  );
776
776
  let success: any = null;
777
777
  let fail: any = null;
778
- const script: any = document.createElement("script");
778
+ const script: any = document.createElement('script');
779
779
  // 如果没有 script 标签,那么代码就不会运行。可以利用这一事实,在页面的第一个 script 标签上使用 insertBefore()。
780
- const firstScript: any = document.getElementsByTagName("script")[0];
781
- script.type = "text/javascript";
780
+ const firstScript: any = document.getElementsByTagName('script')[0];
781
+ script.type = 'text/javascript';
782
782
  if (isDefer) {
783
- script.defer = "defer";
783
+ script.defer = 'defer';
784
784
  }
785
785
  if (id) {
786
786
  script.id = id;
@@ -788,7 +788,7 @@ export function loadScript(
788
788
  if (script.readyState) {
789
789
  // IE
790
790
  script.onreadystatechange = function() {
791
- if (script.readyState === "loaded" || script.readyState === "complete") {
791
+ if (script.readyState === 'loaded' || script.readyState === 'complete') {
792
792
  script.onreadystatechange = null;
793
793
  doFn(callback);
794
794
  doFn(success, true);
@@ -806,7 +806,7 @@ export function loadScript(
806
806
  return new Promise((resolve, reject) => {
807
807
  [success, fail] = [resolve, reject];
808
808
  if (timeout) {
809
- setTimeout(fail.bind(null, Error("timeout")), timeout);
809
+ setTimeout(fail.bind(null, Error('timeout')), timeout);
810
810
  }
811
811
  });
812
812
  }
@@ -840,14 +840,14 @@ export function setCookie(
840
840
  if (days) {
841
841
  date = new Date();
842
842
  date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
843
- expires = "; expires=" + date.toGMTString();
843
+ expires = '; expires=' + date.toGMTString();
844
844
  } else {
845
- expires = "";
845
+ expires = '';
846
846
  }
847
847
  const host = location.host;
848
- if (host.split(".").length === 1) {
848
+ if (host.split('.').length === 1) {
849
849
  // no "." in a domain - it's localhost or something similar
850
- document.cookie = name + "=" + value + expires + "; path=/";
850
+ document.cookie = name + '=' + value + expires + '; path=/';
851
851
  } else {
852
852
  // Remember the cookie on all subdomains.
853
853
  //
@@ -858,18 +858,18 @@ export function setCookie(
858
858
  // If the cookie will not be set, it means ".com"
859
859
  // is a top level domain and we need to
860
860
  // set the cookie to ".foo.com"
861
- domainParts = host.split(".");
861
+ domainParts = host.split('.');
862
862
  domainParts.shift();
863
- domain = domain || "." + domainParts.join(".");
863
+ domain = domain || '.' + domainParts.join('.');
864
864
  document.cookie =
865
- name + "=" + value + expires + "; path=/; domain=" + domain;
865
+ name + '=' + value + expires + '; path=/; domain=' + domain;
866
866
  // check if cookie was successfuly set to the given domain
867
867
  // (otherwise it was a Top-Level Domain)
868
868
  if (getCookie(name) === null || getCookie(name) !== value) {
869
869
  // append "." to current domain
870
- domain = domain || "." + host;
870
+ domain = domain || '.' + host;
871
871
  document.cookie =
872
- name + "=" + value + expires + "; path=/; domain=" + domain;
872
+ name + '=' + value + expires + '; path=/; domain=' + domain;
873
873
  }
874
874
  }
875
875
  }
@@ -879,16 +879,16 @@ export function setCookie(
879
879
  * @description 获取 Cookie
880
880
  */
881
881
  export function getCookie(name: string): string {
882
- const nameEQ = name + "=";
883
- const ca = document.cookie.split(";");
882
+ const nameEQ = name + '=';
883
+ const ca = document.cookie.split(';');
884
884
  for (let i = 0; i < ca.length; i++) {
885
885
  let c = ca[i];
886
- while (c.charAt(0) == " ") {
886
+ while (c.charAt(0) == ' ') {
887
887
  c = c.substring(1, c.length);
888
888
  }
889
889
  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
890
890
  }
891
- return "";
891
+ return '';
892
892
  }
893
893
 
894
894
  interface WebPerformance {
@@ -923,7 +923,7 @@ export function getPerformance(
923
923
  getTiming();
924
924
  } else {
925
925
  // console.log('creating')
926
- window.addEventListener("load", function() {
926
+ window.addEventListener('load', function() {
927
927
  //不能影响最后的时间计算
928
928
  window.setTimeout(function() {
929
929
  getTiming();
@@ -936,16 +936,16 @@ export function getPerformance(
936
936
  try {
937
937
  if (window.performance && Boolean(window.performance.getEntriesByType)) {
938
938
  const performance = window.performance;
939
- const performanceEntries = performance.getEntriesByType("paint");
939
+ const performanceEntries = performance.getEntriesByType('paint');
940
940
  performanceEntries.forEach((performanceEntry, i, entries) => {
941
941
  const startTime = Math.round(performanceEntry.startTime);
942
- if (performanceEntry.name === "first-paint")
942
+ if (performanceEntry.name === 'first-paint')
943
943
  firstPaintTime = startTime;
944
- else if (performanceEntry.name === "first-contentful-paint")
944
+ else if (performanceEntry.name === 'first-contentful-paint')
945
945
  firstContentfulPaintTime = startTime;
946
946
  });
947
947
  } else {
948
- console.error("paint");
948
+ console.error('paint');
949
949
  }
950
950
  } catch (e) {
951
951
  console.error((e as any).message);
@@ -953,7 +953,7 @@ export function getPerformance(
953
953
  // 获取加载时间
954
954
  if (
955
955
  window.performance &&
956
- typeof window.performance.getEntries === "function"
956
+ typeof window.performance.getEntries === 'function'
957
957
  ) {
958
958
  const performanceNavigationTiming: any =
959
959
  (window.performance.getEntries() || [])[0] || {};
@@ -978,8 +978,8 @@ export function getPerformance(
978
978
  onloadTime: timing.loadEventStart - startTime || 0, //*onload时间(总和)
979
979
  whiteTime: timing.responseStart - startTime, //*白屏时间
980
980
  renderTime: timing.loadEventEnd - startTime || 0, //整个过程的时间之和
981
- decodedBodySize: performanceNavigationTiming.decodedBodySize || "", //页面压缩前大小
982
- encodedBodySize: performanceNavigationTiming.encodedBodySize || "" //页面压缩后大小
981
+ decodedBodySize: performanceNavigationTiming.decodedBodySize || '', //页面压缩前大小
982
+ encodedBodySize: performanceNavigationTiming.encodedBodySize || '' //页面压缩后大小
983
983
  };
984
984
  // 过滤异常数据
985
985
  Object.keys(data).forEach(k => {
@@ -1003,26 +1003,26 @@ export function getPerformance(
1003
1003
  }
1004
1004
  success(Underscore || data);
1005
1005
  } else {
1006
- fail(Error("startTime"));
1006
+ fail(Error('startTime'));
1007
1007
  }
1008
1008
  } else {
1009
- fail(Error("getEntries"));
1009
+ fail(Error('getEntries'));
1010
1010
  }
1011
1011
  }
1012
1012
  //获取当前操作系统
1013
1013
  function getOS() {
1014
1014
  let os;
1015
1015
  if (
1016
- navigator.userAgent.indexOf("Android") > -1 ||
1017
- navigator.userAgent.indexOf("Linux") > -1
1016
+ navigator.userAgent.indexOf('Android') > -1 ||
1017
+ navigator.userAgent.indexOf('Linux') > -1
1018
1018
  ) {
1019
- os = "android";
1020
- } else if (navigator.userAgent.indexOf("iPhone") > -1) {
1021
- os = "ios";
1022
- } else if (navigator.userAgent.indexOf("Windows Phone") > -1) {
1023
- os = "wp";
1019
+ os = 'android';
1020
+ } else if (navigator.userAgent.indexOf('iPhone') > -1) {
1021
+ os = 'ios';
1022
+ } else if (navigator.userAgent.indexOf('Windows Phone') > -1) {
1023
+ os = 'wp';
1024
1024
  } else {
1025
- os = "others";
1025
+ os = 'others';
1026
1026
  }
1027
1027
  return os;
1028
1028
  }
@@ -1030,15 +1030,15 @@ export function getPerformance(
1030
1030
  function getOSVersion() {
1031
1031
  let OSVision: any;
1032
1032
  const u = navigator.userAgent;
1033
- const isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //Android
1033
+ const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //Android
1034
1034
  const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
1035
1035
  if (isAndroid) {
1036
- OSVision = (navigator.userAgent.split(";")[1].match(/\d+\.\d+/g) ||
1036
+ OSVision = (navigator.userAgent.split(';')[1].match(/\d+\.\d+/g) ||
1037
1037
  [])[0];
1038
1038
  }
1039
1039
  if (isIOS) {
1040
1040
  OSVision = (navigator.userAgent
1041
- .split(";")[1]
1041
+ .split(';')[1]
1042
1042
  .match(/(\d+)_(\d+)_?(\d+)?/) || [])[0];
1043
1043
  }
1044
1044
  return OSVision;
@@ -1047,14 +1047,14 @@ export function getPerformance(
1047
1047
  function getDeviceType() {
1048
1048
  let deviceType;
1049
1049
  const sUserAgent = navigator.userAgent.toLowerCase();
1050
- const bIsIpad = sUserAgent.match(/(ipad)/i) && "ipad";
1051
- const bIsIphoneOs = sUserAgent.match(/iphone os/i) && "iphone os";
1052
- const bIsMidp = sUserAgent.match(/midp/i) && "midp";
1053
- const bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) && "rv:1.2.3.4";
1054
- const bIsUc = sUserAgent.match(/ucweb/i) && "ucweb";
1055
- const bIsAndroid = sUserAgent.match(/android/i) && "android";
1056
- const bIsCE = sUserAgent.match(/windows ce/i) && "windows ce";
1057
- const bIsWM = sUserAgent.match(/windows mobile/i) && "windows mobile";
1050
+ const bIsIpad = sUserAgent.match(/(ipad)/i) && 'ipad';
1051
+ const bIsIphoneOs = sUserAgent.match(/iphone os/i) && 'iphone os';
1052
+ const bIsMidp = sUserAgent.match(/midp/i) && 'midp';
1053
+ const bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) && 'rv:1.2.3.4';
1054
+ const bIsUc = sUserAgent.match(/ucweb/i) && 'ucweb';
1055
+ const bIsAndroid = sUserAgent.match(/android/i) && 'android';
1056
+ const bIsCE = sUserAgent.match(/windows ce/i) && 'windows ce';
1057
+ const bIsWM = sUserAgent.match(/windows mobile/i) && 'windows mobile';
1058
1058
  if (
1059
1059
  !(
1060
1060
  bIsIpad ||
@@ -1067,7 +1067,7 @@ export function getPerformance(
1067
1067
  bIsWM
1068
1068
  )
1069
1069
  ) {
1070
- deviceType = "pc"; //pc
1070
+ deviceType = 'pc'; //pc
1071
1071
  } else if (
1072
1072
  bIsIphoneOs ||
1073
1073
  bIsMidp ||
@@ -1077,9 +1077,9 @@ export function getPerformance(
1077
1077
  bIsCE ||
1078
1078
  bIsWM
1079
1079
  ) {
1080
- deviceType = "phone"; //phone
1080
+ deviceType = 'phone'; //phone
1081
1081
  } else if (bIsIpad) {
1082
- deviceType = "ipad"; //ipad
1082
+ deviceType = 'ipad'; //ipad
1083
1083
  } else {
1084
1084
  deviceType = undefined;
1085
1085
  }
@@ -1093,22 +1093,22 @@ export function getPerformance(
1093
1093
  (navigator as any).connection.effectiveType
1094
1094
  ) {
1095
1095
  switch ((navigator as any).connection.effectiveType) {
1096
- case "wifi":
1097
- netWork = "wifi"; // wifi
1096
+ case 'wifi':
1097
+ netWork = 'wifi'; // wifi
1098
1098
  break;
1099
- case "4g":
1100
- netWork = "4g"; // 4g
1099
+ case '4g':
1100
+ netWork = '4g'; // 4g
1101
1101
  break;
1102
- case "2g":
1103
- netWork = "2g"; // 2g
1102
+ case '2g':
1103
+ netWork = '2g'; // 2g
1104
1104
  break;
1105
- case "3g":
1106
- netWork = "3g"; // 3g
1105
+ case '3g':
1106
+ netWork = '3g'; // 3g
1107
1107
  break;
1108
- case "ethernet":
1109
- netWork = "ethernet"; // ethernet
1108
+ case 'ethernet':
1109
+ netWork = 'ethernet'; // ethernet
1110
1110
  break;
1111
- case "default":
1111
+ case 'default':
1112
1112
  netWork = undefined; // 未知
1113
1113
  break;
1114
1114
  }
@@ -1128,14 +1128,14 @@ export function getPerformance(
1128
1128
  window.screen.orientation.angle === 0
1129
1129
  ) {
1130
1130
  // 竖屏
1131
- orientationStatu = "|";
1131
+ orientationStatu = '|';
1132
1132
  }
1133
1133
  if (
1134
1134
  window.screen.orientation.angle === 90 ||
1135
1135
  window.screen.orientation.angle === -90
1136
1136
  ) {
1137
1137
  // 横屏
1138
- orientationStatu = "-";
1138
+ orientationStatu = '-';
1139
1139
  }
1140
1140
  }
1141
1141
  return orientationStatu;
@@ -1175,7 +1175,7 @@ export function isSafePWAEnv(): boolean {
1175
1175
  let isSupportAsyncAwaitFunc;
1176
1176
  try {
1177
1177
  // eval("func = async function(){};");
1178
- const fn = new Function("return async function(){};");
1178
+ const fn = new Function('return async function(){};');
1179
1179
  isSupportAsyncAwaitFunc = fn();
1180
1180
  // console.log('isSupportAsyncAwaitFunc', isSupportAsyncAwaitFunc);
1181
1181
  // 由于async函数的构造器不是全局对象,所以我们需要由下面代码来获取async函数的构造器
@@ -1189,8 +1189,8 @@ export function isSafePWAEnv(): boolean {
1189
1189
  // 判断是否支持 Promise
1190
1190
  function isSupportPromise() {
1191
1191
  if (
1192
- typeof Promise !== "undefined" &&
1193
- Promise.toString().indexOf("[native code]") !== -1
1192
+ typeof Promise !== 'undefined' &&
1193
+ Promise.toString().indexOf('[native code]') !== -1
1194
1194
  ) {
1195
1195
  return true;
1196
1196
  }
@@ -1199,13 +1199,13 @@ export function isSafePWAEnv(): boolean {
1199
1199
  // 浏览器信息
1200
1200
  const BrowserType = getBrowserInfo();
1201
1201
  if (
1202
- "serviceWorker" in navigator &&
1202
+ 'serviceWorker' in navigator &&
1203
1203
  isSupportAsyncAwait() &&
1204
1204
  isSupportPromise() &&
1205
1205
  Boolean(window.fetch) &&
1206
1206
  Boolean(window.indexedDB) &&
1207
1207
  Boolean(window.caches) &&
1208
- !BrowserType["shell"]
1208
+ !BrowserType['shell']
1209
1209
  ) {
1210
1210
  return true;
1211
1211
  }
@@ -1261,151 +1261,151 @@ export function getBrowserInfo(): {
1261
1261
  const testUa: (regexp: RegExp) => boolean = regexp => regexp.test(ua);
1262
1262
  const testVs: (regexp: RegExp) => string = regexp => {
1263
1263
  const matchRes = ua.match(regexp);
1264
- let ret = "";
1264
+ let ret = '';
1265
1265
  if (matchRes) {
1266
1266
  ret = matchRes
1267
1267
  .toString()
1268
- .replace(/[^0-9|_.]/g, "")
1269
- .replace(/_/g, ".");
1268
+ .replace(/[^0-9|_.]/g, '')
1269
+ .replace(/_/g, '.');
1270
1270
  }
1271
1271
  return ret;
1272
1272
  };
1273
1273
  // 系统
1274
- let system = "";
1274
+ let system = '';
1275
1275
  // Apple device type.
1276
- let appleType = "";
1276
+ let appleType = '';
1277
1277
  if (testUa(/windows|win32|win64|wow32|wow64/g)) {
1278
- system = "windows"; // windows系统
1278
+ system = 'windows'; // windows系统
1279
1279
  } else if (testUa(/macintosh|macintel/g)) {
1280
- system = "macos"; // macos系统
1280
+ system = 'macos'; // macos系统
1281
1281
  } else if (testUa(/x11/g)) {
1282
- system = "linux"; // linux系统
1282
+ system = 'linux'; // linux系统
1283
1283
  } else if (testUa(/android|adr/g)) {
1284
- system = "android"; // android系统
1284
+ system = 'android'; // android系统
1285
1285
  } else if (testUa(/ios|iphone|ipad|ipod|iwatch/g)) {
1286
- system = "ios"; // ios系统
1286
+ system = 'ios'; // ios系统
1287
1287
  if (testUa(/iphone/g)) {
1288
- appleType = "iphone";
1288
+ appleType = 'iphone';
1289
1289
  } else if (testUa(/ipad/g)) {
1290
- appleType = "ipad";
1290
+ appleType = 'ipad';
1291
1291
  } else if (testUa(/iwatch/g)) {
1292
- appleType = "iwatch";
1292
+ appleType = 'iwatch';
1293
1293
  } else if (testUa(/ipod/g)) {
1294
- appleType = "ipod";
1294
+ appleType = 'ipod';
1295
1295
  }
1296
1296
  }
1297
1297
  // 系统版本
1298
- let systemVs = "";
1299
- if (system === "windows") {
1298
+ let systemVs = '';
1299
+ if (system === 'windows') {
1300
1300
  if (testUa(/windows nt 5.0|windows 2000/g)) {
1301
- systemVs = "2000";
1301
+ systemVs = '2000';
1302
1302
  } else if (testUa(/windows nt 5.1|windows xp/g)) {
1303
- systemVs = "xp";
1303
+ systemVs = 'xp';
1304
1304
  } else if (testUa(/windows nt 5.2|windows 2003/g)) {
1305
- systemVs = "2003";
1305
+ systemVs = '2003';
1306
1306
  } else if (testUa(/windows nt 6.0|windows vista/g)) {
1307
- systemVs = "vista";
1307
+ systemVs = 'vista';
1308
1308
  } else if (testUa(/windows nt 6.1|windows 7/g)) {
1309
- systemVs = "7";
1309
+ systemVs = '7';
1310
1310
  } else if (testUa(/windows nt 6.2|windows 8/g)) {
1311
- systemVs = "8";
1311
+ systemVs = '8';
1312
1312
  } else if (testUa(/windows nt 6.3|windows 8.1/g)) {
1313
- systemVs = "8.1";
1313
+ systemVs = '8.1';
1314
1314
  } else if (testUa(/windows nt 10.0|windows 10/g)) {
1315
- systemVs = "10";
1315
+ systemVs = '10';
1316
1316
  }
1317
- } else if (system === "macos") {
1317
+ } else if (system === 'macos') {
1318
1318
  systemVs = testVs(/os x [\d._]+/g);
1319
- } else if (system === "android") {
1319
+ } else if (system === 'android') {
1320
1320
  systemVs = testVs(/android [\d._]+/g);
1321
- } else if (system === "ios") {
1321
+ } else if (system === 'ios') {
1322
1322
  systemVs = testVs(/os [\d._]+/g);
1323
1323
  }
1324
1324
  // 平台
1325
- let platform = "";
1326
- if (system === "windows" || system === "macos" || system === "linux") {
1327
- platform = "desktop"; // 桌面端
1328
- } else if (system === "android" || system === "ios" || testUa(/mobile/g)) {
1329
- platform = "mobile"; // 移动端
1325
+ let platform = '';
1326
+ if (system === 'windows' || system === 'macos' || system === 'linux') {
1327
+ platform = 'desktop'; // 桌面端
1328
+ } else if (system === 'android' || system === 'ios' || testUa(/mobile/g)) {
1329
+ platform = 'mobile'; // 移动端
1330
1330
  }
1331
1331
  // 内核和载体
1332
- let engine = "";
1333
- let supporter = "";
1332
+ let engine = '';
1333
+ let supporter = '';
1334
1334
  if (testUa(/applewebkit/g)) {
1335
- engine = "webkit"; // webkit内核
1335
+ engine = 'webkit'; // webkit内核
1336
1336
  if (testUa(/edge/g)) {
1337
- supporter = "edge"; // edge浏览器
1337
+ supporter = 'edge'; // edge浏览器
1338
1338
  } else if (testUa(/opr/g)) {
1339
- supporter = "opera"; // opera浏览器
1339
+ supporter = 'opera'; // opera浏览器
1340
1340
  } else if (testUa(/chrome/g)) {
1341
- supporter = "chrome"; // chrome浏览器
1341
+ supporter = 'chrome'; // chrome浏览器
1342
1342
  } else if (testUa(/safari/g)) {
1343
- supporter = "safari"; // safari浏览器
1343
+ supporter = 'safari'; // safari浏览器
1344
1344
  }
1345
1345
  } else if (testUa(/gecko/g) && testUa(/firefox/g)) {
1346
- engine = "gecko"; // gecko内核
1347
- supporter = "firefox"; // firefox浏览器
1346
+ engine = 'gecko'; // gecko内核
1347
+ supporter = 'firefox'; // firefox浏览器
1348
1348
  } else if (testUa(/presto/g)) {
1349
- engine = "presto"; // presto内核
1350
- supporter = "opera"; // opera浏览器
1349
+ engine = 'presto'; // presto内核
1350
+ supporter = 'opera'; // opera浏览器
1351
1351
  } else if (testUa(/trident|compatible|msie/g)) {
1352
- engine = "trident"; // trident内核
1353
- supporter = "iexplore"; // iexplore浏览器
1352
+ engine = 'trident'; // trident内核
1353
+ supporter = 'iexplore'; // iexplore浏览器
1354
1354
  }
1355
1355
  // 内核版本
1356
- let engineVs = "";
1357
- if (engine === "webkit") {
1356
+ let engineVs = '';
1357
+ if (engine === 'webkit') {
1358
1358
  engineVs = testVs(/applewebkit\/[\d._]+/g);
1359
- } else if (engine === "gecko") {
1359
+ } else if (engine === 'gecko') {
1360
1360
  engineVs = testVs(/gecko\/[\d._]+/g);
1361
- } else if (engine === "presto") {
1361
+ } else if (engine === 'presto') {
1362
1362
  engineVs = testVs(/presto\/[\d._]+/g);
1363
- } else if (engine === "trident") {
1363
+ } else if (engine === 'trident') {
1364
1364
  engineVs = testVs(/trident\/[\d._]+/g);
1365
1365
  }
1366
1366
  // 载体版本
1367
- let supporterVs = "";
1368
- if (supporter === "chrome") {
1367
+ let supporterVs = '';
1368
+ if (supporter === 'chrome') {
1369
1369
  supporterVs = testVs(/chrome\/[\d._]+/g);
1370
- } else if (supporter === "safari") {
1370
+ } else if (supporter === 'safari') {
1371
1371
  supporterVs = testVs(/version\/[\d._]+/g);
1372
- } else if (supporter === "firefox") {
1372
+ } else if (supporter === 'firefox') {
1373
1373
  supporterVs = testVs(/firefox\/[\d._]+/g);
1374
- } else if (supporter === "opera") {
1374
+ } else if (supporter === 'opera') {
1375
1375
  supporterVs = testVs(/opr\/[\d._]+/g);
1376
- } else if (supporter === "iexplore") {
1376
+ } else if (supporter === 'iexplore') {
1377
1377
  supporterVs = testVs(/(msie [\d._]+)|(rv:[\d._]+)/g);
1378
- } else if (supporter === "edge") {
1378
+ } else if (supporter === 'edge') {
1379
1379
  supporterVs = testVs(/edge\/[\d._]+/g);
1380
1380
  }
1381
1381
  // 外壳和外壳版本
1382
- let shell = "";
1383
- let shellVs = "";
1382
+ let shell = '';
1383
+ let shellVs = '';
1384
1384
  if (testUa(/micromessenger/g)) {
1385
- shell = "wechat"; // 微信浏览器
1385
+ shell = 'wechat'; // 微信浏览器
1386
1386
  shellVs = testVs(/micromessenger\/[\d._]+/g);
1387
1387
  } else if (testUa(/qqbrowser/g)) {
1388
- shell = "qq_browser"; // QQ Browser
1388
+ shell = 'qq_browser'; // QQ Browser
1389
1389
  shellVs = testVs(/qqbrowser\/[\d._]+/g);
1390
1390
  } else if (testUa(/\sqq/g)) {
1391
- shell = "qq_app"; // QQ APP
1391
+ shell = 'qq_app'; // QQ APP
1392
1392
  } else if (testUa(/ucbrowser/g)) {
1393
- shell = "uc"; // UC浏览器
1393
+ shell = 'uc'; // UC浏览器
1394
1394
  shellVs = testVs(/ucbrowser\/[\d._]+/g);
1395
1395
  } else if (testUa(/qihu 360se/g)) {
1396
- shell = "360"; // 360浏览器(无版本)
1396
+ shell = '360'; // 360浏览器(无版本)
1397
1397
  } else if (testUa(/2345explorer/g)) {
1398
- shell = "2345"; // 2345浏览器
1398
+ shell = '2345'; // 2345浏览器
1399
1399
  shellVs = testVs(/2345explorer\/[\d._]+/g);
1400
1400
  } else if (testUa(/metasr/g)) {
1401
- shell = "sougou"; // 搜狗浏览器(无版本)
1401
+ shell = 'sougou'; // 搜狗浏览器(无版本)
1402
1402
  } else if (testUa(/lbbrowser/g)) {
1403
- shell = "liebao"; // 猎豹浏览器(无版本)
1403
+ shell = 'liebao'; // 猎豹浏览器(无版本)
1404
1404
  } else if (testUa(/maxthon/g)) {
1405
- shell = "maxthon"; // 遨游浏览器
1405
+ shell = 'maxthon'; // 遨游浏览器
1406
1406
  shellVs = testVs(/maxthon\/[\d._]+/g);
1407
1407
  } else if (testUa(/biliapp/g)) {
1408
- shell = "bilibili"; // 哔哩哔哩
1408
+ shell = 'bilibili'; // 哔哩哔哩
1409
1409
  }
1410
1410
  return Object.assign(
1411
1411
  {
@@ -1424,15 +1424,15 @@ export function getBrowserInfo(): {
1424
1424
  }
1425
1425
  );
1426
1426
  } catch (err) {
1427
- console.warn("mazey:", err);
1427
+ console.warn('mazey:', err);
1428
1428
  return {
1429
- engine: "", // webkit gecko presto trident
1430
- engineVs: "",
1431
- platform: "", // desktop mobile
1432
- supporter: "", // chrome safari firefox opera iexplore edge
1433
- supporterVs: "",
1434
- system: "", // windows macos linux android ios
1435
- systemVs: ""
1429
+ engine: '', // webkit gecko presto trident
1430
+ engineVs: '',
1431
+ platform: '', // desktop mobile
1432
+ supporter: '', // chrome safari firefox opera iexplore edge
1433
+ supporterVs: '',
1434
+ system: '', // windows macos linux android ios
1435
+ systemVs: ''
1436
1436
  };
1437
1437
  }
1438
1438
  }
@@ -1444,7 +1444,7 @@ export function getBrowserInfo(): {
1444
1444
  * @returns {string} 字符串
1445
1445
  */
1446
1446
  export function clearHtml(str: string): string {
1447
- return str.replace(/<\/?.+?>/g, "").replace(/[\r\n]/g, "");
1447
+ return str.replace(/<\/?.+?>/g, '').replace(/[\r\n]/g, '');
1448
1448
  }
1449
1449
 
1450
1450
  /**
@@ -1456,15 +1456,15 @@ export function clearHtml(str: string): string {
1456
1456
  * @returnss {string} 返回截取后的字符串
1457
1457
  */
1458
1458
  export function cutCHSString(str: string, len: number, hasDot = false): string {
1459
- if (str == "" || !str) {
1460
- return "";
1459
+ if (str == '' || !str) {
1460
+ return '';
1461
1461
  } else {
1462
1462
  let newLength = 0;
1463
- let newStr = "";
1463
+ let newStr = '';
1464
1464
  // eslint-disable-next-line no-control-regex
1465
1465
  const chineseRegex = /[^\x00-\xff]/g;
1466
- let singleChar = "";
1467
- const strLength = str.replace(chineseRegex, "**").length;
1466
+ let singleChar = '';
1467
+ const strLength = str.replace(chineseRegex, '**').length;
1468
1468
  for (let i = 0; i < strLength; i++) {
1469
1469
  singleChar = str.charAt(i).toString();
1470
1470
  if (singleChar.match(chineseRegex) != null) {
@@ -1479,7 +1479,7 @@ export function cutCHSString(str: string, len: number, hasDot = false): string {
1479
1479
  }
1480
1480
 
1481
1481
  if (hasDot && strLength > len) {
1482
- newStr += "...";
1482
+ newStr += '...';
1483
1483
  }
1484
1484
  return newStr;
1485
1485
  }
@@ -1500,13 +1500,13 @@ export function windowLoaded(timeout = 90): Promise<string | Error> {
1500
1500
  loadFail = reject;
1501
1501
  }
1502
1502
  );
1503
- if (document.readyState === "complete") {
1504
- loaded("complete");
1503
+ if (document.readyState === 'complete') {
1504
+ loaded('complete');
1505
1505
  } else {
1506
- window.addEventListener("load", () => loaded("load"));
1506
+ window.addEventListener('load', () => loaded('load'));
1507
1507
  }
1508
1508
  // 超过 timeout 秒后加载失败
1509
- setTimeout(() => loadFail(Error("timeout")), timeout * 1000);
1509
+ setTimeout(() => loadFail(Error('timeout')), timeout * 1000);
1510
1510
  return status;
1511
1511
  }
1512
1512
 
@@ -1558,7 +1558,7 @@ export function windowLoaded(timeout = 90): Promise<string | Error> {
1558
1558
  */
1559
1559
  export function addStyle(
1560
1560
  style: string,
1561
- options: { id?: string } = { id: "" }
1561
+ options: { id?: string } = { id: '' }
1562
1562
  ): boolean {
1563
1563
  // console.log('_ style', style);
1564
1564
  // console.log('_ options', options);
@@ -1568,16 +1568,16 @@ export function addStyle(
1568
1568
  // 创建 style 文档碎片
1569
1569
  const styleFrag = document.createDocumentFragment();
1570
1570
  let idDom: HTMLElement | null = null;
1571
- let domId = "";
1571
+ let domId = '';
1572
1572
  // Custom Style
1573
- const customStyle = document.createElement("style");
1573
+ const customStyle = document.createElement('style');
1574
1574
  // 如果需要 ID
1575
1575
  if (options.id) {
1576
1576
  domId = `${options.id}`;
1577
1577
  idDom = document.getElementById(domId);
1578
1578
  // 如果 Dom 不存在,插入 style
1579
1579
  if (!idDom) {
1580
- customStyle.setAttribute("id", options.id);
1580
+ customStyle.setAttribute('id', options.id);
1581
1581
  customStyle.innerHTML = style;
1582
1582
  styleFrag.appendChild(customStyle);
1583
1583
  document.head.appendChild(styleFrag);
@@ -1595,29 +1595,70 @@ export function addStyle(
1595
1595
  }
1596
1596
 
1597
1597
  /**
1598
- * @method genCustomConsole
1599
- * @description 生成自定义控制台打印
1598
+ * 生成自定义控制台打印
1599
+ *
1600
1600
  * @param {string} prefix 前缀
1601
1601
  * @param {function} allowFn 允许打印的判断函数
1602
1602
  * @returns {object} 新实例
1603
1603
  */
1604
1604
  export function genCustomConsole(
1605
- prefix = "",
1606
- options: { isClose?: boolean } = { isClose: false }
1605
+ prefix = '',
1606
+ options: {
1607
+ isClosed?: boolean;
1608
+ showWrap?: boolean;
1609
+ logFn?: () => void;
1610
+ errorFn?: () => void;
1611
+ } = {
1612
+ isClosed: false,
1613
+ showWrap: false,
1614
+ logFn: () => undefined,
1615
+ errorFn: () => undefined
1616
+ }
1607
1617
  ): Console {
1608
- const { isClose } = Object.assign({ isClose: false }, options);
1609
- const methods = ["log", "info", "warn", "error"];
1618
+ const { isClosed, showWrap, logFn, errorFn } = Object.assign(
1619
+ {
1620
+ isClosed: false,
1621
+ showWrap: false,
1622
+ logFn: () => undefined,
1623
+ errorFn: () => undefined
1624
+ },
1625
+ options
1626
+ );
1627
+ const methods = ['log', 'info', 'warn', 'error'];
1610
1628
  const newConsole = Object.create(null);
1611
1629
  methods.forEach(method => {
1612
1630
  newConsole[method] = function(...argu: any) {
1613
- if (isClose) {
1631
+ if (isClosed) {
1614
1632
  return false;
1615
1633
  }
1634
+ let elaboratePrefix = '';
1635
+ if (typeof prefix === 'string' && prefix.length >= 2) {
1636
+ const len = prefix.length;
1637
+ if (prefix[len - 1] === ':') {
1638
+ elaboratePrefix = prefix.substring(0, len - 2);
1639
+ } else {
1640
+ elaboratePrefix = prefix;
1641
+ }
1642
+ console.log('prefix', prefix);
1643
+ console.log('elaboratePrefix', elaboratePrefix);
1644
+ }
1645
+ if (showWrap) {
1646
+ console.log(`--- ${elaboratePrefix} - begin ---`);
1647
+ }
1616
1648
  if (prefix) {
1617
1649
  (console as any)[method](prefix, ...argu);
1618
1650
  } else {
1619
1651
  (console as any)[method](...argu);
1620
1652
  }
1653
+ if (method === 'log') {
1654
+ logFn();
1655
+ }
1656
+ if (method === 'error') {
1657
+ errorFn();
1658
+ }
1659
+ if (showWrap) {
1660
+ console.log(`--- ${elaboratePrefix} - end ---`);
1661
+ }
1621
1662
  };
1622
1663
  });
1623
1664
  return newConsole;
@@ -1646,7 +1687,7 @@ export function zAxiosIsValidRes(
1646
1687
  options
1647
1688
  );
1648
1689
  if (validStatusRange.length !== 2) {
1649
- console.error("valid validStatusRange is required");
1690
+ console.error('valid validStatusRange is required');
1650
1691
  }
1651
1692
  let ret = false;
1652
1693
  if (
@@ -1680,21 +1721,21 @@ export function isNonEmptyArray(arr: any[]): boolean {
1680
1721
  */
1681
1722
  export function getFileSize(size: number): string {
1682
1723
  const toCeilStr: (v: number) => string = n => String(Math.ceil(n));
1683
- if (!size) return "";
1724
+ if (!size) return '';
1684
1725
  const num = 1024.0; // byte
1685
1726
  if (size < num) {
1686
- return size + " B";
1727
+ return size + ' B';
1687
1728
  }
1688
1729
  if (size < Math.pow(num, 2)) {
1689
- return toCeilStr(size / num) + " KB";
1730
+ return toCeilStr(size / num) + ' KB';
1690
1731
  } // kb
1691
1732
  if (size < Math.pow(num, 3)) {
1692
- return toCeilStr(size / Math.pow(num, 2)) + " MB";
1733
+ return toCeilStr(size / Math.pow(num, 2)) + ' MB';
1693
1734
  } // M
1694
1735
  if (size < Math.pow(num, 4)) {
1695
- return toCeilStr(size / Math.pow(num, 3)) + " G";
1736
+ return toCeilStr(size / Math.pow(num, 3)) + ' G';
1696
1737
  } // G
1697
- return toCeilStr(size / Math.pow(num, 4)) + " T";
1738
+ return toCeilStr(size / Math.pow(num, 4)) + ' T';
1698
1739
  }
1699
1740
 
1700
1741
  /**
@@ -1712,7 +1753,7 @@ export function isSupportWebp(): Promise<boolean> {
1712
1753
  resolve(false);
1713
1754
  };
1714
1755
  img.src =
1715
- "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=";
1756
+ 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=';
1716
1757
  };
1717
1758
  return new Promise(fn);
1718
1759
  }