@ajaxjs/ui 1.3.9 → 1.3.10

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.
@@ -214,7 +214,7 @@ var render = function render() {
214
214
  var staticRenderFns = [];
215
215
 
216
216
  // EXTERNAL MODULE: ./node_modules/@ajaxjs/util/dist/index.esm.js
217
- var index_esm = __webpack_require__(2957);
217
+ var index_esm = __webpack_require__(2822);
218
218
  // EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
219
219
  var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__(4100);
220
220
  var external_commonjs_vue_commonjs2_vue_root_Vue_default = /*#__PURE__*/__webpack_require__.n(external_commonjs_vue_commonjs2_vue_root_Vue_);
@@ -380,7 +380,7 @@ var staticRenderFns = [];
380
380
  // EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom-exception.stack.js
381
381
  var web_dom_exception_stack = __webpack_require__(4979);
382
382
  // EXTERNAL MODULE: ./node_modules/@ajaxjs/util/dist/index.esm.js
383
- var index_esm = __webpack_require__(2957);
383
+ var index_esm = __webpack_require__(2822);
384
384
  // EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
385
385
  var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__(4100);
386
386
  var external_commonjs_vue_commonjs2_vue_root_Vue_default = /*#__PURE__*/__webpack_require__.n(external_commonjs_vue_commonjs2_vue_root_Vue_);
@@ -627,7 +627,7 @@ var external_commonjs_vue_commonjs2_vue_root_Vue_default = /*#__PURE__*/__webpac
627
627
  // EXTERNAL MODULE: ./src/iview-ext/list.ts
628
628
  var list = __webpack_require__(7184);
629
629
  // EXTERNAL MODULE: ./node_modules/@ajaxjs/util/dist/index.esm.js
630
- var index_esm = __webpack_require__(2957);
630
+ var index_esm = __webpack_require__(2822);
631
631
  ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-41.use[2]!./src/iview-ext/fast-iview-table.ts?vue&type=script&lang=ts&external
632
632
 
633
633
 
@@ -932,7 +932,7 @@ var staticRenderFns = [];
932
932
  var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__(4100);
933
933
  var external_commonjs_vue_commonjs2_vue_root_Vue_default = /*#__PURE__*/__webpack_require__.n(external_commonjs_vue_commonjs2_vue_root_Vue_);
934
934
  // EXTERNAL MODULE: ./node_modules/@ajaxjs/util/dist/index.esm.js
935
- var index_esm = __webpack_require__(2957);
935
+ var index_esm = __webpack_require__(2822);
936
936
  ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/iview-ext/table-selector.vue?vue&type=script&lang=js
937
937
 
938
938
 
@@ -1289,7 +1289,7 @@ function normalizeComponent(
1289
1289
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1290
1290
 
1291
1291
  "use strict";
1292
- /* harmony import */ var _ajaxjs_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2957);
1292
+ /* harmony import */ var _ajaxjs_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2822);
1293
1293
 
1294
1294
  /* harmony default export */ __webpack_exports__.A = ({
1295
1295
  afterDelete(cb) {
@@ -3568,7 +3568,7 @@ if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
3568
3568
 
3569
3569
  /***/ }),
3570
3570
 
3571
- /***/ 2957:
3571
+ /***/ 2822:
3572
3572
  /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3573
3573
 
3574
3574
  "use strict";
@@ -3584,10 +3584,12 @@ if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
3584
3584
  * @returns 值
3585
3585
  */
3586
3586
  function getCookie(name) {
3587
- let arr,
3588
- reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
3589
- // @ts-ignore
3590
- if (arr = document.cookie.match(reg)) return unescape(arr[2]);else return null;
3587
+ let arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
3588
+ // @ts-ignore
3589
+ if (arr = document.cookie.match(reg))
3590
+ return unescape(arr[2]);
3591
+ else
3592
+ return null;
3591
3593
  }
3592
3594
  /**
3593
3595
  * 设置某个 Cookie
@@ -3596,31 +3598,31 @@ function getCookie(name) {
3596
3598
  * @param value 值
3597
3599
  */
3598
3600
  function setCookie(name, value) {
3599
- let days = 2,
3600
- exp = new Date();
3601
- exp.setTime(exp.getTime() + days * 24 * 60 * 60 * 1000);
3602
- // @ts-ignore
3603
- document.cookie = name + "=" + escape(value) + ";path=/;expires=" + exp.toGMTString();
3601
+ let days = 2, exp = new Date();
3602
+ exp.setTime(exp.getTime() + days * 24 * 60 * 60 * 1000);
3603
+ // @ts-ignore
3604
+ document.cookie = name + "=" + escape(value) + ";path=/;expires=" + exp.toGMTString();
3604
3605
  }
3605
3606
  /**
3606
3607
  * 清空 Cookie
3607
3608
  */
3608
3609
  function delCookie() {
3609
- let keys = document.cookie.match(/[^ =;]+(?==)/g);
3610
- if (keys) {
3611
- let date = new Date(0).toUTCString();
3612
- for (let i = keys.length; i--;) {
3613
- document.cookie = keys[i] + '=0;path=/;expires=' + date; // 清除当前域名下的,例如:m.ratingdog.cn
3614
- document.cookie = keys[i] + '=0;path=/;domain=' + document.domain + ';expires=' + date; // 清除当前域名下的,例如 .m.ratingdog.cn
3615
- document.cookie = keys[i] + '=0;path=/;domain=' + location.host + ';expires=' + date; // 清除一级域名下的或指定的,例如 .ratingdog.cn
3610
+ let keys = document.cookie.match(/[^ =;]+(?==)/g);
3611
+ if (keys) {
3612
+ let date = new Date(0).toUTCString();
3613
+ for (let i = keys.length; i--;) {
3614
+ document.cookie = keys[i] + '=0;path=/;expires=' + date; // 清除当前域名下的,例如:m.ratingdog.cn
3615
+ document.cookie = keys[i] + '=0;path=/;domain=' + document.domain + ';expires=' + date; // 清除当前域名下的,例如 .m.ratingdog.cn
3616
+ document.cookie = keys[i] + '=0;path=/;domain=' + location.host + ';expires=' + date; // 清除一级域名下的或指定的,例如 .ratingdog.cn
3617
+ }
3616
3618
  }
3617
- }
3618
3619
  }
3620
+
3619
3621
  var cookies = /*#__PURE__*/Object.freeze({
3620
- __proto__: null,
3621
- delCookie: delCookie,
3622
- getCookie: getCookie,
3623
- setCookie: setCookie
3622
+ __proto__: null,
3623
+ delCookie: delCookie,
3624
+ getCookie: getCookie,
3625
+ setCookie: setCookie
3624
3626
  });
3625
3627
 
3626
3628
  /**
@@ -3632,15 +3634,18 @@ var cookies = /*#__PURE__*/Object.freeze({
3632
3634
  * @returns 目标元素,找不到为 null
3633
3635
  */
3634
3636
  function up(_el, tagName, className) {
3635
- if (tagName && className) throw '只能任选一种参数,不能同时传';
3636
- let el = _el.parentNode;
3637
- tagName = tagName && tagName.toUpperCase();
3638
- while (el) {
3639
- if (tagName && el.tagName == tagName) return el;
3640
- if (className && el.className && ~el.className.indexOf(className)) return el;
3641
- el = el.parentNode;
3642
- }
3643
- return null;
3637
+ if (tagName && className)
3638
+ throw '只能任选一种参数,不能同时传';
3639
+ let el = _el.parentNode;
3640
+ tagName = tagName && tagName.toUpperCase();
3641
+ while (el) {
3642
+ if (tagName && el.tagName == tagName)
3643
+ return el;
3644
+ if (className && el.className && ~el.className.indexOf(className))
3645
+ return el;
3646
+ el = el.parentNode;
3647
+ }
3648
+ return null;
3644
3649
  }
3645
3650
  /**
3646
3651
  * 加载脚本
@@ -3650,16 +3655,19 @@ function up(_el, tagName, className) {
3650
3655
  * @param cb 回调函数,可选的
3651
3656
  */
3652
3657
  function loadScript(url, id, cb) {
3653
- let script = document.createElement("script");
3654
- script.src = url;
3655
- if (cb) script.onload = cb;
3656
- if (id) script.id = id;
3657
- document.getElementsByTagName("head")[0].appendChild(script);
3658
+ let script = document.createElement("script");
3659
+ script.src = url;
3660
+ if (cb)
3661
+ script.onload = cb;
3662
+ if (id)
3663
+ script.id = id;
3664
+ document.getElementsByTagName("head")[0].appendChild(script);
3658
3665
  }
3666
+
3659
3667
  var dom = /*#__PURE__*/Object.freeze({
3660
- __proto__: null,
3661
- loadScript: loadScript,
3662
- up: up
3668
+ __proto__: null,
3669
+ loadScript: loadScript,
3670
+ up: up
3663
3671
  });
3664
3672
 
3665
3673
  /**
@@ -3673,13 +3681,13 @@ var dom = /*#__PURE__*/Object.freeze({
3673
3681
  * @returns
3674
3682
  */
3675
3683
  function isDebug() {
3676
- // @ts-ignore
3677
- return "production" === 'development';
3684
+ // @ts-ignore
3685
+ return "production" === 'development';
3678
3686
  }
3679
3687
  function isDev() {
3680
- let currentHostname = window.location.hostname;
3681
- // 判断主机名是否是内网地址
3682
- return currentHostname.startsWith('192.168.') || currentHostname.startsWith('10.') || currentHostname === 'localhost';
3688
+ let currentHostname = window.location.hostname;
3689
+ // 判断主机名是否是内网地址
3690
+ return (currentHostname.startsWith('192.168.') || currentHostname.startsWith('10.') || currentHostname === 'localhost');
3683
3691
  }
3684
3692
  /**
3685
3693
  * 日期格式化。详见博客文章:http://blog.csdn.net/zhangxin09/archive/2011/01/01/6111294.aspx
@@ -3689,33 +3697,29 @@ function isDev() {
3689
3697
  * @return {String}
3690
3698
  */
3691
3699
  function dateFormat(format) {
3692
- let $1,
3693
- o = {
3694
- "M+": this.getMonth() + 1,
3695
- // 月份,从0开始算
3696
- "d+": this.getDate(),
3697
- // 日期
3698
- "h+": this.getHours(),
3699
- // 小时
3700
- "m+": this.getMinutes(),
3701
- // 分钟
3702
- "s+": this.getSeconds(),
3703
- // 秒钟
3704
- // 季度 quarter
3705
- "q+": Math.floor((this.getMonth() + 3) / 3),
3706
- "S": this.getMilliseconds() // 千秒
3700
+ let $1, o = {
3701
+ "M+": this.getMonth() + 1, // 月份,从0开始算
3702
+ "d+": this.getDate(), // 日期
3703
+ "h+": this.getHours(), // 小时
3704
+ "m+": this.getMinutes(), // 分钟
3705
+ "s+": this.getSeconds(), // 秒钟
3706
+ // 季度 quarter
3707
+ "q+": Math.floor((this.getMonth() + 3) / 3),
3708
+ "S": this.getMilliseconds() // 千秒
3707
3709
  };
3708
- if (/(y+)/.test(format))
3709
- // @ts-ignore
3710
- $1 = RegExp.$1, format = format.replace($1, String(this.getFullYear()).substr(4 - $1));
3711
- let key, value;
3712
- for (key in o) {
3713
- // 如果没有指定该参数,则子字符串将延续到 stringvar 的最后。
3714
- if (new RegExp("(" + key + ")").test(format)) {
3715
- $1 = RegExp.$1, value = String(o[key]), value = $1.length == 1 ? value : ("00" + value).substr(value.length), format = format.replace($1, value);
3710
+ if (/(y+)/.test(format))
3711
+ // @ts-ignore
3712
+ $1 = RegExp.$1, format = format.replace($1, String(this.getFullYear()).substr(4 - $1));
3713
+ let key, value;
3714
+ for (key in o) { // 如果没有指定该参数,则子字符串将延续到 stringvar 的最后。
3715
+ if (new RegExp("(" + key + ")").test(format)) {
3716
+ $1 = RegExp.$1,
3717
+ value = String(o[key]),
3718
+ value = $1.length == 1 ? value : ("00" + value).substr(value.length),
3719
+ format = format.replace($1, value);
3720
+ }
3716
3721
  }
3717
- }
3718
- return format;
3722
+ return format;
3719
3723
  }
3720
3724
  /**
3721
3725
  * 日期格式化
@@ -3725,28 +3729,24 @@ function dateFormat(format) {
3725
3729
  * @returns 格式化后的字符串
3726
3730
  */
3727
3731
  function dateFormat2(date, fmt) {
3728
- let o = {
3729
- "M+": date.getMonth() + 1,
3730
- // 月份
3731
- "d+": date.getDate(),
3732
- //
3733
- "h+": date.getHours(),
3734
- // 小时
3735
- "m+": date.getMinutes(),
3736
- // 分
3737
- "s+": date.getSeconds(),
3738
- //
3739
- "q+": Math.floor((date.getMonth() + 3) / 3),
3740
- // 季度
3741
- "S": date.getMilliseconds() // 毫秒
3742
- };
3743
- if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
3744
- for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) {
3745
- let obj = RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length);
3746
- // @ts-ignore
3747
- fmt = fmt.replace(RegExp.$1, obj);
3748
- }
3749
- return fmt;
3732
+ let o = {
3733
+ "M+": date.getMonth() + 1, // 月份
3734
+ "d+": date.getDate(), //
3735
+ "h+": date.getHours(), // 小时
3736
+ "m+": date.getMinutes(), //
3737
+ "s+": date.getSeconds(), // 秒
3738
+ "q+": Math.floor((date.getMonth() + 3) / 3), // 季度
3739
+ "S": date.getMilliseconds() // 毫秒
3740
+ };
3741
+ if (/(y+)/.test(fmt))
3742
+ fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
3743
+ for (var k in o)
3744
+ if (new RegExp("(" + k + ")").test(fmt)) {
3745
+ let obj = (RegExp.$1.length == 1) ? o[k] : ("00" + o[k]).substr(("" + o[k]).length);
3746
+ // @ts-ignore
3747
+ fmt = fmt.replace(RegExp.$1, obj);
3748
+ }
3749
+ return fmt;
3750
3750
  }
3751
3751
  /**
3752
3752
  * 并行和串行任务
@@ -3756,32 +3756,28 @@ function dateFormat2(date, fmt) {
3756
3756
  * @param finnaly
3757
3757
  */
3758
3758
  function parallel(arr, _finally) {
3759
- let fn,
3760
- index = 0;
3761
- // @ts-ignore
3762
- let statusArr = Array(arr.length).fill().map(() => ({
3763
- isActive: false,
3764
- data: null
3765
- }));
3766
- let isFinished = function () {
3767
- return statusArr.every(item => item.isActive === true);
3768
- };
3769
- let resolve = function (index) {
3770
- return function (data) {
3771
- statusArr[index].data = data;
3772
- statusArr[index].isActive = true;
3773
- let isFinish = isFinished();
3774
- if (isFinish) {
3775
- let datas = statusArr.map(item => item.data);
3776
- _finally(datas);
3777
- }
3759
+ let fn, index = 0;
3760
+ // @ts-ignore
3761
+ let statusArr = Array(arr.length).fill().map(() => ({ isActive: false, data: null }));
3762
+ let isFinished = function () {
3763
+ return statusArr.every((item) => item.isActive === true);
3778
3764
  };
3779
- };
3780
- // @ts-ignore
3781
- while (fn = arr.shift()) {
3782
- fn(resolve(index)); // 给 resolve 函数追加参数,可以使用 bind 函数实现,这里使用了柯里化
3783
- index++;
3784
- }
3765
+ let resolve = function (index) {
3766
+ return function (data) {
3767
+ statusArr[index].data = data;
3768
+ statusArr[index].isActive = true;
3769
+ let isFinish = isFinished();
3770
+ if (isFinish) {
3771
+ let datas = statusArr.map((item) => item.data);
3772
+ _finally(datas);
3773
+ }
3774
+ };
3775
+ };
3776
+ // @ts-ignore
3777
+ while ((fn = arr.shift())) {
3778
+ fn(resolve(index)); // 给 resolve 函数追加参数,可以使用 bind 函数实现,这里使用了柯里化
3779
+ index++;
3780
+ }
3785
3781
  }
3786
3782
  /**
3787
3783
  * 函数节流
@@ -3792,21 +3788,23 @@ function parallel(arr, _finally) {
3792
3788
  * @param mustRunDelay
3793
3789
  */
3794
3790
  function throttle(fn, delay, mustRunDelay) {
3795
- var timer, t_start;
3796
- return function () {
3797
- var t_curr = +new Date();
3798
- window.clearTimeout(timer);
3799
- if (!t_start) t_start = t_curr;
3800
- if (t_curr - t_start >= mustRunDelay) {
3801
- // @ts-ignore
3802
- fn.apply(this, arguments);
3803
- t_start = t_curr;
3804
- } else {
3805
- var args = arguments;
3806
- // @ts-ignore
3807
- timer = window.setTimeout(() => fn.apply(this, args), delay);
3808
- }
3809
- };
3791
+ var timer, t_start;
3792
+ return function () {
3793
+ var t_curr = +new Date();
3794
+ window.clearTimeout(timer);
3795
+ if (!t_start)
3796
+ t_start = t_curr;
3797
+ if (t_curr - t_start >= mustRunDelay) {
3798
+ // @ts-ignore
3799
+ fn.apply(this, arguments);
3800
+ t_start = t_curr;
3801
+ }
3802
+ else {
3803
+ var args = arguments;
3804
+ // @ts-ignore
3805
+ timer = window.setTimeout(() => fn.apply(this, args), delay);
3806
+ }
3807
+ };
3810
3808
  }
3811
3809
  /**
3812
3810
  * 复制文字到剪切板
@@ -3814,37 +3812,39 @@ function throttle(fn, delay, mustRunDelay) {
3814
3812
  * @param {string} text
3815
3813
  */
3816
3814
  function copyToClipboard(text) {
3817
- if (navigator.clipboard) navigator.clipboard.writeText(text); // clipboard api 复制
3818
- else {
3819
- let textarea = document.createElement('textarea');
3820
- document.body.appendChild(textarea); // 隐藏此输入框
3821
- textarea.style.position = 'fixed';
3822
- textarea.style.clip = 'rect(0 0 0 0)';
3823
- textarea.style.top = '10px';
3824
- textarea.value = text; // 赋值
3825
- textarea.select(); // 选中
3826
- document.execCommand('copy', true); // 复制
3827
- document.body.removeChild(textarea); // 移除输入框
3828
- }
3815
+ if (navigator.clipboard)
3816
+ navigator.clipboard.writeText(text); // clipboard api 复制
3817
+ else {
3818
+ let textarea = document.createElement('textarea');
3819
+ document.body.appendChild(textarea); // 隐藏此输入框
3820
+ textarea.style.position = 'fixed';
3821
+ textarea.style.clip = 'rect(0 0 0 0)';
3822
+ textarea.style.top = '10px';
3823
+ textarea.value = text; // 赋值
3824
+ textarea.select(); // 选中
3825
+ document.execCommand('copy', true); // 复制
3826
+ document.body.removeChild(textarea); // 移除输入框
3827
+ }
3829
3828
  }
3829
+
3830
3830
  var utils = /*#__PURE__*/Object.freeze({
3831
- __proto__: null,
3832
- copyToClipboard: copyToClipboard,
3833
- dateFormat: dateFormat,
3834
- dateFormat2: dateFormat2,
3835
- isDebug: isDebug,
3836
- isDev: isDev,
3837
- parallel: parallel,
3838
- throttle: throttle
3831
+ __proto__: null,
3832
+ copyToClipboard: copyToClipboard,
3833
+ dateFormat: dateFormat,
3834
+ dateFormat2: dateFormat2,
3835
+ isDebug: isDebug,
3836
+ isDev: isDev,
3837
+ parallel: parallel,
3838
+ throttle: throttle
3839
3839
  });
3840
3840
 
3841
3841
  /**
3842
3842
  * 默认的请求配置
3843
3843
  */
3844
3844
  const DEFAULT_XHR_CFG = {
3845
- timeout: 5000,
3846
- withCredentials: false,
3847
- parseContentType: 'json'
3845
+ timeout: 5000,
3846
+ withCredentials: false,
3847
+ parseContentType: 'json'
3848
3848
  };
3849
3849
  /**
3850
3850
  * 全局请求的 head 参数
@@ -3856,8 +3856,9 @@ let BASE_HEAD_PARAMS = null;
3856
3856
  * @param param
3857
3857
  */
3858
3858
  function setBaseHeadParams(params) {
3859
- if (BASE_HEAD_PARAMS === null) BASE_HEAD_PARAMS = {};
3860
- Object.assign(BASE_HEAD_PARAMS, params);
3859
+ if (BASE_HEAD_PARAMS === null)
3860
+ BASE_HEAD_PARAMS = {};
3861
+ Object.assign(BASE_HEAD_PARAMS, params);
3861
3862
  }
3862
3863
  /**
3863
3864
  *
@@ -3868,18 +3869,21 @@ function setBaseHeadParams(params) {
3868
3869
  * @param cfg
3869
3870
  */
3870
3871
  function getOrDel(getOrDel, url, cb, params, cfg = DEFAULT_XHR_CFG) {
3871
- let xhr = initXhr(cfg);
3872
- if (params != null) {
3873
- if (url.indexOf('?') != -1) url += '&' + toParams(params);else url += '?' + toParams(params);
3874
- }
3875
- xhr.open(getOrDel.toUpperCase(), url, true);
3876
- xhr.onreadystatechange = function () {
3877
- responseHandle(this, cb, cfg);
3878
- };
3879
- if (BASE_HEAD_PARAMS)
3880
- // 设置自定义请求头
3881
- for (let key in BASE_HEAD_PARAMS) xhr.setRequestHeader(key, BASE_HEAD_PARAMS[key]);
3882
- xhr.send();
3872
+ let xhr = initXhr(cfg);
3873
+ if (params != null) {
3874
+ if (url.indexOf('?') != -1)
3875
+ url += '&' + toParams(params);
3876
+ else
3877
+ url += '?' + toParams(params);
3878
+ }
3879
+ xhr.open(getOrDel.toUpperCase(), url, true);
3880
+ xhr.onreadystatechange = function () {
3881
+ responseHandle(this, cb, cfg);
3882
+ };
3883
+ if (BASE_HEAD_PARAMS) // 设置自定义请求头
3884
+ for (let key in BASE_HEAD_PARAMS)
3885
+ xhr.setRequestHeader(key, BASE_HEAD_PARAMS[key]);
3886
+ xhr.send();
3883
3887
  }
3884
3888
  /**
3885
3889
  *
@@ -3890,20 +3894,24 @@ function getOrDel(getOrDel, url, cb, params, cfg = DEFAULT_XHR_CFG) {
3890
3894
  * @param cfg
3891
3895
  */
3892
3896
  function postOrPut(method, url, cb, params, cfg = DEFAULT_XHR_CFG) {
3893
- let xhr = initXhr(cfg);
3894
- xhr.open(method, url, true);
3895
- xhr.onreadystatechange = function () {
3896
- responseHandle(this, cb, cfg);
3897
- };
3898
- if (BASE_HEAD_PARAMS)
3899
- // 设置自定义请求头
3900
- for (let key in BASE_HEAD_PARAMS) xhr.setRequestHeader(key, BASE_HEAD_PARAMS[key]);
3901
- // 此方法必须在 open() 方法和 send() 之间调用
3902
- if (!cfg.contentType)
3903
- // 如未设置,默认为表单请求
3904
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");else xhr.setRequestHeader("Content-Type", cfg.contentType);
3905
- let _params = typeof params != 'string' ? toParams(params) : params;
3906
- if (_params) xhr.send(_params);else xhr.send();
3897
+ let xhr = initXhr(cfg);
3898
+ xhr.open(method, url, true);
3899
+ xhr.onreadystatechange = function () {
3900
+ responseHandle(this, cb, cfg);
3901
+ };
3902
+ if (BASE_HEAD_PARAMS) // 设置自定义请求头
3903
+ for (let key in BASE_HEAD_PARAMS)
3904
+ xhr.setRequestHeader(key, BASE_HEAD_PARAMS[key]);
3905
+ // 此方法必须在 open() 方法和 send() 之间调用
3906
+ if (!cfg.contentType) // 如未设置,默认为表单请求
3907
+ xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
3908
+ else
3909
+ xhr.setRequestHeader("Content-Type", cfg.contentType);
3910
+ let _params = typeof params != 'string' ? toParams(params) : params;
3911
+ if (_params)
3912
+ xhr.send(_params);
3913
+ else
3914
+ xhr.send();
3907
3915
  }
3908
3916
  /**
3909
3917
  *
@@ -3913,16 +3921,16 @@ function postOrPut(method, url, cb, params, cfg = DEFAULT_XHR_CFG) {
3913
3921
  * @param cfg
3914
3922
  */
3915
3923
  function xhr_post_upload(url, cb, params, cfg = DEFAULT_XHR_CFG) {
3916
- let xhr = initXhr(cfg);
3917
- xhr.open('post', url, true);
3918
- xhr.onreadystatechange = function () {
3919
- responseHandle(this, cb, cfg);
3920
- };
3921
- if (BASE_HEAD_PARAMS)
3922
- // 设置自定义请求头
3923
- for (let key in BASE_HEAD_PARAMS) xhr.setRequestHeader(key, BASE_HEAD_PARAMS[key]);
3924
- // 什么 Content-Type 都不设置
3925
- xhr.send(params);
3924
+ let xhr = initXhr(cfg);
3925
+ xhr.open('post', url, true);
3926
+ xhr.onreadystatechange = function () {
3927
+ responseHandle(this, cb, cfg);
3928
+ };
3929
+ if (BASE_HEAD_PARAMS) // 设置自定义请求头
3930
+ for (let key in BASE_HEAD_PARAMS)
3931
+ xhr.setRequestHeader(key, BASE_HEAD_PARAMS[key]);
3932
+ // 什么 Content-Type 都不设置
3933
+ xhr.send(params);
3926
3934
  }
3927
3935
  /**
3928
3936
  * XHR GET 请求
@@ -3933,7 +3941,7 @@ function xhr_post_upload(url, cb, params, cfg = DEFAULT_XHR_CFG) {
3933
3941
  * @param cfg 配置,可选的
3934
3942
  */
3935
3943
  function xhr_get(url, cb, params, cfg = DEFAULT_XHR_CFG) {
3936
- getOrDel('get', url, cb, params, cfg);
3944
+ getOrDel('get', url, cb, params, cfg);
3937
3945
  }
3938
3946
  /**
3939
3947
  * XHR DELETE 请求
@@ -3944,7 +3952,7 @@ function xhr_get(url, cb, params, cfg = DEFAULT_XHR_CFG) {
3944
3952
  * @param cfg 配置,可选的
3945
3953
  */
3946
3954
  function xhr_del(url, cb, params, cfg = DEFAULT_XHR_CFG) {
3947
- getOrDel('delete', url, cb, params, cfg);
3955
+ getOrDel('delete', url, cb, params, cfg);
3948
3956
  }
3949
3957
  /**
3950
3958
  * XHR POST 请求
@@ -3955,7 +3963,7 @@ function xhr_del(url, cb, params, cfg = DEFAULT_XHR_CFG) {
3955
3963
  * @param cfg 配置,可选的
3956
3964
  */
3957
3965
  function xhr_post(url, cb, params, cfg = DEFAULT_XHR_CFG) {
3958
- postOrPut('post', url, cb, params, cfg);
3966
+ postOrPut('post', url, cb, params, cfg);
3959
3967
  }
3960
3968
  /**
3961
3969
  * XHR PUT 请求
@@ -3966,7 +3974,7 @@ function xhr_post(url, cb, params, cfg = DEFAULT_XHR_CFG) {
3966
3974
  * @param cfg 配置,可选的
3967
3975
  */
3968
3976
  function xhr_put(url, cb, params, cfg = DEFAULT_XHR_CFG) {
3969
- postOrPut('put', url, cb, params, cfg);
3977
+ postOrPut('put', url, cb, params, cfg);
3970
3978
  }
3971
3979
  /**
3972
3980
  * 初始化 XHR
@@ -3975,13 +3983,14 @@ function xhr_put(url, cb, params, cfg = DEFAULT_XHR_CFG) {
3975
3983
  * @returns
3976
3984
  */
3977
3985
  function initXhr(cfg) {
3978
- let xhr = new XMLHttpRequest();
3979
- if (cfg && cfg.timeout) {
3980
- xhr.timeout = cfg.timeout;
3981
- xhr.ontimeout = e => console.error('系统异常,XHR 连接服务超时');
3982
- }
3983
- if (cfg && cfg.withCredentials) xhr.withCredentials = true;
3984
- return xhr;
3986
+ let xhr = new XMLHttpRequest();
3987
+ if (cfg && cfg.timeout) {
3988
+ xhr.timeout = cfg.timeout;
3989
+ xhr.ontimeout = (e) => console.error('系统异常,XHR 连接服务超时');
3990
+ }
3991
+ if (cfg && cfg.withCredentials)
3992
+ xhr.withCredentials = true;
3993
+ return xhr;
3985
3994
  }
3986
3995
  /**
3987
3996
  * 错误处理
@@ -3989,10 +3998,16 @@ function initXhr(cfg) {
3989
3998
  * @param xhr
3990
3999
  */
3991
4000
  function errHandle(xhr) {
3992
- let msg;
3993
- if (xhr.status <= 400) msg = '请求参数错误或者权限不足。';else if (xhr.status <= 500) msg = '服务端异常。';else msg = `未知异常,HTTP code:${xhr.status}。`;
3994
- if (!xhr.responseText) msg += " 服务端返回空的字符串!";
3995
- console.error(msg, xhr.responseText);
4001
+ let msg;
4002
+ if (xhr.status <= 400)
4003
+ msg = '请求参数错误或者权限不足。';
4004
+ else if (xhr.status <= 500)
4005
+ msg = '服务端异常。';
4006
+ else
4007
+ msg = `未知异常,HTTP code:${xhr.status}。`;
4008
+ if (!xhr.responseText)
4009
+ msg += " 服务端返回空的字符串!";
4010
+ console.error(msg, xhr.responseText);
3996
4011
  }
3997
4012
  /**
3998
4013
  * 响应处理
@@ -4002,29 +4017,33 @@ function errHandle(xhr) {
4002
4017
  * @param cfg
4003
4018
  */
4004
4019
  function responseHandle(xhr, cb, cfg) {
4005
- if (xhr.readyState == 4) {
4006
- if (xhr.status >= 200 && xhr.status < 300 || xhr.status == 304) {
4007
- let text = xhr.responseText;
4008
- let json;
4009
- if (!text) console.warn('服务端没有返回任何字符串');
4010
- switch (cfg.parseContentType) {
4011
- case 'text':
4012
- break;
4013
- case 'xml':
4014
- json = xhr.responseXML;
4015
- break;
4016
- case 'json':
4017
- default:
4018
- try {
4019
- json = JSON.parse(text);
4020
- } catch (e) {
4021
- console.error('解析 JSON 时候发生错误,非法 JSON');
4022
- console.warn(e);
4023
- }
4024
- }
4025
- cb && cb(json, text);
4026
- } else errHandle(xhr);
4027
- }
4020
+ if (xhr.readyState == 4) {
4021
+ if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
4022
+ let text = xhr.responseText;
4023
+ let json;
4024
+ if (!text)
4025
+ console.warn('服务端没有返回任何字符串');
4026
+ switch (cfg.parseContentType) {
4027
+ case 'text':
4028
+ break;
4029
+ case 'xml':
4030
+ json = xhr.responseXML;
4031
+ break;
4032
+ case 'json':
4033
+ default:
4034
+ try {
4035
+ json = JSON.parse(text);
4036
+ }
4037
+ catch (e) {
4038
+ console.error('解析 JSON 时候发生错误,非法 JSON');
4039
+ console.warn(e);
4040
+ }
4041
+ }
4042
+ cb && cb(json, text);
4043
+ }
4044
+ else
4045
+ errHandle(xhr);
4046
+ }
4028
4047
  }
4029
4048
  /**
4030
4049
  * 对象转换为 URL 参数列表,用 & 分隔
@@ -4033,11 +4052,12 @@ function responseHandle(xhr, cb, cfg) {
4033
4052
  * @returns URL 参数列表
4034
4053
  */
4035
4054
  function toParams(param) {
4036
- let result = "";
4037
- for (let name in param) {
4038
- if (typeof param[name] != "function") result += "&" + name + "=" + encodeURIComponent(param[name]);
4039
- }
4040
- return result.substring(1);
4055
+ let result = "";
4056
+ for (let name in param) {
4057
+ if (typeof param[name] != "function")
4058
+ result += "&" + name + "=" + encodeURIComponent(param[name]);
4059
+ }
4060
+ return result.substring(1);
4041
4061
  }
4042
4062
  /**
4043
4063
  * 获取 QueryString 的某个参数
@@ -4046,38 +4066,44 @@ function toParams(param) {
4046
4066
  * @returns
4047
4067
  */
4048
4068
  function getQuery(val) {
4049
- const w = location.hash.indexOf('?');
4050
- const query = location.hash.substring(w + 1);
4051
- let vars = query.split('&');
4052
- for (let i = 0; i < vars.length; i++) {
4053
- const pair = vars[i].split('=');
4054
- if (pair[0] == val) return pair[1];
4055
- }
4056
- return '';
4069
+ const w = location.hash.indexOf('?');
4070
+ const query = location.hash.substring(w + 1);
4071
+ let vars = query.split('&');
4072
+ for (let i = 0; i < vars.length; i++) {
4073
+ const pair = vars[i].split('=');
4074
+ if (pair[0] == val)
4075
+ return pair[1];
4076
+ }
4077
+ return '';
4057
4078
  }
4058
4079
  function getPageList(self, listArray, callback) {
4059
- return j => {
4060
- if (j.status) {
4061
- listArray.total = j.total;
4062
- listArray.data = j.data;
4063
- callback && callback();
4064
- } else self.$Message.warning(j.message || '获取数据失败');
4065
- };
4080
+ return (j) => {
4081
+ if (j.status) {
4082
+ listArray.total = j.total;
4083
+ listArray.data = j.data;
4084
+ callback && callback();
4085
+ }
4086
+ else
4087
+ self.$Message.warning(j.message || '获取数据失败');
4088
+ };
4066
4089
  }
4090
+
4067
4091
  var xhr = /*#__PURE__*/Object.freeze({
4068
- __proto__: null,
4069
- getPageList: getPageList,
4070
- getQuery: getQuery,
4071
- setBaseHeadParams: setBaseHeadParams,
4072
- toParams: toParams,
4073
- xhr_del: xhr_del,
4074
- xhr_get: xhr_get,
4075
- xhr_post: xhr_post,
4076
- xhr_post_upload: xhr_post_upload,
4077
- xhr_put: xhr_put
4092
+ __proto__: null,
4093
+ getPageList: getPageList,
4094
+ getQuery: getQuery,
4095
+ setBaseHeadParams: setBaseHeadParams,
4096
+ toParams: toParams,
4097
+ xhr_del: xhr_del,
4098
+ xhr_get: xhr_get,
4099
+ xhr_post: xhr_post,
4100
+ xhr_post_upload: xhr_post_upload,
4101
+ xhr_put: xhr_put
4078
4102
  });
4079
4103
 
4080
4104
 
4105
+
4106
+
4081
4107
  /***/ })
4082
4108
 
4083
4109
  /******/ });
@@ -4205,7 +4231,7 @@ var web_url_search_params_has = __webpack_require__(7566);
4205
4231
  // EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.size.js
4206
4232
  var web_url_search_params_size = __webpack_require__(8721);
4207
4233
  // EXTERNAL MODULE: ./node_modules/@ajaxjs/util/dist/index.esm.js
4208
- var index_esm = __webpack_require__(2957);
4234
+ var index_esm = __webpack_require__(2822);
4209
4235
  ;// CONCATENATED MODULE: ./src/iam/iam.ts
4210
4236
 
4211
4237