mazey 1.4.39 → 2.0.0

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/lib/index.cjs.js CHANGED
@@ -3020,6 +3020,14 @@ function __spreadArrays() {
3020
3020
  */
3021
3021
 
3022
3022
  function calLongestCommonSubstring(aStr, bStr) {
3023
+ if (aStr === void 0) {
3024
+ aStr = '';
3025
+ }
3026
+
3027
+ if (bStr === void 0) {
3028
+ bStr = '';
3029
+ }
3030
+
3023
3031
  var aLen = aStr.length;
3024
3032
  var bLen = bStr.length; // 创建二维数组并且深拷贝
3025
3033
 
@@ -3054,6 +3062,14 @@ function calLongestCommonSubstring(aStr, bStr) {
3054
3062
  */
3055
3063
 
3056
3064
  function calLongestCommonSubsequence(aStr, bStr) {
3065
+ if (aStr === void 0) {
3066
+ aStr = '';
3067
+ }
3068
+
3069
+ if (bStr === void 0) {
3070
+ bStr = '';
3071
+ }
3072
+
3057
3073
  var aLen = aStr.length;
3058
3074
  var bLen = bStr.length; // 创建二维数组并且深拷贝
3059
3075
 
@@ -3094,148 +3110,178 @@ function calLongestCommonSubsequence(aStr, bStr) {
3094
3110
  return maxLong;
3095
3111
  }
3096
3112
  /**
3097
- * @method join
3098
- * @description 将一系列值连接成固定字符分隔的字符串 123,456 => 123 - 456。
3099
- * @param {String} joinStr 连接值的字符串。
3100
- * @param {Rest} ...rest 需要连接的值 。
3113
+ * @method getQueryParam
3114
+ * @description Get the query param's value of the current Web URL(`location.search`).
3115
+ * @param {String} param Query param.
3116
+ * @return {String} value
3101
3117
  * */
3102
3118
 
3103
- function join(joinStr) {
3104
- var rest = [];
3105
-
3106
- for (var _i = 1; _i < arguments.length; _i++) {
3107
- rest[_i - 1] = arguments[_i];
3119
+ function getQueryParam(param) {
3120
+ if (param === void 0) {
3121
+ param = '';
3108
3122
  }
3109
3123
 
3110
- var ret = '';
3111
- var len = joinStr.length;
3112
-
3113
- for (var _a = 0, rest_1 = rest; _a < rest_1.length; _a++) {
3114
- var v = rest_1[_a];
3124
+ var reg = new RegExp('(^|&)' + param + '=([^&]*)(&|$)');
3125
+ var r = location.search.substr(1).match(reg);
3115
3126
 
3116
- if (v) {
3117
- ret += "" + joinStr + v;
3118
- }
3119
- }
3120
-
3121
- if (ret) {
3122
- ret = ret.substring(len);
3127
+ if (r !== null) {
3128
+ return decodeURIComponent(unescape(r[2]));
3123
3129
  }
3124
3130
 
3125
- return ret;
3131
+ return '';
3126
3132
  }
3127
3133
  /**
3128
- * @method renderTable
3129
- * @description 渲染表格
3130
- * @param {DOM Object} tbID
3131
- * @param {Array} data
3132
- * @param {Array} property
3133
- */
3134
+ * @method getUrlParam
3135
+ * @description Get the query param's value of the input URL.
3136
+ * @param {String} url URL string.
3137
+ * @param {String} param Query param.
3138
+ * @return {String} value
3139
+ * */
3134
3140
 
3135
- function renderTable(tbID, data, property) {
3136
- if (tbID === void 0) {
3137
- tbID = null;
3141
+ function getUrlParam(url, param) {
3142
+ if (url === void 0) {
3143
+ url = '';
3138
3144
  }
3139
3145
 
3140
- if (data === void 0) {
3141
- data = [];
3146
+ if (param === void 0) {
3147
+ param = '';
3142
3148
  }
3143
3149
 
3144
- if (property === void 0) {
3145
- property = [];
3146
- }
3150
+ var result = {}; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
3151
+
3152
+ url.replace(/\??(\w+)=([^&]*)&?/g, function (a, k, v) {
3153
+ if (result[k] !== undefined) {
3154
+ var t = result[k];
3155
+ result[k] = [].concat(t, v);
3156
+ } else {
3157
+ result[k] = v;
3158
+ }
3159
+ }); // if (param === undefined) {
3160
+ // return result;
3161
+ // } else {
3162
+ // return result[param] || '';
3163
+ // }
3147
3164
 
3148
- var TBODY = document.querySelector("#" + tbID + " tbody");
3165
+ return result[param] || '';
3166
+ }
3167
+ /**
3168
+ * @method updateQueryParam
3169
+ * @description Update the query param's value of the input URL.
3170
+ * @param {String} url URL string.
3171
+ * @param {String} param Query param.
3172
+ * @param {String} value Param's value.
3173
+ * @return {String} URL.
3174
+ * */
3149
3175
 
3150
- function mNullToNA(str) {
3151
- return str === null ? 'N.A.' : str;
3176
+ function updateQueryParam(url, param, value) {
3177
+ if (url === void 0) {
3178
+ url = '';
3152
3179
  }
3153
3180
 
3154
- var content = '';
3155
- TBODY.innerHTML = ''; // 无数据
3181
+ if (param === void 0) {
3182
+ param = '';
3183
+ }
3156
3184
 
3157
- if (!data.length) {
3158
- content = "<tr><td colspan=\"" + property.length + "\">\u65E0\u6570\u636E</td></tr>";
3159
- } else {
3160
- for (var _a = [0, data.length], i = _a[0], max = _a[1]; i < max; ++i) {
3161
- var item = data[i];
3162
- content += '<tr>';
3185
+ if (value === void 0) {
3186
+ value = '';
3187
+ }
3163
3188
 
3164
- for (var _b = [0, property.length], i_1 = _b[0], max_1 = _b[1]; i_1 < max_1; ++i_1) {
3165
- content += "<td>" + mNullToNA(item[property[i_1]]) + "</td>";
3166
- }
3189
+ var re = new RegExp('([?&])' + param + '=.*?(&|$)', 'i');
3190
+ var separator = url.indexOf('?') !== -1 ? '&' : '?';
3167
3191
 
3168
- content += '</tr>';
3169
- }
3192
+ if (url.match(re)) {
3193
+ return url.replace(re, '$1' + param + '=' + value + '$2');
3194
+ } else {
3195
+ return url + separator + param + '=' + value;
3170
3196
  }
3171
-
3172
- TBODY.innerHTML = content;
3173
3197
  }
3174
3198
  /**
3175
3199
  * @method getHashQueryParam
3176
- * @description 获取地址栏 hash 后面的参数。
3177
- * @param {String} param 获取参数的名字。
3200
+ * @description Get the hash query param's value of the current Web URL(`location.hash`).
3201
+ * @param {String} param Query param.
3202
+ * @return {String} value
3178
3203
  */
3179
3204
 
3180
3205
  function getHashQueryParam(param) {
3181
- var hashs = window.location.hash.split('?');
3206
+ if (param === void 0) {
3207
+ param = '';
3208
+ }
3209
+
3210
+ var hashs = location.hash.split('?');
3182
3211
 
3183
3212
  if (hashs.length === 1) {
3184
- return null;
3213
+ return '';
3185
3214
  }
3186
3215
 
3187
3216
  var reg = new RegExp("(^|&)" + param + "=([^&]*)(&|$)");
3188
3217
  var ret = hashs[1].match(reg);
3189
- return ret ? ret[2] : null;
3218
+ return ret ? ret[2] : '';
3219
+ }
3220
+ /**
3221
+ * @method getDomain
3222
+ * @description Get the domain of URL, and other params.
3223
+ * @param {String} url
3224
+ * @param {Array} rules Object.keys(location), ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
3225
+ * */
3226
+
3227
+ function getDomain(url, rules) {
3228
+ if (url === void 0) {
3229
+ url = '';
3230
+ }
3231
+
3232
+ if (rules === void 0) {
3233
+ rules = ['hostname'];
3234
+ }
3235
+
3236
+ var aEl = document.createElement('a');
3237
+ aEl.href = url;
3238
+ return rules.reduce(function (ret, v) {
3239
+ ret += aEl[v];
3240
+ return ret;
3241
+ }, '');
3190
3242
  }
3191
3243
  /**
3192
3244
  * @method camelCaseToKebabCase
3193
- * @description 驼峰转连接线。
3194
- * @param {String} camelCase
3245
+ * @description Transfer CamelCase to KebabCase.
3246
+ * @param {String} camelCase 'aBC' or 'ABC'
3247
+ * @return {String} 'a-b-c'
3195
3248
  * */
3196
3249
 
3197
3250
  function camelCaseToKebabCase(camelCase) {
3251
+ if (camelCase === void 0) {
3252
+ camelCase = '';
3253
+ }
3254
+
3198
3255
  var kebabCase = camelCase.replace(/([A-Z])/g, '-$1').toLowerCase();
3199
3256
  return kebabCase[0] === '-' ? kebabCase.substr(1) : kebabCase;
3200
3257
  }
3201
3258
  /**
3202
3259
  * @method camelCase2Underscore
3203
- * @description 驼峰转下划线。
3204
- * @param {String} camelCase
3260
+ * @description Transfer CamelCase to Underscore.
3261
+ * @param {String} camelCase 'aBC' or 'ABC'
3262
+ * @return {String} 'a_b_c'
3205
3263
  * */
3206
3264
 
3207
3265
  function camelCase2Underscore(camelCase) {
3266
+ if (camelCase === void 0) {
3267
+ camelCase = '';
3268
+ }
3269
+
3208
3270
  var kebabCase = camelCase.replace(/([A-Z])/g, '_$1').toLowerCase();
3209
3271
  return kebabCase[0] === '_' ? kebabCase.substr(1) : kebabCase;
3210
3272
  }
3211
3273
  /**
3212
- * @method getDomain
3213
- * @description 获取地址中的域名(及其他参数)。
3214
- * @param {String} url
3215
- * @param {Array} rules ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
3274
+ * @method mTrim
3275
+ * @description Remove leading and trailing whitespace or specified characters from string.
3276
+ * @param {String} str The string to trim.
3277
+ * @return {String} Trimmed string.
3216
3278
  * */
3217
3279
 
3218
- function getDomain(_a) {
3219
- var _b = _a === void 0 ? {} : _a,
3220
- _c = _b.url,
3221
- url = _c === void 0 ? '' : _c,
3222
- _d = _b.rules,
3223
- rules = _d === void 0 ? ['hostname'] : _d;
3224
-
3225
- var aEl = document.createElement('a');
3226
- aEl.href = url;
3227
- return rules.reduce(function (ret, v, index) {
3228
- ret += aEl[v];
3229
- return ret;
3230
- }, '');
3231
- }
3232
- /**
3233
- * @method trim
3234
- * @description 去除左右空格。
3235
- * @param {String} str 需要去除两边空格的字符串。
3236
- * */
3280
+ function mTrim(str) {
3281
+ if (str === void 0) {
3282
+ str = '';
3283
+ }
3237
3284
 
3238
- function trim$1(str) {
3239
3285
  str = str.replace(/^\s+/, ''); // 去除头部空格
3240
3286
 
3241
3287
  var end = str.length - 1;
@@ -3249,11 +3295,16 @@ function trim$1(str) {
3249
3295
  }
3250
3296
  /**
3251
3297
  * @method newLine
3252
- * @description html换行。
3253
- * @param {String} str
3298
+ * @description Make a newline of HTML.
3299
+ * @param {String} str The string to make a newline.
3300
+ * @return {String} A newline with `<br />`.
3254
3301
  * */
3255
3302
 
3256
3303
  function newLine(str) {
3304
+ if (str === void 0) {
3305
+ str = '';
3306
+ }
3307
+
3257
3308
  if (!str) {
3258
3309
  return '';
3259
3310
  }
@@ -3263,22 +3314,48 @@ function newLine(str) {
3263
3314
  }
3264
3315
  /**
3265
3316
  * @method deepCopyObject
3266
- * @description 对象深拷贝。
3267
- * @param {Object} obj 被拷贝的对象。
3268
- * @return {Object}
3317
+ * @description Clone Object deeply.
3318
+ * @param {Object} obj The value to clone.
3319
+ * @return {Object} Returns the deep cloned value.
3269
3320
  * */
3270
3321
 
3271
3322
  function deepCopyObject(obj) {
3272
3323
  return JSON.parse(JSON.stringify(obj));
3273
3324
  }
3325
+ /**
3326
+ * @method isJsonString
3327
+ * @description Check whether it is a valid JSON string.
3328
+ * @param {String} str The string to check.
3329
+ * @return {Boolean} Return the result of checking.
3330
+ * */
3331
+
3332
+ function isJsonString(str) {
3333
+ if (str === void 0) {
3334
+ str = '';
3335
+ }
3336
+
3337
+ try {
3338
+ if (_typeof_1(JSON.parse(str)) === 'object') {
3339
+ return true;
3340
+ }
3341
+ } catch (e) {
3342
+ /* pass */
3343
+ }
3344
+
3345
+ return false;
3346
+ }
3274
3347
  /**
3275
3348
  * @method generateRndNum
3276
- * @description 生成随机数 mGenerateRndNum(7) => 7658495。
3277
- * @param {Number} n 随机数的长度
3278
- * @return {String}
3349
+ * @description Produce a random string of number, `generateRndNum(7)` => '7658495'.
3350
+ * @param {Number} n Length
3351
+ * @return {String} Return the random string.
3279
3352
  * */
3280
3353
 
3281
3354
  function generateRndNum(n) {
3355
+ if (n === void 0) {
3356
+ n = 5;
3357
+ }
3358
+
3282
3359
  var ret = '';
3283
3360
 
3284
3361
  while (n--) {
@@ -3294,36 +3371,15 @@ function generateRndNum(n) {
3294
3371
  * */
3295
3372
 
3296
3373
  function generateUniqueNum(n) {
3374
+ if (n === void 0) {
3375
+ n = 3;
3376
+ }
3377
+
3297
3378
  var _a = [mNow(), generateRndNum(n || 3)],
3298
3379
  now = _a[0],
3299
3380
  rnd = _a[1];
3300
3381
  return now + rnd;
3301
3382
  }
3302
- /**
3303
- * @method resetForm
3304
- * @description 重置表单输入值为原始(空)状态。
3305
- * @param {String} rest name1,name2,name3...NAME属性,可以多个。
3306
- * */
3307
-
3308
- function resetForm() {
3309
- var rest = [];
3310
-
3311
- for (var _i = 0; _i < arguments.length; _i++) {
3312
- rest[_i] = arguments[_i];
3313
- }
3314
-
3315
- for (var i = 0; i < rest.length; i++) {
3316
- var tagMz = document.getElementsByName(rest[i])[0]; // tag object
3317
-
3318
- var tagNameMz = tagMz.tagName.toLowerCase(); // tag name
3319
-
3320
- if (tagNameMz === 'input') {
3321
- tagMz.value = '';
3322
- } else if (tagNameMz === 'select') {
3323
- tagMz.options[0].selected = true;
3324
- }
3325
- }
3326
- }
3327
3383
  /**
3328
3384
  * @method floatToPercent
3329
3385
  * @description 浮点数转为百分比 0.2 => 20%。
@@ -3332,17 +3388,23 @@ function resetForm() {
3332
3388
  * */
3333
3389
 
3334
3390
  function floatToPercent(num, fixSize) {
3391
+ if (num === void 0) {
3392
+ num = 0;
3393
+ }
3394
+
3335
3395
  if (fixSize === void 0) {
3336
3396
  fixSize = 0;
3337
3397
  }
3338
3398
 
3399
+ var ret = '';
3400
+
3339
3401
  if (fixSize) {
3340
- num = (num * 100).toFixed(fixSize);
3402
+ ret = (num * 100).toFixed(fixSize);
3341
3403
  } else {
3342
- num = Math.floor(num * 100);
3404
+ ret = String(Math.floor(num * 100));
3343
3405
  }
3344
3406
 
3345
- return num + "%";
3407
+ return ret + "%";
3346
3408
  }
3347
3409
  /**
3348
3410
  * @method floatFixed
@@ -3350,23 +3412,11 @@ function floatToPercent(num, fixSize) {
3350
3412
  * */
3351
3413
 
3352
3414
  function floatFixed(num, size) {
3353
- return parseFloat(num).toFixed(size);
3354
- }
3355
- /**
3356
- * @method compatibleExist
3357
- * @description 不存在返回 ——。
3358
- * */
3359
-
3360
- function compatibleExist(instance, replaceStr) {
3361
- var ret = '';
3362
-
3363
- try {
3364
- ret = instance || replaceStr || '——';
3365
- } catch (e) {
3366
- ret = '——';
3415
+ if (size === void 0) {
3416
+ size = 0;
3367
3417
  }
3368
3418
 
3369
- return ret;
3419
+ return parseFloat(num).toFixed(size);
3370
3420
  }
3371
3421
  /**
3372
3422
  * @method cancelBubble
@@ -3613,7 +3663,7 @@ function friendlyInterval(_a) {
3613
3663
  /**
3614
3664
  * @method isNumber
3615
3665
  * @description 判断是否有效数字
3616
- * @param {Any} num 被判断的值
3666
+ * @param {*} num 被判断的值
3617
3667
  * @param {Boolean} isNaNAsNumber 是否 NaN 算数字(默认不算)
3618
3668
  * @param {Boolean} isUnFiniteAsNumber 是否 无限 算数字(默认不算)
3619
3669
  * @return {Boolean} true 是数字
@@ -3646,84 +3696,6 @@ function isNumber(num, _a) {
3646
3696
 
3647
3697
  return ret;
3648
3698
  }
3649
- /**
3650
- * @method updateQueryStringParameter
3651
- * @description 替换或添加地址栏参数。
3652
- * */
3653
-
3654
- function updateQueryStringParameter(uri, key, value) {
3655
- var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
3656
- var separator = uri.indexOf('?') !== -1 ? '&' : '?';
3657
-
3658
- if (uri.match(re)) {
3659
- return uri.replace(re, '$1' + key + '=' + value + '$2');
3660
- } else {
3661
- return uri + separator + key + '=' + value;
3662
- }
3663
- }
3664
- /**
3665
- * @method isJsonString
3666
- * @description 判断是否合法 JSON 字符串。
3667
- * */
3668
-
3669
- function isJsonString(str) {
3670
- try {
3671
- if (_typeof_1(JSON.parse(str)) === 'object') {
3672
- return true;
3673
- }
3674
- } catch (e) {
3675
- /* pass */
3676
- }
3677
-
3678
- return false;
3679
- }
3680
- /**
3681
- * @method getUrlParam
3682
- * @description 链接参数
3683
- * @param {String} sUrl 链接
3684
- * @param {String} sKey 参数
3685
- * */
3686
-
3687
- function getUrlParam(sUrl, sKey) {
3688
- var result = {};
3689
- sUrl.replace(/\??(\w+)=([^&]*)&?/g, function (a, k, v) {
3690
- if (result[k] !== undefined) {
3691
- var t = result[k];
3692
- result[k] = [].concat(t, v);
3693
- } else {
3694
- result[k] = v;
3695
- }
3696
- });
3697
-
3698
- if (sKey === undefined) {
3699
- return result;
3700
- } else {
3701
- return result[sKey] || '';
3702
- }
3703
- }
3704
- /**
3705
- * @method getSearchQueryParam
3706
- * @description 地址栏参数。
3707
- * */
3708
-
3709
- function getSearchQueryParam(name) {
3710
- var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
3711
- var r = window.location.search.substr(1).match(reg);
3712
-
3713
- if (r != null) {
3714
- return decodeURIComponent(unescape(r[2]));
3715
- }
3716
-
3717
- return null;
3718
- }
3719
- /**
3720
- * @method getQueryParam
3721
- * @description 地址栏参数,getSearchQueryParam 的别名。
3722
- * */
3723
-
3724
- function getQueryParam(name) {
3725
- return getSearchQueryParam(name);
3726
- }
3727
3699
  /**
3728
3700
  * @method doFn
3729
3701
  * @description 执行有效函数
@@ -3765,7 +3737,7 @@ function setSessionStorage(key, value) {
3765
3737
  * @method getSessionStorage
3766
3738
  * @description 存储数据到 sessionStorage
3767
3739
  * @param {String} key 键
3768
- * @return {Any} 返回值
3740
+ * @return {*} 返回值
3769
3741
  * */
3770
3742
 
3771
3743
  function getSessionStorage(key) {
@@ -3801,7 +3773,7 @@ function setLocalStorage(key, value) {
3801
3773
  * @method getLocalStorage
3802
3774
  * @description 存储数据到 localStorage
3803
3775
  * @param {String} key 键
3804
- * @return {Any} 返回值
3776
+ * @return {*} 返回值
3805
3777
  * */
3806
3778
 
3807
3779
  function getLocalStorage(key) {
@@ -4094,7 +4066,7 @@ function getCookie(name) {
4094
4066
  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
4095
4067
  }
4096
4068
 
4097
- return null;
4069
+ return '';
4098
4070
  }
4099
4071
  /**
4100
4072
  * @method getPerformance
@@ -4735,232 +4707,6 @@ function addInlineStyle(_a) {
4735
4707
 
4736
4708
  return true;
4737
4709
  }
4738
- /**
4739
- * @method customScrollBarForTransformEle
4740
- * @description 为进行变换(transform)的元素设置滚动条
4741
- * @param {String} containerClassName 进行变换(transform)的元素↓的容器(Father)的类名
4742
- * @param {String} imgBoxClassName 图片的容器(transform It's YOU!)的类名
4743
- * @param {String} imgBoxDom 图片的容器 Dom 对象
4744
- * @param {String} imgClassName 图片的类名
4745
- * @param {Object} imgDom 图片 Dom 对象
4746
- * @param {String} action 操作类型 hide 隐藏指定 `containerClassName` 滚动条
4747
- * @param {String} customStyle 滚动条的定制样式,会覆盖默认样式
4748
- * @return {Boolean} 设置成功
4749
- */
4750
-
4751
- function customScrollBarForTransformEle(_a) {
4752
- var _b = _a === void 0 ? {} : _a,
4753
- _c = _b.containerClassName,
4754
- containerClassName = _c === void 0 ? '' : _c,
4755
- _d = _b.imgBoxClassName,
4756
- imgBoxClassName = _d === void 0 ? '' : _d,
4757
- _e = _b.imgBoxDom,
4758
- imgBoxDom = _e === void 0 ? null : _e,
4759
- _f = _b.imgClassName,
4760
- imgClassName = _f === void 0 ? '' : _f,
4761
- _g = _b.imgDom,
4762
- imgDom = _g === void 0 ? null : _g,
4763
- _h = _b.action,
4764
- action = _h === void 0 ? '' : _h,
4765
- _j = _b.customStyle,
4766
- customStyle = _j === void 0 ? '' : _j; // 变量
4767
-
4768
-
4769
- var barIsHideId = 'bar-is-hide';
4770
- var barTopId = 'bar-top';
4771
- var barBottomId = 'bar-bottom';
4772
-
4773
- if (action === 'hide') {
4774
- addInlineStyle({
4775
- inlineStyle: "\n ." + containerClassName + "::after {\n display: none;\n }\n ",
4776
- id: barIsHideId
4777
- });
4778
- return true;
4779
- }
4780
-
4781
- setTimeout(function () {
4782
- // 样式初始化
4783
- addInlineStyle({
4784
- inlineStyle: "\n ." + containerClassName + "::after {\n content: ' ';\n position: fixed;\n top: 0;\n right: 2px;\n min-height: 0vh;\n max-height: 100vh;\n width: 6px;\n border-radius: 3px;\n box-shadow: inset 0 0 6px rgba(0,0,0,.3);\n -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);\n background-color: rgb(109, 108, 109);\n " + customStyle + "\n }\n ",
4785
- id: 'bar-init'
4786
- });
4787
- var imgInstance = imgDom || document.querySelector("." + imgClassName);
4788
-
4789
- if (!imgInstance) {
4790
- console.warn('Need element\'s Dom instance.');
4791
- return false;
4792
- }
4793
-
4794
- var imgBoxInstance = imgBoxDom || document.querySelector("." + imgBoxClassName);
4795
-
4796
- if (!imgBoxInstance) {
4797
- console.warn('Need element box\'s Dom instance.');
4798
- return false;
4799
- }
4800
-
4801
- var Box2ToRes = getBox2To(); // console.log('获取图片距离顶部的距离', Box2ToRes);
4802
-
4803
- var ImgHeightRes = getImgHeight(); // console.log('获取图片的高度', ImgHeightRes);
4804
-
4805
- var WindowHeightRes = getWindowHeight(); // console.log('获取窗口的高度', WindowHeightRes);
4806
-
4807
- var TopOverflowPercentRes = getTopOverflowPercent(); // console.log('获取顶部溢出的百分比', TopOverflowPercentRes);
4808
-
4809
- var BottomOverflowPercentRes = getBottomOverflowPercent(); // console.log('获取顶部溢出的百分比', BottomOverflowPercentRes);
4810
-
4811
- var hideBarRes = hideBar(); // console.log('如果都是 0 ,隐藏滚动条', hideBarRes);
4812
-
4813
- if (!hideBarRes) {
4814
- setBarTop(); // const setBarTopRes = setBarTop();
4815
- // console.log('设置顶部状态栏', setBarTopRes);
4816
-
4817
- setBarBottom(); // const setBarBottomRes = setBarBottom();
4818
- // console.log('设置底部状态栏', setBarBottomRes);
4819
- } // 获取图片距离顶部的距离
4820
-
4821
-
4822
- function getBox2To() {
4823
- var translates = window.getComputedStyle(imgBoxInstance, null).transform;
4824
- var tanslateY = parseFloat(translates.substring(6).split(',')[5]);
4825
- return tanslateY;
4826
- } // 获取图片的高度
4827
-
4828
-
4829
- function getImgHeight() {
4830
- var _a;
4831
-
4832
- return (_a = imgInstance) === null || _a === void 0 ? void 0 : _a.clientHeight;
4833
- } // 获取窗口的高度
4834
-
4835
-
4836
- function getWindowHeight() {
4837
- return document.querySelector("." + containerClassName).clientHeight; // window.outerHeight;
4838
- } // 获取顶部溢出的百分比
4839
-
4840
-
4841
- function getTopOverflowPercent() {
4842
- var box2To = Box2ToRes;
4843
-
4844
- if (box2To >= 0) {
4845
- box2To = 0;
4846
- }
4847
-
4848
- box2To = Math.abs(box2To); // 图片高度
4849
-
4850
- var imgHeight = ImgHeightRes;
4851
- var per = floatToPercent(box2To / imgHeight, 2);
4852
- return {
4853
- box2To: box2To,
4854
- per: per
4855
- };
4856
- } // 获取底部溢出的百分比
4857
-
4858
-
4859
- function getBottomOverflowPercent() {
4860
- // 窗口高度
4861
- var windowHeight = WindowHeightRes; // 图片高度
4862
-
4863
- var imgHeight = ImgHeightRes; // 上面溢出的高度
4864
-
4865
- var box2To = Box2ToRes; // 底部
4866
-
4867
- var remindImageHeight = windowHeight - box2To;
4868
- var box2ToBottom = imgHeight - remindImageHeight;
4869
-
4870
- if (box2ToBottom <= 0) {
4871
- box2ToBottom = 0;
4872
- }
4873
-
4874
- var per = floatToPercent(box2ToBottom / imgHeight, 2);
4875
- return {
4876
- box2ToBottom: box2ToBottom,
4877
- per: per
4878
- };
4879
- } // 如果都是 0 ,隐藏滚动条
4880
-
4881
-
4882
- function hideBar() {
4883
- var box2To = TopOverflowPercentRes.box2To;
4884
- var box2ToBottom = BottomOverflowPercentRes.box2ToBottom;
4885
-
4886
- if (!box2To && !box2ToBottom) {
4887
- return addInlineStyle({
4888
- inlineStyle: "\n ." + containerClassName + "::after {\n display: none;\n }\n ",
4889
- id: barIsHideId
4890
- });
4891
- } else {
4892
- addInlineStyle({
4893
- inlineStyle: "\n ." + containerClassName + "::after {\n display: block;\n }\n ",
4894
- id: barIsHideId
4895
- });
4896
- }
4897
-
4898
- return false;
4899
- } // 设置顶部状态栏
4900
-
4901
-
4902
- function setBarTop() {
4903
- var per = TopOverflowPercentRes.per;
4904
- return addInlineStyle({
4905
- inlineStyle: "\n ." + containerClassName + "::after {\n top: " + per + ";\n }\n ",
4906
- id: barTopId
4907
- });
4908
- } // 设置底部状态栏
4909
-
4910
-
4911
- function setBarBottom() {
4912
- var per = BottomOverflowPercentRes.per;
4913
- return addInlineStyle({
4914
- inlineStyle: "\n ." + containerClassName + "::after {\n bottom: " + per + ";\n }\n ",
4915
- id: barBottomId
4916
- });
4917
- }
4918
- }, 25);
4919
- return true;
4920
- }
4921
- /**
4922
- * @method calcContainImageSizeAndPosition
4923
- * @description 计算适配容器宽度的图片的尺寸、距离顶部的距离。如果高度不足以占满容器,使其垂直居中;如果高度比容器长,由上向下铺开。
4924
- * @param {Number} oriImageWidth 图片原始宽度
4925
- * @param {Number} oriImageHeight 图片原始高度
4926
- * @param {Number} viewportWidth 可视窗口宽度
4927
- * @param {Number} viewportHeight 可视窗口高度
4928
- * @return {Object} 结果 {"targetImageWidth":375,"targetImageHeight":375,"top":218.5,"wPer":1.25}
4929
- */
4930
-
4931
- function calcContainImageSizeAndPosition(_a) {
4932
- var _b = _a === void 0 ? {} : _a,
4933
- _c = _b.oriImageWidth,
4934
- oriImageWidth = _c === void 0 ? 0 : _c,
4935
- _d = _b.oriImageHeight,
4936
- oriImageHeight = _d === void 0 ? 0 : _d,
4937
- _e = _b.viewportWidth,
4938
- viewportWidth = _e === void 0 ? 0 : _e,
4939
- _f = _b.viewportHeight,
4940
- viewportHeight = _f === void 0 ? 0 : _f;
4941
-
4942
- var targetImageWidth = viewportWidth;
4943
- var _g = [0, 0, 0],
4944
- targetImageHeight = _g[0],
4945
- top = _g[1],
4946
- wPer = _g[2]; // 比例
4947
-
4948
- wPer = viewportWidth / oriImageWidth; // 1.+ 1.1 1.5
4949
-
4950
- targetImageHeight = oriImageHeight * wPer;
4951
-
4952
- if (targetImageHeight < viewportHeight) {
4953
- var doubleGap = viewportHeight - targetImageHeight;
4954
- top = doubleGap / 2;
4955
- }
4956
-
4957
- return {
4958
- targetImageWidth: targetImageWidth,
4959
- targetImageHeight: targetImageHeight,
4960
- top: top,
4961
- wPer: wPer
4962
- };
4963
- }
4964
4710
  /**
4965
4711
  * @method genCustomConsole
4966
4712
  * @description 生成自定义控制台打印
@@ -4971,8 +4717,7 @@ function calcContainImageSizeAndPosition(_a) {
4971
4717
 
4972
4718
  function genCustomConsole(_a) {
4973
4719
  var _b = (_a === void 0 ? {} : _a).prefix,
4974
- prefix = _b === void 0 ? '' : _b; // ...
4975
-
4720
+ prefix = _b === void 0 ? '' : _b;
4976
4721
  var methods = ['log', 'info', 'warn', 'error'];
4977
4722
  var newConsole = Object.create(null);
4978
4723
  methods.forEach(function (method) {
@@ -4999,13 +4744,10 @@ exports.addClass = addClass;
4999
4744
  exports.addInlineStyle = addInlineStyle;
5000
4745
  exports.calLongestCommonSubsequence = calLongestCommonSubsequence;
5001
4746
  exports.calLongestCommonSubstring = calLongestCommonSubstring;
5002
- exports.calcContainImageSizeAndPosition = calcContainImageSizeAndPosition;
5003
4747
  exports.camelCase2Underscore = camelCase2Underscore;
5004
4748
  exports.camelCaseToKebabCase = camelCaseToKebabCase;
5005
4749
  exports.cancelBubble = cancelBubble;
5006
4750
  exports.clearHtml = clearHtml;
5007
- exports.compatibleExist = compatibleExist;
5008
- exports.customScrollBarForTransformEle = customScrollBarForTransformEle;
5009
4751
  exports.cutCHSString = cutCHSString;
5010
4752
  exports.debounce = debounce;
5011
4753
  exports.deepCopyObject = deepCopyObject;
@@ -5023,7 +4765,6 @@ exports.getHashQueryParam = getHashQueryParam;
5023
4765
  exports.getLocalStorage = getLocalStorage;
5024
4766
  exports.getPerformance = getPerformance;
5025
4767
  exports.getQueryParam = getQueryParam;
5026
- exports.getSearchQueryParam = getSearchQueryParam;
5027
4768
  exports.getSessionStorage = getSessionStorage;
5028
4769
  exports.getUrlParam = getUrlParam;
5029
4770
  exports.hasClass = hasClass;
@@ -5031,18 +4772,15 @@ exports.inRate = inRate;
5031
4772
  exports.isJsonString = isJsonString;
5032
4773
  exports.isNumber = isNumber;
5033
4774
  exports.isSafePWAEnv = isSafePWAEnv;
5034
- exports.join = join;
5035
4775
  exports.loadCSS = loadCSS;
5036
4776
  exports.loadScript = loadScript;
5037
4777
  exports.mNow = mNow;
4778
+ exports.mTrim = mTrim;
5038
4779
  exports.newLine = newLine;
5039
4780
  exports.removeClass = removeClass;
5040
- exports.renderTable = renderTable;
5041
- exports.resetForm = resetForm;
5042
4781
  exports.setCookie = setCookie;
5043
4782
  exports.setLocalStorage = setLocalStorage;
5044
4783
  exports.setSessionStorage = setSessionStorage;
5045
4784
  exports.throttle = throttle;
5046
- exports.trim = trim$1;
5047
- exports.updateQueryStringParameter = updateQueryStringParameter;
4785
+ exports.updateQueryParam = updateQueryParam;
5048
4786
  exports.windowLoaded = windowLoaded;