@vtj/renderer 0.14.3 → 0.14.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.cjs +3 -3
- package/dist/index.mjs +54 -54
- package/package.json +5 -5
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Copyright (c) 2026, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/renderer
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.14.
|
|
5
|
+
* @version 0.14.5
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const k="0.14.
|
|
7
|
+
*/const k="0.14.5";var S=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(S||{});const te=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],st=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],_e=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"],Se={String,Number,Boolean,Array,Object,Function,Date},F="VtjPage",L="VtjHomepage",we="html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot,svg".split(","),Ee="component,slot".split(","),nt=["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o"].join(""),rt={auth:["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o","/","a","u","t","h",".","h","t","m","l"].join(""),storageKey:["R","R","O","_","I","D","E","_","A","C","C","E","S","S","_","S","T","O","R","A","G","E","_","_"].join(""),privateKey:"MIIBOgIBAAJBAKoIzmn1FYQ1YOhOBw9EhABxZ+PySAIaydI+zdhoKflrdgJ4A5E4/5gbQmRpk09hPWG8nvX7h+l/QLU8kXxAIBECAwEAAQJAAlgpxQY6sByLsXqzJcthC8LSGsLf2JEJkHwlnpwFqlEV8UCkoINpuZ2Wzl+aftURu5rIfAzRCQBvHmeOTW9/zQIhAO5ufWDmnSLyfAAsNo5JRNpVuLFCFodR8Xm+ulDlosR/AiEAtpAltyP9wmCABKG/v/hrtTr3mcvFNGCjoGa9bUAok28CIHbrVs9w1ijrBlvTsXYwJw46uP539uKRRT4ymZzlm9QjAiB+1KH/G9f9pEEL9rtaSOG7JF5D0JcOjlze4MGVFs+ZrQIhALKOUFBNr2zEsyJIjw2PlvEucdlG77UniszjXTROHSPd"};function H(n,e){return n.map(t=>f.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function U(n){return/\.css$/.test(n)}function B(n){return/\.js$/.test(n)}function $e(n){return/\.json$/.test(n)}function ot(n){return n.map(e=>`<script src="${f.url.append(e,{v:k})}"><\/script>`).join("")}function it(n=[]){return n.map(e=>`<link rel="stylesheet" href="${f.url.append(e,{v:k})}" />`).join("")}function be(n,e=!1){return e&&n.endsWith(".prod.js")?n.replace(".prod.js",".js"):n}function je(n,e,t=!1){const s=n.filter(d=>!!d.enabled),r=[],o=[],a=[],i=[],l={},c={},p=[],u={};return s.forEach(({urls:d,assetsUrl:m,library:h,assetsLibrary:g,localeLibrary:v})=>{d?.forEach(y=>{B(y)&&r.push(be(y,t)),U(y)&&o.push(y)}),h&&(i.push(h),l[h]=H(d||[],e),v&&(c[h]=v)),m&&a.push(m),g&&p.push(g),h&&g&&(u[g]=h)}),{scripts:H(r,e),css:H(o,e),materials:H(a,e),libraryExports:i,materialExports:f.dedupArray(p),materialMapLibrary:u,libraryMap:l,libraryLocaleMap:c}}function Re(n,e){const{name:t,parent:s,alias:r}=n;return s?e[s]?.[r||t]:e[r||t]}function Ce(n=[]){const e=n.filter(s=>U(s)),t=n.filter(s=>B(s));return{css:e,js:t}}function Pe(n,e){const t=c=>{const p=[];let u=0;for(;u<c.length;){if(/\s/.test(c[u])){u++;continue}if(c.substring(u,u+2)==="/*"){const y=c.indexOf("*/",u+2);if(y!==-1){u=y+2;continue}}if(c[u]==="@"){const y=u;for(;u<c.length&&c[u]!=="{"&&c[u]!==";";)u++;const w=c.substring(y,u).trim(),_=w.includes("@keyframes");if(c[u]===";")p.push({type:"simple-at-rule",content:c.substring(y,u+1)}),u++;else if(c[u]==="{"){const E=u+1;let A=1;for(u++;u<c.length&&A>0;)c[u]==="{"?A++:c[u]==="}"&&A--,u++;const Q=c.substring(y,u),I=c.substring(E,u-1);p.push({type:_?"keyframes":"at-rule",rule:w,content:Q,inner:I})}continue}const d=u;for(;u<c.length&&c[u]!=="{";)u++;if(u>=c.length)break;const m=c.substring(d,u).trim();if(!m){u++;continue}const h=u+1;let g=1;for(u++;u<c.length&&g>0;)c[u]==="{"?g++:c[u]==="}"&&g--,u++;const v=c.substring(h,u-1);p.push({type:"rule",selector:m,content:v.trim()})}return p},s=c=>{const p=c.trim();return/^(from|to|\d+(\.\d+)?%)$/.test(p)},r=c=>c.replace(/::v-deep\(/g,":deep(").replace(/::v-deep\s+/g,":deep(").replace(/\/deep\//g," ").replace(/>>>/g," ").replace(/(.*?):deep\(([^)]+)\)/g,(p,u,d)=>{const m=u.trim(),h=d.trim();return m?`${m}[${e}] ${h}`:h}),o=c=>{const p=c.trim();if(!p||p.includes(`[${e}]`)||/^(:root|:host|html|body)(\s|$|:|\.|\#|\[)/.test(p)||s(p))return p;const u=p.match(/^(.+?)((?:::?[\w-]+(?:\([^)]*\))?)*)\s*$/);if(u){const[,d,m=""]=u,h=d.trim();return h?`${h}[${e}]${m}`:p}return`${p}[${e}]`},a=c=>r(c).split(",").map(u=>o(u)).filter(u=>u.trim()).join(", "),i=c=>c.map(p=>{switch(p.type){case"simple-at-rule":return p.content;case"keyframes":return p.content;case"at-rule":try{const d=t(p.inner),m=i(d);return`${p.rule} { ${m} }`}catch{return p.content}case"rule":if(!p.selector||!p.content)return"";const u=a(p.selector);return u.trim()?`${u} { ${p.content} }`:"";default:return""}}).filter(p=>p.trim()).join(" "),l=c=>c.replace(/\s*{\s*/g," { ").replace(/\s*}\s*/g," } ").replace(/\s*;\s*/g,"; ").replace(/\s*,\s*/g,", ").replace(/\s+/g," ").replace(/^\s+|\s+$/g,"").replace(/\s*}\s*}/g," } }").trim();try{const c=n.replace(/\/\*(?!\s*!)[\s\S]*?\*\//g,"").replace(/^\s+|\s+$/gm,"").replace(/\n\s*\n/g,`
|
|
8
8
|
`),p=t(c),u=i(p);return l(u)}catch(c){return console.error("CSS scoping failed:",c),console.error("Input CSS:",n),n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(@keyframes\s+[^{]+\s*{[^{}]*(?:{[^}]*}[^{}]*)*})/g,p=>p).replace(/([^{}@]+)(?=\s*{)/g,p=>{const u=p.trim();return!u||u.startsWith("@")||u.includes(`[${e}]`)||s(u)?p:`${u}[${e}]`})}}const at=750;function Ae(n,e,t){let s;typeof n<"u"?s=n.innerWidth||n.document.documentElement.clientWidth:(console.warn("无法获取屏幕宽度,使用默认值375"),s=375);const r=t||at;return e*s/r}function Ie(n,e){let t=!1,s=!1,r=!1,o="";for(let a=0;a<e.length;a++){const i=e[a];if(i==="'"&&!s&&!r?t=!t:i==='"'&&!t&&!r?s=!s:e.substr(a,4).toLowerCase()==="url("&&!t&&!s?r=!0:i===")"&&r&&(r=!1),!t&&!s&&!r){const l=e.substr(a).match(/^(-?\d+(?:\.\d+)?)\s*rpx/);if(l){const c=l[1],p=parseFloat(c),d=`${Ae(n,p).toFixed(6).replace(/\.?0+$/,"")}px`;o+=d,a+=l[0].length-1;continue}}o+=i}return o}function re(n){return f.isString(n)?n:JSON.stringify(n)}function z(n,e,t,s=!1){const r=n.CSSStyleSheet,o=s?`data-v-${e}`:e,a=n.__uniConfig?Ie(n,t):t,i=s?Pe(a,o):a;if(r.prototype.replaceSync){const l=new r;l.id=e,l.replaceSync(i);const c=n.document,p=c.adoptedStyleSheets,u=Array.from(p).filter(d=>d.id!==e);c.adoptedStyleSheets=[...u,l]}else{const l=n.document;let c=l.getElementById(e);c?c.innerHTML=i:(c=l.createElement("style"),c.id=e,c.innerHTML=i,l.head.appendChild(c))}}function ct(n){const e=n.adoptedStyleSheets||[];let t="";if(e.forEach(s=>{try{for(const r of s.cssRules)t+=r.cssText+`
|
|
9
9
|
`}catch(r){console.error("Failed to read cssRules from adopted stylesheet:",r)}}),t){const s=n.createElement("style");s.textContent=t,n.head.appendChild(s)}}async function Te(n,e){const t=await window.fetch(e).then(s=>s.text()).catch(()=>"");t&&z(window,n,t)}function oe(n,e=window){const t=e.document,s=e.document.head;for(const r of n)if(!t.getElementById(r)){const a=t.createElement("link");a.rel="stylesheet",a.id=r,a.href=r,s.appendChild(a)}}async function ie(n,e,t=window){const s=t.document,r=t.document.head;let o=t[e];return o?o.default||o:new Promise((a,i)=>{for(const l of n){const c=s.createElement("script");c.src=l,c.onload=()=>{o=t[e],o?a(o.default||o):i(null)},c.onerror=p=>{i(p)},r.appendChild(c)}})}function Me(n){return f.isFunction(n)&&Object.getOwnPropertyNames(n.prototype||{}).length===0||f.isFunction(n?.install)}function Oe(n){return Ee.includes(n)}function ke(n){return we.includes(n)}function D(n=window){const e=window?.Mock;if(e)return e;const t=n?.Mock;if(t&&window)return window.Mock=t,t}function lt(n,e,t){Object.assign(e.meta,t.meta);const s=n?._container;t?.type==="page"&&s.classList.add("is-page"),t?.pure&&s.classList.add("is-pure")}function x(n,e,t=!1,s=!1,r=!1){try{const o=['"use strict";',"var __self = arguments[0];"];o.push("return ");let a=(n.value||"").trim();r||(a=a.replace(/this(\W|$)/g,(l,c)=>`__self${c}`)),a=o.join(`
|
|
10
10
|
`)+a;const i=r?`
|
|
11
11
|
${a}
|
|
12
|
-
`:`with(${t?"{}":"$scope || {}"}) { ${a} }`;return new Function("$scope",i)(e)}catch(o){if(f.logger.error("parseExpression.error",o,n,e?.__self??e),s)throw o}}function P(n,e,t=!1,s=!1,r=!1){const o=x(n,e,t,s,r);if(typeof o!="function"&&(f.logger.error("parseFunction.error","not a function",n,e?.__self??e),s))throw new Error(`"${n.value}" not a function`);return o}function R(n){return n&&n.type==="JSExpression"}function j(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function Fe(n){return R(n)||j(n)}function ut(n){return Fe(n)?n.value:JSON.stringify(n)}const pt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},ae=Symbol("access");class V{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},pt,e),this.loadData()}enableIntercept(){this.interceptResponse=!0}disableIntercept(){this.interceptResponse=!1}connect(e){const{mode:t,router:s,request:r}=e;this.mode=t,s&&this.mode!==S.Design&&this.setGuard(s),r&&this.setRequest(r)}login(e){const{storageKey:t,storagePrefix:s,session:r,authKey:o}=this.options;this.setData(e),this.data&&(f.storage.save(t,e,{type:"local",prefix:s}),r&&f.cookie.set(o,this.data.token))}clear(){const{storageKey:e,storagePrefix:t,session:s,authKey:r}=this.options;this.data=null,f.storage.remove(e,{type:"local",prefix:t}),s&&f.cookie.remove(r)}logout(){this.clear(),this.toLogin()}getData(){return this.data?this.data:(this.loadData(),this.data)}getToken(){return this.data||this.loadData(),this.data?.token}can(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return typeof e=="function"?e(s):f.toArray(e).every(o=>s[o]||s[t+"."+o])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return f.toArray(e).some(o=>s[o]||s[t+"."+o])}install(e){e.config.globalProperties.$access=this,e.provide(ae,this)}isAuthPath(e){const{auth:t,isAuth:s}=this.options;if(s)return s(e);if(e.path&&typeof t=="string"){const r=t.split("#")[1]||t;return e.path===r}return!1}toLogin(){const{auth:e,redirectParam:t}=this.options;if(!e)return;const s=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(s):location.href=t?`${e}${s}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const s=e.map(r=>f.unRSA(r,t));try{this.data=JSON.parse(s.join(""))}catch(r){console.warn(r)}return}if(typeof e=="string")try{const s=t?f.unRSA(e,t):e;s?this.data=JSON.parse(s):console.warn("RSA解密失败或登录信息缺失")}catch(s){console.warn(s)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,s=f.storage.get(e,{type:"local",prefix:t});this.setData(s||null)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!f.cookie.get(t):!!this.getToken()}hasRoutePermission(e){if(e.name===F){const t=e.params.id;return t&&this.can(t)}return e.meta.__vtj__?this.can(e.meta.__vtj__):e.meta.permission?this.can(e.meta.permission):!0}setGuard(e){e.beforeEach((t,s,r)=>this.guard(t,r))}async guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:s="无权限访问",unauthorized:r=!1}=this.options;return await this.showTip(s),f.isFunction(r)?(r(),t(!1)):f.isString(r)?t(r):t(!1)}}t(!1),await f.delay(0),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(s=>e.fullPath.startsWith(s)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401,statusKey:s="code"}=this.options;return e.status===t||e.data?.[s]===t}async showUnauthorizedAlert(e){const{unauthorizedMessage:t="登录已失效"}=this.options;this.isUnauthorized(e)&&await this.showTip(t)&&this.toLogin()}async showTip(e){const{alert:t}=this.options;return this.isTipShowing?!1:t?(this.isTipShowing=!0,await f.delay(150),await t(e,{title:"提示",type:"warning"})?.catch(()=>!0)?.finally(()=>{this.isTipShowing=!1})):(window.alert(e),!0)}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(this.interceptResponse&&await this.showUnauthorizedAlert(t),t),async t=>{if(!this.interceptResponse)return Promise.reject(t);const s=t.response||t||{};return await this.showUnauthorizedAlert(s),Promise.reject(t)})}}function De(){return b.inject(ae,null)}function ft(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:o,useTitle:a,alert:i}=n;let l=null;return{request:f.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:p=>p.data?.code===0||!!p.data?.success,failMessage:!0,showError:p=>{e&&e(p||"未知错误")},showLoading:()=>{l&&l.close(),t&&(l=t())},hideLoading:()=>{l&&(l.close(),l=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:a,alert:i,startupComponent:r,access:o?new V({alert:i,...o}):void 0}}function dt(n={}){return new V(n)}function xe(n,e){const{jsonp:t,request:s}=e;if(n.method==="jsonp")return(r={})=>t(n.url,{...n.jsonpOptions,query:r});{const r=n.headers?x(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(a,i)=>(delete o.data,s.send(f.merge(o,i||{},{data:a})))}}function He(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,o,a)}}function Le(n=[],e=[],t){const s={};for(const r of n){const o=xe(r,t);s[r.id]=o,s[r.name]=o}for(const r of e)s[r.id]=He(r,t);return s}async function Ne(n=[],e=window){const t=D(e);t&&(ce(e),n.forEach(s=>Be(t,s)))}function Ue(n,e=window){const t=j(n.mockTemplate)&&n.mockTemplate.value?P(n.mockTemplate,{},!0):void 0,s=D(e);return async(...r)=>{let o={};if(t)try{o=await t.apply(t,r)}catch(a){f.logger.warn("模拟数据模版异常",a)}return s?.mock(o)}}function Be(n,e){if(!e.mock)return;const{url:t,mockTemplate:s}=e;if(t&&s)try{const r=f.isUrl(t)?new URL(t).pathname:t,o=f.pathToRegexp(`(.*)${r}(.*)`),a=f.pathToRegexpMatch(r,{decode:decodeURIComponent}),i=x(s,{},!0);n.mock(o,l=>{const c=f.url.parse(l.url)||{},p=l.body instanceof FormData?f.formDataToJson(l.body):l.body,u=f.isUrl(l.url)?new URL(l.url).pathname:l.url.split("?")[0],d=a(u)?.params;Object.assign(l,{data:p,params:d,query:c});try{return n.mock(i(l))}catch(m){return console.warn("[mockApi]",o,l,m),null}})}catch(r){console.warn("mockApi",r)}}function ce(n=window){const e=D(n);e&&(e._mocked={})}class qe{__id=null;__mode;__instance=null;__contextRefs={};__refs={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};$provider=null;__transform={};constructor(e){const{mode:t,dsl:s,attrs:r}=e;this.__mode=t,s&&(this.__id=s.id||null,this.__transform=s.transform||{}),r&&Object.assign(this,r)}setup(e,t=K){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=s.proxy;const r=s.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__reset()})}__proxy(){this.__instance&&te.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){te.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return P({type:s,value:r},this)}else return P(e,this)}__parseExpression(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return x({type:s,value:r},this)}else return x(e,this)}__ref(e=null,t){if(this.__mode!==S.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async s=>{await f.delay(0);let r=s?.$vtjEl||s?.$el||s?._?.vnode?.el||s;if(!r){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return r.nodeType===3&&r.nextSibling&&(r=r.nextSibling),r.__vtj__=e,S.Design===this.__mode&&(r.__context__=this,r.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,s)),typeof t=="function"?t(s):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,s)),s}}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const o=new Set([].concat(r,s));return Array.from(o)}else return s}__clone(e={}){const t={...this.context,...e},s={...t,context:t};return s.context.__proto__=this.context,s.__proto__=this,s}}function J(n){const{Vue:e=K,mode:t=S.Runtime,components:s={},libs:r={},apis:o={},loader:a}=n,i=e.computed(()=>n.dsl),l={$components:s,$libs:r,$apis:o},c=new qe({mode:t,dsl:i.value,attrs:l}),p=e.defineComponent({name:i.value.name,__scopeId:i.value.id?`data-v-${i.value.id}`:void 0,props:{...mt(i.value.props??[],c)},setup(u){c.$props=u,c.props=u,i.value.id&&z(n.window||window,i.value.id,i.value.css||"",!0),c.state=gt(e,i.value.state??{},c);const d=vt(e,i.value.computed??{},c),m=yt(i.value.methods??{},c),h=_t(e,i.value.inject,c);for(const[y,w]of Object.entries(h||{}))h[y]=e.inject(y,w);const g=Je(i.value.dataSources||{},c),v={...h,...d,...m,...g};return c.setup(v,e),St(e,i.value.watch??[],c),{vtj:c,state:c.state,...d,...m}},emits:ht(i.value.emits),expose:["vtj",...i.value.expose||[]],render(){if(!i.value.nodes)return null;const u=i.value.nodes||[];return u.length===1?O(u[0],c,e,a,u):u.map(d=>O(d,c,e,a,u))},...wt(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(p),context:c}}function ht(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function mt(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(o=>Se[o]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:R(s.default)?e.__parseExpression(s.default):s.default}).reduce((s,r)=>(s[r.name]={type:t(r.type),required:r.required,default:r.default},s),{})}function gt(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let o=e[r];return R(o)?o=t.__parseExpression(o):j(o)&&(o=t.__parseFunction(o)),s[r]=o,s},{}))}function vt(n,e,t){return Object.entries(e??{}).reduce((s,[r,o])=>(s[r]=n.computed(t.__parseFunction(o)),s),{})}function yt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}function _t(n,e=[],t){return e.reduce((s,r)=>{const{name:o,from:a}=r||{};r.default;const i=R(a)?t.__parseExpression(a)||o:a??o,l=R(r.default)?t.__parseExpression(r.default):r.default??null;return s[o]=n.inject(i,l),s},{})}function Je(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=Ue(r);else if(r.ref){const o=e.$apis[r.ref],a=j(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...i)=>{const l=await o.apply(e,i);return a?a(l):l}}return t},{})}function St(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function wt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>{const o=e.__parseFunction(r);return t[s]=async()=>{await f.delay(0),f.isFunction(o)&&o()},t},{})}const Ge=new f.Queue;let X=[],M={};const Ke=n=>n;async function le(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(i=>B(i));if(r.length===0||!s)return null;const o=t.filter(i=>U(i));return o.length&&oe(o,e),await ie(r,s,e).catch(i=>(console.warn("loadScriptUrl error",r,s,i),null))}function G(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(X.forEach(r=>{delete s.window[r]}),X=[]),(r,o,a=K)=>{if(!o||typeof o=="string")return r;if(o.type==="Schema"&&o.id)return a.defineAsyncComponent(async()=>{const i=M[o.id]||await Ge.add(o.id,()=>e(o.id));return i&&(i.name=r,M[o.id]=i),i?J({...s,Vue:a,dsl:f.cloneDeep(i),mode:S.Runtime,loader:G(n)}).renderer:null});if(o.type==="UrlSchema"&&o.url)return a.defineAsyncComponent(async()=>{const i=M[o.url]||await t(o.url);return i&&(i.name=r,M[o.url]=i),i?J({...s,Vue:a,dsl:f.cloneDeep(i),mode:S.Runtime,loader:G(n)}).renderer:null});if(o.type==="Plugin"){let i=o.library?M[o.library]:null;return i||(o.library&&X.push(o.library),i=M[o.library||Symbol()]=a.defineAsyncComponent(async()=>{const l=await le(o,s.window);return l||(console.warn("getPlugin result is null",o),null)}),i)}return r}}function Et(){M={},Ge.clearAllCache()}function O(n,e,t=K,s=Ke,r=[],o=!1){if(!n||!n.name||n.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:i=null,directives:l=[]}=n,{vIf:c,vElseIf:p,vElse:u,vFor:d,vShow:m,vModels:h,vBind:g,vHtml:v,others:y}=ze(l);if(!o&&(p||u))return null;if(c&&!bt(c,e))return Pt(n,e,t,s,r);const w=(_,E=0)=>{const A=_.$components,Q=(()=>{if(n.name==="component")return jt(_,n.props?.is);if(n.name==="slot")return n.name;const C=s(n.name,n.from,t);if(f.isString(C))return Oe(C)||ke(C)?C:A[C]??a?.app?.component(C)??C;if(f.isObject(C)&&n.id){const ge=`Loader${n.id}_${E}`,ve=A[ge];return ve||(A[ge]=C)}return C})(),I=Rt(i,n.props??{},_),Xe=Ct(t,n.events??{},_);if(n.name==="slot")return At(t,n,I,_,s);g&&Object.assign(I,_.__parseExpression(g.value)),m&&(I.style=Object.assign(I.style??{},Tt(m,_))),v&&Object.assign(I,Mt(v,_)),h.forEach(C=>{Object.assign(I,Ot(t,C,_))});const Ze=kt(t,n.children??[],_,s,n),he=_?.__id?`data-v-${_.__id}`:void 0,et=he?{[he]:""}:{};let Y=t.createVNode(Q,{key:`${i}_${E}`,...et,...I,...Xe},Ze);const me=a?$t(a,y,_):[];return me.length&&(Y=t.withDirectives(Y,me)),Y};return d?xt(d,w,e):w(e)}function $t(n,e,t){const s=n.app;return e.map(r=>{const o=typeof r.name=="string"?s.directive(r.name):t.__parseExpression(r.name);if(!o)return null;const a=[o];return r.value&&a.push(t.__parseExpression(r.value)),r.arg&&a.push(r.arg),r.modifiers&&a.push(r.modifiers),a}).filter(r=>!!r)}function ze(n=[]){const e=n.find(p=>f.camelCase(p.name)==="vIf"),t=n.find(p=>f.camelCase(p.name)==="vElseIf"),s=n.find(p=>f.camelCase(p.name)==="vElse"),r=n.find(p=>f.camelCase(p.name)==="vFor"),o=n.find(p=>f.camelCase(p.name)==="vShow"),a=n.find(p=>f.camelCase(p.name)==="vBind"),i=n.find(p=>f.camelCase(p.name)==="vHtml"),l=n.filter(p=>f.camelCase(p.name)==="vModel"),c=n.filter(p=>!_e.includes(f.camelCase(p.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:o,vModels:l,vBind:a,others:c,vHtml:i}}function bt(n,e){return!!e.__parseExpression(n.value)}function jt(n,e){return e?R(e)?n.__parseExpression(e):e:"div"}function Rt(n,e,t){const s=se(e,t);return s.ref=t.__ref(n,s.ref),s}function se(n,e){return R(n)?e.__parseExpression(n):j(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>se(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=se(r,e),t},{}):n}function Ct(n,e,t){const s=["passive","capture","once"],r={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],l=ue(i.modifiers),c=l.find(d=>s.includes(d)),p="on"+f.upperFirst(a)+(c&&r[c]||""),u=t.__parseFunction(i.handler);return u&&(o[p]=n.withModifiers(u,l)),o},{})}function Pt(n,e,t,s,r=[]){let o=r.findIndex(a=>a.id===n.id);for(let a=++o;a<r.length;a++){const{directives:i=[]}=r[a],{vElseIf:l,vElse:c}=ze(i);if(l){if(e.__parseExpression(l.value))return O(r[a],e,t,s,r,!0);continue}if(c)return O(r[a],e,t,s,r,!0)}return null}function ue(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function At(n,e,t,s,r){const{children:o}=e,a=It(e,s),i=s.$slots?.[a.name];return i?i(t):o?f.isString(o)?n.createTextVNode(o):R(o)?n.createTextVNode(re(s.__parseExpression(o))):Array.isArray(o)?o.map(l=>O(l,s,n,r,o)):null:null}function It(n,e){const{props:t}=n,s=t?.name||"default";return{name:R(s)?e.__parseExpression(s):s,params:[]}}function Tt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Mt(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Ot(n,e,t){const s={type:"JSFunction",value:e.value?.value?`(v) => {
|
|
12
|
+
`:`with(${t?"{}":"$scope || {}"}) { ${a} }`;return new Function("$scope",i)(e)}catch(o){if(f.logger.error("parseExpression.error",o,n,e?.__self??e),s)throw o}}function P(n,e,t=!1,s=!1,r=!1){const o=x(n,e,t,s,r);if(typeof o!="function"&&(f.logger.error("parseFunction.error","not a function",n,e?.__self??e),s))throw new Error(`"${n.value}" not a function`);return o}function R(n){return n&&n.type==="JSExpression"}function j(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function Fe(n){return R(n)||j(n)}function ut(n){return Fe(n)?n.value:JSON.stringify(n)}const pt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},ae=Symbol("access");class V{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},pt,e),this.loadData()}enableIntercept(){this.interceptResponse=!0}disableIntercept(){this.interceptResponse=!1}connect(e){const{mode:t,router:s,request:r}=e;this.mode=t,s&&this.mode!==S.Design&&this.setGuard(s),r&&this.setRequest(r)}login(e){const{storageKey:t,storagePrefix:s,session:r,authKey:o}=this.options;this.setData(e),this.data&&(f.storage.save(t,e,{type:"local",prefix:s}),r&&f.cookie.set(o,this.data.token))}clear(){const{storageKey:e,storagePrefix:t,session:s,authKey:r}=this.options;this.data=null,f.storage.remove(e,{type:"local",prefix:t}),s&&f.cookie.remove(r)}logout(){this.clear(),this.toLogin()}getData(){return this.data?this.data:(this.loadData(),this.data)}getToken(){return this.data||this.loadData(),this.data?.token}can(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return typeof e=="function"?e(s):f.toArray(e).every(o=>s[o]||s[t+"."+o])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return f.toArray(e).some(o=>s[o]||s[t+"."+o])}install(e){e.config.globalProperties.$access=this,e.provide(ae,this)}isAuthPath(e){const{auth:t,isAuth:s}=this.options;if(s)return s(e);if(e.path&&typeof t=="string"){const r=t.split("#")[1]||t;return e.path===r}return!1}toLogin(){const{auth:e,redirectParam:t}=this.options;if(!e)return;const s=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(s):location.href=t?`${e}${s}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const s=e.map(r=>f.unRSA(r,t));try{this.data=JSON.parse(s.join(""))}catch(r){console.warn(r)}return}if(typeof e=="string")try{const s=t?f.unRSA(e,t):e;s?this.data=JSON.parse(s):console.warn("RSA解密失败或登录信息缺失")}catch(s){console.warn(s)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,s=f.storage.get(e,{type:"local",prefix:t});this.setData(s||null)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!f.cookie.get(t):!!this.getToken()}hasRoutePermission(e){if(e.name===F){const t=e.params.id;return t&&this.can(t)}return e.meta.__vtj__?this.can(e.meta.__vtj__):e.meta.permission?this.can(e.meta.permission):!0}setGuard(e){e.beforeEach((t,s,r)=>this.guard(t,r))}async guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:s="无权限访问",unauthorized:r=!1}=this.options;return await this.showTip(s),f.isFunction(r)?(r(),t(!1)):f.isString(r)?t(r):t(!1)}}t(!1),await f.delay(0),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(s=>e.fullPath.startsWith(s)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401,statusKey:s="code"}=this.options;return e.status===t||e.data?.[s]===t}async showUnauthorizedAlert(e){const{unauthorizedMessage:t="登录已失效"}=this.options;this.isUnauthorized(e)&&await this.showTip(t)&&this.toLogin()}async showTip(e){const{alert:t}=this.options;return this.isTipShowing?!1:t?(this.isTipShowing=!0,await f.delay(150),await t(e,{title:"提示",type:"warning"})?.catch(()=>!0)?.finally(()=>{this.isTipShowing=!1})):(window.alert(e),!0)}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(this.interceptResponse&&await this.showUnauthorizedAlert(t),t),async t=>{if(!this.interceptResponse)return Promise.reject(t);const s=t.response||t||{};return await this.showUnauthorizedAlert(s),Promise.reject(t)})}}function De(){return b.inject(ae,null)}function ft(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:o,useTitle:a,alert:i}=n;let l=null;return{request:f.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:p=>p.data?.code===0||!!p.data?.success,failMessage:!0,showError:p=>{e&&e(p||"未知错误")},showLoading:()=>{l&&l.close(),t&&(l=t())},hideLoading:()=>{l&&(l.close(),l=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:a,alert:i,startupComponent:r,access:o?new V({alert:i,...o}):void 0}}function dt(n={}){return new V(n)}function xe(n,e){const{jsonp:t,request:s}=e;if(n.method==="jsonp")return(r={})=>t(n.url,{...n.jsonpOptions,query:r});{const r=n.headers?x(n.headers,{},!0):void 0,o={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(a,i)=>(delete o.data,s.send(f.merge(o,i||{},{data:a})))}}function He(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,o,a)}}function Le(n=[],e=[],t){const s={};for(const r of n){const o=xe(r,t);s[r.id]=o,s[r.name]=o}for(const r of e)s[r.id]=He(r,t);return s}async function Ne(n=[],e=window){const t=D(e);t&&(ce(e),n.forEach(s=>Be(t,s)))}function Ue(n,e=window){const t=j(n.mockTemplate)&&n.mockTemplate.value?P(n.mockTemplate,{},!0):void 0,s=D(e);return async(...r)=>{let o={};if(t)try{o=await t.apply(t,r)}catch(a){f.logger.warn("模拟数据模版异常",a)}return s?.mock(o)}}function Be(n,e){if(!e.mock)return;const{url:t,mockTemplate:s}=e;if(t&&s)try{const r=f.isUrl(t)?new URL(t).pathname:t,o=f.pathToRegexp(`(.*)${r}(.*)`),a=f.pathToRegexpMatch(r,{decode:decodeURIComponent}),i=x(s,{},!0);n.mock(o,l=>{const c=f.url.parse(l.url)||{},p=l.body instanceof FormData?f.formDataToJson(l.body):l.body,u=f.isUrl(l.url)?new URL(l.url).pathname:l.url.split("?")[0],d=a(u)?.params;Object.assign(l,{data:p,params:d,query:c});try{return n.mock(i(l))}catch(m){return console.warn("[mockApi]",o,l,m),null}})}catch(r){console.warn("mockApi",r)}}function ce(n=window){const e=D(n);e&&(e._mocked={})}class qe{__id=null;__mode;__instance=null;__contextRefs={};__refs={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};$provider=null;__transform={};constructor(e){const{mode:t,dsl:s,attrs:r}=e;this.__mode=t,s&&(this.__id=s.id||null,this.__transform=s.transform||{}),r&&Object.assign(this,r)}setup(e,t=K){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=s.proxy;const r=s.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__reset()})}__proxy(){this.__instance&&te.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){te.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.$refs={},this.__contextRefs={},this.context={}}__parseFunction(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return P({type:s,value:r},this)}else return P(e,this)}__parseExpression(e){if(e)if(this.__mode===S.Runtime){const{id:t,type:s}=e,r=t?this.__transform[t]??e.value:e.value;return x({type:s,value:r},this)}else return x(e,this)}__ref(e=null,t){if(this.__mode!==S.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async s=>{await f.delay(0);let r=s?.$vtjEl||s?.$el||s?._?.vnode?.el||s;if(!r){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return r.nodeType===3&&r.nextSibling&&(r=r.nextSibling),r.__vtj__=e,S.Design===this.__mode&&(r.__context__=this,r.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,s)),typeof t=="function"?t(s):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,s)),s}}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const o=new Set([].concat(r,s));return Array.from(o)}else return s}__clone(e={}){const t={...this.context,...e},s={...t,context:t};return s.context.__proto__=this.context,s.__proto__=this,s}}function J(n){const{Vue:e=K,mode:t=S.Runtime,components:s={},libs:r={},apis:o={},loader:a}=n,i=e.computed(()=>n.dsl),l={$components:s,$libs:r,$apis:o},c=new qe({mode:t,dsl:i.value,attrs:l}),p=e.defineComponent({name:i.value.name,__scopeId:i.value.id?`data-v-${i.value.id}`:void 0,props:{...mt(i.value.props??[],c)},async setup(u){c.$props=u,c.props=u,i.value.id&&z(n.window||window,i.value.id,i.value.css||"",!0),c.state=gt(e,i.value.state??{},c);const d=vt(e,i.value.computed??{},c),m=yt(i.value.methods??{},c),h=_t(e,i.value.inject,c);for(const[y,w]of Object.entries(h||{}))h[y]=e.inject(y,w);const g=Je(i.value.dataSources||{},c),v={...h,...d,...m,...g};return c.setup(v,e),St(e,i.value.watch??[],c),{vtj:c,state:c.state,...d,...m}},emits:ht(i.value.emits),expose:["vtj",...i.value.expose||[]],render(){if(!i.value.nodes)return null;const u=i.value.nodes||[];return u.length===1?O(u[0],c,e,a,u):u.map(d=>O(d,c,e,a,u))},...wt(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(p),context:c}}function ht(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function mt(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(o=>Se[o]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:R(s.default)?e.__parseExpression(s.default):s.default}).reduce((s,r)=>(s[r.name]={type:t(r.type),required:r.required,default:r.default},s),{})}function gt(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let o=e[r];return R(o)?o=t.__parseExpression(o):j(o)&&(o=t.__parseFunction(o)),s[r]=o,s},{}))}function vt(n,e,t){return Object.entries(e??{}).reduce((s,[r,o])=>(s[r]=n.computed(t.__parseFunction(o)),s),{})}function yt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}function _t(n,e=[],t){return e.reduce((s,r)=>{const{name:o,from:a}=r||{};r.default;const i=R(a)?t.__parseExpression(a)||o:a??o,l=R(r.default)?t.__parseExpression(r.default):r.default??null;return s[o]=n.inject(i,l),s},{})}function Je(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=Ue(r);else if(r.ref){const o=e.$apis[r.ref],a=j(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...i)=>{const l=await o.apply(e,i);return a?a(l):l}}return t},{})}function St(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function wt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>{const o=e.__parseFunction(r);return t[s]=async()=>{f.isFunction(o)&&await o()},t},{})}const Ge=new f.Queue;let X=[],M={};const Ke=n=>n;async function le(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(i=>B(i));if(r.length===0||!s)return null;const o=t.filter(i=>U(i));return o.length&&oe(o,e),await ie(r,s,e).catch(i=>(console.warn("loadScriptUrl error",r,s,i),null))}function G(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(X.forEach(r=>{delete s.window[r]}),X=[]),(r,o,a=K)=>{if(!o||typeof o=="string")return r;if(o.type==="Schema"&&o.id)return a.defineAsyncComponent(async()=>{const i=M[o.id]||await Ge.add(o.id,()=>e(o.id));return i&&(i.name=r,M[o.id]=i),i?J({...s,Vue:a,dsl:f.cloneDeep(i),mode:S.Runtime,loader:G(n)}).renderer:null});if(o.type==="UrlSchema"&&o.url)return a.defineAsyncComponent(async()=>{const i=M[o.url]||await t(o.url);return i&&(i.name=r,M[o.url]=i),i?J({...s,Vue:a,dsl:f.cloneDeep(i),mode:S.Runtime,loader:G(n)}).renderer:null});if(o.type==="Plugin"){let i=o.library?M[o.library]:null;return i||(o.library&&X.push(o.library),i=M[o.library||Symbol()]=a.defineAsyncComponent(async()=>{const l=await le(o,s.window);return l||(console.warn("getPlugin result is null",o),null)}),i)}return r}}function Et(){M={},Ge.clearAllCache()}function O(n,e,t=K,s=Ke,r=[],o=!1){if(!n||!n.name||n.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:i=null,directives:l=[]}=n,{vIf:c,vElseIf:p,vElse:u,vFor:d,vShow:m,vModels:h,vBind:g,vHtml:v,others:y}=ze(l);if(!o&&(p||u))return null;if(c&&!bt(c,e))return Pt(n,e,t,s,r);const w=(_,E=0)=>{const A=_.$components,Q=(()=>{if(n.name==="component")return jt(_,n.props?.is);if(n.name==="slot")return n.name;const C=s(n.name,n.from,t);if(f.isString(C))return Oe(C)||ke(C)?C:A[C]??a?.app?.component(C)??C;if(f.isObject(C)&&n.id){const ge=`Loader${n.id}_${E}`,ve=A[ge];return ve||(A[ge]=C)}return C})(),I=Rt(i,n.props??{},_),Xe=Ct(t,n.events??{},_);if(n.name==="slot")return At(t,n,I,_,s);g&&Object.assign(I,_.__parseExpression(g.value)),m&&(I.style=Object.assign(I.style??{},Tt(m,_))),v&&Object.assign(I,Mt(v,_)),h.forEach(C=>{Object.assign(I,Ot(t,C,_))});const Ze=kt(t,n.children??[],_,s,n),he=_?.__id?`data-v-${_.__id}`:void 0,et=he?{[he]:""}:{};let Y=t.createVNode(Q,{key:`${i}_${E}`,...et,...I,...Xe},Ze);const me=a?$t(a,y,_):[];return me.length&&(Y=t.withDirectives(Y,me)),Y};return d?xt(d,w,e):w(e)}function $t(n,e,t){const s=n.app;return e.map(r=>{const o=typeof r.name=="string"?s.directive(r.name):t.__parseExpression(r.name);if(!o)return null;const a=[o];return r.value&&a.push(t.__parseExpression(r.value)),r.arg&&a.push(r.arg),r.modifiers&&a.push(r.modifiers),a}).filter(r=>!!r)}function ze(n=[]){const e=n.find(p=>f.camelCase(p.name)==="vIf"),t=n.find(p=>f.camelCase(p.name)==="vElseIf"),s=n.find(p=>f.camelCase(p.name)==="vElse"),r=n.find(p=>f.camelCase(p.name)==="vFor"),o=n.find(p=>f.camelCase(p.name)==="vShow"),a=n.find(p=>f.camelCase(p.name)==="vBind"),i=n.find(p=>f.camelCase(p.name)==="vHtml"),l=n.filter(p=>f.camelCase(p.name)==="vModel"),c=n.filter(p=>!_e.includes(f.camelCase(p.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:o,vModels:l,vBind:a,others:c,vHtml:i}}function bt(n,e){return!!e.__parseExpression(n.value)}function jt(n,e){return e?R(e)?n.__parseExpression(e):e:"div"}function Rt(n,e,t){const s=se(e,t);return s.ref=t.__ref(n,s.ref),s}function se(n,e){return R(n)?e.__parseExpression(n):j(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>se(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=se(r,e),t},{}):n}function Ct(n,e,t){const s=["passive","capture","once"],r={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],l=ue(i.modifiers),c=l.find(d=>s.includes(d)),p="on"+f.upperFirst(a)+(c&&r[c]||""),u=t.__parseFunction(i.handler);return u&&(o[p]=n.withModifiers(u,l)),o},{})}function Pt(n,e,t,s,r=[]){let o=r.findIndex(a=>a.id===n.id);for(let a=++o;a<r.length;a++){const{directives:i=[]}=r[a],{vElseIf:l,vElse:c}=ze(i);if(l){if(e.__parseExpression(l.value))return O(r[a],e,t,s,r,!0);continue}if(c)return O(r[a],e,t,s,r,!0)}return null}function ue(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function At(n,e,t,s,r){const{children:o}=e,a=It(e,s),i=s.$slots?.[a.name];return i?i(t):o?f.isString(o)?n.createTextVNode(o):R(o)?n.createTextVNode(re(s.__parseExpression(o))):Array.isArray(o)?o.map(l=>O(l,s,n,r,o)):null:null}function It(n,e){const{props:t}=n,s=t?.name||"default";return{name:R(s)?e.__parseExpression(s):s,params:[]}}function Tt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Mt(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Ot(n,e,t){const s={type:"JSFunction",value:e.value?.value?`(v) => {
|
|
13
13
|
${e.value.value} = v;
|
|
14
14
|
}`:"(v) => {}"},r=t.__parseFunction(s),o=ue(R(e.modifiers)?t.__parseExpression(e.modifiers):e.modifiers),a=R(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&r?n.withModifiers(r,o):r}}function kt(n,e,t,s,r){if(!e)return null;if(f.isString(e))return{default:()=>e};if(R(e))return{default:()=>re(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=Ft(e),a=(i,l)=>!i||!r?{}:r?.id&&Object.keys(i).length?l?{[l]:i}:{[`scope_${r.id}`]:i}:l?{[l]:Object.create(null)}:{};return Object.entries(o).reduce((i,[l,{nodes:c,params:p,scope:u}])=>(i[l]=d=>{const m=p.length?f.pick(d??{},p):a(d,u);return c.map(h=>O(h,t.__clone(m),n,s,c))},i),{})}return null}function Ft(n){const e={};for(const t of n){const s=Dt(t.slot),r=s.name;e[r]?(e[r].nodes.push(t),e[r].params=e[r].params.concat(s.params),e[r].scope=s.scope||""):e[r]={nodes:[t],params:s.params,scope:s.scope||""}}return e}function Dt(n="default"){return f.isString(n)?{name:n,params:[],scope:""}:{params:[],scope:"",...n}}function xt(n,e,t){const{value:s,iterator:r}=n,{item:o="item",index:a="index"}=r||{};let i=t.__parseExpression(s)||[];return Number.isInteger(i)&&(i=new Array(i).fill(!0).map((l,c)=>c+1)),Array.isArray(i)?i.map((l,c)=>e(t.__clone({[o]:l,[a]:c}),c)):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}const Z=b.defineComponent({name:"VtjPageContainer",async setup(){const n=de(),e=ye.useRoute(),t=e.meta.__vtj__||e.params.id,s=t?n.getPage(t):n.getHomepage(),r=s?await n.getRenderComponent(s.id):null,o=b.ref(Symbol());if(s){Object.assign(e.meta,s.meta||{},{cache:s.cache});const{useTitle:a}=n?.adapter;if(a){const i=e.meta.title||s.title||"VTJ.PRO";a(i)}}return{provider:n,component:r,file:s,query:e.query,meta:e.meta,sid:o,route:e}},render(){const{component:n,query:e,sid:t}=this;return n?b.h(n,{...e,key:t}):b.h("div","页面不存在")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),Ht=b.defineComponent({name:"VtjStartupContainer",render(){return b.h("div","page not found!")}});function N(n,e,t=[]){const s=[];for(const r of t){const{id:o,title:a,icon:i,children:l,hidden:c,layout:p}=r;if(p){const u=N(n,e,l||[]);s.push(...u)}else{const u={id:o,title:a,icon:i,hidden:c,url:`${n}/${e}/${o}`,children:l&&l.length?N(n,e,l):void 0};s.push(u)}}return s}function pe(n,e){if(!e)return n;let t=[];for(const s of n)if(s.children&&s.children.length){const r=pe(s.children,e);r.length&&(s.children=r,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function Lt(n){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=n||{},r=de(),o=ye.useRoute(),a=De(),i=b.ref(!1),l=b.ref(!1),c=r.project,p=(m,h)=>{i.value=!m?.mask,l.value=h?.pure??!!m?.pure};b.watchEffect(()=>{const{name:m,params:h,meta:g}=o;if(m===F){const v=r.getPage(h.id);p(v,g)}else if(m===L){const v=r.getHomepage();p(v,g)}else{const v=g.__vtj__;if(v){const y=r.getPage(v);p(y,g)}else i.value=!g.mask,l.value=!!g.pure}});const u=N(e,t,c?.pages),d=c?.config;return{disabled:i,logo:d?.logo,themeSwitchable:d?.themeSwitchable,title:d?.title||c?.description||c?.name||"VTJ App",menus:s?u:pe(u,a),pure:l}}function ee(n,e){const{id:t,title:s,meta:r}=n,{name:o="page",prefix:a="",component:i,routeMeta:l}=e;return{name:t,path:`${a}${o}/${t}`,component:i,meta:{title:s,...l,...r,__vtj__:t}}}function ne(n){const{name:e="page",prefix:t="",pages:s=[],component:r,loader:o,routeMeta:a,homepage:i}=n,l=[];for(const c of s){const{id:p,title:u,dir:d,layout:m,children:h,meta:g}=c;if(d){const v=ne({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:h||[]});l.push(...v)}else if(m){const v=ne({name:e,prefix:t,component:r,routeMeta:a,homepage:i,loader:o,pages:h||[]}),y={name:`layout_${p}`,path:t,component:()=>o(p),meta:{title:u,...a,...g,__vtj__:p},children:v};l.push(y),l.push(ee(c,n))}else if(l.push(ee(c,n)),i===p){const v=ee(c,n);v.path="",v.name=`home_${p}`,l.push(v)}}return l}function Nt(n={},e){const{css:t,store:s,enhance:r}=n,{window:o,app:a,library:i={},adapter:l,mode:c}=e,{Pinia:p}=i;a.config.globalProperties.$libs=i,z(o,"global-css",t||""),p&&s&&Ut(s,a,p),qt(a,l,n),!l.access&&n.access&&Bt(n.access,a,c,l),Jt(a,n),r&&Gt(r,a,i)}function Ut(n,e,t){const s=t.createPinia();if(e.use(s),j(n)&&n.value){const r=P(n,{},!1,!1,!0),o=t.defineStore("$store",r(e)||{});e.config.globalProperties.$store=o()}}function Bt(n,e,t,s){if(j(n)&&n.value){const r=P(n,{},!1,!1,!0),{alert:o,request:a}=s,i=new V({alert:o,storagePrefix:"__VTJ_APP_",...r(e)}),l=e.config.globalProperties.$router;i.connect({mode:t,router:l,request:a}),e.use(i)}}function qt(n,e,t){if(!e.request)return;const{axios:s,request:r,response:o}=t;if(s&&j(s)&&s.value){const a=P(s,{},!1,!1,!0);e.request.setConfig(a(n))}if(r&&j(r)&&r.value){const a=P(r,{},!1,!1,!0),i=e.request;i.__unReq&&i.__unReq(),i.__unReq=e.request.useRequest(l=>a(l,n))}if(o&&j(o)&&o.value){const a=P(o,{},!1,!1,!0),i=e.request;i.__unRes&&i.__unRes(),i.__unRes=e.request.useResponse(l=>a(l,n))}}function Jt(n,e){const{beforeEach:t,afterEach:s}=e,r=n.config.globalProperties.$router;if(t&&j(t)&&t.value){const o=P(t,{},!1,!1,!0);r&&r.beforeEach((a,i,l)=>o(a,i,l,n))}if(s&&j(s)&&s.value){const o=P(s,{},!1,!1,!0);r&&r.afterEach((a,i,l)=>o(a,i,l,n))}}function Gt(n,e,t={}){j(n)&&n.value&&P(n,{},!1,!1,!0)(e,t)}function Kt(n,e,t){if(!n||!e||!t)return;const{VueI18n:s}=e;if(s){const{locale:r,fallbackLocale:o,messages:a=[]}=t,i={};for(let c of a){const p=Object.keys(c).filter(u=>u!=="key");for(const u of p)i[u]||(i[u]={}),i[u][c.key]=c[u]}const l=s.createI18n({legacy:!1,locale:r,fallbackLocale:o,messages:i});n.use(l)}}const fe=Symbol("Provider");var Ve=(n=>(n.Production="production",n.Development="development",n))(Ve||{});class We extends T.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=S.Raw,dependencies:r,materials:o,project:a={},adapter:i={},globals:l={},modules:c={},router:p=null,materialPath:u="./",nodeEnv:d="development"}=e;this.mode=s,this.modules=c,this.service=t,this.router=p,this.materialPath=u,this.nodeEnv=d,r&&(this.dependencies=r),o&&(this.materials=o),Object.assign(this.globals,l),Object.assign(this.adapter,i);const{access:m,request:h}=this.adapter;m&&m.connect({mode:s,router:p,request:h}),a&&s!==S.Design?this.load(a):this.project=a}mode;globals={};modules={};adapter={request:f.request,jsonp:f.jsonp};apis={};dependencies={};materials={};library={};libraryLocales={};libraryLocaleMap={};service;project=null;components={};nodeEnv="development";env={};router=null;materialPath="./";urlDslCaches={};createMock(e){return async(...t)=>{let s={};if(e)try{s=await e.apply(e,t)}catch(o){f.logger.warn("模拟数据模版异常",o)}return D()?.mock(s)}}async load(e){const{vtjDir:t=".vtj"}=this.options,s=this.modules[`${t}/projects/${e.id}.json`]||this.modules[`/src/${t}/projects/${e.id}.json`];if(this.project=s?await s():await this.service.init(e),!this.project)throw new Error("project is null");const{apis:r=[],meta:o=[],env:a=[]}=this.project,i=window;i&&(i.CKEDITOR_VERSION=void 0),this.initEnv(a),this.mode===S.Raw?await this.loadDependencies(i):await this.loadAssets(i),this.initMock(i),this.apis=Le(r,o,this.adapter),ce(i),Ne(r,i),e.platform!=="uniapp"&&this.initRouter(),this.triggerReady()}initMock(e){const t=D(e);t&&t.setup({timeout:"50-500"})}async loadDependencies(e={}){const t=Object.entries(this.dependencies);for(const[s,r]of t)e[s]||(e[s]=this.library[s]=await r())}async loadAssets(e={}){const{dependencies:t=[]}=this.project,{dependencies:s,library:r,components:o,materialPath:a,nodeEnv:i,libraryLocales:l}=this,{libraryExports:c,libraryMap:p,materials:u,materialExports:d,materialMapLibrary:m,libraryLocaleMap:h}=je(t,a,i==="development");Object.assign(this.libraryLocaleMap,h);for(const g of c){const v=s[g],y=e[g];if(y)r[g]=y;else if(v)e[g]=r[g]=await v();else{const _=p[g]||[];for(const E of _)U(E)&&await Te(E,f.url.append(E,{v:k})),B(E)&&await f.loadScript(f.url.append(E,{v:k}));r[g]=e[g]}const w=h[g];if(w){const _=s[w];l[w]=_?await _():e[w]}}if(i==="development"){for(const v of u)await f.loadScript(f.url.append(v,{v:k}));const g=this.materials||{};for(const v of d){const y=e[m[v]],w=y?.default||y,_=T.BUILT_IN_COMPONENTS[v];if(_)w&&_.forEach(E=>{o[E]=w[E]});else{const E=g[v]?(await g[v]()).default:e[v];E&&w&&(E.components||[]).forEach(A=>{o[A.name]=Re(A,w)})}}}}initRouter(){const{router:e,project:t,options:s,adapter:r}=this;if(!e)return;const o=t?.platform==="uniapp"?"pages":"page",{routeAppendTo:a,pageRouteName:i=o,routeMeta:l}=s,c=a?"":"/",p={path:`${c}${i}/:id`,name:F,component:Z},u={path:c,name:L,component:t?.homepage?Z:r.startupComponent||Ht,meta:l};if(e.hasRoute(F)&&e.removeRoute(F),e.hasRoute(L)&&e.removeRoute(L),s.enableStaticRoute){const d=t?.pages||[];ne({name:i,prefix:c,pages:d,component:Z,loader:this.getRenderComponent.bind(this),homepage:t?.homepage}).forEach(h=>{a?e.addRoute(a,h):e.addRoute(h)}),t?.homepage||(a?e.addRoute(a,u):e.addRoute(u))}else a?(e.addRoute(a,p),e.addRoute(a,u)):(e.addRoute(p),e.addRoute(u))}install(e){const{libraryLocaleMap:t,libraryLocales:s}=this,{libraryOptions:r={}}=this.options,o=e.config.globalProperties.installed||{};for(const[a,i]of Object.entries(this.library))if(!o[a]&&Me(i)){const c={locale:s[t[a]]},p=r[a]||{},u={...c,...p};e.use(i,u),o[a]=!0}e.provide(fe,this),e.config.globalProperties.$provider=this,e.config.globalProperties.$request=this.adapter?.request,this.options.install&&e.use(this.options.install),this.adapter.access&&e.use(this.adapter.access),this.project?.platform!=="uniapp"&&this.mode!==S.Design&&this.initGlobals(this.project?.globals||{},{app:e,window,adapter:this.adapter,library:this.library,mode:this.mode}),this.mode!==S.Design&&this.project?.i18n&&this.initI18n(e,this.library,this.project.i18n),this.options.enhance&&e.use(this.options.enhance,this),this.mode===S.Design&&(e.config.errorHandler=(a,i,l)=>{const c=i?.$options.name,p=typeof a=="string"?a:a?.message||a?.msg||"未知错误",u=`[ ${c} ] ${p} ${l}`;console.error("[VTJ Error]:",{err:a,instance:i,info:l},a?.stack),this.adapter.notify&&this.adapter.notify(u,"组件渲染错误","error")}),e.config.globalProperties.installed=o}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(s=>s.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},s=(r,o=[])=>{for(const a of o){if(a.id===r)return a;if(a.children&&a.children.length){const i=s(r,a.children);if(i)return i}}};return s(e,t)||null}getMenus(e="page",t=""){return N(t,e,this.project?.pages||[])}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):null}async getDsl(e){const{vtjDir:t=".vtj"}=this.options,s=this.modules[`${t}/files/${e}.json`]||this.modules[`/src/${t}/files/${e}.json`];return s?await s():this.service.getFile(e,this.project||void 0).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.adapter.request?this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(s=>s.data).catch(()=>null):null)}createDslRenderer(e,t={}){const{library:s,components:r,mode:o,apis:a}=this,i={mode:o,Vue:s.Vue,components:r,libs:s,apis:a,window,...t},l=G({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return J({...i,dsl:e,loader:l})}async getRenderComponent(e,t){const s=this.getFile(e);if(!s)return f.logger.warn(`Can not find file: ${e}`),null;if(t&&t(s),this.mode===S.Raw){const{vtjRawDir:o=".vtj/vue"}=this.options,a=`${o}/${e}.vue`,i=this.modules[a]||this.modules[`/src/pages/${e}.vue`];return i?(await i())?.default:this.nodeEnv==="development"&&this.adapter.startupComponent||null}const r=await this.getDsl(s.id);return r?this.createDslRenderer(r).renderer:(f.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return b.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return b.defineAsyncComponent(async()=>await le(e,window))}initGlobals(e,t){const s=Object.assign({adapter:this.adapter,window},t);Nt(e,s)}initI18n(e,t,s){Kt(e,t,s)}initEnv(e=[]){this.env=e.reduce((t,s)=>(t[s.name]=s[this.nodeEnv],t),{})}}function zt(n){const e=new We(n);return{provider:e,onReady:s=>e.ready(s)}}function de(n={}){const e=b.inject(fe,null);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:s}=n;t&&s&&(async()=>{const r=await e.getDsl(t);r?.__VERSION__!==s&&e.adapter.notify&&e.adapter.notify(`[ ${r?.name} ] 组件源码版本与运行时版本不一致,请重新发布组件`,"版本不一致","warning")})()}return e}async function Vt(n,e=""){const{name:t,urls:s=[]}=n||{},r=s.map(i=>e+i),{css:o,js:a}=Ce(r);if(o.length&&oe(o),a.length)return await ie(a,t).catch(()=>{})}const Qe={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0},Wt=(n,e="/__vtj__/api/:type.json")=>(t,s,r)=>n.send({url:e,method:"post",params:{type:t},query:r,data:{type:t,data:s},settings:Qe}),Qt=(n,e="/__vtj__/api/uploader.json")=>async(t,s)=>await n.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...Qe,type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);function Yt(n){return f.createRequest({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:e=>e.data?.code===0,showError:e=>{n&&n(e||"未知错误")}}})}class W{constructor(e=f.request){this.req=e,this.api=Wt(e),this.uploader=Qt(e)}api;pluginCaches={};uploader;async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).catch(()=>!1)}async saveMaterials(e,t){return console.log("BaseService.saveMaterials",e,t),!1}async saveFile(e){return console.log("BaseService.saveFile",e),!1}async getFile(e){return console.log("BaseService.getFile",e),{}}async removeFile(e){return console.log("BaseService.removeFile",e),!1}async saveHistory(e){return console.log("BaseService.saveHistory",e),!1}async removeHistory(e){return console.log("BaseService.removeHistory",e),!1}async getHistory(e){return console.log("BaseService.getHistory",e),{}}async getHistoryItem(e,t){return console.log("BaseService.getHistoryItem",e,t),{}}async saveHistoryItem(e,t){return console.log("BaseService.saveHistoryItem",e,t),!1}async removeHistoryItem(e,t){return console.log("BaseService.removeHistoryItem",e,t),!1}async publish(e){return!!await this.api("publish",e).catch(()=>!1)}async publishFile(e,t){return!!await this.api("publishFile",{project:e,file:t}).catch(()=>!1)}async genVueContent(e,t){return await this.api("genVueContent",{project:e,dsl:t}).catch(()=>"")}async parseVue(e,t){return await this.api("parseVue",{project:e,...t})}async createRawPage(e){return await this.api("createRawPage",e).catch(()=>"")}async removeRawPage(e){return await this.api("removeRawPage",e).catch(()=>"")}async uploadStaticFile(e,t){return await this.uploader(e,t).catch(()=>null)}async getStaticFiles(e){return await this.api("getStaticFiles",e).catch(()=>[])}async removeStaticFile(e,t){return await this.api("removeStaticFile",{name:e,projectId:t}).catch(()=>"")}async clearStaticFiles(e){return await this.api("clearStaticFiles",e).catch(()=>"")}async getPluginMaterial(e){const{urls:t=[]}=e,s=t.filter(o=>$e(o))[0];if(!s)return null;const r=this.pluginCaches[s];return r||(this.pluginCaches[s]=f.request.send({url:s,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}async genSource(e){return console.log("BaseService.genSource",e),""}}const $=new f.Storage({type:"local",expired:0,prefix:"__VTJ_"});class Xt extends W{init(e){const t=new T.ProjectModel(e),s=$.get(`project_${t.id}`),r=Object.assign(t.toDsl(),s||{});return $.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new T.ProjectModel(e);return $.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return $.save(`materials_${e.id}`,f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return $.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=$.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return $.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return $.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=$.get(`history_${e}`);if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),$.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=$.get(`history_${e}`),s=new T.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=$.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return $.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{$.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class Ye extends W{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new T.ProjectModel(e),s=this.projects[t.id]||{},r=Object.assign(t.toDsl(),s);return this.projects[r.id]=r,Promise.resolve(r)}saveProject(e){const t=new T.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return this.files[e.id]=e,Promise.resolve(!0)}getFile(e){const t=this.files[e];return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return delete this.files[e],Promise.resolve(!0)}saveHistory(e){return this.histories[e.id]=e,Promise.resolve(!0)}removeHistory(e){const t=this.histories[e];if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new T.HistoryModel(t||{id:e});return Promise.resolve(s)}getHistoryItem(e,t){const s=`${e}_${t}`,r=this.historyItems[s]||{};return Promise.resolve(r)}saveHistoryItem(e,t){const s=`${e}_${t.id}`;return this.historyItems[s]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{const r=`${e}_${s}`;delete this.historyItems[r]}),Promise.resolve(!0)}}let q=null;function Zt(){return q||(q=new Ye,q)}class es extends W{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e,t){return!!await this.api("saveProject",e,{type:t}).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:f.mapToObject(t)}).catch(()=>!1)}async saveFile(e){return!!await this.api("saveFile",e).catch(()=>!1)}async getFile(e){const t=this.getFileCaches[e];return t||(this.getFileCaches[e]=this.api("getFile",e).catch(()=>null)).finally(()=>{delete this.getFileCaches[e]})}async removeFile(e){return!!await this.api("removeFile",e).catch(()=>!1)}async saveHistory(e){return!!await this.api("saveHistory",e).catch(()=>!1)}async removeHistory(e){return!!await this.api("removeHistory",e).catch(()=>!1)}async getHistory(e){return await this.api("getHistory",e).catch(()=>null)||{}}async getHistoryItem(e,t){return await this.api("getHistoryItem",{fId:e,id:t}).catch(()=>null)||{}}async saveHistoryItem(e,t){return!!await this.api("saveHistoryItem",{fId:e,item:t}).catch(()=>!1)}async removeHistoryItem(e,t){return!!await this.api("removeHistoryItem",{fId:e,ids:t}).catch(()=>!1)}}exports.ACCESS=rt;exports.ACCESS_KEY=ae;exports.Access=V;exports.BUILD_IN_TAGS=Ee;exports.BUILT_IN_DIRECTIVES=_e;exports.BaseService=W;exports.CONTEXT_HOST=te;exports.Context=qe;exports.ContextMode=S;exports.DATA_TYPES=Se;exports.HOMEPAGE_ROUTE_NAME=L;exports.HTML_TAGS=we;exports.JSCodeToString=ut;exports.LIFE_CYCLES_LIST=st;exports.LocalService=es;exports.MemoryService=Ye;exports.NodeEnv=Ve;exports.PAGE_ROUTE_NAME=F;exports.Provider=We;exports.REMOTE=nt;exports.StorageService=Xt;exports.VTJ_RENDERER_VERSION=k;exports.adoptStylesToInline=ct;exports.adoptedStyleSheets=z;exports.clearLoaderCache=Et;exports.compileScopedCSS=Pe;exports.convertCssRpx=Ie;exports.createAccess=dt;exports.createAdapter=ft;exports.createAssetScripts=ot;exports.createAssetsCss=it;exports.createDataSources=Je;exports.createLoader=G;exports.createMemoryService=Zt;exports.createMenus=N;exports.createMetaApi=He;exports.createMock=Ue;exports.createProvider=zt;exports.createRenderer=J;exports.createSchemaApi=xe;exports.createSchemaApis=Le;exports.createServiceRequest=Yt;exports.defaultLoader=Ke;exports.fillBasePath=H;exports.getMock=D;exports.getModifiers=ue;exports.getPlugin=le;exports.getRawComponent=Re;exports.isBuiltInTag=Oe;exports.isCSSUrl=U;exports.isJSCode=Fe;exports.isJSExpression=R;exports.isJSFunction=j;exports.isJSON=$e;exports.isJSUrl=B;exports.isNativeTag=ke;exports.isVuePlugin=Me;exports.loadCss=Te;exports.loadCssUrl=oe;exports.loadEnhance=Vt;exports.loadScriptUrl=ie;exports.menusFilter=pe;exports.mockApi=Be;exports.mockApis=Ne;exports.mockCleanup=ce;exports.nodeRender=O;exports.parseDeps=je;exports.parseExpression=x;exports.parseFunction=P;exports.parseUrls=Ce;exports.providerKey=fe;exports.removeProdFlag=be;exports.rpxToPx=Ae;exports.setupPageSetting=lt;exports.toString=re;exports.useAccess=De;exports.useMask=Lt;exports.useProvider=de;
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Base as Ge, BUILT_IN_COMPONENTS as ze, ProjectModel as U, HistoryModel as Ee } from "@vtj/core";
|
|
2
|
-
import { isUrl as
|
|
3
|
-
import * as
|
|
2
|
+
import { isUrl as te, url as F, dedupArray as Ve, isString as I, isFunction as q, logger as O, storage as Q, cookie as X, toArray as ve, unRSA as _e, delay as se, createRequest as je, jsonp as Re, merge as We, pathToRegexp as Qe, pathToRegexpMatch as Xe, formDataToJson as Ye, Queue as Ze, cloneDeep as we, camelCase as A, isObject as et, upperFirst as tt, pick as st, request as ne, loadScript as Se, Storage as nt, mapToObject as ue } from "@vtj/utils";
|
|
3
|
+
import * as K from "vue";
|
|
4
4
|
import { inject as Pe, defineComponent as Ce, h as re, ref as ie, watchEffect as rt, defineAsyncComponent as $e } from "vue";
|
|
5
5
|
import { useRoute as Ae } from "vue-router";
|
|
6
6
|
/**!
|
|
7
7
|
* Copyright (c) 2026, VTJ.PRO All rights reserved.
|
|
8
8
|
* @name @vtj/renderer
|
|
9
9
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
10
|
-
* @version 0.14.
|
|
10
|
+
* @version 0.14.5
|
|
11
11
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
12
12
|
*/
|
|
13
|
-
const T = "0.14.
|
|
13
|
+
const T = "0.14.5";
|
|
14
14
|
var w = /* @__PURE__ */ ((n) => (n.Runtime = "Runtime", n.Design = "Design", n.Raw = "Raw", n.VNode = "VNode", n))(w || {});
|
|
15
15
|
const be = [
|
|
16
16
|
"$el",
|
|
@@ -138,12 +138,12 @@ const be = [
|
|
|
138
138
|
privateKey: "MIIBOgIBAAJBAKoIzmn1FYQ1YOhOBw9EhABxZ+PySAIaydI+zdhoKflrdgJ4A5E4/5gbQmRpk09hPWG8nvX7h+l/QLU8kXxAIBECAwEAAQJAAlgpxQY6sByLsXqzJcthC8LSGsLf2JEJkHwlnpwFqlEV8UCkoINpuZ2Wzl+aftURu5rIfAzRCQBvHmeOTW9/zQIhAO5ufWDmnSLyfAAsNo5JRNpVuLFCFodR8Xm+ulDlosR/AiEAtpAltyP9wmCABKG/v/hrtTr3mcvFNGCjoGa9bUAok28CIHbrVs9w1ijrBlvTsXYwJw46uP539uKRRT4ymZzlm9QjAiB+1KH/G9f9pEEL9rtaSOG7JF5D0JcOjlze4MGVFs+ZrQIhALKOUFBNr2zEsyJIjw2PlvEucdlG77UniszjXTROHSPd"
|
|
139
139
|
};
|
|
140
140
|
function B(n, e) {
|
|
141
|
-
return n.map((t) =>
|
|
141
|
+
return n.map((t) => te(t) || t.startsWith("/") ? t : `${e}${t}`);
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function G(n) {
|
|
144
144
|
return /\.css$/.test(n);
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function z(n) {
|
|
147
147
|
return /\.js$/.test(n);
|
|
148
148
|
}
|
|
149
149
|
function lt(n) {
|
|
@@ -167,7 +167,7 @@ function ft(n, e, t = !1) {
|
|
|
167
167
|
return s.forEach(
|
|
168
168
|
({ urls: p, assetsUrl: h, library: d, assetsLibrary: m, localeLibrary: g }) => {
|
|
169
169
|
p?.forEach((y) => {
|
|
170
|
-
|
|
170
|
+
z(y) && r.push(ut(y, t)), G(y) && i.push(y);
|
|
171
171
|
}), d && (o.push(d), l[d] = B(p || [], e), g && (c[d] = g)), h && a.push(h), m && f.push(m), d && m && (u[m] = d);
|
|
172
172
|
}
|
|
173
173
|
), {
|
|
@@ -186,7 +186,7 @@ function pt(n, e) {
|
|
|
186
186
|
return s ? e[s]?.[r || t] : e[r || t];
|
|
187
187
|
}
|
|
188
188
|
function dt(n = []) {
|
|
189
|
-
const e = n.filter((s) =>
|
|
189
|
+
const e = n.filter((s) => G(s)), t = n.filter((s) => z(s));
|
|
190
190
|
return {
|
|
191
191
|
css: e,
|
|
192
192
|
js: t
|
|
@@ -223,11 +223,11 @@ function ht(n, e) {
|
|
|
223
223
|
let P = 1;
|
|
224
224
|
for (u++; u < c.length && P > 0; )
|
|
225
225
|
c[u] === "{" ? P++ : c[u] === "}" && P--, u++;
|
|
226
|
-
const
|
|
226
|
+
const V = c.substring(y, u), C = c.substring(S, u - 1);
|
|
227
227
|
f.push({
|
|
228
228
|
type: v ? "keyframes" : "at-rule",
|
|
229
229
|
rule: _,
|
|
230
|
-
content:
|
|
230
|
+
content: V,
|
|
231
231
|
inner: C
|
|
232
232
|
});
|
|
233
233
|
}
|
|
@@ -484,17 +484,17 @@ class pe {
|
|
|
484
484
|
}
|
|
485
485
|
login(e) {
|
|
486
486
|
const { storageKey: t, storagePrefix: s, session: r, authKey: i } = this.options;
|
|
487
|
-
this.setData(e), this.data && (
|
|
487
|
+
this.setData(e), this.data && (Q.save(t, e, {
|
|
488
488
|
type: "local",
|
|
489
489
|
prefix: s
|
|
490
|
-
}), r &&
|
|
490
|
+
}), r && X.set(i, this.data.token));
|
|
491
491
|
}
|
|
492
492
|
clear() {
|
|
493
493
|
const { storageKey: e, storagePrefix: t, session: s, authKey: r } = this.options;
|
|
494
|
-
this.data = null,
|
|
494
|
+
this.data = null, Q.remove(e, {
|
|
495
495
|
type: "local",
|
|
496
496
|
prefix: t
|
|
497
|
-
}), s &&
|
|
497
|
+
}), s && X.remove(r);
|
|
498
498
|
}
|
|
499
499
|
logout() {
|
|
500
500
|
this.clear(), this.toLogin();
|
|
@@ -554,7 +554,7 @@ class pe {
|
|
|
554
554
|
this.data = e;
|
|
555
555
|
}
|
|
556
556
|
loadData() {
|
|
557
|
-
const { storageKey: e, storagePrefix: t } = this.options, s =
|
|
557
|
+
const { storageKey: e, storagePrefix: t } = this.options, s = Q.get(e, {
|
|
558
558
|
type: "local",
|
|
559
559
|
prefix: t
|
|
560
560
|
});
|
|
@@ -562,7 +562,7 @@ class pe {
|
|
|
562
562
|
}
|
|
563
563
|
isLogined() {
|
|
564
564
|
const { session: e, authKey: t } = this.options;
|
|
565
|
-
return e && t ? !!
|
|
565
|
+
return e && t ? !!X.get(t) : !!this.getToken();
|
|
566
566
|
}
|
|
567
567
|
hasRoutePermission(e) {
|
|
568
568
|
if (e.name === x) {
|
|
@@ -585,7 +585,7 @@ class pe {
|
|
|
585
585
|
return await this.showTip(s), q(r) ? (r(), t(!1)) : I(r) ? t(r) : t(!1);
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
|
-
t(!1), await
|
|
588
|
+
t(!1), await se(0), this.toLogin();
|
|
589
589
|
}
|
|
590
590
|
isWhiteList(e) {
|
|
591
591
|
const { whiteList: t } = this.options;
|
|
@@ -601,7 +601,7 @@ class pe {
|
|
|
601
601
|
}
|
|
602
602
|
async showTip(e) {
|
|
603
603
|
const { alert: t } = this.options;
|
|
604
|
-
return this.isTipShowing ? !1 : t ? (this.isTipShowing = !0, await
|
|
604
|
+
return this.isTipShowing ? !1 : t ? (this.isTipShowing = !0, await se(150), await t(e, {
|
|
605
605
|
title: "提示",
|
|
606
606
|
type: "warning"
|
|
607
607
|
})?.catch(() => !0)?.finally(() => {
|
|
@@ -729,9 +729,9 @@ function It(n, e) {
|
|
|
729
729
|
const { url: t, mockTemplate: s } = e;
|
|
730
730
|
if (t && s)
|
|
731
731
|
try {
|
|
732
|
-
const r =
|
|
732
|
+
const r = te(t) ? new URL(t).pathname : t, i = Qe(`(.*)${r}(.*)`), a = Xe(r, { decode: decodeURIComponent }), o = H(s, {}, !0);
|
|
733
733
|
n.mock(i, (l) => {
|
|
734
|
-
const c = F.parse(l.url) || {}, f = l.body instanceof FormData ? Ye(l.body) : l.body, u =
|
|
734
|
+
const c = F.parse(l.url) || {}, f = l.body instanceof FormData ? Ye(l.body) : l.body, u = te(l.url) ? new URL(l.url).pathname : l.url.split("?")[0], p = a(u)?.params;
|
|
735
735
|
Object.assign(l, { data: f, params: p, query: c });
|
|
736
736
|
try {
|
|
737
737
|
return n.mock(o(l));
|
|
@@ -777,7 +777,7 @@ class kt {
|
|
|
777
777
|
const { mode: t, dsl: s, attrs: r } = e;
|
|
778
778
|
this.__mode = t, s && (this.__id = s.id || null, this.__transform = s.transform || {}), r && Object.assign(this, r);
|
|
779
779
|
}
|
|
780
|
-
setup(e, t =
|
|
780
|
+
setup(e, t = K) {
|
|
781
781
|
const s = t.getCurrentInstance();
|
|
782
782
|
if (!s) return;
|
|
783
783
|
this.__refs = {}, this.$refs = {}, this.context = {}, this.__contextRefs = {}, this.__instance = s.proxy;
|
|
@@ -822,7 +822,7 @@ class kt {
|
|
|
822
822
|
__ref(e = null, t) {
|
|
823
823
|
if (this.__mode !== w.VNode)
|
|
824
824
|
return e && e !== this.__id && (this.__contextRefs[e] = this), async (s) => {
|
|
825
|
-
await
|
|
825
|
+
await se(0);
|
|
826
826
|
let r = s?.$vtjEl || s?.$el || s?._?.vnode?.el || s;
|
|
827
827
|
if (!r) {
|
|
828
828
|
typeof t == "string" && (delete this.$refs[t], e && delete this.__refs[e]);
|
|
@@ -849,7 +849,7 @@ class kt {
|
|
|
849
849
|
}
|
|
850
850
|
function oe(n) {
|
|
851
851
|
const {
|
|
852
|
-
Vue: e =
|
|
852
|
+
Vue: e = K,
|
|
853
853
|
mode: t = w.Runtime,
|
|
854
854
|
components: s = {},
|
|
855
855
|
libs: r = {},
|
|
@@ -869,7 +869,7 @@ function oe(n) {
|
|
|
869
869
|
props: {
|
|
870
870
|
...Ot(o.value.props ?? [], c)
|
|
871
871
|
},
|
|
872
|
-
setup(u) {
|
|
872
|
+
async setup(u) {
|
|
873
873
|
c.$props = u, c.props = u, o.value.id && fe(
|
|
874
874
|
n.window || window,
|
|
875
875
|
o.value.id,
|
|
@@ -1001,28 +1001,28 @@ function Lt(n, e) {
|
|
|
1001
1001
|
(t, [s, r]) => {
|
|
1002
1002
|
const i = e.__parseFunction(r);
|
|
1003
1003
|
return t[s] = async () => {
|
|
1004
|
-
|
|
1004
|
+
q(i) && await i();
|
|
1005
1005
|
}, t;
|
|
1006
1006
|
},
|
|
1007
1007
|
{}
|
|
1008
1008
|
);
|
|
1009
1009
|
}
|
|
1010
1010
|
const Te = new Ze();
|
|
1011
|
-
let
|
|
1011
|
+
let Y = [], k = {};
|
|
1012
1012
|
const Nt = (n) => n;
|
|
1013
1013
|
async function xe(n, e = window) {
|
|
1014
|
-
const { urls: t = [], library: s } = n, r = t.filter((o) =>
|
|
1014
|
+
const { urls: t = [], library: s } = n, r = t.filter((o) => z(o));
|
|
1015
1015
|
if (r.length === 0 || !s) return null;
|
|
1016
|
-
const i = t.filter((o) =>
|
|
1016
|
+
const i = t.filter((o) => G(o));
|
|
1017
1017
|
return i.length && ke(i, e), await Fe(r, s, e).catch(
|
|
1018
1018
|
(o) => (console.warn("loadScriptUrl error", r, s, o), null)
|
|
1019
1019
|
);
|
|
1020
1020
|
}
|
|
1021
1021
|
function ae(n) {
|
|
1022
1022
|
const { getDsl: e, getDslByUrl: t, options: s } = n;
|
|
1023
|
-
return s.window && (
|
|
1023
|
+
return s.window && (Y.forEach((r) => {
|
|
1024
1024
|
delete s.window[r];
|
|
1025
|
-
}),
|
|
1025
|
+
}), Y = []), (r, i, a = K) => {
|
|
1026
1026
|
if (!i || typeof i == "string") return r;
|
|
1027
1027
|
if (i.type === "Schema" && i.id)
|
|
1028
1028
|
return a.defineAsyncComponent(async () => {
|
|
@@ -1051,7 +1051,7 @@ function ae(n) {
|
|
|
1051
1051
|
});
|
|
1052
1052
|
if (i.type === "Plugin") {
|
|
1053
1053
|
let o = i.library ? k[i.library] : null;
|
|
1054
|
-
return o || (i.library &&
|
|
1054
|
+
return o || (i.library && Y.push(i.library), o = k[i.library || Symbol()] = a.defineAsyncComponent(
|
|
1055
1055
|
async () => {
|
|
1056
1056
|
const l = await xe(i, s.window);
|
|
1057
1057
|
return l || (console.warn("getPlugin result is null", i), null);
|
|
@@ -1064,7 +1064,7 @@ function ae(n) {
|
|
|
1064
1064
|
function Is() {
|
|
1065
1065
|
k = {}, Te.clearAllCache();
|
|
1066
1066
|
}
|
|
1067
|
-
function M(n, e, t =
|
|
1067
|
+
function M(n, e, t = K, s = Nt, r = [], i = !1) {
|
|
1068
1068
|
if (!n || !n.name || n.invisible) return null;
|
|
1069
1069
|
const a = t.getCurrentInstance()?.appContext, { id: o = null, directives: l = [] } = n, { vIf: c, vElseIf: f, vElse: u, vFor: p, vShow: h, vModels: d, vBind: m, vHtml: g, others: y } = De(l);
|
|
1070
1070
|
if (!i && (f || u))
|
|
@@ -1072,7 +1072,7 @@ function M(n, e, t = G, s = Nt, r = [], i = !1) {
|
|
|
1072
1072
|
if (c && !qt(c, e))
|
|
1073
1073
|
return zt(n, e, t, s, r);
|
|
1074
1074
|
const _ = (v, S = 0) => {
|
|
1075
|
-
const P = v.$components,
|
|
1075
|
+
const P = v.$components, V = (() => {
|
|
1076
1076
|
if (n.name === "component")
|
|
1077
1077
|
return Jt(v, n.props?.is);
|
|
1078
1078
|
if (n.name === "slot") return n.name;
|
|
@@ -1100,13 +1100,13 @@ function M(n, e, t = G, s = Nt, r = [], i = !1) {
|
|
|
1100
1100
|
s,
|
|
1101
1101
|
n
|
|
1102
1102
|
), he = v?.__id ? `data-v-${v.__id}` : void 0, Ke = he ? { [he]: "" } : {};
|
|
1103
|
-
let
|
|
1104
|
-
|
|
1103
|
+
let W = t.createVNode(
|
|
1104
|
+
V,
|
|
1105
1105
|
{ key: `${o}_${S}`, ...Ke, ...C, ...qe },
|
|
1106
1106
|
Je
|
|
1107
1107
|
);
|
|
1108
1108
|
const me = a ? Ut(a, y, v) : [];
|
|
1109
|
-
return me.length && (
|
|
1109
|
+
return me.length && (W = t.withDirectives(W, me)), W;
|
|
1110
1110
|
};
|
|
1111
1111
|
return p ? ss(p, _, e) : _(e);
|
|
1112
1112
|
}
|
|
@@ -1275,7 +1275,7 @@ function ss(n, e, t) {
|
|
|
1275
1275
|
let o = t.__parseExpression(s) || [];
|
|
1276
1276
|
return Number.isInteger(o) && (o = new Array(o).fill(!0).map((l, c) => c + 1)), Array.isArray(o) ? o.map((l, c) => e(t.__clone({ [i]: l, [a]: c }), c)) : (console.warn("[vForRender]:", `${s?.value} is not a Arrary`), []);
|
|
1277
1277
|
}
|
|
1278
|
-
const
|
|
1278
|
+
const Z = Ce({
|
|
1279
1279
|
name: "VtjPageContainer",
|
|
1280
1280
|
async setup() {
|
|
1281
1281
|
const n = Ne(), e = Ae(), t = e.meta.__vtj__ || e.params.id, s = t ? n.getPage(t) : n.getHomepage(), r = s ? await n.getRenderComponent(s.id) : null, i = ie(Symbol());
|
|
@@ -1310,12 +1310,12 @@ const ee = Ce({
|
|
|
1310
1310
|
return re("div", "page not found!");
|
|
1311
1311
|
}
|
|
1312
1312
|
});
|
|
1313
|
-
function
|
|
1313
|
+
function J(n, e, t = []) {
|
|
1314
1314
|
const s = [];
|
|
1315
1315
|
for (const r of t) {
|
|
1316
1316
|
const { id: i, title: a, icon: o, children: l, hidden: c, layout: f } = r;
|
|
1317
1317
|
if (f) {
|
|
1318
|
-
const u =
|
|
1318
|
+
const u = J(n, e, l || []);
|
|
1319
1319
|
s.push(...u);
|
|
1320
1320
|
} else {
|
|
1321
1321
|
const u = {
|
|
@@ -1324,7 +1324,7 @@ function K(n, e, t = []) {
|
|
|
1324
1324
|
icon: o,
|
|
1325
1325
|
hidden: c,
|
|
1326
1326
|
url: `${n}/${e}/${i}`,
|
|
1327
|
-
children: l && l.length ?
|
|
1327
|
+
children: l && l.length ? J(n, e, l) : void 0
|
|
1328
1328
|
};
|
|
1329
1329
|
s.push(u);
|
|
1330
1330
|
}
|
|
@@ -1367,7 +1367,7 @@ function ks(n) {
|
|
|
1367
1367
|
o.value = !m.mask, l.value = !!m.pure;
|
|
1368
1368
|
}
|
|
1369
1369
|
});
|
|
1370
|
-
const u =
|
|
1370
|
+
const u = J(
|
|
1371
1371
|
e,
|
|
1372
1372
|
t,
|
|
1373
1373
|
c?.pages
|
|
@@ -1381,7 +1381,7 @@ function ks(n) {
|
|
|
1381
1381
|
pure: l
|
|
1382
1382
|
};
|
|
1383
1383
|
}
|
|
1384
|
-
function
|
|
1384
|
+
function ee(n, e) {
|
|
1385
1385
|
const { id: t, title: s, meta: r } = n, { name: i = "page", prefix: a = "", component: o, routeMeta: l } = e;
|
|
1386
1386
|
return {
|
|
1387
1387
|
name: t,
|
|
@@ -1439,9 +1439,9 @@ function le(n) {
|
|
|
1439
1439
|
},
|
|
1440
1440
|
children: g
|
|
1441
1441
|
};
|
|
1442
|
-
l.push(y), l.push(
|
|
1443
|
-
} else if (l.push(
|
|
1444
|
-
const g =
|
|
1442
|
+
l.push(y), l.push(ee(c, n));
|
|
1443
|
+
} else if (l.push(ee(c, n)), o === f) {
|
|
1444
|
+
const g = ee(c, n);
|
|
1445
1445
|
g.path = "", g.name = `home_${f}`, l.push(g);
|
|
1446
1446
|
}
|
|
1447
1447
|
}
|
|
@@ -1650,7 +1650,7 @@ class ps extends Ge {
|
|
|
1650
1650
|
else {
|
|
1651
1651
|
const v = f[m] || [];
|
|
1652
1652
|
for (const S of v)
|
|
1653
|
-
|
|
1653
|
+
G(S) && await vt(S, F.append(S, { v: T })), z(S) && await Se(F.append(S, { v: T }));
|
|
1654
1654
|
r[m] = e[m];
|
|
1655
1655
|
}
|
|
1656
1656
|
const _ = d[m];
|
|
@@ -1688,11 +1688,11 @@ class ps extends Ge {
|
|
|
1688
1688
|
} = s, c = a ? "" : "/", f = {
|
|
1689
1689
|
path: `${c}${o}/:id`,
|
|
1690
1690
|
name: x,
|
|
1691
|
-
component:
|
|
1691
|
+
component: Z
|
|
1692
1692
|
}, u = {
|
|
1693
1693
|
path: c,
|
|
1694
1694
|
name: N,
|
|
1695
|
-
component: t?.homepage ?
|
|
1695
|
+
component: t?.homepage ? Z : r.startupComponent || ns,
|
|
1696
1696
|
meta: l
|
|
1697
1697
|
};
|
|
1698
1698
|
if (e.hasRoute(x) && e.removeRoute(x), e.hasRoute(N) && e.removeRoute(N), s.enableStaticRoute) {
|
|
@@ -1701,7 +1701,7 @@ class ps extends Ge {
|
|
|
1701
1701
|
name: o,
|
|
1702
1702
|
prefix: c,
|
|
1703
1703
|
pages: p,
|
|
1704
|
-
component:
|
|
1704
|
+
component: Z,
|
|
1705
1705
|
loader: this.getRenderComponent.bind(this),
|
|
1706
1706
|
homepage: t?.homepage
|
|
1707
1707
|
}).forEach((d) => {
|
|
@@ -1765,7 +1765,7 @@ class ps extends Ge {
|
|
|
1765
1765
|
return s(e, t) || null;
|
|
1766
1766
|
}
|
|
1767
1767
|
getMenus(e = "page", t = "") {
|
|
1768
|
-
return
|
|
1768
|
+
return J(t, e, this.project?.pages || []);
|
|
1769
1769
|
}
|
|
1770
1770
|
getHomepage() {
|
|
1771
1771
|
const { homepage: e } = this.project || {};
|
|
@@ -2270,7 +2270,7 @@ export {
|
|
|
2270
2270
|
Ht as createDataSources,
|
|
2271
2271
|
ae as createLoader,
|
|
2272
2272
|
xs as createMemoryService,
|
|
2273
|
-
|
|
2273
|
+
J as createMenus,
|
|
2274
2274
|
Rt as createMetaApi,
|
|
2275
2275
|
At as createMock,
|
|
2276
2276
|
Fs as createProvider,
|
|
@@ -2285,12 +2285,12 @@ export {
|
|
|
2285
2285
|
xe as getPlugin,
|
|
2286
2286
|
pt as getRawComponent,
|
|
2287
2287
|
wt as isBuiltInTag,
|
|
2288
|
-
|
|
2288
|
+
G as isCSSUrl,
|
|
2289
2289
|
$t as isJSCode,
|
|
2290
2290
|
j as isJSExpression,
|
|
2291
2291
|
b as isJSFunction,
|
|
2292
2292
|
lt as isJSON,
|
|
2293
|
-
|
|
2293
|
+
z as isJSUrl,
|
|
2294
2294
|
St as isNativeTag,
|
|
2295
2295
|
_t as isVuePlugin,
|
|
2296
2296
|
vt as loadCss,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/renderer",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.14.
|
|
4
|
+
"version": "0.14.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"低代码引擎",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"author": "chenhuachun",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@vtj/
|
|
25
|
-
"@vtj/
|
|
24
|
+
"@vtj/utils": "~0.14.5",
|
|
25
|
+
"@vtj/core": "~0.14.5"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"vue": "~3.5.5",
|
|
29
29
|
"vue-router": "~4.6.0",
|
|
30
|
+
"@vtj/ui": "~0.14.5",
|
|
30
31
|
"@vtj/cli": "~0.12.18",
|
|
31
|
-
"@vtj/
|
|
32
|
-
"@vtj/icons": "~0.14.3"
|
|
32
|
+
"@vtj/icons": "~0.14.5"
|
|
33
33
|
},
|
|
34
34
|
"exports": {
|
|
35
35
|
".": {
|
package/types/version.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2026, VTJ.PRO All rights reserved.
|
|
3
3
|
* @name @vtj/renderer
|
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
|
5
|
-
* @version 0.14.
|
|
5
|
+
* @version 0.14.4
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.14.
|
|
8
|
+
export declare const version = "0.14.4";
|