UNPKG

@hsui/core

Version:

Hundsun frontend runtime core framework

14 lines (13 loc) 26.6 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@hsui/sdk"),require("@hsui/logger"),require("vue"),require("vue-router"),require("@@/huiExports")):"function"==typeof define&&define.amd?define(["exports","@hsui/sdk","@hsui/logger","vue","vue-router","@@/huiExports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).core={},t.huiSdk,t.huiLogger,t.Vue,t.VueRouter,t.huiExports)}(this,(function(t,e,r,n,o,i){"use strict";function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var u=a(n),c=a(o);function f(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;i.length>n;n++)0>e.indexOf(r=i[n])&&(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;i.length>n;n++)0>e.indexOf(r=i[n])&&Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function s(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function h(t){for(var e=1;arguments.length>e;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?l(Object(r),!0).forEach((function(e){s(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function p(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function d(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function v(t,e,r){return e&&d(t.prototype,e),r&&d(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function y(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var g=0;function m(t){return"__private_"+g+++"_"+t}function b(t){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(t)}var w=Array.isArray;function x(t){return"[object Function]"===Object.prototype.toString.call(t)}function j(t){if("object"!==b(t)||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function O(){return!!window.__POWERED_BY_HUI_MICRO_APP__}var _=0;var k=Object.assign;function E(t){var e=b(t);return null!=t&&("object"==e||"function"==e)}function P(t){return JSON.parse(JSON.stringify(t))}var R=Object.freeze({__proto__:null,isArray:w,isFunction:x,isPlainObject:j,isMicroApp:O,uuid:function(){var t=Date.now();return"undefined"!=typeof performance&&"function"==typeof performance.now&&(t+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?r:3&r|8).toString(16)}))},uniqueId:function(t){var e=++_+"";return t?t+e:e},extend:k,isObject:E,clone:function(t){return E(t)?"function"==typeof t?t:w(t)?t.slice():k({},t):t},deepClone:P});function L(t){return void 0===t}function A(){}function C(t){return"string"==typeof t}function S(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);e>r;r++)n[r]=t[r];return n}function N(t){return function(t){if(Array.isArray(t))return S(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return S(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var M=function(){function t(e){p(this,t),this.type=e,this.middlewares=[],this.finalHook=A}return v(t,[{key:"final",value:function(t){this.finalHook=t}},{key:"concat",value:function(t){this.middlewares=this.middlewares.concat(t)}},{key:"push",value:function(t){this.middlewares.push(t)}},{key:"justRun",value:function(){this.args=Array.prototype.slice.call(arguments);var t=this;(function e(r){this.middlewares.length>r?this.middlewares[r].apply(null,[].concat(N(this.args),[function(){e.call(t,++r)}])):this.finalHook.apply(null,this.args)}).call(t,0)}},{key:"runAndReturn",value:function(){this.args=Array.prototype.slice.call(arguments);var t=this;return new Promise((function(e,r){(function n(o){if(this.middlewares.length>o)try{this.middlewares[o].apply(null,[].concat(N(this.args),[function(){n.call(t,++o)}]))}catch(t){r(t)}else this.finalHook.apply(null,this.args).then(e).catch(r)}).call(t,0)}))}}]),t}(),q={};["before-route-change","after-route-change","before-request-send","after-request-send","before-launch"].forEach((function(t){q[t]=new M(t)}));var $=q["before-route-change"],I=q["after-route-change"],T=q["before-request-send"],F=q["after-request-send"],U=q["before-launch"];function G(t,e){x(e)&&q[t].push(e),w(e)&&q[t].concat(e)}var D=r.createLogger(),H=function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return D.info.apply(D,e)};function W(t,e){return t?Promise.reject(t):Promise.resolve(e)}function V(t,e){var r=h(h({},t),e);if(r.shouldMergeHeaders){var n=e.headers,o=h(h({},t.headers),n);r.headers=o}return r}D.levels.forEach((function(t){H[t]=function(){for(var e=arguments.length,r=Array(e),n=0;e>n;n++)r[n]=arguments[n];return D[t].apply(D,r)}}));var Y=new WeakMap,B={method:"post",data:{},timeout:5e3,headers:{},withCredentials:!1},J=v((function t(){var r,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};function o(t){H.debug("Fetch 实例初始化选项",V(B,t));var e=T.runAndReturn(V(B,t));return Y.set(e,r),e}return p(this,t),k(B,n),T.final((function(t){return new Promise((function(n,o){var i,a;(r=e.ajax(t)).then((function(t){return a=t})).catch((function(t){return i=t})).finally((function(){F.runAndReturn(i,a).then(n).catch(o)}))}))})),F.final(W),o.get=function(t,e){return e?k(e,{url:t,method:"get"}):e={url:t,method:"get"},o(e)},o.post=function(t,e,r){return r?k(r,{url:t,method:"post",data:e}):r={url:t,method:"post",data:e},o(r)},o.cancel=function(){for(var t=arguments.length,r=Array(t),n=0;t>n;n++)r[n]=arguments[n];r.forEach((function(t,r){var n=Y.get(t),o=e.ajaxCancelMap.get(n);o?o():H.debug("没有找到下标为 ".concat(r," 对应的 cancel 函数"))}))},o}));var Q=require("../package.json").version,z=c.default.isNavigationFailure,K=c.default.NavigationFailureType,X=/[!'()*]/g,Z=function(t){return"%"+t.charCodeAt(0).toString(16)},tt=/%2C/g,et=function(t){return encodeURIComponent(t).replace(X,Z).replace(tt,",")},rt=decodeURIComponent,nt={scrollBehavior:function(){return{x:0,y:0}}},ot=null;function it(t,e){return ot||(u.default.use(c.default),"hash"===(e=h(h({},nt),e)).mode&&(e=h(h({},e),{},{parseQuery:function(t){var e={};if(!(t=t.trim().replace(/^(\?|#|&)/,""))){var r=location.search;if(!(r=r.trim().replace(/^(\?|#|&)/,"")))return e;t=r}return t.split("&").forEach((function(t){var r=t.replace(/\+/g," ").split("="),n=rt(r.shift()),o=r.length>0?rt(r.join("=")):null;void 0===e[n]?e[n]=o:Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]})),e},stringifyQuery:function(t){var e=t?Object.keys(t).map((function(e){var r=t[e];if(void 0===r)return"";if(null===r)return et(e);if(Array.isArray(r)){var n=[];return r.forEach((function(t){void 0!==t&&n.push(null===t?et(e):et(e)+"="+et(t))})),n.join("&")}return et(e)+"="+et(r)})).filter((function(t){return t.length>0})).join("&"):null;return e&&!location.search.includes(e)?"?".concat(e):""}})),ot=new c.default(e),t&&ot.addRoutes(t),H.debug("Router 实例",ot),H.debug("Router 构建选项",e),H.debug("Routes 路由记录",ot.getRoutes()),ot.beforeEach((function(t,e,r){H.debug("路由跳转前置导航守卫",t,e),r()})),$.middlewares.forEach((function(t){return ot.beforeEach(t)})),ot.afterEach((function(t,e){H.debug("路由跳转后置导航守卫",t,e),I.justRun(t,e)})),ot)}function at(t){k(nt,t)}function ut(t,e,r){if(ot){var n={history:!0};if("string"===!b(t)||""===t)return H.error("navigate 方法必须指定 path 为字符串类型且不能为空"),!1;j(e)&&L(r)&&(r=e,e=n),L(e)&&(e=n,r={});var o=function(t){if(!z(t,K.duplicated)&&!z(t,K.redirected))throw H.error("路由跳转异常",t),t};e.history?ot.push({path:t,query:r}).catch(o):ot.replace({path:t,query:r}).catch(o)}}function ct(t){ot&&ot.go(t)}var ft,st=(ft=ft||new Map,{on:function(t,e){var r=ft.get(t);r&&r.push(e)||ft.set(t,[e]),H.debug("部署事件监听",t)},off:function(t,e){var r=ft.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):ft.set(t,[])),H.debug("取消事件监听",t)},emit:function(t){H.debug.apply(H,["触发事件监听"].concat(Array.prototype.slice.call(arguments)));var e=Array.prototype.slice.call(arguments);(ft.get(t)||[]).slice().map((function(r){H.debug("响应事件监听",t,r),r.apply(null,e.slice(1))})),(ft.get("*")||[]).slice().map((function(r){H.debug("响应事件监听",t,r),r.apply(null,e)}))}});st.once=function(t,e){st.on(t,(function r(){e.apply(null,Array.prototype.slice.call(arguments)),st.off(t,r)}))};var lt=st.on,ht=st.once,pt=st.off,dt=st.emit,vt=st.emit,yt=0,gt=1,mt=2,bt=3,wt=0,xt=4,jt=5,Ot=6,_t=7,kt=8,Et=[];Et[wt]={ws:[wt],ident:[3,yt],"[":[xt],eof:[_t]},Et[1]={ws:[1],".":[2],"[":[xt],eof:[_t]},Et[2]={ws:[2],ident:[3,yt],0:[3,yt],number:[3,yt]},Et[3]={ident:[3,yt],0:[3,yt],number:[3,yt],ws:[1,gt],".":[2,gt],"[":[xt,gt],eof:[_t,gt]},Et[xt]={"'":[jt,yt],'"':[Ot,yt],"[":[xt,mt],"]":[1,bt],eof:kt,else:[xt,yt]},Et[jt]={"'":[xt,yt],eof:kt,else:[jt,yt]},Et[Ot]={'"':[xt,yt],eof:kt,else:[Ot,yt]};var Pt=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function Rt(t){if(null==t)return"eof";switch(t.charCodeAt(0)){case 91:case 93:case 46:case 34:case 39:return t;case 95:case 36:case 45:return"ident";case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"ws"}return"ident"}function Lt(t){var e,r,n=t.trim();return"0"!==t.charAt(0)&&(Pt.test(n)?(r=(e=n).charCodeAt(0))!==e.charCodeAt(e.length-1)||34!==r&&39!==r?e:e.slice(1,-1):"*"+n)}var At=function(){function t(){p(this,t),this._cache=void 0,this._cache=Object.create(null)}return v(t,[{key:"parsePath",value:function(t){var e=this._cache[t];return e||(e=function(t){var e,r,n,o,i,a,u,c=[],f=-1,s=wt,l=0,h=[];function p(){var e=t[f+1];if(s===jt&&"'"===e||s===Ot&&'"'===e)return f++,n="\\"+e,h[yt](),!0}for(h[gt]=function(){void 0!==r&&(c.push(r),r=void 0)},h[yt]=function(){void 0===r?r=n:r+=n},h[mt]=function(){h[yt](),l++},h[bt]=function(){if(l>0)l--,s=xt,h[yt]();else{if(l=0,void 0===r)return!1;if(!1===(r=Lt(r)))return!1;h[gt]()}};null!==s;)if(f++,"\\"!==(e=t[f])||!p()){if(o=Rt(e),(i=(u=Et[s])[o]||u.else||kt)===kt)return;if(s=i[0],(a=h[i[1]])&&(n=void 0===(n=i[2])?e:n,!1===a()))return;if(s===_t)return c}}(t),e&&(this._cache[t]=e)),e||[]}},{key:"getPathValue",value:function(t,e){if(!function(t){var e=b(t);return null!=t&&("object"==e||"function"==e)}(t))return null;var r=this.parsePath(e);if(0===r.length)return null;for(var n=r.length,o=t,i=0;n>i;){var a=o[r[i]];if(null==a)return null;o=a,i++}return o}}]),t}(),Ct=[],St=function(){function t(e){p(this,t),this.locale=e.locale||"en-US",this.messages=e.messages||{};var r=window.__hCoreReference__.root;this._root=e.root||r||null,this._path=new At,this.watchLocale(),Ct.push(this)}return v(t,[{key:"watchLocale",value:function(){if(this._root&&this._root.$i18n){var t=this;this.localeWatcher=this._root.$i18n.vm.$watch("locale",(function(e){t.locale=e}),{immediate:!0})}return null}},{key:"_translate",value:function(t,e){var r,n=this._path.getPathValue(t,e);if(w(n)||j(n))return n;if(null==n&&j(t))r=t[e];else{if(!C(n))return null;r=n}return C(r)?r:r.join("")}},{key:"t",value:function(t){if(!t)return"";var e=this.messages[this.locale];return e?this._translate(e,t):""}}]),t}(),Nt=m("app"),Mt=m("isNavigable"),qt=m("options"),$t=m("walkOpts"),It=function(){function t(r){if(p(this,t),Object.defineProperty(this,$t,{value:Tt}),Object.defineProperty(this,Nt,{writable:!0,value:void 0}),Object.defineProperty(this,Mt,{writable:!0,value:!0}),Object.defineProperty(this,qt,{writable:!0,value:{el:"#app",beforeDestroy:function(){Ct.forEach((function(t){t.localeWatcher&&(delete t.localeWatcher,t=null)}))}}}),y(this,Nt)[Nt])return y(this,Nt)[Nt];if(y(this,Nt)[Nt]=this,y(this,$t)[$t](r),this.Model.prototype.$hCore=y(this,Nt)[Nt],!this.ajax){var n=new J;k(this,{ajax:n,fetch:n})}k(this,{middleware:G}),k(this,{on:lt,once:ht,off:pt,emit:dt,trigger:vt}),k(this,{log:H,logger:D}),k(this,{utils:R}),k(this,{storage:e.storage}),k(this,{navigate:ut,go:ct})}return v(t,[{key:"Model",get:function(){return u.default}},{key:"options",get:function(){return y(this,qt)[qt]}},{key:"version",get:function(){return Q}},{key:"initRouter",value:function(t,e){if(y(this,Mt)[Mt]){var r=it(t,e);k(y(this,qt)[qt],{router:r,template:"<router-view></router-view>"}),k(this,{router:r})}}},{key:"addRoutes",value:function(t){this.router?(this.log.debug("新增 Routes 路由记录",t),this.router.addRoutes(t)):this.initRouter(t)}},{key:"start",value:function(t){var e=this;this.router||this.initRouter(),U.final((function(){O()?vt("app-start",t):(e.root=new e.Model(y(e,qt)[qt]),e.root.$nextTick((function(){vt("app-ready",e.root),t&&t(e.root)})))})),U.justRun(this)}}]),t}();function Tt(t){var e=this;j(t)&&Object.keys(t).forEach((function(r){if("ajaxConfig"===r||"fetchConfig"===r){var n=new J(t[r]);k(e,{ajax:n,fetch:n})}if("logLevel"===r&&D.setLevel(t[r]),"extraModelOptions"===r){var o=["router"];Object.keys(t[r]).filter((function(t){return!o.includes(t)})).forEach((function(n){k(y(e,qt)[qt],s({},n,t[r][n])),"store"===n&&k(e,s({},n,t[r][n]))}))}"extraRouterOptions"===r&&(void 0!==t[r].isNavigable&&(y(e,Mt)[Mt]=t[r].isNavigable),y(e,Mt)[Mt]&&y(e,Mt)[Mt]&&at(t[r]))}))}function Ft(){ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ Ft=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var o=Object.create((e&&e.prototype instanceof l?e:l).prototype),i=new _(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return E()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=x(a,r);if(u){if(u===s)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===s)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,i),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var s={};function l(){}function h(){}function p(){}var d={};u(d,o,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(k([])));y&&y!==e&&r.call(y,o)&&(d=y);var g=p.prototype=l.prototype=Object.create(d);function m(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function n(o,i,a,u){var c=f(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==b(l)&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var o;this._invoke=function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return s;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,s;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,s):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,s)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function k(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return h.prototype=p,u(g,"constructor",p),u(p,"constructor",h),h.displayName=u(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,u(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},m(w.prototype),u(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(c(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},m(g),u(g,a,"Generator"),u(g,o,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(this.prev>=i.tryLoc){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(i.catchLoc>this.prev)return n(i.catchLoc,!0);if(i.finallyLoc>this.prev)return n(i.finallyLoc)}else if(u){if(i.catchLoc>this.prev)return n(i.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(i.finallyLoc>this.prev)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(this.prev>=o.tryLoc&&r.call(o,"finallyLoc")&&o.finallyLoc>this.prev){var i=o;break}}i&&("break"===t||"continue"===t)&&e>=i.tryLoc&&i.finallyLoc>=e&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,s):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),s},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),s}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),s}},t}function Ut(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function Gt(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){Ut(i,n,o,a,u,"next",t)}function u(t){Ut(i,n,o,a,u,"throw",t)}a(void 0)}))}}function Dt(t){var e=t[t.length-1];if(e){var r=e.components.default;if(r)if(!("function"==typeof r&&!r.options))return Ht(r)||"default"}}function Ht(t){var e="function"==typeof t&&t.options?t.options:t;return e.layout?e.layout:(e.mixins||[]).slice().reverse().concat(e.extends||[]).reduce((function(t,e){return t||Ht(e)}),void 0)}function Wt(t){var e=[];return t.matched.forEach((function(t){Object.keys(t.components).forEach((function(r){var n=t.components[r];"function"==typeof n&&!n.options&&e.push(n().then((function(e){var n=e.__esModule||"undefined"!=typeof Symbol&&"Module"===e[Symbol.toStringTag];t.components[r]=n?e.default:e})))}))})),Promise.all(e)} /*! * vue-router-layout v0.1.5 * Lightweight layout resolver for Vue Router. * https://github.com/ktsn/vue-router-layout * * @license * Copyright (c) 2018 katashin * Released under the MIT license * https://github.com/ktsn/vue-router-layout/blob/master/LICENSE */var Vt=["meta"];t.hCoreReference=void 0;var Yt={meta:{versions:{"@hsui/core":Q,vue:u.default.version,"vue-router":c.default.version}}};function Bt(e){if(j(e)){if(D.setLevel(e.logLevel||"info"),D.setConfig&&D.setConfig(e.logConfig||{}),e.meta)for(var r in e.meta)Object.hasOwnProperty.call(e.meta,r)&&("versions"===r?Yt.meta.versions=h(h({},Yt.meta.versions),e.meta.versions):Yt.meta[r]=e.meta[r]);var n=f(e,Vt);Yt=h(h({},Yt),n)}return window.__hCoreReference__=t.hCoreReference=new It(Yt),H.debug("应用元数据信息",Yt.meta),H.debug("hCore 实例",t.hCoreReference),H.debug("hCore 构建选项",Yt),t.hCoreReference}if(e.setConfig({logger:D}),k(Bt,{extend:function(t){if(!j(t))return!1;for(var e in t)if(Object.hasOwnProperty.call(t,e)){var r=t[e];if("__proto__"===e||t===r)continue;r&&(j(r)||w(r))?It.prototype[e]=P(r):void 0!==r&&(It.prototype[e]=r)}}}),k(Bt,{middleware:G}),k(Bt,{log:H,logger:D}),k(Bt,{navigate:ut,go:ct}),k(Bt,{on:lt,once:ht,off:pt,emit:dt,trigger:vt}),k(Bt,{storage:e.storage}),k(Bt,{utils:R}),Yt.ajaxConfig||Yt.fetchConfig){var Jt=new J(Yt.ajaxConfig||Yt.fetchConfig);k(Bt,{ajax:Jt,fetch:Jt})}else{var Qt=new J;k(Bt,{ajax:Qt,fetch:Qt})}t.I18n=St,t.default=Bt,t.initFetch=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.defaultConfig,n=void 0===r?{method:"post",data:{},timeout:5e3,headers:{},withCredentials:!1}:r,o=t.beforeRequestSendMiddlewares,i=void 0===o?[]:o,a=t.afterRequestSendMiddlewares,u=void 0===a?[]:a,c=new M("before-request-send");c.concat(i);var f,s=new M("after-request-send");s.concat(u),s.final(W),c.final((function(t){return new Promise((function(r,n){var o,i;(f=e.ajax(t)).then((function(t){return i=t})).catch((function(t){return o=t})).finally((function(){s.runAndReturn(o,i).then(r).catch(n)}))}))}));var l=function(t){H.debug("Fetch 实例初始化选项",V(n,t));var e=c.runAndReturn(V(n,t));return Y.set(e,f),e};return l.get=function(t,e){return e?k(e,{url:t,method:"get"}):e={url:t,method:"get"},l(e)},l.post=function(t,e,r){return r?k(r,{url:t,method:"post",data:e}):r={url:t,method:"post",data:e},l(r)},l.cancel=function(){for(var t=arguments.length,r=Array(t),n=0;t>n;n++)r[n]=arguments[n];r.forEach((function(t,r){var n=Y.get(t),o=e.ajaxCancelMap.get(n);o?o():H.debug("没有找到下标为 ".concat(r," 对应的 cancel 函数"))}))},l},t.initRouter=function(t,e){return at(k(e,{routes:t}))},t.initRouterLayout=function(t){return u.default.use(c.default),u.default.mixin({inject:{$_routerLayout_notifyRouteUpdate:{default:null}},beforeRouteUpdate:function(t,e,r){var n=this;return Gt(Ft().mark((function e(){var o;return Ft().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(o=n.$_routerLayout_notifyRouteUpdate)){e.next=4;break}return e.next=4,o(t);case 4:r();case 5:case"end":return e.stop()}}),e)})))()}}),u.default.extend({name:"RouterLayout",data:function(){return{layoutName:void 0,layouts:Object.create(null)}},watch:{layoutName:function(e){this.layouts[e]||this.$set(this.layouts,e,(function(){return t(e)}))}},provide:function(){var t,e=this;return{$_routerLayout_notifyRouteUpdate:(t=Gt(Ft().mark((function t(r){return Ft().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Wt(r);case 2:e.layoutName=Dt(r.matched)||e.layoutName;case 3:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})}},mounted:function(){var t=this;return Gt(Ft().mark((function e(){return Ft().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.$router){e.next=4;break}return e.next=3,Wt(t.$route);case 3:t.layoutName=Dt(t.$route.matched)||t.layoutName;case 4:case"end":return e.stop()}}),e)})))()},beforeRouteEnter:function(t,e,r){return Gt(Ft().mark((function e(){return Ft().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Wt(t);case 2:r((function(e){e.layoutName=Dt(t.matched)||e.layoutName}));case 3:case"end":return e.stop()}}),e)})))()},beforeRouteUpdate:function(t,e,r){var n=this;return Gt(Ft().mark((function e(){return Ft().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Wt(t);case 2:n.layoutName=Dt(t.matched)||n.layoutName,r();case 4:case"end":return e.stop()}}),e)})))()},render:function(t){var e=this.layoutName&&this.layouts[this.layoutName];return e?t(e,{key:this.layoutName}):t()}})},t.initRouterOptions=at,Object.keys(i).forEach((function(e){"default"===e||t.hasOwnProperty(e)||Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}})})),Object.defineProperty(t,"__esModule",{value:!0})}));