multiStoreAdmin/dist/store/assets/vue-jsonp.3d85fcb6.js

2 lines
1.5 KiB
JavaScript
Raw Normal View History

2024-06-07 17:39:35 +08:00
function f(n,e){n=n.replace(/=/g,"");var t=[];switch(e.constructor){case String:case Number:case Boolean:t.push(encodeURIComponent(n)+"="+encodeURIComponent(e));break;case Array:e.forEach(function(a){t=t.concat(f(n+"[]=",a))});break;case Object:Object.keys(e).forEach(function(a){var c=e[a];t=t.concat(f(n+"["+a+"]",c))})}return t}function p(n){var e=[];return n.forEach(function(t){typeof t=="string"?e.push(t):e=e.concat(p(t))}),e}function h(n,e,t){if(e===void 0&&(e={}),typeof n!="string")throw new Error('[Vue-jsonp] Type of param "url" is not string.');if(typeof e!="object"||!e)throw new Error("[Vue-jsonp] Invalid params, should be an object.");return t=typeof t=="number"?t:5e3,new Promise(function(a,c){var b=typeof e.callbackQuery=="string"?e.callbackQuery:"callback",u=typeof e.callbackName=="string"?e.callbackName:"jsonp_"+(Math.floor(1e5*Math.random())*Date.now()).toString(16);e[b]=u,delete e.callbackQuery,delete e.callbackName;var i=[];Object.keys(e).forEach(function(r){i=i.concat(f(r,e[r]))});var y=p(i).join("&"),d=function(){s(),clearTimeout(l),c({status:400,statusText:"Bad Request"})},s=function(){o.removeEventListener("error",d)},m=function(){document.body.removeChild(o),delete window[u]},l=null;t>-1&&(l=setTimeout(function(){s(),m(),c({statusText:"Request Timeout",status:408})},t)),window[u]=function(r){clearTimeout(l),s(),m(),a(r)};var o=document.createElement("script");o.addEventListener("error",d),o.src=n+(/\?/.test(n)?"&":"?")+y,document.body.appendChild(o)})}export{h as o};