mooho-base-admin-plus 0.1.33 → 0.1.36
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.
|
@@ -9,7 +9,7 @@ var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnP
|
|
|
9
9
|
* (c) 2022 Eduardo San Martin Morote
|
|
10
10
|
* @license MIT
|
|
11
11
|
*/const hasSymbol$1="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,PolySymbol=e=>hasSymbol$1?Symbol(e):"_vr_"+e,matchedRouteKey=PolySymbol("rvlm"),viewDepthKey=PolySymbol("rvd"),routerKey=PolySymbol("r"),routeLocationKey=PolySymbol("rl"),routerViewLocationKey=PolySymbol("rvl"),isBrowser="undefined"!=typeof window;function isESModule(e){return e.__esModule||hasSymbol$1&&"Module"===e[Symbol.toStringTag]}const assign$2=Object.assign;function applyToParams(e,t){const r={};for(const i in t){const a=t[i];r[i]=Array.isArray(a)?a.map(e):e(a)}return r}const noop$1=()=>{},TRAILING_SLASH_RE=/\/$/,removeTrailingSlash=e=>e.replace(TRAILING_SLASH_RE,"");function parseURL(e,t,r="/"){let i,a={},n="",o="";const s=t.indexOf("?"),l=t.indexOf("#",s>-1?s:0);return s>-1&&(i=t.slice(0,s),n=t.slice(s+1,l>-1?l:t.length),a=e(n)),l>-1&&(i=i||t.slice(0,l),o=t.slice(l,t.length)),i=resolveRelativePath(null!=i?i:t,r),{fullPath:i+(n&&"?")+n+o,path:i,query:a,hash:o}}function stringifyURL(e,t){const r=t.query?e(t.query):"";return t.path+(r&&"?")+r+(t.hash||"")}function stripBase(e,t){return t&&e.toLowerCase().startsWith(t.toLowerCase())?e.slice(t.length)||"/":e}function isSameRouteLocation(e,t,r){const i=t.matched.length-1,a=r.matched.length-1;return i>-1&&i===a&&isSameRouteRecord(t.matched[i],r.matched[a])&&isSameRouteLocationParams(t.params,r.params)&&e(t.query)===e(r.query)&&t.hash===r.hash}function isSameRouteRecord(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function isSameRouteLocationParams(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(!isSameRouteLocationParamsValue(e[r],t[r]))return!1;return!0}function isSameRouteLocationParamsValue(e,t){return Array.isArray(e)?isEquivalentArray(e,t):Array.isArray(t)?isEquivalentArray(t,e):e===t}function isEquivalentArray(e,t){return Array.isArray(t)?e.length===t.length&&e.every(((e,r)=>e===t[r])):1===e.length&&e[0]===t}function resolveRelativePath(e,t){if(e.startsWith("/"))return e;if(!e)return t;const r=t.split("/"),i=e.split("/");let a,n,o=r.length-1;for(a=0;a<i.length;a++)if(n=i[a],1!==o&&"."!==n){if(".."!==n)break;o--}return r.slice(0,o).join("/")+"/"+i.slice(a-(a===i.length?1:0)).join("/")}var NavigationType,NavigationType2,NavigationDirection,NavigationDirection2;NavigationType2=NavigationType||(NavigationType={}),NavigationType2.pop="pop",NavigationType2.push="push",NavigationDirection2=NavigationDirection||(NavigationDirection={}),NavigationDirection2.back="back",NavigationDirection2.forward="forward",NavigationDirection2.unknown="";const START="";function normalizeBase(e){if(!e)if(isBrowser){const t=document.querySelector("base");e=(e=t&&t.getAttribute("href")||"/").replace(/^\w+:\/\/[^\/]+/,"")}else e="/";return"/"!==e[0]&&"#"!==e[0]&&(e="/"+e),removeTrailingSlash(e)}const BEFORE_HASH_RE=/^[^#]+#/;function createHref(e,t){return e.replace(BEFORE_HASH_RE,"#")+t}function getElementPosition(e,t){const r=document.documentElement.getBoundingClientRect(),i=e.getBoundingClientRect();return{behavior:t.behavior,left:i.left-r.left-(t.left||0),top:i.top-r.top-(t.top||0)}}const computeScrollPosition=()=>({left:window.pageXOffset,top:window.pageYOffset});function scrollToPosition(e){let t;if("el"in e){const r=e.el,i="string"==typeof r&&r.startsWith("#"),a="string"==typeof r?i?document.getElementById(r.slice(1)):document.querySelector(r):r;if(!a)return;t=getElementPosition(a,e)}else t=e;"scrollBehavior"in document.documentElement.style?window.scrollTo(t):window.scrollTo(null!=t.left?t.left:window.pageXOffset,null!=t.top?t.top:window.pageYOffset)}function getScrollKey(e,t){return(history.state?history.state.position-t:-1)+e}const scrollPositions=new Map;function saveScrollPosition(e,t){scrollPositions.set(e,t)}function getSavedScrollPosition(e){const t=scrollPositions.get(e);return scrollPositions.delete(e),t}let createBaseLocation=()=>location.protocol+"//"+location.host;function createCurrentLocation(e,t){const{pathname:r,search:i,hash:a}=t,n=e.indexOf("#");if(n>-1){let t=a.includes(e.slice(n))?e.slice(n).length:1,r=a.slice(t);return"/"!==r[0]&&(r="/"+r),stripBase(r,"")}return stripBase(r,e)+i+a}function useHistoryListeners(e,t,r,i){let a=[],n=[],o=null;const s=({state:n})=>{const s=createCurrentLocation(e,location),l=r.value,u=t.value;let c=0;if(n){if(r.value=s,t.value=n,o&&o===l)return void(o=null);c=u?n.position-u.position:0}else i(s);a.forEach((e=>{e(r.value,l,{delta:c,type:NavigationType.pop,direction:c?c>0?NavigationDirection.forward:NavigationDirection.back:NavigationDirection.unknown})}))};function l(){const{history:e}=window;e.state&&e.replaceState(assign$2({},e.state,{scroll:computeScrollPosition()}),"")}return window.addEventListener("popstate",s),window.addEventListener("beforeunload",l),{pauseListeners:function(){o=r.value},listen:function(e){a.push(e);const t=()=>{const t=a.indexOf(e);t>-1&&a.splice(t,1)};return n.push(t),t},destroy:function(){for(const e of n)e();n=[],window.removeEventListener("popstate",s),window.removeEventListener("beforeunload",l)}}}function buildState(e,t,r,i=!1,a=!1){return{back:e,current:t,forward:r,replaced:i,position:window.history.length,scroll:a?computeScrollPosition():null}}function useHistoryStateNavigation(e){const{history:t,location:r}=window,i={value:createCurrentLocation(e,r)},a={value:t.state};function n(i,n,o){const s=e.indexOf("#"),l=s>-1?(r.host&&document.querySelector("base")?e:e.slice(s))+i:createBaseLocation()+e+i;try{t[o?"replaceState":"pushState"](n,"",l),a.value=n}catch(u){console.error(u),r[o?"replace":"assign"](l)}}return a.value||n(i.value,{back:null,current:i.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0),{location:i,state:a,push:function(e,r){const o=assign$2({},a.value,t.state,{forward:e,scroll:computeScrollPosition()});n(o.current,o,!0),n(e,assign$2({},buildState(i.value,e,null),{position:o.position+1},r),!1),i.value=e},replace:function(e,r){n(e,assign$2({},t.state,buildState(a.value.back,e,a.value.forward,!0),r,{position:a.value.position}),!0),i.value=e}}}function createWebHistory(e){const t=useHistoryStateNavigation(e=normalizeBase(e)),r=useHistoryListeners(e,t.state,t.location,t.replace);const i=assign$2({location:"",base:e,go:function(e,t=!0){t||r.pauseListeners(),history.go(e)},createHref:createHref.bind(null,e)},t,r);return Object.defineProperty(i,"location",{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(i,"state",{enumerable:!0,get:()=>t.state.value}),i}function createMemoryHistory(e=""){let t=[],r=[START],i=0;function a(e){i++,i===r.length||r.splice(i),r.push(e)}e=normalizeBase(e);const n={location:START,state:{},base:e,createHref:createHref.bind(null,e),replace(e){r.splice(i--,1),a(e)},push(e,t){a(e)},listen:e=>(t.push(e),()=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)}),destroy(){t=[],r=[START],i=0},go(e,a=!0){const n=this.location,o=e<0?NavigationDirection.back:NavigationDirection.forward;i=Math.max(0,Math.min(i+e,r.length-1)),a&&function(e,r,{direction:i,delta:a}){const n={direction:i,delta:a,type:NavigationType.pop};for(const o of t)o(e,r,n)}(this.location,n,{direction:o,delta:e})}};return Object.defineProperty(n,"location",{enumerable:!0,get:()=>r[i]}),n}function createWebHashHistory(e){return(e=location.host?e||location.pathname+location.search:"").includes("#")||(e+="#"),createWebHistory(e)}function isRouteLocation(e){return"string"==typeof e||e&&"object"==typeof e}function isRouteName(e){return"string"==typeof e||"symbol"==typeof e}const START_LOCATION_NORMALIZED={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0},NavigationFailureSymbol=PolySymbol("nf");var NavigationFailureType,NavigationFailureType2;function createRouterError(e,t){return assign$2(new Error,{type:e,[NavigationFailureSymbol]:!0},t)}function isNavigationFailure(e,t){return e instanceof Error&&NavigationFailureSymbol in e&&(null==t||!!(e.type&t))}NavigationFailureType2=NavigationFailureType||(NavigationFailureType={}),NavigationFailureType2[NavigationFailureType2.aborted=4]="aborted",NavigationFailureType2[NavigationFailureType2.cancelled=8]="cancelled",NavigationFailureType2[NavigationFailureType2.duplicated=16]="duplicated";const BASE_PARAM_PATTERN="[^/]+?",BASE_PATH_PARSER_OPTIONS={sensitive:!1,strict:!1,start:!0,end:!0},REGEX_CHARS_RE=/[.+*?^${}()[\]/\\]/g;function tokensToParser(e,t){const r=assign$2({},BASE_PATH_PARSER_OPTIONS,t),i=[];let a=r.start?"^":"";const n=[];for(const l of e){const e=l.length?[]:[90];r.strict&&!l.length&&(a+="/");for(let t=0;t<l.length;t++){const i=l[t];let o=40+(r.sensitive?.25:0);if(0===i.type)t||(a+="/"),a+=i.value.replace(REGEX_CHARS_RE,"\\$&"),o+=40;else if(1===i.type){const{value:e,repeatable:r,optional:u,regexp:c}=i;n.push({name:e,repeatable:r,optional:u});const d=c||BASE_PARAM_PATTERN;if(d!==BASE_PARAM_PATTERN){o+=10;try{new RegExp(`(${d})`)}catch(s){throw new Error(`Invalid custom RegExp for param "${e}" (${d}): `+s.message)}}let p=r?`((?:${d})(?:/(?:${d}))*)`:`(${d})`;t||(p=u&&l.length<2?`(?:/${p})`:"/"+p),u&&(p+="?"),a+=p,o+=20,u&&(o+=-8),r&&(o+=-20),".*"===d&&(o+=-50)}e.push(o)}i.push(e)}if(r.strict&&r.end){const e=i.length-1;i[e][i[e].length-1]+=.7000000000000001}r.strict||(a+="/?"),r.end?a+="$":r.strict&&(a+="(?:/|$)");const o=new RegExp(a,r.sensitive?"":"i");return{re:o,score:i,keys:n,parse:function(e){const t=e.match(o),r={};if(!t)return null;for(let i=1;i<t.length;i++){const e=t[i]||"",a=n[i-1];r[a.name]=e&&a.repeatable?e.split("/"):e}return r},stringify:function(t){let r="",i=!1;for(const a of e){i&&r.endsWith("/")||(r+="/"),i=!1;for(const n of a)if(0===n.type)r+=n.value;else if(1===n.type){const{value:o,repeatable:s,optional:l}=n,u=o in t?t[o]:"";if(Array.isArray(u)&&!s)throw new Error(`Provided param "${o}" is an array but it is not repeatable (* or + modifiers)`);const c=Array.isArray(u)?u.join("/"):u;if(!c){if(!l)throw new Error(`Missing required param "${o}"`);a.length<2&&e.length>1&&(r.endsWith("/")?r=r.slice(0,-1):i=!0)}r+=c}}return r}}}function compareScoreArray(e,t){let r=0;for(;r<e.length&&r<t.length;){const i=t[r]-e[r];if(i)return i;r++}return e.length<t.length?1===e.length&&80===e[0]?-1:1:e.length>t.length?1===t.length&&80===t[0]?1:-1:0}function comparePathParserScore(e,t){let r=0;const i=e.score,a=t.score;for(;r<i.length&&r<a.length;){const e=compareScoreArray(i[r],a[r]);if(e)return e;r++}return a.length-i.length}const ROOT_TOKEN={type:0,value:""},VALID_PARAM_RE=/[a-zA-Z0-9_]/;function tokenizePath(e){if(!e)return[[]];if("/"===e)return[[ROOT_TOKEN]];if(!e.startsWith("/"))throw new Error(`Invalid path "${e}"`);function t(e){throw new Error(`ERR (${r})/"${u}": ${e}`)}let r=0,i=r;const a=[];let n;function o(){n&&a.push(n),n=[]}let s,l=0,u="",c="";function d(){u&&(0===r?n.push({type:0,value:u}):1===r||2===r||3===r?(n.length>1&&("*"===s||"+"===s)&&t(`A repeatable param (${u}) must be alone in its segment. eg: '/:ids+.`),n.push({type:1,value:u,regexp:c,repeatable:"*"===s||"+"===s,optional:"*"===s||"?"===s})):t("Invalid state to consume buffer"),u="")}function p(){u+=s}for(;l<e.length;)if(s=e[l++],"\\"!==s||2===r)switch(r){case 0:"/"===s?(u&&d(),o()):":"===s?(d(),r=1):p();break;case 4:p(),r=i;break;case 1:"("===s?r=2:VALID_PARAM_RE.test(s)?p():(d(),r=0,"*"!==s&&"?"!==s&&"+"!==s&&l--);break;case 2:")"===s?"\\"==c[c.length-1]?c=c.slice(0,-1)+s:r=3:c+=s;break;case 3:d(),r=0,"*"!==s&&"?"!==s&&"+"!==s&&l--,c="";break;default:t("Unknown state")}else i=r,r=4;return 2===r&&t(`Unfinished custom RegExp for param "${u}"`),d(),o(),a}function createRouteRecordMatcher(e,t,r){const i=tokensToParser(tokenizePath(e.path),r),a=assign$2(i,{record:e,parent:t,children:[],alias:[]});return t&&!a.record.aliasOf==!t.record.aliasOf&&t.children.push(a),a}function createRouterMatcher(e,t){const r=[],i=new Map;function a(e,r,i){const s=!i,l=normalizeRouteRecord(e);l.aliasOf=i&&i.record;const u=mergeOptions(t,e),c=[l];if("alias"in e){const t="string"==typeof e.alias?[e.alias]:e.alias;for(const e of t)c.push(assign$2({},l,{components:i?i.record.components:l.components,path:e,aliasOf:i?i.record:l}))}let d,p;for(const t of c){const{path:c}=t;if(r&&"/"!==c[0]){const e=r.record.path,i="/"===e[e.length-1]?"":"/";t.path=r.record.path+(c&&i+c)}if(d=createRouteRecordMatcher(t,r,u),i?i.alias.push(d):(p=p||d,p!==d&&p.alias.push(d),s&&e.name&&!isAliasRecord(d)&&n(e.name)),"children"in l){const e=l.children;for(let t=0;t<e.length;t++)a(e[t],d,i&&i.children[t])}i=i||d,o(d)}return p?()=>{n(p)}:noop$1}function n(e){if(isRouteName(e)){const t=i.get(e);t&&(i.delete(e),r.splice(r.indexOf(t),1),t.children.forEach(n),t.alias.forEach(n))}else{const t=r.indexOf(e);t>-1&&(r.splice(t,1),e.record.name&&i.delete(e.record.name),e.children.forEach(n),e.alias.forEach(n))}}function o(e){let t=0;for(;t<r.length&&comparePathParserScore(e,r[t])>=0&&(e.record.path!==r[t].record.path||!isRecordChildOf(e,r[t]));)t++;r.splice(t,0,e),e.record.name&&!isAliasRecord(e)&&i.set(e.record.name,e)}return t=mergeOptions({strict:!1,end:!0,sensitive:!1},t),e.forEach((e=>a(e))),{addRoute:a,resolve:function(e,t){let a,n,o,s={};if("name"in e&&e.name){if(a=i.get(e.name),!a)throw createRouterError(1,{location:e});o=a.record.name,s=assign$2(paramsFromLocation(t.params,a.keys.filter((e=>!e.optional)).map((e=>e.name))),e.params),n=a.stringify(s)}else if("path"in e)n=e.path,a=r.find((e=>e.re.test(n))),a&&(s=a.parse(n),o=a.record.name);else{if(a=t.name?i.get(t.name):r.find((e=>e.re.test(t.path))),!a)throw createRouterError(1,{location:e,currentLocation:t});o=a.record.name,s=assign$2({},t.params,e.params),n=a.stringify(s)}const l=[];let u=a;for(;u;)l.unshift(u.record),u=u.parent;return{name:o,path:n,params:s,matched:l,meta:mergeMetaFields(l)}},removeRoute:n,getRoutes:function(){return r},getRecordMatcher:function(e){return i.get(e)}}}function paramsFromLocation(e,t){const r={};for(const i of t)i in e&&(r[i]=e[i]);return r}function normalizeRouteRecord(e){return{path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:void 0,beforeEnter:e.beforeEnter,props:normalizeRecordProps(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in e?e.components||{}:{default:e.component}}}function normalizeRecordProps(e){const t={},r=e.props||!1;if("component"in e)t.default=r;else for(const i in e.components)t[i]="boolean"==typeof r?r:r[i];return t}function isAliasRecord(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function mergeMetaFields(e){return e.reduce(((e,t)=>assign$2(e,t.meta)),{})}function mergeOptions(e,t){const r={};for(const i in e)r[i]=i in t?t[i]:e[i];return r}function isRecordChildOf(e,t){return t.children.some((t=>t===e||isRecordChildOf(e,t)))}const HASH_RE=/#/g,AMPERSAND_RE=/&/g,SLASH_RE=/\//g,EQUAL_RE=/=/g,IM_RE=/\?/g,PLUS_RE=/\+/g,ENC_BRACKET_OPEN_RE=/%5B/g,ENC_BRACKET_CLOSE_RE=/%5D/g,ENC_CARET_RE=/%5E/g,ENC_BACKTICK_RE=/%60/g,ENC_CURLY_OPEN_RE=/%7B/g,ENC_PIPE_RE=/%7C/g,ENC_CURLY_CLOSE_RE=/%7D/g,ENC_SPACE_RE=/%20/g;function commonEncode(e){return encodeURI(""+e).replace(ENC_PIPE_RE,"|").replace(ENC_BRACKET_OPEN_RE,"[").replace(ENC_BRACKET_CLOSE_RE,"]")}function encodeHash(e){return commonEncode(e).replace(ENC_CURLY_OPEN_RE,"{").replace(ENC_CURLY_CLOSE_RE,"}").replace(ENC_CARET_RE,"^")}function encodeQueryValue(e){return commonEncode(e).replace(PLUS_RE,"%2B").replace(ENC_SPACE_RE,"+").replace(HASH_RE,"%23").replace(AMPERSAND_RE,"%26").replace(ENC_BACKTICK_RE,"`").replace(ENC_CURLY_OPEN_RE,"{").replace(ENC_CURLY_CLOSE_RE,"}").replace(ENC_CARET_RE,"^")}function encodeQueryKey(e){return encodeQueryValue(e).replace(EQUAL_RE,"%3D")}function encodePath(e){return commonEncode(e).replace(HASH_RE,"%23").replace(IM_RE,"%3F")}function encodeParam(e){return null==e?"":encodePath(e).replace(SLASH_RE,"%2F")}function decode$1(e){try{return decodeURIComponent(""+e)}catch(t){}return""+e}function parseQuery(e){const t={};if(""===e||"?"===e)return t;const r=("?"===e[0]?e.slice(1):e).split("&");for(let i=0;i<r.length;++i){const e=r[i].replace(PLUS_RE," "),a=e.indexOf("="),n=decode$1(a<0?e:e.slice(0,a)),o=a<0?null:decode$1(e.slice(a+1));if(n in t){let e=t[n];Array.isArray(e)||(e=t[n]=[e]),e.push(o)}else t[n]=o}return t}function stringifyQuery(e){let t="";for(let r in e){const i=e[r];if(r=encodeQueryKey(r),null==i){void 0!==i&&(t+=(t.length?"&":"")+r);continue}(Array.isArray(i)?i.map((e=>e&&encodeQueryValue(e))):[i&&encodeQueryValue(i)]).forEach((e=>{void 0!==e&&(t+=(t.length?"&":"")+r,null!=e&&(t+="="+e))}))}return t}function normalizeQuery(e){const t={};for(const r in e){const i=e[r];void 0!==i&&(t[r]=Array.isArray(i)?i.map((e=>null==e?null:""+e)):null==i?i:""+i)}return t}function useCallbacks(){let e=[];return{add:function(t){return e.push(t),()=>{const r=e.indexOf(t);r>-1&&e.splice(r,1)}},list:()=>e,reset:function(){e=[]}}}function guardToPromiseFn(e,t,r,i,a){const n=i&&(i.enterCallbacks[a]=i.enterCallbacks[a]||[]);return()=>new Promise(((o,s)=>{const l=e=>{!1===e?s(createRouterError(4,{from:r,to:t})):e instanceof Error?s(e):isRouteLocation(e)?s(createRouterError(2,{from:t,to:e})):(n&&i.enterCallbacks[a]===n&&"function"==typeof e&&n.push(e),o())},u=e.call(i&&i.instances[a],t,r,l);let c=Promise.resolve(u);e.length<3&&(c=c.then(l)),c.catch((e=>s(e)))}))}function extractComponentsGuards(e,t,r,i){const a=[];for(const n of e)for(const e in n.components){let o=n.components[e];if("beforeRouteEnter"===t||n.instances[e])if(isRouteComponent(o)){const s=(o.__vccOpts||o)[t];s&&a.push(guardToPromiseFn(s,r,i,n,e))}else{let s=o();a.push((()=>s.then((a=>{if(!a)return Promise.reject(new Error(`Couldn't resolve component "${e}" at "${n.path}"`));const o=isESModule(a)?a.default:a;n.components[e]=o;const s=(o.__vccOpts||o)[t];return s&&guardToPromiseFn(s,r,i,n,e)()}))))}}return a}function isRouteComponent(e){return"object"==typeof e||"displayName"in e||"props"in e||"__vccOpts"in e}function useLink(e){const t=require$$0$1.inject(routerKey),r=require$$0$1.inject(routeLocationKey),i=require$$0$1.computed((()=>t.resolve(require$$0$1.unref(e.to)))),a=require$$0$1.computed((()=>{const{matched:e}=i.value,{length:t}=e,a=e[t-1],n=r.matched;if(!a||!n.length)return-1;const o=n.findIndex(isSameRouteRecord.bind(null,a));if(o>-1)return o;const s=getOriginalPath(e[t-2]);return t>1&&getOriginalPath(a)===s&&n[n.length-1].path!==s?n.findIndex(isSameRouteRecord.bind(null,e[t-2])):o})),n=require$$0$1.computed((()=>a.value>-1&&includesParams(r.params,i.value.params))),o=require$$0$1.computed((()=>a.value>-1&&a.value===r.matched.length-1&&isSameRouteLocationParams(r.params,i.value.params)));return{route:i,href:require$$0$1.computed((()=>i.value.href)),isActive:n,isExactActive:o,navigate:function(r={}){return guardEvent(r)?t[require$$0$1.unref(e.replace)?"replace":"push"](require$$0$1.unref(e.to)).catch(noop$1):Promise.resolve()}}}const RouterLinkImpl=require$$0$1.defineComponent({name:"RouterLink",props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:useLink,setup(e,{slots:t}){const r=require$$0$1.reactive(useLink(e)),{options:i}=require$$0$1.inject(routerKey),a=require$$0$1.computed((()=>({[getLinkClass(e.activeClass,i.linkActiveClass,"router-link-active")]:r.isActive,[getLinkClass(e.exactActiveClass,i.linkExactActiveClass,"router-link-exact-active")]:r.isExactActive})));return()=>{const i=t.default&&t.default(r);return e.custom?i:require$$0$1.h("a",{"aria-current":r.isExactActive?e.ariaCurrentValue:null,href:r.href,onClick:r.navigate,class:a.value},i)}}}),RouterLink=RouterLinkImpl;function guardEvent(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||e.defaultPrevented||void 0!==e.button&&0!==e.button)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function includesParams(e,t){for(const r in t){const i=t[r],a=e[r];if("string"==typeof i){if(i!==a)return!1}else if(!Array.isArray(a)||a.length!==i.length||i.some(((e,t)=>e!==a[t])))return!1}return!0}function getOriginalPath(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const getLinkClass=(e,t,r)=>null!=e?e:null!=t?t:r,RouterViewImpl=require$$0$1.defineComponent({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(e,{attrs:t,slots:r}){const i=require$$0$1.inject(routerViewLocationKey),a=require$$0$1.computed((()=>e.route||i.value)),n=require$$0$1.inject(viewDepthKey,0),o=require$$0$1.computed((()=>a.value.matched[n]));require$$0$1.provide(viewDepthKey,n+1),require$$0$1.provide(matchedRouteKey,o),require$$0$1.provide(routerViewLocationKey,a);const s=require$$0$1.ref();return require$$0$1.watch((()=>[s.value,o.value,e.name]),(([e,t,r],[i,a,n])=>{t&&(t.instances[r]=e,a&&a!==t&&e&&e===i&&(t.leaveGuards.size||(t.leaveGuards=a.leaveGuards),t.updateGuards.size||(t.updateGuards=a.updateGuards))),!e||!t||a&&isSameRouteRecord(t,a)&&i||(t.enterCallbacks[r]||[]).forEach((t=>t(e)))}),{flush:"post"}),()=>{const i=a.value,n=o.value,l=n&&n.components[e.name],u=e.name;if(!l)return normalizeSlot(r.default,{Component:l,route:i});const c=n.props[e.name],d=c?!0===c?i.params:"function"==typeof c?c(i):c:null,p=require$$0$1.h(l,assign$2({},d,t,{onVnodeUnmounted:e=>{e.component.isUnmounted&&(n.instances[u]=null)},ref:s}));return normalizeSlot(r.default,{Component:p,route:i})||p}}});function normalizeSlot(e,t){if(!e)return null;const r=e(t);return 1===r.length?r[0]:r}const RouterView=RouterViewImpl;function createRouter(e){const t=createRouterMatcher(e.routes,e),r=e.parseQuery||parseQuery,i=e.stringifyQuery||stringifyQuery,a=e.history,n=useCallbacks(),o=useCallbacks(),s=useCallbacks(),l=require$$0$1.shallowRef(START_LOCATION_NORMALIZED);let u=START_LOCATION_NORMALIZED;isBrowser&&e.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const c=applyToParams.bind(null,(e=>""+e)),d=applyToParams.bind(null,encodeParam),p=applyToParams.bind(null,decode$1);function h(e,n){if(n=assign$2({},n||l.value),"string"==typeof e){const i=parseURL(r,e,n.path),o=t.resolve({path:i.path},n),s=a.createHref(i.fullPath);return assign$2(i,o,{params:p(o.params),hash:decode$1(i.hash),redirectedFrom:void 0,href:s})}let o;if("path"in e)o=assign$2({},e,{path:parseURL(r,e.path,n.path).path});else{const t=assign$2({},e.params);for(const e in t)null==t[e]&&delete t[e];o=assign$2({},e,{params:d(e.params)}),n.params=d(n.params)}const s=t.resolve(o,n),u=e.hash||"";s.params=c(p(s.params));const h=stringifyURL(i,assign$2({},e,{hash:encodeHash(u),path:s.path})),m=a.createHref(h);return assign$2({fullPath:h,hash:u,query:i===stringifyQuery?normalizeQuery(e.query):e.query||{}},s,{redirectedFrom:void 0,href:m})}function m(e){return"string"==typeof e?parseURL(r,e,l.value.path):assign$2({},e)}function f(e,t){if(u!==e)return createRouterError(8,{from:t,to:e})}function g(e){return y(e)}function $(e){const t=e.matched[e.matched.length-1];if(t&&t.redirect){const{redirect:r}=t;let i="function"==typeof r?r(e):r;return"string"==typeof i&&(i=i.includes("?")||i.includes("#")?i=m(i):{path:i},i.params={}),assign$2({query:e.query,hash:e.hash,params:e.params},i)}}function y(e,t){const r=u=h(e),a=l.value,n=e.state,o=e.force,s=!0===e.replace,c=$(r);if(c)return y(assign$2(m(c),{state:n,force:o,replace:s}),t||r);const d=r;let p;return d.redirectedFrom=t,!o&&isSameRouteLocation(i,a,r)&&(p=createRouterError(16,{to:d,from:a}),D(a,a,!0,!1)),(p?Promise.resolve(p):_(d,a)).catch((e=>isNavigationFailure(e)?isNavigationFailure(e,2)?e:A(e):I(e,d,a))).then((e=>{if(e){if(isNavigationFailure(e,2))return y(assign$2(m(e.to),{state:n,force:o,replace:s}),t||d)}else e=S(d,a,!0,s,n);return x(d,a,e),e}))}function v(e,t){const r=f(e,t);return r?Promise.reject(r):Promise.resolve()}function _(e,t){let r;const[i,a,s]=extractChangingRecords(e,t);r=extractComponentsGuards(i.reverse(),"beforeRouteLeave",e,t);for(const n of i)n.leaveGuards.forEach((i=>{r.push(guardToPromiseFn(i,e,t))}));const l=v.bind(null,e,t);return r.push(l),runGuardQueue(r).then((()=>{r=[];for(const i of n.list())r.push(guardToPromiseFn(i,e,t));return r.push(l),runGuardQueue(r)})).then((()=>{r=extractComponentsGuards(a,"beforeRouteUpdate",e,t);for(const i of a)i.updateGuards.forEach((i=>{r.push(guardToPromiseFn(i,e,t))}));return r.push(l),runGuardQueue(r)})).then((()=>{r=[];for(const i of e.matched)if(i.beforeEnter&&!t.matched.includes(i))if(Array.isArray(i.beforeEnter))for(const a of i.beforeEnter)r.push(guardToPromiseFn(a,e,t));else r.push(guardToPromiseFn(i.beforeEnter,e,t));return r.push(l),runGuardQueue(r)})).then((()=>(e.matched.forEach((e=>e.enterCallbacks={})),r=extractComponentsGuards(s,"beforeRouteEnter",e,t),r.push(l),runGuardQueue(r)))).then((()=>{r=[];for(const i of o.list())r.push(guardToPromiseFn(i,e,t));return r.push(l),runGuardQueue(r)})).catch((e=>isNavigationFailure(e,8)?e:Promise.reject(e)))}function x(e,t,r){for(const i of s.list())i(e,t,r)}function S(e,t,r,i,n){const o=f(e,t);if(o)return o;const s=t===START_LOCATION_NORMALIZED,u=isBrowser?history.state:{};r&&(i||s?a.replace(e.fullPath,assign$2({scroll:s&&u&&u.scroll},n)):a.push(e.fullPath,n)),l.value=e,D(e,t,r,s),A()}let C;let b,w=useCallbacks(),T=useCallbacks();function I(e,t,r){A(e);const i=T.list();return i.length?i.forEach((i=>i(e,t,r))):console.error(e),Promise.reject(e)}function A(e){return b||(b=!e,C||(C=a.listen(((e,t,r)=>{const i=h(e),n=$(i);if(n)return void y(assign$2(n,{replace:!0}),i).catch(noop$1);u=i;const o=l.value;isBrowser&&saveScrollPosition(getScrollKey(o.fullPath,r.delta),computeScrollPosition()),_(i,o).catch((e=>isNavigationFailure(e,12)?e:isNavigationFailure(e,2)?(y(e.to,i).then((e=>{isNavigationFailure(e,20)&&!r.delta&&r.type===NavigationType.pop&&a.go(-1,!1)})).catch(noop$1),Promise.reject()):(r.delta&&a.go(-r.delta,!1),I(e,i,o)))).then((e=>{(e=e||S(i,o,!1))&&(r.delta?a.go(-r.delta,!1):r.type===NavigationType.pop&&isNavigationFailure(e,20)&&a.go(-1,!1)),x(i,o,e)})).catch(noop$1)}))),w.list().forEach((([t,r])=>e?r(e):t())),w.reset()),e}function D(t,r,i,a){const{scrollBehavior:n}=e;if(!isBrowser||!n)return Promise.resolve();const o=!i&&getSavedScrollPosition(getScrollKey(t.fullPath,0))||(a||!i)&&history.state&&history.state.scroll||null;return require$$0$1.nextTick().then((()=>n(t,r,o))).then((e=>e&&scrollToPosition(e))).catch((e=>I(e,t,r)))}const E=e=>a.go(e);let M;const k=new Set;return{currentRoute:l,addRoute:function(e,r){let i,a;return isRouteName(e)?(i=t.getRecordMatcher(e),a=r):a=e,t.addRoute(a,i)},removeRoute:function(e){const r=t.getRecordMatcher(e);r&&t.removeRoute(r)},hasRoute:function(e){return!!t.getRecordMatcher(e)},getRoutes:function(){return t.getRoutes().map((e=>e.record))},resolve:h,options:e,push:g,replace:function(e){return g(assign$2(m(e),{replace:!0}))},go:E,back:()=>E(-1),forward:()=>E(1),beforeEach:n.add,beforeResolve:o.add,afterEach:s.add,onError:T.add,isReady:function(){return b&&l.value!==START_LOCATION_NORMALIZED?Promise.resolve():new Promise(((e,t)=>{w.add([e,t])}))},install(e){e.component("RouterLink",RouterLink),e.component("RouterView",RouterView),e.config.globalProperties.$router=this,Object.defineProperty(e.config.globalProperties,"$route",{enumerable:!0,get:()=>require$$0$1.unref(l)}),isBrowser&&!M&&l.value===START_LOCATION_NORMALIZED&&(M=!0,g(a.location).catch((e=>{})));const t={};for(const i in START_LOCATION_NORMALIZED)t[i]=require$$0$1.computed((()=>l.value[i]));e.provide(routerKey,this),e.provide(routeLocationKey,require$$0$1.reactive(t)),e.provide(routerViewLocationKey,l);const r=e.unmount;k.add(e),e.unmount=function(){k.delete(e),k.size<1&&(u=START_LOCATION_NORMALIZED,C&&C(),C=null,l.value=START_LOCATION_NORMALIZED,M=!1,b=!1),r()}}}}function runGuardQueue(e){return e.reduce(((e,t)=>e.then((()=>t()))),Promise.resolve())}function extractChangingRecords(e,t){const r=[],i=[],a=[],n=Math.max(t.matched.length,e.matched.length);for(let o=0;o<n;o++){const n=t.matched[o];n&&(e.matched.find((e=>isSameRouteRecord(e,n)))?i.push(n):r.push(n));const s=e.matched[o];s&&(t.matched.find((e=>isSameRouteRecord(e,s)))||a.push(s))}return[r,i,a]}
|
|
12
|
-
/*! js-cookie v3.0.1 | MIT */function assign$1(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)e[i]=r[i]}return e}var defaultConverter={read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function init$4(e,t){function r(r,i,a){if("undefined"!=typeof document){"number"==typeof(a=assign$1({},t,a)).expires&&(a.expires=new Date(Date.now()+864e5*a.expires)),a.expires&&(a.expires=a.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var n="";for(var o in a)a[o]&&(n+="; "+o,!0!==a[o]&&(n+="="+a[o].split(";")[0]));return document.cookie=r+"="+e.write(i,r)+n}}return Object.create({set:r,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var r=document.cookie?document.cookie.split("; "):[],i={},a=0;a<r.length;a++){var n=r[a].split("="),o=n.slice(1).join("=");try{var s=decodeURIComponent(n[0]);if(i[s]=e.read(o,s),t===s)break}catch(l){}}return t?i[t]:i}},remove:function(e,t){r(e,"",assign$1({},t,{expires:-1}))},withAttributes:function(e){return init$4(this.converter,assign$1({},this.attributes,e))},withConverter:function(e){return init$4(assign$1({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var api=init$4(defaultConverter,{path:"/"});const env$2=
|
|
12
|
+
/*! js-cookie v3.0.1 | MIT */function assign$1(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)e[i]=r[i]}return e}var defaultConverter={read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function init$4(e,t){function r(r,i,a){if("undefined"!=typeof document){"number"==typeof(a=assign$1({},t,a)).expires&&(a.expires=new Date(Date.now()+864e5*a.expires)),a.expires&&(a.expires=a.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var n="";for(var o in a)a[o]&&(n+="; "+o,!0!==a[o]&&(n+="="+a[o].split(";")[0]));return document.cookie=r+"="+e.write(i,r)+n}}return Object.create({set:r,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var r=document.cookie?document.cookie.split("; "):[],i={},a=0;a<r.length;a++){var n=r[a].split("="),o=n.slice(1).join("=");try{var s=decodeURIComponent(n[0]);if(i[s]=e.read(o,s),t===s)break}catch(l){}}return t?i[t]:i}},remove:function(e,t){r(e,"",assign$1({},t,{expires:-1}))},withAttributes:function(e){return init$4(this.converter,assign$1({},this.attributes,e))},withConverter:function(e){return init$4(assign$1({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(e)}})}var api=init$4(defaultConverter,{path:"/"});const env$2="production",Setting={info:{},appID:"app",rootPath:"/static/",titleSuffix:"Admin Plus",routerMode:"history",showProgressBar:!0,cookiesExpires:1,i18n:{default:"zh-CN",auto:!1,refresh:!1,list:[{locale:"zh-CN",language:"简体中文"},{locale:"en-US",language:"English"}],remote:!1},menuSideWidth:256,headerHeight:64,menuSideCollapseWidth:80,layout:{siderTheme:"dark",headerTheme:"light",headerStick:!1,tabs:!1,showTabsIcon:!0,tabsFix:!0,tabsReload:!1,tabsOrder:!0,siderFix:!0,headerFix:!0,headerHide:!1,headerMenu:!1,menuAccordion:!0,showSiderCollapse:!0,menuCollapse:!1,menuSiderReload:!1,menuHeaderReload:!1,showCollapseMenuTitle:!1,showReload:!1,showSearch:!1,showNotice:!1,showFullscreen:!0,showMobileLogo:!0,showBreadcrumb:!0,showBreadcrumbIcon:!1,showLog:"development"===env$2,showI18n:!1,enableSetting:"development"===env$2,logoutConfirm:!0,autoFixRatio:!0,maskClosable:!0,draggable:!0},page:{opened:[],loadOpenedTabs:!0},waterMark:{show:!0,text:"MOOHO",options:{}},sameRouteForceUpdate:!1},copyTo=(e,t)=>{for(let r in e)"object"==typeof e[r]?(null==t[r]&&(t[r]={}),copyTo(e[r],t[r])):t[r]=e[r]};let localSetting=window.setting;localSetting&©To(localSetting,Setting),console.log('{"VITE_APP_BASE_PATH":"","BASE_URL":"/","MODE":"production","DEV":false,"PROD":true}',{VITE_APP_BASE_PATH:"",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0}),Setting.apiBaseURL=Setting.apiBaseURL.prd,console.log("Setting.apiBaseURL",Setting.apiBaseURL,"production");const cookies$2={set:function(e="default",t="",r={}){let i={};0!==Setting.cookiesExpires&&(i.expires=Setting.cookiesExpires),Object.assign(i,r),api.set(`admin-plus-${Setting.appID}-${e}`,t,i)},get:function(e="default"){return api.get(`admin-plus-${Setting.appID}-${e}`)},getAll:function(){return api.get()},remove:function(e="default"){return api.remove(`admin-plus-${Setting.appID}-${e}`)}},log$2={};function typeColor(e="default"){let t="";switch(e){case"default":t="#515a6e";break;case"primary":t="#2d8cf0";break;case"success":t="#19be6b";break;case"warning":t="#ff9900";break;case"error":t="#ed4014"}return t}log$2.capsule=function(e,t,r="primary"){console.log(`%c ${e} %c ${t} %c`,"background:#35495E; padding: 1px; border-radius: 3px 0 0 3px; color: #fff;",`background:${typeColor(r)}; padding: 1px; border-radius: 0 3px 3px 0; color: #fff;`,"background:transparent")},log$2.colorful=function(e){console.log(`%c${e.map((e=>e.text||"")).join("%c")}`,...e.map((e=>`color: ${typeColor(e.type)};`)))},log$2.default=function(e){log$2.colorful([{text:e}])},log$2.primary=function(e){log$2.colorful([{text:e,type:"primary"}])},log$2.success=function(e){log$2.colorful([{text:e,type:"success"}])},log$2.warning=function(e){log$2.colorful([{text:e,type:"warning"}])},log$2.error=function(e){log$2.colorful([{text:e,type:"error"}])};var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function getAugmentedNamespace(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})})),t}var lodash$1={exports:{}},module2,exports2;
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
15
15
|
* Lodash <https://lodash.com/>
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
// 只在开发模式下打印 log
|
|
19
|
-
if (
|
|
19
|
+
if (import.meta.env.MODE === 'development') {
|
|
20
20
|
util.log.capsule('Admin Plus', 'ErrorHandler', 'error');
|
|
21
21
|
util.log.error('>>>>>> 错误信息 >>>>>>');
|
|
22
22
|
console.log(info);
|
package/src/setting.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Admin Plus 业务配置
|
|
3
3
|
* */
|
|
4
4
|
|
|
5
|
-
const env = import.meta.env.
|
|
5
|
+
const env = import.meta.env.MODE;
|
|
6
6
|
const basePath = import.meta.env.VITE_APP_BASE_PATH;
|
|
7
7
|
|
|
8
8
|
const Setting = {
|
|
@@ -192,15 +192,15 @@ const copyTo = (source, target) => {
|
|
|
192
192
|
|
|
193
193
|
let localSetting = window.setting;
|
|
194
194
|
|
|
195
|
-
console.log('localSetting', localSetting);
|
|
196
|
-
|
|
197
195
|
if (localSetting) {
|
|
198
196
|
copyTo(localSetting, Setting);
|
|
199
197
|
}
|
|
200
198
|
|
|
199
|
+
console.log('import.meta.env', import.meta.env);
|
|
200
|
+
|
|
201
201
|
// API地址
|
|
202
|
-
Setting.apiBaseURL =
|
|
202
|
+
Setting.apiBaseURL = import.meta.env.MODE === 'development' ? Setting.apiBaseURL.dev : Setting.apiBaseURL.prd;
|
|
203
203
|
|
|
204
|
-
console.log('Setting.apiBaseURL', Setting.apiBaseURL,
|
|
204
|
+
console.log('Setting.apiBaseURL', Setting.apiBaseURL, import.meta.env.MODE);
|
|
205
205
|
|
|
206
206
|
export default Setting;
|