@vtj/renderer 0.16.30 → 0.16.31
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 +8 -8
- package/dist/index.mjs +93 -92
- package/package.json +5 -5
- package/types/render/context.d.ts +1 -0
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("@vtj/core"),f=require("@vtj/utils"),$=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("@vtj/core"),f=require("@vtj/utils"),$=require("vue"),Ee=require("vue-router");function ct(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const W=ct($);/**!
|
|
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.16.
|
|
5
|
+
* @version 0.16.31
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
|
-
*/const D="0.16.
|
|
8
|
-
`),l=t(c),p=a(l);return u(p)}catch(c){return console.error("CSS scoping failed:",c),console.error("Input CSS:",n),n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(@keyframes\s+[^{]+\s*{[^{}]*(?:{[^}]*}[^{}]*)*})/g,l=>l).replace(/([^{}@]+)(?=\s*{)/g,l=>{const p=l.trim();return!p||p.startsWith("@")||p.includes(`[${e}]`)||s(p)?l:`${p}[${e}]`})}}const ht=750;function Te(n,e,t){let s;typeof n<"u"?s=n.innerWidth||n.document.documentElement.clientWidth:(console.warn("无法获取屏幕宽度,使用默认值375"),s=375);const r=t||ht;return e*s/r}function Me(n,e){let t=!1,s=!1,r=!1,i="";for(let o=0;o<e.length;o++){const a=e[o];if(a==="'"&&!s&&!r?t=!t:a==='"'&&!t&&!r?s=!s:e.substr(o,4).toLowerCase()==="url("&&!t&&!s?r=!0:a===")"&&r&&(r=!1),!t&&!s&&!r){const u=e.substr(o).match(/^(-?\d+(?:\.\d+)?)\s*rpx/);if(u){const c=u[1],l=parseFloat(c),d=`${Te(n,l).toFixed(6).replace(/\.?0+$/,"")}px`;i+=d,o+=u[0].length-1;continue}}i+=a}return i}function
|
|
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 Oe(n,e){const t=await window.fetch(e).then(s=>s.text()).catch(()=>"");t&&Q(window,n,t)}function
|
|
7
|
+
*/const D="0.16.31";var S=(n=>(n.Runtime="Runtime",n.Design="Design",n.Raw="Raw",n.VNode="VNode",n))(S||{});const oe=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],lt=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],$e=["vIf","vElseIf","vElse","vShow","vModel","vFor","vBind","vHtml"],Ce={String,Number,Boolean,Array,Object,Function,Date},x="VtjPage",U="VtjHomepage",le="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(","),be="component,slot".split(","),ut=["h","t","t","p","s",":","/","/","a","p","p",".","v","t","j",".","p","r","o"].join(""),pt={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 N(n,e){return n.map(t=>f.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function B(n){return/\.css$/.test(n)}function J(n){return/\.js$/.test(n)}function je(n){return/\.json$/.test(n)}function ft(n){return n.map(e=>`<script src="${f.url.append(e,{v:D})}"><\/script>`).join("")}function dt(n=[]){return n.map(e=>`<link rel="stylesheet" href="${f.url.append(e,{v:D})}" />`).join("")}function Re(n,e=!1){return e&&n.endsWith(".prod.js")?n.replace(".prod.js",".js"):n}function Pe(n,e,t=!1){const s=n.filter(d=>!!d.enabled),r=[],i=[],o=[],a=[],u={},c={},l=[],p={};return s.forEach(({urls:d,assetsUrl:h,library:g,assetsLibrary:m,localeLibrary:_})=>{d?.forEach(y=>{J(y)&&r.push(Re(y,t)),B(y)&&i.push(y)}),g&&(a.push(g),u[g]=N(d||[],e),_&&(c[g]=_)),h&&o.push(h),m&&l.push(m),g&&m&&(p[m]=g)}),{scripts:N(r,e),css:N(i,e),materials:N(o,e),libraryExports:a,materialExports:f.dedupArray(l),materialMapLibrary:p,libraryMap:u,libraryLocaleMap:c}}function Ae(n,e){const{name:t,parent:s,alias:r}=n;return s?e[s]?.[r||t]:e[r||t]}function Ie(n=[]){const e=n.filter(s=>B(s)),t=n.filter(s=>J(s));return{css:e,js:t}}function Fe(n,e){const t=c=>{const l=[];let p=0;for(;p<c.length;){if(/\s/.test(c[p])){p++;continue}if(c.substring(p,p+2)==="/*"){const y=c.indexOf("*/",p+2);if(y!==-1){p=y+2;continue}}if(c[p]==="@"){const y=p;for(;p<c.length&&c[p]!=="{"&&c[p]!==";";)p++;const w=c.substring(y,p).trim(),j=w.includes("@keyframes");if(c[p]===";")l.push({type:"simple-at-rule",content:c.substring(y,p+1)}),p++;else if(c[p]==="{"){const v=p+1;let A=1;for(p++;p<c.length&&A>0;)c[p]==="{"?A++:c[p]==="}"&&A--,p++;const Z=c.substring(y,p),ee=c.substring(v,p-1);l.push({type:j?"keyframes":"at-rule",rule:w,content:Z,inner:ee})}continue}const d=p;for(;p<c.length&&c[p]!=="{";)p++;if(p>=c.length)break;const h=c.substring(d,p).trim();if(!h){p++;continue}const g=p+1;let m=1;for(p++;p<c.length&&m>0;)c[p]==="{"?m++:c[p]==="}"&&m--,p++;const _=c.substring(g,p-1);l.push({type:"rule",selector:h,content:_.trim()})}return l},s=c=>{const l=c.trim();return/^(from|to|\d+(\.\d+)?%)$/.test(l)},r=c=>c.replace(/::v-deep\(/g,":deep(").replace(/::v-deep\s+/g,":deep(").replace(/\/deep\//g," ").replace(/>>>/g," ").replace(/(.*?):deep\(([^)]+)\)/g,(l,p,d)=>{const h=p.trim(),g=d.trim();return h?`${h}[${e}] ${g}`:g}),i=c=>{const l=c.trim();if(!l||l.includes(`[${e}]`)||/^(:root|:host|html|body)(\s|$|:|\.|\#|\[)/.test(l)||s(l))return l;const p=l.match(/^(.+?)((?:::?[\w-]+(?:\([^)]*\))?)*)\s*$/);if(p){const[,d,h=""]=p,g=d.trim();return g?`${g}[${e}]${h}`:l}return`${l}[${e}]`},o=c=>r(c).split(",").map(p=>i(p)).filter(p=>p.trim()).join(", "),a=c=>c.map(l=>{switch(l.type){case"simple-at-rule":return l.content;case"keyframes":return l.content;case"at-rule":try{const d=t(l.inner),h=a(d);return`${l.rule} { ${h} }`}catch{return l.content}case"rule":if(!l.selector||!l.content)return"";const p=o(l.selector);return p.trim()?`${p} { ${l.content} }`:"";default:return""}}).filter(l=>l.trim()).join(" "),u=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
|
+
`),l=t(c),p=a(l);return u(p)}catch(c){return console.error("CSS scoping failed:",c),console.error("Input CSS:",n),n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/(@keyframes\s+[^{]+\s*{[^{}]*(?:{[^}]*}[^{}]*)*})/g,l=>l).replace(/([^{}@]+)(?=\s*{)/g,l=>{const p=l.trim();return!p||p.startsWith("@")||p.includes(`[${e}]`)||s(p)?l:`${p}[${e}]`})}}const ht=750;function Te(n,e,t){let s;typeof n<"u"?s=n.innerWidth||n.document.documentElement.clientWidth:(console.warn("无法获取屏幕宽度,使用默认值375"),s=375);const r=t||ht;return e*s/r}function Me(n,e){let t=!1,s=!1,r=!1,i="";for(let o=0;o<e.length;o++){const a=e[o];if(a==="'"&&!s&&!r?t=!t:a==='"'&&!t&&!r?s=!s:e.substr(o,4).toLowerCase()==="url("&&!t&&!s?r=!0:a===")"&&r&&(r=!1),!t&&!s&&!r){const u=e.substr(o).match(/^(-?\d+(?:\.\d+)?)\s*rpx/);if(u){const c=u[1],l=parseFloat(c),d=`${Te(n,l).toFixed(6).replace(/\.?0+$/,"")}px`;i+=d,o+=u[0].length-1;continue}}i+=a}return i}function ue(n){return f.isString(n)?n:JSON.stringify(n)}function Q(n,e,t,s=!1){const r=n.CSSStyleSheet,i=s?`data-v-${e}`:e,o=n.__uniConfig?Me(n,t):t,a=s?Fe(o,i):o,u=!!n.__uniConfig;if(r.prototype.replaceSync&&!u){const c=new r;c.id=e,c.replaceSync(a);const l=n.document,p=l.adoptedStyleSheets,d=Array.from(p).filter(h=>h.id!==e);l.adoptedStyleSheets=[...d,c]}else{const c=n.document;let l=c.getElementById(e);l?l.innerHTML=a:(l=c.createElement("style"),l.id=e,l.innerHTML=a,c.head.appendChild(l))}}function mt(n){const e=n.adoptedStyleSheets||[];let t="";if(e.forEach(s=>{try{for(const r of s.cssRules)t+=r.cssText+`
|
|
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 Oe(n,e){const t=await window.fetch(e).then(s=>s.text()).catch(()=>"");t&&Q(window,n,t)}function pe(n,e=window){const t=e.document,s=e.document.head;for(const r of n)if(!t.getElementById(r)){const o=t.createElement("link");o.rel="stylesheet",o.id=r,o.href=r,s.appendChild(o)}}async function fe(n,e,t=window){const s=t.document,r=t.document.head;let i=t[e];return i?i.default||i:new Promise((o,a)=>{for(const u of n){const c=s.createElement("script");c.src=u,c.onload=()=>{i=t[e],i?o(i.default||i):a(null)},c.onerror=l=>{a(l)},r.appendChild(c)}})}function De(n){return f.isFunction(n)&&Object.getOwnPropertyNames(n.prototype||{}).length===0||f.isFunction(n?.install)}function xe(n){return be.includes(n)}function ke(n){return le.includes(n)}function k(n=window){const e=window?.Mock;if(e)return e;const t=n?.Mock;if(t&&window)return window.Mock=t,t}function gt(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 He(n){return/^\([\s\S]*\)/.test(n.trim())}function Ne(n){return/\w+\([\s\S]*\)$/.test(n.trim())}function Le(n){return n.includes("=")}function _t(n){if(typeof window>"u")return;const e=window[0]||window;if(e.__simulator__)try{const t=e.__simulator__.engine.provider.errorHandler;t&&t(n)}catch{}}function H(n,e,t=!1,s=!1,r=!1){try{const i=['"use strict";',"var __self = arguments[0];"];i.push("return ");let o=(n.value||"").trim();r||(o=o.replace(/this(\W|$)/g,(u,c)=>`__self${c}`)),o=i.join(`
|
|
10
10
|
`)+o;const a=r?`
|
|
11
11
|
${o}
|
|
12
|
-
`:`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",a)(e)}catch(i){if(f.logger.error("parseExpression.error",i,n,e?.__self??e),_t(i),s)throw i}}function R(n,e,t=!1,s=!1,r=!1){const i=H(n,e,t,s,r);if(typeof i!="function"&&(f.logger.error("parseFunction.error","not a function",n,e?.__self??e),s))throw new Error(`"${n.value}" not a function`);return i}function b(n){return n&&n.type==="JSExpression"}function C(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function Ue(n){return b(n)||C(n)}function vt(n){return Ue(n)?n.value:JSON.stringify(n)}const yt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},fe=Symbol("access");class Y{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},yt,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:i}=this.options;this.setData(e),this.data&&(f.storage.save(t,e,{type:"local",prefix:s}),r&&f.cookie.set(i,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(i=>s[i]||s[t+"."+i])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return f.toArray(e).some(i=>s[i]||s[t+"."+i])}install(e){e.config.globalProperties.$access=this,e.provide(fe,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===x){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 qe(){return $.inject(fe,null)}function St(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:i,useTitle:o,alert:a}=n;let u=null;return{request:f.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:l=>l.data?.code===0||!!l.data?.success,failMessage:!0,showError:l=>{e&&e(l||"未知错误")},showLoading:()=>{u&&u.close(),t&&(u=t())},hideLoading:()=>{u&&(u.close(),u=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:o,alert:a,startupComponent:r,access:i?new Y({alert:a,...i}):void 0}}function wt(n={}){return new Y(n)}function Be(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?H(n.headers,{},!0):void 0,i={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(o,a)=>(delete i.data,s.send(f.merge(i,a||{},{data:o})))}}function Je(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(i,o)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,i,o)}}function Ke(n=[],e=[],t){const s={};for(const r of n){const i=Be(r,t);s[r.id]=i,s[r.name]=i}for(const r of e)s[r.id]=Je(r,t);return s}async function Ge(n=[],e=window){const t=k(e);t&&(de(e),n.forEach(s=>ze(t,s)))}function Ve(n,e=window){const t=C(n.mockTemplate)&&n.mockTemplate.value?R(n.mockTemplate,{},!0):void 0,s=k(e);return async(...r)=>{let i={};if(t)try{i=await t.apply(t,r)}catch(o){f.logger.warn("模拟数据模版异常",o)}return s?.mock(i)}}function ze(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,i=f.pathToRegexp(`(.*)${r}(.*)`),o=f.pathToRegexpMatch(r,{decode:decodeURIComponent}),a=H(s,{},!0);n.mock(i,u=>{const c=f.url.parse(u.url)||{},l=u.body instanceof FormData?f.formDataToJson(u.body):u.body,p=f.isUrl(u.url)?new URL(u.url).pathname:u.url.split("?")[0],d=o(p)?.params;Object.assign(u,{data:l,params:d,query:c});try{return n.mock(a(u))}catch(h){return console.warn("[mockApi]",i,u,h),null}})}catch(r){console.warn("mockApi",r)}}function de(n=window){const e=k(n);e&&(e._mocked={})}class We{__id=null;__mode;__instance=null;__contextRefs={};__refs={};__refCaches={};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=W){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.__refCaches={},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.onBeforeUpdate(()=>{this.__reset()})}__proxy(){if(!this.__instance)return;const e=this.__instance;Ee.forEach(t=>{this[t]=e[t]||e._?.[t.replace("$","")]||null})}__reset(){this.__refs={},this.__refCaches={},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 R({type:s,value:r},this)}else return R(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 H({type:s,value:r},this)}else return H(e,this)}__ref(e=null,t){if(this.__mode===S.VNode)return;e&&e!==this.__id&&(this.__contextRefs[e]=this);let s=e?this.__refCaches[e]:null;return s||(s=async r=>{await f.delay(0);let i=r?.$vtjEl||r?.$el||r?._?.vnode?.el||r;if(!i){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return i.nodeType===3&&i.nextSibling&&(i=i.nextSibling),i.__vtj__=e,S.Design===this.__mode&&(i.__context__=this,i.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,r)),typeof t=="function"?t(r):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,r)),r},e&&(this.__refCaches[e]=s),s)}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const i=new Set([].concat(r,s));return Array.from(i)}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 V(n){const{Vue:e=W,mode:t=S.Runtime,components:s={},libs:r={},apis:i={},loader:o}=n,a=e.computed(()=>n.dsl),u={$components:s,$libs:r,$apis:i},c=new We({mode:t,dsl:a.value,attrs:u}),l=e.defineComponent({name:a.value.name,__scopeId:a.value.id?`data-v-${a.value.id}`:void 0,props:{...$t(a.value.props??[],c)},async setup(p={}){c.$props=p,c.props=p,a.value.id&&Q(n.window||window,a.value.id,a.value.css||"",!0),c.state=Ct(e,a.value.state??{},c);const d=bt(e,a.value.computed??{},c),h=jt(a.value.methods??{},c),g=Rt(e,a.value.inject,c);for(const[y,w]of Object.entries(g||{}))g[y]=e.inject(y,w);const m=Qe(a.value.dataSources||{},c),_={...g,...d,...h,...m};return c.setup(_,e),Pt(e,a.value.watch??[],c),{vtj:c,state:c.state,...p,...d,...h}},emits:Et(a.value.emits),expose:["vtj",...a.value.expose||[]],render(){if(!a.value.nodes)return null;const p=a.value.nodes||[];if(p.length===1)return M(p[0],c,e,o,p);{const d=p.map(h=>M(h,c,e,o,p));return e.createVNode("div",{},d)}},...At(a.value.lifeCycles??{},c)});return{renderer:e.markRaw(l),context:c}}function Et(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function $t(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(i=>Ce[i]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:b(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 Ct(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let i=e[r];return b(i)?i=t.__parseExpression(i):C(i)&&(i=t.__parseFunction(i)),s[r]=i,s},{}))}function bt(n,e,t){return Object.entries(e??{}).reduce((s,[r,i])=>(s[r]=n.computed(t.__parseFunction(i)),s),{})}function jt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}function Rt(n,e=[],t){return e.reduce((s,r)=>{const{name:i,from:o}=r||{};r.default;const a=b(o)?t.__parseExpression(o)||i:o??i,u=b(r.default)?t.__parseExpression(r.default):r.default??null;return s[i]=n.inject(a,u),s},{})}function Qe(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=Ve(r);else if(r.ref){const i=e.$apis[r.ref],o=C(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...a)=>{const u=await i.apply(e,a);return o?o(u):u}}return t},{})}function Pt(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function At(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>{const i=e.__parseFunction(r);return t[s]=async()=>{f.isFunction(i)&&(await f.delay(0),await i())},t},{})}class It{__props={};__events={};__nodes={};constructor(){}setProps(e,t){this.__props[e]=t}getProps(e){return this.__props[e]}loadProps(e,t){const s=e?this.getProps(e):null;return s||(e&&this.setProps(e,t),t)}setEvents(e,t){}getEvents(e){return this.__events[e]}loadEvents(e,t){const s=e?this.getEvents(e):null;return s||(e&&this.setEvents(e,t),t)}setNode(e,t){this.__nodes[e]=t}getNode(e){return this.__nodes[e]}loadNode(e,t){const s=e?this.getNode(e):null;return s||(e&&this.setNode(e,t),t)}isEqual(e,t){return f.isEqual(e,t)}clear(){this.__props={},this.__events={},this.__nodes={}}}const O=new It,Ye=new f.Queue;let ne=[],T={},L={};const Xe=(n,e)=>e;async function he(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(a=>J(a));if(r.length===0||!s)return null;const i=t.filter(a=>B(a));return i.length&&ue(i,e),await pe(r,s,e).catch(a=>(console.warn("loadScriptUrl error",r,s,a),null))}function z(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(ne.forEach(r=>{delete s.window[r]}),ne=[]),(r,i,o,a=W)=>{if(!o||typeof o=="string")return i;let u="";if(o.type==="Schema"&&o.id)return u=o.id+"_"+r,L[u]||(L[u]=a.defineAsyncComponent(async()=>{const c=T[o.id]||await Ye.add(o.id,()=>e(o.id));return c&&(c.name=i,T[o.id]=c),c?V({Vue:a,mode:S.Runtime,...s,dsl:f.cloneDeep(c),loader:z(n)}).renderer:null}));if(o.type==="UrlSchema"&&o.url)return u=o.url+"_"+r,L[u]||(L[u]=a.defineAsyncComponent(async()=>{const c=T[o.url]||await t(o.url);return c&&(c.name=i,T[o.url]=c),c?V({...s,Vue:a,dsl:f.cloneDeep(c),mode:S.Runtime,loader:z(n)}).renderer:null}));if(o.type==="Plugin"){let c=o.library?T[o.library]:null;return c||(o.library&&ne.push(o.library),c=T[o.library||Symbol()]=a.defineAsyncComponent(async()=>{const l=await he(o,s.window);return l||(console.warn("getPlugin result is null",o),null)}),c)}return i}}function Ft(){T={},L={},Ye.clearAllCache(),O.clear()}function M(n,e,t=W,s=Xe,r=[],i=!1,o=0){if(!n||!n.name||n.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:u=null,directives:c=[]}=n,{vIf:l,vElseIf:p,vElse:d,vFor:h,vShow:g,vModels:m,vBind:_,vHtml:y,others:w}=Ze(c);if(!i&&(p||d))return null;if(l&&!Mt(l,e))return Nt(n,e,t,s,r);const j=(v,A=0)=>{const Z=v.$components,ee=(()=>{if(n.name==="component")return Ot(v,n.props?.is);if(n.name==="slot")return n.name;const P=s(`${n.id}_${A}`,n.name,n.from,t);return f.isString(P)?xe(P)||ke(P)?P:Z[P]??a?.app?.component(P)??P:P})(),I=Dt(u,n.props??{},v),rt=Ht(t,n.id,n.events??{},v);if(n.name==="slot")return Lt(t,n,I,v,s);_&&Object.assign(I,v.__parseExpression(_.value)),g&&(I.style=Object.assign(I.style??{},qt(g,v))),y&&Object.assign(I,Bt(y,v)),m.forEach(P=>{ce.includes(n.name)?Object.assign(I,Jt(P,v)):Object.assign(I,Kt(t,P,v))});const it=Gt(t,n.children??[],v,s,n),ye=v?.__id?`data-v-${v.__id}`:void 0,ot=ye?{[ye]:""}:{},at=v.__mode===S.Design?{"data-vtj":u}:{},K=`${u}_${A}`,te={key:K,...ot,...at,...I,...rt};O.isEqual(te,O.getNode(K))||O.setNode(K,te);let se=t.createVNode(ee,O.getNode(K)||te||{},it);const Se=a?Tt(a,w,v):[];return Se.length&&(se=t.withDirectives(se,Se)),se};return h?Wt(h,j,e):j(e,o)}function Tt(n,e,t){const s=n.app;return e.map(r=>{const i=typeof r.name=="string"?s.directive(r.name):t.__parseExpression(r.name);if(!i)return null;const o=[i];return r.value&&o.push(t.__parseExpression(r.value)),r.arg&&o.push(r.arg),r.modifiers&&o.push(r.modifiers),o}).filter(r=>!!r)}function Ze(n=[]){const e=n.find(l=>f.camelCase(l.name)==="vIf"),t=n.find(l=>f.camelCase(l.name)==="vElseIf"),s=n.find(l=>f.camelCase(l.name)==="vElse"),r=n.find(l=>f.camelCase(l.name)==="vFor"),i=n.find(l=>f.camelCase(l.name)==="vShow"),o=n.find(l=>f.camelCase(l.name)==="vBind"),a=n.find(l=>f.camelCase(l.name)==="vHtml"),u=n.filter(l=>f.camelCase(l.name)==="vModel"),c=n.filter(l=>!$e.includes(f.camelCase(l.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:i,vModels:u,vBind:o,others:c,vHtml:a}}function Mt(n,e){return!!e.__parseExpression(n.value)}function Ot(n,e){return e?b(e)?n.__parseExpression(e):e:"div"}function Dt(n,e,t){const s=oe(e,t);return s.ref=t.__ref(n,s.ref),s}function oe(n,e){return b(n)?e.__parseExpression(n):C(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>oe(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=oe(r,e),t},{}):n}function xt(n,e){return t=>{t?.key?.toLowerCase()===e.toLowerCase()&&n(t)}}function kt(n){return He(n.value)?n:Ne(n.value)?{type:"JSFunction",value:`(...args) => (() => {
|
|
12
|
+
`:`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",a)(e)}catch(i){if(f.logger.error("parseExpression.error",i,n,e?.__self??e),_t(i),s)throw i}}function R(n,e,t=!1,s=!1,r=!1){const i=H(n,e,t,s,r);if(typeof i!="function"&&(f.logger.error("parseFunction.error","not a function",n,e?.__self??e),s))throw new Error(`"${n.value}" not a function`);return i}function b(n){return n&&n.type==="JSExpression"}function C(n){return typeof n=="object"&&n&&n.type==="JSFunction"}function Ue(n){return b(n)||C(n)}function vt(n){return Ue(n)?n.value:JSON.stringify(n)}const yt={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",appName:"",statusKey:"code"},de=Symbol("access");class Y{options;data=null;mode=S.Raw;interceptResponse=!0;isTipShowing=!1;constructor(e){this.options=Object.assign({},yt,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:i}=this.options;this.setData(e),this.data&&(f.storage.save(t,e,{type:"local",prefix:s}),r&&f.cookie.set(i,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(i=>s[i]||s[t+"."+i])}some(e){const{appName:t}=this.options,{permissions:s={}}=this.data||{};return f.toArray(e).some(i=>s[i]||s[t+"."+i])}install(e){e.config.globalProperties.$access=this,e.provide(de,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===x){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 qe(){return $.inject(de,null)}function St(n={}){const{notify:e,loading:t,settings:s={},Startup:r,access:i,useTitle:o,alert:a}=n;let u=null;return{request:f.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:l=>l.data?.code===0||!!l.data?.success,failMessage:!0,showError:l=>{e&&e(l||"未知错误")},showLoading:()=>{u&&u.close(),t&&(u=t())},hideLoading:()=>{u&&(u.close(),u=null)},...s}}),jsonp:f.jsonp,notify:e,loading:t,useTitle:o,alert:a,startupComponent:r,access:i?new Y({alert:a,...i}):void 0}}function wt(n={}){return new Y(n)}function Be(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?H(n.headers,{},!0):void 0,i={url:n.url,method:n.method,settings:{...n.settings,headers:r}};return(o,a)=>(delete i.data,s.send(f.merge(i,a||{},{data:o})))}}function Je(n,e){const{metaQuery:t}=e;if(!t)return;const{code:s,queryCode:r}=n;return(i,o)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(s,r,i,o)}}function Ke(n=[],e=[],t){const s={};for(const r of n){const i=Be(r,t);s[r.id]=i,s[r.name]=i}for(const r of e)s[r.id]=Je(r,t);return s}async function Ge(n=[],e=window){const t=k(e);t&&(he(e),n.forEach(s=>Ve(t,s)))}function ze(n,e=window){const t=C(n.mockTemplate)&&n.mockTemplate.value?R(n.mockTemplate,{},!0):void 0,s=k(e);return async(...r)=>{let i={};if(t)try{i=await t.apply(t,r)}catch(o){f.logger.warn("模拟数据模版异常",o)}return s?.mock(i)}}function Ve(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,i=f.pathToRegexp(`(.*)${r}(.*)`),o=f.pathToRegexpMatch(r,{decode:decodeURIComponent}),a=H(s,{},!0);n.mock(i,u=>{const c=f.url.parse(u.url)||{},l=u.body instanceof FormData?f.formDataToJson(u.body):u.body,p=f.isUrl(u.url)?new URL(u.url).pathname:u.url.split("?")[0],d=o(p)?.params;Object.assign(u,{data:l,params:d,query:c});try{return n.mock(a(u))}catch(h){return console.warn("[mockApi]",i,u,h),null}})}catch(r){console.warn("mockApi",r)}}function he(n=window){const e=k(n);e&&(e._mocked={})}class We{__id=null;__mode;__instance=null;__contextRefs={};__refs={};__refCaches={};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=W){const s=t.getCurrentInstance();if(!s)return;this.__refs={},this.__refCaches={},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(){if(!this.__instance)return;const e=this.__instance;oe.forEach(t=>{this[t]=e[t]||e._?.[t.replace("$","")]||null})}__cleanup(){oe.forEach(e=>{this[e]=null}),this.__reset()}__reset(){this.__refs={},this.__refCaches={},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 R({type:s,value:r},this)}else return R(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 H({type:s,value:r},this)}else return H(e,this)}__ref(e=null,t){if(this.__mode===S.VNode)return;e&&e!==this.__id&&(this.__contextRefs[e]=this);let s=e?this.__refCaches[e]:null;return s||(s=async r=>{await f.delay(0);let i=r?.$vtjEl||r?.$el||r?._?.vnode?.el||r;if(!i){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}return i.nodeType===3&&i.nextSibling&&(i=i.nextSibling),i.__vtj__=e,S.Design===this.__mode&&(i.__context__=this,i.draggable=!0),e&&(this.__refs[e]=this.__getRefEl(this.__refs,e,r)),typeof t=="function"?t(r):t&&(this.$refs[t]=this.__getRefEl(this.$refs,t,r)),r},e&&(this.__refCaches[e]=s),s)}__getRefEl(e,t,s){const r=e[t];if(r&&s!==r){const i=new Set([].concat(r,s));return Array.from(i)}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 z(n){const{Vue:e=W,mode:t=S.Runtime,components:s={},libs:r={},apis:i={},loader:o}=n,a=e.computed(()=>n.dsl),u={$components:s,$libs:r,$apis:i},c=new We({mode:t,dsl:a.value,attrs:u}),l=e.defineComponent({name:a.value.name,__scopeId:a.value.id?`data-v-${a.value.id}`:void 0,props:{...$t(a.value.props??[],c)},async setup(p={}){c.$props=p,c.props=p,a.value.id&&Q(n.window||window,a.value.id,a.value.css||"",!0),c.state=Ct(e,a.value.state??{},c);const d=bt(e,a.value.computed??{},c),h=jt(a.value.methods??{},c),g=Rt(e,a.value.inject,c);for(const[y,w]of Object.entries(g||{}))g[y]=e.inject(y,w);const m=Qe(a.value.dataSources||{},c),_={...g,...d,...h,...m};return c.setup(_,e),Pt(e,a.value.watch??[],c),{vtj:c,state:c.state,...p,...d,...h}},emits:Et(a.value.emits),expose:["vtj",...a.value.expose||[]],render(){if(!a.value.nodes)return null;const p=a.value.nodes||[];if(p.length===1)return M(p[0],c,e,o,p);{const d=p.map(h=>M(h,c,e,o,p));return e.createVNode("div",{},d)}},...At(a.value.lifeCycles??{},c)});return{renderer:e.markRaw(l),context:c}}function Et(n=[]){return n.map(e=>f.isString(e)?e:e.name)}function $t(n=[],e){const t=s=>s?(Array.isArray(s)?s:[s]).map(i=>Ce[i]):void 0;return n.map(s=>f.isString(s)?{name:s}:{name:s.name,type:s.type,required:s.required,default:b(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 Ct(n,e,t){return n.reactive(Object.keys(e||{}).reduce((s,r)=>{let i=e[r];return b(i)?i=t.__parseExpression(i):C(i)&&(i=t.__parseFunction(i)),s[r]=i,s},{}))}function bt(n,e,t){return Object.entries(e??{}).reduce((s,[r,i])=>(s[r]=n.computed(t.__parseFunction(i)),s),{})}function jt(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>(t[s]=e.__parseFunction(r),t),{})}function Rt(n,e=[],t){return e.reduce((s,r)=>{const{name:i,from:o}=r||{};r.default;const a=b(o)?t.__parseExpression(o)||i:o??i,u=b(r.default)?t.__parseExpression(r.default):r.default??null;return s[i]=n.inject(a,u),s},{})}function Qe(n,e){return Object.keys(n).reduce((t,s)=>{const r=n[s];if(r.type==="mock")t[s]=ze(r);else if(r.ref){const i=e.$apis[r.ref],o=C(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;t[s]=async(...a)=>{const u=await i.apply(e,a);return o?o(u):u}}return t},{})}function Pt(n,e=[],t){e.forEach(s=>{n.watch(t.__parseExpression(s.source),t.__parseFunction(s.handler),{deep:s.deep,immediate:s.immediate})})}function At(n,e){return Object.entries(n??{}).reduce((t,[s,r])=>{const i=e.__parseFunction(r);return t[s]=async()=>{f.isFunction(i)&&(await f.delay(0),await i())},t},{})}class It{__props={};__events={};__nodes={};constructor(){}setProps(e,t){this.__props[e]=t}getProps(e){return this.__props[e]}loadProps(e,t){const s=e?this.getProps(e):null;return s||(e&&this.setProps(e,t),t)}setEvents(e,t){}getEvents(e){return this.__events[e]}loadEvents(e,t){const s=e?this.getEvents(e):null;return s||(e&&this.setEvents(e,t),t)}setNode(e,t){this.__nodes[e]=t}getNode(e){return this.__nodes[e]}loadNode(e,t){const s=e?this.getNode(e):null;return s||(e&&this.setNode(e,t),t)}isEqual(e,t){return f.isEqual(e,t)}clear(){this.__props={},this.__events={},this.__nodes={}}}const O=new It,Ye=new f.Queue;let ne=[],T={},L={};const Xe=(n,e)=>e;async function me(n,e=window){const{urls:t=[],library:s}=n,r=t.filter(a=>J(a));if(r.length===0||!s)return null;const i=t.filter(a=>B(a));return i.length&&pe(i,e),await fe(r,s,e).catch(a=>(console.warn("loadScriptUrl error",r,s,a),null))}function V(n){const{getDsl:e,getDslByUrl:t,options:s}=n;return s.window&&(ne.forEach(r=>{delete s.window[r]}),ne=[]),(r,i,o,a=W)=>{if(!o||typeof o=="string")return i;let u="";if(o.type==="Schema"&&o.id)return u=o.id+"_"+r,L[u]||(L[u]=a.defineAsyncComponent(async()=>{const c=T[o.id]||await Ye.add(o.id,()=>e(o.id));return c&&(c.name=i,T[o.id]=c),c?z({Vue:a,mode:S.Runtime,...s,dsl:f.cloneDeep(c),loader:V(n)}).renderer:null}));if(o.type==="UrlSchema"&&o.url)return u=o.url+"_"+r,L[u]||(L[u]=a.defineAsyncComponent(async()=>{const c=T[o.url]||await t(o.url);return c&&(c.name=i,T[o.url]=c),c?z({...s,Vue:a,dsl:f.cloneDeep(c),mode:S.Runtime,loader:V(n)}).renderer:null}));if(o.type==="Plugin"){let c=o.library?T[o.library]:null;return c||(o.library&&ne.push(o.library),c=T[o.library||Symbol()]=a.defineAsyncComponent(async()=>{const l=await me(o,s.window);return l||(console.warn("getPlugin result is null",o),null)}),c)}return i}}function Ft(){T={},L={},Ye.clearAllCache(),O.clear()}function M(n,e,t=W,s=Xe,r=[],i=!1,o=0){if(!n||!n.name||n.invisible)return null;const a=t.getCurrentInstance()?.appContext,{id:u=null,directives:c=[]}=n,{vIf:l,vElseIf:p,vElse:d,vFor:h,vShow:g,vModels:m,vBind:_,vHtml:y,others:w}=Ze(c);if(!i&&(p||d))return null;if(l&&!Mt(l,e))return Nt(n,e,t,s,r);const j=(v,A=0)=>{const Z=v.$components,ee=(()=>{if(n.name==="component")return Ot(v,n.props?.is);if(n.name==="slot")return n.name;const P=s(`${n.id}_${A}`,n.name,n.from,t);return f.isString(P)?xe(P)||ke(P)?P:Z[P]??a?.app?.component(P)??P:P})(),I=Dt(u,n.props??{},v),rt=Ht(t,n.id,n.events??{},v);if(n.name==="slot")return Lt(t,n,I,v,s);_&&Object.assign(I,v.__parseExpression(_.value)),g&&(I.style=Object.assign(I.style??{},qt(g,v))),y&&Object.assign(I,Bt(y,v)),m.forEach(P=>{le.includes(n.name)?Object.assign(I,Jt(P,v)):Object.assign(I,Kt(t,P,v))});const it=Gt(t,n.children??[],v,s,n),Se=v?.__id?`data-v-${v.__id}`:void 0,ot=Se?{[Se]:""}:{},at=v.__mode===S.Design?{"data-vtj":u}:{},K=`${u}_${A}`,te={key:K,...ot,...at,...I,...rt};O.isEqual(te,O.getNode(K))||O.setNode(K,te);let se=t.createVNode(ee,O.getNode(K)||te||{},it);const we=a?Tt(a,w,v):[];return we.length&&(se=t.withDirectives(se,we)),se};return h?Wt(h,j,e):j(e,o)}function Tt(n,e,t){const s=n.app;return e.map(r=>{const i=typeof r.name=="string"?s.directive(r.name):t.__parseExpression(r.name);if(!i)return null;const o=[i];return r.value&&o.push(t.__parseExpression(r.value)),r.arg&&o.push(r.arg),r.modifiers&&o.push(r.modifiers),o}).filter(r=>!!r)}function Ze(n=[]){const e=n.find(l=>f.camelCase(l.name)==="vIf"),t=n.find(l=>f.camelCase(l.name)==="vElseIf"),s=n.find(l=>f.camelCase(l.name)==="vElse"),r=n.find(l=>f.camelCase(l.name)==="vFor"),i=n.find(l=>f.camelCase(l.name)==="vShow"),o=n.find(l=>f.camelCase(l.name)==="vBind"),a=n.find(l=>f.camelCase(l.name)==="vHtml"),u=n.filter(l=>f.camelCase(l.name)==="vModel"),c=n.filter(l=>!$e.includes(f.camelCase(l.name)));return{vIf:e,vElseIf:t,vElse:s,vFor:r,vShow:i,vModels:u,vBind:o,others:c,vHtml:a}}function Mt(n,e){return!!e.__parseExpression(n.value)}function Ot(n,e){return e?b(e)?n.__parseExpression(e):e:"div"}function Dt(n,e,t){const s=ae(e,t);return s.ref=t.__ref(n,s.ref),s}function ae(n,e){return b(n)?e.__parseExpression(n):C(n)?e.__parseFunction(n):Array.isArray(n)?n.map(t=>ae(t,e)):typeof n=="object"?Object.keys(n||{}).reduce((t,s)=>{let r=n[s];return t[s]=ae(r,e),t},{}):n}function xt(n,e){return t=>{t?.key?.toLowerCase()===e.toLowerCase()&&n(t)}}function kt(n){return He(n.value)?n:Ne(n.value)?{type:"JSFunction",value:`(...args) => (() => {
|
|
13
13
|
return (($event) => {
|
|
14
14
|
${n.value}
|
|
15
15
|
}).apply(this, args);
|
|
16
|
-
})()`}:Le(n.value)?{type:"JSFunction",value:`() => { ${n.value}}`}:n}function Ht(n,e,t,s){const r=["passive","capture","once"],i={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(t||{}).reduce((a,u)=>{const c=t[u],l=
|
|
16
|
+
})()`}:Le(n.value)?{type:"JSFunction",value:`() => { ${n.value}}`}:n}function Ht(n,e,t,s){const r=["passive","capture","once"],i={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(t||{}).reduce((a,u)=>{const c=t[u],l=ge(c.modifiers),p=l.find(g=>r.includes(g)),d="on"+f.upperFirstCamelCase(u)+(p&&i[p]||""),h=c.handler?s.__parseFunction(kt(c.handler)):null;return h&&(a[d]=n.withModifiers(l.includes("enter")?xt(h,"enter"):h,l)),a},{})}function Nt(n,e,t,s,r=[]){let i=r.findIndex(o=>o.id===n.id);for(let o=++i;o<r.length;o++){const{directives:a=[]}=r[o],{vElseIf:u,vElse:c}=Ze(a);if(u){if(e.__parseExpression(u.value))return M(r[o],e,t,s,r,!0);continue}if(c)return M(r[o],e,t,s,r,!0)}return null}function ge(n={},e=!1){const t=Object.keys(n);return e?t.map(s=>"."+s):t}function Lt(n,e,t,s,r){const{children:i}=e,o=Ut(e,s),a=s.$slots?.[o.name];return a?a(t):i?f.isString(i)?n.createTextVNode(i):b(i)?n.createTextVNode(ue(s.__parseExpression(i))):Array.isArray(i)?i.map((u,c)=>M(u,s,n,r,i,!1,c)):null:null}function Ut(n,e){const{props:t}=n,s=t?.name||"default";return{name:b(s)?e.__parseExpression(s):s,params:[]}}function qt(n,e){return e.__parseExpression(n.value)?{}:{display:"none"}}function Bt(n,e){return{innerHTML:e.__parseExpression(n.value)||""}}function Jt(n,e){const t={type:"JSFunction",value:n.value?.value?`(v) => {
|
|
17
17
|
${n.value.value} = v?.target.value;
|
|
18
18
|
}`:"(v) => {}"};return{[b(n.arg)?e.__parseExpression(n.arg):n.arg||"value"]:e.__parseExpression(n.value),onInput:e.__parseFunction(t)}}function Kt(n,e,t){const s={type:"JSFunction",value:e.value?.value?`(v) => {
|
|
19
19
|
${e.value.value} = v;
|
|
20
|
-
}`:"(v) => {}"},r=t.__parseFunction(s),i=me(b(e.modifiers)?t.__parseExpression(e.modifiers):e.modifiers),o=b(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[o]:t.__parseExpression(e.value),[`onUpdate:${o}`]:i.length&&r?n.withModifiers(r,i):r}}function Gt(n,e,t,s,r){if(!e)return null;if(f.isString(e))return{default:()=>e};if(b(e))return{default:()=>le(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const i=Vt(e),o=(a,u)=>!a||!r?{}:r?.id&&Object.keys(a).length?u?{[u]:a}:{[`scope_${r.id}`]:a}:u?{[u]:Object.create(null)}:{};return Object.entries(i).reduce((a,[u,{nodes:c,params:l,scope:p}])=>(a[u]=d=>{const h=l.length?f.pick(d??{},l):o(d,p);return c.map((g,m)=>M(g,t.__clone(h),n,s,c,!1,m))},a),{})}return null}function Vt(n){const e={};for(const t of n){const s=zt(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 zt(n="default"){return f.isString(n)?{name:n,params:[],scope:""}:{params:[],scope:"",...n}}function Wt(n,e,t){const{value:s,iterator:r}=n,{item:i="item",index:o="index"}=r||{};let a=t.__parseExpression(s)||[];return Number.isInteger(a)&&(a=new Array(a).fill(!0).map((u,c)=>c+1)),Array.isArray(a)?a.map((u,c)=>e(t.__clone({[i]:u,[o]:c}),c)):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}const re=$.defineComponent({name:"VtjPageContainer",async setup(){const n=ve(),e=we.useRoute(),t=e.meta.__vtj__||e.params.id,s=t?n.getPage(t):n.getHomepage(),r=s?await n.getRenderComponent(s.id):null,i=$.ref(Symbol());if(s){Object.assign(e.meta,s.meta||{},{cache:s.cache});const{useTitle:o}=n?.adapter;if(o){const a=e.meta.title||s.title||"VTJ.PRO";o(a)}}return{provider:n,component:r,file:s,query:e.query,meta:e.meta,sid:i,route:e}},render(){const{component:n,query:e,sid:t}=this;return n?$.h(n,{...e,key:t}):$.h("div",{style:{padding:"10px"}},"找不到组件,组件不存在或未发布!")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),Qt=$.defineComponent({name:"VtjStartupContainer",render(){return $.h("div","page not found!")}});function q(n,e,t=[]){const s=[];for(const r of t){const{id:i,title:o,icon:a,children:u,hidden:c,layout:l}=r;if(l){const p=q(n,e,u||[]);s.push(...p)}else{const p={id:i,title:o,icon:a,hidden:c,url:`${n}/${e}/${i}`,children:u&&u.length?q(n,e,u):void 0};s.push(p)}}return s}function ge(n,e){if(!e)return n;let t=[];for(const s of n)if(s.children&&s.children.length){const r=ge(s.children,e);r.length&&(s.children=r,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function Yt(n){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=n||{},r=ve(),i=we.useRoute(),o=qe(),a=$.ref(!1),u=$.ref(!1),c=r.project,l=(h,g)=>{a.value=!h?.mask,u.value=g?.pure??!!h?.pure};$.watchEffect(()=>{const{name:h,params:g,meta:m}=i;if(h===x){const _=r.getPage(g.id);l(_,m)}else if(h===U){const _=r.getHomepage();l(_,m)}else{const _=m.__vtj__;if(_){const y=r.getPage(_);l(y,m)}else a.value=!m.mask,u.value=!!m.pure}});const p=q(e,t,c?.pages),d=c?.config;return{disabled:a,logo:d?.logo,themeSwitchable:d?.themeSwitchable,title:d?.title||c?.description||c?.name||"VTJ App",menus:s?p:ge(p,o),pure:u}}function ie(n,e){const{id:t,title:s,meta:r}=n,{name:i="page",prefix:o="",component:a,routeMeta:u}=e;return{name:t,path:`${o}${i}/${t}`,component:a,meta:{title:s,...u,...r,__vtj__:t}}}function ae(n){const{name:e="page",prefix:t="",pages:s=[],component:r,loader:i,routeMeta:o,homepage:a}=n,u=[];for(const c of s){const{id:l,title:p,dir:d,layout:h,children:g,meta:m}=c;if(d){const _=ae({name:e,prefix:t,component:r,routeMeta:o,homepage:a,loader:i,pages:g||[]});u.push(..._)}else if(h){const _=ae({name:e,prefix:t,component:r,routeMeta:o,homepage:a,loader:i,pages:g||[]}),y={name:`layout_${l}`,path:t,component:()=>i(l),meta:{title:p,...o,...m,__vtj__:l},children:_};u.push(y),u.push(ie(c,n))}else if(u.push(ie(c,n)),a===l){const _=ie(c,n);_.path="",_.name=`home_${l}`,u.push(_)}}return u}function Xt(n={},e){const{css:t,store:s,enhance:r}=n,{window:i,app:o,library:a={},adapter:u,mode:c}=e,{Pinia:l}=a;o.config.globalProperties.$libs=a,Q(i,"global-css",t||""),l&&s&&Zt(s,o,l),ts(o,u,n),!u.access&&n.access&&es(n.access,o,c,u),ss(o,n),r&&ns(r,o,a)}function Zt(n,e,t){const s=t.createPinia();if(e.use(s),C(n)&&n.value){const r=R(n,{},!1,!1,!0),i=t.defineStore("$store",r(e)||{});e.config.globalProperties.$store=i()}}function es(n,e,t,s){if(C(n)&&n.value){const r=R(n,{},!1,!1,!0),{alert:i,request:o}=s,a=new Y({alert:i,storagePrefix:"__VTJ_APP_",...r(e)}),u=e.config.globalProperties.$router;a.connect({mode:t,router:u,request:o}),e.use(a)}}function ts(n,e,t){if(!e.request)return;const{axios:s,request:r,response:i}=t;if(s&&C(s)&&s.value){const o=R(s,{},!1,!1,!0);e.request.setConfig(o(n))}if(r&&C(r)&&r.value){const o=R(r,{},!1,!1,!0),a=e.request;a.__unReq&&a.__unReq(),a.__unReq=e.request.useRequest(u=>o(u,n))}if(i&&C(i)&&i.value){const o=R(i,{},!1,!1,!0),a=e.request;a.__unRes&&a.__unRes(),a.__unRes=e.request.useResponse(u=>o(u,n))}}function ss(n,e){const{beforeEach:t,afterEach:s}=e,r=n.config.globalProperties.$router;if(t&&C(t)&&t.value){const i=R(t,{},!1,!1,!0);r&&r.beforeEach((o,a,u)=>i(o,a,u,n))}if(s&&C(s)&&s.value){const i=R(s,{},!1,!1,!0);r&&r.afterEach((o,a,u)=>i(o,a,u,n))}}function ns(n,e,t={}){C(n)&&n.value&&R(n,{},!1,!1,!0)(e,t)}function rs(n,e,t){if(!n||!e||!t)return;const{VueI18n:s}=e;if(s){const{locale:r,fallbackLocale:i,messages:o=[]}=t,a={};for(let c of o){const l=Object.keys(c).filter(p=>p!=="key");for(const p of l)a[p]||(a[p]={}),a[p][c.key]=c[p]}const u=s.createI18n({legacy:!1,locale:r,fallbackLocale:i,messages:a});n.use(u)}}const _e=Symbol("Provider");var et=(n=>(n.Production="production",n.Development="development",n))(et||{});class tt extends F.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=S.Raw,dependencies:r,materials:i,project:o={},adapter:a={},globals:u={},modules:c={},router:l=null,materialPath:p="./",nodeEnv:d="development"}=e;this.mode=s,this.modules=c,this.service=t,this.router=l,this.materialPath=p,this.nodeEnv=d,r&&(this.dependencies=r),i&&(this.materials=i),Object.assign(this.globals,u),Object.assign(this.adapter,a);const{access:h,request:g}=this.adapter;h&&h.connect({mode:s,router:l,request:g}),o&&s!==S.Design?this.load(o):this.project=o}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={};errorHandler=null;createMock(e){return async(...t)=>{let s={};if(e)try{s=await e.apply(e,t)}catch(i){f.logger.warn("模拟数据模版异常",i)}return k()?.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:i=[],env:o=[]}=this.project,a=window;a&&(a.CKEDITOR_VERSION=void 0),this.initEnv(o),this.mode===S.Raw?await this.loadDependencies(a):await this.loadAssets(a),this.initMock(a),this.apis=Ke(r,i,this.adapter),de(a),Ge(r,a),e.platform!=="uniapp"&&this.initRouter(),this.triggerReady()}initMock(e){const t=k(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:i,materialPath:o,nodeEnv:a,libraryLocales:u}=this,{libraryExports:c,libraryMap:l,materials:p,materialExports:d,materialMapLibrary:h,libraryLocaleMap:g}=Pe(t,o,a==="development");Object.assign(this.libraryLocaleMap,g);for(const m of c){const _=s[m],y=e[m];if(y)r[m]=y;else if(_)e[m]=r[m]=await _();else{const j=l[m]||[];for(const v of j)B(v)&&await Oe(v,f.url.append(v,{v:D})),J(v)&&await f.loadScript(f.url.append(v,{v:D}));r[m]=e[m]}const w=g[m];if(w){const j=s[w];u[w]=j?await j():e[w]}}if(a==="development"){for(const _ of p)await f.loadScript(f.url.append(_,{v:D}));const m=this.materials||{};for(const _ of d){const y=e[h[_]],w=y?.default||y,j=F.BUILT_IN_COMPONENTS[_];if(j)w&&j.forEach(v=>{i[v]=w[v]});else{const v=m[_]?(await m[_]()).default:e[_];v&&w&&(v.components||[]).forEach(A=>{i[A.name]=Ae(A,w)})}}}}initRouter(){const{router:e,project:t,options:s,adapter:r}=this;if(!e)return;const i=t?.platform==="uniapp"?"pages":"page",{routeAppendTo:o,pageRouteName:a=i,routeMeta:u}=s,c=o?"":"/",l={path:`${c}${a}/:id`,name:x,component:re},p=this.getHomepage(),d={path:c,name:U,component:p?re:r.startupComponent||Qt,meta:u};if(e.hasRoute(x)&&e.removeRoute(x),e.hasRoute(U)&&e.removeRoute(U),s.enableStaticRoute){const h=t?.pages||[];ae({name:a,prefix:c,pages:h,component:re,loader:this.getRenderComponent.bind(this),homepage:p?.id}).forEach(m=>{o?e.addRoute(o,m):e.addRoute(m)}),p||(o?e.addRoute(o,d):e.addRoute(d))}else o?(e.addRoute(o,l),e.addRoute(o,d)):(e.addRoute(l),e.addRoute(d))}setErrorHandler(e){e.config.errorHandler=f.debounce((t,s,r)=>{const i=s?.$options.name,o=typeof t=="string"?t:t?.message||t?.msg||"未知错误",a=`[ ${i} ] ${o} ${r}`;["getComputedStyle","ResizeObserver"].some(c=>a.includes(c))||(console.error("[VTJ Error]:",{err:t,instance:s,info:r},t?.stack),this.errorHandler&&this.errorHandler(t),this.adapter.notify&&this.adapter.notify(a,"组件渲染错误","error"))},300)}install(e){const{libraryLocaleMap:t,libraryLocales:s}=this,{libraryOptions:r={}}=this.options,i=e.config.globalProperties.installed||{};for(const[o,a]of Object.entries(this.library))if(!i[o]&&De(a)){const c={locale:s[t[o]]},l=r[o]||{},p={...c,...l};e.use(a,p),i[o]=!0}e.provide(_e,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&&this.setErrorHandler(e),e.config.globalProperties.installed=i}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,i=[])=>{for(const o of i){if(o.id===r)return o;if(o.children&&o.children.length){const a=s(r,o.children);if(a)return a}}};return s(e,t)||null}getFirstPage(){const{pages:e=[]}=this.project||{};if(!e.length)return null;const t=(s=[])=>{for(const r of s){if(r.type==="page"&&!r.dir&&!r.layout)return r;if(r.children&&r.children.length){const i=t(r.children);if(i)return i}}};return t(e)||null}getMenus(e="page",t=""){return q(t,e,this.project?.pages||[])}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):this.getFirstPage()}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:i,apis:o}=this,a={mode:i,Vue:s.Vue,components:r,libs:s,apis:o,window,...t},u=z({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:a});return V({...a,dsl:e,loader:u})}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:i=".vtj/vue"}=this.options,o=`${i}/${e}.vue`,a=this.modules[o]||this.modules[`/src/pages/${e}.vue`];return a?(await a())?.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 $.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return $.defineAsyncComponent(async()=>await he(e,window))}initGlobals(e,t){const s=Object.assign({adapter:this.adapter,window},t);Xt(e,s)}initI18n(e,t,s){rs(e,t,s)}initEnv(e=[]){this.env=e.reduce((t,s)=>(t[s.name]=s[this.nodeEnv],t),{})}}function is(n){const e=new tt(n);return{provider:e,onReady:s=>e.ready(s)}}function ve(n={}){const e=$.inject(_e,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 os(n,e=""){const{name:t,urls:s=[]}=n||{},r=s.map(a=>e+a),{css:i,js:o}=Ie(r);if(i.length&&ue(i),o.length)return await pe(o,t).catch(()=>{})}const st={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0},as=(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:st}),cs=(n,e="/__vtj__/api/uploader.json")=>async(t,s)=>await n.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...st,type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);function ls(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 X{constructor(e=f.request){this.req=e,this.api=as(e),this.uploader=cs(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(i=>je(i))[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(i=>i.data).catch(()=>null))}async genSource(e){return console.log("BaseService.genSource",e),""}}const E=new f.Storage({type:"local",expired:0,prefix:"__VTJ_"});class us extends X{init(e){const t=new F.ProjectModel(e),s=E.get(`project_${t.id}`),r=Object.assign(t.toDsl(),s||{});return E.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new F.ProjectModel(e);return E.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return E.save(`materials_${e.id}`,f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return E.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=E.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return E.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return E.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=E.get(`history_${e}`);if(t){const r=(t.items||[]).map(i=>i.id);this.removeHistoryItem(e,r),E.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=E.get(`history_${e}`),s=new F.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=E.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return E.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{E.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class nt extends X{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new F.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 F.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(i=>i.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new F.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 G=null;function ps(){return G||(G=new nt,G)}class fs extends X{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=pt;exports.ACCESS_KEY=fe;exports.Access=Y;exports.BUILD_IN_TAGS=be;exports.BUILT_IN_DIRECTIVES=$e;exports.BaseService=X;exports.CONTEXT_HOST=Ee;exports.Context=We;exports.ContextMode=S;exports.DATA_TYPES=Ce;exports.HOMEPAGE_ROUTE_NAME=U;exports.HTML_TAGS=ce;exports.JSCodeToString=vt;exports.LIFE_CYCLES_LIST=lt;exports.LocalService=fs;exports.MemoryService=nt;exports.NodeEnv=et;exports.PAGE_ROUTE_NAME=x;exports.Provider=tt;exports.REMOTE=ut;exports.StorageService=us;exports.VTJ_RENDERER_VERSION=D;exports.adoptStylesToInline=mt;exports.adoptedStyleSheets=Q;exports.clearLoaderCache=Ft;exports.compileScopedCSS=Fe;exports.convertCssRpx=Me;exports.createAccess=wt;exports.createAdapter=St;exports.createAssetScripts=ft;exports.createAssetsCss=dt;exports.createDataSources=Qe;exports.createLoader=z;exports.createMemoryService=ps;exports.createMenus=q;exports.createMetaApi=Je;exports.createMock=Ve;exports.createProvider=is;exports.createRenderer=V;exports.createSchemaApi=Be;exports.createSchemaApis=Ke;exports.createServiceRequest=ls;exports.defaultLoader=Xe;exports.fillBasePath=N;exports.getMock=k;exports.getModifiers=me;exports.getPlugin=he;exports.getRawComponent=Ae;exports.isArrowFunction=He;exports.isAssignment=Le;exports.isBuiltInTag=xe;exports.isCSSUrl=B;exports.isCallFunction=Ne;exports.isJSCode=Ue;exports.isJSExpression=b;exports.isJSFunction=C;exports.isJSON=je;exports.isJSUrl=J;exports.isNativeTag=ke;exports.isVuePlugin=De;exports.loadCss=Oe;exports.loadCssUrl=ue;exports.loadEnhance=os;exports.loadScriptUrl=pe;exports.menusFilter=ge;exports.mockApi=ze;exports.mockApis=Ge;exports.mockCleanup=de;exports.nodeCache=O;exports.nodeRender=M;exports.parseDeps=Pe;exports.parseExpression=H;exports.parseFunction=R;exports.parseUrls=Ie;exports.providerKey=_e;exports.removeProdFlag=Re;exports.rpxToPx=Te;exports.setupPageSetting=gt;exports.toString=le;exports.useAccess=qe;exports.useMask=Yt;exports.useProvider=ve;
|
|
20
|
+
}`:"(v) => {}"},r=t.__parseFunction(s),i=ge(b(e.modifiers)?t.__parseExpression(e.modifiers):e.modifiers),o=b(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[o]:t.__parseExpression(e.value),[`onUpdate:${o}`]:i.length&&r?n.withModifiers(r,i):r}}function Gt(n,e,t,s,r){if(!e)return null;if(f.isString(e))return{default:()=>e};if(b(e))return{default:()=>ue(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const i=zt(e),o=(a,u)=>!a||!r?{}:r?.id&&Object.keys(a).length?u?{[u]:a}:{[`scope_${r.id}`]:a}:u?{[u]:Object.create(null)}:{};return Object.entries(i).reduce((a,[u,{nodes:c,params:l,scope:p}])=>(a[u]=d=>{const h=l.length?f.pick(d??{},l):o(d,p);return c.map((g,m)=>M(g,t.__clone(h),n,s,c,!1,m))},a),{})}return null}function zt(n){const e={};for(const t of n){const s=Vt(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 Vt(n="default"){return f.isString(n)?{name:n,params:[],scope:""}:{params:[],scope:"",...n}}function Wt(n,e,t){const{value:s,iterator:r}=n,{item:i="item",index:o="index"}=r||{};let a=t.__parseExpression(s)||[];return Number.isInteger(a)&&(a=new Array(a).fill(!0).map((u,c)=>c+1)),Array.isArray(a)?a.map((u,c)=>e(t.__clone({[i]:u,[o]:c}),c)):(console.warn("[vForRender]:",`${s?.value} is not a Arrary`),[])}const re=$.defineComponent({name:"VtjPageContainer",async setup(){const n=ye(),e=Ee.useRoute(),t=e.meta.__vtj__||e.params.id,s=t?n.getPage(t):n.getHomepage(),r=s?await n.getRenderComponent(s.id):null,i=$.ref(Symbol());if(s){Object.assign(e.meta,s.meta||{},{cache:s.cache});const{useTitle:o}=n?.adapter;if(o){const a=e.meta.title||s.title||"VTJ.PRO";o(a)}}return{provider:n,component:r,file:s,query:e.query,meta:e.meta,sid:i,route:e}},render(){const{component:n,query:e,sid:t}=this;return n?$.h(n,{...e,key:t}):$.h("div",{style:{padding:"10px"}},"找不到组件,组件不存在或未发布!")},activated(){this.meta.cache===!1&&(this.sid=Symbol())}}),Qt=$.defineComponent({name:"VtjStartupContainer",render(){return $.h("div","page not found!")}});function q(n,e,t=[]){const s=[];for(const r of t){const{id:i,title:o,icon:a,children:u,hidden:c,layout:l}=r;if(l){const p=q(n,e,u||[]);s.push(...p)}else{const p={id:i,title:o,icon:a,hidden:c,url:`${n}/${e}/${i}`,children:u&&u.length?q(n,e,u):void 0};s.push(p)}}return s}function _e(n,e){if(!e)return n;let t=[];for(const s of n)if(s.children&&s.children.length){const r=_e(s.children,e);r.length&&(s.children=r,t.push(s))}else e.can(s.id.toString())&&t.push(s);return t}function Yt(n){const{menuPathPrefix:e="",pageRouteName:t="page",disableMenusFilter:s=!1}=n||{},r=ye(),i=Ee.useRoute(),o=qe(),a=$.ref(!1),u=$.ref(!1),c=r.project,l=(h,g)=>{a.value=!h?.mask,u.value=g?.pure??!!h?.pure};$.watchEffect(()=>{const{name:h,params:g,meta:m}=i;if(h===x){const _=r.getPage(g.id);l(_,m)}else if(h===U){const _=r.getHomepage();l(_,m)}else{const _=m.__vtj__;if(_){const y=r.getPage(_);l(y,m)}else a.value=!m.mask,u.value=!!m.pure}});const p=q(e,t,c?.pages),d=c?.config;return{disabled:a,logo:d?.logo,themeSwitchable:d?.themeSwitchable,title:d?.title||c?.description||c?.name||"VTJ App",menus:s?p:_e(p,o),pure:u}}function ie(n,e){const{id:t,title:s,meta:r}=n,{name:i="page",prefix:o="",component:a,routeMeta:u}=e;return{name:t,path:`${o}${i}/${t}`,component:a,meta:{title:s,...u,...r,__vtj__:t}}}function ce(n){const{name:e="page",prefix:t="",pages:s=[],component:r,loader:i,routeMeta:o,homepage:a}=n,u=[];for(const c of s){const{id:l,title:p,dir:d,layout:h,children:g,meta:m}=c;if(d){const _=ce({name:e,prefix:t,component:r,routeMeta:o,homepage:a,loader:i,pages:g||[]});u.push(..._)}else if(h){const _=ce({name:e,prefix:t,component:r,routeMeta:o,homepage:a,loader:i,pages:g||[]}),y={name:`layout_${l}`,path:t,component:()=>i(l),meta:{title:p,...o,...m,__vtj__:l},children:_};u.push(y),u.push(ie(c,n))}else if(u.push(ie(c,n)),a===l){const _=ie(c,n);_.path="",_.name=`home_${l}`,u.push(_)}}return u}function Xt(n={},e){const{css:t,store:s,enhance:r}=n,{window:i,app:o,library:a={},adapter:u,mode:c}=e,{Pinia:l}=a;o.config.globalProperties.$libs=a,Q(i,"global-css",t||""),l&&s&&Zt(s,o,l),ts(o,u,n),!u.access&&n.access&&es(n.access,o,c,u),ss(o,n),r&&ns(r,o,a)}function Zt(n,e,t){const s=t.createPinia();if(e.use(s),C(n)&&n.value){const r=R(n,{},!1,!1,!0),i=t.defineStore("$store",r(e)||{});e.config.globalProperties.$store=i()}}function es(n,e,t,s){if(C(n)&&n.value){const r=R(n,{},!1,!1,!0),{alert:i,request:o}=s,a=new Y({alert:i,storagePrefix:"__VTJ_APP_",...r(e)}),u=e.config.globalProperties.$router;a.connect({mode:t,router:u,request:o}),e.use(a)}}function ts(n,e,t){if(!e.request)return;const{axios:s,request:r,response:i}=t;if(s&&C(s)&&s.value){const o=R(s,{},!1,!1,!0);e.request.setConfig(o(n))}if(r&&C(r)&&r.value){const o=R(r,{},!1,!1,!0),a=e.request;a.__unReq&&a.__unReq(),a.__unReq=e.request.useRequest(u=>o(u,n))}if(i&&C(i)&&i.value){const o=R(i,{},!1,!1,!0),a=e.request;a.__unRes&&a.__unRes(),a.__unRes=e.request.useResponse(u=>o(u,n))}}function ss(n,e){const{beforeEach:t,afterEach:s}=e,r=n.config.globalProperties.$router;if(t&&C(t)&&t.value){const i=R(t,{},!1,!1,!0);r&&r.beforeEach((o,a,u)=>i(o,a,u,n))}if(s&&C(s)&&s.value){const i=R(s,{},!1,!1,!0);r&&r.afterEach((o,a,u)=>i(o,a,u,n))}}function ns(n,e,t={}){C(n)&&n.value&&R(n,{},!1,!1,!0)(e,t)}function rs(n,e,t){if(!n||!e||!t)return;const{VueI18n:s}=e;if(s){const{locale:r,fallbackLocale:i,messages:o=[]}=t,a={};for(let c of o){const l=Object.keys(c).filter(p=>p!=="key");for(const p of l)a[p]||(a[p]={}),a[p][c.key]=c[p]}const u=s.createI18n({legacy:!1,locale:r,fallbackLocale:i,messages:a});n.use(u)}}const ve=Symbol("Provider");var et=(n=>(n.Production="production",n.Development="development",n))(et||{});class tt extends F.Base{constructor(e){super(),this.options=e;const{service:t,mode:s=S.Raw,dependencies:r,materials:i,project:o={},adapter:a={},globals:u={},modules:c={},router:l=null,materialPath:p="./",nodeEnv:d="development"}=e;this.mode=s,this.modules=c,this.service=t,this.router=l,this.materialPath=p,this.nodeEnv=d,r&&(this.dependencies=r),i&&(this.materials=i),Object.assign(this.globals,u),Object.assign(this.adapter,a);const{access:h,request:g}=this.adapter;h&&h.connect({mode:s,router:l,request:g}),o&&s!==S.Design?this.load(o):this.project=o}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={};errorHandler=null;createMock(e){return async(...t)=>{let s={};if(e)try{s=await e.apply(e,t)}catch(i){f.logger.warn("模拟数据模版异常",i)}return k()?.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:i=[],env:o=[]}=this.project,a=window;a&&(a.CKEDITOR_VERSION=void 0),this.initEnv(o),this.mode===S.Raw?await this.loadDependencies(a):await this.loadAssets(a),this.initMock(a),this.apis=Ke(r,i,this.adapter),he(a),Ge(r,a),e.platform!=="uniapp"&&this.initRouter(),this.triggerReady()}initMock(e){const t=k(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:i,materialPath:o,nodeEnv:a,libraryLocales:u}=this,{libraryExports:c,libraryMap:l,materials:p,materialExports:d,materialMapLibrary:h,libraryLocaleMap:g}=Pe(t,o,a==="development");Object.assign(this.libraryLocaleMap,g);for(const m of c){const _=s[m],y=e[m];if(y)r[m]=y;else if(_)e[m]=r[m]=await _();else{const j=l[m]||[];for(const v of j)B(v)&&await Oe(v,f.url.append(v,{v:D})),J(v)&&await f.loadScript(f.url.append(v,{v:D}));r[m]=e[m]}const w=g[m];if(w){const j=s[w];u[w]=j?await j():e[w]}}if(a==="development"){for(const _ of p)await f.loadScript(f.url.append(_,{v:D}));const m=this.materials||{};for(const _ of d){const y=e[h[_]],w=y?.default||y,j=F.BUILT_IN_COMPONENTS[_];if(j)w&&j.forEach(v=>{i[v]=w[v]});else{const v=m[_]?(await m[_]()).default:e[_];v&&w&&(v.components||[]).forEach(A=>{i[A.name]=Ae(A,w)})}}}}initRouter(){const{router:e,project:t,options:s,adapter:r}=this;if(!e)return;const i=t?.platform==="uniapp"?"pages":"page",{routeAppendTo:o,pageRouteName:a=i,routeMeta:u}=s,c=o?"":"/",l={path:`${c}${a}/:id`,name:x,component:re},p=this.getHomepage(),d={path:c,name:U,component:p?re:r.startupComponent||Qt,meta:u};if(e.hasRoute(x)&&e.removeRoute(x),e.hasRoute(U)&&e.removeRoute(U),s.enableStaticRoute){const h=t?.pages||[];ce({name:a,prefix:c,pages:h,component:re,loader:this.getRenderComponent.bind(this),homepage:p?.id}).forEach(m=>{o?e.addRoute(o,m):e.addRoute(m)}),p||(o?e.addRoute(o,d):e.addRoute(d))}else o?(e.addRoute(o,l),e.addRoute(o,d)):(e.addRoute(l),e.addRoute(d))}setErrorHandler(e){e.config.errorHandler=f.debounce((t,s,r)=>{const i=s?.$options.name,o=typeof t=="string"?t:t?.message||t?.msg||"未知错误",a=`[ ${i} ] ${o} ${r}`;["getComputedStyle","ResizeObserver"].some(c=>a.includes(c))||(console.error("[VTJ Error]:",{err:t,instance:s,info:r},t?.stack),this.errorHandler&&this.errorHandler(t),this.adapter.notify&&this.adapter.notify(a,"组件渲染错误","error"))},300)}install(e){const{libraryLocaleMap:t,libraryLocales:s}=this,{libraryOptions:r={}}=this.options,i=e.config.globalProperties.installed||{};for(const[o,a]of Object.entries(this.library))if(!i[o]&&De(a)){const c={locale:s[t[o]]},l=r[o]||{},p={...c,...l};e.use(a,p),i[o]=!0}e.provide(ve,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&&this.setErrorHandler(e),e.config.globalProperties.installed=i}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,i=[])=>{for(const o of i){if(o.id===r)return o;if(o.children&&o.children.length){const a=s(r,o.children);if(a)return a}}};return s(e,t)||null}getFirstPage(){const{pages:e=[]}=this.project||{};if(!e.length)return null;const t=(s=[])=>{for(const r of s){if(r.type==="page"&&!r.dir&&!r.layout)return r;if(r.children&&r.children.length){const i=t(r.children);if(i)return i}}};return t(e)||null}getMenus(e="page",t=""){return q(t,e,this.project?.pages||[])}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):this.getFirstPage()}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:i,apis:o}=this,a={mode:i,Vue:s.Vue,components:r,libs:s,apis:o,window,...t},u=V({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:a});return z({...a,dsl:e,loader:u})}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:i=".vtj/vue"}=this.options,o=`${i}/${e}.vue`,a=this.modules[o]||this.modules[`/src/pages/${e}.vue`];return a?(await a())?.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 $.defineAsyncComponent(async()=>{const s=await this.getDslByUrl(e);return s?(s.name=t||s.name,this.createDslRenderer(s).renderer):null})}definePluginComponent(e){return $.defineAsyncComponent(async()=>await me(e,window))}initGlobals(e,t){const s=Object.assign({adapter:this.adapter,window},t);Xt(e,s)}initI18n(e,t,s){rs(e,t,s)}initEnv(e=[]){this.env=e.reduce((t,s)=>(t[s.name]=s[this.nodeEnv],t),{})}}function is(n){const e=new tt(n);return{provider:e,onReady:s=>e.ready(s)}}function ye(n={}){const e=$.inject(ve,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 os(n,e=""){const{name:t,urls:s=[]}=n||{},r=s.map(a=>e+a),{css:i,js:o}=Ie(r);if(i.length&&pe(i),o.length)return await fe(o,t).catch(()=>{})}const st={type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:n=>n.data?.code===0},as=(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:st}),cs=(n,e="/__vtj__/api/uploader.json")=>async(t,s)=>await n.send({url:e,method:"post",data:{files:t,projectId:s},settings:{...st,type:"data"}}).then(r=>r&&r[0]?r[0]:null).catch(()=>null);function ls(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 X{constructor(e=f.request){this.req=e,this.api=as(e),this.uploader=cs(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(i=>je(i))[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(i=>i.data).catch(()=>null))}async genSource(e){return console.log("BaseService.genSource",e),""}}const E=new f.Storage({type:"local",expired:0,prefix:"__VTJ_"});class us extends X{init(e){const t=new F.ProjectModel(e),s=E.get(`project_${t.id}`),r=Object.assign(t.toDsl(),s||{});return E.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new F.ProjectModel(e);return E.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return E.save(`materials_${e.id}`,f.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return E.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=E.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return E.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return E.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=E.get(`history_${e}`);if(t){const r=(t.items||[]).map(i=>i.id);this.removeHistoryItem(e,r),E.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=E.get(`history_${e}`),s=new F.HistoryModel(t||{id:e});return Promise.resolve(s.toDsl())}getHistoryItem(e,t){const s=E.get(`history_${e}_${t}`);return Promise.resolve(s)}saveHistoryItem(e,t){return E.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(s=>{E.remove(`history_${e}_${s}`)}),Promise.resolve(!0)}}class nt extends X{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new F.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 F.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(i=>i.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],s=new F.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 G=null;function ps(){return G||(G=new nt,G)}class fs extends X{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=pt;exports.ACCESS_KEY=de;exports.Access=Y;exports.BUILD_IN_TAGS=be;exports.BUILT_IN_DIRECTIVES=$e;exports.BaseService=X;exports.CONTEXT_HOST=oe;exports.Context=We;exports.ContextMode=S;exports.DATA_TYPES=Ce;exports.HOMEPAGE_ROUTE_NAME=U;exports.HTML_TAGS=le;exports.JSCodeToString=vt;exports.LIFE_CYCLES_LIST=lt;exports.LocalService=fs;exports.MemoryService=nt;exports.NodeEnv=et;exports.PAGE_ROUTE_NAME=x;exports.Provider=tt;exports.REMOTE=ut;exports.StorageService=us;exports.VTJ_RENDERER_VERSION=D;exports.adoptStylesToInline=mt;exports.adoptedStyleSheets=Q;exports.clearLoaderCache=Ft;exports.compileScopedCSS=Fe;exports.convertCssRpx=Me;exports.createAccess=wt;exports.createAdapter=St;exports.createAssetScripts=ft;exports.createAssetsCss=dt;exports.createDataSources=Qe;exports.createLoader=V;exports.createMemoryService=ps;exports.createMenus=q;exports.createMetaApi=Je;exports.createMock=ze;exports.createProvider=is;exports.createRenderer=z;exports.createSchemaApi=Be;exports.createSchemaApis=Ke;exports.createServiceRequest=ls;exports.defaultLoader=Xe;exports.fillBasePath=N;exports.getMock=k;exports.getModifiers=ge;exports.getPlugin=me;exports.getRawComponent=Ae;exports.isArrowFunction=He;exports.isAssignment=Le;exports.isBuiltInTag=xe;exports.isCSSUrl=B;exports.isCallFunction=Ne;exports.isJSCode=Ue;exports.isJSExpression=b;exports.isJSFunction=C;exports.isJSON=je;exports.isJSUrl=J;exports.isNativeTag=ke;exports.isVuePlugin=De;exports.loadCss=Oe;exports.loadCssUrl=pe;exports.loadEnhance=os;exports.loadScriptUrl=fe;exports.menusFilter=_e;exports.mockApi=Ve;exports.mockApis=Ge;exports.mockCleanup=he;exports.nodeCache=O;exports.nodeRender=M;exports.parseDeps=Pe;exports.parseExpression=H;exports.parseFunction=R;exports.parseUrls=Ie;exports.providerKey=ve;exports.removeProdFlag=Re;exports.rpxToPx=Te;exports.setupPageSetting=gt;exports.toString=ue;exports.useAccess=qe;exports.useMask=Yt;exports.useProvider=ye;
|
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Base as
|
|
2
|
-
import { url as O, isUrl as ae, dedupArray as
|
|
1
|
+
import { Base as Xe, BUILT_IN_COMPONENTS as Ye, ProjectModel as K, HistoryModel as Ce } from "@vtj/core";
|
|
2
|
+
import { url as O, isUrl as ae, dedupArray as Ze, isFunction as z, isString as I, logger as M, storage as se, cookie as ne, toArray as Se, unRSA as $e, delay as G, createRequest as Pe, jsonp as Ae, merge as et, pathToRegexp as tt, pathToRegexpMatch as st, formDataToJson as nt, isEqual as rt, Queue as it, cloneDeep as Ee, camelCase as P, upperFirstCamelCase as ot, pick as at, request as ce, loadScript as be, debounce as ct, Storage as lt, mapToObject as me } from "@vtj/utils";
|
|
3
3
|
import * as W from "vue";
|
|
4
|
-
import { inject as
|
|
5
|
-
import { useRoute as
|
|
4
|
+
import { inject as Ie, defineComponent as Fe, h as le, ref as ue, watchEffect as ut, defineAsyncComponent as je } from "vue";
|
|
5
|
+
import { useRoute as Oe } 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.16.
|
|
10
|
+
* @version 0.16.31
|
|
11
11
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
12
12
|
*/
|
|
13
|
-
const H = "0.16.
|
|
13
|
+
const H = "0.16.31";
|
|
14
14
|
var y = /* @__PURE__ */ ((n) => (n.Runtime = "Runtime", n.Design = "Design", n.Raw = "Raw", n.VNode = "VNode", n))(y || {});
|
|
15
|
-
const
|
|
15
|
+
const Re = [
|
|
16
16
|
"$el",
|
|
17
17
|
"$emit",
|
|
18
18
|
"$nextTick",
|
|
@@ -55,7 +55,7 @@ const ut = [
|
|
|
55
55
|
Object,
|
|
56
56
|
Function,
|
|
57
57
|
Date
|
|
58
|
-
}, k = "VtjPage", J = "VtjHomepage",
|
|
58
|
+
}, k = "VtjPage", J = "VtjHomepage", Me = "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(
|
|
59
59
|
","
|
|
60
60
|
), dt = "component,slot".split(","), Ts = [
|
|
61
61
|
"h",
|
|
@@ -175,7 +175,7 @@ function gt(n, e, t = !1) {
|
|
|
175
175
|
css: q(i, e),
|
|
176
176
|
materials: q(o, e),
|
|
177
177
|
libraryExports: a,
|
|
178
|
-
materialExports:
|
|
178
|
+
materialExports: Ze(l),
|
|
179
179
|
materialMapLibrary: f,
|
|
180
180
|
libraryMap: u,
|
|
181
181
|
libraryLocaleMap: c
|
|
@@ -329,7 +329,7 @@ function $t(n, e) {
|
|
|
329
329
|
}
|
|
330
330
|
return i;
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function Te(n) {
|
|
333
333
|
return I(n) ? n : JSON.stringify(n);
|
|
334
334
|
}
|
|
335
335
|
function ge(n, e, t, s = !1) {
|
|
@@ -367,7 +367,7 @@ async function Et(n, e) {
|
|
|
367
367
|
const t = await window.fetch(e).then((s) => s.text()).catch(() => "");
|
|
368
368
|
t && ge(window, n, t);
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function xe(n, e = window) {
|
|
371
371
|
const t = e.document, s = e.document.head;
|
|
372
372
|
for (const r of n)
|
|
373
373
|
if (!t.getElementById(r)) {
|
|
@@ -375,7 +375,7 @@ function Te(n, e = window) {
|
|
|
375
375
|
o.rel = "stylesheet", o.id = r, o.href = r, s.appendChild(o);
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
|
-
async function
|
|
378
|
+
async function De(n, e, t = window) {
|
|
379
379
|
const s = t.document, r = t.document.head;
|
|
380
380
|
let i = t[e];
|
|
381
381
|
return i ? i.default || i : new Promise((o, a) => {
|
|
@@ -396,7 +396,7 @@ function jt(n) {
|
|
|
396
396
|
return dt.includes(n);
|
|
397
397
|
}
|
|
398
398
|
function Rt(n) {
|
|
399
|
-
return
|
|
399
|
+
return Me.includes(n);
|
|
400
400
|
}
|
|
401
401
|
function N(n = window) {
|
|
402
402
|
const e = window?.Mock;
|
|
@@ -481,7 +481,7 @@ const Ot = {
|
|
|
481
481
|
noPermissionMessage: "无权限访问该页面",
|
|
482
482
|
appName: "",
|
|
483
483
|
statusKey: "code"
|
|
484
|
-
},
|
|
484
|
+
}, He = Symbol("access");
|
|
485
485
|
class _e {
|
|
486
486
|
options;
|
|
487
487
|
data = null;
|
|
@@ -533,7 +533,7 @@ class _e {
|
|
|
533
533
|
return Se(e).some((i) => s[i] || s[t + "." + i]);
|
|
534
534
|
}
|
|
535
535
|
install(e) {
|
|
536
|
-
e.config.globalProperties.$access = this, e.provide(
|
|
536
|
+
e.config.globalProperties.$access = this, e.provide(He, this);
|
|
537
537
|
}
|
|
538
538
|
isAuthPath(e) {
|
|
539
539
|
const { auth: t, isAuth: s } = this.options;
|
|
@@ -639,7 +639,7 @@ class _e {
|
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
641
|
function Mt() {
|
|
642
|
-
return
|
|
642
|
+
return Ie(He, null);
|
|
643
643
|
}
|
|
644
644
|
function Ls(n = {}) {
|
|
645
645
|
const {
|
|
@@ -653,7 +653,7 @@ function Ls(n = {}) {
|
|
|
653
653
|
} = n;
|
|
654
654
|
let u = null;
|
|
655
655
|
return {
|
|
656
|
-
request:
|
|
656
|
+
request: Pe({
|
|
657
657
|
settings: {
|
|
658
658
|
type: "form",
|
|
659
659
|
validSuccess: !0,
|
|
@@ -673,7 +673,7 @@ function Ls(n = {}) {
|
|
|
673
673
|
...s
|
|
674
674
|
}
|
|
675
675
|
}),
|
|
676
|
-
jsonp:
|
|
676
|
+
jsonp: Ae,
|
|
677
677
|
notify: e,
|
|
678
678
|
loading: t,
|
|
679
679
|
useTitle: o,
|
|
@@ -701,7 +701,7 @@ function Tt(n, e) {
|
|
|
701
701
|
headers: r
|
|
702
702
|
}
|
|
703
703
|
};
|
|
704
|
-
return (o, a) => (delete i.data, s.send(
|
|
704
|
+
return (o, a) => (delete i.data, s.send(et(i, a || {}, { data: o })));
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
707
|
function xt(n, e) {
|
|
@@ -728,7 +728,7 @@ function Dt(n = [], e = [], t) {
|
|
|
728
728
|
}
|
|
729
729
|
async function Ht(n = [], e = window) {
|
|
730
730
|
const t = N(e);
|
|
731
|
-
t && (
|
|
731
|
+
t && (ke(e), n.forEach((s) => Nt(t, s)));
|
|
732
732
|
}
|
|
733
733
|
function kt(n, e = window) {
|
|
734
734
|
const t = $(n.mockTemplate) && n.mockTemplate.value ? R(n.mockTemplate, {}, !0) : void 0, s = N(e);
|
|
@@ -748,9 +748,9 @@ function Nt(n, e) {
|
|
|
748
748
|
const { url: t, mockTemplate: s } = e;
|
|
749
749
|
if (t && s)
|
|
750
750
|
try {
|
|
751
|
-
const r = ae(t) ? new URL(t).pathname : t, i =
|
|
751
|
+
const r = ae(t) ? new URL(t).pathname : t, i = tt(`(.*)${r}(.*)`), o = st(r, { decode: decodeURIComponent }), a = B(s, {}, !0);
|
|
752
752
|
n.mock(i, (u) => {
|
|
753
|
-
const c = O.parse(u.url) || {}, l = u.body instanceof FormData ?
|
|
753
|
+
const c = O.parse(u.url) || {}, l = u.body instanceof FormData ? nt(u.body) : u.body, f = ae(u.url) ? new URL(u.url).pathname : u.url.split("?")[0], p = o(f)?.params;
|
|
754
754
|
Object.assign(u, { data: l, params: p, query: c });
|
|
755
755
|
try {
|
|
756
756
|
return n.mock(a(u));
|
|
@@ -762,7 +762,7 @@ function Nt(n, e) {
|
|
|
762
762
|
console.warn("mockApi", r);
|
|
763
763
|
}
|
|
764
764
|
}
|
|
765
|
-
function
|
|
765
|
+
function ke(n = window) {
|
|
766
766
|
const e = N(n);
|
|
767
767
|
e && (e._mocked = {});
|
|
768
768
|
}
|
|
@@ -804,6 +804,8 @@ class Bt {
|
|
|
804
804
|
const r = s.appContext.config.globalProperties;
|
|
805
805
|
Object.assign(this, r), Object.assign(this, e || {}), this.__proxy(), t.onMounted(() => {
|
|
806
806
|
this.__proxy();
|
|
807
|
+
}), t.onUnmounted(() => {
|
|
808
|
+
this.__cleanup();
|
|
807
809
|
}), t.onBeforeUpdate(() => {
|
|
808
810
|
this.__reset();
|
|
809
811
|
});
|
|
@@ -811,16 +813,15 @@ class Bt {
|
|
|
811
813
|
__proxy() {
|
|
812
814
|
if (!this.__instance) return;
|
|
813
815
|
const e = this.__instance;
|
|
814
|
-
|
|
816
|
+
Re.forEach((t) => {
|
|
815
817
|
this[t] = e[t] || e._?.[t.replace("$", "")] || null;
|
|
816
818
|
});
|
|
817
819
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
// }
|
|
820
|
+
__cleanup() {
|
|
821
|
+
Re.forEach((e) => {
|
|
822
|
+
this[e] = null;
|
|
823
|
+
}), this.__reset();
|
|
824
|
+
}
|
|
824
825
|
__reset() {
|
|
825
826
|
this.__refs = {}, this.__refCaches = {}, this.$refs = {}, this.__contextRefs = {}, this.context = {};
|
|
826
827
|
}
|
|
@@ -1073,20 +1074,20 @@ class Qt {
|
|
|
1073
1074
|
return s || (e && this.setNode(e, t), t);
|
|
1074
1075
|
}
|
|
1075
1076
|
isEqual(e, t) {
|
|
1076
|
-
return
|
|
1077
|
+
return rt(e, t);
|
|
1077
1078
|
}
|
|
1078
1079
|
clear() {
|
|
1079
1080
|
this.__props = {}, this.__events = {}, this.__nodes = {};
|
|
1080
1081
|
}
|
|
1081
1082
|
}
|
|
1082
|
-
const x = new Qt(),
|
|
1083
|
+
const x = new Qt(), Ne = new it();
|
|
1083
1084
|
let re = [], F = {}, D = {};
|
|
1084
1085
|
const Xt = (n, e) => e;
|
|
1085
|
-
async function
|
|
1086
|
+
async function Be(n, e = window) {
|
|
1086
1087
|
const { urls: t = [], library: s } = n, r = t.filter((a) => X(a));
|
|
1087
1088
|
if (r.length === 0 || !s) return null;
|
|
1088
1089
|
const i = t.filter((a) => Q(a));
|
|
1089
|
-
return i.length &&
|
|
1090
|
+
return i.length && xe(i, e), await De(r, s, e).catch(
|
|
1090
1091
|
(a) => (console.warn("loadScriptUrl error", r, s, a), null)
|
|
1091
1092
|
);
|
|
1092
1093
|
}
|
|
@@ -1099,7 +1100,7 @@ function pe(n) {
|
|
|
1099
1100
|
let u = "";
|
|
1100
1101
|
if (o.type === "Schema" && o.id)
|
|
1101
1102
|
return u = o.id + "_" + r, D[u] || (D[u] = a.defineAsyncComponent(async () => {
|
|
1102
|
-
const c = F[o.id] || await
|
|
1103
|
+
const c = F[o.id] || await Ne.add(
|
|
1103
1104
|
o.id,
|
|
1104
1105
|
() => e(o.id)
|
|
1105
1106
|
);
|
|
@@ -1126,7 +1127,7 @@ function pe(n) {
|
|
|
1126
1127
|
let c = o.library ? F[o.library] : null;
|
|
1127
1128
|
return c || (o.library && re.push(o.library), c = F[o.library || Symbol()] = a.defineAsyncComponent(
|
|
1128
1129
|
async () => {
|
|
1129
|
-
const l = await
|
|
1130
|
+
const l = await Be(o, s.window);
|
|
1130
1131
|
return l || (console.warn("getPlugin result is null", o), null);
|
|
1131
1132
|
}
|
|
1132
1133
|
), c);
|
|
@@ -1135,11 +1136,11 @@ function pe(n) {
|
|
|
1135
1136
|
};
|
|
1136
1137
|
}
|
|
1137
1138
|
function Us() {
|
|
1138
|
-
F = {}, D = {},
|
|
1139
|
+
F = {}, D = {}, Ne.clearAllCache(), x.clear();
|
|
1139
1140
|
}
|
|
1140
1141
|
function T(n, e, t = W, s = Xt, r = [], i = !1, o = 0) {
|
|
1141
1142
|
if (!n || !n.name || n.invisible) return null;
|
|
1142
|
-
const a = t.getCurrentInstance()?.appContext, { id: u = null, directives: c = [] } = n, { vIf: l, vElseIf: f, vElse: p, vFor: d, vShow: m, vModels: h, vBind: g, vHtml: v, others: w } =
|
|
1143
|
+
const a = t.getCurrentInstance()?.appContext, { id: u = null, directives: c = [] } = n, { vIf: l, vElseIf: f, vElse: p, vFor: d, vShow: m, vModels: h, vBind: g, vHtml: v, others: w } = Le(c);
|
|
1143
1144
|
if (!i && (f || p))
|
|
1144
1145
|
return null;
|
|
1145
1146
|
if (l && !Zt(l, e))
|
|
@@ -1151,7 +1152,7 @@ function T(n, e, t = W, s = Xt, r = [], i = !1, o = 0) {
|
|
|
1151
1152
|
if (n.name === "slot") return n.name;
|
|
1152
1153
|
const j = s(`${n.id}_${C}`, n.name, n.from, t);
|
|
1153
1154
|
return I(j) ? jt(j) || Rt(j) ? j : Y[j] ?? a?.app?.component(j) ?? j : j;
|
|
1154
|
-
})(), A = ts(u, n.props ?? {}, _),
|
|
1155
|
+
})(), A = ts(u, n.props ?? {}, _), Ge = rs(
|
|
1155
1156
|
t,
|
|
1156
1157
|
n.id,
|
|
1157
1158
|
n.events ?? {},
|
|
@@ -1163,26 +1164,26 @@ function T(n, e, t = W, s = Xt, r = [], i = !1, o = 0) {
|
|
|
1163
1164
|
A.style ?? {},
|
|
1164
1165
|
cs(m, _)
|
|
1165
1166
|
)), v && Object.assign(A, ls(v, _)), h.forEach((j) => {
|
|
1166
|
-
|
|
1167
|
+
Me.includes(n.name) ? Object.assign(A, us(j, _)) : Object.assign(A, fs(t, j, _));
|
|
1167
1168
|
});
|
|
1168
|
-
const
|
|
1169
|
+
const Ve = ps(
|
|
1169
1170
|
t,
|
|
1170
1171
|
n.children ?? [],
|
|
1171
1172
|
_,
|
|
1172
1173
|
s,
|
|
1173
1174
|
n
|
|
1174
|
-
), ye = _?.__id ? `data-v-${_.__id}` : void 0,
|
|
1175
|
+
), ye = _?.__id ? `data-v-${_.__id}` : void 0, We = ye ? { [ye]: "" } : {}, Qe = _.__mode === y.Design ? { "data-vtj": u } : {}, L = `${u}_${C}`, ee = {
|
|
1175
1176
|
key: L,
|
|
1176
|
-
...Ve,
|
|
1177
1177
|
...We,
|
|
1178
|
+
...Qe,
|
|
1178
1179
|
...A,
|
|
1179
|
-
...
|
|
1180
|
+
...Ge
|
|
1180
1181
|
};
|
|
1181
1182
|
x.isEqual(ee, x.getNode(L)) || x.setNode(L, ee);
|
|
1182
1183
|
let te = t.createVNode(
|
|
1183
1184
|
Z,
|
|
1184
1185
|
x.getNode(L) || ee || {},
|
|
1185
|
-
|
|
1186
|
+
Ve
|
|
1186
1187
|
);
|
|
1187
1188
|
const we = a ? Yt(a, w, _) : [];
|
|
1188
1189
|
return we.length && (te = t.withDirectives(te, we)), te;
|
|
@@ -1198,7 +1199,7 @@ function Yt(n, e, t) {
|
|
|
1198
1199
|
return r.value && o.push(t.__parseExpression(r.value)), r.arg && o.push(r.arg), r.modifiers && o.push(r.modifiers), o;
|
|
1199
1200
|
}).filter((r) => !!r);
|
|
1200
1201
|
}
|
|
1201
|
-
function
|
|
1202
|
+
function Le(n = []) {
|
|
1202
1203
|
const e = n.find((l) => P(l.name) === "vIf"), t = n.find(
|
|
1203
1204
|
(l) => P(l.name) === "vElseIf"
|
|
1204
1205
|
), s = n.find((l) => P(l.name) === "vElse"), r = n.find((l) => P(l.name) === "vFor"), i = n.find((l) => P(l.name) === "vShow"), o = n.find((l) => P(l.name) === "vBind"), a = n.find((l) => P(l.name) === "vHtml"), u = n.filter(
|
|
@@ -1263,7 +1264,7 @@ function rs(n, e, t, s) {
|
|
|
1263
1264
|
};
|
|
1264
1265
|
return Object.keys(t || {}).reduce(
|
|
1265
1266
|
(a, u) => {
|
|
1266
|
-
const c = t[u], l =
|
|
1267
|
+
const c = t[u], l = qe(c.modifiers), f = l.find((m) => r.includes(m)), p = "on" + ot(u) + (f && i[f] || ""), d = c.handler ? s.__parseFunction(ns(c.handler)) : null;
|
|
1267
1268
|
return d && (a[p] = n.withModifiers(
|
|
1268
1269
|
l.includes("enter") ? ss(d, "enter") : d,
|
|
1269
1270
|
l
|
|
@@ -1275,7 +1276,7 @@ function rs(n, e, t, s) {
|
|
|
1275
1276
|
function is(n, e, t, s, r = []) {
|
|
1276
1277
|
let i = r.findIndex((o) => o.id === n.id);
|
|
1277
1278
|
for (let o = ++i; o < r.length; o++) {
|
|
1278
|
-
const { directives: a = [] } = r[o], { vElseIf: u, vElse: c } =
|
|
1279
|
+
const { directives: a = [] } = r[o], { vElseIf: u, vElse: c } = Le(a);
|
|
1279
1280
|
if (u) {
|
|
1280
1281
|
if (e.__parseExpression(u.value))
|
|
1281
1282
|
return T(r[o], e, t, s, r, !0);
|
|
@@ -1286,14 +1287,14 @@ function is(n, e, t, s, r = []) {
|
|
|
1286
1287
|
}
|
|
1287
1288
|
return null;
|
|
1288
1289
|
}
|
|
1289
|
-
function
|
|
1290
|
+
function qe(n = {}, e = !1) {
|
|
1290
1291
|
const t = Object.keys(n);
|
|
1291
1292
|
return e ? t.map((s) => "." + s) : t;
|
|
1292
1293
|
}
|
|
1293
1294
|
function os(n, e, t, s, r) {
|
|
1294
1295
|
const { children: i } = e, o = as(e, s), a = s.$slots?.[o.name];
|
|
1295
1296
|
return a ? a(t) : i ? I(i) ? n.createTextVNode(i) : E(i) ? n.createTextVNode(
|
|
1296
|
-
|
|
1297
|
+
Te(s.__parseExpression(i))
|
|
1297
1298
|
) : Array.isArray(i) ? i.map(
|
|
1298
1299
|
(u, c) => T(u, s, n, r, i, !1, c)
|
|
1299
1300
|
) : null : null;
|
|
@@ -1333,7 +1334,7 @@ function fs(n, e, t) {
|
|
|
1333
1334
|
value: e.value?.value ? `(v) => {
|
|
1334
1335
|
${e.value.value} = v;
|
|
1335
1336
|
}` : "(v) => {}"
|
|
1336
|
-
}, r = t.__parseFunction(s), i =
|
|
1337
|
+
}, r = t.__parseFunction(s), i = qe(
|
|
1337
1338
|
E(e.modifiers) ? t.__parseExpression(e.modifiers) : e.modifiers
|
|
1338
1339
|
), o = E(e.arg) ? t.__parseExpression(e.arg) : e.arg || "modelValue";
|
|
1339
1340
|
return {
|
|
@@ -1347,7 +1348,7 @@ function ps(n, e, t, s, r) {
|
|
|
1347
1348
|
return { default: () => e };
|
|
1348
1349
|
if (E(e))
|
|
1349
1350
|
return {
|
|
1350
|
-
default: () =>
|
|
1351
|
+
default: () => Te(t.__parseExpression(e))
|
|
1351
1352
|
};
|
|
1352
1353
|
if (Array.isArray(e) && e.length > 0) {
|
|
1353
1354
|
const i = ds(e), o = (a, u) => !a || !r ? {} : r?.id && Object.keys(a).length ? u ? {
|
|
@@ -1357,7 +1358,7 @@ function ps(n, e, t, s, r) {
|
|
|
1357
1358
|
} : u ? { [u]: /* @__PURE__ */ Object.create(null) } : {};
|
|
1358
1359
|
return Object.entries(i).reduce(
|
|
1359
1360
|
(a, [u, { nodes: c, params: l, scope: f }]) => (a[u] = (p) => {
|
|
1360
|
-
const d = l.length ?
|
|
1361
|
+
const d = l.length ? at(p ?? {}, l) : o(p, f);
|
|
1361
1362
|
return c.map(
|
|
1362
1363
|
(m, h) => T(
|
|
1363
1364
|
m,
|
|
@@ -1395,10 +1396,10 @@ function ms(n, e, t) {
|
|
|
1395
1396
|
let a = t.__parseExpression(s) || [];
|
|
1396
1397
|
return Number.isInteger(a) && (a = new Array(a).fill(!0).map((u, c) => c + 1)), Array.isArray(a) ? a.map((u, c) => e(t.__clone({ [i]: u, [o]: c }), c)) : (console.warn("[vForRender]:", `${s?.value} is not a Arrary`), []);
|
|
1397
1398
|
}
|
|
1398
|
-
const ie =
|
|
1399
|
+
const ie = Fe({
|
|
1399
1400
|
name: "VtjPageContainer",
|
|
1400
1401
|
async setup() {
|
|
1401
|
-
const n =
|
|
1402
|
+
const n = Ke(), e = Oe(), t = e.meta.__vtj__ || e.params.id, s = t ? n.getPage(t) : n.getHomepage(), r = s ? await n.getRenderComponent(s.id) : null, i = ue(Symbol());
|
|
1402
1403
|
if (s) {
|
|
1403
1404
|
Object.assign(e.meta, s.meta || {}, { cache: s.cache });
|
|
1404
1405
|
const { useTitle: o } = n?.adapter;
|
|
@@ -1428,7 +1429,7 @@ const ie = Ie({
|
|
|
1428
1429
|
activated() {
|
|
1429
1430
|
this.meta.cache === !1 && (this.sid = Symbol());
|
|
1430
1431
|
}
|
|
1431
|
-
}), gs =
|
|
1432
|
+
}), gs = Fe({
|
|
1432
1433
|
name: "VtjStartupContainer",
|
|
1433
1434
|
render() {
|
|
1434
1435
|
return le("div", "page not found!");
|
|
@@ -1455,12 +1456,12 @@ function V(n, e, t = []) {
|
|
|
1455
1456
|
}
|
|
1456
1457
|
return s;
|
|
1457
1458
|
}
|
|
1458
|
-
function
|
|
1459
|
+
function Ue(n, e) {
|
|
1459
1460
|
if (!e) return n;
|
|
1460
1461
|
let t = [];
|
|
1461
1462
|
for (const s of n)
|
|
1462
1463
|
if (s.children && s.children.length) {
|
|
1463
|
-
const r =
|
|
1464
|
+
const r = Ue(s.children, e);
|
|
1464
1465
|
r.length && (s.children = r, t.push(s));
|
|
1465
1466
|
} else
|
|
1466
1467
|
e.can(s.id.toString()) && t.push(s);
|
|
@@ -1471,10 +1472,10 @@ function Js(n) {
|
|
|
1471
1472
|
menuPathPrefix: e = "",
|
|
1472
1473
|
pageRouteName: t = "page",
|
|
1473
1474
|
disableMenusFilter: s = !1
|
|
1474
|
-
} = n || {}, r =
|
|
1475
|
+
} = n || {}, r = Ke(), i = Oe(), o = Mt(), a = ue(!1), u = ue(!1), c = r.project, l = (d, m) => {
|
|
1475
1476
|
a.value = !d?.mask, u.value = m?.pure ?? !!d?.pure;
|
|
1476
1477
|
};
|
|
1477
|
-
|
|
1478
|
+
ut(() => {
|
|
1478
1479
|
const { name: d, params: m, meta: h } = i;
|
|
1479
1480
|
if (d === k) {
|
|
1480
1481
|
const g = r.getPage(m.id);
|
|
@@ -1501,7 +1502,7 @@ function Js(n) {
|
|
|
1501
1502
|
logo: p?.logo,
|
|
1502
1503
|
themeSwitchable: p?.themeSwitchable,
|
|
1503
1504
|
title: p?.title || c?.description || c?.name || "VTJ App",
|
|
1504
|
-
menus: s ? f :
|
|
1505
|
+
menus: s ? f : Ue(f, o),
|
|
1505
1506
|
pure: u
|
|
1506
1507
|
};
|
|
1507
1508
|
}
|
|
@@ -1641,9 +1642,9 @@ function Es(n, e, t) {
|
|
|
1641
1642
|
n.use(u);
|
|
1642
1643
|
}
|
|
1643
1644
|
}
|
|
1644
|
-
const
|
|
1645
|
+
const Je = Symbol("Provider");
|
|
1645
1646
|
var bs = /* @__PURE__ */ ((n) => (n.Production = "production", n.Development = "development", n))(bs || {});
|
|
1646
|
-
class js extends
|
|
1647
|
+
class js extends Xe {
|
|
1647
1648
|
/**
|
|
1648
1649
|
* 创建Provider实例
|
|
1649
1650
|
* @param options 配置选项
|
|
@@ -1674,7 +1675,7 @@ class js extends Qe {
|
|
|
1674
1675
|
// 全局变量
|
|
1675
1676
|
modules = {};
|
|
1676
1677
|
// 异步模块加载器
|
|
1677
|
-
adapter = { request: ce, jsonp:
|
|
1678
|
+
adapter = { request: ce, jsonp: Ae };
|
|
1678
1679
|
// 适配器接口
|
|
1679
1680
|
apis = {};
|
|
1680
1681
|
// API集合
|
|
@@ -1731,7 +1732,7 @@ class js extends Qe {
|
|
|
1731
1732
|
if (this.project = s ? await s() : await this.service.init(e), !this.project)
|
|
1732
1733
|
throw new Error("project is null");
|
|
1733
1734
|
const { apis: r = [], meta: i = [], env: o = [] } = this.project, a = window;
|
|
1734
|
-
a && (a.CKEDITOR_VERSION = void 0), this.initEnv(o), this.mode === y.Raw ? await this.loadDependencies(a) : await this.loadAssets(a), this.initMock(a), this.apis = Dt(r, i, this.adapter),
|
|
1735
|
+
a && (a.CKEDITOR_VERSION = void 0), this.initEnv(o), this.mode === y.Raw ? await this.loadDependencies(a) : await this.loadAssets(a), this.initMock(a), this.apis = Dt(r, i, this.adapter), ke(a), Ht(r, a), e.platform !== "uniapp" && this.initRouter(), this.triggerReady();
|
|
1735
1736
|
}
|
|
1736
1737
|
initMock(e) {
|
|
1737
1738
|
const t = N(e);
|
|
@@ -1789,7 +1790,7 @@ class js extends Qe {
|
|
|
1789
1790
|
await be(O.append(g, { v: H }));
|
|
1790
1791
|
const h = this.materials || {};
|
|
1791
1792
|
for (const g of p) {
|
|
1792
|
-
const v = e[d[g]], w = v?.default || v, b =
|
|
1793
|
+
const v = e[d[g]], w = v?.default || v, b = Ye[g];
|
|
1793
1794
|
if (b)
|
|
1794
1795
|
w && b.forEach((_) => {
|
|
1795
1796
|
i[_] = w[_];
|
|
@@ -1836,7 +1837,7 @@ class js extends Qe {
|
|
|
1836
1837
|
o ? (e.addRoute(o, l), e.addRoute(o, p)) : (e.addRoute(l), e.addRoute(p));
|
|
1837
1838
|
}
|
|
1838
1839
|
setErrorHandler(e) {
|
|
1839
|
-
e.config.errorHandler =
|
|
1840
|
+
e.config.errorHandler = ct((t, s, r) => {
|
|
1840
1841
|
const i = s?.$options.name, o = typeof t == "string" ? t : t?.message || t?.msg || "未知错误", a = `[ ${i} ] ${o} ${r}`;
|
|
1841
1842
|
["getComputedStyle", "ResizeObserver"].some((c) => a.includes(c)) || (console.error(
|
|
1842
1843
|
"[VTJ Error]:",
|
|
@@ -1866,7 +1867,7 @@ class js extends Qe {
|
|
|
1866
1867
|
const c = { locale: s[t[o]] }, l = r[o] || {}, f = { ...c, ...l };
|
|
1867
1868
|
e.use(a, f), i[o] = !0;
|
|
1868
1869
|
}
|
|
1869
|
-
e.provide(
|
|
1870
|
+
e.provide(Je, 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 !== y.Design && this.initGlobals(this.project?.globals || {}, {
|
|
1870
1871
|
app: e,
|
|
1871
1872
|
window,
|
|
1872
1873
|
adapter: this.adapter,
|
|
@@ -2003,7 +2004,7 @@ class js extends Qe {
|
|
|
2003
2004
|
* @returns Vue异步组件
|
|
2004
2005
|
*/
|
|
2005
2006
|
definePluginComponent(e) {
|
|
2006
|
-
return je(async () => await
|
|
2007
|
+
return je(async () => await Be(e, window));
|
|
2007
2008
|
}
|
|
2008
2009
|
/**
|
|
2009
2010
|
* 设置应用全局
|
|
@@ -2037,8 +2038,8 @@ function Ks(n) {
|
|
|
2037
2038
|
onReady: (s) => e.ready(s)
|
|
2038
2039
|
};
|
|
2039
2040
|
}
|
|
2040
|
-
function
|
|
2041
|
-
const e =
|
|
2041
|
+
function Ke(n = {}) {
|
|
2042
|
+
const e = Ie(Je, null);
|
|
2042
2043
|
if (!e)
|
|
2043
2044
|
throw new Error("Can not find provider");
|
|
2044
2045
|
if (e.nodeEnv === "development") {
|
|
@@ -2056,13 +2057,13 @@ function Je(n = {}) {
|
|
|
2056
2057
|
}
|
|
2057
2058
|
async function zs(n, e = "") {
|
|
2058
2059
|
const { name: t, urls: s = [] } = n || {}, r = s.map((a) => e + a), { css: i, js: o } = vt(r);
|
|
2059
|
-
if (i.length &&
|
|
2060
|
-
return await
|
|
2060
|
+
if (i.length && xe(i), o.length)
|
|
2061
|
+
return await De(o, t).catch(
|
|
2061
2062
|
() => {
|
|
2062
2063
|
}
|
|
2063
2064
|
);
|
|
2064
2065
|
}
|
|
2065
|
-
const
|
|
2066
|
+
const ze = {
|
|
2066
2067
|
type: "json",
|
|
2067
2068
|
validSuccess: !0,
|
|
2068
2069
|
originResponse: !1,
|
|
@@ -2077,7 +2078,7 @@ const Ke = {
|
|
|
2077
2078
|
type: t,
|
|
2078
2079
|
data: s
|
|
2079
2080
|
},
|
|
2080
|
-
settings:
|
|
2081
|
+
settings: ze
|
|
2081
2082
|
}), Cs = (n, e = "/__vtj__/api/uploader.json") => async (t, s) => await n.send({
|
|
2082
2083
|
url: e,
|
|
2083
2084
|
method: "post",
|
|
@@ -2086,12 +2087,12 @@ const Ke = {
|
|
|
2086
2087
|
projectId: s
|
|
2087
2088
|
},
|
|
2088
2089
|
settings: {
|
|
2089
|
-
...
|
|
2090
|
+
...ze,
|
|
2090
2091
|
type: "data"
|
|
2091
2092
|
}
|
|
2092
2093
|
}).then((r) => r && r[0] ? r[0] : null).catch(() => null);
|
|
2093
2094
|
function Gs(n) {
|
|
2094
|
-
return
|
|
2095
|
+
return Pe({
|
|
2095
2096
|
settings: {
|
|
2096
2097
|
type: "json",
|
|
2097
2098
|
validSuccess: !0,
|
|
@@ -2206,7 +2207,7 @@ class ve {
|
|
|
2206
2207
|
return console.log("BaseService.genSource", e), "";
|
|
2207
2208
|
}
|
|
2208
2209
|
}
|
|
2209
|
-
const S = new
|
|
2210
|
+
const S = new lt({
|
|
2210
2211
|
type: "local",
|
|
2211
2212
|
expired: 0,
|
|
2212
2213
|
prefix: "__VTJ_"
|
|
@@ -2245,7 +2246,7 @@ class Vs extends ve {
|
|
|
2245
2246
|
return Promise.resolve(!0);
|
|
2246
2247
|
}
|
|
2247
2248
|
getHistory(e) {
|
|
2248
|
-
const t = S.get(`history_${e}`), s = new
|
|
2249
|
+
const t = S.get(`history_${e}`), s = new Ce(t || { id: e });
|
|
2249
2250
|
return Promise.resolve(s.toDsl());
|
|
2250
2251
|
}
|
|
2251
2252
|
getHistoryItem(e, t) {
|
|
@@ -2300,7 +2301,7 @@ class Ps extends ve {
|
|
|
2300
2301
|
return Promise.resolve(!0);
|
|
2301
2302
|
}
|
|
2302
2303
|
getHistory(e) {
|
|
2303
|
-
const t = this.histories[e], s = new
|
|
2304
|
+
const t = this.histories[e], s = new Ce(t || { id: e });
|
|
2304
2305
|
return Promise.resolve(s);
|
|
2305
2306
|
}
|
|
2306
2307
|
getHistoryItem(e, t) {
|
|
@@ -2381,17 +2382,17 @@ class Qs extends ve {
|
|
|
2381
2382
|
}
|
|
2382
2383
|
export {
|
|
2383
2384
|
xs as ACCESS,
|
|
2384
|
-
|
|
2385
|
+
He as ACCESS_KEY,
|
|
2385
2386
|
_e as Access,
|
|
2386
2387
|
dt as BUILD_IN_TAGS,
|
|
2387
2388
|
ft as BUILT_IN_DIRECTIVES,
|
|
2388
2389
|
ve as BaseService,
|
|
2389
|
-
|
|
2390
|
+
Re as CONTEXT_HOST,
|
|
2390
2391
|
Bt as Context,
|
|
2391
2392
|
y as ContextMode,
|
|
2392
2393
|
pt as DATA_TYPES,
|
|
2393
2394
|
J as HOMEPAGE_ROUTE_NAME,
|
|
2394
|
-
|
|
2395
|
+
Me as HTML_TAGS,
|
|
2395
2396
|
Bs as JSCodeToString,
|
|
2396
2397
|
Ms as LIFE_CYCLES_LIST,
|
|
2397
2398
|
Qs as LocalService,
|
|
@@ -2425,8 +2426,8 @@ export {
|
|
|
2425
2426
|
Xt as defaultLoader,
|
|
2426
2427
|
q as fillBasePath,
|
|
2427
2428
|
N as getMock,
|
|
2428
|
-
|
|
2429
|
-
|
|
2429
|
+
qe as getModifiers,
|
|
2430
|
+
Be as getPlugin,
|
|
2430
2431
|
_t as getRawComponent,
|
|
2431
2432
|
Ct as isArrowFunction,
|
|
2432
2433
|
At as isAssignment,
|
|
@@ -2441,25 +2442,25 @@ export {
|
|
|
2441
2442
|
Rt as isNativeTag,
|
|
2442
2443
|
bt as isVuePlugin,
|
|
2443
2444
|
Et as loadCss,
|
|
2444
|
-
|
|
2445
|
+
xe as loadCssUrl,
|
|
2445
2446
|
zs as loadEnhance,
|
|
2446
|
-
|
|
2447
|
-
|
|
2447
|
+
De as loadScriptUrl,
|
|
2448
|
+
Ue as menusFilter,
|
|
2448
2449
|
Nt as mockApi,
|
|
2449
2450
|
Ht as mockApis,
|
|
2450
|
-
|
|
2451
|
+
ke as mockCleanup,
|
|
2451
2452
|
x as nodeCache,
|
|
2452
2453
|
T as nodeRender,
|
|
2453
2454
|
gt as parseDeps,
|
|
2454
2455
|
B as parseExpression,
|
|
2455
2456
|
R as parseFunction,
|
|
2456
2457
|
vt as parseUrls,
|
|
2457
|
-
|
|
2458
|
+
Je as providerKey,
|
|
2458
2459
|
mt as removeProdFlag,
|
|
2459
2460
|
St as rpxToPx,
|
|
2460
2461
|
Ns as setupPageSetting,
|
|
2461
|
-
|
|
2462
|
+
Te as toString,
|
|
2462
2463
|
Mt as useAccess,
|
|
2463
2464
|
Js as useMask,
|
|
2464
|
-
|
|
2465
|
+
Ke as useProvider
|
|
2465
2466
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtj/renderer",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.31",
|
|
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/core": "~0.16.
|
|
25
|
-
"@vtj/utils": "~0.16.
|
|
24
|
+
"@vtj/core": "~0.16.31",
|
|
25
|
+
"@vtj/utils": "~0.16.31"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"vue": "~3.5.5",
|
|
29
29
|
"vue-router": "~4.6.0",
|
|
30
30
|
"@vtj/cli": "~0.12.19",
|
|
31
|
-
"@vtj/
|
|
32
|
-
"@vtj/
|
|
31
|
+
"@vtj/icons": "~0.16.31",
|
|
32
|
+
"@vtj/ui": "~0.16.31"
|
|
33
33
|
},
|
|
34
34
|
"exports": {
|
|
35
35
|
".": {
|
|
@@ -42,6 +42,7 @@ export declare class Context {
|
|
|
42
42
|
constructor(options: ContextOptions);
|
|
43
43
|
setup(attrs: Record<string, any>, Vue?: any): void;
|
|
44
44
|
private __proxy;
|
|
45
|
+
private __cleanup;
|
|
45
46
|
private __reset;
|
|
46
47
|
__parseFunction(code?: JSFunction): Function | undefined;
|
|
47
48
|
__parseExpression(code?: JSExpression | JSFunction): any;
|
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.16.
|
|
5
|
+
* @version 0.16.30
|
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
|
7
7
|
*/
|
|
8
|
-
export declare const version = "0.16.
|
|
8
|
+
export declare const version = "0.16.30";
|