@ibiz-template/core 0.0.1-alpha.39 → 0.0.1-alpha.40

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.
@@ -1 +1 @@
1
- System.register(["lodash-es","qx-util","axios","qs","pluralize"],(function(e){"use strict";var t,n,o,r,i,s,c;return{setters:[function(e){t=e.debounce,n=e.merge},function(e){o=e.getCookie,r=e.notNilEmpty},function(e){i=e.default},function(e){s=e.stringify},function(e){c=e.default}],execute:function(){function a(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}e({debounceAndMerge:function(e,n,o,r){var i,s=t((function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return i=void 0,e.apply(void 0,R([],b(t),!1))}),o,r);return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=e;return i&&(o=n(i,o)),i=o,s.apply(void 0,R([],b(o),!1))}},eventPath:I,getToken:E,install:function(){if(window.ibiz)throw new Error("ibiz 已经存在, 无需重复安装");window.ibiz=new q,window.___fc=new B,ibiz.net.addInterceptor("CoreInterceptor",new L)},isEventInside:N,isOverlap:function(e,t){return Array.from(new Set(R(R([],b(e),!1),b(t),!1))).length!==e.length+t.length},listenJSEvent:_,onClickOutside:function(e,t,n){void 0===n&&(n={});var o=n.window,r=void 0===o?M:o,i=n.ignore,s=void 0===i?[]:i,c=n.capture,a=void 0===c||c;if(!e)throw new y("target元素不存在");if(!r)throw new y("找不到window");var u,l=!0,p=function(t){return!R([e],b(s),!1).some((function(e){return N(t,e)}))},f=!1,h=function(e){f||(r.clearTimeout(u),l&&p(e)&&t(e))},d=[_(r,"click",h,{passive:!0,capture:a}),_(r,"pointerdown",(function(e){f||(l=p(e))}),{passive:!0}),_(r,"pointerup",(function(e){if(!f&&0===e.button){var t=I(e);e.composedPath=function(){return t},u=r.setTimeout((function(){return h(e)}),50)}}),{passive:!0})].filter(Boolean);return{stop:function(){return d.forEach((function(e){return e()}))},pause:function(){f=!0},proceed:function(){f=!1}}},plural:A,pluralLower:function(e){return A(e).toLowerCase()}});var u,l,p=e("CoreConst",function(){function e(){}return e.DEFAULT_MODEL_SERVICE_TAG="default",e.TOKEN="access_token",e}()),f=e("NOOP",(function(){})),h=e("HttpStatusMessageConst",{200:"服务器成功返回请求的数据。",201:"新建或修改数据成功。",202:"一个请求已经进入后台排队(异步任务)。",204:"删除数据成功。",400:"发出的请求有错误,服务器没有进行新建或修改数据的操作。",401:"用户没有权限(令牌、用户名、密码错误)。",403:"用户得到授权,但是访问是被禁止的。",404:"发出的请求针对的是不存在的记录,服务器没有进行操作。",406:"请求的格式不可得。",410:"请求的资源被永久删除,且不会再得到的。",422:"当创建一个对象时,发生一个验证错误。",500:"服务器发生错误,请检查服务器。",502:"网关错误。",503:"服务不可用,服务器暂时过载或维护。",504:"网关超时。"});e("LoginMode",u),function(e){e.DEFAULT="DEFAULT",e.CUSTOM="CUSTOM",e.CAS="CAS"}(u||e("LoginMode",u={})),e("MenuPermissionMode",l),function(e){e.MIXIN="MIXIN",e.RESOURCE="RESOURCE",e.RT="RT"}(l||e("MenuPermissionMode",l={}));e("IBizContext",(function(e,t){if(void 0===e&&(e={}),t){var n=this;Object.defineProperty(this,"_context",{enumerable:!1,value:{}});var o={};Object.keys(t).forEach((function(e){o[e]={enumerable:!0,set:function(t){n._context[e]=null==t?null:t},get:function(){return void 0!==n._context[e]?n._context[e]:t[e]}}})),Object.defineProperties(this,o)}Object.assign(this,e)}));var d=e("Environment",{dev:!1,logLevel:"ERROR",jsCdn:"https://cdn.jsdelivr.net",baseUrl:"",pluginBaseUrl:"./plugins",remoteModelUrl:"/remotemodel",assetsUrl:"./assets",dcSystem:"",ExportFile:"/ibizutil/download",UploadFile:"/ibizutil/upload",casLoginUrl:"",loginMode:u.DEFAULT,menuPermissionMode:l.MIXIN,enablePermission:!0}),v=e("HttpError",(function(e){this.name="HttpError";var t=e.response;this.response=e.response,t?(t.data?this.message=t.data.message:this.message=t.statusText,this.message||(this.message=h[t.status]),this.message||(this.message="网络异常,请稍后重试!"),this.status=t.status):(this.message=e.message,this.status=500)})),y=e("RuntimeError",(function(e){this.message=e,this.name="Runtime Error"})),g=function(e,t){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},g(e,t)};function w(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((o=o.apply(e,t||[])).next())}))}function m(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}function b(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)s.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return s}function R(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function E(){return o(p.TOKEN)}var T,O,P,C=e("Interceptor",function(){function e(){}return e.prototype.onBeforeRequest=function(e){return w(this,void 0,void 0,(function(){return m(this,(function(t){return[2,e]}))}))},e.prototype.onRequestError=function(e){return Promise.reject(e)},e.prototype.onResponseSuccess=function(e){return w(this,void 0,void 0,(function(){return m(this,(function(t){return[2,e]}))}))},e.prototype.onResponseError=function(e){return Promise.reject(e)},e.prototype.use=function(e){this.requestTag=e.interceptors.request.use(this.onBeforeRequest,this.onRequestError),this.responseTag=e.interceptors.response.use(this.onResponseSuccess,this.onResponseError)},e.prototype.eject=function(e){this.requestTag&&e.interceptors.request.eject(this.requestTag),this.responseTag&&e.interceptors.response.eject(this.responseTag)},e}()),L=e("CoreInterceptor",function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}g(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.onBeforeRequest=function(t){return w(this,void 0,void 0,(function(){var n;return m(this,(function(o){switch(o.label){case 0:return[4,e.prototype.onBeforeRequest.call(this,t)];case 1:return o.sent(),t.headers||(t.headers={}),t.headers.Authorization="Bearer ".concat(E()),(n=ibiz.orgData)&&(n.systemid&&(t.headers.srfsystemid=n.systemid),n.orgid&&(t.headers.srforgid=n.orgid)),[2,t]}}))}))},t}(C)),k="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},U={exports:{}};O=k,P=function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"];function r(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function i(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(o){return"debug"===o&&(o="log"),typeof console!==t&&("trace"===o&&n?i:void 0!==console[o]?r(console,o):void 0!==console.log?r(console,"log"):e)}function c(t,n){for(var r=0;r<o.length;r++){var i=o[r];this[i]=r<t?e:this.methodFactory(i,t,n)}this.log=this.debug}function a(e,n,o){return function(){typeof console!==t&&(c.call(this,n,o),this[e].apply(this,arguments))}}function u(e,t,n){return s(e)||a.apply(this,arguments)}function l(e,n,r){var i,s=this;n=null==n?"WARN":n;var a="loglevel";function l(){var e;if(typeof window!==t&&a){try{e=window.localStorage[a]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,o=n.indexOf(encodeURIComponent(a)+"=");-1!==o&&(e=/^([^;]+)/.exec(n.slice(o))[1])}catch(e){}return void 0===s.levels[e]&&(e=void 0),e}}"string"==typeof e?a+=":"+e:"symbol"==typeof e&&(a=void 0),s.name=e,s.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},s.methodFactory=r||u,s.getLevel=function(){return i},s.setLevel=function(n,r){if("string"==typeof n&&void 0!==s.levels[n.toUpperCase()]&&(n=s.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=s.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(i=n,!1!==r&&function(e){var n=(o[e]||"silent").toUpperCase();if(typeof window!==t&&a){try{return void(window.localStorage[a]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(a)+"="+n+";"}catch(e){}}}(n),c.call(s,n,e),typeof console===t&&n<s.levels.SILENT)return"No console available for logging"},s.setDefaultLevel=function(e){n=e,l()||s.setLevel(e,!1)},s.resetLevel=function(){s.setLevel(n,!1),function(){if(typeof window!==t&&a){try{return void window.localStorage.removeItem(a)}catch(e){}try{window.document.cookie=encodeURIComponent(a)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},s.enableAll=function(e){s.setLevel(s.levels.TRACE,e)},s.disableAll=function(e){s.setLevel(s.levels.SILENT,e)};var p=l();null==p&&(p=n),s.setLevel(p,!1)}var p=new l,f={};p.getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=f[e];return t||(t=f[e]=new l(e,p.getLevel(),p.methodFactory)),t};var h=typeof window!==t?window.log:void 0;return p.noConflict=function(){return typeof window!==t&&window.log===p&&(window.log=h),p},p.getLoggers=function(){return f},p.default=p,p},(T=U).exports?T.exports=P():O.log=P();var x=a({__proto__:null,default:U.exports},[U.exports]);e("Logger",x);function S(e,t,n,o,r){var i="".concat(e,"-").concat(t);return n&&(i+="-".concat(n)),o&&(i+="__".concat(o)),r&&(i+="--".concat(r)),i}e("Namespace",function(){function e(e,t){this.block=e,this.namespace=t||"ibiz"}return e.prototype.b=function(e){return void 0===e&&(e=""),S(this.namespace,this.block,e,"","")},e.prototype.e=function(e){return e?S(this.namespace,this.block,"",e,""):""},e.prototype.m=function(e){return e?S(this.namespace,this.block,"","",e):""},e.prototype.be=function(e,t){return e&&t?S(this.namespace,this.block,e,t,""):""},e.prototype.em=function(e,t){return e&&t?S(this.namespace,this.block,"",e,t):""},e.prototype.bm=function(e,t){return e&&t?S(this.namespace,this.block,e,"",t):""},e.prototype.bem=function(e,t,n){return e&&t&&n?S(this.namespace,this.block,e,t,n):""},e.prototype.is=function(e,t){return e&&t?"".concat("is-").concat(e):""},e.prototype.cssVar=function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarName(n)]=e[n]);return t},e.prototype.cssVarBlock=function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarBlockName(n)]=e[n]);return t},e.prototype.cssVarName=function(e){return"--".concat(this.namespace,"-").concat(e)},e.prototype.cssVarBlockName=function(e){return"--".concat(this.namespace,"-").concat(this.block,"-").concat(e)},e}()),e("HttpResponse",(function(e,t,n){this.local=!0,this.ok=!1,this.headers={},this.config={},this.data=e,this.status=t||200,this.statusText=n||"",this.status>=200&&this.status<300&&(this.ok=!0)}));var j=e("Net",function(){function e(e){this.interceptors=new Map,this.instance=i.create(e)}return e.prototype.addInterceptor=function(e,t){t.use(this.instance),this.interceptors.set(e,t)},e.prototype.removeInterceptor=function(e){var t=this.interceptors.get(e);t&&(t.eject(this.instance),this.interceptors.delete(e))},Object.defineProperty(e.prototype,"presetConfig",{get:function(){return{baseURL:this.instance.defaults.baseURL||ibiz.env.baseUrl,headers:{"Content-Type":"application/json;charset=UTF-8",Accept:"application/json"}}},enumerable:!1,configurable:!0}),e.prototype.mergeConfig=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 0===e.length?this.presetConfig:n.apply(void 0,R([this.presetConfig],b(e),!1))},e.prototype.post=function(e,t,n,o){return void 0===n&&(n={}),void 0===o&&(o={}),w(this,void 0,void 0,(function(){var r,i;return m(this,(function(s){switch(s.label){case 0:e=this.handleAppPresetParam(e,n),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.request(e,{method:"post",data:t,headers:o})];case 2:return r=s.sent(),[2,this.doResponseResult(r)];case 3:throw i=s.sent(),new v(i);case 4:return[2]}}))}))},e.prototype.get=function(e,t,o,r){return void 0===t&&(t={}),void 0===o&&(o={}),void 0===r&&(r={}),w(this,void 0,void 0,(function(){var i,s;return m(this,(function(c){switch(c.label){case 0:e=this.attachUrlParam(e,t),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,this.request(e,n({method:"get",headers:o},r))];case 2:return i=c.sent(),[2,this.doResponseResult(i)];case 3:throw s=c.sent(),new v(s);case 4:return[2]}}))}))},e.prototype.delete=function(e,t,n){return void 0===n&&(n={}),w(this,void 0,void 0,(function(){var o,r;return m(this,(function(i){switch(i.label){case 0:e=this.handleAppPresetParam(e,t),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.request(e,{method:"delete",headers:n})];case 2:return o=i.sent(),[2,this.doResponseResult(o)];case 3:throw r=i.sent(),new v(r);case 4:return[2]}}))}))},e.prototype.put=function(e,t,n,o){return void 0===n&&(n={}),void 0===o&&(o={}),w(this,void 0,void 0,(function(){var r,i;return m(this,(function(s){switch(s.label){case 0:e=this.handleAppPresetParam(e,n),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.request(e,{method:"put",data:t,headers:o})];case 2:return r=s.sent(),[2,this.doResponseResult(r)];case 3:throw i=s.sent(),new v(i);case 4:return[2]}}))}))},e.prototype.getModel=function(e,t){return void 0===t&&(t={}),w(this,void 0,void 0,(function(){var n,o;return m(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.instance.get(e,{headers:t})];case 1:return n=r.sent(),[2,this.doResponseResult(n)];case 2:throw o=r.sent(),new v(o);case 3:return[2]}}))}))},e.prototype.request=function(e,t){return void 0===t&&(t={}),w(this,void 0,void 0,(function(){var n,o;return m(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.instance.request(this.mergeConfig({url:e},t))];case 1:return n=r.sent(),[2,this.doResponseResult(n)];case 2:throw o=r.sent(),new v(o);case 3:return[2]}}))}))},e.prototype.doResponseResult=function(e){var t=e;return t.status>=200&&t.status<=299&&(t.ok=!0),t},e.prototype.handleAppPresetParam=function(e,t){if(t){var n=Object.keys(t),o={};return n.forEach((function(e){e.startsWith("srf")&&r(t[e])&&(o[e]=t[e])})),this.attachUrlParam(e,t)}return e},e.prototype.attachUrlParam=function(e,t){var n=s(t);return r(n)&&(e=e.endsWith("?")||-1!==e.indexOf("?")&&e.endsWith("&")?"".concat(e).concat(n):-1===e.indexOf("?")||e.endsWith("&")?"".concat(e,"?").concat(n):"".concat(e,"&").concat(n)),e},e}());function A(e){return c(e)}e("UrlHelper",function(){function e(){}return Object.defineProperty(e,"routeBase",{get:function(){return"".concat(this.appBase,"/#")},enumerable:!1,configurable:!0}),Object.defineProperty(e,"appBase",{get:function(){var e=window.location,t=e.origin,n=e.pathname;return"".concat(t).concat(n).replace(/\/$/,"")},enumerable:!1,configurable:!0}),Object.defineProperty(e,"routePath",{get:function(){return window.location.hash.replace("#","")},enumerable:!1,configurable:!0}),Object.defineProperty(e,"fullPath",{get:function(){return window.location.href},enumerable:!1,configurable:!0}),e}());function I(e){var t=e.composedPath&&e.composedPath()||e.path;if(null!=t)return t;return[e.target].concat(function e(t,n){void 0===n&&(n=[]);var o=t.parentNode;return o?e(o,n.concat([o])):n}(e.target))}function _(e,t,n,o){void 0===o&&(o={}),e.addEventListener(t,n,o);var r=function(){e.removeEventListener(t,n,o),r=f};return function(){r()}}function N(e,t){return t&&(e.target===t||I(e).includes(t))}var M="undefined"!=typeof window?window:void 0;var q=e("IBizSys",(function(){this.env=d,this.log=x,this.net=new j})),B=e("FactoryCenter",(function(){}))}}}));
1
+ System.register(["lodash-es","qx-util","axios","qs","pluralize"],(function(e){"use strict";var t,n,o,r,i,s,c;return{setters:[function(e){t=e.debounce,n=e.merge},function(e){o=e.getCookie,r=e.notNilEmpty},function(e){i=e.default},function(e){s=e.stringify},function(e){c=e.default}],execute:function(){function a(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}e({debounceAndAsyncMerge:function(e,n,o){var r,i=this,s=[],c=t((function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return w(i,void 0,void 0,(function(){var n;return b(this,(function(o){switch(o.label){case 0:return r=void 0,[4,e.apply(void 0,R([],m(t),!1))];case 1:return n=o.sent(),s.forEach((function(e){e.resolve(n)})),s=[],[2,n]}}))}))}),o);return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return w(i,void 0,void 0,(function(){var t;return b(this,(function(o){return t=e,r&&(t=n(r,t)),r=t,c.apply(void 0,R([],m(t),!1)),[2,new Promise((function(e,t){s.push({resolve:e,reject:t})}))]}))}))}},debounceAndMerge:function(e,n,o){var r,i=t((function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return r=void 0,e.apply(void 0,R([],m(t),!1))}),o);return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var o=e;return r&&(o=n(r,o)),r=o,i.apply(void 0,R([],m(o),!1))}},eventPath:I,getToken:E,install:function(){if(window.ibiz)throw new Error("ibiz 已经存在, 无需重复安装");window.ibiz=new q,window.___fc=new B,ibiz.net.addInterceptor("CoreInterceptor",new L)},isEventInside:N,isOverlap:function(e,t){return Array.from(new Set(R(R([],m(e),!1),m(t),!1))).length!==e.length+t.length},listenJSEvent:_,onClickOutside:function(e,t,n){void 0===n&&(n={});var o=n.window,r=void 0===o?M:o,i=n.ignore,s=void 0===i?[]:i,c=n.capture,a=void 0===c||c;if(!e)throw new y("target元素不存在");if(!r)throw new y("找不到window");var u,l=!0,f=function(t){return!R([e],m(s),!1).some((function(e){return N(t,e)}))},p=!1,h=function(e){p||(r.clearTimeout(u),l&&f(e)&&t(e))},d=[_(r,"click",h,{passive:!0,capture:a}),_(r,"pointerdown",(function(e){p||(l=f(e))}),{passive:!0}),_(r,"pointerup",(function(e){if(!p&&0===e.button){var t=I(e);e.composedPath=function(){return t},u=r.setTimeout((function(){return h(e)}),50)}}),{passive:!0})].filter(Boolean);return{stop:function(){return d.forEach((function(e){return e()}))},pause:function(){p=!0},proceed:function(){p=!1}}},plural:S,pluralLower:function(e){return S(e).toLowerCase()}});var u,l,f=e("CoreConst",function(){function e(){}return e.DEFAULT_MODEL_SERVICE_TAG="default",e.TOKEN="access_token",e}()),p=e("NOOP",(function(){})),h=e("HttpStatusMessageConst",{200:"服务器成功返回请求的数据。",201:"新建或修改数据成功。",202:"一个请求已经进入后台排队(异步任务)。",204:"删除数据成功。",400:"发出的请求有错误,服务器没有进行新建或修改数据的操作。",401:"用户没有权限(令牌、用户名、密码错误)。",403:"用户得到授权,但是访问是被禁止的。",404:"发出的请求针对的是不存在的记录,服务器没有进行操作。",406:"请求的格式不可得。",410:"请求的资源被永久删除,且不会再得到的。",422:"当创建一个对象时,发生一个验证错误。",500:"服务器发生错误,请检查服务器。",502:"网关错误。",503:"服务不可用,服务器暂时过载或维护。",504:"网关超时。"});e("LoginMode",u),function(e){e.DEFAULT="DEFAULT",e.CUSTOM="CUSTOM",e.CAS="CAS"}(u||e("LoginMode",u={})),e("MenuPermissionMode",l),function(e){e.MIXIN="MIXIN",e.RESOURCE="RESOURCE",e.RT="RT"}(l||e("MenuPermissionMode",l={}));e("IBizContext",(function(e,t){if(void 0===e&&(e={}),t){var n=this;Object.defineProperty(this,"_context",{enumerable:!1,value:{}});var o={};Object.keys(t).forEach((function(e){o[e]={enumerable:!0,set:function(t){n._context[e]=null==t?null:t},get:function(){return void 0!==n._context[e]?n._context[e]:t[e]}}})),Object.defineProperties(this,o)}Object.assign(this,e)}));var d=e("Environment",{dev:!1,logLevel:"ERROR",jsCdn:"https://cdn.jsdelivr.net",baseUrl:"",pluginBaseUrl:"./plugins",remoteModelUrl:"/remotemodel",assetsUrl:"./assets",dcSystem:"",ExportFile:"/ibizutil/download",UploadFile:"/ibizutil/upload",casLoginUrl:"",loginMode:u.DEFAULT,menuPermissionMode:l.MIXIN,enablePermission:!0}),v=e("HttpError",(function(e){this.name="HttpError";var t=e.response;this.response=e.response,t?(t.data?this.message=t.data.message:this.message=t.statusText,this.message||(this.message=h[t.status]),this.message||(this.message="网络异常,请稍后重试!"),this.status=t.status):(this.message=e.message,this.status=500)})),y=e("RuntimeError",(function(e){this.message=e,this.name="Runtime Error"})),g=function(e,t){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},g(e,t)};function w(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((o=o.apply(e,t||[])).next())}))}function b(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}function m(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)s.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return s}function R(e,t,n){if(n||2===arguments.length)for(var o,r=0,i=t.length;r<i;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function E(){return o(f.TOKEN)}var T,O,P,C=e("Interceptor",function(){function e(){}return e.prototype.onBeforeRequest=function(e){return w(this,void 0,void 0,(function(){return b(this,(function(t){return[2,e]}))}))},e.prototype.onRequestError=function(e){return Promise.reject(e)},e.prototype.onResponseSuccess=function(e){return w(this,void 0,void 0,(function(){return b(this,(function(t){return[2,e]}))}))},e.prototype.onResponseError=function(e){return Promise.reject(e)},e.prototype.use=function(e){this.requestTag=e.interceptors.request.use(this.onBeforeRequest,this.onRequestError),this.responseTag=e.interceptors.response.use(this.onResponseSuccess,this.onResponseError)},e.prototype.eject=function(e){this.requestTag&&e.interceptors.request.eject(this.requestTag),this.responseTag&&e.interceptors.response.eject(this.responseTag)},e}()),L=e("CoreInterceptor",function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}g(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.onBeforeRequest=function(t){return w(this,void 0,void 0,(function(){var n;return b(this,(function(o){switch(o.label){case 0:return[4,e.prototype.onBeforeRequest.call(this,t)];case 1:return o.sent(),t.headers||(t.headers={}),t.headers.Authorization="Bearer ".concat(E()),(n=ibiz.orgData)&&(n.systemid&&(t.headers.srfsystemid=n.systemid),n.orgid&&(t.headers.srforgid=n.orgid)),[2,t]}}))}))},t}(C)),k="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},U={exports:{}};O=k,P=function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"];function r(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function i(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(o){return"debug"===o&&(o="log"),typeof console!==t&&("trace"===o&&n?i:void 0!==console[o]?r(console,o):void 0!==console.log?r(console,"log"):e)}function c(t,n){for(var r=0;r<o.length;r++){var i=o[r];this[i]=r<t?e:this.methodFactory(i,t,n)}this.log=this.debug}function a(e,n,o){return function(){typeof console!==t&&(c.call(this,n,o),this[e].apply(this,arguments))}}function u(e,t,n){return s(e)||a.apply(this,arguments)}function l(e,n,r){var i,s=this;n=null==n?"WARN":n;var a="loglevel";function l(){var e;if(typeof window!==t&&a){try{e=window.localStorage[a]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,o=n.indexOf(encodeURIComponent(a)+"=");-1!==o&&(e=/^([^;]+)/.exec(n.slice(o))[1])}catch(e){}return void 0===s.levels[e]&&(e=void 0),e}}"string"==typeof e?a+=":"+e:"symbol"==typeof e&&(a=void 0),s.name=e,s.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},s.methodFactory=r||u,s.getLevel=function(){return i},s.setLevel=function(n,r){if("string"==typeof n&&void 0!==s.levels[n.toUpperCase()]&&(n=s.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=s.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(i=n,!1!==r&&function(e){var n=(o[e]||"silent").toUpperCase();if(typeof window!==t&&a){try{return void(window.localStorage[a]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(a)+"="+n+";"}catch(e){}}}(n),c.call(s,n,e),typeof console===t&&n<s.levels.SILENT)return"No console available for logging"},s.setDefaultLevel=function(e){n=e,l()||s.setLevel(e,!1)},s.resetLevel=function(){s.setLevel(n,!1),function(){if(typeof window!==t&&a){try{return void window.localStorage.removeItem(a)}catch(e){}try{window.document.cookie=encodeURIComponent(a)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},s.enableAll=function(e){s.setLevel(s.levels.TRACE,e)},s.disableAll=function(e){s.setLevel(s.levels.SILENT,e)};var f=l();null==f&&(f=n),s.setLevel(f,!1)}var f=new l,p={};f.getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=p[e];return t||(t=p[e]=new l(e,f.getLevel(),f.methodFactory)),t};var h=typeof window!==t?window.log:void 0;return f.noConflict=function(){return typeof window!==t&&window.log===f&&(window.log=h),f},f.getLoggers=function(){return p},f.default=f,f},(T=U).exports?T.exports=P():O.log=P();var A=a({__proto__:null,default:U.exports},[U.exports]);e("Logger",A);function j(e,t,n,o,r){var i="".concat(e,"-").concat(t);return n&&(i+="-".concat(n)),o&&(i+="__".concat(o)),r&&(i+="--".concat(r)),i}e("Namespace",function(){function e(e,t){this.block=e,this.namespace=t||"ibiz"}return e.prototype.b=function(e){return void 0===e&&(e=""),j(this.namespace,this.block,e,"","")},e.prototype.e=function(e){return e?j(this.namespace,this.block,"",e,""):""},e.prototype.m=function(e){return e?j(this.namespace,this.block,"","",e):""},e.prototype.be=function(e,t){return e&&t?j(this.namespace,this.block,e,t,""):""},e.prototype.em=function(e,t){return e&&t?j(this.namespace,this.block,"",e,t):""},e.prototype.bm=function(e,t){return e&&t?j(this.namespace,this.block,e,"",t):""},e.prototype.bem=function(e,t,n){return e&&t&&n?j(this.namespace,this.block,e,t,n):""},e.prototype.is=function(e,t){return e&&t?"".concat("is-").concat(e):""},e.prototype.cssVar=function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarName(n)]=e[n]);return t},e.prototype.cssVarBlock=function(e){var t={};for(var n in e)e[n]&&(t[this.cssVarBlockName(n)]=e[n]);return t},e.prototype.cssVarName=function(e){return"--".concat(this.namespace,"-").concat(e)},e.prototype.cssVarBlockName=function(e){return"--".concat(this.namespace,"-").concat(this.block,"-").concat(e)},e}()),e("HttpResponse",(function(e,t,n){this.local=!0,this.ok=!1,this.headers={},this.config={},this.data=e,this.status=t||200,this.statusText=n||"",this.status>=200&&this.status<300&&(this.ok=!0)}));var x=e("Net",function(){function e(e){this.interceptors=new Map,this.instance=i.create(e)}return e.prototype.addInterceptor=function(e,t){t.use(this.instance),this.interceptors.set(e,t)},e.prototype.removeInterceptor=function(e){var t=this.interceptors.get(e);t&&(t.eject(this.instance),this.interceptors.delete(e))},Object.defineProperty(e.prototype,"presetConfig",{get:function(){return{baseURL:this.instance.defaults.baseURL||ibiz.env.baseUrl,headers:{"Content-Type":"application/json;charset=UTF-8",Accept:"application/json"}}},enumerable:!1,configurable:!0}),e.prototype.mergeConfig=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 0===e.length?this.presetConfig:n.apply(void 0,R([this.presetConfig],m(e),!1))},e.prototype.post=function(e,t,n,o){return void 0===n&&(n={}),void 0===o&&(o={}),w(this,void 0,void 0,(function(){var r,i;return b(this,(function(s){switch(s.label){case 0:e=this.handleAppPresetParam(e,n),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.request(e,{method:"post",data:t,headers:o})];case 2:return r=s.sent(),[2,this.doResponseResult(r)];case 3:throw i=s.sent(),new v(i);case 4:return[2]}}))}))},e.prototype.get=function(e,t,o,r){return void 0===t&&(t={}),void 0===o&&(o={}),void 0===r&&(r={}),w(this,void 0,void 0,(function(){var i,s;return b(this,(function(c){switch(c.label){case 0:e=this.attachUrlParam(e,t),c.label=1;case 1:return c.trys.push([1,3,,4]),[4,this.request(e,n({method:"get",headers:o},r))];case 2:return i=c.sent(),[2,this.doResponseResult(i)];case 3:throw s=c.sent(),new v(s);case 4:return[2]}}))}))},e.prototype.delete=function(e,t,n){return void 0===n&&(n={}),w(this,void 0,void 0,(function(){var o,r;return b(this,(function(i){switch(i.label){case 0:e=this.handleAppPresetParam(e,t),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.request(e,{method:"delete",headers:n})];case 2:return o=i.sent(),[2,this.doResponseResult(o)];case 3:throw r=i.sent(),new v(r);case 4:return[2]}}))}))},e.prototype.put=function(e,t,n,o){return void 0===n&&(n={}),void 0===o&&(o={}),w(this,void 0,void 0,(function(){var r,i;return b(this,(function(s){switch(s.label){case 0:e=this.handleAppPresetParam(e,n),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.request(e,{method:"put",data:t,headers:o})];case 2:return r=s.sent(),[2,this.doResponseResult(r)];case 3:throw i=s.sent(),new v(i);case 4:return[2]}}))}))},e.prototype.getModel=function(e,t){return void 0===t&&(t={}),w(this,void 0,void 0,(function(){var n,o;return b(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.instance.get(e,{headers:t})];case 1:return n=r.sent(),[2,this.doResponseResult(n)];case 2:throw o=r.sent(),new v(o);case 3:return[2]}}))}))},e.prototype.request=function(e,t){return void 0===t&&(t={}),w(this,void 0,void 0,(function(){var n,o;return b(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.instance.request(this.mergeConfig({url:e},t))];case 1:return n=r.sent(),[2,this.doResponseResult(n)];case 2:throw o=r.sent(),new v(o);case 3:return[2]}}))}))},e.prototype.doResponseResult=function(e){var t=e;return t.status>=200&&t.status<=299&&(t.ok=!0),t},e.prototype.handleAppPresetParam=function(e,t){if(t){var n=Object.keys(t),o={};return n.forEach((function(e){e.startsWith("srf")&&r(t[e])&&(o[e]=t[e])})),this.attachUrlParam(e,t)}return e},e.prototype.attachUrlParam=function(e,t){var n=s(t);return r(n)&&(e=e.endsWith("?")||-1!==e.indexOf("?")&&e.endsWith("&")?"".concat(e).concat(n):-1===e.indexOf("?")||e.endsWith("&")?"".concat(e,"?").concat(n):"".concat(e,"&").concat(n)),e},e}());function S(e){return c(e)}e("UrlHelper",function(){function e(){}return Object.defineProperty(e,"routeBase",{get:function(){return"".concat(this.appBase,"/#")},enumerable:!1,configurable:!0}),Object.defineProperty(e,"appBase",{get:function(){var e=window.location,t=e.origin,n=e.pathname;return"".concat(t).concat(n).replace(/\/$/,"")},enumerable:!1,configurable:!0}),Object.defineProperty(e,"routePath",{get:function(){return window.location.hash.replace("#","")},enumerable:!1,configurable:!0}),Object.defineProperty(e,"fullPath",{get:function(){return window.location.href},enumerable:!1,configurable:!0}),e}());function I(e){var t=e.composedPath&&e.composedPath()||e.path;if(null!=t)return t;return[e.target].concat(function e(t,n){void 0===n&&(n=[]);var o=t.parentNode;return o?e(o,n.concat([o])):n}(e.target))}function _(e,t,n,o){void 0===o&&(o={}),e.addEventListener(t,n,o);var r=function(){e.removeEventListener(t,n,o),r=p};return function(){r()}}function N(e,t){return t&&(e.target===t||I(e).includes(t))}var M="undefined"!=typeof window?window:void 0;var q=e("IBizSys",(function(){this.env=d,this.log=A,this.net=new x})),B=e("FactoryCenter",(function(){}))}}}));
@@ -1,4 +1,3 @@
1
- import { DebounceSettings } from 'lodash-es';
2
1
  /**
3
2
  * 获取认证令牌
4
3
  *
@@ -20,7 +19,8 @@ export declare function getToken(): string | null;
20
19
  */
21
20
  export declare function isOverlap(arr1: any[], arr2: any[]): boolean;
22
21
  /**
23
- * 防抖并合并每次的参数
22
+ * 防抖并合并每次的参数,
23
+ * 最后一次才会执行
24
24
  *
25
25
  * @author lxm
26
26
  * @date 2022-09-20 21:09:53
@@ -32,8 +32,24 @@ export declare function isOverlap(arr1: any[], arr2: any[]): boolean;
32
32
  * newParams: Parameters<T>,
33
33
  * ) => Parameters<T>} mergeFunc 合并的回调函数
34
34
  * @param {number} [wait] 防抖的延迟毫秒数
35
- * @param {DebounceSettings} [options] 防抖函数的额外参数
36
35
  * @returns {*}
37
36
  */
38
- export declare function debounceAndMerge<T extends (...args: any[]) => any>(func: T, mergeFunc: (oldParams: Parameters<T>, newParams: Parameters<T>) => Parameters<T>, wait?: number, options?: DebounceSettings): (...args: Parameters<T>) => any;
37
+ export declare function debounceAndMerge<T extends (...args: any[]) => any>(func: T, mergeFunc: (oldParams: Parameters<T>, newParams: Parameters<T>) => Parameters<T>, wait?: number): (...args: Parameters<T>) => any;
38
+ /**
39
+ * 防抖并合并每次的参数,最后一次才会执行
40
+ * 绑定方法为异步方法,给每次调用返回最终执行那次的结果
41
+ *
42
+ * @author lxm
43
+ * @date 2022-09-20 21:09:53
44
+ * @export
45
+ * @template T
46
+ * @param {T} func 要防抖的函数
47
+ * @param {(
48
+ * oldParams: Parameters<T>,
49
+ * newParams: Parameters<T>,
50
+ * ) => Parameters<T>} mergeFunc 合并的回调函数
51
+ * @param {number} [wait] 防抖的延迟毫秒数
52
+ * @returns {*}
53
+ */
54
+ export declare function debounceAndAsyncMerge<T extends (...args: any[]) => Promise<any>>(func: T, mergeFunc: (oldParams: Parameters<T>, newParams: Parameters<T>) => Parameters<T>, wait?: number): T;
39
55
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/utils/util/util.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAIvD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,IAAI,MAAM,GAAG,IAAI,CAExC;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAG3D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAChE,IAAI,EAAE,CAAC,EACP,SAAS,EAAE,CACT,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EACxB,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,KACrB,UAAU,CAAC,CAAC,CAAC,EAClB,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,gBAAgB,aAaT,WAAW,CAAC,CAAC,SAS/B"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/utils/util/util.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,wBAAgB,QAAQ,IAAI,MAAM,GAAG,IAAI,CAExC;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAG3D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAChE,IAAI,EAAE,CAAC,EACP,SAAS,EAAE,CACT,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EACxB,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,KACrB,UAAU,CAAC,CAAC,CAAC,EAClB,IAAI,CAAC,EAAE,MAAM,aASI,WAAW,CAAC,CAAC,SAS/B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EAE1C,IAAI,EAAE,CAAC,EACP,SAAS,EAAE,CACT,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EACxB,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,KACrB,UAAU,CAAC,CAAC,CAAC,EAClB,IAAI,CAAC,EAAE,MAAM,GACZ,CAAC,CA6BH"}
@@ -28,7 +28,8 @@ export function isOverlap(arr1, arr2) {
28
28
  return newArr.length !== arr1.length + arr2.length;
29
29
  }
30
30
  /**
31
- * 防抖并合并每次的参数
31
+ * 防抖并合并每次的参数,
32
+ * 最后一次才会执行
32
33
  *
33
34
  * @author lxm
34
35
  * @date 2022-09-20 21:09:53
@@ -40,17 +41,16 @@ export function isOverlap(arr1, arr2) {
40
41
  * newParams: Parameters<T>,
41
42
  * ) => Parameters<T>} mergeFunc 合并的回调函数
42
43
  * @param {number} [wait] 防抖的延迟毫秒数
43
- * @param {DebounceSettings} [options] 防抖函数的额外参数
44
44
  * @returns {*}
45
45
  */
46
- export function debounceAndMerge(func, mergeFunc, wait, options) {
46
+ export function debounceAndMerge(func, mergeFunc, wait) {
47
47
  // 缓存上一次的函数参数
48
48
  let oldParams;
49
49
  const debounceFunc = debounce((...params) => {
50
50
  // 防抖函数执行的时候清空缓存参数
51
51
  oldParams = undefined;
52
52
  return func(...params);
53
- }, wait, options);
53
+ }, wait);
54
54
  return (...args) => {
55
55
  // 合并参数,并把参数缓存到oldParams里,用新参数调用防抖函数
56
56
  let newParams = args;
@@ -61,3 +61,49 @@ export function debounceAndMerge(func, mergeFunc, wait, options) {
61
61
  return debounceFunc(...newParams);
62
62
  };
63
63
  }
64
+ /**
65
+ * 防抖并合并每次的参数,最后一次才会执行
66
+ * 绑定方法为异步方法,给每次调用返回最终执行那次的结果
67
+ *
68
+ * @author lxm
69
+ * @date 2022-09-20 21:09:53
70
+ * @export
71
+ * @template T
72
+ * @param {T} func 要防抖的函数
73
+ * @param {(
74
+ * oldParams: Parameters<T>,
75
+ * newParams: Parameters<T>,
76
+ * ) => Parameters<T>} mergeFunc 合并的回调函数
77
+ * @param {number} [wait] 防抖的延迟毫秒数
78
+ * @returns {*}
79
+ */
80
+ export function debounceAndAsyncMerge(func, mergeFunc, wait) {
81
+ // 缓存上一次的函数参数
82
+ let oldParams;
83
+ let promises = [];
84
+ const debounceFunc = debounce(async (...params) => {
85
+ // 防抖函数执行的时候清空缓存参数
86
+ oldParams = undefined;
87
+ const result = await func(...params);
88
+ promises.forEach(promise => {
89
+ promise.resolve(result);
90
+ });
91
+ promises = [];
92
+ return result;
93
+ }, wait);
94
+ const fun = async (...args) => {
95
+ // 合并参数,并把参数缓存到oldParams里,用新参数调用防抖函数
96
+ let newParams = args;
97
+ if (oldParams) {
98
+ newParams = mergeFunc(oldParams, newParams);
99
+ }
100
+ oldParams = newParams;
101
+ // 执行防抖函数
102
+ debounceFunc(...newParams);
103
+ return new Promise((resolve, reject) => {
104
+ // 阻塞当前调用,当防抖函数被执行后返回
105
+ promises.push({ resolve, reject });
106
+ });
107
+ };
108
+ return fun;
109
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/core",
3
- "version": "0.0.1-alpha.39",
3
+ "version": "0.0.1-alpha.40",
4
4
  "description": "核心包",
5
5
  "type": "module",
6
6
  "main": "out/index.js",
@@ -44,5 +44,5 @@
44
44
  "lodash-es": "^4.17.21",
45
45
  "qx-util": "^0.4.4"
46
46
  },
47
- "gitHead": "0c3339c9aa6fd4e59d180bb7b804dbbc8240e3ae"
47
+ "gitHead": "be7fae93941fcce8a2c0fa9f4158e9525bcdb55d"
48
48
  }
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { debounce, DebounceSettings } from 'lodash-es';
2
+ import { debounce } from 'lodash-es';
3
3
  import { getCookie } from 'qx-util';
4
4
  import { CoreConst } from '../../constant';
5
5
 
@@ -31,7 +31,8 @@ export function isOverlap(arr1: any[], arr2: any[]): boolean {
31
31
  }
32
32
 
33
33
  /**
34
- * 防抖并合并每次的参数
34
+ * 防抖并合并每次的参数,
35
+ * 最后一次才会执行
35
36
  *
36
37
  * @author lxm
37
38
  * @date 2022-09-20 21:09:53
@@ -43,7 +44,6 @@ export function isOverlap(arr1: any[], arr2: any[]): boolean {
43
44
  * newParams: Parameters<T>,
44
45
  * ) => Parameters<T>} mergeFunc 合并的回调函数
45
46
  * @param {number} [wait] 防抖的延迟毫秒数
46
- * @param {DebounceSettings} [options] 防抖函数的额外参数
47
47
  * @returns {*}
48
48
  */
49
49
  export function debounceAndMerge<T extends (...args: any[]) => any>(
@@ -53,19 +53,14 @@ export function debounceAndMerge<T extends (...args: any[]) => any>(
53
53
  newParams: Parameters<T>,
54
54
  ) => Parameters<T>,
55
55
  wait?: number,
56
- options?: DebounceSettings,
57
56
  ) {
58
57
  // 缓存上一次的函数参数
59
58
  let oldParams: Parameters<T> | undefined;
60
- const debounceFunc = debounce(
61
- (...params: Parameters<T>) => {
62
- // 防抖函数执行的时候清空缓存参数
63
- oldParams = undefined;
64
- return func(...params);
65
- },
66
- wait,
67
- options,
68
- );
59
+ const debounceFunc = debounce((...params: Parameters<T>) => {
60
+ // 防抖函数执行的时候清空缓存参数
61
+ oldParams = undefined;
62
+ return func(...params);
63
+ }, wait);
69
64
  return (...args: Parameters<T>) => {
70
65
  // 合并参数,并把参数缓存到oldParams里,用新参数调用防抖函数
71
66
  let newParams = args;
@@ -76,3 +71,59 @@ export function debounceAndMerge<T extends (...args: any[]) => any>(
76
71
  return debounceFunc(...newParams);
77
72
  };
78
73
  }
74
+
75
+ /**
76
+ * 防抖并合并每次的参数,最后一次才会执行
77
+ * 绑定方法为异步方法,给每次调用返回最终执行那次的结果
78
+ *
79
+ * @author lxm
80
+ * @date 2022-09-20 21:09:53
81
+ * @export
82
+ * @template T
83
+ * @param {T} func 要防抖的函数
84
+ * @param {(
85
+ * oldParams: Parameters<T>,
86
+ * newParams: Parameters<T>,
87
+ * ) => Parameters<T>} mergeFunc 合并的回调函数
88
+ * @param {number} [wait] 防抖的延迟毫秒数
89
+ * @returns {*}
90
+ */
91
+ export function debounceAndAsyncMerge<
92
+ T extends (...args: any[]) => Promise<any>,
93
+ >(
94
+ func: T,
95
+ mergeFunc: (
96
+ oldParams: Parameters<T>,
97
+ newParams: Parameters<T>,
98
+ ) => Parameters<T>,
99
+ wait?: number,
100
+ ): T {
101
+ // 缓存上一次的函数参数
102
+ let oldParams: Parameters<T> | undefined;
103
+ let promises: Array<{ resolve: any; reject: any }> = [];
104
+ const debounceFunc = debounce(async (...params: Parameters<T>) => {
105
+ // 防抖函数执行的时候清空缓存参数
106
+ oldParams = undefined;
107
+ const result = await func(...params);
108
+ promises.forEach(promise => {
109
+ promise.resolve(result);
110
+ });
111
+ promises = [];
112
+ return result;
113
+ }, wait);
114
+ const fun = async (...args: Parameters<T>) => {
115
+ // 合并参数,并把参数缓存到oldParams里,用新参数调用防抖函数
116
+ let newParams = args;
117
+ if (oldParams) {
118
+ newParams = mergeFunc(oldParams, newParams);
119
+ }
120
+ oldParams = newParams;
121
+ // 执行防抖函数
122
+ debounceFunc(...newParams);
123
+ return new Promise((resolve, reject) => {
124
+ // 阻塞当前调用,当防抖函数被执行后返回
125
+ promises.push({ resolve, reject });
126
+ });
127
+ };
128
+ return fun as T;
129
+ }