UNPKG

@vtj/designer

Version:

VTJ 是一款基于 Vue3 + Typescript 的低代码页面可视化设计器。内置低代码引擎、渲染器和代码生成器,面向前端开发者,开箱即用。 无缝嵌入本地开发工程,不改变前端开发流程和编码习惯。

1,653 lines (1,652 loc) 396 kB
var xl = Object.defineProperty; var Cl = (u, t, e) => t in u ? xl(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e; var F = (u, t, e) => Cl(u, typeof t != "symbol" ? t + "" : t, e); import { computed as x, unref as n, ref as C, watch as W, reactive as nt, toValue as _e, defineComponent as T, createElementBlock as D, openBlock as c, toDisplayString as U, createVNode as m, withCtx as b, createElementVNode as j, createBlock as _, createCommentVNode as E, shallowRef as xe, readonly as Vl, onMounted as Gt, nextTick as Ve, getCurrentScope as jl, onScopeDispose as Al, getCurrentInstance as Kt, toRaw as En, createTextVNode as M, mergeProps as ce, h as Le, Fragment as L, renderList as J, normalizeClass as X, defineAsyncComponent as El, resolveDynamicComponent as Dn, createSlots as Dl, renderSlot as De, withDirectives as Re, vShow as qe, withModifiers as Se, isRef as Lt, normalizeStyle as st, inject as Xt, provide as Il, withKeys as Ee, normalizeProps as In, guardReactiveProps as $n, onUnmounted as Tn, markRaw as Nt, createApp as Pn, shallowReactive as $l, triggerRef as ze, KeepAlive as Rn } from "vue"; import { ElNotification as Qt, ElMessage as Oe, ElMessageBox as Ie, ElButton as Y, ElDivider as Ne, ElInput as de, ElRadioGroup as On, ElRadioButton as ot, ElButtonGroup as Tl, ElSwitch as Yt, ElImage as Bn, ElDropdown as zn, ElDropdownMenu as Fn, ElDropdownItem as bt, ElEmpty as ue, ElAlert as Zt, ElTooltip as Ln, ElTag as Nn, ElTree as en, ElCollapse as Ct, ElCollapseItem as Vt, ElRow as _t, ElCol as wt, ElDrawer as Un, ElForm as be, ElFormItem as et, ElBreadcrumb as Pl, ElBreadcrumbItem as Rl, ElLoading as Ol, ElBadge as Bl, ElAvatar as Jn, vLoading as zl, ElSelect as Fl, ElOption as Ll, ElInputNumber as Nl, ElColorPicker as Ul, ElUpload as Jl, ElSlider as Wl, ElConfigProvider as Ml, ElContainer as vn, ElHeader as ql, ElAside as gn, ElMain as Hl, ElFooter as Gl } from "element-plus"; import Kl from "element-plus/es/locale/lang/zh-cn"; import { XDialogForm as $e, XField as R, createDialog as Wn, XIcon as Ue, XDialog as Te, XPanel as jt, XAction as he, XTabs as At, XContainer as K, XForm as tn, XAttachment as Xl, XActionBar as Ql, XInputUnit as Mn, vResizable as fn } from "@vtj/ui"; import { kebabCase as Yl, jsonp as Ye, groupBy as it, dataURLtoBlob as Zl, delay as ut, upperFirstCamelCase as qn, toRawType as Pt, cloneDeep as vt, logger as Be, isPlainObject as ea, fileToBase64 as ta, merge as nn, toArray as ln, debounce as Hn, storage as hn, uuid as na, getClientInfo as la, base64 as aa, arrayToMap as sa } from "@vtj/utils"; import { BUILT_IN_NAME as kt, isBlock as oe, DirectiveModel as Gn, createNodeFrom as oa, BUILT_IN_VUE as bn, BUILT_IN_VUE_ROUTER as ra, emitter as ie, EVENT_PROJECT_ACTIVED as Ut, EVENT_NODE_CHANGE as ct, NodeModel as Rt, EVENT_BLOCK_CHANGE as Jt, Base as Kn, BUILT_IN_LIBRARAY_MAP as ia, ProjectModel as ua, EVENT_PROJECT_CHANGE as ca, EVENT_PROJECT_BLOCKS_CHANGE as da, EVENT_PROJECT_PAGES_CHANGE as pa, EVENT_PROJECT_DEPS_CHANGE as ma, EVENT_PROJECT_PUBLISH as va, EVENT_PROJECT_FILE_PUBLISH as ga, EVENT_HISTORY_CHANGE as fa, EVENT_HISTORY_LOAD as ha, EVENT_PROJECT_GEN_SOURCE as ba, BlockModel as yn, HistoryModel as ya } from "@vtj/core"; import { parseExpression as dt, parseFunction as Xn, BUILT_IN_DIRECTIVES as _a, JSCodeToString as tt, LIFE_CYCLES_LIST as wa, DATA_TYPES as ka, createMock as Sa, isJSExpression as He, ContextMode as Qn, clearLoaderCache as xa, parseDeps as Ca, createAssetsCss as Va, createAssetScripts as _n, getRawComponent as wn, createSchemaApis as ja, mockCleanup as Aa, mockApis as Ea, Provider as Da, Access as Ia, isJSFunction as $a } from "@vtj/renderer"; import { VtjIconBack as Ta, VtjIconPc as Pa, VtjIconPhone as Ra, VtjIconPad as Oa, VtjIconEdit as an, VtjIconUndo as Ba, VtjIconRedo as za, VtjIconTemplate as St, VtjIconPreview as Fa, VtjIconRefresh as Yn, VtjIconSetting as Zn, Download as Wt, VtjIconPublish as La, VtjIconProject as Na, icons as Mt, ArrowDown as sn, Search as Ge, CopyDocument as Ua, Back as Ja, VtjIconPlus as el, EditPen as Wa, Delete as tl, VtjIconSave as Ma, ArrowUp as qa, MoreFilled as lt, VtjIconCheck as nl, VtjIconComponents as ll, VtjIconShare as Ha, VtjIconHome as Ga, VtjIconVisible as Ka, VtjIconInvisible as al, VtjIconUnlock as Xa, VtjIconLock as sl, VtjIconRemove as Et, VtjIconCopy as on, Files as Qa, VtjIconSearch as Ya, VtjIconHelp as ol, VtjIconLayers as rl, Rank as Za, VtjIconArrowUp as es, VtjIconArrowDown as ts, IconDisplayBlock as ns, IconDisplayFlex as ls, IconDisplayInlineBlock as as, IconDisplayInline as ss, IconEyeInvisible as os, IconFlexDirectionrow as rs, IconFlexDirectionrowReverse as is, IconFlexDirectioncolumn as us, IconFlexDirectioncolumnReverse as cs, IconFlexJustifyflexStartrow as ds, IconFlexJustifyflexEndrow as ps, IconFlexJustifycenterrow as ms, IconFlexJustifyspaceBetweenrow as vs, IconFlexJustifyspaceAroundrow as gs, IconFlexAlignflexStartrow as fs, IconFlexAlignflexEndrow as hs, IconFlexAligncenterrow as bs, IconFlexAlignbaselinerow as ys, IconFlexAlignstretchrow as _s, IconPositionTopLeft as ws, IconPositionTopRight as ks, IconPositionBottomLeft as Ss, IconPositionBottomRight as xs, IconPositionLeft as Cs, IconPositionRight as Vs, IconPositionTop as js, IconPositionBottom as As, IconPositionAll as Es, IconTextAlignLeft as Ds, IconTextAlignCenter as Is, IconTextAlignRight as $s, IconTextAlignJustify as Ts, IconFontStyleNone as Ps, IconFontStyleItalic as Rs, IconCross as il, IconTextDecorationUnderline as Os, IconTextDecorationStrike as Bs, IconTextDecorationOverline as zs, IconTileXy as Fs, IconTileX as Ls, IconTileY as Ns, IconClose as Us, IconBorderAll as Js, IconBorderLeft as Ws, IconBorderTop as Ms, IconBorderBottom as qs, IconBorderRight as Hs, IconBorderStyleSolid as Gs, IconBorderStyleDashed as Ks, IconBorderStyleDotted as Xs, IconCursorAuto as Qs, IconCursorPointer as Ys, IconCursorNotAllowed as Zs, IconCursorNone as eo, ArrowRight as to, UserFilled as ul, VtjIconDocument as no, VtjIconBlock as lo, VtjIconOutline as ao, VtjIconHistory as so, VtjIconApi as oo, VtjIconCategory as ro, VtjIconUniapp as io, HomeFilled as uo, Plus as co, Close as po, VtjIconVars as mo, VtjIconSwitch as vo, Switch as go } from "@vtj/icons"; import fo from "html2canvas"; import cl from "mockjs"; import { PAGE_LIFE_CYCLES_LIST as ho, APP_LIFE_CYCLE as bo, createUniAppComponent as yo, setupUniApp as _o } from "@vtj/uni"; /**! * Copyright (c) 2025, VTJ.PRO All rights reserved. * @name @vtj/designer * @author CHC chenhuachun1549@dingtalk.com * @version 0.11.13 * @license <a href="https://vtj.pro/license.html">MIT License</a> */ const pt = "0.11.13", wo = { width: 390, height: 844 }, ko = { width: 1024, height: 768 }, Pe = /^[A-Za-z_$][\:\w_-]*$/, So = /(\d+)\.(\d+)\.(\d+)/, xo = [ "click", "dblclick", "mouseenter", "mouseleave", "mousedown", "mouseup", "mouseover", "contextmenu" ], Co = ["keydown", "keyup", "keypress"], Vo = [ "GET", "POST", "PUT", "PATCH", "DELETE", "JSONP" ], jo = [ "stop", "prevent", "capture", "self", "once", "passive" ], kn = "__vue-devtools-frame-state__", Ao = "@id/virtual:vue-devtools-path:overlay.js", Eo = "@id/virtual:vue-devtools-path:overlay/devtools-overlay.mjs", Do = [ "h", "t", "t", "p", "s", ":", "/", "/", "r", "e", "g", "i", "s", "t", "r", "y", ".", "n", "p", "m", "m", "i", "r", "r", "o", "r", ".", "c", "o", "m", "/", "@", "v", "t", "j", "/", "p", "r", "o" ].join(""), Io = [ "h", "t", "t", "p", "s", ":", "/", "/", "l", "c", "d", "p", ".", "v", "t", "j", ".", "p", "r", "o" ].join(""), $o = { auth: [ "h", "t", "t", "p", "s", ":", "/", "/", "l", "c", "d", "p", ".", "v", "t", "j", ".", "p", "r", "o", "/", "a", "u", "t", "h", ".", "h", "t", "m", "l" ].join(""), storageKey: [ "R", "R", "O", "_", "I", "D", "E", "_", "A", "C", "C", "E", "S", "S", "_", "S", "T", "O", "R", "A", "G", "E", "_", "_" ].join(""), privateKey: "MIIBOgIBAAJBAKoIzmn1FYQ1YOhOBw9EhABxZ+PySAIaydI+zdhoKflrdgJ4A5E4/5gbQmRpk09hPWG8nvX7h+l/QLU8kXxAIBECAwEAAQJAAlgpxQY6sByLsXqzJcthC8LSGsLf2JEJkHwlnpwFqlEV8UCkoINpuZ2Wzl+aftURu5rIfAzRCQBvHmeOTW9/zQIhAO5ufWDmnSLyfAAsNo5JRNpVuLFCFodR8Xm+ulDlosR/AiEAtpAltyP9wmCABKG/v/hrtTr3mcvFNGCjoGa9bUAok28CIHbrVs9w1ijrBlvTsXYwJw46uP539uKRRT4ymZzlm9QjAiB+1KH/G9f9pEEL9rtaSOG7JF5D0JcOjlze4MGVFs+ZrQIhALKOUFBNr2zEsyJIjw2PlvEucdlG77UniszjXTROHSPd" }, To = [ "/", "a", "p", "i", "/", "o", "p", "e", "n", "/", "r", "e", "p", "o", "r", "t" ].join(""), Sn = "SESSION_ID__"; var Ce = /* @__PURE__ */ ((u) => (u.Block = "block", u.Node = "node", u))(Ce || {}), Po = /* @__PURE__ */ ((u) => (u.Brand = "Brand", u.Toolbar = "Toolbar", u.Actions = "Actions", u.Apps = "Apps", u.Workspace = "Workspace", u.Settings = "Settings", u.Status = "Status", u.Preview = "Preview", u))(Po || {}); function dl() { const u = pe(), t = x(() => u.project.value?.dependencies ?? []), e = x(() => u.project.value?.apis ?? []), l = x(() => u.project.value?.meta ?? []); return { engine: u, dependencies: t, apis: e, meta: l }; } function Je(u, t) { const e = x(() => mn.getWidgets(n(u), n(t)).filter((a) => !a.invisible)), l = C(); return { widgets: e, widgetsRef: l }; } function rn(u = 160) { const t = pe(); return { span: x(() => { const r = t.skeleton?.skeletonRef.leftWidth || 350, s = Math.max(Math.floor(r / u), 1); return Math.floor(24 / s); }), engine: t }; } function Ro() { const u = pe(), t = x(() => u.project.value?.blocks ?? []); return { engine: u, blocks: t }; } const Oo = (u = []) => u.map((t) => t.name), Bo = (u) => { const t = u.findIndex((e) => e.name === kt); u.splice(t, 1); }; function zo() { const u = pe(), { components: t, groups: e, componentMap: l } = u.assets; W( e, () => { const { platform: g = "web" } = u.project.value || {}; g === "uniapp" && Bo(e.value); }, { immediate: !0 } ); const a = nt({}), r = x(() => { const g = {}; return e.value && e.value.forEach((f) => { g[f.name] = f; }), g; }), s = x(() => e.value ? e.value.map((g) => ({ label: `${g.label} (${g.count})`, name: g.name, disabled: !g.children?.length })) : []), o = C(s.value[0]?.name), i = C(""), p = x(() => r.value[o.value]); W( s, (g) => { const f = g.reduce( (h, v) => (h[v.name] = Oo( r.value[v.name].children ), h), {} ); Object.assign(a, f); }, { immediate: !0 } ), W( s, (g) => { g.length && !o.value && (o.value = g[0].name); }, { immediate: !0 } ); const d = x(() => { const g = i.value.toLowerCase(); return !g || !t ? [] : t.filter((f) => f.name.toLowerCase().includes(g) || f.label?.toLowerCase().includes(g)); }); return { components: t, groups: e, componentMap: l, groupMap: r, tabs: s, model: a, currentTab: o, currentGroup: p, searchKey: i, searchResult: d }; } function ge() { const u = pe(), t = x(() => u.current.value), e = x(() => u.simulator.renderer?.context ?? null), l = x(() => u.isEmptyCurrent.value); return { engine: u, current: t, isEmpty: l, context: e }; } function Fo(u, t, e, l, a, r) { const s = pe(); s.simulator.init(u, t, e, l, a, r); const o = x(() => s.simulator.designer.value), i = x( () => Ot("hover", o.value?.hover.value) ), p = x( () => Ot("dropping", o.value?.dropping.value) ), d = x( () => Ot("selected", o.value?.selected.value) ), g = x( () => o.value?.outlineEnabled.value ? Uo(o.value?.lines.value || []) : [] ); return W(s.changed, () => { o.value?.updateRect(), o.value?.updateLines(); }), { designer: o, dropping: p, hover: i, selected: d, lines: g }; } function Lo(u, t = !0) { const { top: e, height: l, width: a, left: r, right: s } = u || {}, o = 250; if (l > 100 && a > o) return "inner"; let i, p; return p = e > 30 ? "top" : "bottom", i = t || r < o && a < o ? "left" : "right", i = s > o ? "right" : "left", [i, p].join("-"); } function No(u) { const { rect: t, type: e } = u, { left: l, width: a, top: r, height: s } = t, o = { left: l, width: a, top: r, height: s }; switch (e) { case "left": o.left = 0, o.width = 0; break; case "right": o.left = o.left + o.width - 4, o.width = 0; break; case "bottom": o.top = o.top + o.height - 4, o.height = 0; break; case "top": o.height = 0; break; } return o; } function Ot(u, t) { if (!t) return null; const { left: e, top: l, width: a, height: r } = u === "dropping" ? No(t) : t.rect, s = { left: `${e}px`, top: `${l}px`, width: `${a}px`, height: `${r}px`, visibility: a || r ? "visible" : "hidden" }; return { ...t, style: s, position: Lo(t.rect, u !== "selected") }; } function Uo(u) { return u.map((t) => { const { width: e, height: l, left: a, top: r } = t; return { width: `${e}px`, height: `${l}px`, left: `${a}px`, top: `${r}px` }; }); } function Ae() { const u = pe(), t = x( () => u.simulator.designer.value ), e = x(() => t.value?.selected.value), l = x(() => oe(e.value?.model)); return { engine: u, designer: t, selected: e, isSelectBlock: l }; } function Jo(u, t) { const e = C(""), { selected: l, isSelectBlock: a } = Ae(), r = x(() => l.value?.model.id), s = x(() => { const i = _e(u), p = _e(t), d = []; if (!i) return d; const g = p?.__contextRefs[r.value || ""], h = p === g || a.value ? [] : Object.keys(g?.context || {}).filter(($) => !["context", "ref"].includes($)).map(($) => `this.context.${$}`); h.length && d.push({ title: "上下文", items: h }); const v = i.inject.map(($) => `this.${$.name}`); v.length && d.push({ title: "注入", items: v }); const S = i.props.map( ($) => typeof $ == "string" ? `this.props.${$}` : `this.props.${$.name}` ); S.length && d.push({ title: "属性", items: S }); const y = Object.keys(i.state).map(($) => `this.state.${$}`); y.length && d.push({ title: "状态", items: y }); const w = Object.keys(i.computed).map( ($) => `this.${$}.value` ); w.length && d.push({ title: "计算属性", items: w }); const k = Object.keys(i.methods).map(($) => `this.${$}`); k.length && d.push({ title: "方法", items: k }); const V = Object.keys(i.dataSources).map( ($) => `this.${$}` ); V.length && d.push({ title: "数据源", items: V }); const A = Object.keys(p?.$refs || {}).map( ($) => `this.$refs.${$}` ); return A.length && d.push({ title: "refs", items: A }), d; }), o = x(() => { if (!e.value) return s.value; const i = e.value.toLowerCase(), p = []; return s.value.forEach((d) => { const g = d.items.filter( (f) => f.toLowerCase().includes(i) ); g.length && p.push({ title: d.title, items: g }); }), p; }); return { keyword: e, options: s, searchResult: o }; } const ht = [ { name: "StringSetter", label: "文本" }, { name: "ExpressionSetter", label: "表达式" } ]; function Wo(u) { const t = pe(), e = x(() => { const g = u.value?.model || null; return oe(g) ? null : g; }), l = C(); W( e, async (g) => { g?.from ? l.value = await t.assets.getBlockMaterial(g.from) || void 0 : l.value = void 0; }, { immediate: !0 } ); const a = x(() => e.value ? [ { name: "key", setters: ht, value: e.value.getPropValue("key") }, { name: "ref", setters: ht, value: e.value.getPropValue("ref") }, { name: "class", label: "class", setters: ht, value: e.value.getPropValue("class") }, { name: "style", label: "style", setters: [ { name: "JSONSetter", label: "JSON" }, { name: "ExpressionSetter", label: "表达式" } ], value: e.value.getPropValue("style") }, { name: "children", label: "文本", title: "如设置组件文本,将清空子组件", setters: ht, value: Array.isArray(e.value.children) ? "" : e.value.children } ] : []), r = x(() => { if (!e.value) return []; const g = l.value || t.assets.componentMap.get(e.value.name); return g ? (g.props || []).map((h) => ({ ...h, value: e.value?.getPropValue(h.name) ?? h.defaultValue })) : []; }), s = (g) => a.value.some((f) => f.name === g) || r.value.some((f) => f.name === g) || g === "style", o = x(() => e.value ? Object.keys(e.value.props).filter((g) => !s(g)).map((g) => ({ name: g, setters: "InputSetter", value: e.value?.getPropValue(g) })) : []); return { commonProps: a, componentProps: r, customProps: o, node: e, change: (g, f) => { e.value && (g === "children" ? e.value.setChildren(f) : e.value.setProp(g, f)); }, addCustom: (g) => { g && e.value?.setProp(g, ""); }, removeCustom: (g) => { e.value?.removeProp(g); }, isExist: s }; } function Mo(u) { return Ie.alert(u, { title: "提示", type: "warning" }); } function ae(u, t = "提示") { return Qt.warning({ title: t, message: u }); } async function Ke(u) { return await Ie.confirm(u, "提示", { type: "warning" }).catch( () => !1 ); } function me(u, t = "success") { return Oe({ message: u, type: t }); } function qo(u) { const t = u ? { ...u } : {}, e = (l) => new Proxy(l || {}, { get(a, r) { return typeof r == "symbol" ? () => { } : e(a[r]); } }); return t.context = new Proxy(t.context || {}, { get(l, a) { return e(l[a]); } }), t; } function ve(u, t, e = !1) { let l = !0; const a = qo(t); try { u.type === "JSExpression" ? dt(u, a, e, !0) : Xn(u, a, e, !0); } catch (r) { l = !1, Qt.error({ title: "代码错误", message: r.message }); } return l; } function Ho(u) { return Object.keys(u).concat( Object.getPrototypeOf(u) ? Object.getOwnPropertyNames(Object.getPrototypeOf(u)) : [] ).filter((t) => !["constructor"].includes(t)); } function qt(u = {}) { const t = {}; for (const [e, l] of Object.entries(u)) t[Yl(e)] = l; return t; } function pl() { const u = pe(), t = x( () => u.simulator.designer.value ), e = x( () => u.current.value ? u.history.value : null ), l = x(() => e.value?.items.length || 0), a = () => { t.value?.cleanHelper(), e.value?.forward(); }, r = () => { e.value?.backward(), t.value?.cleanHelper(); }, s = (p) => { t.value?.cleanHelper(), e.value?.load(p), me("已载入历史记录", "success"); }, o = x(() => l.value <= 1 ? !0 : (e.value?.index || -1) <= 0), i = x(() => l.value <= 1 ? !0 : (e.value?.index || -1) >= l.value - 1); return { engine: u, history: e, total: l, forward: a, backward: r, load: s, forwardDisabled: o, backwardDisabled: i }; } function Xe() { const u = pe(), t = x(() => u.project.value); return { engine: u, project: t }; } function Go(u) { const t = pe(), e = x(() => { const o = u.value?.model || null; return !o || oe(o) ? null : o; }), l = C(); W( e, async (o) => { o?.from ? l.value = await t.assets.getBlockMaterial(o.from) || void 0 : l.value = void 0; }, { immediate: !0 } ); const a = x(() => { if (oe(e.value)) return []; const o = e.value?.events || {}; return xo.map((i) => ({ name: i, event: o[i] })); }), r = x(() => { if (oe(e.value)) return []; const o = e.value?.events || {}; return Co.map((i) => ({ name: i, event: o[i] })); }), s = x(() => { if (!e.value || oe(e.value)) return []; const o = e.value.events || {}; return (l.value?.events || t.assets.componentMap.get(e.value.name)?.events || []).map((p) => { const d = typeof p == "string" ? p : p.name; return { name: d, event: o[d] }; }); }); return { mouseEventList: a, keyboardEventList: r, componentEventList: s }; } const Bt = (u, t) => new Gn({ name: u, value: void 0, iterator: t }), Ko = (u = "modelValue") => new Gn({ name: "vModel", value: void 0, arg: u }); function Xo(u) { if (!u) return []; const { props: t = [], events: e = [] } = u; if (t.length && e.length) { const l = e.filter((a) => (typeof a == "string" ? a : a.name).startsWith("update:")).map((a) => a = typeof a == "string" ? a : a.name); return l.length ? t.filter((a) => l.some((r) => r.endsWith(":" + a.name))) : []; } return []; } function Qo(u) { const t = pe(), e = x(() => { const A = u.value?.model || null; return oe(A) ? null : A; }), l = (A) => x(() => e.value && (e.value.directives || []).find(($) => $.name === A) || Bt(A)), a = () => x(() => { if (!e.value) return []; const A = t.assets.componentMap.get(e.value.name || ""); return (A ? Xo(A) : []).map((I) => (e.value?.directives || []).find( (O) => O.name === "vModel" && O.arg == I.name ) || Ko(I.name)); }), r = () => x(() => e.value ? (e.value.directives || []).filter( (A) => !_a.includes(A.name) ) : []), s = l("vIf"), o = l("vShow"), i = l("vBind"), p = l("vFor"), d = l("vHtml"), g = a(), f = r(), h = { vIf: s, vShow: o, vBind: i, vFor: p, vHtml: d }; return { engine: t, node: e, vIf: s, vShow: o, vBind: i, vFor: p, vHtml: d, vModels: g, customDirectives: f, onValueChange: (A, $) => { const I = h[A]; e.value && ($ ? (I.value.value = $, e.value.setDirective(I.value)) : (I.value.value = void 0, e.value.removeDirective(I.value))); }, onForChange: (A, $) => { if (e.value) { if (A === "value") { $ ? (p.value.value = $, e.value.setDirective(p.value)) : e.value.removeDirective(p.value); return; } (A === "item" || A === "index") && (p.value.iterator = { ...p.value.iterator, [A]: $ || void 0 }, e.value.setDirective(p.value)); } }, onModelChange: (A, $) => { if (!e.value) return; const I = parseInt(A), O = g.value[I]; O && ($ ? (O.value = $, e.value.setDirective(O)) : (O.value = void 0, e.value.removeDirective(O))); }, onAddCustom: () => { const A = Bt(""); e.value?.setDirective(A); }, onRemoveCustom: async (A) => { await Ke("确定删除指令?") && e.value?.removeDirective(A); }, onCustomChange: (A) => ($, I) => { A.update({ [$]: I }), e.value?.setDirective(A); } }; } function Yo() { const { engine: u, project: t } = Xe(), e = x(() => t.value?.apis || []), l = x(() => t.value?.meta || []); return { engine: u, project: t, apis: e, meta: l }; } function Dt() { const u = pe(), { access: t, remote: e } = u || {}, l = () => { if (e && t) { const f = encodeURIComponent(location.href), { auth: h = "/auth.html" } = t.options, { protocol: v, host: S, pathname: y } = location, w = `${v}//${S}${y}#/auth?redirect=${f}`; if (typeof h == "string") { const k = h.startsWith("/") ? `${e}${h}` : h; location.href = `${k}?r=${encodeURIComponent(w)}`; } else h(location.search); } }, a = async () => { const f = t?.getData()?.token; if (f) { const h = `${e}/api/open/user/${f}`, v = await Ye(h).catch(() => null); return !!(v && v.data); } return !1; }, r = async (f = "web") => { const h = `${e}/api/open/templates`, v = t?.getData()?.token; return (await Ye(h, { query: v ? { platform: f, token: v } : { platform: f } }))?.data || []; }, s = async (f) => { const h = t?.getData()?.token, v = `${e}/api/open/template/${h}`; return (await Ye(v, { query: { id: f } }))?.data || null; }, o = async (f) => { const h = t?.getData()?.token, v = `${e}/api/open/template/remove/${h}`; return !!(await Ye(v, { query: { id: f } }))?.data; }, i = async (f) => { const h = t?.getData()?.token, v = `${e}/api/open/dsl/${h}`, S = await Ye(v, { query: { id: f } }); return S?.data ? S.data : null; }, p = async (f) => { const h = `${e}/api/open/dict/${f}`; return (await Ye(h))?.data || []; }; return { engine: u, access: t, remote: e, toRemoteAuth: l, isLogined: a, getTemplates: r, getTemplateDsl: i, getDictOptions: p, getTemplateCategories: () => p("TemplateCategory"), publishTemplate: async (f) => { const h = t?.getData()?.token, v = `${e}/api/open/template/publish/${h}`, S = new FormData(); for (const [y, w] of Object.entries(f)) w !== void 0 && S.append(y, w); return window.fetch(v, { method: "post", body: S }).then((y) => y.json()); }, getTemplateById: s, removeTemplate: o }; } function Zo() { const { engine: u, access: t, toRemoteAuth: e, isLogined: l, getTemplates: a, getTemplateDsl: r, removeTemplate: s } = Dt(), o = C([]), i = C(!1), p = async (f) => { const h = u.current.value, v = u.project.value; if (!v) return; if (!h) { Oe.warning({ message: "设计区无文件,请先打开页面或区块" }); return; } const S = await r(f); if (!S) return await Ie.alert("模板不可用,可能该模板没发布过版本", { type: "error", title: "提示" }); const y = h.toDsl(), { id: w, name: k } = y, V = { ...S, id: w, name: k }, A = v.currentFile; u.onSaveBlockFileFinish(() => { h.update(V), Oe.success({ message: "模板已加载完成" }); }), A && (A.market = { id: f }, A.dsl = V, v.isPageFile(A) ? v.updatePage(A) : v.updateBlock(A)); }, d = x(() => { const f = t?.getData()?.id; return it(o.value, (h) => h.author === f ? "我的" : h.category); }), g = () => { const f = u.project.value; i.value = !0, a(f?.platform).then((h) => { o.value = h; }).finally(() => { i.value = !1; }); }; return g(), { engine: u, templates: o, toRemoteAuth: e, isLogined: l, getTemplates: a, getTemplateDsl: r, installTemplate: p, removeTemplate: s, groups: d, access: t, refreshTemplates: g, loading: i }; } function ml(u) { const t = C(); return t.value ? t.value !== pt && u && u(t.value) : window.fetch(Do).then((e) => e.json()).then((e) => { e && (t.value = e["dist-tags"]?.latest, t.value && t.value !== pt && u && u(t.value)); }), { latest: t }; } const er = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1711803009570'%20class='icon'%20viewBox='0%200%201280%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='1500'%20width='320'%20height='256'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cpath%20d='M557.85%201023l-122-35.4c-12.8-3.6-20-17-16.4-29.8L692.45%2017.4c3.6-12.8%2017-20%2029.8-16.4l122%2035.4c12.8%203.6%2020%2017%2016.4%2029.8L587.65%201006.6c-3.8%2012.8-17%2020.2-29.8%2016.4z%20m-228-224.4l87-92.8c9.2-9.8%208.6-25.4-1.6-34.4L234.05%20512l181.2-159.4c10.2-9%2011-24.6%201.6-34.4l-87-92.8c-9-9.6-24.2-10.2-34-1L7.65%20494.4c-10.2%209.4-10.2%2025.6%200%2035l288.2%20270.2c9.8%209.2%2025%208.8%2034-1z%20m654.4%201.2l288.2-270.2c10.2-9.4%2010.2-25.6%200-35L984.25%20224.2c-9.6-9-24.8-8.6-34%201L863.25%20318c-9.2%209.8-8.6%2025.4%201.6%2034.4L1046.05%20512l-181.2%20159.4c-10.2%209-11%2024.6-1.6%2034.4l87%2092.8c9%209.8%2024.2%2010.2%2034%201.2z'%20fill='%230157fe'%20p-id='1501'%3e%3c/path%3e%3c/svg%3e", tr = ["title", "src"], nr = { key: 1 }, lr = /* @__PURE__ */ T({ name: "LogoWidget", inheritAttrs: !1, __name: "index", props: { icon: {}, text: { default: "VTJ" }, link: {} }, setup(u) { const { engine: t } = ge(), e = u, l = x(() => e.icon || t.project.value?.config?.logo || er), a = () => { e.link && (location.href = e.link); }; return (r, s) => (c(), D("div", { class: "v-logo-widget", onClick: a }, [ l.value ? (c(), D("img", { key: 0, title: e.text, class: "v-logo-widget__icon", src: l.value }, null, 8, tr)) : (c(), D("span", nr, U(e.text), 1)) ])); } }), ar = { class: "v-empty-widget" }, sr = /* @__PURE__ */ T({ name: "EmptyWidget", __name: "index", setup(u) { return (t, e) => (c(), D("div", ar, "EmptyWidget")); } }), or = { class: "v-switcher-widget" }, rr = { key: 1 }, ir = /* @__PURE__ */ T({ name: "SwitcherWidget", inheritAttrs: !1, __name: "index", emits: ["click"], setup(u, { emit: t }) { const e = t, { engine: l } = ge(), a = x(() => l.project.value?.config?.title || l.project.value?.name), r = x(() => l.project.value?.currentFile?.title), s = () => { e("click", l.project.value); }; return (o, i) => (c(), D("div", or, [ m(n(Y), { size: "small", round: "", onClick: s }, { default: b(() => [ m(n(Ta), { class: "v-switcher-widget__back" }), j("span", null, U(a.value), 1), r.value ? (c(), _(n(Ne), { key: 0, direction: "vertical" })) : E("", !0), r.value ? (c(), D("span", rr, U(r.value), 1)) : E("", !0) ]), _: 1 }) ])); } }); function un(u) { return jl() ? (Al(u), !0) : !1; } const It = typeof window < "u" && typeof document < "u"; typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope; const ur = (u) => typeof u < "u", cr = Object.prototype.toString, dr = (u) => cr.call(u) === "[object Object]", Ze = () => { }, pr = /* @__PURE__ */ mr(); function mr() { var u, t; return It && ((u = window?.navigator) == null ? void 0 : u.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window?.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent)); } function vr(u) { let t; function e() { return t || (t = u()), t; } return e.reset = async () => { const l = t; t = void 0, l && await l; }, e; } function yt(u) { return Array.isArray(u) ? u : [u]; } function gr(u) { return Kt(); } function fr(u, t = !0, e) { gr() ? Gt(u, e) : t ? u() : Ve(u); } function hr(u, t, e = {}) { const { immediate: l = !0, immediateCallback: a = !1 } = e, r = xe(!1); let s = null; function o() { s && (clearTimeout(s), s = null); } function i() { r.value = !1, o(); } function p(...d) { a && u(), o(), r.value = !0, s = setTimeout(() => { r.value = !1, s = null, u(...d); }, _e(t)); } return l && (r.value = !0, It && p()), un(i), { isPending: Vl(r), start: p, stop: i }; } function br(u, t, e) { return W( u, t, { ...e, immediate: !0 } ); } const $t = It ? window : void 0, vl = It ? window.navigator : void 0; function je(u) { var t; const e = _e(u); return (t = e?.$el) != null ? t : e; } function Me(...u) { const t = [], e = () => { t.forEach((o) => o()), t.length = 0; }, l = (o, i, p, d) => (o.addEventListener(i, p, d), () => o.removeEventListener(i, p, d)), a = x(() => { const o = yt(_e(u[0])).filter((i) => i != null); return o.every((i) => typeof i != "string") ? o : void 0; }), r = br( () => { var o, i; return [ (i = (o = a.value) == null ? void 0 : o.map((p) => je(p))) != null ? i : [$t].filter((p) => p != null), yt(_e(a.value ? u[1] : u[0])), yt(n(a.value ? u[2] : u[1])), // @ts-expect-error - TypeScript gets the correct types, but somehow still complains _e(a.value ? u[3] : u[2]) ]; }, ([o, i, p, d]) => { if (e(), !o?.length || !i?.length || !p?.length) return; const g = dr(d) ? { ...d } : d; t.push( ...o.flatMap( (f) => i.flatMap( (h) => p.map((v) => l(f, h, v, g)) ) ) ); }, { flush: "post" } ), s = () => { r(), e(); }; return un(e), s; } let xn = !1; function yr(u, t, e = {}) { const { window: l = $t, ignore: a = [], capture: r = !0, detectIframe: s = !1, controls: o = !1 } = e; if (!l) return o ? { stop: Ze, cancel: Ze, trigger: Ze } : Ze; if (pr && !xn) { xn = !0; const y = { passive: !0 }; Array.from(l.document.body.children).forEach((w) => Me(w, "click", Ze, y)), Me(l.document.documentElement, "click", Ze, y); } let i = !0; const p = (y) => _e(a).some((w) => { if (typeof w == "string") return Array.from(l.document.querySelectorAll(w)).some((k) => k === y.target || y.composedPath().includes(k)); { const k = je(w); return k && (y.target === k || y.composedPath().includes(k)); } }); function d(y) { const w = _e(y); return w && w.$.subTree.shapeFlag === 16; } function g(y, w) { const k = _e(y), V = k.$.subTree && k.$.subTree.children; return V == null || !Array.isArray(V) ? !1 : V.some((A) => A.el === w.target || w.composedPath().includes(A.el)); } const f = (y) => { const w = je(u); if (y.target != null && !(!(w instanceof Element) && d(u) && g(u, y)) && !(!w || w === y.target || y.composedPath().includes(w))) { if ("detail" in y && y.detail === 0 && (i = !p(y)), !i) { i = !0; return; } t(y); } }; let h = !1; const v = [ Me(l, "click", (y) => { h || (h = !0, setTimeout(() => { h = !1; }, 0), f(y)); }, { passive: !0, capture: r }), Me(l, "pointerdown", (y) => { const w = je(u); i = !p(y) && !!(w && !y.composedPath().includes(w)); }, { passive: !0 }), s && Me(l, "blur", (y) => { setTimeout(() => { var w; const k = je(u); ((w = l.document.activeElement) == null ? void 0 : w.tagName) === "IFRAME" && !k?.contains(l.document.activeElement) && t(y); }, 0); }, { passive: !0 }) ].filter(Boolean), S = () => v.forEach((y) => y()); return o ? { stop: S, cancel: () => { i = !1; }, trigger: (y) => { i = !0, f(y), i = !1; } } : S; } function _r() { const u = xe(!1), t = Kt(); return t && Gt(() => { u.value = !0; }, t), u; } function cn(u) { const t = _r(); return x(() => (t.value, !!u())); } function Cn(u, t = {}) { const { controls: e = !1, navigator: l = vl } = t, a = cn(() => l && "permissions" in l), r = xe(), s = typeof u == "string" ? { name: u } : u, o = xe(), i = () => { var d, g; o.value = (g = (d = r.value) == null ? void 0 : d.state) != null ? g : "prompt"; }; Me(r, "change", i, { passive: !0 }); const p = vr(async () => { if (a.value) { if (!r.value) try { r.value = await l.permissions.query(s); } catch { r.value = void 0; } finally { i(); } if (e) return En(r.value); } }); return p(), e ? { state: o, isSupported: a, query: p } : o; } function gl(u = {}) { const { navigator: t = vl, read: e = !1, source: l, copiedDuring: a = 1500, legacy: r = !1 } = u, s = cn(() => t && "clipboard" in t), o = Cn("clipboard-read"), i = Cn("clipboard-write"), p = x(() => s.value || r), d = xe(""), g = xe(!1), f = hr(() => g.value = !1, a, { immediate: !1 }); async function h() { let k = !(s.value && w(o.value)); if (!k) try { d.value = await t.clipboard.readText(); } catch { k = !0; } k && (d.value = y()); } p.value && e && Me(["copy", "cut"], h, { passive: !0 }); async function v(k = _e(l)) { if (p.value && k != null) { let V = !(s.value && w(i.value)); if (!V) try { await t.clipboard.writeText(k); } catch { V = !0; } V && S(k), d.value = k, g.value = !0, f.start(); } } function S(k) { const V = document.createElement("textarea"); V.value = k ?? "", V.style.position = "absolute", V.style.opacity = "0", document.body.appendChild(V), V.select(), document.execCommand("copy"), V.remove(); } function y() { var k, V, A; return (A = (V = (k = document?.getSelection) == null ? void 0 : k.call(document)) == null ? void 0 : V.toString()) != null ? A : ""; } function w(k) { return k === "granted" || k === "prompt"; } return { isSupported: p, text: d, copied: g, copy: v }; } function wr(u) { return JSON.parse(JSON.stringify(u)); } function kr(u, t, e = {}) { const { window: l = $t, ...a } = e; let r; const s = cn(() => l && "ResizeObserver" in l), o = () => { r && (r.disconnect(), r = void 0); }, i = x(() => { const g = _e(u); return Array.isArray(g) ? g.map((f) => je(f)) : [je(g)]; }), p = W( i, (g) => { if (o(), s.value && l) { r = new ResizeObserver(t); for (const f of g) f && r.observe(f, a); } }, { immediate: !0, flush: "post" } ), d = () => { o(), p(); }; return un(d), { isSupported: s, stop: d }; } function mt(u, t = { width: 0, height: 0 }, e = {}) { const { window: l = $t, box: a = "content-box" } = e, r = x(() => { var g, f; return (f = (g = je(u)) == null ? void 0 : g.namespaceURI) == null ? void 0 : f.includes("svg"); }), s = xe(t.width), o = xe(t.height), { stop: i } = kr( u, ([g]) => { const f = a === "border-box" ? g.borderBoxSize : a === "content-box" ? g.contentBoxSize : g.devicePixelContentBoxSize; if (l && r.value) { const h = je(u); if (h) { const v = h.getBoundingClientRect(); s.value = v.width, o.value = v.height; } } else if (f) { const h = yt(f); s.value = h.reduce((v, { inlineSize: S }) => v + S, 0), o.value = h.reduce((v, { blockSize: S }) => v + S, 0); } else s.value = g.contentRect.width, o.value = g.contentRect.height; }, e ); fr(() => { const g = je(u); g && (s.value = "offsetWidth" in g ? g.offsetWidth : t.width, o.value = "offsetHeight" in g ? g.offsetHeight : t.height); }); const p = W( () => je(u), (g) => { s.value = g ? t.width : 0, o.value = g ? t.height : 0; } ); function d() { i(), p(); } return { width: s, height: o, stop: d }; } function Sr(u, t, e, l = {}) { var a, r, s; const { clone: o = !1, passive: i = !1, eventName: p, deep: d = !1, defaultValue: g, shouldEmit: f } = l, h = Kt(), v = e || h?.emit || ((a = h?.$emit) == null ? void 0 : a.bind(h)) || ((s = (r = h?.proxy) == null ? void 0 : r.$emit) == null ? void 0 : s.bind(h?.proxy)); let S = p; S = S || `update:${t.toString()}`; const y = (V) => o ? typeof o == "function" ? o(V) : wr(V) : V, w = () => ur(u[t]) ? y(u[t]) : g, k = (V) => { f ? f(V) && v(S, V) : v(S, V); }; if (i) { const V = w(), A = C(V); let $ = !1; return W( () => u[t], (I) => { $ || ($ = !0, A.value = y(I), Ve(() => $ = !1)); } ), W( A, (I) => { !$ && (I !== u[t] || d) && k(I); }, { deep: d } ), A; } else return x({ get() { return w(); }, set(V) { k(V); } }); } const xr = { class: "v-toolbar-widget__custom-size" }, Cr = /* @__PURE__ */ T({ __name: "ScreenSize", props: { modelValue: { type: Object, default: () => ({ width: 1920, height: 1080 }) } }, emits: ["update:modelValue"], setup(u, { emit: t }) { const a = Sr(u, "modelValue", t); return (r, s) => (c(), D("div", xr, [ m(n(de), { modelValue: n(a).width, "onUpdate:modelValue": s[0] || (s[0] = (o) => n(a).width = o), size: "small", class: "size-input" }, null, 8, ["modelValue"]), s[2] || (s[2] = j("div", { class: "custom-size-space" }, "X", -1)), m(n(de), { modelValue: n(a).height, "onUpdate:modelValue": s[1] || (s[1] = (o) => n(a).height = o), size: "small", class: "size-input" }, null, 8, ["modelValue"]) ])); } }), Qe = (u, t) => { const e = u.__vccOpts || u; for (const [l, a] of t) e[l] = a; return e; }, Vr = /* @__PURE__ */ Qe(Cr, [["__scopeId", "data-v-3f069bbf"]]), jr = { class: "v-toolbar-widget" }, Ar = /* @__PURE__ */ T({ name: "ToolbarWidget", inheritAttrs: !1, __name: "index", props: { preview: { type: Boolean } }, setup(u, { expose: t }) { const e = u, { forward: l, backward: a, forwardDisabled: r, backwardDisabled: s, engine: o } = pl(), i = x(() => { const { platform: f = "web" } = o.project.value || {}; return f === "web"; }), p = C("pc"), d = C(!0), g = C({ width: 1920, height: 1080 }); return W( i, (f) => { p.value = f ? "pc" : "mobile"; }, { immediate: !0 } ), t({ mode: p, outline: d, customSize: g }), (f, h) => (c(), D("div", jr, [ m(n(On), { size: "small", modelValue: p.value, "onUpdate:modelValue": h[0] || (h[0] = (v) => p.value = v) }, { default: b(() => [ m(n(ot), { label: "pc", value: "pc" }, { default: b(() => [ m(n(Pa)) ]), _: 1 }), m(n(ot), { label: "mobile", value: "mobile" }, { default: b(() => [ m(n(Ra)) ]), _: 1 }), m(n(ot), { label: "pad", value: "pad" }, { default: b(() => [ m(n(Oa)) ]), _: 1 }), m(n(ot), { label: "custom", value: "custom" }, { default: b(() => [ m(n(an)) ]), _: 1 }) ]), _: 1 }, 8, ["modelValue"]), p.value === "custom" ? (c(), _(Vr, { key: 0, modelValue: g.value, "onUpdate:modelValue": h[1] || (h[1] = (v) => g.value = v) }, null, 8, ["modelValue"])) : E("", !0), E("", !0), m(n(Tl), null, { default: b(() => [ m(n(Y), { type: "default", size: "small", onClick: n(a), disabled: n(s) || !!e.preview }, { default: b(() => [ m(n(Ba)) ]), _: 1 }, 8, ["onClick", "disabled"]), m(n(Y), { type: "default", size: "small", onClick: n(l), disabled: n(r) || !!e.preview }, { default: b(() => [ m(n(za)) ]), _: 1 }, 8, ["onClick", "disabled"]) ]), _: 1 }), m(n(Ne), { direction: "vertical" }), m(n(Yt), { class: "v-toolbar-widget__outline", size: "default", "inline-prompt": "", "active-text": "辅助线", "inactive-text": "辅助线", disabled: !!e.preview, modelValue: d.value, "onUpdate:modelValue": h[2] || (h[2] = (v) => d.value = v) }, null, 8, ["disabled", "modelValue"]) ])); } }), Er = { class: "v-actions-widget__cover" }, Dr = /* @__PURE__ */ T({ __name: "publisher", props: { id: {}, canvas: {}, name: {}, label: {}, dsl: {} }, setup(u) { const t = u, { getTemplateCategories: e, publishTemplate: l, getTemplateById: a, engine: r } = Dt(), s = nt({ name: t.name, label: t.label, share: !1 }), o = C(!1); t.id && a(t.id).then((d) => { d && Object.assign(s, { category: d.category, version: d.latest }), o.value = !!d; }); const i = x(() => t.canvas ? t.canvas.toDataURL("image/png") : null), p = async () => { if (!i.value) return await Ie.alert("截图失败,无法完成发布", { title: "提示", type: "error" }), !1; const d = Zl(i.value), { dsl: g, id: f } = t; let h; o.value && (h = await Ie.confirm( "该模板已存在,请确认您的操作是更新模板还是新建", { type: "warning", title: "提示", confirmButtonText: "更新", cancelButtonText: "新建", showClose: !1 } ).catch(() => !1) ? f : void 0); const v = r.project.value?.platform || "web", S = { id: h, dsl: JSON.stringify(g), cover: d, category: "", version: "", platform: v, ...s }, y = await l(S).catch((w) => (Oe.error({ message: w.message || w || "未知错误" }), !1)); return y && (Oe.success({ message: "发布模板成功!" }), r.skeleton?.getWidget("Templates")?.widgetRef.refreshTemplates()), !!y; }; return (d, g) => (c(), _(n($e), { width: "600px", height: "760px", icon: n(St), title: "发布到模板", model: s, "submit-method": p }, { default: b(() => [ m(n(R), { label: "截图" }, { editor: b(() => [ j("div", Er, [ m(n(Bn), { src: i.value, fit: "contain" }, null, 8, ["src"]) ]) ]), _: 1 }), m(n(R), { label: "名称", name: "name", required: "", rules: { pattern: n(Pe), message: "名称格式不正确,要求英文字母大写驼峰格式" } }, null, 8, ["rules"]), m(n(R), { label: "标题", name: "label", required: "" }), m(n(R), { label: "分类", name: "category", editor: "select", options: n(e), required: "" }, null, 8, ["options"]), m(n(R), { label: "版本号", name: "version", required: "", rules: { pattern: n(So), message: "版本号格式不正确,示例: 0.1.0" } }, null, 8, ["rules"]), m(n(R), { label: "公开", name: "share", editor: "switch", tip: "非公共的模版即仅自己可以使用, 公开模版后不允许删除", required: "" }), m(n(R), { label: "更新日志", name: "changelog", props: { type: "textarea" } }) ]), _: 1 }, 8, ["icon", "model"])); } }), Ir = /* @__PURE__ */ Qe(Dr, [["__scopeId", "data-v-0b177747"]]), $r = { class: "x-coder-result" }, Tr = ["href"], Pr = /* @__PURE__ */ T({ __name: "coder", props: { link: {} }, setup(u) { return (t, e) => (c(), D("div", $r, [ e[0] || (e[0] = j("div", null, "已生成源码项目,可通过以下链接下载(两小时内有效)。", -1)), j("div", null, [ j("a", { href: t.link, target: "_blank" }, U(t.link), 9, Tr) ]) ])); } }), Rr = { class: "v-actions-widget" }, Or = /* @__PURE__ */ T({ name: "ActionsWidget", inheritAttrs: !1, __name: "index", props: { onlyPublishTemplate: { type: Boolean, default: !1 }, coder: { type: Boolean, default: !1 } }, setup(u) { const t = u, { engine: e, designer: l } = Ae(), { isLogined: a, toRemoteAuth: r } = Dt(), s = C(!1), o = C(!1), i = C(), p = () => { e.current.value ? (s.value ? e.skeleton?.getWidget("Previewer")?.widgetRef.refresh() : (l.value?.setSelected(null), e.simulator.refresh()), me("刷新完成", "success")) : me("请先打开文件", "warning"); }, d = async () => { e.current.value ? (s.value && (e.skeleton?.closePreview(), s.value = !1, await ut(1e3)), l.value?.setSelected(e.current.value)) : me("请先打开文件", "warning"); }, g = () => { if (e.project.value) if (e.current.value) { if (s.value) { e.skeleton?.closePreview(), s.value = !1; return; } e.skeleton?.openPreview(""), s.value = !0; } else me("请先打开文件", "warning"); }, f = () => { const y = e.project.value; y && (y.currentFile ? y.publish(y.currentFile) : me("请先打开文件", "warning")); }, h = async () => { const y = e.project.value; if (y) if (y.currentFile) if (await a()) { const w = await e.simulator.capture(), { name: k, title: V, market: A } = y.currentFile; if (!w) { me("截图失败", "warning"); return; } i.value = { id: A?.id, canvas: w, name: k, label: V, dsl: e.current.value?.toDsl() }, o.value = !0; } else await Ie.confirm( "发布到模板需登录系统,您还没登录或登录已过期,请重新登录!", "提示", { type: "info", confirmButtonText: "立即登录" } ).catch(() => !1) && r(); else me("请先打开文件", "warning"); }, v = (y) => { const w = e.project.value; if (w) switch (y) { case "current": f(); break; case "project": w.publish(); break; case "template": h(); break; } }, S = async () => { if (!e.project.value) return; const w = await e.genSource(); w && Wn({ width: "600px", height: "200px", title: "出码", icon: Wt,