@vtj/renderer 0.9.0-alpha.16 → 0.9.0-alpha.17
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 +6 -6
- package/dist/index.mjs +159 -158
- package/package.json +5 -5
- package/types/version.d.ts +2 -2
package/dist/index.cjs
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
"use strict";var Ae=Object.create;var te=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var Ie=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Oe(e))!Te.call(s,r)&&r!==t&&te(s,r,{get:()=>e[r],enumerable:!(n=Fe(e,r))||n.enumerable});return s};var De=(s,e,t)=>(t=s!=null?Ae(Me(s)):{},Ie(e||!s||!s.__esModule?te(t,"default",{value:s,enumerable:!0}):t,s));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("@vtj/core"),l=require("@vtj/utils"),p=require("vue"),
|
1
|
+
"use strict";var Ae=Object.create;var te=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var Ie=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Oe(e))!Te.call(s,r)&&r!==t&&te(s,r,{get:()=>e[r],enumerable:!(n=Fe(e,r))||n.enumerable});return s};var De=(s,e,t)=>(t=s!=null?Ae(Me(s)):{},Ie(e||!s||!s.__esModule?te(t,"default",{value:s,enumerable:!0}):t,s));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("@vtj/core"),l=require("@vtj/utils"),p=require("vue"),F=require("element-plus"),se=require("vue-router");function He(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const H=He(p);/**!
|
2
2
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
3
3
|
* @name @vtj/renderer
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
5
|
-
* @version 0.9.0-alpha.
|
5
|
+
* @version 0.9.0-alpha.17
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
7
|
-
*/const C="0.9.0-alpha.
|
8
|
-
`)+o;const a=`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",a)(e)}catch(r){if(l.logger.error("parseExpression.error",r,s,e?.__self??e),n)throw r}}function J(s,e,t=!1,n=!1){const r=R(s,e,t,n);if(typeof r!="function"&&(l.logger.error("parseFunction.error","not a function",s,e?.__self??e),n))throw new Error(`"${s.value}" not a function`);return r}function E(s){return s&&s.type==="JSExpression"}function F(s){return typeof s=="object"&&s&&s.type==="JSFunction"}function he(s){return E(s)||F(s)}function Le(s){return he(s)?s.value:JSON.stringify(s)}let P=null;const Je=l.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:s=>s.data?.code===0||!!s.data?.success,failMessage:!0,showError:s=>{k.ElNotification.error({message:s||"未知错误"})},showLoading:()=>{P&&P.close(),P=k.ElLoading.service({lock:!0,text:"Loading",background:"rgba(0, 0, 0, 0.05)"})},hideLoading:()=>{P&&(P.close(),P=null)}}});let $;function me(s,e){const{jsonp:t,request:n}=e;if(s.method==="jsonp")return(r={})=>t(s.url,{...s.jsonpOptions,query:r});{const r=s.headers?R(s.headers,{},!0):void 0,o={url:s.url,method:s.method,settings:{...s.settings,headers:r}};return(a,i)=>(delete o.data,n.send(l.merge(o,i||{},{data:a})))}}function ge(s,e){const{metaQuery:t}=e;if(!t)return;const{code:n,queryCode:r}=s;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(n,r,o,a)}}function ve(s=[],e=[],t){const n={};for(const r of s)n[r.id]=me(r,t);for(const r of e)n[r.id]=ge(r,t);return n}async function ye(s=[]){$=await import("mockjs").then(e=>e.default||e),$&&($.setup({timeout:"50-500"}),K(),s.forEach(e=>_e($,e)))}function _e(s,e){if(!e.mock)return;const{url:t,mockTemplate:n}=e;if(t&&n){const r=l.pathToRegexp(`${t}(.*)`),o=l.pathToRegexpMatch(t,{decode:decodeURIComponent}),a=R(n,{},!0);s.mock(r,i=>{const u=l.url.parse(i.url)||{},c=i.body instanceof FormData?l.formDataToJson(i.body):i.body,m=o(i.url)?.params;return Object.assign(i,{data:c,params:u,query:m}),s.mock(a(i))})}}function K(){$&&($._mocked={})}const qe={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",keyPrefix:""},W=Symbol("access");class Ve{options;data=null;mode=y.Raw;constructor(e){this.options=Object.assign({},qe,e),this.loadData()}connect(e){const{mode:t,router:n,request:r}=e;this.mode=t,n&&t===y.Raw&&this.setGuard(n),r&&this.setRequest(r)}login(e){const{storageKey:t,storagePrefix:n,session:r,authKey:o}=this.options;this.setData(e),this.data&&(l.storage.save(t,e,{type:"local",prefix:n}),r&&l.cookie.set(o,this.data.token))}clear(){const{storageKey:e,storagePrefix:t,session:n,authKey:r}=this.options;this.data=null,l.storage.remove(e,{type:"local",prefix:t}),n&&l.cookie.remove(r)}logout(){this.clear(),this.toLogin()}getData(){return this.data}getToken(){return this.data?.token}can(e){const{keyPrefix:t}=this.options,{permissions:n={}}=this.data||{};return typeof e=="function"?e(n):l.toArray(e).every(o=>n[o]||n[t+o])}some(e){const{keyPrefix:t}=this.options,{permissions:n={}}=this.data||{};return l.toArray(e).some(o=>n[o]||n[t+o])}install(e){e.config.globalProperties.$access||(e.config.globalProperties.$access=this),e.provide(W,this)}isAuthPath(e){const{auth:t,isAuth:n}=this.options;if(n)return n(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||this.mode!==y.Raw)return;const n=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(n):location.href=t?`${e}${n}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const n=e.map(r=>l.unRSA(r,t));this.data=JSON.parse(n.join(""));return}if(typeof e=="string")try{const n=t?l.unRSA(e,t):e;n?this.data=JSON.parse(n):console.warn("RSA解密失败或登录信息缺失")}catch(n){console.warn(n)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,n=l.storage.get(e,{type:"local",prefix:t});this.setData(n)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!l.cookie.get(t):!!this.data}hasRoutePermission(e){if(e.name===D){const t=e.params.id;return t&&this.can(t)}return!0}setGuard(e){e.beforeEach((t,n,r)=>this.guard(t,r))}guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:n="无权限访问",unauthorized:r=!1}=this.options;return this.showTip(n),l.isFunction(r)?(r(),t(!1)):l.isString(r)?t(r):t(!1)}}t(!1),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(n=>e.fullPath.startsWith(n)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401}=this.options;return e.status===t||e.data.code===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 t?(await l.delay(150),await t(e,{title:"提示",type:"warning"}).catch(()=>!1)):!1}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(await this.showUnauthorizedAlert(t),t),async t=>{const n=t.response||t||{};return await this.showUnauthorizedAlert(n),Promise.reject(t)})}}function we(){return p.inject(W,null)}class Se{__id=null;__mode;__instance=null;__contextRefs={};__refs={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};__transform={};constructor(e){const{mode:t,dsl:n,attrs:r}=e;this.__mode=t,n&&(this.__id=n.id||null,this.__transform=n.transform||{}),r&&Object.assign(this,r)}setup(e,t=I){const n=t.getCurrentInstance();if(!n)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=n.proxy;const r=n.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__refs={},this.$refs={},this.__contextRefs={},this.context={}})}__proxy(){this.__instance&&L.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){L.forEach(e=>{this[e]=null})}__parseFunction(e){if(e)if(this.__mode===y.Runtime){const{id:t,type:n}=e,r=t?this.__transform[t]??e.value:e.value;return J({type:n,value:r},this)}else return J(e,this)}__parseExpression(e){if(e)if(this.__mode===y.Runtime){const{id:t,type:n}=e,r=t?this.__transform[t]??e.value:e.value;return R({type:n,value:r},this)}else return R(e,this)}__ref(e=null,t){if(this.__mode!==y.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async n=>{await l.delay(0);let r=n?.$vtjEl||n?.$el||n?._?.vnode?.el||n;if(!r){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}if(r.nodeType===3&&r.nextSibling&&(r=r.nextSibling),r.__vtj__=e,y.Design===this.__mode&&(r.__context__=this,r.draggable=!0),e&&(this.__refs[e]=n),typeof t=="function")t(n);else if(t){const o=this.$refs[t];if(o&&n!==o){const a=new Set([].concat(o,n));this.$refs[t]=Array.from(a)}else this.$refs[t]=n}return n}}__clone(e={}){const t={...this.context,...e},n={...t,context:t};return n.context.__proto__=this.context,n.__proto__=this,n}}function M(s){const{Vue:e=I,mode:t=y.Runtime,components:n={},libs:r={},apis:o={},loader:a}=s,i=e.computed(()=>s.dsl),u={$components:n,$libs:r,$apis:o},c=new Se({mode:t,dsl:i.value,attrs:u}),m=e.defineComponent({name:i.value.name,props:{...Ke(i.value.props??[],c)},setup(f){c.$props=f,c.props=f,i.value.id&&z(s.window||window,i.value.id,i.value.css||""),c.state=We(e,i.value.state??{},c);const d=Ge(e,i.value.computed??{},c),g=Ye(i.value.methods??{},c),h=Qe(e,i.value.inject,c),v=je(i.value.dataSources||{},c),j={...h,...d,...g,...v};return c.setup(j,e),Xe(e,i.value.watch??[],c),{vtj:c}},emits:ze(i.value.emits),expose:["vtj"],render(){if(!i.value.nodes)return null;const f=i.value.nodes||[];return f.length===1?A(f[0],c,e,a):f.map(d=>A(d,c,e,a))},...Ze(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(m),context:c}}function ze(s=[]){return s.map(e=>l.isString(e)?e:e.name)}function Ke(s=[],e){const t=n=>n?(Array.isArray(n)?n:[n]).map(o=>oe[o]):void 0;return s.map(n=>l.isString(n)?{name:n}:{name:n.name,type:n.type,required:n.required,default:E(n.default)?e.__parseExpression(n.default):n.default}).reduce((n,r)=>(n[r.name]={type:t(r.type),required:r.required,default:r.default},n),{})}function We(s,e,t){return s.reactive(Object.keys(e||{}).reduce((n,r)=>{let o=e[r];return E(o)?o=t.__parseExpression(o):F(o)&&(o=t.__parseFunction(o)),n[r]=o,n},{}))}function Ge(s,e,t){return Object.entries(e??{}).reduce((n,[r,o])=>(n[r]=s.computed(t.__parseFunction(o)),n),{})}function Ye(s,e){return Object.entries(s??{}).reduce((t,[n,r])=>(t[n]=e.__parseFunction(r),t),{})}function Qe(s,e=[],t){return e.reduce((n,r)=>{const{name:o,from:a}=r||{};r.default;const i=E(a)?t.__parseExpression(a)||o:a??o,u=E(r.default)?t.__parseExpression(r.default):r.default??null;return n[o]=s.inject(i,u),n},{})}function je(s,e){return Object.keys(s).reduce((t,n)=>{const r=s[n],o=e.$apis[r.ref],a=F(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;return t[n]=async(...i)=>{const u=await o.apply(e,i);return a?a(u):u},t},{})}function Xe(s,e=[],t){e.forEach(n=>{s.watch(t.__parseExpression(n.source),t.__parseFunction(n.handler),{deep:n.deep,immediate:n.immediate})})}function Ze(s,e){return Object.entries(s??{}).reduce((t,[n,r])=>(t[n]=e.__parseFunction(r),t),{})}let B=[];const Ee=s=>s;async function G(s,e=window){const{urls:t=[],library:n}=s,r=t.filter(i=>N(i));if(r.length===0||!n)return null;const o=t.filter(i=>H(i));return o.length&&de(o,e),await pe(r,n,e).catch(i=>(console.warn("loadScriptUrl error",r,n,i),null))}function T(s){const{getDsl:e,getDslByUrl:t,options:n}=s;return n.window&&(B.forEach(r=>{delete n.window[r]}),B=[]),(r,o,a=I)=>!o||typeof o=="string"?r:o.type==="Schema"&&o.id?a.defineAsyncComponent(async()=>{const i=await e(o.id);return i&&(i.name=r),i?M({...n,Vue:a,dsl:i,mode:y.Runtime,loader:T(s)}).renderer:null}):o.type==="UrlSchema"&&o.url?a.defineAsyncComponent(async()=>{const i=await t(o.url);return i&&(i.name=r),i?M({...n,Vue:a,dsl:i,mode:y.Runtime,loader:T(s)}).renderer:null}):o.type==="Plugin"?(o.library&&B.push(o.library),a.defineAsyncComponent(async()=>{const i=await G(o,n.window);return i||(console.warn("getPlugin result is null",o),null)})):r}function A(s,e,t=I,n=Ee){if(!s||!s.name||s.invisible)return null;const{id:r=null,directives:o=[]}=s,{vIf:a,vFor:i,vShow:u,vModels:c,vBind:m}=et(o);if(a&&!tt(a,e))return null;const f=d=>{const g=d.$components,h=(()=>{if(s.name==="component")return nt(d,s.props?.is);if(s.name==="slot")return s.name;const w=n(s.name,s.from,t);return l.isString(w)?g[w]??w:w})(),v=st(r,s.props??{},d),j=rt(t,s.events??{},d);if(s.name==="slot")return ot(t,s,v,d,n);m&&Object.assign(v,d.__parseExpression(m.value)),u&&(v.style=Object.assign(v.style??{},at(u,d))),c.forEach(w=>{Object.assign(v,ct(t,w,d))});const _=lt(t,s.children??[],d,n,s);return t.createVNode(h,{...v,...j},_)};return i?pt(i,f,e):f(e)}function et(s=[]){const e=s.find(i=>l.camelCase(i.name)==="vIf"),t=s.find(i=>l.camelCase(i.name)==="vFor"),n=s.find(i=>l.camelCase(i.name)==="vShow"),r=s.find(i=>l.camelCase(i.name)==="vBind"),o=s.filter(i=>l.camelCase(i.name)==="vModel"),a=s.filter(i=>!re.includes(l.camelCase(i.name)));return{vIf:e,vFor:t,vShow:n,vModels:o,vBind:r,others:a}}function tt(s,e){return!!e.__parseExpression(s.value)}function nt(s,e){return e?E(e)?s.__parseExpression(e):e:"div"}function st(s,e,t){const n=Object.keys(e||{}).reduce((r,o)=>{let a=e[o];return E(a)?a=t.__parseExpression(a):F(a)&&(a=t.__parseFunction(a)),r[o]=a,r},{});return n.ref=t.__ref(s,n.ref),n}function rt(s,e,t){const n=["passive","capture","once"],r={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],u=Y(i.modifiers),c=u.find(d=>n.includes(d)),m="on"+l.upperFirst(a)+(c&&r[c]||""),f=t.__parseFunction(i.handler);return f&&(o[m]=s.withModifiers(f,u)),o},{})}function Y(s={},e=!1){const t=Object.keys(s);return e?t.map(n=>"."+n):t}function ot(s,e,t,n,r){const{children:o}=e,a=it(e,n),i=n.$slots?.[a.name];return i?i(t):o?l.isString(o)?s.createTextVNode(o):E(o)?s.createTextVNode(V(n.__parseExpression(o))):Array.isArray(o)?o.map(u=>A(u,n,s,r)):null:null}function it(s,e){const{props:t}=s,n=t?.name||"default";return{name:E(n)?e.__parseExpression(n):n,params:[]}}function at(s,e){return e.__parseExpression(s.value)?{}:{display:"none"}}function ct(s,e,t){const n={type:"JSFunction",value:e.value?.value?`(v) => {
|
7
|
+
*/const C="0.9.0-alpha.17";var y=(s=>(s.Runtime="Runtime",s.Design="Design",s.Raw="Raw",s.VNode="VNode",s))(y||{});const J=["$el","$emit","$nextTick","$parent","$root","$attrs","$slots","$watch","$props","$options","$forceUpdate"],Ne=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeUnmount","unmounted","errorCaptured","renderTracked","renderTriggered","activated","deactivated"],re=["vIf","vShow","vModel","vFor","vBind"],oe={String,Number,Boolean,Array,Object,Function,Date},R="VtjPage",A="VtjHomepage";function k(s,e){return s.map(t=>l.isUrl(t)||t.startsWith("/")?t:`${e}${t}`)}function N(s){return/\.css$/.test(s)}function U(s){return/\.js$/.test(s)}function ie(s){return/\.json$/.test(s)}function Ue(s){return s.map(e=>`<script src="${l.url.append(e,{v:C})}"><\/script>`).join("")}function Be(s=[]){return s.map(e=>`<link rel="stylesheet" href="${l.url.append(e,{v:C})}" />`).join("")}function ae(s,e=!1){return e&&s.endsWith(".prod.js")?s.replace(".prod.js",".js"):s}function ce(s,e,t=!1){const n=s.filter(d=>!!d.enabled),r=[],o=[],a=[],i=[],u={},c={},m=[],f={};return n.forEach(({urls:d,assetsUrl:g,library:h,assetsLibrary:v,localeLibrary:E})=>{d?.forEach(_=>{U(_)&&r.push(ae(_,t)),N(_)&&o.push(_)}),h&&(i.push(h),u[h]=k(d||[],e),E&&(c[h]=E)),g&&a.push(g),v&&m.push(v),h&&v&&(f[v]=h)}),{scripts:k(r,e),css:k(o,e),materials:k(a,e),libraryExports:i,materialExports:l.dedupArray(m),materialMapLibrary:f,libraryMap:u,libraryLocaleMap:c}}function le(s,e){const{name:t,parent:n,alias:r}=s;return n?e[n]?.[r||t]:e[r||t]}function V(s){return l.isString(s)?s:JSON.stringify(s)}function z(s,e,t){const n=s.CSSStyleSheet;if(n.prototype.replaceSync){const r=new n;r.id=e,r.replaceSync(t);const o=s.document,a=o.adoptedStyleSheets,i=Array.from(a).filter(u=>u.id!==e);o.adoptedStyleSheets=[...i,r]}else{const r=s.document;let o=r.getElementById(e);o?o.innerHTML=t:(o=r.createElement("style"),o.id=e,o.innerHTML=t,r.head.appendChild(o))}}async function ue(s,e){const t=await window.fetch(e).then(n=>n.text()).catch(()=>"");t&&z(window,s,t)}function de(s,e=window){const t=e.document,n=e.document.head;for(const r of s)if(!t.getElementById(r)){const a=t.createElement("link");a.rel="stylesheet",a.id=r,a.href=r,n.appendChild(a)}}async function pe(s,e,t=window){const n=t.document,r=t.document.head;let o=t[e];return o?o.default||o:new Promise((a,i)=>{for(const u of s){const c=n.createElement("script");c.src=u,c.onload=()=>{o=t[e],o?a(o.default||o):i(null)},c.onerror=m=>{i(m)},r.appendChild(c)}})}function fe(s){return l.isFunction(s)||l.isFunction(s?.install)}function x(s,e,t=!1,n=!1){try{const r=['"use strict";',"var __self = arguments[0];"];r.push("return ");let o=(s.value||"").trim();o=o.replace(/this(\W|$)/g,(i,u)=>`__self${u}`),o=r.join(`
|
8
|
+
`)+o;const a=`with(${t?"{}":"$scope || {}"}) { ${o} }`;return new Function("$scope",a)(e)}catch(r){if(l.logger.error("parseExpression.error",r,s,e?.__self??e),n)throw r}}function q(s,e,t=!1,n=!1){const r=x(s,e,t,n);if(typeof r!="function"&&(l.logger.error("parseFunction.error","not a function",s,e?.__self??e),n))throw new Error(`"${s.value}" not a function`);return r}function j(s){return s&&s.type==="JSExpression"}function M(s){return typeof s=="object"&&s&&s.type==="JSFunction"}function he(s){return j(s)||M(s)}function Le(s){return he(s)?s.value:JSON.stringify(s)}let P=null;const Je=l.createRequest({settings:{type:"form",validSuccess:!0,originResponse:!1,loading:!0,validate:s=>s.data?.code===0||!!s.data?.success,failMessage:!0,showError:s=>{F.ElNotification.error({message:s||"未知错误"})},showLoading:()=>{P&&P.close(),P=F.ElLoading.service({lock:!0,text:"Loading",background:"rgba(0, 0, 0, 0.05)"})},hideLoading:()=>{P&&(P.close(),P=null)}}});let $;function me(s,e){const{jsonp:t,request:n}=e;if(s.method==="jsonp")return(r={})=>t(s.url,{...s.jsonpOptions,query:r});{const r=s.headers?x(s.headers,{},!0):void 0,o={url:s.url,method:s.method,settings:{...s.settings,headers:r}};return(a,i)=>(delete o.data,n.send(l.merge(o,i||{},{data:a})))}}function ge(s,e){const{metaQuery:t}=e;if(!t)return;const{code:n,queryCode:r}=s;return(o,a)=>{if(!t){console.warn("adapter.metaQuery is not defined!");return}return t(n,r,o,a)}}function ve(s=[],e=[],t){const n={};for(const r of s)n[r.id]=me(r,t);for(const r of e)n[r.id]=ge(r,t);return n}async function ye(s=[]){$=await import("mockjs").then(e=>e.default||e),$&&($.setup({timeout:"50-500"}),K(),s.forEach(e=>_e($,e)))}function _e(s,e){if(!e.mock)return;const{url:t,mockTemplate:n}=e;if(t&&n){const r=l.pathToRegexp(`${t}(.*)`),o=l.pathToRegexpMatch(t,{decode:decodeURIComponent}),a=x(n,{},!0);s.mock(r,i=>{const u=l.url.parse(i.url)||{},c=i.body instanceof FormData?l.formDataToJson(i.body):i.body,m=o(i.url)?.params;return Object.assign(i,{data:c,params:u,query:m}),s.mock(a(i))})}}function K(){$&&($._mocked={})}const qe={session:!1,authKey:"Authorization",storageKey:"ACCESS_STORAGE",storagePrefix:"__VTJ_",unauthorized:void 0,auth:"/#/login",redirectParam:"r",unauthorizedCode:401,unauthorizedMessage:"登录已经失效,请重新登录!",noPermissionMessage:"无权限访问该页面",keyPrefix:""},W=Symbol("access");class Ve{options;data=null;mode=y.Raw;constructor(e){this.options=Object.assign({},qe,e),this.loadData()}connect(e){const{mode:t,router:n,request:r}=e;this.mode=t,n&&t===y.Raw&&this.setGuard(n),r&&this.setRequest(r)}login(e){const{storageKey:t,storagePrefix:n,session:r,authKey:o}=this.options;this.setData(e),this.data&&(l.storage.save(t,e,{type:"local",prefix:n}),r&&l.cookie.set(o,this.data.token))}clear(){const{storageKey:e,storagePrefix:t,session:n,authKey:r}=this.options;this.data=null,l.storage.remove(e,{type:"local",prefix:t}),n&&l.cookie.remove(r)}logout(){this.clear(),this.toLogin()}getData(){return this.data}getToken(){return this.data?.token}can(e){const{keyPrefix:t}=this.options,{permissions:n={}}=this.data||{};return typeof e=="function"?e(n):l.toArray(e).every(o=>n[o]||n[t+o])}some(e){const{keyPrefix:t}=this.options,{permissions:n={}}=this.data||{};return l.toArray(e).some(o=>n[o]||n[t+o])}install(e){e.config.globalProperties.$access||(e.config.globalProperties.$access=this),e.provide(W,this)}isAuthPath(e){const{auth:t,isAuth:n}=this.options;if(n)return n(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||this.mode!==y.Raw)return;const n=t?`?${t}=${encodeURIComponent(location.href)}`:"";typeof e=="function"?e(n):location.href=t?`${e}${n}`:e}setData(e){const{privateKey:t}=this.options;if(Array.isArray(e)&&t){const n=e.map(r=>l.unRSA(r,t));this.data=JSON.parse(n.join(""));return}if(typeof e=="string")try{const n=t?l.unRSA(e,t):e;n?this.data=JSON.parse(n):console.warn("RSA解密失败或登录信息缺失")}catch(n){console.warn(n)}else this.data=e}loadData(){const{storageKey:e,storagePrefix:t}=this.options,n=l.storage.get(e,{type:"local",prefix:t});this.setData(n)}isLogined(){const{session:e,authKey:t}=this.options;return e&&t?!!l.cookie.get(t):!!this.data}hasRoutePermission(e){if(e.name===R){const t=e.params.id;return t&&this.can(t)}return!0}setGuard(e){e.beforeEach((t,n,r)=>this.guard(t,r))}guard(e,t){if(this.isWhiteList(e)||this.isAuthPath(e))return t();if(this.isLogined()){if(this.hasRoutePermission(e))return t();{const{noPermissionMessage:n="无权限访问",unauthorized:r=!1}=this.options;return this.showTip(n),l.isFunction(r)?(r(),t(!1)):l.isString(r)?t(r):t(!1)}}t(!1),this.toLogin()}isWhiteList(e){const{whiteList:t}=this.options;return t?Array.isArray(t)?t.some(n=>e.fullPath.startsWith(n)):t(e):!1}isUnauthorized(e){const{unauthorizedCode:t=401}=this.options;return e.status===t||e.data.code===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 t?(await l.delay(150),await t(e,{title:"提示",type:"warning"}).catch(()=>!1)):!1}setRequest(e){e.useRequest(t=>(this.data?.token&&(t.headers[this.options.authKey]=this.data?.token),t)),e.useResponse(async t=>(await this.showUnauthorizedAlert(t),t),async t=>{const n=t.response||t||{};return await this.showUnauthorizedAlert(n),Promise.reject(t)})}}function we(){return p.inject(W,null)}class Se{__id=null;__mode;__instance=null;__contextRefs={};__refs={};context={};state={};props={};$props={};$refs={};$el=null;$emit=null;$nextTick=null;$parent=null;$root=null;$attrs=null;$slots=null;$watch=null;$options=null;$forceUpdate=null;$components={};$libs={};$apis={};__transform={};constructor(e){const{mode:t,dsl:n,attrs:r}=e;this.__mode=t,n&&(this.__id=n.id||null,this.__transform=n.transform||{}),r&&Object.assign(this,r)}setup(e,t=H){const n=t.getCurrentInstance();if(!n)return;this.__refs={},this.$refs={},this.context={},this.__contextRefs={},this.__instance=n.proxy;const r=n.appContext.config.globalProperties;Object.assign(this,r),Object.assign(this,e||{}),this.__proxy(),t.onMounted(()=>{this.__proxy()}),t.onUnmounted(()=>{this.__cleanup()}),t.onBeforeUpdate(()=>{this.__refs={},this.$refs={},this.__contextRefs={},this.context={}})}__proxy(){this.__instance&&J.forEach(e=>{this[e]=this.__instance?.[e]})}__cleanup(){J.forEach(e=>{this[e]=null})}__parseFunction(e){if(e)if(this.__mode===y.Runtime){const{id:t,type:n}=e,r=t?this.__transform[t]??e.value:e.value;return q({type:n,value:r},this)}else return q(e,this)}__parseExpression(e){if(e)if(this.__mode===y.Runtime){const{id:t,type:n}=e,r=t?this.__transform[t]??e.value:e.value;return x({type:n,value:r},this)}else return x(e,this)}__ref(e=null,t){if(this.__mode!==y.VNode)return e&&e!==this.__id&&(this.__contextRefs[e]=this),async n=>{await l.delay(0);let r=n?.$vtjEl||n?.$el||n?._?.vnode?.el||n;if(!r){typeof t=="string"&&(delete this.$refs[t],e&&delete this.__refs[e]);return}if(r.nodeType===3&&r.nextSibling&&(r=r.nextSibling),r.__vtj__=e,y.Design===this.__mode&&(r.__context__=this,r.draggable=!0),e&&(this.__refs[e]=n),typeof t=="function")t(n);else if(t){const o=this.$refs[t];if(o&&n!==o){const a=new Set([].concat(o,n));this.$refs[t]=Array.from(a)}else this.$refs[t]=n}return n}}__clone(e={}){const t={...this.context,...e},n={...t,context:t};return n.context.__proto__=this.context,n.__proto__=this,n}}function I(s){const{Vue:e=H,mode:t=y.Runtime,components:n={},libs:r={},apis:o={},loader:a}=s,i=e.computed(()=>s.dsl),u={$components:n,$libs:r,$apis:o},c=new Se({mode:t,dsl:i.value,attrs:u}),m=e.defineComponent({name:i.value.name,props:{...Ke(i.value.props??[],c)},setup(f){c.$props=f,c.props=f,i.value.id&&z(s.window||window,i.value.id,i.value.css||""),c.state=We(e,i.value.state??{},c);const d=Ge(e,i.value.computed??{},c),g=Ye(i.value.methods??{},c),h=Qe(e,i.value.inject,c),v=Ee(i.value.dataSources||{},c),E={...h,...d,...g,...v};return c.setup(E,e),Xe(e,i.value.watch??[],c),{vtj:c}},emits:ze(i.value.emits),expose:["vtj"],render(){if(!i.value.nodes)return null;const f=i.value.nodes||[];return f.length===1?O(f[0],c,e,a):f.map(d=>O(d,c,e,a))},...Ze(i.value.lifeCycles??{},c)});return{renderer:e.markRaw(m),context:c}}function ze(s=[]){return s.map(e=>l.isString(e)?e:e.name)}function Ke(s=[],e){const t=n=>n?(Array.isArray(n)?n:[n]).map(o=>oe[o]):void 0;return s.map(n=>l.isString(n)?{name:n}:{name:n.name,type:n.type,required:n.required,default:j(n.default)?e.__parseExpression(n.default):n.default}).reduce((n,r)=>(n[r.name]={type:t(r.type),required:r.required,default:r.default},n),{})}function We(s,e,t){return s.reactive(Object.keys(e||{}).reduce((n,r)=>{let o=e[r];return j(o)?o=t.__parseExpression(o):M(o)&&(o=t.__parseFunction(o)),n[r]=o,n},{}))}function Ge(s,e,t){return Object.entries(e??{}).reduce((n,[r,o])=>(n[r]=s.computed(t.__parseFunction(o)),n),{})}function Ye(s,e){return Object.entries(s??{}).reduce((t,[n,r])=>(t[n]=e.__parseFunction(r),t),{})}function Qe(s,e=[],t){return e.reduce((n,r)=>{const{name:o,from:a}=r||{};r.default;const i=j(a)?t.__parseExpression(a)||o:a??o,u=j(r.default)?t.__parseExpression(r.default):r.default??null;return n[o]=s.inject(i,u),n},{})}function Ee(s,e){return Object.keys(s).reduce((t,n)=>{const r=s[n],o=e.$apis[r.ref],a=M(r.transform)?r.transform.value?e.__parseFunction(r.transform):void 0:r.transform;return t[n]=async(...i)=>{const u=await o.apply(e,i);return a?a(u):u},t},{})}function Xe(s,e=[],t){e.forEach(n=>{s.watch(t.__parseExpression(n.source),t.__parseFunction(n.handler),{deep:n.deep,immediate:n.immediate})})}function Ze(s,e){return Object.entries(s??{}).reduce((t,[n,r])=>(t[n]=e.__parseFunction(r),t),{})}let L=[];const je=s=>s;async function G(s,e=window){const{urls:t=[],library:n}=s,r=t.filter(i=>U(i));if(r.length===0||!n)return null;const o=t.filter(i=>N(i));return o.length&&de(o,e),await pe(r,n,e).catch(i=>(console.warn("loadScriptUrl error",r,n,i),null))}function D(s){const{getDsl:e,getDslByUrl:t,options:n}=s;return n.window&&(L.forEach(r=>{delete n.window[r]}),L=[]),(r,o,a=H)=>!o||typeof o=="string"?r:o.type==="Schema"&&o.id?a.defineAsyncComponent(async()=>{const i=await e(o.id);return i&&(i.name=r),i?I({...n,Vue:a,dsl:i,mode:y.Runtime,loader:D(s)}).renderer:null}):o.type==="UrlSchema"&&o.url?a.defineAsyncComponent(async()=>{const i=await t(o.url);return i&&(i.name=r),i?I({...n,Vue:a,dsl:i,mode:y.Runtime,loader:D(s)}).renderer:null}):o.type==="Plugin"?(o.library&&L.push(o.library),a.defineAsyncComponent(async()=>{const i=await G(o,n.window);return i||(console.warn("getPlugin result is null",o),null)})):r}function O(s,e,t=H,n=je){if(!s||!s.name||s.invisible)return null;const{id:r=null,directives:o=[]}=s,{vIf:a,vFor:i,vShow:u,vModels:c,vBind:m}=et(o);if(a&&!tt(a,e))return null;const f=d=>{const g=d.$components,h=(()=>{if(s.name==="component")return nt(d,s.props?.is);if(s.name==="slot")return s.name;const w=n(s.name,s.from,t);return l.isString(w)?g[w]??w:w})(),v=st(r,s.props??{},d),E=rt(t,s.events??{},d);if(s.name==="slot")return ot(t,s,v,d,n);m&&Object.assign(v,d.__parseExpression(m.value)),u&&(v.style=Object.assign(v.style??{},at(u,d))),c.forEach(w=>{Object.assign(v,ct(t,w,d))});const _=lt(t,s.children??[],d,n,s);return t.createVNode(h,{...v,...E},_)};return i?pt(i,f,e):f(e)}function et(s=[]){const e=s.find(i=>l.camelCase(i.name)==="vIf"),t=s.find(i=>l.camelCase(i.name)==="vFor"),n=s.find(i=>l.camelCase(i.name)==="vShow"),r=s.find(i=>l.camelCase(i.name)==="vBind"),o=s.filter(i=>l.camelCase(i.name)==="vModel"),a=s.filter(i=>!re.includes(l.camelCase(i.name)));return{vIf:e,vFor:t,vShow:n,vModels:o,vBind:r,others:a}}function tt(s,e){return!!e.__parseExpression(s.value)}function nt(s,e){return e?j(e)?s.__parseExpression(e):e:"div"}function st(s,e,t){const n=Object.keys(e||{}).reduce((r,o)=>{let a=e[o];return j(a)?a=t.__parseExpression(a):M(a)&&(a=t.__parseFunction(a)),r[o]=a,r},{});return n.ref=t.__ref(s,n.ref),n}function rt(s,e,t){const n=["passive","capture","once"],r={capture:"Capture",once:"Once",passive:"OnceCapture"};return Object.keys(e||{}).reduce((o,a)=>{const i=e[a],u=Y(i.modifiers),c=u.find(d=>n.includes(d)),m="on"+l.upperFirst(a)+(c&&r[c]||""),f=t.__parseFunction(i.handler);return f&&(o[m]=s.withModifiers(f,u)),o},{})}function Y(s={},e=!1){const t=Object.keys(s);return e?t.map(n=>"."+n):t}function ot(s,e,t,n,r){const{children:o}=e,a=it(e,n),i=n.$slots?.[a.name];return i?i(t):o?l.isString(o)?s.createTextVNode(o):j(o)?s.createTextVNode(V(n.__parseExpression(o))):Array.isArray(o)?o.map(u=>O(u,n,s,r)):null:null}function it(s,e){const{props:t}=s,n=t?.name||"default";return{name:j(n)?e.__parseExpression(n):n,params:[]}}function at(s,e){return e.__parseExpression(s.value)?{}:{display:"none"}}function ct(s,e,t){const n={type:"JSFunction",value:e.value?.value?`(v) => {
|
9
9
|
${e.value.value} = v;
|
10
|
-
}`:"(v) => {}"},r=t.__parseFunction(n),o=Y(e.modifiers),a=
|
10
|
+
}`:"(v) => {}"},r=t.__parseFunction(n),o=Y(e.modifiers),a=j(e.arg)?t.__parseExpression(e.arg):e.arg||"modelValue";return{[a]:t.__parseExpression(e.value),[`onUpdate:${a}`]:o.length&&r?s.withModifiers(r,o):r}}function lt(s,e,t,n,r){if(!e)return null;if(l.isString(e))return{default:()=>e};if(j(e))return{default:()=>V(t.__parseExpression(e))};if(Array.isArray(e)&&e.length>0){const o=ut(e),a=i=>!i||!r?{}:r?.id&&Object.keys(i).length?{[`scope_${r.id}`]:i}:{};return Object.entries(o).reduce((i,[u,{nodes:c,params:m}])=>(i[u]=f=>{const d=m.length?l.pick(f??{},m):a(f);return c.map(g=>O(g,t.__clone(d),s,n))},i),{})}return null}function ut(s){const e={default:{params:[],nodes:[]}};for(const t of s){const n=dt(t.slot),r=n.name;e[r]?(e[r].nodes.push(t),e[r].params=e[r].params.concat(n.params)):e[r]={nodes:[t],params:n.params}}return e}function dt(s="default"){return l.isString(s)?{name:s,params:[]}:{params:[],...s}}function pt(s,e,t){const{value:n,iterator:r}=s,{item:o="item",index:a="index"}=r||{};let i=t.__parseExpression(n)||[];return Number.isInteger(i)&&(i=new Array(i).fill(!0).map((u,c)=>c+1)),Array.isArray(i)?i.map((u,c)=>e(t.__clone({[o]:u,[a]:c}))):(console.warn("[vForRender]:",`${n?.value} is not a Arrary`),[])}function ft(s){return p.getCurrentScope()?(p.onScopeDispose(s),!0):!1}function Q(s){return typeof s=="function"?s():p.unref(s)}const be=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const ht=s=>s!=null,mt=()=>{};function gt(s){return p.getCurrentInstance()}function vt(...s){if(s.length!==1)return p.toRef(...s);const e=s[0];return typeof e=="function"?p.readonly(p.customRef(()=>({get:e,set:mt}))):p.ref(e)}function yt(s,e){gt()&&p.onBeforeUnmount(s,e)}const _t=be?window:void 0,wt=be?window.document:void 0;function St(s){var e;const t=Q(s);return(e=t?.$el)!=null?e:t}function Et(){const s=p.ref(!1),e=p.getCurrentInstance();return e&&p.onMounted(()=>{s.value=!0},e),s}function jt(s){const e=Et();return p.computed(()=>(e.value,!!s()))}function bt(s,e,t={}){const{window:n=_t,...r}=t;let o;const a=jt(()=>n&&"MutationObserver"in n),i=()=>{o&&(o.disconnect(),o=void 0)},u=p.computed(()=>{const d=Q(s),g=(Array.isArray(d)?d:[d]).map(St).filter(ht);return new Set(g)}),c=p.watch(()=>u.value,d=>{i(),a.value&&d.size&&(o=new MutationObserver(e),d.forEach(g=>o.observe(g,r)))},{immediate:!0,flush:"post"}),m=()=>o?.takeRecords(),f=()=>{c(),i()};return ft(f),{isSupported:a,stop:f,takeRecords:m}}function Pt(s=null,e={}){var t,n,r;const{document:o=wt,restoreOnUnmount:a=f=>f}=e,i=(t=o?.title)!=null?t:"",u=vt((n=s??o?.title)!=null?n:null),c=s&&typeof s=="function";function m(f){if(!("titleTemplate"in e))return f;const d=e.titleTemplate||"%s";return typeof d=="function"?d(f):Q(d).replace(/%s/g,f)}return p.watch(u,(f,d)=>{f!==d&&o&&(o.title=m(typeof f=="string"?f:""))},{immediate:!0}),e.observe&&!e.titleTemplate&&o&&!c&&bt((r=o.head)==null?void 0:r.querySelector("title"),()=>{o&&o.title!==u.value&&(u.value=m(o.title))},{childList:!0}),yt(()=>{if(a){const f=a(i,u.value||"");f!=null&&o&&(o.title=f)}}),u}const ne=p.defineComponent({name:"VtjPageContainer",async setup(){const s=Z(),e=se.useRoute(),t=e.params.id,n=t?s.getPage(t):s.getHomepage(),r=n?await s.getRenderComponent(n.id):null;return n&&(Object.assign(e.meta,n.meta||{}),Pt(n.title||"VTJ")),{provider:s,component:r,file:n,query:e.query,meta:n?.meta}},render(){const{component:s,query:e}=this;return s?p.h(s,e):p.h("div","页面不存在")}}),$t={"data-l-h6o7ki7":"",class:"vtj-startup__wrapper"},Ct={"data-l-h6o7ki7":"",class:"vtj-startup"},Rt={"data-l-h6o7ki7":"",class:"vtj-startup__name"},xt={"data-l-h6o7ki7":""},kt={"data-l-h6o7ki7":"",class:"vtj-startup__tagline"},At={"data-l-h6o7ki7":"",class:"vtj-startup__actions"},Pe=p.defineComponent({__name:"Startup",props:{name:{default:"VTJ.PRO"},tagline:{default:"基于 Vue3 + TypeScript 快速打造高生产力的低代码研发平台"},actionText:{default:"开始设计"}},setup(s){((r,o)=>{let a=document.getElementById("h6o7ki7");a||(a=document.createElement("style"),a.id="h6o7ki7",document.head.appendChild(a),a.innerHTML=o)})("h6o7ki7",`
|
11
11
|
.vtj-startup[data-l-h6o7ki7]{
|
12
12
|
padding: 20px;
|
13
13
|
border-radius: 4px;
|
@@ -72,4 +72,4 @@
|
|
72
72
|
}
|
73
73
|
.vtj-startup__actions button[data-l-h6o7ki7]:hover{
|
74
74
|
opacity: 0.7;
|
75
|
-
}`);const t=s,n=()=>{if(typeof window<"u"){let o=(window.__VTJ_LINK__||{}).href||window.location.pathname+"__vtj__/#/";window.location.href=o}};return(r,o)=>(p.openBlock(),p.createElementBlock("div",$t,[p.createElementVNode("div",Ct,[p.createElementVNode("h1",Rt,[p.createElementVNode("span",xt,p.toDisplayString(t.name),1)]),p.createElementVNode("div",kt,p.toDisplayString(t.tagline),1),p.createElementVNode("div",At,[p.createElementVNode("button",{"data-l-h6o7ki7":"",onClick:n},p.toDisplayString(t.actionText),1)])])]))}}),Ft=p.defineComponent({name:"VtjStartupContainer",render(){return p.h(Pe)}}),X=Symbol("Provider");var $e=(s=>(s.Production="production",s.Development="development",s))($e||{});class Ce extends b.Base{constructor(e){super(),this.options=e;const{service:t,mode:n=y.Raw,dependencies:r,materials:o,project:a={},adapter:i={},globals:u={},modules:c={},router:m=null,materialPath:f="./",nodeEnv:d="development"}=e;this.mode=n,this.modules=c,this.service=t,this.router=m,this.materialPath=f,this.nodeEnv=d,r&&(this.dependencies=r),o&&(this.materials=o),Object.assign(this.globals,u),Object.assign(this.adapter,i);const{access:g,request:h}=this.adapter;g&&g.connect({mode:n,router:m,request:h}),n!==y.Design&&this.load(a)}mode;globals={};modules={};adapter={request:Je,jsonp:l.jsonp};apis={};dependencies={};materials={};library={};service;project=null;components={};nodeEnv="development";router=null;materialPath="./";urlDslCaches={};async load(e){const t=this.modules[`.vtj/projects/${e.id}.json`];if(this.project=t?await t():await this.service.init(e),!this.project)throw new Error("project is null");const{apis:n=[],meta:r=[]}=this.project,o=window;o.CKEDITOR_VERSION=void 0,this.nodeEnv!=="production"?await this.loadAssets(o):await this.loadDependencies(o),this.apis=ve(n,r,this.adapter),K(),this.project.config?.mock&&ye(n),this.initRouter(),this.triggerReady()}async loadDependencies(e){const t=Object.entries(this.dependencies);for(const[n,r]of t)e[n]||(e[n]=await r())}async loadAssets(e){const{dependencies:t=[]}=this.project,{dependencies:n,library:r,components:o,materialPath:a,nodeEnv:i}=this,{libraryExports:u,libraryMap:c,materials:m,materialExports:f,materialMapLibrary:d}=ce(t,a,i==="development");for(const h of u){const v=n[h],j=e[h];if(j)r[h]=j;else if(v)e[h]=r[h]=await v();else{const _=c[h]||[];for(const w of _)H(w)&&await ue(h,l.url.append(w,{v:C})),N(w)&&await l.loadScript(l.url.append(w,{v:C}));r[h]=e[h]}}for(const h of m)await l.loadScript(l.url.append(h,{v:C}));const g=this.materials||{};for(const h of f){const v=e[d[h]],j=b.BUILT_IN_COMPONENTS[h];if(j)v&&j.forEach(_=>{o[_]=v[_]});else{const _=g[h]?(await g[h]()).default:e[h];_&&v&&(_.components||[]).forEach(w=>{o[w.name]=le(w,v)})}}}initRouter(){const{router:e,project:t,options:n}=this;if(!e)return;const{routeParentName:r,pageRouteName:o="page",routeMeta:a}=n,i=r?"":"/",u={path:`${i}${o}/:id`,name:D,component:ne},c={path:i,name:q,component:t?.homepage?ne:Ft,meta:a};r?(e.addRoute(r,u),e.addRoute(r,c)):(e.addRoute(u),e.addRoute(c))}install(e){const t=e.config.globalProperties.installed||{};for(const[n,r]of Object.entries(this.library))!t[n]&&fe(r)&&(e.use(r),t[n]=!0);this.options.install&&e.use(this.options.install),this.adapter.access&&e.use(this.adapter.access),e.provide(X,this),e.config.globalProperties.installed=t,this.mode===y.Design&&(e.config.errorHandler=(n,r,o)=>{const a=r?.$options.name,i=typeof n=="string"?n:n?.message||n?.msg||"未知错误",u=`[ ${a} ] ${i} ${o}`;console.error("[VTJ Error]:",{err:n,instance:r,info:o},n?.stack),k.ElNotification.error({title:"未处理的异常:请在控制台查看详情",message:u})})}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(n=>n.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},n=(r,o=[])=>{for(const a of o){if(a.id===r)return a;if(a.children&&a.children.length){const i=n(r,a.children);if(i)return i}}};return n(e,t)||null}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):null}async getDsl(e){const t=this.modules[`.vtj/files/${e}.json`];return t?await t():this.service.getFile(e).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(n=>n.data).catch(()=>null))}createDslRenderer(e,t={}){const{library:n,components:r,mode:o,apis:a}=this,i={mode:o,Vue:n.Vue,components:r,libs:n,apis:a,window,...t},u=T({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return M({...i,dsl:e,loader:u})}async getRenderComponent(e,t){const n=this.getFile(e);if(!n)return l.logger.warn(`Can not find file: ${e}`),null;t&&t(n);const r=`.vtj/vue/${e}.vue`,o=this.modules[r];if(o)return(await o())?.default;const a=await this.getDsl(n.id);return a?this.createDslRenderer(a).renderer:(l.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return p.defineAsyncComponent(async()=>{const n=await this.getDslByUrl(e);return n?(n.name=t||n.name,this.createDslRenderer(n).renderer):null})}definePluginComponent(e){return p.defineAsyncComponent(async()=>await G(e,window))}}function Ot(s){const e=new Ce(s);return{provider:e,onReady:n=>e.ready(n)}}function Z(s={}){const e=p.inject(X);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:n}=s;t&&n&&(async()=>{const r=await e.getDsl(t);r?.__VERSION__!==n&&k.ElNotification.warning({title:r?.name,message:"当前组件源码版本与运行时版本不一致,请重新发布组件"})})()}return e}const ee=new l.Request({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:s=>s.data?.code===0,showError:s=>{k.ElNotification.error({message:s||"未知错误"})}}}),Mt=(s="/__vtj__/api/:type.json")=>(e,t)=>ee.send({url:s,method:"post",params:{type:e},data:{type:e,data:t}}),Tt=(s="/__vtj__/api/uploader.json")=>async(e,t)=>await ee.send({url:s,method:"post",data:{files:e,projectId:t},settings:{type:"data"}}).then(n=>n&&n[0]?n[0]:null).catch(()=>null);class U{api;pluginCaches={};uploader;constructor(){this.api=Mt(),this.uploader=Tt()}async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e){return!!await this.api("saveProject",e).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 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,n=t.filter(o=>ie(o))[0];if(!n)return null;const r=this.pluginCaches[n];return r||(this.pluginCaches[n]=ee.send({url:n,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}}const S=new l.Storage({type:"local",expired:0,prefix:"__VTJ_"});class It extends U{init(e){const t=new b.ProjectModel(e),n=S.get(`project_${t.id}`),r=Object.assign(t.toDsl(),n||{});return S.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new b.ProjectModel(e);return S.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return S.save(`materials_${e.id}`,l.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return S.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=S.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return S.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return S.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=S.get(`history_${e}`);if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),S.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=S.get(`history_${e}`),n=new b.HistoryModel(t||{id:e});return Promise.resolve(n.toDsl())}getHistoryItem(e,t){const n=S.get(`history_${e}_${t}`);return Promise.resolve(n)}saveHistoryItem(e,t){return S.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(n=>{S.remove(`history_${e}_${n}`)}),Promise.resolve(!0)}}class Re extends U{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new b.ProjectModel(e),n=this.projects[t.id]||{},r=Object.assign(t.toDsl(),n);return this.projects[r.id]=r,Promise.resolve(r)}saveProject(e){const t=new b.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=l.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return this.files[e.id]=e,Promise.resolve(!0)}getFile(e){const t=this.files[e];return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return delete this.files[e],Promise.resolve(!0)}saveHistory(e){return this.histories[e.id]=e,Promise.resolve(!0)}removeHistory(e){const t=this.histories[e];if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],n=new b.HistoryModel(t||{id:e});return Promise.resolve(n)}getHistoryItem(e,t){const n=`${e}_${t}`,r=this.historyItems[n]||{};return Promise.resolve(r)}saveHistoryItem(e,t){const n=`${e}_${t.id}`;return this.historyItems[n]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(n=>{const r=`${e}_${n}`;delete this.historyItems[r]}),Promise.resolve(!0)}}let O=null;function Dt(){return O||(O=new Re,O)}class Ht extends U{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e){return!!await this.api("saveProject",e).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:l.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)}}function xe(s,e=[]){return e.map(t=>{const{id:n,title:r,icon:o,children:a,hidden:i}=t;return{id:n,title:r,icon:o,hidden:i,url:`${s}/${n}`,children:a&&a.length?xe(s,a):void 0}})}function ke(s,e){if(!e)return s;let t=[];for(const n of s)if(n.children&&n.children.length){const r=ke(n.children,e);r.length&&(n.children=r,t.push(n))}else e.can(n.id.toString())&&t.push(n);return t}function Nt(s){const{menuBasePath:e="/page"}=s||{},t=Z(),n=se.useRoute(),r=we(),o=p.ref(!1),a=p.ref(!1),i=t.project;p.watchEffect(()=>{const{name:m,params:f,meta:d}=n;if(m===D){const g=t.getPage(f.id);o.value=!g?.mask,a.value=!!g?.pure}else if(m===q){const g=t.getHomepage();o.value=!g?.mask,a.value=!!g?.pure}else o.value=!d.mask,a.value=!!d.pure});const u=xe(e,i?.pages),c=i?.config;return{disabled:o,logo:c?.logo,themeSwitchable:c?.themeSwitchable,title:c?.title||i?.description||i?.name||"VTJ App",menus:ke(u,r),pure:a}}exports.ACCESS_KEY=W;exports.Access=Ve;exports.BUILT_IN_DIRECTIVES=re;exports.BaseService=U;exports.CONTEXT_HOST=L;exports.Context=Se;exports.ContextMode=y;exports.DATA_TYPES=oe;exports.HOMEPAGE_ROUTE_NAME=q;exports.JSCodeToString=Le;exports.LIFE_CYCLES_LIST=Ne;exports.LocalService=Ht;exports.MemoryService=Re;exports.NodeEnv=$e;exports.PAGE_ROUTE_NAME=D;exports.Provider=Ce;exports.Startup=Pe;exports.StorageService=It;exports.VTJ_RENDERER_VERSION=C;exports.adoptedStyleSheets=z;exports.createAssetScripts=Ue;exports.createAssetsCss=Be;exports.createDataSources=je;exports.createLoader=T;exports.createMemoryService=Dt;exports.createMetaApi=ge;exports.createProvider=Ot;exports.createRenderer=M;exports.createSchemaApi=me;exports.createSchemaApis=ve;exports.defaultLoader=Ee;exports.fillBasePath=x;exports.getModifiers=Y;exports.getPlugin=G;exports.getRawComponent=le;exports.isCSSUrl=H;exports.isJSCode=he;exports.isJSExpression=E;exports.isJSFunction=F;exports.isJSON=ie;exports.isJSUrl=N;exports.isVuePlugin=fe;exports.loadCss=ue;exports.loadCssUrl=de;exports.loadScriptUrl=pe;exports.mockApi=_e;exports.mockApis=ye;exports.mockCleanup=K;exports.nodeRender=A;exports.parseDeps=ce;exports.parseExpression=R;exports.parseFunction=J;exports.providerKey=X;exports.removeProdFlag=ae;exports.toString=V;exports.useAccess=we;exports.useMask=Nt;exports.useProvider=Z;
|
75
|
+
}`);const t=s,n=()=>{if(typeof window<"u"){let o=(window.__VTJ_LINK__||{}).href||window.location.pathname+"__vtj__/#/";window.location.href=o}};return(r,o)=>(p.openBlock(),p.createElementBlock("div",$t,[p.createElementVNode("div",Ct,[p.createElementVNode("h1",Rt,[p.createElementVNode("span",xt,p.toDisplayString(t.name),1)]),p.createElementVNode("div",kt,p.toDisplayString(t.tagline),1),p.createElementVNode("div",At,[p.createElementVNode("button",{"data-l-h6o7ki7":"",onClick:n},p.toDisplayString(t.actionText),1)])])]))}}),Ft=p.defineComponent({name:"VtjStartupContainer",render(){return p.h(Pe)}}),X=Symbol("Provider");var $e=(s=>(s.Production="production",s.Development="development",s))($e||{});class Ce extends b.Base{constructor(e){super(),this.options=e;const{service:t,mode:n=y.Raw,dependencies:r,materials:o,project:a,adapter:i={},globals:u={},modules:c={},router:m=null,materialPath:f="./",nodeEnv:d="development"}=e;this.mode=n,this.modules=c,this.service=t,this.router=m,this.materialPath=f,this.nodeEnv=d,r&&(this.dependencies=r),o&&(this.materials=o),Object.assign(this.globals,u),Object.assign(this.adapter,i);const{access:g,request:h}=this.adapter;g&&g.connect({mode:n,router:m,request:h}),a&&a.id&&n!==y.Design&&this.load(a)}mode;globals={};modules={};adapter={request:Je,jsonp:l.jsonp};apis={};dependencies={};materials={};library={};service;project=null;components={};nodeEnv="development";router=null;materialPath="./";urlDslCaches={};async load(e){if(!e.id)return;const t=this.modules[`.vtj/projects/${e.id}.json`];if(this.project=t?await t():await this.service.init(e),!this.project)throw new Error("project is null");const{apis:n=[],meta:r=[]}=this.project,o=window;o.CKEDITOR_VERSION=void 0,this.nodeEnv!=="production"?await this.loadAssets(o):await this.loadDependencies(o),this.apis=ve(n,r,this.adapter),K(),this.project.config?.mock&&ye(n),this.initRouter(),this.triggerReady()}async loadDependencies(e){const t=Object.entries(this.dependencies);for(const[n,r]of t)e[n]||(e[n]=await r())}async loadAssets(e){const{dependencies:t=[]}=this.project,{dependencies:n,library:r,components:o,materialPath:a,nodeEnv:i}=this,{libraryExports:u,libraryMap:c,materials:m,materialExports:f,materialMapLibrary:d}=ce(t,a,i==="development");for(const h of u){const v=n[h],E=e[h];if(E)r[h]=E;else if(v)e[h]=r[h]=await v();else{const _=c[h]||[];for(const w of _)N(w)&&await ue(h,l.url.append(w,{v:C})),U(w)&&await l.loadScript(l.url.append(w,{v:C}));r[h]=e[h]}}for(const h of m)await l.loadScript(l.url.append(h,{v:C}));const g=this.materials||{};for(const h of f){const v=e[d[h]],E=b.BUILT_IN_COMPONENTS[h];if(E)v&&E.forEach(_=>{o[_]=v[_]});else{const _=g[h]?(await g[h]()).default:e[h];_&&v&&(_.components||[]).forEach(w=>{o[w.name]=le(w,v)})}}}initRouter(){const{router:e,project:t,options:n}=this;if(!e)return;const{routeParentName:r,pageRouteName:o="page",routeMeta:a}=n,i=r?"":"/",u={path:`${i}${o}/:id`,name:R,component:ne},c={path:i,name:A,component:t?.homepage?ne:Ft,meta:a};e.hasRoute(R)&&e.removeRoute(R),e.hasRoute(A)&&e.removeRoute(A),r?(e.addRoute(r,u),e.addRoute(r,c)):(e.addRoute(u),e.addRoute(c))}install(e){const t=e.config.globalProperties.installed||{};for(const[n,r]of Object.entries(this.library))!t[n]&&fe(r)&&(e.use(r),t[n]=!0);this.options.install&&e.use(this.options.install),this.adapter.access&&e.use(this.adapter.access),e.provide(X,this),e.config.globalProperties.installed=t,this.mode===y.Design&&(e.config.errorHandler=(n,r,o)=>{const a=r?.$options.name,i=typeof n=="string"?n:n?.message||n?.msg||"未知错误",u=`[ ${a} ] ${i} ${o}`;console.error("[VTJ Error]:",{err:n,instance:r,info:o},n?.stack),F.ElNotification.error({title:"未处理的异常:请在控制台查看详情",message:u})})}getFile(e){const{blocks:t=[]}=this.project||{};return this.getPage(e)||t.find(n=>n.id===e)||null}getPage(e){const{pages:t=[]}=this.project||{},n=(r,o=[])=>{for(const a of o){if(a.id===r)return a;if(a.children&&a.children.length){const i=n(r,a.children);if(i)return i}}};return n(e,t)||null}getHomepage(){const{homepage:e}=this.project||{};return e?this.getPage(e):null}async getDsl(e){const t=this.modules[`.vtj/files/${e}.json`];return t?await t():this.service.getFile(e).catch(()=>null)}async getDslByUrl(e){const t=this.urlDslCaches[e];return t||(this.urlDslCaches[e]=this.adapter.request.send({url:e,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(n=>n.data).catch(()=>null))}createDslRenderer(e,t={}){const{library:n,components:r,mode:o,apis:a}=this,i={mode:o,Vue:n.Vue,components:r,libs:n,apis:a,window,...t},u=D({getDsl:async c=>await this.getDsl(c)||null,getDslByUrl:async c=>await this.getDslByUrl(c)||null,options:i});return I({...i,dsl:e,loader:u})}async getRenderComponent(e,t){const n=this.getFile(e);if(!n)return l.logger.warn(`Can not find file: ${e}`),null;t&&t(n);const r=`.vtj/vue/${e}.vue`,o=this.modules[r];if(o)return(await o())?.default;const a=await this.getDsl(n.id);return a?this.createDslRenderer(a).renderer:(l.logger.warn(`Can not find dsl: ${e}`),null)}defineUrlSchemaComponent(e,t){return p.defineAsyncComponent(async()=>{const n=await this.getDslByUrl(e);return n?(n.name=t||n.name,this.createDslRenderer(n).renderer):null})}definePluginComponent(e){return p.defineAsyncComponent(async()=>await G(e,window))}}function Ot(s){const e=new Ce(s);return{provider:e,onReady:n=>e.ready(n)}}function Z(s={}){const e=p.inject(X);if(!e)throw new Error("Can not find provider");if(e.nodeEnv==="development"){const{id:t,version:n}=s;t&&n&&(async()=>{const r=await e.getDsl(t);r?.__VERSION__!==n&&F.ElNotification.warning({title:r?.name,message:"当前组件源码版本与运行时版本不一致,请重新发布组件"})})()}return e}const ee=new l.Request({settings:{type:"json",validSuccess:!0,originResponse:!1,failMessage:!0,validate:s=>s.data?.code===0,showError:s=>{F.ElNotification.error({message:s||"未知错误"})}}}),Mt=(s="/__vtj__/api/:type.json")=>(e,t)=>ee.send({url:s,method:"post",params:{type:e},data:{type:e,data:t}}),Tt=(s="/__vtj__/api/uploader.json")=>async(e,t)=>await ee.send({url:s,method:"post",data:{files:e,projectId:t},settings:{type:"data"}}).then(n=>n&&n[0]?n[0]:null).catch(()=>null);class B{api;pluginCaches={};uploader;constructor(){this.api=Mt(),this.uploader=Tt()}async getExtension(){console.log("BaseService.getExtension")}async init(e){return console.log("BaseService.init",e),{}}async saveProject(e){return!!await this.api("saveProject",e).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 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,n=t.filter(o=>ie(o))[0];if(!n)return null;const r=this.pluginCaches[n];return r||(this.pluginCaches[n]=ee.send({url:n,method:"get",settings:{validSuccess:!1,originResponse:!0}}).then(o=>o.data).catch(()=>null))}}const S=new l.Storage({type:"local",expired:0,prefix:"__VTJ_"});class It extends B{init(e){const t=new b.ProjectModel(e),n=S.get(`project_${t.id}`),r=Object.assign(t.toDsl(),n||{});return S.save(`project_${t.id}`,r),Promise.resolve(r)}saveProject(e){const t=new b.ProjectModel(e);return S.save(`project_${t.id}`,t.toDsl()),Promise.resolve(!0)}saveMaterials(e,t){return S.save(`materials_${e.id}`,l.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return S.save(`file_${e.id}`,e),Promise.resolve(!0)}getFile(e){const t=S.get(`file_${e}`);return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return S.remove(`file_${e}`),Promise.resolve(!0)}saveHistory(e){return S.save(`history_${e.id}`,e),Promise.resolve(!0)}removeHistory(e){const t=S.get(`history_${e}`);if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),S.remove(`history_${e}`)}return Promise.resolve(!0)}getHistory(e){const t=S.get(`history_${e}`),n=new b.HistoryModel(t||{id:e});return Promise.resolve(n.toDsl())}getHistoryItem(e,t){const n=S.get(`history_${e}_${t}`);return Promise.resolve(n)}saveHistoryItem(e,t){return S.save(`history_${e}_${t.id}`,t),Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(n=>{S.remove(`history_${e}_${n}`)}),Promise.resolve(!0)}}class Re extends B{projects={};materials={};files={};histories={};historyItems={};init(e){const t=new b.ProjectModel(e),n=this.projects[t.id]||{},r=Object.assign(t.toDsl(),n);return this.projects[r.id]=r,Promise.resolve(r)}saveProject(e){const t=new b.ProjectModel(e);return this.projects[t.id]=t.toDsl(),Promise.resolve(!0)}saveMaterials(e,t){return e.id&&(this.materials[e.id]=l.mapToObject(t)),Promise.resolve(!0)}saveFile(e){return this.files[e.id]=e,Promise.resolve(!0)}getFile(e){const t=this.files[e];return t?Promise.resolve(t):Promise.reject(null)}removeFile(e){return delete this.files[e],Promise.resolve(!0)}saveHistory(e){return this.histories[e.id]=e,Promise.resolve(!0)}removeHistory(e){const t=this.histories[e];if(t){const r=(t.items||[]).map(o=>o.id);this.removeHistoryItem(e,r),delete this.historyItems[e]}return Promise.resolve(!0)}getHistory(e){const t=this.histories[e],n=new b.HistoryModel(t||{id:e});return Promise.resolve(n)}getHistoryItem(e,t){const n=`${e}_${t}`,r=this.historyItems[n]||{};return Promise.resolve(r)}saveHistoryItem(e,t){const n=`${e}_${t.id}`;return this.historyItems[n]=t,Promise.resolve(!0)}removeHistoryItem(e,t){return t.forEach(n=>{const r=`${e}_${n}`;delete this.historyItems[r]}),Promise.resolve(!0)}}let T=null;function Dt(){return T||(T=new Re,T)}class Ht extends B{getFileCaches={};async getExtension(){return await this.api("getExtension",{}).catch(()=>{})}async init(e){return await this.api("init",e).catch(()=>null)||{}}async saveProject(e){return!!await this.api("saveProject",e).catch(()=>!1)}async saveMaterials(e,t){return!!await this.api("saveMaterials",{project:e,materials:l.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)}}function xe(s,e=[]){return e.map(t=>{const{id:n,title:r,icon:o,children:a,hidden:i}=t;return{id:n,title:r,icon:o,hidden:i,url:`${s}/${n}`,children:a&&a.length?xe(s,a):void 0}})}function ke(s,e){if(!e)return s;let t=[];for(const n of s)if(n.children&&n.children.length){const r=ke(n.children,e);r.length&&(n.children=r,t.push(n))}else e.can(n.id.toString())&&t.push(n);return t}function Nt(s){const{menuBasePath:e="/page"}=s||{},t=Z(),n=se.useRoute(),r=we(),o=p.ref(!1),a=p.ref(!1),i=t.project;p.watchEffect(()=>{const{name:m,params:f,meta:d}=n;if(m===R){const g=t.getPage(f.id);o.value=!g?.mask,a.value=!!g?.pure}else if(m===A){const g=t.getHomepage();o.value=!g?.mask,a.value=!!g?.pure}else o.value=!d.mask,a.value=!!d.pure});const u=xe(e,i?.pages),c=i?.config;return{disabled:o,logo:c?.logo,themeSwitchable:c?.themeSwitchable,title:c?.title||i?.description||i?.name||"VTJ App",menus:ke(u,r),pure:a}}exports.ACCESS_KEY=W;exports.Access=Ve;exports.BUILT_IN_DIRECTIVES=re;exports.BaseService=B;exports.CONTEXT_HOST=J;exports.Context=Se;exports.ContextMode=y;exports.DATA_TYPES=oe;exports.HOMEPAGE_ROUTE_NAME=A;exports.JSCodeToString=Le;exports.LIFE_CYCLES_LIST=Ne;exports.LocalService=Ht;exports.MemoryService=Re;exports.NodeEnv=$e;exports.PAGE_ROUTE_NAME=R;exports.Provider=Ce;exports.Startup=Pe;exports.StorageService=It;exports.VTJ_RENDERER_VERSION=C;exports.adoptedStyleSheets=z;exports.createAssetScripts=Ue;exports.createAssetsCss=Be;exports.createDataSources=Ee;exports.createLoader=D;exports.createMemoryService=Dt;exports.createMetaApi=ge;exports.createProvider=Ot;exports.createRenderer=I;exports.createSchemaApi=me;exports.createSchemaApis=ve;exports.defaultLoader=je;exports.fillBasePath=k;exports.getModifiers=Y;exports.getPlugin=G;exports.getRawComponent=le;exports.isCSSUrl=N;exports.isJSCode=he;exports.isJSExpression=j;exports.isJSFunction=M;exports.isJSON=ie;exports.isJSUrl=U;exports.isVuePlugin=fe;exports.loadCss=ue;exports.loadCssUrl=de;exports.loadScriptUrl=pe;exports.mockApi=_e;exports.mockApis=ye;exports.mockCleanup=K;exports.nodeRender=O;exports.parseDeps=ce;exports.parseExpression=x;exports.parseFunction=q;exports.providerKey=X;exports.removeProdFlag=ae;exports.toString=V;exports.useAccess=we;exports.useMask=Nt;exports.useProvider=Z;
|
package/dist/index.mjs
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
import { Base as
|
2
|
-
import { isUrl as ke, url as
|
3
|
-
import * as
|
4
|
-
import { inject as
|
5
|
-
import { ElNotification as
|
6
|
-
import { useRoute as
|
1
|
+
import { Base as Re, BUILT_IN_COMPONENTS as xe, ProjectModel as O, HistoryModel as le } from "@vtj/core";
|
2
|
+
import { isUrl as ke, url as R, dedupArray as Ce, isString as $, isFunction as V, logger as M, createRequest as Fe, merge as Ae, pathToRegexp as Ie, pathToRegexpMatch as Oe, formDataToJson as Me, storage as N, cookie as L, toArray as se, unRSA as ne, delay as ue, camelCase as j, upperFirst as Te, pick as De, jsonp as He, loadScript as re, Request as Be, Storage as Ue, mapToObject as G } from "@vtj/utils";
|
3
|
+
import * as H from "vue";
|
4
|
+
import { inject as de, toRef as Ne, readonly as Le, customRef as qe, ref as T, onBeforeUnmount as Je, getCurrentScope as Ve, onScopeDispose as ze, unref as Ke, getCurrentInstance as pe, watch as fe, computed as he, onMounted as We, defineComponent as Y, h as z, openBlock as Ge, createElementBlock as Ye, createElementVNode as b, toDisplayString as q, defineAsyncComponent as oe, watchEffect as Qe } from "vue";
|
5
|
+
import { ElNotification as B, ElLoading as Xe } from "element-plus";
|
6
|
+
import { useRoute as me } from "vue-router";
|
7
7
|
/**!
|
8
8
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
9
9
|
* @name @vtj/renderer
|
10
10
|
* @author CHC chenhuachun1549@dingtalk.com
|
11
|
-
* @version 0.9.0-alpha.
|
11
|
+
* @version 0.9.0-alpha.17
|
12
12
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
13
13
|
*/
|
14
|
-
const
|
14
|
+
const x = "0.9.0-alpha.17";
|
15
15
|
var _ = /* @__PURE__ */ ((n) => (n.Runtime = "Runtime", n.Design = "Design", n.Raw = "Raw", n.VNode = "VNode", n))(_ || {});
|
16
|
-
const
|
16
|
+
const ie = [
|
17
17
|
"$el",
|
18
18
|
"$emit",
|
19
19
|
"$nextTick",
|
@@ -47,14 +47,14 @@ const oe = [
|
|
47
47
|
Object,
|
48
48
|
Function,
|
49
49
|
Date
|
50
|
-
},
|
51
|
-
function
|
50
|
+
}, k = "VtjPage", I = "VtjHomepage";
|
51
|
+
function F(n, e) {
|
52
52
|
return n.map((t) => ke(t) || t.startsWith("/") ? t : `${e}${t}`);
|
53
53
|
}
|
54
|
-
function
|
54
|
+
function Q(n) {
|
55
55
|
return /\.css$/.test(n);
|
56
56
|
}
|
57
|
-
function
|
57
|
+
function X(n) {
|
58
58
|
return /\.js$/.test(n);
|
59
59
|
}
|
60
60
|
function tt(n) {
|
@@ -62,12 +62,12 @@ function tt(n) {
|
|
62
62
|
}
|
63
63
|
function ws(n) {
|
64
64
|
return n.map(
|
65
|
-
(e) => `<script src="${
|
65
|
+
(e) => `<script src="${R.append(e, { v: x })}"><\/script>`
|
66
66
|
).join("");
|
67
67
|
}
|
68
68
|
function Ss(n = []) {
|
69
69
|
return n.map(
|
70
|
-
(e) => `<link rel="stylesheet" href="${
|
70
|
+
(e) => `<link rel="stylesheet" href="${R.append(e, { v: x })}" />`
|
71
71
|
).join("");
|
72
72
|
}
|
73
73
|
function st(n, e = !1) {
|
@@ -78,13 +78,13 @@ function nt(n, e, t = !1) {
|
|
78
78
|
return s.forEach(
|
79
79
|
({ urls: u, assetsUrl: h, library: p, assetsLibrary: m, localeLibrary: w }) => {
|
80
80
|
u?.forEach((g) => {
|
81
|
-
|
82
|
-
}), p && (i.push(p), l[p] =
|
81
|
+
X(g) && r.push(st(g, t)), Q(g) && o.push(g);
|
82
|
+
}), p && (i.push(p), l[p] = F(u || [], e), w && (c[p] = w)), h && a.push(h), m && f.push(m), p && m && (d[m] = p);
|
83
83
|
}
|
84
84
|
), {
|
85
|
-
scripts:
|
86
|
-
css:
|
87
|
-
materials:
|
85
|
+
scripts: F(r, e),
|
86
|
+
css: F(o, e),
|
87
|
+
materials: F(a, e),
|
88
88
|
libraryExports: i,
|
89
89
|
materialExports: Ce(f),
|
90
90
|
materialMapLibrary: d,
|
@@ -141,9 +141,9 @@ async function at(n, e, t = window) {
|
|
141
141
|
});
|
142
142
|
}
|
143
143
|
function ct(n) {
|
144
|
-
return
|
144
|
+
return V(n) || V(n?.install);
|
145
145
|
}
|
146
|
-
function
|
146
|
+
function C(n, e, t = !1, s = !1) {
|
147
147
|
try {
|
148
148
|
const r = ['"use strict";', "var __self = arguments[0];"];
|
149
149
|
r.push("return ");
|
@@ -153,13 +153,13 @@ function k(n, e, t = !1, s = !1) {
|
|
153
153
|
const a = `with(${t ? "{}" : "$scope || {}"}) { ${o} }`;
|
154
154
|
return new Function("$scope", a)(e);
|
155
155
|
} catch (r) {
|
156
|
-
if (
|
156
|
+
if (M.error("parseExpression.error", r, n, e?.__self ?? e), s)
|
157
157
|
throw r;
|
158
158
|
}
|
159
159
|
}
|
160
|
-
function
|
161
|
-
const r =
|
162
|
-
if (typeof r != "function" && (
|
160
|
+
function ae(n, e, t = !1, s = !1) {
|
161
|
+
const r = C(n, e, t, s);
|
162
|
+
if (typeof r != "function" && (M.error(
|
163
163
|
"parseFunction.error",
|
164
164
|
"not a function",
|
165
165
|
n,
|
@@ -171,11 +171,11 @@ function ie(n, e, t = !1, s = !1) {
|
|
171
171
|
function S(n) {
|
172
172
|
return n && n.type === "JSExpression";
|
173
173
|
}
|
174
|
-
function
|
174
|
+
function U(n) {
|
175
175
|
return typeof n == "object" && n && n.type === "JSFunction";
|
176
176
|
}
|
177
177
|
function lt(n) {
|
178
|
-
return S(n) ||
|
178
|
+
return S(n) || U(n);
|
179
179
|
}
|
180
180
|
function $s(n) {
|
181
181
|
return lt(n) ? n.value : JSON.stringify(n);
|
@@ -190,7 +190,7 @@ const ut = Fe({
|
|
190
190
|
validate: (n) => n.data?.code === 0 || !!n.data?.success,
|
191
191
|
failMessage: !0,
|
192
192
|
showError: (n) => {
|
193
|
-
|
193
|
+
B.error({
|
194
194
|
message: n || "未知错误"
|
195
195
|
});
|
196
196
|
},
|
@@ -215,7 +215,7 @@ function dt(n, e) {
|
|
215
215
|
query: r
|
216
216
|
});
|
217
217
|
{
|
218
|
-
const r = n.headers ?
|
218
|
+
const r = n.headers ? C(n.headers, {}, !0) : void 0, o = {
|
219
219
|
url: n.url,
|
220
220
|
method: n.method,
|
221
221
|
settings: {
|
@@ -255,9 +255,9 @@ function mt(n, e) {
|
|
255
255
|
if (!e.mock) return;
|
256
256
|
const { url: t, mockTemplate: s } = e;
|
257
257
|
if (t && s) {
|
258
|
-
const r = Ie(`${t}(.*)`), o = Oe(t, { decode: decodeURIComponent }), a =
|
258
|
+
const r = Ie(`${t}(.*)`), o = Oe(t, { decode: decodeURIComponent }), a = C(s, {}, !0);
|
259
259
|
n.mock(r, (i) => {
|
260
|
-
const l =
|
260
|
+
const l = R.parse(i.url) || {}, c = i.body instanceof FormData ? Me(i.body) : i.body, f = o(i.url)?.params;
|
261
261
|
return Object.assign(i, { data: c, params: l, query: f }), n.mock(a(i));
|
262
262
|
});
|
263
263
|
}
|
@@ -291,17 +291,17 @@ class js {
|
|
291
291
|
}
|
292
292
|
login(e) {
|
293
293
|
const { storageKey: t, storagePrefix: s, session: r, authKey: o } = this.options;
|
294
|
-
this.setData(e), this.data && (
|
294
|
+
this.setData(e), this.data && (N.save(t, e, {
|
295
295
|
type: "local",
|
296
296
|
prefix: s
|
297
|
-
}), r &&
|
297
|
+
}), r && L.set(o, this.data.token));
|
298
298
|
}
|
299
299
|
clear() {
|
300
300
|
const { storageKey: e, storagePrefix: t, session: s, authKey: r } = this.options;
|
301
|
-
this.data = null,
|
301
|
+
this.data = null, N.remove(e, {
|
302
302
|
type: "local",
|
303
303
|
prefix: t
|
304
|
-
}), s &&
|
304
|
+
}), s && L.remove(r);
|
305
305
|
}
|
306
306
|
logout() {
|
307
307
|
this.clear(), this.toLogin();
|
@@ -314,11 +314,11 @@ class js {
|
|
314
314
|
}
|
315
315
|
can(e) {
|
316
316
|
const { keyPrefix: t } = this.options, { permissions: s = {} } = this.data || {};
|
317
|
-
return typeof e == "function" ? e(s) :
|
317
|
+
return typeof e == "function" ? e(s) : se(e).every((o) => s[o] || s[t + o]);
|
318
318
|
}
|
319
319
|
some(e) {
|
320
320
|
const { keyPrefix: t } = this.options, { permissions: s = {} } = this.data || {};
|
321
|
-
return
|
321
|
+
return se(e).some((o) => s[o] || s[t + o]);
|
322
322
|
}
|
323
323
|
install(e) {
|
324
324
|
e.config.globalProperties.$access || (e.config.globalProperties.$access = this), e.provide(_e, this);
|
@@ -342,13 +342,13 @@ class js {
|
|
342
342
|
setData(e) {
|
343
343
|
const { privateKey: t } = this.options;
|
344
344
|
if (Array.isArray(e) && t) {
|
345
|
-
const s = e.map((r) =>
|
345
|
+
const s = e.map((r) => ne(r, t));
|
346
346
|
this.data = JSON.parse(s.join(""));
|
347
347
|
return;
|
348
348
|
}
|
349
349
|
if (typeof e == "string")
|
350
350
|
try {
|
351
|
-
const s = t ?
|
351
|
+
const s = t ? ne(e, t) : e;
|
352
352
|
s ? this.data = JSON.parse(s) : console.warn("RSA解密失败或登录信息缺失");
|
353
353
|
} catch (s) {
|
354
354
|
console.warn(s);
|
@@ -357,7 +357,7 @@ class js {
|
|
357
357
|
this.data = e;
|
358
358
|
}
|
359
359
|
loadData() {
|
360
|
-
const { storageKey: e, storagePrefix: t } = this.options, s =
|
360
|
+
const { storageKey: e, storagePrefix: t } = this.options, s = N.get(e, {
|
361
361
|
type: "local",
|
362
362
|
prefix: t
|
363
363
|
});
|
@@ -365,10 +365,10 @@ class js {
|
|
365
365
|
}
|
366
366
|
isLogined() {
|
367
367
|
const { session: e, authKey: t } = this.options;
|
368
|
-
return e && t ? !!
|
368
|
+
return e && t ? !!L.get(t) : !!this.data;
|
369
369
|
}
|
370
370
|
hasRoutePermission(e) {
|
371
|
-
if (e.name ===
|
371
|
+
if (e.name === k) {
|
372
372
|
const t = e.params.id;
|
373
373
|
return t && this.can(t);
|
374
374
|
}
|
@@ -385,7 +385,7 @@ class js {
|
|
385
385
|
return t();
|
386
386
|
{
|
387
387
|
const { noPermissionMessage: s = "无权限访问", unauthorized: r = !1 } = this.options;
|
388
|
-
return this.showTip(s),
|
388
|
+
return this.showTip(s), V(r) ? (r(), t(!1)) : $(r) ? t(r) : t(!1);
|
389
389
|
}
|
390
390
|
}
|
391
391
|
t(!1), this.toLogin();
|
@@ -404,7 +404,7 @@ class js {
|
|
404
404
|
}
|
405
405
|
async showTip(e) {
|
406
406
|
const { alert: t } = this.options;
|
407
|
-
return t ? (await
|
407
|
+
return t ? (await ue(150), await t(e, {
|
408
408
|
title: "提示",
|
409
409
|
type: "warning"
|
410
410
|
}).catch(() => !1)) : !1;
|
@@ -420,7 +420,7 @@ class js {
|
|
420
420
|
}
|
421
421
|
}
|
422
422
|
function vt() {
|
423
|
-
return
|
423
|
+
return de(_e, null);
|
424
424
|
}
|
425
425
|
class yt {
|
426
426
|
__id = null;
|
@@ -451,7 +451,7 @@ class yt {
|
|
451
451
|
const { mode: t, dsl: s, attrs: r } = e;
|
452
452
|
this.__mode = t, s && (this.__id = s.id || null, this.__transform = s.transform || {}), r && Object.assign(this, r);
|
453
453
|
}
|
454
|
-
setup(e, t =
|
454
|
+
setup(e, t = H) {
|
455
455
|
const s = t.getCurrentInstance();
|
456
456
|
if (!s) return;
|
457
457
|
this.__refs = {}, this.$refs = {}, this.context = {}, this.__contextRefs = {}, this.__instance = s.proxy;
|
@@ -465,12 +465,12 @@ class yt {
|
|
465
465
|
});
|
466
466
|
}
|
467
467
|
__proxy() {
|
468
|
-
this.__instance &&
|
468
|
+
this.__instance && ie.forEach((e) => {
|
469
469
|
this[e] = this.__instance?.[e];
|
470
470
|
});
|
471
471
|
}
|
472
472
|
__cleanup() {
|
473
|
-
|
473
|
+
ie.forEach((e) => {
|
474
474
|
this[e] = null;
|
475
475
|
});
|
476
476
|
}
|
@@ -478,22 +478,22 @@ class yt {
|
|
478
478
|
if (e)
|
479
479
|
if (this.__mode === _.Runtime) {
|
480
480
|
const { id: t, type: s } = e, r = t ? this.__transform[t] ?? e.value : e.value;
|
481
|
-
return
|
481
|
+
return ae({ type: s, value: r }, this);
|
482
482
|
} else
|
483
|
-
return
|
483
|
+
return ae(e, this);
|
484
484
|
}
|
485
485
|
__parseExpression(e) {
|
486
486
|
if (e)
|
487
487
|
if (this.__mode === _.Runtime) {
|
488
488
|
const { id: t, type: s } = e, r = t ? this.__transform[t] ?? e.value : e.value;
|
489
|
-
return
|
489
|
+
return C({ type: s, value: r }, this);
|
490
490
|
} else
|
491
|
-
return
|
491
|
+
return C(e, this);
|
492
492
|
}
|
493
493
|
__ref(e = null, t) {
|
494
494
|
if (this.__mode !== _.VNode)
|
495
495
|
return e && e !== this.__id && (this.__contextRefs[e] = this), async (s) => {
|
496
|
-
await
|
496
|
+
await ue(0);
|
497
497
|
let r = s?.$vtjEl || s?.$el || s?._?.vnode?.el || s;
|
498
498
|
if (!r) {
|
499
499
|
typeof t == "string" && (delete this.$refs[t], e && delete this.__refs[e]);
|
@@ -520,9 +520,9 @@ class yt {
|
|
520
520
|
return s.context.__proto__ = this.context, s.__proto__ = this, s;
|
521
521
|
}
|
522
522
|
}
|
523
|
-
function
|
523
|
+
function K(n) {
|
524
524
|
const {
|
525
|
-
Vue: e =
|
525
|
+
Vue: e = H,
|
526
526
|
mode: t = _.Runtime,
|
527
527
|
components: s = {},
|
528
528
|
libs: r = {},
|
@@ -565,9 +565,9 @@ function V(n) {
|
|
565
565
|
render() {
|
566
566
|
if (!i.value.nodes) return null;
|
567
567
|
const d = i.value.nodes || [];
|
568
|
-
return d.length === 1 ?
|
568
|
+
return d.length === 1 ? D(d[0], c, e, a) : d.map((u) => D(u, c, e, a));
|
569
569
|
},
|
570
|
-
...
|
570
|
+
...Rt(i.value.lifeCycles ?? {}, c)
|
571
571
|
});
|
572
572
|
return {
|
573
573
|
renderer: e.markRaw(f),
|
@@ -600,7 +600,7 @@ function St(n, e, t) {
|
|
600
600
|
Object.keys(e || {}).reduce(
|
601
601
|
(s, r) => {
|
602
602
|
let o = e[r];
|
603
|
-
return S(o) ? o = t.__parseExpression(o) :
|
603
|
+
return S(o) ? o = t.__parseExpression(o) : U(o) && (o = t.__parseFunction(o)), s[r] = o, s;
|
604
604
|
},
|
605
605
|
{}
|
606
606
|
)
|
@@ -632,7 +632,7 @@ function bt(n, e = [], t) {
|
|
632
632
|
function Et(n, e) {
|
633
633
|
return Object.keys(n).reduce(
|
634
634
|
(t, s) => {
|
635
|
-
const r = n[s], o = e.$apis[r.ref], a =
|
635
|
+
const r = n[s], o = e.$apis[r.ref], a = U(r.transform) ? r.transform.value ? e.__parseFunction(r.transform) : void 0 : r.transform;
|
636
636
|
return t[s] = async (...i) => {
|
637
637
|
const l = await o.apply(e, i);
|
638
638
|
return a ? a(l) : l;
|
@@ -653,50 +653,50 @@ function Pt(n, e = [], t) {
|
|
653
653
|
);
|
654
654
|
});
|
655
655
|
}
|
656
|
-
function
|
656
|
+
function Rt(n, e) {
|
657
657
|
return Object.entries(n ?? {}).reduce(
|
658
658
|
(t, [s, r]) => (t[s] = e.__parseFunction(r), t),
|
659
659
|
{}
|
660
660
|
);
|
661
661
|
}
|
662
|
-
let
|
663
|
-
const
|
662
|
+
let J = [];
|
663
|
+
const xt = (n) => n;
|
664
664
|
async function we(n, e = window) {
|
665
|
-
const { urls: t = [], library: s } = n, r = t.filter((i) =>
|
665
|
+
const { urls: t = [], library: s } = n, r = t.filter((i) => X(i));
|
666
666
|
if (r.length === 0 || !s) return null;
|
667
|
-
const o = t.filter((i) =>
|
667
|
+
const o = t.filter((i) => Q(i));
|
668
668
|
return o.length && it(o, e), await at(r, s, e).catch(
|
669
669
|
(i) => (console.warn("loadScriptUrl error", r, s, i), null)
|
670
670
|
);
|
671
671
|
}
|
672
|
-
function
|
672
|
+
function W(n) {
|
673
673
|
const { getDsl: e, getDslByUrl: t, options: s } = n;
|
674
|
-
return s.window && (
|
674
|
+
return s.window && (J.forEach((r) => {
|
675
675
|
delete s.window[r];
|
676
|
-
}),
|
676
|
+
}), J = []), (r, o, a = H) => !o || typeof o == "string" ? r : o.type === "Schema" && o.id ? a.defineAsyncComponent(async () => {
|
677
677
|
const i = await e(o.id);
|
678
|
-
return i && (i.name = r), i ?
|
678
|
+
return i && (i.name = r), i ? K({
|
679
679
|
...s,
|
680
680
|
Vue: a,
|
681
681
|
dsl: i,
|
682
682
|
mode: _.Runtime,
|
683
|
-
loader:
|
683
|
+
loader: W(n)
|
684
684
|
}).renderer : null;
|
685
685
|
}) : o.type === "UrlSchema" && o.url ? a.defineAsyncComponent(async () => {
|
686
686
|
const i = await t(o.url);
|
687
|
-
return i && (i.name = r), i ?
|
687
|
+
return i && (i.name = r), i ? K({
|
688
688
|
...s,
|
689
689
|
Vue: a,
|
690
690
|
dsl: i,
|
691
691
|
mode: _.Runtime,
|
692
|
-
loader:
|
692
|
+
loader: W(n)
|
693
693
|
}).renderer : null;
|
694
|
-
}) : o.type === "Plugin" ? (o.library &&
|
694
|
+
}) : o.type === "Plugin" ? (o.library && J.push(o.library), a.defineAsyncComponent(async () => {
|
695
695
|
const i = await we(o, s.window);
|
696
696
|
return i || (console.warn("getPlugin result is null", o), null);
|
697
697
|
})) : r;
|
698
698
|
}
|
699
|
-
function
|
699
|
+
function D(n, e, t = H, s = xt) {
|
700
700
|
if (!n || !n.name || n.invisible) return null;
|
701
701
|
const { id: r = null, directives: o = [] } = n, { vIf: a, vFor: i, vShow: l, vModels: c, vBind: f } = kt(o);
|
702
702
|
if (a && !Ct(a, e))
|
@@ -751,7 +751,7 @@ function At(n, e, t) {
|
|
751
751
|
const s = Object.keys(e || {}).reduce(
|
752
752
|
(r, o) => {
|
753
753
|
let a = e[o];
|
754
|
-
return S(a) ? a = t.__parseExpression(a) :
|
754
|
+
return S(a) ? a = t.__parseExpression(a) : U(a) && (a = t.__parseFunction(a)), r[o] = a, r;
|
755
755
|
},
|
756
756
|
{}
|
757
757
|
);
|
@@ -780,7 +780,7 @@ function Ot(n, e, t, s, r) {
|
|
780
780
|
return i ? i(t) : o ? $(o) ? n.createTextVNode(o) : S(o) ? n.createTextVNode(
|
781
781
|
ge(s.__parseExpression(o))
|
782
782
|
) : Array.isArray(o) ? o.map(
|
783
|
-
(l) =>
|
783
|
+
(l) => D(l, s, n, r)
|
784
784
|
) : null : null;
|
785
785
|
}
|
786
786
|
function Mt(n, e) {
|
@@ -822,7 +822,7 @@ function Ht(n, e, t, s, r) {
|
|
822
822
|
return Object.entries(o).reduce((i, [l, { nodes: c, params: f }]) => (i[l] = (d) => {
|
823
823
|
const u = f.length ? De(d ?? {}, f) : a(d);
|
824
824
|
return c.map(
|
825
|
-
(h) =>
|
825
|
+
(h) => D(h, t.__clone(u), n, s)
|
826
826
|
);
|
827
827
|
}, i), {});
|
828
828
|
}
|
@@ -855,7 +855,7 @@ function Nt(n, e, t) {
|
|
855
855
|
function Lt(n) {
|
856
856
|
return Ve() ? (ze(n), !0) : !1;
|
857
857
|
}
|
858
|
-
function
|
858
|
+
function Z(n) {
|
859
859
|
return typeof n == "function" ? n() : Ke(n);
|
860
860
|
}
|
861
861
|
const $e = typeof window < "u" && typeof document < "u";
|
@@ -863,13 +863,13 @@ typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
863
863
|
const qt = (n) => n != null, Jt = () => {
|
864
864
|
};
|
865
865
|
function Vt(n) {
|
866
|
-
return
|
866
|
+
return pe();
|
867
867
|
}
|
868
868
|
function zt(...n) {
|
869
869
|
if (n.length !== 1)
|
870
870
|
return Ne(...n);
|
871
871
|
const e = n[0];
|
872
|
-
return typeof e == "function" ? Le(qe(() => ({ get: e, set: Jt }))) :
|
872
|
+
return typeof e == "function" ? Le(qe(() => ({ get: e, set: Jt }))) : T(e);
|
873
873
|
}
|
874
874
|
function Kt(n, e) {
|
875
875
|
Vt() && Je(n, e);
|
@@ -877,28 +877,28 @@ function Kt(n, e) {
|
|
877
877
|
const Wt = $e ? window : void 0, Gt = $e ? window.document : void 0;
|
878
878
|
function Yt(n) {
|
879
879
|
var e;
|
880
|
-
const t =
|
880
|
+
const t = Z(n);
|
881
881
|
return (e = t?.$el) != null ? e : t;
|
882
882
|
}
|
883
883
|
function Qt() {
|
884
|
-
const n =
|
884
|
+
const n = T(!1), e = pe();
|
885
885
|
return e && We(() => {
|
886
886
|
n.value = !0;
|
887
887
|
}, e), n;
|
888
888
|
}
|
889
889
|
function Xt(n) {
|
890
890
|
const e = Qt();
|
891
|
-
return
|
891
|
+
return he(() => (e.value, !!n()));
|
892
892
|
}
|
893
893
|
function Zt(n, e, t = {}) {
|
894
894
|
const { window: s = Wt, ...r } = t;
|
895
895
|
let o;
|
896
896
|
const a = Xt(() => s && "MutationObserver" in s), i = () => {
|
897
897
|
o && (o.disconnect(), o = void 0);
|
898
|
-
}, l =
|
899
|
-
const u =
|
898
|
+
}, l = he(() => {
|
899
|
+
const u = Z(n), h = (Array.isArray(u) ? u : [u]).map(Yt).filter(qt);
|
900
900
|
return new Set(h);
|
901
|
-
}), c =
|
901
|
+
}), c = fe(
|
902
902
|
() => l.value,
|
903
903
|
(u) => {
|
904
904
|
i(), a.value && u.size && (o = new MutationObserver(e), u.forEach((h) => o.observe(h, r)));
|
@@ -923,9 +923,9 @@ function es(n = null, e = {}) {
|
|
923
923
|
if (!("titleTemplate" in e))
|
924
924
|
return d;
|
925
925
|
const u = e.titleTemplate || "%s";
|
926
|
-
return typeof u == "function" ? u(d) :
|
926
|
+
return typeof u == "function" ? u(d) : Z(u).replace(/%s/g, d);
|
927
927
|
}
|
928
|
-
return
|
928
|
+
return fe(
|
929
929
|
l,
|
930
930
|
(d, u) => {
|
931
931
|
d !== u && o && (o.title = f(typeof d == "string" ? d : ""));
|
@@ -944,10 +944,10 @@ function es(n = null, e = {}) {
|
|
944
944
|
}
|
945
945
|
}), l;
|
946
946
|
}
|
947
|
-
const
|
947
|
+
const ce = Y({
|
948
948
|
name: "VtjPageContainer",
|
949
949
|
async setup() {
|
950
|
-
const n = be(), e =
|
950
|
+
const n = be(), e = me(), t = e.params.id, s = t ? n.getPage(t) : n.getHomepage(), r = s ? await n.getRenderComponent(s.id) : null;
|
951
951
|
return s && (Object.assign(e.meta, s.meta || {}), es(s.title || "VTJ")), {
|
952
952
|
provider: n,
|
953
953
|
component: r,
|
@@ -958,7 +958,7 @@ const ae = W({
|
|
958
958
|
},
|
959
959
|
render() {
|
960
960
|
const { component: n, query: e } = this;
|
961
|
-
return n ?
|
961
|
+
return n ? z(n, e) : z("div", "页面不存在");
|
962
962
|
}
|
963
963
|
}), ts = {
|
964
964
|
"data-l-h6o7ki7": "",
|
@@ -975,7 +975,7 @@ const ae = W({
|
|
975
975
|
}, is = {
|
976
976
|
"data-l-h6o7ki7": "",
|
977
977
|
class: "vtj-startup__actions"
|
978
|
-
}, as = /* @__PURE__ */
|
978
|
+
}, as = /* @__PURE__ */ Y({
|
979
979
|
__name: "Startup",
|
980
980
|
props: {
|
981
981
|
name: { default: "VTJ.PRO" },
|
@@ -1061,26 +1061,26 @@ const ae = W({
|
|
1061
1061
|
return (r, o) => (Ge(), Ye("div", ts, [
|
1062
1062
|
b("div", ss, [
|
1063
1063
|
b("h1", ns, [
|
1064
|
-
b("span", rs,
|
1064
|
+
b("span", rs, q(t.name), 1)
|
1065
1065
|
]),
|
1066
|
-
b("div", os,
|
1066
|
+
b("div", os, q(t.tagline), 1),
|
1067
1067
|
b("div", is, [
|
1068
1068
|
b("button", {
|
1069
1069
|
"data-l-h6o7ki7": "",
|
1070
1070
|
onClick: s
|
1071
|
-
},
|
1071
|
+
}, q(t.actionText), 1)
|
1072
1072
|
])
|
1073
1073
|
])
|
1074
1074
|
]));
|
1075
1075
|
}
|
1076
|
-
}), cs =
|
1076
|
+
}), cs = Y({
|
1077
1077
|
name: "VtjStartupContainer",
|
1078
1078
|
render() {
|
1079
|
-
return
|
1079
|
+
return z(as);
|
1080
1080
|
}
|
1081
1081
|
}), je = Symbol("Provider");
|
1082
1082
|
var ls = /* @__PURE__ */ ((n) => (n.Production = "production", n.Development = "development", n))(ls || {});
|
1083
|
-
class us extends
|
1083
|
+
class us extends Re {
|
1084
1084
|
constructor(e) {
|
1085
1085
|
super(), this.options = e;
|
1086
1086
|
const {
|
@@ -1088,7 +1088,7 @@ class us extends xe {
|
|
1088
1088
|
mode: s = _.Raw,
|
1089
1089
|
dependencies: r,
|
1090
1090
|
materials: o,
|
1091
|
-
project: a
|
1091
|
+
project: a,
|
1092
1092
|
adapter: i = {},
|
1093
1093
|
globals: l = {},
|
1094
1094
|
modules: c = {},
|
@@ -1099,7 +1099,7 @@ class us extends xe {
|
|
1099
1099
|
} = e;
|
1100
1100
|
this.mode = s, this.modules = c, this.service = t, this.router = f, this.materialPath = d, this.nodeEnv = u, r && (this.dependencies = r), o && (this.materials = o), Object.assign(this.globals, l), Object.assign(this.adapter, i);
|
1101
1101
|
const { access: h, request: p } = this.adapter;
|
1102
|
-
h && h.connect({ mode: s, router: f, request: p }), s !== _.Design && this.load(a);
|
1102
|
+
h && h.connect({ mode: s, router: f, request: p }), a && a.id && s !== _.Design && this.load(a);
|
1103
1103
|
}
|
1104
1104
|
mode;
|
1105
1105
|
globals = {};
|
@@ -1117,6 +1117,7 @@ class us extends xe {
|
|
1117
1117
|
materialPath = "./";
|
1118
1118
|
urlDslCaches = {};
|
1119
1119
|
async load(e) {
|
1120
|
+
if (!e.id) return;
|
1120
1121
|
const t = this.modules[`.vtj/projects/${e.id}.json`];
|
1121
1122
|
if (this.project = t ? await t() : await this.service.init(e), !this.project)
|
1122
1123
|
throw new Error("project is null");
|
@@ -1150,15 +1151,15 @@ class us extends xe {
|
|
1150
1151
|
else {
|
1151
1152
|
const g = c[p] || [];
|
1152
1153
|
for (const v of g)
|
1153
|
-
|
1154
|
+
Q(v) && await ot(p, R.append(v, { v: x })), X(v) && await re(R.append(v, { v: x }));
|
1154
1155
|
r[p] = e[p];
|
1155
1156
|
}
|
1156
1157
|
}
|
1157
1158
|
for (const p of f)
|
1158
|
-
await
|
1159
|
+
await re(R.append(p, { v: x }));
|
1159
1160
|
const h = this.materials || {};
|
1160
1161
|
for (const p of d) {
|
1161
|
-
const m = e[u[p]], w =
|
1162
|
+
const m = e[u[p]], w = xe[p];
|
1162
1163
|
if (w)
|
1163
1164
|
m && w.forEach((g) => {
|
1164
1165
|
o[g] = m[g];
|
@@ -1176,15 +1177,15 @@ class us extends xe {
|
|
1176
1177
|
if (!e) return;
|
1177
1178
|
const { routeParentName: r, pageRouteName: o = "page", routeMeta: a } = s, i = r ? "" : "/", l = {
|
1178
1179
|
path: `${i}${o}/:id`,
|
1179
|
-
name:
|
1180
|
-
component:
|
1180
|
+
name: k,
|
1181
|
+
component: ce
|
1181
1182
|
}, c = {
|
1182
1183
|
path: i,
|
1183
|
-
name:
|
1184
|
-
component: t?.homepage ?
|
1184
|
+
name: I,
|
1185
|
+
component: t?.homepage ? ce : cs,
|
1185
1186
|
meta: a
|
1186
1187
|
};
|
1187
|
-
r ? (e.addRoute(r, l), e.addRoute(r, c)) : (e.addRoute(l), e.addRoute(c));
|
1188
|
+
e.hasRoute(k) && e.removeRoute(k), e.hasRoute(I) && e.removeRoute(I), r ? (e.addRoute(r, l), e.addRoute(r, c)) : (e.addRoute(l), e.addRoute(c));
|
1188
1189
|
}
|
1189
1190
|
install(e) {
|
1190
1191
|
const t = e.config.globalProperties.installed || {};
|
@@ -1200,7 +1201,7 @@ class us extends xe {
|
|
1200
1201
|
info: o
|
1201
1202
|
},
|
1202
1203
|
s?.stack
|
1203
|
-
),
|
1204
|
+
), B.error({
|
1204
1205
|
title: "未处理的异常:请在控制台查看详情",
|
1205
1206
|
message: l
|
1206
1207
|
});
|
@@ -1252,12 +1253,12 @@ class us extends xe {
|
|
1252
1253
|
apis: a,
|
1253
1254
|
window,
|
1254
1255
|
...t
|
1255
|
-
}, l =
|
1256
|
+
}, l = W({
|
1256
1257
|
getDsl: async (c) => await this.getDsl(c) || null,
|
1257
1258
|
getDslByUrl: async (c) => await this.getDslByUrl(c) || null,
|
1258
1259
|
options: i
|
1259
1260
|
});
|
1260
|
-
return
|
1261
|
+
return K({
|
1261
1262
|
...i,
|
1262
1263
|
dsl: e,
|
1263
1264
|
loader: l
|
@@ -1266,22 +1267,22 @@ class us extends xe {
|
|
1266
1267
|
async getRenderComponent(e, t) {
|
1267
1268
|
const s = this.getFile(e);
|
1268
1269
|
if (!s)
|
1269
|
-
return
|
1270
|
+
return M.warn(`Can not find file: ${e}`), null;
|
1270
1271
|
t && t(s);
|
1271
1272
|
const r = `.vtj/vue/${e}.vue`, o = this.modules[r];
|
1272
1273
|
if (o)
|
1273
1274
|
return (await o())?.default;
|
1274
1275
|
const a = await this.getDsl(s.id);
|
1275
|
-
return a ? this.createDslRenderer(a).renderer : (
|
1276
|
+
return a ? this.createDslRenderer(a).renderer : (M.warn(`Can not find dsl: ${e}`), null);
|
1276
1277
|
}
|
1277
1278
|
defineUrlSchemaComponent(e, t) {
|
1278
|
-
return
|
1279
|
+
return oe(async () => {
|
1279
1280
|
const s = await this.getDslByUrl(e);
|
1280
1281
|
return s ? (s.name = t || s.name, this.createDslRenderer(s).renderer) : null;
|
1281
1282
|
});
|
1282
1283
|
}
|
1283
1284
|
definePluginComponent(e) {
|
1284
|
-
return
|
1285
|
+
return oe(async () => await we(e, window));
|
1285
1286
|
}
|
1286
1287
|
}
|
1287
1288
|
function bs(n) {
|
@@ -1292,14 +1293,14 @@ function bs(n) {
|
|
1292
1293
|
};
|
1293
1294
|
}
|
1294
1295
|
function be(n = {}) {
|
1295
|
-
const e =
|
1296
|
+
const e = de(je);
|
1296
1297
|
if (!e)
|
1297
1298
|
throw new Error("Can not find provider");
|
1298
1299
|
if (e.nodeEnv === "development") {
|
1299
1300
|
const { id: t, version: s } = n;
|
1300
1301
|
t && s && (async () => {
|
1301
1302
|
const r = await e.getDsl(t);
|
1302
|
-
r?.__VERSION__ !== s &&
|
1303
|
+
r?.__VERSION__ !== s && B.warning({
|
1303
1304
|
title: r?.name,
|
1304
1305
|
message: "当前组件源码版本与运行时版本不一致,请重新发布组件"
|
1305
1306
|
});
|
@@ -1307,7 +1308,7 @@ function be(n = {}) {
|
|
1307
1308
|
}
|
1308
1309
|
return e;
|
1309
1310
|
}
|
1310
|
-
const
|
1311
|
+
const ee = new Be({
|
1311
1312
|
settings: {
|
1312
1313
|
type: "json",
|
1313
1314
|
validSuccess: !0,
|
@@ -1315,12 +1316,12 @@ const Z = new Be({
|
|
1315
1316
|
failMessage: !0,
|
1316
1317
|
validate: (n) => n.data?.code === 0,
|
1317
1318
|
showError: (n) => {
|
1318
|
-
|
1319
|
+
B.error({
|
1319
1320
|
message: n || "未知错误"
|
1320
1321
|
});
|
1321
1322
|
}
|
1322
1323
|
}
|
1323
|
-
}), ds = (n = "/__vtj__/api/:type.json") => (e, t) =>
|
1324
|
+
}), ds = (n = "/__vtj__/api/:type.json") => (e, t) => ee.send({
|
1324
1325
|
url: n,
|
1325
1326
|
method: "post",
|
1326
1327
|
params: { type: e },
|
@@ -1328,7 +1329,7 @@ const Z = new Be({
|
|
1328
1329
|
type: e,
|
1329
1330
|
data: t
|
1330
1331
|
}
|
1331
|
-
}), ps = (n = "/__vtj__/api/uploader.json") => async (e, t) => await
|
1332
|
+
}), ps = (n = "/__vtj__/api/uploader.json") => async (e, t) => await ee.send({
|
1332
1333
|
url: n,
|
1333
1334
|
method: "post",
|
1334
1335
|
data: {
|
@@ -1339,7 +1340,7 @@ const Z = new Be({
|
|
1339
1340
|
type: "data"
|
1340
1341
|
}
|
1341
1342
|
}).then((s) => s && s[0] ? s[0] : null).catch(() => null);
|
1342
|
-
class
|
1343
|
+
class te {
|
1343
1344
|
api;
|
1344
1345
|
pluginCaches = {};
|
1345
1346
|
uploader;
|
@@ -1420,7 +1421,7 @@ class ee {
|
|
1420
1421
|
const { urls: t = [] } = e, s = t.filter((o) => tt(o))[0];
|
1421
1422
|
if (!s) return null;
|
1422
1423
|
const r = this.pluginCaches[s];
|
1423
|
-
return r || (this.pluginCaches[s] =
|
1424
|
+
return r || (this.pluginCaches[s] = ee.send({
|
1424
1425
|
url: s,
|
1425
1426
|
method: "get",
|
1426
1427
|
settings: {
|
@@ -1435,17 +1436,17 @@ const y = new Ue({
|
|
1435
1436
|
expired: 0,
|
1436
1437
|
prefix: "__VTJ_"
|
1437
1438
|
});
|
1438
|
-
class Es extends
|
1439
|
+
class Es extends te {
|
1439
1440
|
init(e) {
|
1440
|
-
const t = new
|
1441
|
+
const t = new O(e), s = y.get(`project_${t.id}`), r = Object.assign(t.toDsl(), s || {});
|
1441
1442
|
return y.save(`project_${t.id}`, r), Promise.resolve(r);
|
1442
1443
|
}
|
1443
1444
|
saveProject(e) {
|
1444
|
-
const t = new
|
1445
|
+
const t = new O(e);
|
1445
1446
|
return y.save(`project_${t.id}`, t.toDsl()), Promise.resolve(!0);
|
1446
1447
|
}
|
1447
1448
|
saveMaterials(e, t) {
|
1448
|
-
return y.save(`materials_${e.id}`,
|
1449
|
+
return y.save(`materials_${e.id}`, G(t)), Promise.resolve(!0);
|
1449
1450
|
}
|
1450
1451
|
saveFile(e) {
|
1451
1452
|
return y.save(`file_${e.id}`, e), Promise.resolve(!0);
|
@@ -1469,7 +1470,7 @@ class Es extends ee {
|
|
1469
1470
|
return Promise.resolve(!0);
|
1470
1471
|
}
|
1471
1472
|
getHistory(e) {
|
1472
|
-
const t = y.get(`history_${e}`), s = new
|
1473
|
+
const t = y.get(`history_${e}`), s = new le(t || { id: e });
|
1473
1474
|
return Promise.resolve(s.toDsl());
|
1474
1475
|
}
|
1475
1476
|
getHistoryItem(e, t) {
|
@@ -1485,22 +1486,22 @@ class Es extends ee {
|
|
1485
1486
|
}), Promise.resolve(!0);
|
1486
1487
|
}
|
1487
1488
|
}
|
1488
|
-
class fs extends
|
1489
|
+
class fs extends te {
|
1489
1490
|
projects = {};
|
1490
1491
|
materials = {};
|
1491
1492
|
files = {};
|
1492
1493
|
histories = {};
|
1493
1494
|
historyItems = {};
|
1494
1495
|
init(e) {
|
1495
|
-
const t = new
|
1496
|
+
const t = new O(e), s = this.projects[t.id] || {}, r = Object.assign(t.toDsl(), s);
|
1496
1497
|
return this.projects[r.id] = r, Promise.resolve(r);
|
1497
1498
|
}
|
1498
1499
|
saveProject(e) {
|
1499
|
-
const t = new
|
1500
|
+
const t = new O(e);
|
1500
1501
|
return this.projects[t.id] = t.toDsl(), Promise.resolve(!0);
|
1501
1502
|
}
|
1502
1503
|
saveMaterials(e, t) {
|
1503
|
-
return e.id && (this.materials[e.id] =
|
1504
|
+
return e.id && (this.materials[e.id] = G(t)), Promise.resolve(!0);
|
1504
1505
|
}
|
1505
1506
|
saveFile(e) {
|
1506
1507
|
return this.files[e.id] = e, Promise.resolve(!0);
|
@@ -1524,7 +1525,7 @@ class fs extends ee {
|
|
1524
1525
|
return Promise.resolve(!0);
|
1525
1526
|
}
|
1526
1527
|
getHistory(e) {
|
1527
|
-
const t = this.histories[e], s = new
|
1528
|
+
const t = this.histories[e], s = new le(t || { id: e });
|
1528
1529
|
return Promise.resolve(s);
|
1529
1530
|
}
|
1530
1531
|
getHistoryItem(e, t) {
|
@@ -1542,11 +1543,11 @@ class fs extends ee {
|
|
1542
1543
|
}), Promise.resolve(!0);
|
1543
1544
|
}
|
1544
1545
|
}
|
1545
|
-
let
|
1546
|
+
let A = null;
|
1546
1547
|
function Ps() {
|
1547
|
-
return
|
1548
|
+
return A || (A = new fs(), A);
|
1548
1549
|
}
|
1549
|
-
class
|
1550
|
+
class Rs extends te {
|
1550
1551
|
getFileCaches = {};
|
1551
1552
|
async getExtension() {
|
1552
1553
|
return await this.api("getExtension", {}).catch(() => {
|
@@ -1561,7 +1562,7 @@ class xs extends ee {
|
|
1561
1562
|
async saveMaterials(e, t) {
|
1562
1563
|
return !!await this.api("saveMaterials", {
|
1563
1564
|
project: e,
|
1564
|
-
materials:
|
1565
|
+
materials: G(t)
|
1565
1566
|
}).catch(() => !1);
|
1566
1567
|
}
|
1567
1568
|
async saveFile(e) {
|
@@ -1625,14 +1626,14 @@ function Pe(n, e) {
|
|
1625
1626
|
e.can(s.id.toString()) && t.push(s);
|
1626
1627
|
return t;
|
1627
1628
|
}
|
1628
|
-
function
|
1629
|
-
const { menuBasePath: e = "/page" } = n || {}, t = be(), s =
|
1629
|
+
function xs(n) {
|
1630
|
+
const { menuBasePath: e = "/page" } = n || {}, t = be(), s = me(), r = vt(), o = T(!1), a = T(!1), i = t.project;
|
1630
1631
|
Qe(() => {
|
1631
1632
|
const { name: f, params: d, meta: u } = s;
|
1632
|
-
if (f ===
|
1633
|
+
if (f === k) {
|
1633
1634
|
const h = t.getPage(d.id);
|
1634
1635
|
o.value = !h?.mask, a.value = !!h?.pure;
|
1635
|
-
} else if (f ===
|
1636
|
+
} else if (f === I) {
|
1636
1637
|
const h = t.getHomepage();
|
1637
1638
|
o.value = !h?.mask, a.value = !!h?.pure;
|
1638
1639
|
} else
|
@@ -1652,44 +1653,44 @@ export {
|
|
1652
1653
|
_e as ACCESS_KEY,
|
1653
1654
|
js as Access,
|
1654
1655
|
Ze as BUILT_IN_DIRECTIVES,
|
1655
|
-
|
1656
|
-
|
1656
|
+
te as BaseService,
|
1657
|
+
ie as CONTEXT_HOST,
|
1657
1658
|
yt as Context,
|
1658
1659
|
_ as ContextMode,
|
1659
1660
|
et as DATA_TYPES,
|
1660
|
-
|
1661
|
+
I as HOMEPAGE_ROUTE_NAME,
|
1661
1662
|
$s as JSCodeToString,
|
1662
1663
|
_s as LIFE_CYCLES_LIST,
|
1663
|
-
|
1664
|
+
Rs as LocalService,
|
1664
1665
|
fs as MemoryService,
|
1665
1666
|
ls as NodeEnv,
|
1666
|
-
|
1667
|
+
k as PAGE_ROUTE_NAME,
|
1667
1668
|
us as Provider,
|
1668
1669
|
as as Startup,
|
1669
1670
|
Es as StorageService,
|
1670
|
-
|
1671
|
+
x as VTJ_RENDERER_VERSION,
|
1671
1672
|
ve as adoptedStyleSheets,
|
1672
1673
|
ws as createAssetScripts,
|
1673
1674
|
Ss as createAssetsCss,
|
1674
1675
|
Et as createDataSources,
|
1675
|
-
|
1676
|
+
W as createLoader,
|
1676
1677
|
Ps as createMemoryService,
|
1677
1678
|
pt as createMetaApi,
|
1678
1679
|
bs as createProvider,
|
1679
|
-
|
1680
|
+
K as createRenderer,
|
1680
1681
|
dt as createSchemaApi,
|
1681
1682
|
ft as createSchemaApis,
|
1682
|
-
|
1683
|
-
|
1683
|
+
xt as defaultLoader,
|
1684
|
+
F as fillBasePath,
|
1684
1685
|
Se as getModifiers,
|
1685
1686
|
we as getPlugin,
|
1686
1687
|
rt as getRawComponent,
|
1687
|
-
|
1688
|
+
Q as isCSSUrl,
|
1688
1689
|
lt as isJSCode,
|
1689
1690
|
S as isJSExpression,
|
1690
|
-
|
1691
|
+
U as isJSFunction,
|
1691
1692
|
tt as isJSON,
|
1692
|
-
|
1693
|
+
X as isJSUrl,
|
1693
1694
|
ct as isVuePlugin,
|
1694
1695
|
ot as loadCss,
|
1695
1696
|
it as loadCssUrl,
|
@@ -1697,14 +1698,14 @@ export {
|
|
1697
1698
|
mt as mockApi,
|
1698
1699
|
ht as mockApis,
|
1699
1700
|
ye as mockCleanup,
|
1700
|
-
|
1701
|
+
D as nodeRender,
|
1701
1702
|
nt as parseDeps,
|
1702
|
-
|
1703
|
-
|
1703
|
+
C as parseExpression,
|
1704
|
+
ae as parseFunction,
|
1704
1705
|
je as providerKey,
|
1705
1706
|
st as removeProdFlag,
|
1706
1707
|
ge as toString,
|
1707
1708
|
vt as useAccess,
|
1708
|
-
|
1709
|
+
xs as useMask,
|
1709
1710
|
be as useProvider
|
1710
1711
|
};
|
package/package.json
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vtj/renderer",
|
3
3
|
"private": false,
|
4
|
-
"version": "0.9.0-alpha.
|
4
|
+
"version": "0.9.0-alpha.17",
|
5
5
|
"type": "module",
|
6
6
|
"dependencies": {
|
7
7
|
"mockjs": "~1.1.0",
|
8
|
-
"@vtj/
|
9
|
-
"@vtj/
|
8
|
+
"@vtj/utils": "~0.9.0-alpha.17",
|
9
|
+
"@vtj/core": "~0.9.0-alpha.17"
|
10
10
|
},
|
11
11
|
"devDependencies": {
|
12
12
|
"vue": "~3.5.5",
|
13
13
|
"vue-router": "~4.4.0",
|
14
14
|
"@vtj/cli": "~0.9.0-alpha.2",
|
15
|
-
"@vtj/ui": "~0.9.0-alpha.
|
16
|
-
"@vtj/icons": "~0.9.0-alpha.
|
15
|
+
"@vtj/ui": "~0.9.0-alpha.17",
|
16
|
+
"@vtj/icons": "~0.9.0-alpha.17"
|
17
17
|
},
|
18
18
|
"exports": {
|
19
19
|
".": {
|
package/types/version.d.ts
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* Copyright (c) 2024, VTJ.PRO All rights reserved.
|
3
3
|
* @name @vtj/renderer
|
4
4
|
* @author CHC chenhuachun1549@dingtalk.com
|
5
|
-
* @version 0.9.0-alpha.
|
5
|
+
* @version 0.9.0-alpha.16
|
6
6
|
* @license <a href="https://vtj.pro/license.html">MIT License</a>
|
7
7
|
*/
|
8
|
-
export declare const version = "0.9.0-alpha.
|
8
|
+
export declare const version = "0.9.0-alpha.16";
|