@ibiz-template/core 0.0.4-beta.4 → 0.0.4-beta.5
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/dist/index.esm.js +2 -1
- package/dist/index.system.min.js +1 -1
- package/out/utils/types/types.d.ts +10 -0
- package/out/utils/types/types.d.ts.map +1 -1
- package/out/utils/url-helper/url-helper.d.ts.map +1 -1
- package/out/utils/url-helper/url-helper.js +2 -1
- package/package.json +2 -2
- package/src/utils/types/types.ts +13 -0
- package/src/utils/url-helper/url-helper.ts +2 -1
package/dist/index.esm.js
CHANGED
|
@@ -1603,7 +1603,8 @@ var UrlHelper = class {
|
|
|
1603
1603
|
* @returns {*}
|
|
1604
1604
|
*/
|
|
1605
1605
|
static get routeBase() {
|
|
1606
|
-
|
|
1606
|
+
const hashIndex = window.location.href.lastIndexOf("#/");
|
|
1607
|
+
return window.location.href.slice(0, hashIndex + 1);
|
|
1607
1608
|
}
|
|
1608
1609
|
/**
|
|
1609
1610
|
* 应用的的基础路径
|
package/dist/index.system.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
System.register(["ramda","lodash-es","qx-util","axios","qs"],(function(e){"use strict";var t,n,s,r,o,i,a,c,l,u;return{setters:[function(e){t=e.clone},function(e){n=e.debounce,s=e.merge,r=e.uniqueId,e.round,e.cloneDeep,o=e.isFunction},function(e){i=e.getCookie,a=e.notNilEmpty},function(e){c=e.AxiosHeaders,l=e.default},function(e){u=e.stringify}],execute:function(){e({awaitTimeout:async function(e,t,n){if(await new Promise((t=>{setTimeout((()=>{t(!0)}),e)})),t)return t(...n||[])},calcMimeByFileName:Z,colorBlend:function(e,t,n=.5,s="hex"){e=e.trim(),t=t.trim();const r=X(e),o=X(t),i=[W((1-n)*r[0]+n*o[0]),W((1-n)*r[1]+n*o[1]),W((1-n)*r[2]+n*o[2]),(1-n)*r[3]+n*o[3]];if("hex"===s){const e=[i[0].toString(16),i[1].toString(16),i[2].toString(16),0===i[3]?"00":W(255*i[3]).toString(16)];return`#${e[0]}${e[1]}${e[2]}${e[3]}`}return`rgb(${i[0]} ${i[1]} ${i[2]} / ${i[3]})`},debounce:function(e,t,n){let s;return function(...r){if(s&&clearTimeout(s),n){const n=!s;s=setTimeout((()=>{s=null}),t),n&&e.apply(this,r)}else s=setTimeout((()=>{e.apply(this,r)}),t)}},debounceAndAsyncMerge:function(e,t,s){let r,o=[];const i=n((async(...t)=>{r=void 0;try{const n=await e(...t);return o.forEach((e=>{e.resolve(n)})),o=[],n}catch(e){o.forEach((t=>{t.reject(e)})),o=[]}}),s);return async(...e)=>{let n=e;return r&&(n=t(r,n)),r=n,i(...n),new Promise(((e,t)=>{o.push({resolve:e,reject:t})}))}},debounceAndMerge:function(e,t,s){let r;const o=n(((...t)=>(r=void 0,e(...t))),s);return(...e)=>{let n=e;return r&&(n=t(r,n)),r=n,o(...n)}},downloadFileFromBlob:function(e,t){const n=Z(t),s=new Blob([e],{type:n}),r=URL.createObjectURL(s),o=document.createElement("a");o.href=r,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)},eventPath:B,fileListToArr:K,getToken:I,install:function(){if(window.ibiz)throw new Error("ibiz 已经存在, 无需重复安装");window.ibiz=new J,window.___fc=new Y},isEventInside:H,isImage:function(e){const t=e.split(".").pop();if(!t)return!1;return[".jpeg","jpg","gif","png","bmp","svg"].includes(t)},isOverlap:function(e,t){return Array.from(new Set([...e,...t])).length!==e.length+t.length},listenJSEvent:D,onClickOutside:function(e,t,n={}){const{window:s=V,ignore:r=[],capture:o=!0}=n;if(!e)throw new S("target元素不存在");if(!s)throw new S("找不到window");let i=!0;const a=t=>![e,...r].some((e=>H(t,e)));let c=!1;let l;const u=e=>{c||(s.clearTimeout(l),i&&a(e)&&t(e))},d=[D(s,"click",u,{passive:!0,capture:o}),D(s,"pointerdown",(e=>{c||(i=a(e))}),{passive:!0}),D(s,"pointerup",(e=>{if(!c&&0===e.button){const t=B(e);e.composedPath=()=>t,l=s.setTimeout((()=>u(e)),50)}}),{passive:!0})].filter(Boolean);return{stop:()=>d.forEach((e=>e())),pause:()=>{c=!0},proceed:()=>{c=!1}}},selectFile:G,setRemoteStyle:async function(e){try{const t=await ibiz.net.get(e),n=document.createElement("style");n.setAttribute("title","app-style-css"),n.innerText=t.data,document.head.appendChild(n)}catch(t){M.debug("加载远程样式表失败",e)}},throttle:function(e,t){let n=null;return function(...s){n||(n=setTimeout((()=>{e.apply(this,s),n=null}),t))}},toDisposable:R,uploadFile:function(e){const t=s({multiple:!0,accept:"",separate:!0,beforeUpload:(e,t)=>!0,finish:e=>{},success:(e,t)=>{},error:(e,t)=>{},progress:e=>{}},e),n=async e=>{const n=e.map((e=>({status:"uploading",name:e.name,uid:r(),percentage:0})));if(!t.beforeUpload(e,n))return n.forEach((e=>{e.status="cancel"})),ibiz.log.debug("取消上传",n),n;try{const s=await(async(e,n)=>{if(t.request&&o(t.request))return t.request(e);const s=new FormData;throw e.forEach((e=>{s.append("file",e)})),new Error("多应用模式等待重新实现请求")})(e);n.forEach((e=>{e.status="finished"})),t.success(n,s),n.forEach((e=>{e.response=s}))}catch(s){n.forEach((e=>{e.status="fail"})),t.error(n,s),n.forEach((e=>{e.error=s})),ibiz.log.error(s),ibiz.log.error(`${e.map((e=>e.name)).join(",")}上传失败`)}return n};G({accept:t.accept,multiple:t.multiple,onSelected:e=>{(async e=>{const s=t.separate?e.map((e=>[e])):[e],r=await Promise.allSettled(s.map((async e=>n(e)))),o=[];r.forEach((e=>{"fulfilled"===e.status&&o.push(...e.value)})),t.finish(o)})(e)}})}});var d,h,p=Object.create,f=Object.defineProperty,m=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,w=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,v=(d={"../../node_modules/.pnpm/loglevel@1.8.1/node_modules/loglevel/lib/loglevel.js"(e,t){var n,s;n=e,s=function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["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 o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function i(s){return"debug"===s&&(s="log"),typeof console!==t&&("trace"===s&&n?o:void 0!==console[s]?r(console,s):void 0!==console.log?r(console,"log"):e)}function a(t,n){for(var r=0;r<s.length;r++){var o=s[r];this[o]=r<t?e:this.methodFactory(o,t,n)}this.log=this.debug}function c(e,n,s){return function(){typeof console!==t&&(a.call(this,n,s),this[e].apply(this,arguments))}}function l(e,t,n){return i(e)||c.apply(this,arguments)}function u(e,n,r){var o,i=this;n=null==n?"WARN":n;var c="loglevel";function u(){var e;if(typeof window!==t&&c){try{e=window.localStorage[c]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,s=n.indexOf(encodeURIComponent(c)+"=");-1!==s&&(e=/^([^;]+)/.exec(n.slice(s))[1])}catch(e){}return void 0===i.levels[e]&&(e=void 0),e}}"string"==typeof e?c+=":"+e:"symbol"==typeof e&&(c=void 0),i.name=e,i.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i.methodFactory=r||l,i.getLevel=function(){return o},i.setLevel=function(n,r){if("string"==typeof n&&void 0!==i.levels[n.toUpperCase()]&&(n=i.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=i.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(o=n,!1!==r&&function(e){var n=(s[e]||"silent").toUpperCase();if(typeof window!==t&&c){try{return void(window.localStorage[c]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+n+";"}catch(e){}}}(n),a.call(i,n,e),typeof console===t&&n<i.levels.SILENT)return"No console available for logging"},i.setDefaultLevel=function(e){n=e,u()||i.setLevel(e,!1)},i.resetLevel=function(){i.setLevel(n,!1),function(){if(typeof window!==t&&c){try{return void window.localStorage.removeItem(c)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},i.enableAll=function(e){i.setLevel(i.levels.TRACE,e)},i.disableAll=function(e){i.setLevel(i.levels.SILENT,e)};var d=u();null==d&&(d=n),i.setLevel(d,!1)}var d=new u,h={};d.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=h[e];return t||(t=h[e]=new u(e,d.getLevel(),d.methodFactory)),t};var p=typeof window!==t?window.log:void 0;return d.noConflict=function(){return typeof window!==t&&window.log===d&&(window.log=p),d},d.getLoggers=function(){return h},d.default=d,d},"function"==typeof define&&define.amd?define(s):"object"==typeof t&&t.exports?t.exports=s():n.log=s()}},function(){return h||(0,d[g(d)[0]])((h={exports:{}}).exports,h),h.exports}),b=class{constructor(e){this.element=e,this.next=b.Undefined,this.prev=b.Undefined}},E=b;E.Undefined=new b(void 0);var _=e("LinkedList",class{constructor(){this._first=E.Undefined,this._last=E.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===E.Undefined}clear(){let e=this._first;for(;e!==E.Undefined;){const{next:t}=e;e.prev=E.Undefined,e.next=E.Undefined,e=t}this._first=E.Undefined,this._last=E.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){const n=new E(e);if(this._first===E.Undefined)this._first=n,this._last=n;else if(t){const e=this._last;this._last=n,n.prev=e,e.next=n}else{const e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first===E.Undefined)return;const e=this._first.element;return this._remove(this._first),e}pop(){if(this._last===E.Undefined)return;const e=this._last.element;return this._remove(this._last),e}_remove(e){if(e.prev!==E.Undefined&&e.next!==E.Undefined){const t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===E.Undefined&&e.next===E.Undefined?(this._first=E.Undefined,this._last=E.Undefined):e.next===E.Undefined?(this._last=this._last.prev,this._last.next=E.Undefined):e.prev===E.Undefined&&(this._first=this._first.next,this._first.prev=E.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==E.Undefined;)yield e.element,e=e.next}});function x(e){const t=this;let n,s=!1;return function(){return s||(s=!0,n=e.apply(t,arguments)),n}}function R(e){return{dispose:x((()=>{e()}))}}var U=e("CommandsRegistry",class{constructor(){this.commands=new Map}registerCommand(e,t,n){if(!e)throw new Error("invalid command");if("string"==typeof e){if(!t)throw new Error("invalid command");return this.registerCommand({id:e,handler:t,opts:n})}const{id:s}=e;let r=this.commands.get(s);r||(r=new _,this.commands.set(s,r));const o=r.unshift(e);return R((()=>{o();const e=this.commands.get(s);(null==e?void 0:e.isEmpty())&&this.commands.delete(s)}))}hasCommand(e){return this.commands.has(e)}getCommand(e){const t=this.commands.get(e);if(t&&!t.isEmpty())return t[Symbol.iterator]().next().value}getCommands(){const e=new Map,t=this.commands.keys();for(const n of t){const t=this.getCommand(n);t&&e.set(n,t)}return e}getCommandOpt(e){const t=this.getCommand(e);return null==t?void 0:t.opts}}),C=e("CommandController",class{constructor(){this.commandRegister=new U}register(e,t,n){return this.commandRegister.registerCommand(e,t,n)}async execute(e,...t){const n=this.commandRegister.getCommand(e);if(n)return n.handler(...t);throw new Error(`未注册指令: ${e},请先注册指令`)}hasCommand(e,t){const n=!!this.commandRegister.hasCommand(e);if(!0===t&&!0===n)throw new Error(`未注册指令: ${e},请先注册指令`);return n}getCommandOpts(e){return this.commandRegister.getCommandOpt(e)}}),$=(e("commands",new C),e("CoreConst",class{}));$.DEFAULT_MODEL_SERVICE_TAG="default",$.TOKEN="access_token",$.TOKEN_EXPIRES="access_token_expires";var k=e("NOOP",(()=>{})),O=(e("HttpStatusMessageConst",{200:"服务器成功返回请求的数据。",201:"新建或修改数据成功。",202:"一个请求已经进入后台排队(异步任务)。",204:"删除数据成功。",400:"发出的请求有错误,服务器没有进行新建或修改数据的操作。",401:"用户没有权限(令牌、用户名、密码错误)。",403:"用户得到授权,但是访问是被禁止的。",404:"发出的请求针对的是不存在的记录,服务器没有进行操作。",406:"请求的格式不可得。",410:"请求的资源被永久删除,且不会再得到的。",422:"当创建一个对象时,发生一个验证错误。",500:"服务器发生错误,请检查服务器。",502:"网关错误。",503:"服务不可用,服务器暂时过载或维护。",504:"网关超时。"}),e("LoginMode",(e=>(e.DEFAULT="DEFAULT",e.CUSTOM="CUSTOM",e.CAS="CAS",e))(O||{}))),P=e("MenuPermissionMode",(e=>(e.MIXIN="MIXIN",e.RESOURCE="RESOURCE",e.RT="RT",e))(P||{})),T=e("IBizContext",class{constructor(e={},t){if(Object.defineProperty(this,"_associationContext",{enumerable:!1,value:[]}),t){const e=this;Object.defineProperty(this,"_parent",{enumerable:!1,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!1,writable:!0,value:{}});const n={};Object.keys(t).forEach((s=>{n[s]={enumerable:!0,set(t){e._context[s]=null==t?null:t},get:()=>void 0!==e._context[s]?e._context[s]:t[s]}})),Object.defineProperties(this,n)}Object.assign(this,e)}getOwnContext(){const e={};return Object.keys(this).forEach((t=>{this._parent&&Object.prototype.hasOwnProperty.call(this._parent,t)&&!Object.prototype.hasOwnProperty.call(this._context,t)||(e[t]=this[t])})),e}destroy(){this._parent=void 0,this._context={},this._associationContext.forEach((e=>{e.destroy()}))}clone(){const e=new T(t(this.getOwnContext()),this._parent);return this._associationContext.push(e),e}static create(e,t){return new T(e,t)}}),L=e("Environment",{dev:!1,hub:!0,logLevel:"ERROR",baseUrl:"/api",appId:"",pluginBaseUrl:"./plugins",remoteModelUrl:"/remotemodel",assetsUrl:"./assets",dcSystem:"",downloadFileUrl:"/ibizutil/download",uploadFileUrl:"/ibizutil/upload",casLoginUrl:"",loginMode:"DEFAULT",menuPermissionMode:"MIXIN",enablePermission:!0,routePlaceholder:"-",enableWfAllHistory:!1}),j=e("HttpError",class extends Error{constructor(e){super("HttpError"),this.name="HttpError";const t=e.response;this.response=e.response,t?(t.data?this.message=t.data.message:this.message=t.statusText,this.message||(this.message="网络异常,请稍后重试!"),this.status=t.status):(this.message=e.message,this.status=500)}}),S=(e("ModelError",class extends Error{constructor(e,t){super(`「${e.id}」模型${t?`: ${t}`:""}`),this.model=e,this.name="未支持的模型"}}),e("RuntimeError",class extends Error{constructor(e){super(e),this.message=e,this.name="Runtime Error"}}));e("RuntimeModelError",class extends Error{constructor(e,t){super(`「${e.id}」模型${t?`: ${t}`:""}`),this.model=e,this.name="模型配置缺失"}});function I(){return i($.TOKEN)}var A=e("Interceptor",class{async onBeforeRequest(e){return e}onRequestError(e){return Promise.reject(e)}async onResponseSuccess(e){return e}onResponseError(e){return Promise.reject(e)}use(e){this.requestTag=e.interceptors.request.use(this.onBeforeRequest,this.onRequestError),this.responseTag=e.interceptors.response.use(this.onResponseSuccess,this.onResponseError)}eject(e){this.requestTag&&e.interceptors.request.eject(this.requestTag),this.responseTag&&e.interceptors.response.eject(this.responseTag)}}),z=e("CoreInterceptor",class extends A{async onBeforeRequest(e){await super.onBeforeRequest(e);const{headers:t}=e;t.set("Authorization",`Bearer ${I()}`);const{orgData:n}=ibiz;return n&&(n.systemid&&t.set("srfsystemid",n.systemid),n.orgid&&t.set("srforgid",n.orgid)),e}}),M=e("Logger",((e,t,n)=>(n=null!=e?p(w(e)):{},((e,t,n,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of g(t))y.call(e,r)||r===n||f(e,r,{get:()=>t[r],enumerable:!(s=m(t,r))||s.enumerable});return e})(!t&&e&&e.__esModule?n:f(n,"default",{value:e,enumerable:!0}),e)))(v(),1));function N(e,t,n,s,r){let o=`${e}-${t}`;return n&&(o+=`-${n}`),s&&(o+=`__${s}`),r&&(o+=`--${r}`),o}e("Namespace",class{constructor(e,t){this.block=e,this.namespace=t||"ibiz"}b(e=""){return N(this.namespace,this.block,e,"","")}e(e){return e?N(this.namespace,this.block,"",e,""):""}m(e){return e?N(this.namespace,this.block,"","",e):""}be(e,t){return e&&t?N(this.namespace,this.block,e,t,""):""}em(e,t){return e&&t?N(this.namespace,this.block,"",e,t):""}bm(e,t){return e&&t?N(this.namespace,this.block,e,"",t):""}bem(e,t,n){return e&&t&&n?N(this.namespace,this.block,e,t,n):""}is(e,t){return e&&t?`is-${e}`:""}cssVar(e){const t={};for(const n in e)e[n]&&(t[this.cssVarName(n)]=e[n]);return t}cssVarBlock(e){const t={};for(const n in e)e[n]&&(t[this.cssVarBlockName(n)]=e[n]);return t}cssVarName(e){return`--${this.namespace}-${e}`}cssVarBlockName(e){return`--${this.namespace}-${this.block}-${e}`}}),e("HttpResponse",class{constructor(e,t,n){this.local=!0,this.ok=!1,this.headers={},this.config={headers:new c},this.data=e,this.status=t||200,this.statusText=n||"",this.status>=200&&this.status<300&&(this.ok=!0)}});var q=e("Net",class{constructor(e){this.urlReg=/^http[s]?:\/\/[^\s]*/,this.interceptors=new Map,this.instance=l.create(e),this.addInterceptor("Default",new z)}addInterceptor(e,t){t.use(this.instance),this.interceptors.set(e,t)}removeInterceptor(e){const t=this.interceptors.get(e);t&&(t.eject(this.instance),this.interceptors.delete(e))}get presetConfig(){return{baseURL:this.instance.defaults.baseURL||`${ibiz.env.baseUrl}/${ibiz.env.appId}`,headers:{"Content-Type":"application/json;charset=UTF-8",Accept:"application/json"}}}mergeConfig(...e){const t=this.presetConfig;if(0===e.length)return t;const{url:n}=e[0];return n&&this.urlReg.test(n)&&delete t.baseURL,s(t,...e)}async post(e,t,n={},s={}){e=this.handleAppPresetParam(e,n);try{const n=await this.request(e,{method:"post",data:t,headers:s});return this.doResponseResult(n)}catch(e){throw new j(e)}}async get(e,t={},n={},r={}){e=this.attachUrlParam(e,t);try{const t=await this.request(e,s({method:"get",headers:n},r));return this.doResponseResult(t)}catch(e){throw new j(e)}}async delete(e,t,n={}){e=this.handleAppPresetParam(e,t);try{const t=await this.request(e,{method:"delete",headers:n});return this.doResponseResult(t)}catch(e){throw new j(e)}}async put(e,t,n={},s={}){e=this.handleAppPresetParam(e,n);try{const n=await this.request(e,{method:"put",data:t,headers:s});return this.doResponseResult(n)}catch(e){throw new j(e)}}async getModel(e,t={}){try{const n=await this.instance.get(e,{headers:t});return this.doResponseResult(n)}catch(e){throw new j(e)}}async request(e,t={}){try{const n=await this.instance.request(this.mergeConfig({url:e},t));return this.doResponseResult(n)}catch(e){throw new j(e)}}axios(e){return l(e)}doResponseResult(e){const t=e;return t.status>=200&&t.status<=299&&(t.ok=!0),t}handleAppPresetParam(e,t){if(t){return Object.keys(t).forEach((e=>{e.startsWith("srf")&&a(t[e])&&t[e]})),this.attachUrlParam(e,t)}return e}attachUrlParam(e,t){const n=u(t);return a(n)&&(e=e.endsWith("?")||-1!==e.indexOf("?")&&e.endsWith("&")?`${e}${n}`:-1===e.indexOf("?")||e.endsWith("&")?`${e}?${n}`:`${e}&${n}`),e}}),F=e("StringUtil",class{static fill(e,t,n){if(a(e)){if(a(t)){const n=e.match(this.contextReg);null==n||n.forEach((n=>{const s=n.slice(10,n.length-1);e=e.replace(`\${context.${s}}`,t[s]||"")}))}if(a(n)){const t=e.match(this.dataReg);null==t||t.forEach((t=>{const s=t.slice(7,t.length-1);e=e.replace(`\${data.${s}}`,n[s]||"")}))}}return e}});F.contextReg=/\$\{context.[a-zA-Z_$][a-zA-Z0-9_$]{1,}\}/g,F.dataReg=/\$\{data.[a-zA-Z_$][a-zA-Z0-9_$]{1,}\}/g;e("UrlHelper",class{static get routeBase(){return`${this.appBase}/#`}static get appBase(){const{origin:e,pathname:t}=window.location;return`${e}${t}`.replace(/\/$/,"")}static get routePath(){return window.location.hash.replace("#","")}static get fullPath(){return window.location.href}});function B(e){const t=e.composedPath&&e.composedPath()||e.path;if(null!=t)return t;return[e.target].concat(function e(t,n=[]){const s=t.parentNode;return s?e(s,n.concat([s])):n}(e.target))}function D(e,t,n,s={}){e.addEventListener(t,n,s);let r=()=>{e.removeEventListener(t,n,s),r=k};return()=>{r()}}function H(e,t){return t&&(e.target===t||B(e).includes(t))}var V="undefined"!=typeof window?window:void 0;var W=Math.round;function X(e){const t=e.length,n=[];if("rgb"===e.slice(0,3).toLowerCase()){const t=e.match(/([\d|.%]{1,3})/g);n[0]=parseInt(t[0],10),n[1]=parseInt(t[1],10),n[2]=parseInt(t[2],10),n[3]=t[3]?-1!==t[3].indexOf("%")?parseInt(t[3],10)/100:parseFloat(t[3]):1}else{let s;s=t<6?parseInt(String(e[1])+e[1]+e[2]+e[2]+e[3]+e[3]+(t>4?String(e[4])+e[4]:""),16):parseInt(e.slice(1),16),n[0]=s>>16&255,n[1]=s>>8&255,n[2]=255&s,n[3]=9===t||5===t?W((s>>24&255)/255*1e4)/1e4:1}return n}function Z(e){let t="";switch(e.split(".").pop()){case".wps":t="application/kswps";break;case".doc":t="application/msword";break;case".docx":t="application/vnd.openxmlformats-officedocument.wordprocessingml.document";break;case".txt":t="text/plain";break;case".zip":t="application/zip";break;case".png":t="image/png";break;case".gif":t="image/gif";break;case".jpeg":case".jpg":t="image/jpeg";break;case".rtf":t="application/rtf";break;case".avi":t="video/x-msvideo";break;case".gz":t="application/x-gzip";break;case".tar":t="application/x-tar";break;case".xlsx":t="application/vnd.ms-excel";break;default:t=""}return t}function K(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t}function G(e){const t=s({multiple:!0,accept:""},e),n=document.createElement("input");n.setAttribute("type","file"),n.setAttribute("multiple",`${t.multiple}`),n.setAttribute("accept",t.accept),n.onchange=e=>{const n=e.target,s=n.files?K(n.files):[];0!==s.length&&(t.onSelected(s),n.value="")},document.body.appendChild(n),n.click(),document.body.removeChild(n)}e("CountLatch",class{constructor(){this.promise=null,this.resolve=null,this.count=0}startPromise(){this.promise=new Promise((e=>{this.resolve=e}))}endPromise(){this.resolve&&(this.resolve(),this.resolve=null,this.promise=null)}lock(){this.count+=1,this.promise||this.startPromise()}unlock(){if(this.count<1)throw new S("lock和unlock次数不匹配!");this.count-=1,0===this.count&&this.endPromise()}async await(){this.promise&&await this.promise}});var J=e("IBizSys",class{constructor(){this.env=L,this.log=M,this.net=new q,this.commands=new C}}),Y=e("FactoryCenter",class{})}}}));
|
|
1
|
+
System.register(["ramda","lodash-es","qx-util","axios","qs"],(function(e){"use strict";var t,n,s,r,o,i,a,c,l,u;return{setters:[function(e){t=e.clone},function(e){n=e.debounce,s=e.merge,r=e.uniqueId,e.round,e.cloneDeep,o=e.isFunction},function(e){i=e.getCookie,a=e.notNilEmpty},function(e){c=e.AxiosHeaders,l=e.default},function(e){u=e.stringify}],execute:function(){e({awaitTimeout:async function(e,t,n){if(await new Promise((t=>{setTimeout((()=>{t(!0)}),e)})),t)return t(...n||[])},calcMimeByFileName:Z,colorBlend:function(e,t,n=.5,s="hex"){e=e.trim(),t=t.trim();const r=X(e),o=X(t),i=[W((1-n)*r[0]+n*o[0]),W((1-n)*r[1]+n*o[1]),W((1-n)*r[2]+n*o[2]),(1-n)*r[3]+n*o[3]];if("hex"===s){const e=[i[0].toString(16),i[1].toString(16),i[2].toString(16),0===i[3]?"00":W(255*i[3]).toString(16)];return`#${e[0]}${e[1]}${e[2]}${e[3]}`}return`rgb(${i[0]} ${i[1]} ${i[2]} / ${i[3]})`},debounce:function(e,t,n){let s;return function(...r){if(s&&clearTimeout(s),n){const n=!s;s=setTimeout((()=>{s=null}),t),n&&e.apply(this,r)}else s=setTimeout((()=>{e.apply(this,r)}),t)}},debounceAndAsyncMerge:function(e,t,s){let r,o=[];const i=n((async(...t)=>{r=void 0;try{const n=await e(...t);return o.forEach((e=>{e.resolve(n)})),o=[],n}catch(e){o.forEach((t=>{t.reject(e)})),o=[]}}),s);return async(...e)=>{let n=e;return r&&(n=t(r,n)),r=n,i(...n),new Promise(((e,t)=>{o.push({resolve:e,reject:t})}))}},debounceAndMerge:function(e,t,s){let r;const o=n(((...t)=>(r=void 0,e(...t))),s);return(...e)=>{let n=e;return r&&(n=t(r,n)),r=n,o(...n)}},downloadFileFromBlob:function(e,t){const n=Z(t),s=new Blob([e],{type:n}),r=URL.createObjectURL(s),o=document.createElement("a");o.href=r,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)},eventPath:B,fileListToArr:K,getToken:S,install:function(){if(window.ibiz)throw new Error("ibiz 已经存在, 无需重复安装");window.ibiz=new J,window.___fc=new Y},isEventInside:H,isImage:function(e){const t=e.split(".").pop();if(!t)return!1;return[".jpeg","jpg","gif","png","bmp","svg"].includes(t)},isOverlap:function(e,t){return Array.from(new Set([...e,...t])).length!==e.length+t.length},listenJSEvent:D,onClickOutside:function(e,t,n={}){const{window:s=V,ignore:r=[],capture:o=!0}=n;if(!e)throw new I("target元素不存在");if(!s)throw new I("找不到window");let i=!0;const a=t=>![e,...r].some((e=>H(t,e)));let c=!1;let l;const u=e=>{c||(s.clearTimeout(l),i&&a(e)&&t(e))},d=[D(s,"click",u,{passive:!0,capture:o}),D(s,"pointerdown",(e=>{c||(i=a(e))}),{passive:!0}),D(s,"pointerup",(e=>{if(!c&&0===e.button){const t=B(e);e.composedPath=()=>t,l=s.setTimeout((()=>u(e)),50)}}),{passive:!0})].filter(Boolean);return{stop:()=>d.forEach((e=>e())),pause:()=>{c=!0},proceed:()=>{c=!1}}},selectFile:G,setRemoteStyle:async function(e){try{const t=await ibiz.net.get(e),n=document.createElement("style");n.setAttribute("title","app-style-css"),n.innerText=t.data,document.head.appendChild(n)}catch(t){M.debug("加载远程样式表失败",e)}},throttle:function(e,t){let n=null;return function(...s){n||(n=setTimeout((()=>{e.apply(this,s),n=null}),t))}},toDisposable:R,uploadFile:function(e){const t=s({multiple:!0,accept:"",separate:!0,beforeUpload:(e,t)=>!0,finish:e=>{},success:(e,t)=>{},error:(e,t)=>{},progress:e=>{}},e),n=async e=>{const n=e.map((e=>({status:"uploading",name:e.name,uid:r(),percentage:0})));if(!t.beforeUpload(e,n))return n.forEach((e=>{e.status="cancel"})),ibiz.log.debug("取消上传",n),n;try{const s=await(async(e,n)=>{if(t.request&&o(t.request))return t.request(e);const s=new FormData;throw e.forEach((e=>{s.append("file",e)})),new Error("多应用模式等待重新实现请求")})(e);n.forEach((e=>{e.status="finished"})),t.success(n,s),n.forEach((e=>{e.response=s}))}catch(s){n.forEach((e=>{e.status="fail"})),t.error(n,s),n.forEach((e=>{e.error=s})),ibiz.log.error(s),ibiz.log.error(`${e.map((e=>e.name)).join(",")}上传失败`)}return n};G({accept:t.accept,multiple:t.multiple,onSelected:e=>{(async e=>{const s=t.separate?e.map((e=>[e])):[e],r=await Promise.allSettled(s.map((async e=>n(e)))),o=[];r.forEach((e=>{"fulfilled"===e.status&&o.push(...e.value)})),t.finish(o)})(e)}})}});var d,h,p=Object.create,f=Object.defineProperty,m=Object.getOwnPropertyDescriptor,g=Object.getOwnPropertyNames,w=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,v=(d={"../../node_modules/.pnpm/loglevel@1.8.1/node_modules/loglevel/lib/loglevel.js"(e,t){var n,s;n=e,s=function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["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 o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function i(s){return"debug"===s&&(s="log"),typeof console!==t&&("trace"===s&&n?o:void 0!==console[s]?r(console,s):void 0!==console.log?r(console,"log"):e)}function a(t,n){for(var r=0;r<s.length;r++){var o=s[r];this[o]=r<t?e:this.methodFactory(o,t,n)}this.log=this.debug}function c(e,n,s){return function(){typeof console!==t&&(a.call(this,n,s),this[e].apply(this,arguments))}}function l(e,t,n){return i(e)||c.apply(this,arguments)}function u(e,n,r){var o,i=this;n=null==n?"WARN":n;var c="loglevel";function u(){var e;if(typeof window!==t&&c){try{e=window.localStorage[c]}catch(e){}if(typeof e===t)try{var n=window.document.cookie,s=n.indexOf(encodeURIComponent(c)+"=");-1!==s&&(e=/^([^;]+)/.exec(n.slice(s))[1])}catch(e){}return void 0===i.levels[e]&&(e=void 0),e}}"string"==typeof e?c+=":"+e:"symbol"==typeof e&&(c=void 0),i.name=e,i.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i.methodFactory=r||l,i.getLevel=function(){return o},i.setLevel=function(n,r){if("string"==typeof n&&void 0!==i.levels[n.toUpperCase()]&&(n=i.levels[n.toUpperCase()]),!("number"==typeof n&&n>=0&&n<=i.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(o=n,!1!==r&&function(e){var n=(s[e]||"silent").toUpperCase();if(typeof window!==t&&c){try{return void(window.localStorage[c]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+n+";"}catch(e){}}}(n),a.call(i,n,e),typeof console===t&&n<i.levels.SILENT)return"No console available for logging"},i.setDefaultLevel=function(e){n=e,u()||i.setLevel(e,!1)},i.resetLevel=function(){i.setLevel(n,!1),function(){if(typeof window!==t&&c){try{return void window.localStorage.removeItem(c)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},i.enableAll=function(e){i.setLevel(i.levels.TRACE,e)},i.disableAll=function(e){i.setLevel(i.levels.SILENT,e)};var d=u();null==d&&(d=n),i.setLevel(d,!1)}var d=new u,h={};d.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=h[e];return t||(t=h[e]=new u(e,d.getLevel(),d.methodFactory)),t};var p=typeof window!==t?window.log:void 0;return d.noConflict=function(){return typeof window!==t&&window.log===d&&(window.log=p),d},d.getLoggers=function(){return h},d.default=d,d},"function"==typeof define&&define.amd?define(s):"object"==typeof t&&t.exports?t.exports=s():n.log=s()}},function(){return h||(0,d[g(d)[0]])((h={exports:{}}).exports,h),h.exports}),b=class{constructor(e){this.element=e,this.next=b.Undefined,this.prev=b.Undefined}},E=b;E.Undefined=new b(void 0);var _=e("LinkedList",class{constructor(){this._first=E.Undefined,this._last=E.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===E.Undefined}clear(){let e=this._first;for(;e!==E.Undefined;){const{next:t}=e;e.prev=E.Undefined,e.next=E.Undefined,e=t}this._first=E.Undefined,this._last=E.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){const n=new E(e);if(this._first===E.Undefined)this._first=n,this._last=n;else if(t){const e=this._last;this._last=n,n.prev=e,e.next=n}else{const e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(n))}}shift(){if(this._first===E.Undefined)return;const e=this._first.element;return this._remove(this._first),e}pop(){if(this._last===E.Undefined)return;const e=this._last.element;return this._remove(this._last),e}_remove(e){if(e.prev!==E.Undefined&&e.next!==E.Undefined){const t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===E.Undefined&&e.next===E.Undefined?(this._first=E.Undefined,this._last=E.Undefined):e.next===E.Undefined?(this._last=this._last.prev,this._last.next=E.Undefined):e.prev===E.Undefined&&(this._first=this._first.next,this._first.prev=E.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==E.Undefined;)yield e.element,e=e.next}});function x(e){const t=this;let n,s=!1;return function(){return s||(s=!0,n=e.apply(t,arguments)),n}}function R(e){return{dispose:x((()=>{e()}))}}var U=e("CommandsRegistry",class{constructor(){this.commands=new Map}registerCommand(e,t,n){if(!e)throw new Error("invalid command");if("string"==typeof e){if(!t)throw new Error("invalid command");return this.registerCommand({id:e,handler:t,opts:n})}const{id:s}=e;let r=this.commands.get(s);r||(r=new _,this.commands.set(s,r));const o=r.unshift(e);return R((()=>{o();const e=this.commands.get(s);(null==e?void 0:e.isEmpty())&&this.commands.delete(s)}))}hasCommand(e){return this.commands.has(e)}getCommand(e){const t=this.commands.get(e);if(t&&!t.isEmpty())return t[Symbol.iterator]().next().value}getCommands(){const e=new Map,t=this.commands.keys();for(const n of t){const t=this.getCommand(n);t&&e.set(n,t)}return e}getCommandOpt(e){const t=this.getCommand(e);return null==t?void 0:t.opts}}),C=e("CommandController",class{constructor(){this.commandRegister=new U}register(e,t,n){return this.commandRegister.registerCommand(e,t,n)}async execute(e,...t){const n=this.commandRegister.getCommand(e);if(n)return n.handler(...t);throw new Error(`未注册指令: ${e},请先注册指令`)}hasCommand(e,t){const n=!!this.commandRegister.hasCommand(e);if(!0===t&&!0===n)throw new Error(`未注册指令: ${e},请先注册指令`);return n}getCommandOpts(e){return this.commandRegister.getCommandOpt(e)}}),$=(e("commands",new C),e("CoreConst",class{}));$.DEFAULT_MODEL_SERVICE_TAG="default",$.TOKEN="access_token",$.TOKEN_EXPIRES="access_token_expires";var k=e("NOOP",(()=>{})),O=(e("HttpStatusMessageConst",{200:"服务器成功返回请求的数据。",201:"新建或修改数据成功。",202:"一个请求已经进入后台排队(异步任务)。",204:"删除数据成功。",400:"发出的请求有错误,服务器没有进行新建或修改数据的操作。",401:"用户没有权限(令牌、用户名、密码错误)。",403:"用户得到授权,但是访问是被禁止的。",404:"发出的请求针对的是不存在的记录,服务器没有进行操作。",406:"请求的格式不可得。",410:"请求的资源被永久删除,且不会再得到的。",422:"当创建一个对象时,发生一个验证错误。",500:"服务器发生错误,请检查服务器。",502:"网关错误。",503:"服务不可用,服务器暂时过载或维护。",504:"网关超时。"}),e("LoginMode",(e=>(e.DEFAULT="DEFAULT",e.CUSTOM="CUSTOM",e.CAS="CAS",e))(O||{}))),P=e("MenuPermissionMode",(e=>(e.MIXIN="MIXIN",e.RESOURCE="RESOURCE",e.RT="RT",e))(P||{})),T=e("IBizContext",class{constructor(e={},t){if(Object.defineProperty(this,"_associationContext",{enumerable:!1,value:[]}),t){const e=this;Object.defineProperty(this,"_parent",{enumerable:!1,writable:!0,value:t}),Object.defineProperty(this,"_context",{enumerable:!1,writable:!0,value:{}});const n={};Object.keys(t).forEach((s=>{n[s]={enumerable:!0,set(t){e._context[s]=null==t?null:t},get:()=>void 0!==e._context[s]?e._context[s]:t[s]}})),Object.defineProperties(this,n)}Object.assign(this,e)}getOwnContext(){const e={};return Object.keys(this).forEach((t=>{this._parent&&Object.prototype.hasOwnProperty.call(this._parent,t)&&!Object.prototype.hasOwnProperty.call(this._context,t)||(e[t]=this[t])})),e}destroy(){this._parent=void 0,this._context={},this._associationContext.forEach((e=>{e.destroy()}))}clone(){const e=new T(t(this.getOwnContext()),this._parent);return this._associationContext.push(e),e}static create(e,t){return new T(e,t)}}),L=e("Environment",{dev:!1,hub:!0,logLevel:"ERROR",baseUrl:"/api",appId:"",pluginBaseUrl:"./plugins",remoteModelUrl:"/remotemodel",assetsUrl:"./assets",dcSystem:"",downloadFileUrl:"/ibizutil/download",uploadFileUrl:"/ibizutil/upload",casLoginUrl:"",loginMode:"DEFAULT",menuPermissionMode:"MIXIN",enablePermission:!0,routePlaceholder:"-",enableWfAllHistory:!1}),j=e("HttpError",class extends Error{constructor(e){super("HttpError"),this.name="HttpError";const t=e.response;this.response=e.response,t?(t.data?this.message=t.data.message:this.message=t.statusText,this.message||(this.message="网络异常,请稍后重试!"),this.status=t.status):(this.message=e.message,this.status=500)}}),I=(e("ModelError",class extends Error{constructor(e,t){super(`「${e.id}」模型${t?`: ${t}`:""}`),this.model=e,this.name="未支持的模型"}}),e("RuntimeError",class extends Error{constructor(e){super(e),this.message=e,this.name="Runtime Error"}}));e("RuntimeModelError",class extends Error{constructor(e,t){super(`「${e.id}」模型${t?`: ${t}`:""}`),this.model=e,this.name="模型配置缺失"}});function S(){return i($.TOKEN)}var A=e("Interceptor",class{async onBeforeRequest(e){return e}onRequestError(e){return Promise.reject(e)}async onResponseSuccess(e){return e}onResponseError(e){return Promise.reject(e)}use(e){this.requestTag=e.interceptors.request.use(this.onBeforeRequest,this.onRequestError),this.responseTag=e.interceptors.response.use(this.onResponseSuccess,this.onResponseError)}eject(e){this.requestTag&&e.interceptors.request.eject(this.requestTag),this.responseTag&&e.interceptors.response.eject(this.responseTag)}}),z=e("CoreInterceptor",class extends A{async onBeforeRequest(e){await super.onBeforeRequest(e);const{headers:t}=e;t.set("Authorization",`Bearer ${S()}`);const{orgData:n}=ibiz;return n&&(n.systemid&&t.set("srfsystemid",n.systemid),n.orgid&&t.set("srforgid",n.orgid)),e}}),M=e("Logger",((e,t,n)=>(n=null!=e?p(w(e)):{},((e,t,n,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of g(t))y.call(e,r)||r===n||f(e,r,{get:()=>t[r],enumerable:!(s=m(t,r))||s.enumerable});return e})(!t&&e&&e.__esModule?n:f(n,"default",{value:e,enumerable:!0}),e)))(v(),1));function N(e,t,n,s,r){let o=`${e}-${t}`;return n&&(o+=`-${n}`),s&&(o+=`__${s}`),r&&(o+=`--${r}`),o}e("Namespace",class{constructor(e,t){this.block=e,this.namespace=t||"ibiz"}b(e=""){return N(this.namespace,this.block,e,"","")}e(e){return e?N(this.namespace,this.block,"",e,""):""}m(e){return e?N(this.namespace,this.block,"","",e):""}be(e,t){return e&&t?N(this.namespace,this.block,e,t,""):""}em(e,t){return e&&t?N(this.namespace,this.block,"",e,t):""}bm(e,t){return e&&t?N(this.namespace,this.block,e,"",t):""}bem(e,t,n){return e&&t&&n?N(this.namespace,this.block,e,t,n):""}is(e,t){return e&&t?`is-${e}`:""}cssVar(e){const t={};for(const n in e)e[n]&&(t[this.cssVarName(n)]=e[n]);return t}cssVarBlock(e){const t={};for(const n in e)e[n]&&(t[this.cssVarBlockName(n)]=e[n]);return t}cssVarName(e){return`--${this.namespace}-${e}`}cssVarBlockName(e){return`--${this.namespace}-${this.block}-${e}`}}),e("HttpResponse",class{constructor(e,t,n){this.local=!0,this.ok=!1,this.headers={},this.config={headers:new c},this.data=e,this.status=t||200,this.statusText=n||"",this.status>=200&&this.status<300&&(this.ok=!0)}});var q=e("Net",class{constructor(e){this.urlReg=/^http[s]?:\/\/[^\s]*/,this.interceptors=new Map,this.instance=l.create(e),this.addInterceptor("Default",new z)}addInterceptor(e,t){t.use(this.instance),this.interceptors.set(e,t)}removeInterceptor(e){const t=this.interceptors.get(e);t&&(t.eject(this.instance),this.interceptors.delete(e))}get presetConfig(){return{baseURL:this.instance.defaults.baseURL||`${ibiz.env.baseUrl}/${ibiz.env.appId}`,headers:{"Content-Type":"application/json;charset=UTF-8",Accept:"application/json"}}}mergeConfig(...e){const t=this.presetConfig;if(0===e.length)return t;const{url:n}=e[0];return n&&this.urlReg.test(n)&&delete t.baseURL,s(t,...e)}async post(e,t,n={},s={}){e=this.handleAppPresetParam(e,n);try{const n=await this.request(e,{method:"post",data:t,headers:s});return this.doResponseResult(n)}catch(e){throw new j(e)}}async get(e,t={},n={},r={}){e=this.attachUrlParam(e,t);try{const t=await this.request(e,s({method:"get",headers:n},r));return this.doResponseResult(t)}catch(e){throw new j(e)}}async delete(e,t,n={}){e=this.handleAppPresetParam(e,t);try{const t=await this.request(e,{method:"delete",headers:n});return this.doResponseResult(t)}catch(e){throw new j(e)}}async put(e,t,n={},s={}){e=this.handleAppPresetParam(e,n);try{const n=await this.request(e,{method:"put",data:t,headers:s});return this.doResponseResult(n)}catch(e){throw new j(e)}}async getModel(e,t={}){try{const n=await this.instance.get(e,{headers:t});return this.doResponseResult(n)}catch(e){throw new j(e)}}async request(e,t={}){try{const n=await this.instance.request(this.mergeConfig({url:e},t));return this.doResponseResult(n)}catch(e){throw new j(e)}}axios(e){return l(e)}doResponseResult(e){const t=e;return t.status>=200&&t.status<=299&&(t.ok=!0),t}handleAppPresetParam(e,t){if(t){return Object.keys(t).forEach((e=>{e.startsWith("srf")&&a(t[e])&&t[e]})),this.attachUrlParam(e,t)}return e}attachUrlParam(e,t){const n=u(t);return a(n)&&(e=e.endsWith("?")||-1!==e.indexOf("?")&&e.endsWith("&")?`${e}${n}`:-1===e.indexOf("?")||e.endsWith("&")?`${e}?${n}`:`${e}&${n}`),e}}),F=e("StringUtil",class{static fill(e,t,n){if(a(e)){if(a(t)){const n=e.match(this.contextReg);null==n||n.forEach((n=>{const s=n.slice(10,n.length-1);e=e.replace(`\${context.${s}}`,t[s]||"")}))}if(a(n)){const t=e.match(this.dataReg);null==t||t.forEach((t=>{const s=t.slice(7,t.length-1);e=e.replace(`\${data.${s}}`,n[s]||"")}))}}return e}});F.contextReg=/\$\{context.[a-zA-Z_$][a-zA-Z0-9_$]{1,}\}/g,F.dataReg=/\$\{data.[a-zA-Z_$][a-zA-Z0-9_$]{1,}\}/g;e("UrlHelper",class{static get routeBase(){const e=window.location.href.lastIndexOf("#/");return window.location.href.slice(0,e+1)}static get appBase(){const{origin:e,pathname:t}=window.location;return`${e}${t}`.replace(/\/$/,"")}static get routePath(){return window.location.hash.replace("#","")}static get fullPath(){return window.location.href}});function B(e){const t=e.composedPath&&e.composedPath()||e.path;if(null!=t)return t;return[e.target].concat(function e(t,n=[]){const s=t.parentNode;return s?e(s,n.concat([s])):n}(e.target))}function D(e,t,n,s={}){e.addEventListener(t,n,s);let r=()=>{e.removeEventListener(t,n,s),r=k};return()=>{r()}}function H(e,t){return t&&(e.target===t||B(e).includes(t))}var V="undefined"!=typeof window?window:void 0;var W=Math.round;function X(e){const t=e.length,n=[];if("rgb"===e.slice(0,3).toLowerCase()){const t=e.match(/([\d|.%]{1,3})/g);n[0]=parseInt(t[0],10),n[1]=parseInt(t[1],10),n[2]=parseInt(t[2],10),n[3]=t[3]?-1!==t[3].indexOf("%")?parseInt(t[3],10)/100:parseFloat(t[3]):1}else{let s;s=t<6?parseInt(String(e[1])+e[1]+e[2]+e[2]+e[3]+e[3]+(t>4?String(e[4])+e[4]:""),16):parseInt(e.slice(1),16),n[0]=s>>16&255,n[1]=s>>8&255,n[2]=255&s,n[3]=9===t||5===t?W((s>>24&255)/255*1e4)/1e4:1}return n}function Z(e){let t="";switch(e.split(".").pop()){case".wps":t="application/kswps";break;case".doc":t="application/msword";break;case".docx":t="application/vnd.openxmlformats-officedocument.wordprocessingml.document";break;case".txt":t="text/plain";break;case".zip":t="application/zip";break;case".png":t="image/png";break;case".gif":t="image/gif";break;case".jpeg":case".jpg":t="image/jpeg";break;case".rtf":t="application/rtf";break;case".avi":t="video/x-msvideo";break;case".gz":t="application/x-gzip";break;case".tar":t="application/x-tar";break;case".xlsx":t="application/vnd.ms-excel";break;default:t=""}return t}function K(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n]);return t}function G(e){const t=s({multiple:!0,accept:""},e),n=document.createElement("input");n.setAttribute("type","file"),n.setAttribute("multiple",`${t.multiple}`),n.setAttribute("accept",t.accept),n.onchange=e=>{const n=e.target,s=n.files?K(n.files):[];0!==s.length&&(t.onSelected(s),n.value="")},document.body.appendChild(n),n.click(),document.body.removeChild(n)}e("CountLatch",class{constructor(){this.promise=null,this.resolve=null,this.count=0}startPromise(){this.promise=new Promise((e=>{this.resolve=e}))}endPromise(){this.resolve&&(this.resolve(),this.resolve=null,this.promise=null)}lock(){this.count+=1,this.promise||this.startPromise()}unlock(){if(this.count<1)throw new I("lock和unlock次数不匹配!");this.count-=1,0===this.count&&this.endPromise()}async await(){this.promise&&await this.promise}});var J=e("IBizSys",class{constructor(){this.env=L,this.log=M,this.net=new q,this.commands=new C}}),Y=e("FactoryCenter",class{})}}}));
|
|
@@ -4,8 +4,18 @@
|
|
|
4
4
|
export type OmitObject<T, U> = {
|
|
5
5
|
[K in keyof Omit<T, keyof U>]: T[K];
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* 返回T和U的并集,其中U里面的属性都变成可选
|
|
9
|
+
*/
|
|
10
|
+
export type PartialWithObject<T, U> = {
|
|
11
|
+
[K in keyof Omit<T, keyof U>]: T[K];
|
|
12
|
+
} & Partial<U>;
|
|
7
13
|
/**
|
|
8
14
|
* 从T里面只获取索引类型为string的键
|
|
9
15
|
*/
|
|
10
16
|
export type StrKeyOf<T> = Extract<keyof T, string>;
|
|
17
|
+
/**
|
|
18
|
+
* 构造函数接口,声明一个返回对象是T的构造函数,不传则返回类型是any
|
|
19
|
+
*/
|
|
20
|
+
export type Constructor<T extends object = any> = new (...args: any[]) => T;
|
|
11
21
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/types/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/types/types.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,IAAI;KACnC,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACpC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAEf;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,GAAG,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-helper.d.ts","sourceRoot":"","sources":["../../../src/utils/url-helper/url-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB;;;;;;;;OAQG;IACH,MAAM,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"url-helper.d.ts","sourceRoot":"","sources":["../../../src/utils/url-helper/url-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB;;;;;;;;OAQG;IACH,MAAM,KAAK,SAAS,WAGnB;IAED;;;;;;;;OAQG;IACH,MAAM,KAAK,OAAO,WAGjB;IAED;;;;;;;;OAQG;IACH,MAAM,KAAK,SAAS,WAEnB;IAED;;;;;;;;OAQG;IACH,MAAM,KAAK,QAAQ,WAElB;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/core",
|
|
3
|
-
"version": "0.0.4-beta.
|
|
3
|
+
"version": "0.0.4-beta.5",
|
|
4
4
|
"description": "核心包",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "out/index.js",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"qx-util": "^0.4.8",
|
|
48
48
|
"ramda": "^0.29.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "899c34a41e55998a64d331fcf8ea28c94d1fdbce"
|
|
51
51
|
}
|
package/src/utils/types/types.ts
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
/**
|
|
2
3
|
* 从T里面排除U里相同的属性后剩下的属性组成的类型
|
|
3
4
|
*/
|
|
4
5
|
export type OmitObject<T, U> = { [K in keyof Omit<T, keyof U>]: T[K] };
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* 返回T和U的并集,其中U里面的属性都变成可选
|
|
9
|
+
*/
|
|
10
|
+
export type PartialWithObject<T, U> = {
|
|
11
|
+
[K in keyof Omit<T, keyof U>]: T[K];
|
|
12
|
+
} & Partial<U>;
|
|
13
|
+
|
|
6
14
|
/**
|
|
7
15
|
* 从T里面只获取索引类型为string的键
|
|
8
16
|
*/
|
|
9
17
|
export type StrKeyOf<T> = Extract<keyof T, string>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 构造函数接口,声明一个返回对象是T的构造函数,不传则返回类型是any
|
|
21
|
+
*/
|
|
22
|
+
export type Constructor<T extends object = any> = new (...args: any[]) => T;
|