diygw-designer 1.4.3 → 1.5.1
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/miniapp-designer/src/MiniProgramDesigner.vue.cjs +1 -1
- package/dist/miniapp-designer/src/MiniProgramDesigner.vue.js +47 -26
- package/dist/ui-kit/panel-ui/src/activitybars/pageManager/usePageManagerSingleton.cjs +1 -1
- package/dist/ui-kit/panel-ui/src/activitybars/pageManager/usePageManagerSingleton.js +135 -131
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const t=require("vue");;/* empty css */;/* empty css */;/* empty css */;/* empty css */;/* empty css */const u=require("../../manager/src/pluginManager.cjs");require("jsep");require("@vueuse/core");require("../../hooks/src/store/index.cjs");;/* empty css */require("vue-draggable-plus");;/* empty css */require("element-plus");;/* empty css */;/* empty css */;/* empty css */const i=require("../../ui-kit/panel-ui/src/activitybars/pageManager/storage.cjs");require("../../ui-kit/panel-ui/src/activitybars/pageManager/pageDraftBootstrap.cjs");require("../../core/src/components/builder/hooks/usePageDataSources.cjs");const f=require("../../core/src/components/designer/src/designer.vue.cjs"),S=require("../../ui/elementPlus/src/index.cjs"),h=require("./setupMiniProgramDesigner.cjs"),q={key:0},P=t.defineComponent({__name:"MiniProgramDesigner",props:{multiPage:{type:Boolean,default:!0},projectId:{},pageStorageHttp:{},pageStorageNamespace:{},syncProjectKeyFromUrl:{type:Boolean,default:!0},initialPageSchema:{},title:{default:"小程序设计页面"},headerPrefix:{},onSaveSchema:{}},emits:["save"],setup(o,{emit:s}){const e=o,g=s,n=t.computed(()=>e.headerPrefix===void 0?"小程序":e.headerPrefix),p=t.computed(()=>{var r;return!(e.multiPage===!1&&((r=e.projectId)!=null&&r.trim()))});function c(){var r;e.pageStorageHttp?i.configurePageStorage({adapter:i.createHttpStorageAdapter(e.pageStorageHttp),projectKey:e.projectId}):e.pageStorageNamespace?i.configurePageStorage({namespace:e.pageStorageNamespace,projectKey:e.projectId}):(r=e.projectId)!=null&&r.trim()?i.configurePageStorage({projectKey:e.projectId}):e.syncProjectKeyFromUrl&&i.syncPageStorageNamespaceFromLocation()}c(),t.watch([()=>e.pageStorageHttp,()=>e.pageStorageNamespace,()=>e.projectId,()=>e.syncProjectKeyFromUrl],()=>{c()},{deep:!0,immediate:!0}),S.setupElementPlus(u.pluginManager);const{defaultSchema:l}=h.setupMiniProgramDesigner(u.pluginManager),m=t.computed(()=>{var a;const r=e.initialPageSchema;return(a=r==null?void 0:r.schemas)!=null&&a.length?JSON.parse(JSON.stringify(r)):{schemas:[JSON.parse(JSON.stringify(l))]}});async function d(r){var a;await i.flushPageStorage(),await((a=e.onSaveSchema)==null?void 0:a.call(e,r)),g("save",r)}return(r,a)=>(t.openBlock(),t.createBlock(t.unref(f),{"canvas-mode":"mobile","form-mode":"","lock-default-schema-edit":"","default-schema":m.value,"enable-page-manager":o.multiPage,"page-tree-persistence":p.value,title:o.title,onSave:d},{"header-prefix":t.withCtx(()=>[t.renderSlot(r.$slots,"header-prefix",{},()=>[n.value?(t.openBlock(),t.createElementBlock("div",q,t.toDisplayString(n.value),1)):t.createCommentVNode("",!0)])]),_:3},8,["default-schema","enable-page-manager","page-tree-persistence","title"]))}});module.exports=P;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineComponent as S, computed as o,
|
|
1
|
+
import { defineComponent as S, computed as o, watch as h, createBlock as P, openBlock as c, unref as y, withCtx as j, renderSlot as v, createElementBlock as N, createCommentVNode as x, toDisplayString as I } from "vue";
|
|
2
2
|
/* empty css */
|
|
3
3
|
/* empty css */
|
|
4
4
|
/* empty css */
|
|
5
5
|
/* empty css */
|
|
6
6
|
/* empty css */
|
|
7
|
-
import { pluginManager as
|
|
7
|
+
import { pluginManager as n } from "../../manager/src/pluginManager.js";
|
|
8
8
|
import "jsep";
|
|
9
9
|
import "@vueuse/core";
|
|
10
10
|
import "../../hooks/src/store/index.js";
|
|
@@ -15,13 +15,13 @@ import "element-plus";
|
|
|
15
15
|
/* empty css */
|
|
16
16
|
/* empty css */
|
|
17
17
|
/* empty css */
|
|
18
|
-
import { configurePageStorage as i, createHttpStorageAdapter as B, syncPageStorageNamespaceFromLocation as
|
|
18
|
+
import { configurePageStorage as i, createHttpStorageAdapter as B, syncPageStorageNamespaceFromLocation as K, flushPageStorage as _ } from "../../ui-kit/panel-ui/src/activitybars/pageManager/storage.js";
|
|
19
19
|
import "../../ui-kit/panel-ui/src/activitybars/pageManager/pageDraftBootstrap.js";
|
|
20
20
|
import "../../core/src/components/builder/hooks/usePageDataSources.js";
|
|
21
|
-
import
|
|
22
|
-
import { setupElementPlus as
|
|
23
|
-
import { setupMiniProgramDesigner as
|
|
24
|
-
const
|
|
21
|
+
import k from "../../core/src/components/designer/src/designer.vue.js";
|
|
22
|
+
import { setupElementPlus as H } from "../../ui/elementPlus/src/index.js";
|
|
23
|
+
import { setupMiniProgramDesigner as w } from "./setupMiniProgramDesigner.js";
|
|
24
|
+
const C = { key: 0 }, te = /* @__PURE__ */ S({
|
|
25
25
|
__name: "MiniProgramDesigner",
|
|
26
26
|
props: {
|
|
27
27
|
multiPage: { type: Boolean, default: !0 },
|
|
@@ -36,8 +36,7 @@ const O = { key: 0 }, ee = /* @__PURE__ */ S({
|
|
|
36
36
|
},
|
|
37
37
|
emits: ["save"],
|
|
38
38
|
setup(r, { emit: s }) {
|
|
39
|
-
|
|
40
|
-
const e = r, m = o(
|
|
39
|
+
const e = r, g = s, m = o(
|
|
41
40
|
() => e.headerPrefix === void 0 ? "小程序" : e.headerPrefix
|
|
42
41
|
), l = o(
|
|
43
42
|
() => {
|
|
@@ -45,35 +44,57 @@ const O = { key: 0 }, ee = /* @__PURE__ */ S({
|
|
|
45
44
|
return !(e.multiPage === !1 && ((t = e.projectId) != null && t.trim()));
|
|
46
45
|
}
|
|
47
46
|
);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
function p() {
|
|
48
|
+
var t;
|
|
49
|
+
e.pageStorageHttp ? i({
|
|
50
|
+
adapter: B(e.pageStorageHttp),
|
|
51
|
+
projectKey: e.projectId
|
|
52
|
+
}) : e.pageStorageNamespace ? i({
|
|
53
|
+
namespace: e.pageStorageNamespace,
|
|
54
|
+
projectKey: e.projectId
|
|
55
|
+
}) : (t = e.projectId) != null && t.trim() ? i({
|
|
56
|
+
projectKey: e.projectId
|
|
57
|
+
}) : e.syncProjectKeyFromUrl && K();
|
|
58
|
+
}
|
|
59
|
+
p(), h(
|
|
60
|
+
[
|
|
61
|
+
() => e.pageStorageHttp,
|
|
62
|
+
() => e.pageStorageNamespace,
|
|
63
|
+
() => e.projectId,
|
|
64
|
+
() => e.syncProjectKeyFromUrl
|
|
65
|
+
],
|
|
66
|
+
() => {
|
|
67
|
+
p();
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
deep: !0,
|
|
71
|
+
immediate: !0
|
|
72
|
+
}
|
|
73
|
+
), H(n);
|
|
74
|
+
const { defaultSchema: f } = w(n), d = o(() => {
|
|
54
75
|
var a;
|
|
55
76
|
const t = e.initialPageSchema;
|
|
56
77
|
return (a = t == null ? void 0 : t.schemas) != null && a.length ? JSON.parse(JSON.stringify(t)) : {
|
|
57
|
-
schemas: [JSON.parse(JSON.stringify(
|
|
78
|
+
schemas: [JSON.parse(JSON.stringify(f))]
|
|
58
79
|
};
|
|
59
|
-
})
|
|
60
|
-
async function
|
|
80
|
+
});
|
|
81
|
+
async function u(t) {
|
|
61
82
|
var a;
|
|
62
|
-
await
|
|
83
|
+
await _(), await ((a = e.onSaveSchema) == null ? void 0 : a.call(e, t)), g("save", t);
|
|
63
84
|
}
|
|
64
|
-
return (t, a) => (
|
|
85
|
+
return (t, a) => (c(), P(y(k), {
|
|
65
86
|
"canvas-mode": "mobile",
|
|
66
87
|
"form-mode": "",
|
|
67
88
|
"lock-default-schema-edit": "",
|
|
68
|
-
"default-schema":
|
|
89
|
+
"default-schema": d.value,
|
|
69
90
|
"enable-page-manager": r.multiPage,
|
|
70
91
|
"page-tree-persistence": l.value,
|
|
71
92
|
title: r.title,
|
|
72
|
-
onSave:
|
|
93
|
+
onSave: u
|
|
73
94
|
}, {
|
|
74
|
-
"header-prefix":
|
|
75
|
-
|
|
76
|
-
m.value ? (
|
|
95
|
+
"header-prefix": j(() => [
|
|
96
|
+
v(t.$slots, "header-prefix", {}, () => [
|
|
97
|
+
m.value ? (c(), N("div", C, I(m.value), 1)) : x("", !0)
|
|
77
98
|
])
|
|
78
99
|
]),
|
|
79
100
|
_: 3
|
|
@@ -81,5 +102,5 @@ const O = { key: 0 }, ee = /* @__PURE__ */ S({
|
|
|
81
102
|
}
|
|
82
103
|
});
|
|
83
104
|
export {
|
|
84
|
-
|
|
105
|
+
te as default
|
|
85
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),_=require("element-plus");;/* empty css */;/* empty css */;/* empty css */const pe=require("../../../../../manager/src/pluginManager.cjs");;/* empty css */require("vue-draggable-plus");const c=require("../../../../../utils/src/common/data.cjs");require("jsep");require("@vueuse/core");require("../../../../../hooks/src/store/index.cjs");const X=require("../../../../../hooks/src/designer/useDesignerContext.cjs"),Q=require("../../../../../hooks/src/plugin/usePageSchema.cjs"),z=require("./pageDraftBootstrap.cjs"),H=require("./storage.cjs"),j="__DIYGW_PAGE_MANAGER_RUNTIME__";function ve(){const g=window;return g[j]||(g[j]={currentPageId:""}),g[j]}const V=new WeakMap;function he(){const g=X.useDesignerContext(),s=g.pageSchema,v=g.revoke,p=()=>H.getPageStorageAdapter(),A=ve(),u=o.ref([]),S=o.ref(""),d=o.ref(A.currentPageId||""),w=o.ref(""),Z=o.ref(),N=o.ref(!1);let P=null,D=Promise.resolve();const B=()=>H.getPageDraftStorageKey(),C=o.ref(!1),E=o.ref(!1),M=o.ref("page"),h=o.ref(null),I=o.ref(""),ee={children:"children",label:"name"},L=o.ref(null);function q(){try{const e=localStorage.getItem(B());if(!e)return null;const t=JSON.parse(e);return!t||!Array.isArray(t.tree)?null:{currentPageId:String(t.currentPageId??""),pages:t.pages??{},scripts:t.scripts&&typeof t.scripts=="object"?t.scripts:void 0,tree:t.tree,updatedAt:Number(t.updatedAt??Date.now())}}catch{return null}}function $(e){localStorage.setItem(B(),JSON.stringify(c.deepClone(e)))}function K(e,t,a){const n=q();$({currentPageId:d.value,pages:t??(n==null?void 0:n.pages)??{},scripts:a??(n==null?void 0:n.scripts)??{},tree:c.deepClone(e),updatedAt:Date.now()})}function te(e,t){const a=q(),n={...(a==null?void 0:a.pages)??{},[e]:c.deepClone(t)},r={...(a==null?void 0:a.scripts)??{},[e]:s.script??""};$({currentPageId:d.value||e,pages:n,scripts:r,tree:c.deepClone((a==null?void 0:a.tree)??u.value),updatedAt:Date.now()})}function b(e){return`${e}_${Date.now()}_${Math.random().toString(36).slice(2,7)}`}function x(e,t,a=null){e.forEach((n,r)=>{var i;t(n,a,r),(i=n.children)!=null&&i.length&&x(n.children,t,n)})}function O(e){let t=null;return x(u.value,(a,n)=>{!t&&a.id===e&&(t={node:a,parent:n})}),t}function R(e){var a;if(e.type==="page")return[e.id];const t=[];return(a=e.children)==null||a.forEach(n=>{t.push(...R(n))}),t}function k(e){let t="";const a=n=>{var r;for(const i of n){if(i.type==="page"){t=i.id;return}if((r=i.children)!=null&&r.length&&(a(i.children),t))return}};return a(e),t}function F(e,t){if(!e)return!1;let a=!1;return x(t,n=>{n.type==="page"&&n.id===e&&(a=!0)}),a}function J(e){var r;const t=L.value??c.deepClone((r=pe.pluginManager.component.getConfigByType("page"))==null?void 0:r.defaultSchema),a=c.generateNewSchema(c.deepClone(t),[]),n=e.trim()||a.label||"新页面";return G(a,n),a}function G(e,t){var n;e.label=t,e.props={...e.props??{},name:t,title:t};const a=(n=e.children)==null?void 0:n[0];a!=null&&a.props&&Object.prototype.hasOwnProperty.call(a.props,"text")&&(a.props.text=t)}async function m(){await p().saveTree(c.deepClone(u.value)),await K(u.value)}async function T(){if(N.value||!d.value||!s.schemas[0])return;const e=d.value,t=c.deepClone(s.schemas[0]);D=D.then(async()=>{await p().savePage(e,t),await te(e,t)}),await D}function U(){P&&clearTimeout(P),P=setTimeout(()=>{P=null,T()},180)}async function W(){P?(clearTimeout(P),P=null,await T()):await D}async function y(e,t=!1){if(d.value===e&&s.schemas[0]){S.value=e,w.value=e;return}t||(await W(),await T()),N.value=!0;try{let a=await p().loadPage(e);a||(a=J("新页面"),await p().savePage(e,a)),d.value=e,s.schemas=[c.deepClone(a)];const n=q();s.script=n!=null&&n.scripts&&Object.prototype.hasOwnProperty.call(n.scripts,e)?n.scripts[e]:Q.INITIAL_PAGE_SCRIPT,S.value=e,w.value=e,await o.nextTick(),g.setSelectedNode(s.schemas[0])}finally{N.value=!1}}async function ae(){var n;await z.awaitPageDraftBootstrap(),L.value=c.deepClone(s.schemas[0]);const e=z.takeRestoredDraftPayload();if(e){const{currentPageId:r,draft:i}=e;u.value=c.deepClone(i.tree);const l=(r&&F(r,u.value)?r:k(u.value))||"";if(l){d.value=l,A.currentPageId=l;const f=i.pages[l];f?(s.schemas=[c.deepClone(f)],s.script=i.scripts&&Object.prototype.hasOwnProperty.call(i.scripts,l)?i.scripts[l]:Q.INITIAL_PAGE_SCRIPT,S.value=l,w.value=l,await o.nextTick(),g.setSelectedNode(s.schemas[0])):await y(l,!0)}await K(u.value,c.deepClone(i.pages),c.deepClone(i.scripts??{}));return}const t=await p().loadTree();if(!t||!t.length){const r=c.deepClone(s.schemas[0]),i=r.id||b("page"),l=((n=r.props)==null?void 0:n.name)||r.label||"首页";u.value=[{id:i,name:l,type:"page"}],await p().savePage(i,r),await m(),await y(i,!0);return}if(u.value=t,d.value&&s.schemas[0]&&await T(),F(d.value,u.value)&&s.schemas[0]){S.value=d.value,w.value=d.value;return}const a=k(u.value);if(!a){_.ElMessage.warning("页面树中没有页面节点,请先新增页面");return}await y(a,!0)}function ne(e){w.value=e.id,e.type==="page"&&y(e.id)}function re(e){var a,n;if(!e)return u.value;const t=(a=O(e))==null?void 0:a.node;if(!t)return u.value;if(t.type==="page"){const r=(n=O(e))==null?void 0:n.parent;return(r==null?void 0:r.children)??u.value}return t.children??(t.children=[]),t.children}function ie(e){M.value=e,I.value="",C.value=!0}async function se(){const e=I.value.trim();if(!e){_.ElMessage.warning("请输入名称");return}const t=w.value||null,a=re(t);if(M.value==="folder"){a.push({id:b("folder"),name:e,type:"folder",children:[]}),await m(),C.value=!1,v.push("新增目录",!0);return}const n=b("page");a.push({id:n,name:e,type:"page"});const r=J(e);await p().savePage(n,r),await m(),C.value=!1,await y(n),v.push("新增页面",!0)}function ue(e){h.value=e,I.value=e.name,E.value=!0}async function le(){if(!h.value)return;const e=I.value.trim();if(!e){_.ElMessage.warning("请输入名称");return}if(h.value.name=e,h.value.type==="page")if(d.value===h.value.id&&s.schemas[0])G(s.schemas[0],e),await T();else{const t=await p().loadPage(h.value.id);t&&(G(t,e),await p().savePage(h.value.id,t))}await m(),E.value=!1,v.push("修改节点名称",!0)}async function oe(e){var l;const t=O(e.id);if(!t)return;const a=R(t.node),n=R({id:"root",type:"folder",children:u.value});if(a.length&&a.length===n.length){_.ElMessage.warning("至少保留一个页面");return}const r=((l=t.parent)==null?void 0:l.children)??u.value,i=r.findIndex(f=>f.id===e.id);i>=0&&r.splice(i,1);for(const f of a)await p().deletePage(f);if(await m(),a.includes(d.value)){const f=k(u.value);f&&await y(f,!0)}v.push("删除节点",!0)}function ce(e,t,a){var i,l,f,Y;const n=e.data.type,r=t.data.type;if(n==="folder"){if(a==="inner")return r==="folder";if(r!=="folder")return!1;const fe=((l=(i=e.parent)==null?void 0:i.data)==null?void 0:l.id)??"__root__",ge=((Y=(f=t.parent)==null?void 0:f.data)==null?void 0:Y.id)??"__root__";return fe===ge}return a==="inner"?r==="folder":!0}async function de(){await W(),await m(),v.push("树结构拖动",!0)}return o.watch(()=>s.schemas,()=>{U()},{deep:!0}),o.watch(()=>s.script,()=>{U()}),o.watch(d,e=>{A.currentPageId=e}),ae(),{activePageId:S,addType:M,allowDrop:ce,currentPageId:d,editTarget:h,handleAdd:se,handleDelete:oe,handleEdit:le,handleNodeClick:ne,handleNodeDrop:de,inputName:I,openAddDialog:ie,openEditDialog:ue,selectedNodeId:w,showAddDialog:C,showEditDialog:E,treeData:u,treeProps:ee,treeRef:Z}}function we(){const g=X.useDesignerContext(),s=V.get(g);if(s)return s;const v=he();return V.set(g,v),v}exports.usePageManagerSingleton=we;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { ref as d, watch as B, nextTick as
|
|
1
|
+
import { ref as d, watch as B, nextTick as z } from "vue";
|
|
2
2
|
import { ElMessage as A } from "element-plus";
|
|
3
3
|
/* empty css */
|
|
4
4
|
/* empty css */
|
|
5
5
|
/* empty css */
|
|
6
|
-
import { pluginManager as
|
|
6
|
+
import { pluginManager as ge } from "../../../../../manager/src/pluginManager.js";
|
|
7
7
|
/* empty css */
|
|
8
8
|
import "vue-draggable-plus";
|
|
9
|
-
import { deepClone as
|
|
9
|
+
import { deepClone as l, generateNewSchema as ve } from "../../../../../utils/src/common/data.js";
|
|
10
10
|
import "jsep";
|
|
11
11
|
import "@vueuse/core";
|
|
12
12
|
import "../../../../../hooks/src/store/index.js";
|
|
13
|
-
import { useDesignerContext as
|
|
14
|
-
import { INITIAL_PAGE_SCRIPT as
|
|
13
|
+
import { useDesignerContext as X } from "../../../../../hooks/src/designer/useDesignerContext.js";
|
|
14
|
+
import { INITIAL_PAGE_SCRIPT as H } from "../../../../../hooks/src/plugin/usePageSchema.js";
|
|
15
15
|
import { awaitPageDraftBootstrap as me, takeRestoredDraftPayload as he } from "./pageDraftBootstrap.js";
|
|
16
16
|
import { getPageStorageAdapter as we, getPageDraftStorageKey as Pe } from "./storage.js";
|
|
17
17
|
const K = "__DIYGW_PAGE_MANAGER_RUNTIME__";
|
|
18
18
|
function ye() {
|
|
19
|
-
const
|
|
20
|
-
return
|
|
19
|
+
const p = window;
|
|
20
|
+
return p[K] || (p[K] = {
|
|
21
21
|
currentPageId: ""
|
|
22
|
-
}),
|
|
22
|
+
}), p[K];
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
const V = /* @__PURE__ */ new WeakMap();
|
|
25
25
|
function Se() {
|
|
26
|
-
const
|
|
27
|
-
let
|
|
28
|
-
const
|
|
26
|
+
const p = X(), s = p.pageSchema, v = p.revoke, g = () => we(), N = ye(), o = d([]), S = d(""), u = d(N.currentPageId || ""), h = d(""), Z = d(), E = d(!1);
|
|
27
|
+
let w = null, D = Promise.resolve();
|
|
28
|
+
const L = () => Pe(), _ = d(!1), b = d(!1), x = d("page"), m = d(null), I = d(""), ee = {
|
|
29
29
|
children: "children",
|
|
30
30
|
label: "name"
|
|
31
|
-
},
|
|
31
|
+
}, $ = d(null);
|
|
32
32
|
function M() {
|
|
33
33
|
try {
|
|
34
|
-
const e = localStorage.getItem(
|
|
34
|
+
const e = localStorage.getItem(L());
|
|
35
35
|
if (!e) return null;
|
|
36
36
|
const t = JSON.parse(e);
|
|
37
37
|
return !t || !Array.isArray(t.tree) ? null : {
|
|
@@ -45,32 +45,32 @@ function Se() {
|
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
localStorage.setItem(
|
|
48
|
+
function F(e) {
|
|
49
|
+
localStorage.setItem(L(), JSON.stringify(l(e)));
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function J(e, t, a) {
|
|
52
52
|
const r = M();
|
|
53
|
-
|
|
53
|
+
F({
|
|
54
54
|
currentPageId: u.value,
|
|
55
55
|
pages: t ?? (r == null ? void 0 : r.pages) ?? {},
|
|
56
56
|
scripts: a ?? (r == null ? void 0 : r.scripts) ?? {},
|
|
57
|
-
tree:
|
|
57
|
+
tree: l(e),
|
|
58
58
|
updatedAt: Date.now()
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function te(e, t) {
|
|
62
62
|
const a = M(), r = {
|
|
63
63
|
...(a == null ? void 0 : a.pages) ?? {},
|
|
64
|
-
[e]:
|
|
64
|
+
[e]: l(t)
|
|
65
65
|
}, n = {
|
|
66
66
|
...(a == null ? void 0 : a.scripts) ?? {},
|
|
67
|
-
[e]:
|
|
67
|
+
[e]: s.script ?? ""
|
|
68
68
|
};
|
|
69
|
-
|
|
69
|
+
F({
|
|
70
70
|
currentPageId: u.value || e,
|
|
71
71
|
pages: r,
|
|
72
72
|
scripts: n,
|
|
73
|
-
tree:
|
|
73
|
+
tree: l((a == null ? void 0 : a.tree) ?? o.value),
|
|
74
74
|
updatedAt: Date.now()
|
|
75
75
|
});
|
|
76
76
|
}
|
|
@@ -83,18 +83,18 @@ function Se() {
|
|
|
83
83
|
t(r, a, n), (i = r.children) != null && i.length && R(r.children, t, r);
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function k(e) {
|
|
87
87
|
let t = null;
|
|
88
|
-
return R(
|
|
88
|
+
return R(o.value, (a, r) => {
|
|
89
89
|
!t && a.id === e && (t = { node: a, parent: r });
|
|
90
90
|
}), t;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function C(e) {
|
|
93
93
|
var a;
|
|
94
94
|
if (e.type === "page") return [e.id];
|
|
95
95
|
const t = [];
|
|
96
96
|
return (a = e.children) == null || a.forEach((r) => {
|
|
97
|
-
t.push(...
|
|
97
|
+
t.push(...C(r));
|
|
98
98
|
}), t;
|
|
99
99
|
}
|
|
100
100
|
function G(e) {
|
|
@@ -112,18 +112,18 @@ function Se() {
|
|
|
112
112
|
};
|
|
113
113
|
return a(e), t;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function U(e, t) {
|
|
116
116
|
if (!e) return !1;
|
|
117
117
|
let a = !1;
|
|
118
118
|
return R(t, (r) => {
|
|
119
119
|
r.type === "page" && r.id === e && (a = !0);
|
|
120
120
|
}), a;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function W(e) {
|
|
123
123
|
var n;
|
|
124
|
-
const t =
|
|
125
|
-
(n =
|
|
126
|
-
), a =
|
|
124
|
+
const t = $.value ?? l(
|
|
125
|
+
(n = ge.component.getConfigByType("page")) == null ? void 0 : n.defaultSchema
|
|
126
|
+
), a = ve(l(t), []), r = e.trim() || a.label || "新页面";
|
|
127
127
|
return j(a, r), a;
|
|
128
128
|
}
|
|
129
129
|
function j(e, t) {
|
|
@@ -136,114 +136,114 @@ function Se() {
|
|
|
136
136
|
const a = (r = e.children) == null ? void 0 : r[0];
|
|
137
137
|
a != null && a.props && Object.prototype.hasOwnProperty.call(a.props, "text") && (a.props.text = t);
|
|
138
138
|
}
|
|
139
|
-
async function
|
|
140
|
-
await
|
|
139
|
+
async function P() {
|
|
140
|
+
await g().saveTree(l(o.value)), await J(o.value);
|
|
141
141
|
}
|
|
142
142
|
async function T() {
|
|
143
|
-
if (E.value || !u.value || !
|
|
143
|
+
if (E.value || !u.value || !s.schemas[0])
|
|
144
144
|
return;
|
|
145
|
-
const e = u.value, t =
|
|
145
|
+
const e = u.value, t = l(s.schemas[0]);
|
|
146
146
|
D = D.then(async () => {
|
|
147
|
-
await
|
|
147
|
+
await g().savePage(e, t), await te(e, t);
|
|
148
148
|
}), await D;
|
|
149
149
|
}
|
|
150
|
-
function
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
function Y() {
|
|
151
|
+
w && clearTimeout(w), w = setTimeout(() => {
|
|
152
|
+
w = null, T();
|
|
153
153
|
}, 180);
|
|
154
154
|
}
|
|
155
|
-
async function
|
|
156
|
-
|
|
155
|
+
async function Q() {
|
|
156
|
+
w ? (clearTimeout(w), w = null, await T()) : await D;
|
|
157
157
|
}
|
|
158
|
-
async function
|
|
159
|
-
if (u.value === e &&
|
|
160
|
-
S.value = e,
|
|
158
|
+
async function y(e, t = !1) {
|
|
159
|
+
if (u.value === e && s.schemas[0]) {
|
|
160
|
+
S.value = e, h.value = e;
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
|
-
t || (await
|
|
163
|
+
t || (await Q(), await T()), E.value = !0;
|
|
164
164
|
try {
|
|
165
|
-
let a = await
|
|
166
|
-
a || (a =
|
|
165
|
+
let a = await g().loadPage(e);
|
|
166
|
+
a || (a = W("新页面"), await g().savePage(e, a)), u.value = e, s.schemas = [l(a)];
|
|
167
167
|
const r = M();
|
|
168
|
-
|
|
168
|
+
s.script = r != null && r.scripts && Object.prototype.hasOwnProperty.call(r.scripts, e) ? r.scripts[e] : H, S.value = e, h.value = e, await z(), p.setSelectedNode(s.schemas[0]);
|
|
169
169
|
} finally {
|
|
170
170
|
E.value = !1;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
async function
|
|
173
|
+
async function ae() {
|
|
174
174
|
var r;
|
|
175
|
-
await me(),
|
|
175
|
+
await me(), $.value = l(s.schemas[0]);
|
|
176
176
|
const e = he();
|
|
177
177
|
if (e) {
|
|
178
178
|
const { currentPageId: n, draft: i } = e;
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
if (
|
|
182
|
-
u.value =
|
|
183
|
-
const f = i.pages[
|
|
184
|
-
f ? (
|
|
179
|
+
o.value = l(i.tree);
|
|
180
|
+
const c = (n && U(n, o.value) ? n : G(o.value)) || "";
|
|
181
|
+
if (c) {
|
|
182
|
+
u.value = c, N.currentPageId = c;
|
|
183
|
+
const f = i.pages[c];
|
|
184
|
+
f ? (s.schemas = [l(f)], s.script = i.scripts && Object.prototype.hasOwnProperty.call(i.scripts, c) ? i.scripts[c] : H, S.value = c, h.value = c, await z(), p.setSelectedNode(s.schemas[0])) : await y(c, !0);
|
|
185
185
|
}
|
|
186
|
-
await
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
await J(
|
|
187
|
+
o.value,
|
|
188
|
+
l(i.pages),
|
|
189
|
+
l(i.scripts ?? {})
|
|
190
190
|
);
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
|
-
const t = await
|
|
193
|
+
const t = await g().loadTree();
|
|
194
194
|
if (!t || !t.length) {
|
|
195
|
-
const n =
|
|
196
|
-
|
|
195
|
+
const n = l(s.schemas[0]), i = n.id || O("page"), c = ((r = n.props) == null ? void 0 : r.name) || n.label || "首页";
|
|
196
|
+
o.value = [
|
|
197
197
|
{
|
|
198
198
|
id: i,
|
|
199
|
-
name:
|
|
199
|
+
name: c,
|
|
200
200
|
type: "page"
|
|
201
201
|
}
|
|
202
|
-
], await
|
|
202
|
+
], await g().savePage(i, n), await P(), await y(i, !0);
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
|
-
if (
|
|
206
|
-
S.value = u.value,
|
|
205
|
+
if (o.value = t, u.value && s.schemas[0] && await T(), U(u.value, o.value) && s.schemas[0]) {
|
|
206
|
+
S.value = u.value, h.value = u.value;
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
|
-
const a = G(
|
|
209
|
+
const a = G(o.value);
|
|
210
210
|
if (!a) {
|
|
211
211
|
A.warning("页面树中没有页面节点,请先新增页面");
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
|
-
await
|
|
215
|
-
}
|
|
216
|
-
function ae(e) {
|
|
217
|
-
m.value = e.id, e.type === "page" && P(e.id);
|
|
214
|
+
await y(a, !0);
|
|
218
215
|
}
|
|
219
216
|
function re(e) {
|
|
217
|
+
h.value = e.id, e.type === "page" && y(e.id);
|
|
218
|
+
}
|
|
219
|
+
function ne(e) {
|
|
220
220
|
var a, r;
|
|
221
|
-
if (!e) return
|
|
222
|
-
const t = (a =
|
|
223
|
-
if (!t) return
|
|
221
|
+
if (!e) return o.value;
|
|
222
|
+
const t = (a = k(e)) == null ? void 0 : a.node;
|
|
223
|
+
if (!t) return o.value;
|
|
224
224
|
if (t.type === "page") {
|
|
225
|
-
const n = (r =
|
|
226
|
-
return (n == null ? void 0 : n.children) ??
|
|
225
|
+
const n = (r = k(e)) == null ? void 0 : r.parent;
|
|
226
|
+
return (n == null ? void 0 : n.children) ?? o.value;
|
|
227
227
|
}
|
|
228
228
|
return t.children ?? (t.children = []), t.children;
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function ie(e) {
|
|
231
231
|
x.value = e, I.value = "", _.value = !0;
|
|
232
232
|
}
|
|
233
|
-
async function
|
|
233
|
+
async function se() {
|
|
234
234
|
const e = I.value.trim();
|
|
235
235
|
if (!e) {
|
|
236
236
|
A.warning("请输入名称");
|
|
237
237
|
return;
|
|
238
238
|
}
|
|
239
|
-
const t =
|
|
239
|
+
const t = h.value || null, a = ne(t);
|
|
240
240
|
if (x.value === "folder") {
|
|
241
241
|
a.push({
|
|
242
242
|
id: O("folder"),
|
|
243
243
|
name: e,
|
|
244
244
|
type: "folder",
|
|
245
245
|
children: []
|
|
246
|
-
}), await
|
|
246
|
+
}), await P(), _.value = !1, v.push("新增目录", !0);
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
249
|
const r = O("page");
|
|
@@ -252,104 +252,108 @@ function Se() {
|
|
|
252
252
|
name: e,
|
|
253
253
|
type: "page"
|
|
254
254
|
});
|
|
255
|
-
const n =
|
|
256
|
-
await
|
|
255
|
+
const n = W(e);
|
|
256
|
+
await g().savePage(r, n), await P(), _.value = !1, await y(r), v.push("新增页面", !0);
|
|
257
257
|
}
|
|
258
|
-
function
|
|
259
|
-
|
|
258
|
+
function oe(e) {
|
|
259
|
+
m.value = e, I.value = e.name, b.value = !0;
|
|
260
260
|
}
|
|
261
|
-
async function
|
|
262
|
-
if (!
|
|
261
|
+
async function ce() {
|
|
262
|
+
if (!m.value) return;
|
|
263
263
|
const e = I.value.trim();
|
|
264
264
|
if (!e) {
|
|
265
265
|
A.warning("请输入名称");
|
|
266
266
|
return;
|
|
267
267
|
}
|
|
268
|
-
if (
|
|
269
|
-
if (u.value ===
|
|
270
|
-
j(
|
|
268
|
+
if (m.value.name = e, m.value.type === "page")
|
|
269
|
+
if (u.value === m.value.id && s.schemas[0])
|
|
270
|
+
j(s.schemas[0], e), await T();
|
|
271
271
|
else {
|
|
272
|
-
const t = await
|
|
273
|
-
t && (j(t, e), await
|
|
272
|
+
const t = await g().loadPage(m.value.id);
|
|
273
|
+
t && (j(t, e), await g().savePage(m.value.id, t));
|
|
274
274
|
}
|
|
275
|
-
await
|
|
275
|
+
await P(), b.value = !1, v.push("修改节点名称", !0);
|
|
276
276
|
}
|
|
277
|
-
async function
|
|
278
|
-
var
|
|
279
|
-
const t =
|
|
277
|
+
async function ue(e) {
|
|
278
|
+
var c;
|
|
279
|
+
const t = k(e.id);
|
|
280
280
|
if (!t) return;
|
|
281
|
-
const a =
|
|
281
|
+
const a = C(t.node), r = C({
|
|
282
282
|
id: "root",
|
|
283
283
|
type: "folder",
|
|
284
|
-
children:
|
|
284
|
+
children: o.value
|
|
285
285
|
});
|
|
286
286
|
if (a.length && a.length === r.length) {
|
|
287
287
|
A.warning("至少保留一个页面");
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
|
-
const n = ((
|
|
290
|
+
const n = ((c = t.parent) == null ? void 0 : c.children) ?? o.value, i = n.findIndex((f) => f.id === e.id);
|
|
291
291
|
i >= 0 && n.splice(i, 1);
|
|
292
292
|
for (const f of a)
|
|
293
|
-
await
|
|
294
|
-
if (await
|
|
295
|
-
const f = G(
|
|
296
|
-
f && await
|
|
293
|
+
await g().deletePage(f);
|
|
294
|
+
if (await P(), a.includes(u.value)) {
|
|
295
|
+
const f = G(o.value);
|
|
296
|
+
f && await y(f, !0);
|
|
297
297
|
}
|
|
298
|
-
|
|
298
|
+
v.push("删除节点", !0);
|
|
299
299
|
}
|
|
300
|
-
function
|
|
301
|
-
var i,
|
|
300
|
+
function le(e, t, a) {
|
|
301
|
+
var i, c, f, q;
|
|
302
302
|
const r = e.data.type, n = t.data.type;
|
|
303
303
|
if (r === "folder") {
|
|
304
304
|
if (a === "inner")
|
|
305
305
|
return n === "folder";
|
|
306
306
|
if (n !== "folder")
|
|
307
307
|
return !1;
|
|
308
|
-
const
|
|
309
|
-
return
|
|
308
|
+
const de = ((c = (i = e.parent) == null ? void 0 : i.data) == null ? void 0 : c.id) ?? "__root__", pe = ((q = (f = t.parent) == null ? void 0 : f.data) == null ? void 0 : q.id) ?? "__root__";
|
|
309
|
+
return de === pe;
|
|
310
310
|
}
|
|
311
311
|
return a === "inner" ? n === "folder" : !0;
|
|
312
312
|
}
|
|
313
|
-
async function
|
|
314
|
-
await
|
|
313
|
+
async function fe() {
|
|
314
|
+
await Q(), await P(), v.push("树结构拖动", !0);
|
|
315
315
|
}
|
|
316
316
|
return B(
|
|
317
|
-
() =>
|
|
317
|
+
() => s.schemas,
|
|
318
318
|
() => {
|
|
319
|
-
|
|
319
|
+
Y();
|
|
320
320
|
},
|
|
321
321
|
{ deep: !0 }
|
|
322
322
|
), B(
|
|
323
|
-
() =>
|
|
323
|
+
() => s.script,
|
|
324
324
|
() => {
|
|
325
|
-
|
|
325
|
+
Y();
|
|
326
326
|
}
|
|
327
327
|
), B(u, (e) => {
|
|
328
328
|
N.currentPageId = e;
|
|
329
|
-
}),
|
|
329
|
+
}), ae(), {
|
|
330
330
|
activePageId: S,
|
|
331
331
|
addType: x,
|
|
332
|
-
allowDrop:
|
|
332
|
+
allowDrop: le,
|
|
333
333
|
currentPageId: u,
|
|
334
|
-
editTarget:
|
|
335
|
-
handleAdd:
|
|
336
|
-
handleDelete:
|
|
337
|
-
handleEdit:
|
|
338
|
-
handleNodeClick:
|
|
339
|
-
handleNodeDrop:
|
|
334
|
+
editTarget: m,
|
|
335
|
+
handleAdd: se,
|
|
336
|
+
handleDelete: ue,
|
|
337
|
+
handleEdit: ce,
|
|
338
|
+
handleNodeClick: re,
|
|
339
|
+
handleNodeDrop: fe,
|
|
340
340
|
inputName: I,
|
|
341
|
-
openAddDialog:
|
|
342
|
-
openEditDialog:
|
|
343
|
-
selectedNodeId:
|
|
341
|
+
openAddDialog: ie,
|
|
342
|
+
openEditDialog: oe,
|
|
343
|
+
selectedNodeId: h,
|
|
344
344
|
showAddDialog: _,
|
|
345
345
|
showEditDialog: b,
|
|
346
|
-
treeData:
|
|
347
|
-
treeProps:
|
|
348
|
-
treeRef:
|
|
346
|
+
treeData: o,
|
|
347
|
+
treeProps: ee,
|
|
348
|
+
treeRef: Z
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
351
|
function Be() {
|
|
352
|
-
|
|
352
|
+
const p = X(), s = V.get(p);
|
|
353
|
+
if (s)
|
|
354
|
+
return s;
|
|
355
|
+
const v = Se();
|
|
356
|
+
return V.set(p, v), v;
|
|
353
357
|
}
|
|
354
358
|
export {
|
|
355
359
|
Be as usePageManagerSingleton
|