@tmagic/editor 1.3.0-alpha.13 → 1.3.0-alpha.15
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/style.css +41 -113
- package/dist/tmagic-editor.js +1315 -1197
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +1326 -1204
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +11 -11
- package/src/Editor.vue +0 -4
- package/src/components/CodeBlockEditor.vue +155 -0
- package/src/components/CodeParams.vue +59 -0
- package/src/fields/Code.vue +27 -19
- package/src/fields/CodeSelect.vue +7 -1
- package/src/fields/CodeSelectCol.vue +65 -74
- package/src/fields/DataSourceFields.vue +7 -9
- package/src/fields/DataSourceMethodSelect.vue +147 -0
- package/src/fields/DataSourceMethods.vue +103 -0
- package/src/fields/EventSelect.vue +33 -7
- package/src/icons/CodeIcon.vue +0 -2
- package/src/index.ts +8 -0
- package/src/layouts/CodeEditor.vue +32 -1
- package/src/layouts/Framework.vue +7 -3
- package/src/layouts/sidebar/LayerPanel.vue +1 -1
- package/src/layouts/sidebar/Sidebar.vue +2 -10
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +73 -124
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +63 -0
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +23 -33
- package/src/layouts/sidebar/data-source/DataSourceList.vue +111 -0
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +13 -81
- package/src/services/codeBlock.ts +17 -70
- package/src/services/dataSource.ts +2 -0
- package/src/services/editor.ts +1 -1
- package/src/theme/code-block.scss +0 -122
- package/src/theme/code-editor.scss +27 -2
- package/src/theme/data-source-methods.scss +13 -0
- package/src/theme/event.scss +15 -12
- package/src/theme/theme.scss +1 -0
- package/src/type.ts +21 -6
- package/src/utils/data-source/index.ts +11 -0
- package/src/utils/use-code-block-edit.ts +84 -0
- package/src/utils/use-data-source-method.ts +101 -0
- package/types/components/CodeBlockEditor.vue.d.ts +21 -0
- package/types/components/CodeParams.vue.d.ts +26 -0
- package/types/components/ContentMenu.vue.d.ts +2 -2
- package/types/fields/Code.vue.d.ts +26 -6
- package/types/fields/CodeSelectCol.vue.d.ts +16 -5
- package/types/fields/DataSourceFields.vue.d.ts +2 -0
- package/types/fields/DataSourceMethodSelect.vue.d.ts +44 -0
- package/types/fields/DataSourceMethods.vue.d.ts +45 -0
- package/types/index.d.ts +4 -0
- package/types/layouts/CodeEditor.vue.d.ts +2 -0
- package/types/layouts/PropsPanel.vue.d.ts +8 -8
- package/types/layouts/sidebar/Sidebar.vue.d.ts +0 -3
- package/types/layouts/sidebar/code-block/CodeBlockList.vue.d.ts +4 -9
- package/types/layouts/sidebar/code-block/{CodeBlockEditor.vue.d.ts → CodeBlockListPanel.vue.d.ts} +8 -5
- package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +3 -1
- package/types/layouts/sidebar/data-source/DataSourceList.vue.d.ts +14 -0
- package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +1 -11
- package/types/services/codeBlock.d.ts +5 -36
- package/types/services/dataSource.d.ts +1 -0
- package/types/services/editor.d.ts +1 -1
- package/types/type.d.ts +19 -6
- package/types/{components/FunctionEditor.vue.d.ts → utils/use-code-block-edit.d.ts} +26 -123
- package/types/utils/use-data-source-method.d.ts +116 -0
- package/src/components/CodeDraftEditor.vue +0 -148
- package/src/components/FunctionEditor.vue +0 -197
- package/src/layouts/sidebar/code-block/CodeBlockEditor.vue +0 -100
- package/types/components/CodeDraftEditor.vue.d.ts +0 -61
package/dist/tmagic-editor.js
CHANGED
|
@@ -1,48 +1,228 @@
|
|
|
1
|
-
import { defineComponent,
|
|
1
|
+
import { defineComponent, ref, watch, onMounted, onUnmounted, openBlock, createElementBlock, createBlock, Teleport, createElementVNode, normalizeClass, normalizeStyle, createVNode, unref, computed, reactive, resolveComponent, inject, withCtx, resolveDynamicComponent, toRaw, nextTick, createCommentVNode, createTextVNode, mergeProps, toDisplayString, Fragment, renderList, watchEffect, withModifiers, renderSlot, createSlots, normalizeProps, markRaw, getCurrentInstance, withDirectives, vShow, createStaticVNode, onBeforeUnmount, toHandlers, provide } from 'vue';
|
|
2
|
+
import { FullScreen, Edit, View, Coin, Delete, Plus, Close, ArrowDown, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Search, Aim, CopyDocument, DocumentCopy, Files, Hide, Goods, List, EditPen, ArrowLeftBold, ArrowRightBold, CaretBottom, Top, Bottom } from '@element-plus/icons-vue';
|
|
3
|
+
import { throttle, isEmpty, cloneDeep, map, has, mergeWith, isObject, uniq, difference, union, pick, keys } from 'lodash-es';
|
|
4
|
+
import * as monaco from 'monaco-editor';
|
|
2
5
|
import serialize from 'serialize-javascript';
|
|
3
|
-
import {
|
|
4
|
-
import { TMagicCard, TMagicIcon, TMagicButton, tMagicMessageBox, getConfig as getConfig$1, TMagicTag, TMagicInput, TMagicTooltip, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, tMagicMessage, TMagicDrawer, TMagicTree, TMagicCollapse, TMagicCollapseItem, TMagicPopover } from '@tmagic/design';
|
|
6
|
+
import { TMagicButton, TMagicCard, tMagicMessage, TMagicIcon, tMagicMessageBox, getConfig as getConfig$1, TMagicTag, TMagicInput, TMagicTooltip, TMagicScrollbar, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicTree, TMagicCollapse, TMagicCollapseItem, TMagicPopover } from '@tmagic/design';
|
|
5
7
|
import { HookType, ActionType, NodeType } from '@tmagic/schema';
|
|
6
|
-
import {
|
|
7
|
-
import { createValues, MFormDialog, MSelect, MForm } from '@tmagic/form';
|
|
8
|
+
import { MFormDrawer, MForm, createValues, MFormDialog, MSelect } from '@tmagic/form';
|
|
8
9
|
import { MagicTable } from '@tmagic/table';
|
|
9
|
-
import * as monaco from 'monaco-editor';
|
|
10
10
|
import Gesto from 'gesto';
|
|
11
|
-
import { isPop, getNodePath, isNumber, isPage, toLine, guid,
|
|
11
|
+
import { isPop, getNodePath, isNumber, isPage, toLine, guid, removeClassNameByClassName, getNodes } from '@tmagic/utils';
|
|
12
12
|
import StageCore, { GuidesType, getOffset, calcValueByFontsize, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
|
|
13
13
|
import { EventEmitter } from 'events';
|
|
14
14
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
15
15
|
import KeyController from 'keycon';
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const _hoisted_1$r = {
|
|
18
|
+
class: /* @__PURE__ */ normalizeClass(`magic-code-editor`)
|
|
19
|
+
};
|
|
20
|
+
const _sfc_main$K = /* @__PURE__ */ defineComponent({
|
|
21
|
+
...{
|
|
22
|
+
name: "MEditorCodeEditor"
|
|
23
|
+
},
|
|
24
|
+
__name: "CodeEditor",
|
|
25
|
+
props: {
|
|
26
|
+
initValues: {},
|
|
27
|
+
modifiedValues: {},
|
|
28
|
+
type: {},
|
|
29
|
+
language: { default: "javascript" },
|
|
30
|
+
options: { default: () => ({
|
|
31
|
+
tabSize: 2
|
|
32
|
+
}) },
|
|
33
|
+
height: {},
|
|
34
|
+
autoSave: { type: Boolean, default: true }
|
|
35
|
+
},
|
|
36
|
+
emits: ["initd", "save"],
|
|
37
|
+
setup(__props, { expose: __expose, emit }) {
|
|
38
|
+
const props = __props;
|
|
39
|
+
const toString = (v, language) => {
|
|
40
|
+
let value = "";
|
|
41
|
+
if (typeof v !== "string") {
|
|
42
|
+
if (props.language.toLocaleLowerCase() === "json") {
|
|
43
|
+
value = JSON.stringify(v, null, 2);
|
|
44
|
+
} else {
|
|
45
|
+
value = serialize(v, {
|
|
46
|
+
space: 2,
|
|
47
|
+
unsafe: true
|
|
48
|
+
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
value = v;
|
|
52
|
+
}
|
|
53
|
+
if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
|
|
54
|
+
value = `(${value})`;
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
};
|
|
58
|
+
let vsEditor = null;
|
|
59
|
+
let vsDiffEditor = null;
|
|
60
|
+
const values = ref("");
|
|
61
|
+
const loading = ref(false);
|
|
62
|
+
const codeEditor = ref();
|
|
63
|
+
const resizeObserver = new globalThis.ResizeObserver(
|
|
64
|
+
throttle(() => {
|
|
65
|
+
vsEditor?.layout();
|
|
66
|
+
vsDiffEditor?.layout();
|
|
67
|
+
}, 300)
|
|
68
|
+
);
|
|
69
|
+
const setEditorValue = (v, m) => {
|
|
70
|
+
values.value = toString(v, props.language);
|
|
71
|
+
if (props.type === "diff") {
|
|
72
|
+
const originalModel = monaco.editor.createModel(values.value, "text/javascript");
|
|
73
|
+
const modifiedModel = monaco.editor.createModel(toString(m, props.language), "text/javascript");
|
|
74
|
+
return vsDiffEditor?.setModel({
|
|
75
|
+
original: originalModel,
|
|
76
|
+
modified: modifiedModel
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return vsEditor?.setValue(values.value);
|
|
80
|
+
};
|
|
81
|
+
const getEditorValue = () => (props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue()) || "";
|
|
82
|
+
const init = async () => {
|
|
83
|
+
if (!codeEditor.value)
|
|
84
|
+
return;
|
|
85
|
+
const options = {
|
|
86
|
+
value: values.value,
|
|
87
|
+
language: props.language,
|
|
88
|
+
theme: "vs-dark",
|
|
89
|
+
...props.options
|
|
90
|
+
};
|
|
91
|
+
if (props.type === "diff") {
|
|
92
|
+
vsDiffEditor = monaco.editor.createDiffEditor(codeEditor.value, options);
|
|
93
|
+
} else {
|
|
94
|
+
vsEditor = monaco.editor.create(codeEditor.value, options);
|
|
95
|
+
}
|
|
96
|
+
setEditorValue(props.initValues, props.modifiedValues);
|
|
97
|
+
loading.value = false;
|
|
98
|
+
emit("initd", vsEditor);
|
|
99
|
+
codeEditor.value.addEventListener("keydown", (e) => {
|
|
100
|
+
if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
e.stopPropagation();
|
|
103
|
+
const newValue = getEditorValue();
|
|
104
|
+
values.value = newValue;
|
|
105
|
+
emit("save", newValue);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (props.type !== "diff" && props.autoSave) {
|
|
109
|
+
vsEditor?.onDidBlurEditorWidget(() => {
|
|
110
|
+
const newValue = getEditorValue();
|
|
111
|
+
if (values.value !== newValue) {
|
|
112
|
+
values.value = newValue;
|
|
113
|
+
emit("save", newValue);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
resizeObserver.observe(codeEditor.value);
|
|
118
|
+
};
|
|
119
|
+
watch(
|
|
120
|
+
() => props.initValues,
|
|
121
|
+
(v, preV) => {
|
|
122
|
+
if (v !== preV) {
|
|
123
|
+
setEditorValue(props.initValues, props.modifiedValues);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
deep: true,
|
|
128
|
+
immediate: true
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
onMounted(async () => {
|
|
132
|
+
loading.value = true;
|
|
133
|
+
init();
|
|
134
|
+
});
|
|
135
|
+
onUnmounted(() => {
|
|
136
|
+
resizeObserver.disconnect();
|
|
137
|
+
});
|
|
138
|
+
const fullScreen = ref(false);
|
|
139
|
+
const fullScreenHandler = () => {
|
|
140
|
+
fullScreen.value = !fullScreen.value;
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
vsEditor?.focus();
|
|
143
|
+
vsEditor?.layout();
|
|
144
|
+
vsDiffEditor?.focus();
|
|
145
|
+
vsDiffEditor?.layout();
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
__expose({
|
|
149
|
+
values,
|
|
150
|
+
getEditor() {
|
|
151
|
+
return vsEditor || vsDiffEditor;
|
|
152
|
+
},
|
|
153
|
+
getVsEditor() {
|
|
154
|
+
return vsEditor;
|
|
155
|
+
},
|
|
156
|
+
getVsDiffEditor() {
|
|
157
|
+
return vsDiffEditor;
|
|
158
|
+
},
|
|
159
|
+
setEditorValue,
|
|
160
|
+
focus() {
|
|
161
|
+
vsEditor?.focus();
|
|
162
|
+
vsDiffEditor?.focus();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return (_ctx, _cache) => {
|
|
166
|
+
return openBlock(), createElementBlock("div", _hoisted_1$r, [
|
|
167
|
+
(openBlock(), createBlock(Teleport, {
|
|
168
|
+
to: "body",
|
|
169
|
+
disabled: !fullScreen.value
|
|
170
|
+
}, [
|
|
171
|
+
createElementVNode("div", {
|
|
172
|
+
class: normalizeClass(`magic-code-editor-wrapper${fullScreen.value ? " full-screen" : ""}`),
|
|
173
|
+
style: normalizeStyle(!fullScreen.value && _ctx.height ? `height: ${_ctx.height}` : "100%")
|
|
174
|
+
}, [
|
|
175
|
+
createVNode(unref(TMagicButton), {
|
|
176
|
+
class: "magic-code-editor-full-screen-icon",
|
|
177
|
+
circle: "",
|
|
178
|
+
size: "small",
|
|
179
|
+
icon: unref(FullScreen),
|
|
180
|
+
onClick: fullScreenHandler
|
|
181
|
+
}, null, 8, ["icon"]),
|
|
182
|
+
createElementVNode("div", {
|
|
183
|
+
ref_key: "codeEditor",
|
|
184
|
+
ref: codeEditor,
|
|
185
|
+
class: "magic-code-editor-content"
|
|
186
|
+
}, null, 512)
|
|
187
|
+
], 6)
|
|
188
|
+
], 8, ["disabled"]))
|
|
189
|
+
]);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
18
195
|
...{
|
|
19
196
|
name: "MEditorCode"
|
|
20
197
|
},
|
|
21
198
|
__name: "Code",
|
|
22
199
|
props: {
|
|
200
|
+
config: {},
|
|
23
201
|
model: {},
|
|
24
202
|
name: {},
|
|
25
|
-
|
|
26
|
-
|
|
203
|
+
prop: {},
|
|
204
|
+
lastValues: {},
|
|
205
|
+
disabled: { type: Boolean, default: false },
|
|
206
|
+
size: {}
|
|
27
207
|
},
|
|
28
208
|
emits: ["change"],
|
|
29
209
|
setup(__props, { emit }) {
|
|
30
210
|
const props = __props;
|
|
31
|
-
const language = computed(() => props.config.language || "javascript");
|
|
32
|
-
const height = computed(() => props.config.height || `${document.body.clientHeight - 168}px`);
|
|
33
211
|
const save = (v) => {
|
|
34
212
|
props.model[props.name] = v;
|
|
35
213
|
emit("change", v);
|
|
36
214
|
};
|
|
37
215
|
return (_ctx, _cache) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
style: normalizeStyle(`height: ${height.value}`),
|
|
216
|
+
return openBlock(), createBlock(_sfc_main$K, {
|
|
217
|
+
height: _ctx.config.height,
|
|
41
218
|
"init-values": _ctx.model[_ctx.name],
|
|
42
|
-
language: language
|
|
43
|
-
options:
|
|
219
|
+
language: _ctx.config.language,
|
|
220
|
+
options: {
|
|
221
|
+
..._ctx.config.options,
|
|
222
|
+
readOnly: _ctx.disabled
|
|
223
|
+
},
|
|
44
224
|
onSave: save
|
|
45
|
-
}, null, 8, ["
|
|
225
|
+
}, null, 8, ["height", "init-values", "language", "options"]);
|
|
46
226
|
};
|
|
47
227
|
}
|
|
48
228
|
});
|
|
@@ -53,7 +233,7 @@ const setConfig = (option) => {
|
|
|
53
233
|
};
|
|
54
234
|
const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
55
235
|
|
|
56
|
-
const _sfc_main$
|
|
236
|
+
const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
57
237
|
...{
|
|
58
238
|
name: "MEditorCodeLink"
|
|
59
239
|
},
|
|
@@ -127,7 +307,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
127
307
|
}
|
|
128
308
|
});
|
|
129
309
|
|
|
130
|
-
const _sfc_main$
|
|
310
|
+
const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
131
311
|
...{
|
|
132
312
|
name: "MEditorCodeSelect"
|
|
133
313
|
},
|
|
@@ -142,6 +322,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
142
322
|
emits: ["change"],
|
|
143
323
|
setup(__props, { emit }) {
|
|
144
324
|
const props = __props;
|
|
325
|
+
const services = inject("services");
|
|
145
326
|
const codeConfig = computed(() => ({
|
|
146
327
|
type: "group-list",
|
|
147
328
|
name: "hookData",
|
|
@@ -151,7 +332,9 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
151
332
|
items: [
|
|
152
333
|
{
|
|
153
334
|
type: "code-select-col",
|
|
154
|
-
|
|
335
|
+
name: "codeId",
|
|
336
|
+
labelWidth: 0,
|
|
337
|
+
disabled: () => !services?.codeBlockService.getEditStatus()
|
|
155
338
|
}
|
|
156
339
|
]
|
|
157
340
|
}));
|
|
@@ -192,6 +375,187 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
192
375
|
}
|
|
193
376
|
});
|
|
194
377
|
|
|
378
|
+
const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
379
|
+
...{
|
|
380
|
+
name: "MEditorCodeBlockEditor"
|
|
381
|
+
},
|
|
382
|
+
__name: "CodeBlockEditor",
|
|
383
|
+
props: {
|
|
384
|
+
content: {},
|
|
385
|
+
disabled: { type: Boolean }
|
|
386
|
+
},
|
|
387
|
+
emits: ["submit"],
|
|
388
|
+
setup(__props, { expose: __expose, emit }) {
|
|
389
|
+
const services = inject("services");
|
|
390
|
+
const columnWidth = computed(() => services?.uiService.get("columnWidth"));
|
|
391
|
+
const size = computed(() => columnWidth.value ? columnWidth.value.center + columnWidth.value.right : 600);
|
|
392
|
+
const codeEditorHeight = ref("600px");
|
|
393
|
+
const defaultParamColConfig = {
|
|
394
|
+
type: "row",
|
|
395
|
+
label: "参数类型",
|
|
396
|
+
items: [
|
|
397
|
+
{
|
|
398
|
+
text: "参数类型",
|
|
399
|
+
labelWidth: "70px",
|
|
400
|
+
type: "select",
|
|
401
|
+
name: "type",
|
|
402
|
+
options: [
|
|
403
|
+
{
|
|
404
|
+
text: "数字",
|
|
405
|
+
label: "数字",
|
|
406
|
+
value: "number"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
text: "字符串",
|
|
410
|
+
label: "字符串",
|
|
411
|
+
value: "text"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
text: "组件",
|
|
415
|
+
label: "组件",
|
|
416
|
+
value: "ui-select"
|
|
417
|
+
}
|
|
418
|
+
]
|
|
419
|
+
}
|
|
420
|
+
]
|
|
421
|
+
};
|
|
422
|
+
const functionConfig = computed(() => [
|
|
423
|
+
{
|
|
424
|
+
text: "名称",
|
|
425
|
+
name: "name"
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
text: "注释",
|
|
429
|
+
name: "desc"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
type: "table",
|
|
433
|
+
border: true,
|
|
434
|
+
text: "参数",
|
|
435
|
+
enableFullscreen: false,
|
|
436
|
+
name: "params",
|
|
437
|
+
maxHeight: "300px",
|
|
438
|
+
dropSort: false,
|
|
439
|
+
items: [
|
|
440
|
+
{
|
|
441
|
+
type: "text",
|
|
442
|
+
label: "参数名",
|
|
443
|
+
name: "name"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
type: "text",
|
|
447
|
+
label: "注释",
|
|
448
|
+
name: "extra"
|
|
449
|
+
},
|
|
450
|
+
services?.codeBlockService.getParamsColConfig() || defaultParamColConfig
|
|
451
|
+
]
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
name: "content",
|
|
455
|
+
type: "vs-code",
|
|
456
|
+
options: inject("codeOptions", {}),
|
|
457
|
+
height: codeEditorHeight.value,
|
|
458
|
+
onChange: (formState, code) => {
|
|
459
|
+
try {
|
|
460
|
+
getConfig("parseDSL")(code);
|
|
461
|
+
return code;
|
|
462
|
+
} catch (error) {
|
|
463
|
+
tMagicMessage.error(error.message);
|
|
464
|
+
throw error;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
]);
|
|
469
|
+
const submitForm = async (values) => {
|
|
470
|
+
emit("submit", values);
|
|
471
|
+
};
|
|
472
|
+
const errorHandler = (error) => {
|
|
473
|
+
tMagicMessage.error(error.message);
|
|
474
|
+
};
|
|
475
|
+
const fomDrawer = ref();
|
|
476
|
+
const openHandler = () => {
|
|
477
|
+
setTimeout(() => {
|
|
478
|
+
if (fomDrawer.value) {
|
|
479
|
+
const height = fomDrawer.value?.bodyHeight - 468;
|
|
480
|
+
codeEditorHeight.value = `${height > 100 ? height : 600}px`;
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
};
|
|
484
|
+
__expose({
|
|
485
|
+
show() {
|
|
486
|
+
fomDrawer.value?.show();
|
|
487
|
+
},
|
|
488
|
+
hide() {
|
|
489
|
+
fomDrawer.value?.hide();
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
return (_ctx, _cache) => {
|
|
493
|
+
return openBlock(), createBlock(unref(MFormDrawer), {
|
|
494
|
+
ref_key: "fomDrawer",
|
|
495
|
+
ref: fomDrawer,
|
|
496
|
+
"label-width": "80px",
|
|
497
|
+
title: _ctx.content.name,
|
|
498
|
+
width: size.value,
|
|
499
|
+
config: functionConfig.value,
|
|
500
|
+
values: _ctx.content,
|
|
501
|
+
disabled: _ctx.disabled,
|
|
502
|
+
onSubmit: submitForm,
|
|
503
|
+
onError: errorHandler,
|
|
504
|
+
onOpen: openHandler
|
|
505
|
+
}, null, 8, ["title", "width", "config", "values", "disabled"]);
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
511
|
+
...{
|
|
512
|
+
name: "MEditorCodeParams"
|
|
513
|
+
},
|
|
514
|
+
__name: "CodeParams",
|
|
515
|
+
props: {
|
|
516
|
+
model: {},
|
|
517
|
+
size: {},
|
|
518
|
+
disabled: { type: Boolean },
|
|
519
|
+
name: {},
|
|
520
|
+
paramsConfig: {}
|
|
521
|
+
},
|
|
522
|
+
emits: ["change"],
|
|
523
|
+
setup(__props, { emit }) {
|
|
524
|
+
const props = __props;
|
|
525
|
+
const form = ref();
|
|
526
|
+
const getFormConfig = (items = []) => [
|
|
527
|
+
{
|
|
528
|
+
type: "fieldset",
|
|
529
|
+
items,
|
|
530
|
+
legend: "参数",
|
|
531
|
+
labelWidth: "70px",
|
|
532
|
+
name: props.name
|
|
533
|
+
}
|
|
534
|
+
];
|
|
535
|
+
const codeParamsConfig = computed(() => getFormConfig(props.paramsConfig));
|
|
536
|
+
const onParamsChangeHandler = async () => {
|
|
537
|
+
try {
|
|
538
|
+
const value = await form.value?.submitForm(true);
|
|
539
|
+
emit("change", value);
|
|
540
|
+
} catch (e) {
|
|
541
|
+
console.log(e);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
return (_ctx, _cache) => {
|
|
545
|
+
return openBlock(), createBlock(unref(MForm), {
|
|
546
|
+
ref_key: "form",
|
|
547
|
+
ref: form,
|
|
548
|
+
config: codeParamsConfig.value,
|
|
549
|
+
"init-values": _ctx.model,
|
|
550
|
+
disabled: _ctx.disabled,
|
|
551
|
+
size: _ctx.size,
|
|
552
|
+
"watch-props": false,
|
|
553
|
+
onChange: onParamsChangeHandler
|
|
554
|
+
}, null, 8, ["config", "init-values", "disabled", "size"]);
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
|
|
195
559
|
const _hoisted_1$q = ["src"];
|
|
196
560
|
const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
197
561
|
...{
|
|
@@ -235,6 +599,64 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
235
599
|
}
|
|
236
600
|
});
|
|
237
601
|
|
|
602
|
+
const useCodeBlockEdit = (codeBlockService) => {
|
|
603
|
+
const codeConfig = ref();
|
|
604
|
+
const codeId = ref();
|
|
605
|
+
const codeBlockEditor = ref();
|
|
606
|
+
const createCodeBlock = async () => {
|
|
607
|
+
if (!codeBlockService) {
|
|
608
|
+
tMagicMessage.error("新增代码块失败");
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
codeConfig.value = {
|
|
612
|
+
name: "代码块",
|
|
613
|
+
content: `({app, params}) => {
|
|
614
|
+
// place your code here
|
|
615
|
+
}`,
|
|
616
|
+
params: []
|
|
617
|
+
};
|
|
618
|
+
codeId.value = await codeBlockService.getUniqueId();
|
|
619
|
+
await nextTick();
|
|
620
|
+
codeBlockEditor.value?.show();
|
|
621
|
+
};
|
|
622
|
+
const editCode = async (id) => {
|
|
623
|
+
const codeBlock = await codeBlockService?.getCodeContentById(id);
|
|
624
|
+
if (!codeBlock) {
|
|
625
|
+
tMagicMessage.error("获取代码块内容失败");
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
let codeContent = codeBlock.content;
|
|
629
|
+
if (typeof codeContent !== "string") {
|
|
630
|
+
codeContent = codeContent.toString();
|
|
631
|
+
}
|
|
632
|
+
codeConfig.value = {
|
|
633
|
+
...cloneDeep(codeBlock),
|
|
634
|
+
content: codeContent
|
|
635
|
+
};
|
|
636
|
+
codeId.value = id;
|
|
637
|
+
await nextTick();
|
|
638
|
+
codeBlockEditor.value?.show();
|
|
639
|
+
};
|
|
640
|
+
const deleteCode = async (key) => {
|
|
641
|
+
codeBlockService?.deleteCodeDslByIds([key]);
|
|
642
|
+
};
|
|
643
|
+
const submitCodeBlockHandler = async (values) => {
|
|
644
|
+
if (!codeId.value)
|
|
645
|
+
return;
|
|
646
|
+
await codeBlockService?.setCodeDslById(codeId.value, values);
|
|
647
|
+
codeBlockEditor.value?.hide();
|
|
648
|
+
};
|
|
649
|
+
return {
|
|
650
|
+
codeId,
|
|
651
|
+
codeConfig,
|
|
652
|
+
codeBlockEditor,
|
|
653
|
+
createCodeBlock,
|
|
654
|
+
editCode,
|
|
655
|
+
deleteCode,
|
|
656
|
+
submitCodeBlockHandler
|
|
657
|
+
};
|
|
658
|
+
};
|
|
659
|
+
|
|
238
660
|
const _hoisted_1$p = { class: "m-fields-code-select-col" };
|
|
239
661
|
const _hoisted_2$f = { class: "code-select-container" };
|
|
240
662
|
const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
@@ -247,28 +669,33 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
247
669
|
model: {},
|
|
248
670
|
prop: {},
|
|
249
671
|
name: {},
|
|
672
|
+
lastValues: {},
|
|
673
|
+
disabled: { type: Boolean, default: false },
|
|
250
674
|
size: {}
|
|
251
675
|
},
|
|
252
676
|
emits: ["change"],
|
|
253
677
|
setup(__props, { emit }) {
|
|
254
678
|
const props = __props;
|
|
255
679
|
const services = inject("services");
|
|
256
|
-
const
|
|
680
|
+
const getParamItemsConfig = (codeId) => {
|
|
681
|
+
if (!codeDsl.value || !codeId)
|
|
682
|
+
return [];
|
|
683
|
+
const paramStatements = codeDsl.value[codeId]?.params;
|
|
684
|
+
if (isEmpty(paramStatements))
|
|
685
|
+
return [];
|
|
686
|
+
return paramStatements.map((paramState) => ({
|
|
687
|
+
labelWidth: "100px",
|
|
688
|
+
text: paramState.name,
|
|
689
|
+
...paramState
|
|
690
|
+
}));
|
|
691
|
+
};
|
|
257
692
|
const codeDsl = computed(() => services?.codeBlockService.getCodeDsl());
|
|
258
|
-
const
|
|
259
|
-
const codeParamsConfig = ref({
|
|
260
|
-
type: "fieldset",
|
|
261
|
-
items: [],
|
|
262
|
-
legend: "参数",
|
|
263
|
-
labelWidth: "70px",
|
|
264
|
-
name: "params",
|
|
265
|
-
display: false
|
|
266
|
-
});
|
|
693
|
+
const paramsConfig = ref(getParamItemsConfig(props.model[props.name]));
|
|
267
694
|
const selectConfig = {
|
|
268
695
|
type: "select",
|
|
269
696
|
text: "代码块",
|
|
270
|
-
name:
|
|
271
|
-
labelWidth: "
|
|
697
|
+
name: props.name,
|
|
698
|
+
labelWidth: "80px",
|
|
272
699
|
options: () => {
|
|
273
700
|
if (codeDsl.value) {
|
|
274
701
|
return map(codeDsl.value, (value, key) => ({
|
|
@@ -280,53 +707,20 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
280
707
|
return [];
|
|
281
708
|
},
|
|
282
709
|
onChange: (formState, codeId, { model }) => {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
if (isEmpty(paramStatements))
|
|
291
|
-
return [];
|
|
292
|
-
return paramStatements.map((paramState) => ({
|
|
293
|
-
labelWidth: "100px",
|
|
294
|
-
text: paramState.name,
|
|
295
|
-
...paramState
|
|
296
|
-
}));
|
|
297
|
-
};
|
|
298
|
-
const getCodeParamsConfig = (codeId) => {
|
|
299
|
-
const paramsConfig = getParamItemsConfig(codeId);
|
|
300
|
-
if (!props.model.params || isEmpty(props.model.params)) {
|
|
301
|
-
props.model.params = {};
|
|
302
|
-
createValues(mForm, paramsConfig, {}, props.model.params);
|
|
710
|
+
paramsConfig.value = getParamItemsConfig(codeId);
|
|
711
|
+
if (paramsConfig.value.length) {
|
|
712
|
+
model.params = createValues(formState, paramsConfig.value, {}, model.params);
|
|
713
|
+
} else {
|
|
714
|
+
model.params = {};
|
|
715
|
+
}
|
|
716
|
+
return codeId;
|
|
303
717
|
}
|
|
304
|
-
codeParamsConfig.value = {
|
|
305
|
-
type: "fieldset",
|
|
306
|
-
items: paramsConfig,
|
|
307
|
-
legend: "参数",
|
|
308
|
-
labelWidth: "70px",
|
|
309
|
-
name: "params",
|
|
310
|
-
display: !isEmpty(paramsConfig)
|
|
311
|
-
};
|
|
312
718
|
};
|
|
313
|
-
const onParamsChangeHandler = () => {
|
|
719
|
+
const onParamsChangeHandler = (value) => {
|
|
720
|
+
props.model.params = value.params;
|
|
314
721
|
emit("change", props.model);
|
|
315
722
|
};
|
|
316
|
-
|
|
317
|
-
() => props.model.codeId,
|
|
318
|
-
(codeId) => {
|
|
319
|
-
if (!codeId)
|
|
320
|
-
return;
|
|
321
|
-
getCodeParamsConfig(codeId);
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
immediate: true
|
|
325
|
-
}
|
|
326
|
-
);
|
|
327
|
-
const editCode = () => {
|
|
328
|
-
services?.codeBlockService.setCodeEditorContent(true, props.model.codeId);
|
|
329
|
-
};
|
|
723
|
+
const { codeBlockEditor, codeConfig, editCode, submitCodeBlockHandler } = useCodeBlockEdit(services?.codeBlockService);
|
|
330
724
|
return (_ctx, _cache) => {
|
|
331
725
|
const _component_m_form_container = resolveComponent("m-form-container");
|
|
332
726
|
return openBlock(), createElementBlock("div", _hoisted_1$p, [
|
|
@@ -337,17 +731,29 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
337
731
|
model: _ctx.model,
|
|
338
732
|
onChange: onParamsChangeHandler
|
|
339
733
|
}, null, 8, ["model"]),
|
|
340
|
-
|
|
734
|
+
_ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$E, {
|
|
735
|
+
key: 0,
|
|
341
736
|
class: "icon",
|
|
342
|
-
icon:
|
|
343
|
-
onClick: editCode
|
|
344
|
-
}, null, 8, ["icon"])
|
|
737
|
+
icon: !_ctx.disabled ? unref(Edit) : unref(View),
|
|
738
|
+
onClick: _cache[0] || (_cache[0] = ($event) => unref(editCode)(_ctx.model[_ctx.name]))
|
|
739
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true)
|
|
345
740
|
]),
|
|
346
|
-
|
|
347
|
-
|
|
741
|
+
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$F, {
|
|
742
|
+
key: 0,
|
|
743
|
+
name: "params",
|
|
348
744
|
model: _ctx.model,
|
|
745
|
+
size: _ctx.size,
|
|
746
|
+
"params-config": paramsConfig.value,
|
|
349
747
|
onChange: onParamsChangeHandler
|
|
350
|
-
}, null, 8, ["
|
|
748
|
+
}, null, 8, ["model", "size", "params-config"])) : createCommentVNode("", true),
|
|
749
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$G, {
|
|
750
|
+
key: 1,
|
|
751
|
+
ref_key: "codeBlockEditor",
|
|
752
|
+
ref: codeBlockEditor,
|
|
753
|
+
disabled: _ctx.disabled,
|
|
754
|
+
content: unref(codeConfig),
|
|
755
|
+
onSubmit: unref(submitCodeBlockHandler)
|
|
756
|
+
}, null, 8, ["disabled", "content", "onSubmit"])) : createCommentVNode("", true)
|
|
351
757
|
]);
|
|
352
758
|
};
|
|
353
759
|
}
|
|
@@ -364,6 +770,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
364
770
|
config: {},
|
|
365
771
|
model: {},
|
|
366
772
|
prop: {},
|
|
773
|
+
lastValues: {},
|
|
367
774
|
disabled: { type: Boolean, default: false },
|
|
368
775
|
name: {}
|
|
369
776
|
},
|
|
@@ -374,24 +781,20 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
374
781
|
const fieldValues = ref({});
|
|
375
782
|
const filedTitle = ref("");
|
|
376
783
|
const newHandler = () => {
|
|
377
|
-
if (!addDialog.value)
|
|
378
|
-
return;
|
|
379
784
|
fieldValues.value = {};
|
|
380
785
|
filedTitle.value = "新增属性";
|
|
381
|
-
addDialog.value
|
|
786
|
+
addDialog.value?.show();
|
|
382
787
|
};
|
|
383
788
|
const fieldChange = ({ index, ...value }) => {
|
|
384
|
-
if (!addDialog.value)
|
|
385
|
-
return;
|
|
386
789
|
if (index > -1) {
|
|
387
790
|
props.model[props.name][index] = value;
|
|
388
791
|
} else {
|
|
389
792
|
props.model[props.name].push(value);
|
|
390
793
|
}
|
|
391
|
-
addDialog.value
|
|
794
|
+
addDialog.value?.hide();
|
|
392
795
|
emit("change", props.model[props.name]);
|
|
393
796
|
};
|
|
394
|
-
const
|
|
797
|
+
const fieldColumns = [
|
|
395
798
|
{
|
|
396
799
|
label: "属性名称",
|
|
397
800
|
prop: "title"
|
|
@@ -411,14 +814,12 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
411
814
|
{
|
|
412
815
|
text: "编辑",
|
|
413
816
|
handler: (row, index) => {
|
|
414
|
-
if (!addDialog.value)
|
|
415
|
-
return;
|
|
416
817
|
fieldValues.value = {
|
|
417
818
|
...row,
|
|
418
819
|
index
|
|
419
820
|
};
|
|
420
821
|
filedTitle.value = `编辑${row.title}`;
|
|
421
|
-
addDialog.value
|
|
822
|
+
addDialog.value?.show();
|
|
422
823
|
}
|
|
423
824
|
},
|
|
424
825
|
{
|
|
@@ -504,7 +905,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
504
905
|
return openBlock(), createElementBlock("div", _hoisted_1$o, [
|
|
505
906
|
createVNode(unref(MagicTable), {
|
|
506
907
|
data: _ctx.model[_ctx.name],
|
|
507
|
-
columns:
|
|
908
|
+
columns: fieldColumns
|
|
508
909
|
}, null, 8, ["data"]),
|
|
509
910
|
createElementVNode("div", _hoisted_2$e, [
|
|
510
911
|
createVNode(unref(TMagicButton), {
|
|
@@ -527,8 +928,9 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
527
928
|
config: dataSourceFieldsConfig,
|
|
528
929
|
values: fieldValues.value,
|
|
529
930
|
parentValues: _ctx.model[_ctx.name],
|
|
931
|
+
disabled: _ctx.disabled,
|
|
530
932
|
onSubmit: fieldChange
|
|
531
|
-
}, null, 8, ["title", "values", "parentValues"])
|
|
933
|
+
}, null, 8, ["title", "values", "parentValues", "disabled"])
|
|
532
934
|
]);
|
|
533
935
|
};
|
|
534
936
|
}
|
|
@@ -536,7 +938,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
536
938
|
|
|
537
939
|
const _hoisted_1$n = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
|
|
538
940
|
const _hoisted_2$d = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
|
|
539
|
-
const _hoisted_3$
|
|
941
|
+
const _hoisted_3$5 = { class: "el-input__inner" };
|
|
540
942
|
const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
541
943
|
...{
|
|
542
944
|
name: "MEditorDataSourceInput"
|
|
@@ -734,75 +1136,358 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
734
1136
|
return _ctx.disabled || isFocused.value ? (openBlock(), createBlock(resolveDynamicComponent(unref(getConfig$1)("components")?.autocomplete.component || "el-autocomplete"), mergeProps(
|
|
735
1137
|
{
|
|
736
1138
|
key: 0,
|
|
737
|
-
class: "tmagic-design-auto-complete",
|
|
738
|
-
ref_key: "autocomplete",
|
|
739
|
-
ref: autocomplete,
|
|
740
|
-
modelValue: state.value,
|
|
741
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.value = $event)
|
|
742
|
-
},
|
|
743
|
-
unref(getConfig$1)("components")?.autocomplete.props({
|
|
744
|
-
disabled: _ctx.disabled,
|
|
1139
|
+
class: "tmagic-design-auto-complete",
|
|
1140
|
+
ref_key: "autocomplete",
|
|
1141
|
+
ref: autocomplete,
|
|
1142
|
+
modelValue: state.value,
|
|
1143
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.value = $event)
|
|
1144
|
+
},
|
|
1145
|
+
unref(getConfig$1)("components")?.autocomplete.props({
|
|
1146
|
+
disabled: _ctx.disabled,
|
|
1147
|
+
size: _ctx.size,
|
|
1148
|
+
fetchSuggestions: querySearch,
|
|
1149
|
+
triggerOnFocus: false,
|
|
1150
|
+
clearable: true
|
|
1151
|
+
}) || {},
|
|
1152
|
+
{
|
|
1153
|
+
style: { "width": "100%" },
|
|
1154
|
+
onBlur: blurHandler,
|
|
1155
|
+
onChange: changeHandler,
|
|
1156
|
+
onInput: inputHandler,
|
|
1157
|
+
onSelect: selectHandler
|
|
1158
|
+
}
|
|
1159
|
+
), {
|
|
1160
|
+
suffix: withCtx(() => [
|
|
1161
|
+
createVNode(_sfc_main$E, { icon: unref(Coin) }, null, 8, ["icon"])
|
|
1162
|
+
]),
|
|
1163
|
+
default: withCtx(({ item }) => [
|
|
1164
|
+
createElementVNode("div", _hoisted_1$n, [
|
|
1165
|
+
createElementVNode("div", null, toDisplayString(item.text), 1),
|
|
1166
|
+
createElementVNode("span", _hoisted_2$d, toDisplayString(item.value), 1)
|
|
1167
|
+
])
|
|
1168
|
+
]),
|
|
1169
|
+
_: 1
|
|
1170
|
+
}, 16, ["modelValue"])) : (openBlock(), createElementBlock("div", {
|
|
1171
|
+
key: 1,
|
|
1172
|
+
class: normalizeClass(`tmagic-data-source-input-text el-input el-input--${_ctx.size}`),
|
|
1173
|
+
onMouseup: mouseupHandler
|
|
1174
|
+
}, [
|
|
1175
|
+
createElementVNode("div", {
|
|
1176
|
+
class: normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
|
|
1177
|
+
}, [
|
|
1178
|
+
createElementVNode("div", _hoisted_3$5, [
|
|
1179
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(displayState.value, (item, index) => {
|
|
1180
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
1181
|
+
item.type === "text" ? (openBlock(), createElementBlock("span", {
|
|
1182
|
+
key: index,
|
|
1183
|
+
style: { "margin-right": "2px" }
|
|
1184
|
+
}, toDisplayString(item.value), 1)) : createCommentVNode("", true),
|
|
1185
|
+
item.type === "var" ? (openBlock(), createBlock(unref(TMagicTag), {
|
|
1186
|
+
key: index,
|
|
1187
|
+
size: _ctx.size
|
|
1188
|
+
}, {
|
|
1189
|
+
default: withCtx(() => [
|
|
1190
|
+
createTextVNode(toDisplayString(item.value), 1)
|
|
1191
|
+
]),
|
|
1192
|
+
_: 2
|
|
1193
|
+
}, 1032, ["size"])) : createCommentVNode("", true)
|
|
1194
|
+
], 64);
|
|
1195
|
+
}), 256)),
|
|
1196
|
+
createVNode(_sfc_main$E, {
|
|
1197
|
+
class: "tmagic-data-source-input-icon",
|
|
1198
|
+
icon: unref(Coin)
|
|
1199
|
+
}, null, 8, ["icon"])
|
|
1200
|
+
])
|
|
1201
|
+
], 2)
|
|
1202
|
+
], 34));
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
|
|
1207
|
+
const useDataSourceMethod = () => {
|
|
1208
|
+
const codeConfig = ref();
|
|
1209
|
+
const codeBlockEditor = ref();
|
|
1210
|
+
const dataSource = ref();
|
|
1211
|
+
const dataSourceMethod = ref("");
|
|
1212
|
+
return {
|
|
1213
|
+
codeConfig,
|
|
1214
|
+
codeBlockEditor,
|
|
1215
|
+
createCode: async (model) => {
|
|
1216
|
+
codeConfig.value = {
|
|
1217
|
+
name: "",
|
|
1218
|
+
content: `({ params, dataSource, app }) => {
|
|
1219
|
+
// place your code here
|
|
1220
|
+
}`,
|
|
1221
|
+
params: []
|
|
1222
|
+
};
|
|
1223
|
+
await nextTick();
|
|
1224
|
+
dataSource.value = model;
|
|
1225
|
+
dataSourceMethod.value = "";
|
|
1226
|
+
codeBlockEditor.value?.show();
|
|
1227
|
+
},
|
|
1228
|
+
editCode: async (model, methodName) => {
|
|
1229
|
+
const method = model.methods?.find((method2) => method2.name === methodName);
|
|
1230
|
+
if (!method) {
|
|
1231
|
+
tMagicMessage.error("获取数据源方法失败");
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
let codeContent = method.content;
|
|
1235
|
+
if (typeof codeContent !== "string") {
|
|
1236
|
+
codeContent = codeContent.toString();
|
|
1237
|
+
}
|
|
1238
|
+
codeConfig.value = {
|
|
1239
|
+
...cloneDeep(method),
|
|
1240
|
+
content: codeContent
|
|
1241
|
+
};
|
|
1242
|
+
await nextTick();
|
|
1243
|
+
dataSource.value = model;
|
|
1244
|
+
dataSourceMethod.value = methodName;
|
|
1245
|
+
codeBlockEditor.value?.show();
|
|
1246
|
+
},
|
|
1247
|
+
deleteCode: async (model, methodName) => {
|
|
1248
|
+
if (!model.methods)
|
|
1249
|
+
return;
|
|
1250
|
+
const index = model.methods.findIndex((method) => method.name === methodName);
|
|
1251
|
+
if (index === -1) {
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
model.methods.splice(index, 1);
|
|
1255
|
+
},
|
|
1256
|
+
submitCode: (values) => {
|
|
1257
|
+
if (!dataSource.value)
|
|
1258
|
+
return;
|
|
1259
|
+
if (!dataSource.value.methods) {
|
|
1260
|
+
dataSource.value.methods = [];
|
|
1261
|
+
}
|
|
1262
|
+
if (values.content) {
|
|
1263
|
+
const parseDSL = getConfig("parseDSL");
|
|
1264
|
+
if (typeof values.content === "string") {
|
|
1265
|
+
values.content = parseDSL(values.content);
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
if (dataSourceMethod.value) {
|
|
1269
|
+
const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
|
|
1270
|
+
dataSource.value.methods.splice(index, 1, values);
|
|
1271
|
+
} else {
|
|
1272
|
+
dataSource.value.methods.push(values);
|
|
1273
|
+
}
|
|
1274
|
+
codeBlockEditor.value?.hide();
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
};
|
|
1278
|
+
|
|
1279
|
+
const _hoisted_1$m = { class: "m-editor-data-source-methods" };
|
|
1280
|
+
const _hoisted_2$c = { class: "m-editor-data-source-methods-footer" };
|
|
1281
|
+
const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
1282
|
+
...{
|
|
1283
|
+
name: "MEditorDataSourceMethods"
|
|
1284
|
+
},
|
|
1285
|
+
__name: "DataSourceMethods",
|
|
1286
|
+
props: {
|
|
1287
|
+
config: {},
|
|
1288
|
+
model: {},
|
|
1289
|
+
prop: {},
|
|
1290
|
+
lastValues: {},
|
|
1291
|
+
disabled: { type: Boolean, default: false },
|
|
1292
|
+
name: {}
|
|
1293
|
+
},
|
|
1294
|
+
emits: ["change"],
|
|
1295
|
+
setup(__props, { emit }) {
|
|
1296
|
+
const props = __props;
|
|
1297
|
+
const { codeConfig, codeBlockEditor, createCode, editCode, deleteCode, submitCode } = useDataSourceMethod();
|
|
1298
|
+
const methodColumns = [
|
|
1299
|
+
{
|
|
1300
|
+
label: "名称",
|
|
1301
|
+
prop: "name"
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
label: "注释",
|
|
1305
|
+
prop: "desc"
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
label: "参数",
|
|
1309
|
+
prop: "params",
|
|
1310
|
+
formatter: (params) => params.map((item) => item.name).join(", ")
|
|
1311
|
+
},
|
|
1312
|
+
{
|
|
1313
|
+
label: "操作",
|
|
1314
|
+
fixed: "right",
|
|
1315
|
+
actions: [
|
|
1316
|
+
{
|
|
1317
|
+
text: "编辑",
|
|
1318
|
+
handler: (row) => {
|
|
1319
|
+
editCode(props.model, row.name);
|
|
1320
|
+
emit("change", props.model[props.name]);
|
|
1321
|
+
}
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
text: "删除",
|
|
1325
|
+
buttonType: "danger",
|
|
1326
|
+
handler: (row) => {
|
|
1327
|
+
deleteCode(props.model, row.name);
|
|
1328
|
+
emit("change", props.model[props.name]);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
]
|
|
1332
|
+
}
|
|
1333
|
+
];
|
|
1334
|
+
const createCodeHandler = () => {
|
|
1335
|
+
createCode(props.model);
|
|
1336
|
+
emit("change", props.model[props.name]);
|
|
1337
|
+
};
|
|
1338
|
+
const submitCodeHandler = (values) => {
|
|
1339
|
+
submitCode(values);
|
|
1340
|
+
emit("change", props.model[props.name]);
|
|
1341
|
+
};
|
|
1342
|
+
return (_ctx, _cache) => {
|
|
1343
|
+
return openBlock(), createElementBlock("div", _hoisted_1$m, [
|
|
1344
|
+
createVNode(unref(MagicTable), {
|
|
1345
|
+
data: _ctx.model[_ctx.name],
|
|
1346
|
+
columns: methodColumns
|
|
1347
|
+
}, null, 8, ["data"]),
|
|
1348
|
+
createElementVNode("div", _hoisted_2$c, [
|
|
1349
|
+
createVNode(unref(TMagicButton), {
|
|
1350
|
+
size: "small",
|
|
1351
|
+
type: "primary",
|
|
1352
|
+
disabled: _ctx.disabled,
|
|
1353
|
+
plain: "",
|
|
1354
|
+
onClick: createCodeHandler
|
|
1355
|
+
}, {
|
|
1356
|
+
default: withCtx(() => [
|
|
1357
|
+
createTextVNode("添加")
|
|
1358
|
+
]),
|
|
1359
|
+
_: 1
|
|
1360
|
+
}, 8, ["disabled"])
|
|
1361
|
+
]),
|
|
1362
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$G, {
|
|
1363
|
+
key: 0,
|
|
1364
|
+
ref_key: "codeBlockEditor",
|
|
1365
|
+
ref: codeBlockEditor,
|
|
1366
|
+
disabled: _ctx.disabled,
|
|
1367
|
+
content: unref(codeConfig),
|
|
1368
|
+
onSubmit: submitCodeHandler
|
|
1369
|
+
}, null, 8, ["disabled", "content"])) : createCommentVNode("", true)
|
|
1370
|
+
]);
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
});
|
|
1374
|
+
|
|
1375
|
+
const _hoisted_1$l = { class: "m-fields-data-source-method-select" };
|
|
1376
|
+
const _hoisted_2$b = { class: "data-source-method-select-container" };
|
|
1377
|
+
const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
1378
|
+
...{
|
|
1379
|
+
name: "MEditorDataSourceMethodSelect"
|
|
1380
|
+
},
|
|
1381
|
+
__name: "DataSourceMethodSelect",
|
|
1382
|
+
props: {
|
|
1383
|
+
config: {},
|
|
1384
|
+
model: {},
|
|
1385
|
+
lastValues: {},
|
|
1386
|
+
prop: {},
|
|
1387
|
+
name: {},
|
|
1388
|
+
disabled: { type: Boolean, default: false },
|
|
1389
|
+
size: {}
|
|
1390
|
+
},
|
|
1391
|
+
emits: ["change"],
|
|
1392
|
+
setup(__props, { emit }) {
|
|
1393
|
+
const props = __props;
|
|
1394
|
+
const services = inject("services");
|
|
1395
|
+
const dataSources = computed(() => services?.dataSourceService.get("dataSources"));
|
|
1396
|
+
const getParamItemsConfig = ([dataSourceId, medthodName] = ["", ""]) => {
|
|
1397
|
+
if (!dataSourceId)
|
|
1398
|
+
return [];
|
|
1399
|
+
const paramStatements = dataSources.value?.find((item) => item.id === dataSourceId)?.methods?.find((item) => item.name === medthodName)?.params;
|
|
1400
|
+
if (!paramStatements)
|
|
1401
|
+
return [];
|
|
1402
|
+
return paramStatements.map((paramState) => ({
|
|
1403
|
+
labelWidth: "100px",
|
|
1404
|
+
text: paramState.name,
|
|
1405
|
+
...paramState
|
|
1406
|
+
}));
|
|
1407
|
+
};
|
|
1408
|
+
const paramsConfig = ref(getParamItemsConfig(props.model.dataSourceMethod));
|
|
1409
|
+
const setParamsConfig = (dataSourceMethod, formState = {}) => {
|
|
1410
|
+
paramsConfig.value = dataSourceMethod ? getParamItemsConfig(dataSourceMethod) : [];
|
|
1411
|
+
if (paramsConfig.value.length) {
|
|
1412
|
+
props.model.params = createValues(formState, paramsConfig.value, {}, props.model.params);
|
|
1413
|
+
} else {
|
|
1414
|
+
props.model.params = {};
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
const cascaderConfig = {
|
|
1418
|
+
type: "cascader",
|
|
1419
|
+
text: "数据源方法",
|
|
1420
|
+
name: props.name,
|
|
1421
|
+
labelWidth: "80px",
|
|
1422
|
+
options: () => dataSources.value?.filter((ds) => ds.methods?.length)?.map((ds) => ({
|
|
1423
|
+
label: `${ds.title}(${ds.id})`,
|
|
1424
|
+
value: ds.id,
|
|
1425
|
+
children: ds.methods?.map((method) => ({
|
|
1426
|
+
label: method.name,
|
|
1427
|
+
value: method.name
|
|
1428
|
+
}))
|
|
1429
|
+
})) || [],
|
|
1430
|
+
onChange: (formState, dataSourceMethod) => {
|
|
1431
|
+
setParamsConfig(dataSourceMethod, formState);
|
|
1432
|
+
return dataSourceMethod;
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
const onChangeHandler = (value) => {
|
|
1436
|
+
props.model.params = value.params;
|
|
1437
|
+
emit("change", props.model);
|
|
1438
|
+
};
|
|
1439
|
+
const { codeBlockEditor, codeConfig, editCode, submitCode } = useDataSourceMethod();
|
|
1440
|
+
const editCodeHandler = () => {
|
|
1441
|
+
const [id, name] = props.model[props.name];
|
|
1442
|
+
const dataSource = services?.dataSourceService.getDataSourceById(id);
|
|
1443
|
+
if (!dataSource)
|
|
1444
|
+
return;
|
|
1445
|
+
editCode(dataSource, name);
|
|
1446
|
+
setParamsConfig([id, name]);
|
|
1447
|
+
};
|
|
1448
|
+
const submitCodeBlockHandler = (value) => {
|
|
1449
|
+
submitCode(value);
|
|
1450
|
+
};
|
|
1451
|
+
return (_ctx, _cache) => {
|
|
1452
|
+
const _component_m_form_container = resolveComponent("m-form-container");
|
|
1453
|
+
return openBlock(), createElementBlock("div", _hoisted_1$l, [
|
|
1454
|
+
createElementVNode("div", _hoisted_2$b, [
|
|
1455
|
+
createVNode(_component_m_form_container, {
|
|
1456
|
+
class: "select",
|
|
1457
|
+
config: cascaderConfig,
|
|
1458
|
+
model: _ctx.model,
|
|
1459
|
+
onChange: onChangeHandler
|
|
1460
|
+
}, null, 8, ["model"]),
|
|
1461
|
+
_ctx.model[_ctx.name] ? (openBlock(), createBlock(_sfc_main$E, {
|
|
1462
|
+
key: 0,
|
|
1463
|
+
class: "icon",
|
|
1464
|
+
icon: !_ctx.disabled ? unref(Edit) : unref(View),
|
|
1465
|
+
onClick: editCodeHandler
|
|
1466
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true)
|
|
1467
|
+
]),
|
|
1468
|
+
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$F, {
|
|
1469
|
+
key: 0,
|
|
1470
|
+
name: "params",
|
|
1471
|
+
model: _ctx.model,
|
|
745
1472
|
size: _ctx.size,
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
})
|
|
750
|
-
{
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
createVNode(_sfc_main$E, { icon: unref(Coin) }, null, 8, ["icon"])
|
|
760
|
-
]),
|
|
761
|
-
default: withCtx(({ item }) => [
|
|
762
|
-
createElementVNode("div", _hoisted_1$n, [
|
|
763
|
-
createElementVNode("div", null, toDisplayString(item.text), 1),
|
|
764
|
-
createElementVNode("span", _hoisted_2$d, toDisplayString(item.value), 1)
|
|
765
|
-
])
|
|
766
|
-
]),
|
|
767
|
-
_: 1
|
|
768
|
-
}, 16, ["modelValue"])) : (openBlock(), createElementBlock("div", {
|
|
769
|
-
key: 1,
|
|
770
|
-
class: normalizeClass(`tmagic-data-source-input-text el-input el-input--${_ctx.size}`),
|
|
771
|
-
onMouseup: mouseupHandler
|
|
772
|
-
}, [
|
|
773
|
-
createElementVNode("div", {
|
|
774
|
-
class: normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
|
|
775
|
-
}, [
|
|
776
|
-
createElementVNode("div", _hoisted_3$6, [
|
|
777
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(displayState.value, (item, index) => {
|
|
778
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
779
|
-
item.type === "text" ? (openBlock(), createElementBlock("span", {
|
|
780
|
-
key: index,
|
|
781
|
-
style: { "margin-right": "2px" }
|
|
782
|
-
}, toDisplayString(item.value), 1)) : createCommentVNode("", true),
|
|
783
|
-
item.type === "var" ? (openBlock(), createBlock(unref(TMagicTag), {
|
|
784
|
-
key: index,
|
|
785
|
-
size: _ctx.size
|
|
786
|
-
}, {
|
|
787
|
-
default: withCtx(() => [
|
|
788
|
-
createTextVNode(toDisplayString(item.value), 1)
|
|
789
|
-
]),
|
|
790
|
-
_: 2
|
|
791
|
-
}, 1032, ["size"])) : createCommentVNode("", true)
|
|
792
|
-
], 64);
|
|
793
|
-
}), 256)),
|
|
794
|
-
createVNode(_sfc_main$E, {
|
|
795
|
-
class: "tmagic-data-source-input-icon",
|
|
796
|
-
icon: unref(Coin)
|
|
797
|
-
}, null, 8, ["icon"])
|
|
798
|
-
])
|
|
799
|
-
], 2)
|
|
800
|
-
], 34));
|
|
1473
|
+
disabled: _ctx.disabled,
|
|
1474
|
+
"params-config": paramsConfig.value,
|
|
1475
|
+
onChange: onChangeHandler
|
|
1476
|
+
}, null, 8, ["model", "size", "disabled", "params-config"])) : createCommentVNode("", true),
|
|
1477
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$G, {
|
|
1478
|
+
key: 1,
|
|
1479
|
+
ref_key: "codeBlockEditor",
|
|
1480
|
+
ref: codeBlockEditor,
|
|
1481
|
+
disabled: _ctx.disabled,
|
|
1482
|
+
content: unref(codeConfig),
|
|
1483
|
+
onSubmit: submitCodeBlockHandler
|
|
1484
|
+
}, null, 8, ["disabled", "content"])) : createCommentVNode("", true)
|
|
1485
|
+
]);
|
|
801
1486
|
};
|
|
802
1487
|
}
|
|
803
1488
|
});
|
|
804
1489
|
|
|
805
|
-
const _sfc_main$
|
|
1490
|
+
const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
806
1491
|
...{
|
|
807
1492
|
name: "MEditorDataSourceSelect"
|
|
808
1493
|
},
|
|
@@ -855,12 +1540,12 @@ const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
|
855
1540
|
}
|
|
856
1541
|
});
|
|
857
1542
|
|
|
858
|
-
const _hoisted_1$
|
|
859
|
-
const _hoisted_2$
|
|
1543
|
+
const _hoisted_1$k = { class: "m-fields-event-select" };
|
|
1544
|
+
const _hoisted_2$a = {
|
|
860
1545
|
key: 1,
|
|
861
1546
|
class: "fullWidth"
|
|
862
1547
|
};
|
|
863
|
-
const _sfc_main$
|
|
1548
|
+
const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
864
1549
|
...{
|
|
865
1550
|
name: "MEditorEventSelect"
|
|
866
1551
|
},
|
|
@@ -893,7 +1578,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
893
1578
|
const defaultActionTypeConfig = {
|
|
894
1579
|
name: "actionType",
|
|
895
1580
|
text: "联动类型",
|
|
896
|
-
labelWidth: "
|
|
1581
|
+
labelWidth: "80px",
|
|
897
1582
|
type: "select",
|
|
898
1583
|
defaultValue: ActionType.COMP,
|
|
899
1584
|
options: () => [
|
|
@@ -905,7 +1590,14 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
905
1590
|
{
|
|
906
1591
|
text: "代码",
|
|
907
1592
|
label: "代码",
|
|
1593
|
+
disabled: !Object.keys(services?.codeBlockService.getCodeDsl() || {}).length,
|
|
908
1594
|
value: ActionType.CODE
|
|
1595
|
+
},
|
|
1596
|
+
{
|
|
1597
|
+
text: "数据源",
|
|
1598
|
+
label: "数据源",
|
|
1599
|
+
disabled: !services?.dataSourceService.get("dataSources")?.filter((ds) => ds.methods?.length).length,
|
|
1600
|
+
value: ActionType.DATA_SOURCE
|
|
909
1601
|
}
|
|
910
1602
|
]
|
|
911
1603
|
};
|
|
@@ -915,7 +1607,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
915
1607
|
const defaultTargetCompConfig = {
|
|
916
1608
|
name: "to",
|
|
917
1609
|
text: "联动组件",
|
|
918
|
-
labelWidth: "
|
|
1610
|
+
labelWidth: "80px",
|
|
919
1611
|
type: "ui-select",
|
|
920
1612
|
display: (mForm, { model }) => model.actionType === ActionType.COMP
|
|
921
1613
|
};
|
|
@@ -925,7 +1617,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
925
1617
|
const defaultCompActionConfig = {
|
|
926
1618
|
name: "method",
|
|
927
1619
|
text: "动作",
|
|
928
|
-
labelWidth: "
|
|
1620
|
+
labelWidth: "80px",
|
|
929
1621
|
type: "select",
|
|
930
1622
|
display: (mForm, { model }) => model.actionType === ActionType.COMP,
|
|
931
1623
|
options: (mForm, { model }) => {
|
|
@@ -944,10 +1636,21 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
944
1636
|
const defaultCodeActionConfig = {
|
|
945
1637
|
type: "code-select-col",
|
|
946
1638
|
labelWidth: 0,
|
|
1639
|
+
name: "codeId",
|
|
1640
|
+
disabled: () => !services?.codeBlockService.getEditStatus(),
|
|
947
1641
|
display: (mForm, { model }) => model.actionType === ActionType.CODE
|
|
948
1642
|
};
|
|
949
1643
|
return { ...defaultCodeActionConfig, ...props.config.codeActionConfig };
|
|
950
1644
|
});
|
|
1645
|
+
const dataSourceActionConfig = computed(() => {
|
|
1646
|
+
const defaultDataSourceActionConfig = {
|
|
1647
|
+
type: "data-source-method-select",
|
|
1648
|
+
name: "dataSourceMethod",
|
|
1649
|
+
labelWidth: 0,
|
|
1650
|
+
display: (mForm, { model }) => model.actionType === ActionType.DATA_SOURCE
|
|
1651
|
+
};
|
|
1652
|
+
return { ...defaultDataSourceActionConfig, ...props.config.dataSourceActionConfig };
|
|
1653
|
+
});
|
|
951
1654
|
const tableConfig = computed(() => ({
|
|
952
1655
|
type: "table",
|
|
953
1656
|
name: "events",
|
|
@@ -989,7 +1692,13 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
989
1692
|
name: "actions",
|
|
990
1693
|
expandAll: true,
|
|
991
1694
|
enableToggleMode: false,
|
|
992
|
-
items: [
|
|
1695
|
+
items: [
|
|
1696
|
+
actionTypeConfig.value,
|
|
1697
|
+
targetCompConfig.value,
|
|
1698
|
+
compActionConfig.value,
|
|
1699
|
+
codeActionConfig.value,
|
|
1700
|
+
dataSourceActionConfig.value
|
|
1701
|
+
]
|
|
993
1702
|
}
|
|
994
1703
|
]
|
|
995
1704
|
}));
|
|
@@ -1022,7 +1731,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
1022
1731
|
const _component_m_form_table = resolveComponent("m-form-table");
|
|
1023
1732
|
const _component_m_form_container = resolveComponent("m-form-container");
|
|
1024
1733
|
const _component_m_form_panel = resolveComponent("m-form-panel");
|
|
1025
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
1734
|
+
return openBlock(), createElementBlock("div", _hoisted_1$k, [
|
|
1026
1735
|
isOldVersion.value ? (openBlock(), createBlock(_component_m_form_table, {
|
|
1027
1736
|
key: 0,
|
|
1028
1737
|
ref: "eventForm",
|
|
@@ -1031,7 +1740,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
1031
1740
|
name: "events",
|
|
1032
1741
|
config: tableConfig.value,
|
|
1033
1742
|
onChange: onChangeHandler
|
|
1034
|
-
}, null, 8, ["size", "model", "config"])) : (openBlock(), createElementBlock("div", _hoisted_2$
|
|
1743
|
+
}, null, 8, ["size", "model", "config"])) : (openBlock(), createElementBlock("div", _hoisted_2$a, [
|
|
1035
1744
|
createVNode(unref(TMagicButton), {
|
|
1036
1745
|
class: "create-button",
|
|
1037
1746
|
type: "primary",
|
|
@@ -1073,9 +1782,9 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
|
1073
1782
|
}
|
|
1074
1783
|
});
|
|
1075
1784
|
|
|
1076
|
-
const _hoisted_1$
|
|
1077
|
-
const _hoisted_2$
|
|
1078
|
-
const _sfc_main$
|
|
1785
|
+
const _hoisted_1$j = { class: "m-fields-key-value" };
|
|
1786
|
+
const _hoisted_2$9 = /* @__PURE__ */ createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
|
|
1787
|
+
const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
1079
1788
|
...{
|
|
1080
1789
|
name: "MEditorKeyValue"
|
|
1081
1790
|
},
|
|
@@ -1118,7 +1827,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
1118
1827
|
records.value.splice(index, 1);
|
|
1119
1828
|
};
|
|
1120
1829
|
return (_ctx, _cache) => {
|
|
1121
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
1830
|
+
return openBlock(), createElementBlock("div", _hoisted_1$j, [
|
|
1122
1831
|
(openBlock(true), createElementBlock(Fragment, null, renderList(records.value, (item, index) => {
|
|
1123
1832
|
return openBlock(), createElementBlock("div", {
|
|
1124
1833
|
class: "m-fields-key-value-item",
|
|
@@ -1132,7 +1841,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
1132
1841
|
size: _ctx.size,
|
|
1133
1842
|
onChange: keyChangeHandler
|
|
1134
1843
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "disabled", "size"]),
|
|
1135
|
-
_hoisted_2$
|
|
1844
|
+
_hoisted_2$9,
|
|
1136
1845
|
createVNode(unref(TMagicInput), {
|
|
1137
1846
|
placeholder: "value",
|
|
1138
1847
|
modelValue: records.value[index][1],
|
|
@@ -1169,12 +1878,12 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
1169
1878
|
}
|
|
1170
1879
|
});
|
|
1171
1880
|
|
|
1172
|
-
const _hoisted_1$
|
|
1881
|
+
const _hoisted_1$i = {
|
|
1173
1882
|
key: 1,
|
|
1174
1883
|
class: "m-fields-ui-select",
|
|
1175
1884
|
style: { "display": "flex" }
|
|
1176
1885
|
};
|
|
1177
|
-
const _sfc_main$
|
|
1886
|
+
const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
1178
1887
|
...{
|
|
1179
1888
|
name: "MEditorUISelect"
|
|
1180
1889
|
},
|
|
@@ -1256,7 +1965,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
1256
1965
|
]),
|
|
1257
1966
|
_: 1
|
|
1258
1967
|
}, 8, ["icon"])
|
|
1259
|
-
])) : (openBlock(), createElementBlock("div", _hoisted_1$
|
|
1968
|
+
])) : (openBlock(), createElementBlock("div", _hoisted_1$i, [
|
|
1260
1969
|
val.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
1261
1970
|
createVNode(unref(TMagicTooltip), {
|
|
1262
1971
|
content: "清除",
|
|
@@ -1296,174 +2005,30 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
1296
2005
|
], 64)) : (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
1297
2006
|
key: 1,
|
|
1298
2007
|
content: "点击此处选择",
|
|
1299
|
-
placement: "top"
|
|
1300
|
-
}, {
|
|
1301
|
-
default: withCtx(() => [
|
|
1302
|
-
createVNode(unref(TMagicButton), {
|
|
1303
|
-
text: "",
|
|
1304
|
-
style: { "padding": "0", "margin": "0" },
|
|
1305
|
-
onClick: startSelect
|
|
1306
|
-
}, {
|
|
1307
|
-
default: withCtx(() => [
|
|
1308
|
-
createTextVNode("点击此处选择")
|
|
1309
|
-
]),
|
|
1310
|
-
_: 1
|
|
1311
|
-
})
|
|
1312
|
-
]),
|
|
1313
|
-
_: 1
|
|
1314
|
-
}))
|
|
1315
|
-
]));
|
|
1316
|
-
};
|
|
1317
|
-
}
|
|
1318
|
-
});
|
|
1319
|
-
|
|
1320
|
-
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
1321
|
-
|
|
1322
|
-
const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
1323
|
-
...{
|
|
1324
|
-
name: "MEditorCodeEditor"
|
|
1325
|
-
},
|
|
1326
|
-
__name: "CodeEditor",
|
|
1327
|
-
props: {
|
|
1328
|
-
initValues: {},
|
|
1329
|
-
modifiedValues: {},
|
|
1330
|
-
type: {},
|
|
1331
|
-
language: { default: "javascript" },
|
|
1332
|
-
options: { default: () => ({
|
|
1333
|
-
tabSize: 2
|
|
1334
|
-
}) },
|
|
1335
|
-
autoSave: { type: Boolean, default: true }
|
|
1336
|
-
},
|
|
1337
|
-
emits: ["initd", "save"],
|
|
1338
|
-
setup(__props, { expose: __expose, emit }) {
|
|
1339
|
-
const props = __props;
|
|
1340
|
-
const toString = (v, language) => {
|
|
1341
|
-
let value = "";
|
|
1342
|
-
if (typeof v !== "string") {
|
|
1343
|
-
if (props.language.toLocaleLowerCase() === "json") {
|
|
1344
|
-
value = JSON.stringify(v, null, 2);
|
|
1345
|
-
} else {
|
|
1346
|
-
value = serialize(v, {
|
|
1347
|
-
space: 2,
|
|
1348
|
-
unsafe: true
|
|
1349
|
-
}).replace(/"(\w+)":\s/g, "$1: ");
|
|
1350
|
-
}
|
|
1351
|
-
} else {
|
|
1352
|
-
value = v;
|
|
1353
|
-
}
|
|
1354
|
-
if (language === "javascript" && value.startsWith("{") && value.endsWith("}")) {
|
|
1355
|
-
value = `(${value})`;
|
|
1356
|
-
}
|
|
1357
|
-
return value;
|
|
1358
|
-
};
|
|
1359
|
-
let vsEditor = null;
|
|
1360
|
-
let vsDiffEditor = null;
|
|
1361
|
-
const values = ref("");
|
|
1362
|
-
const loading = ref(false);
|
|
1363
|
-
const codeEditor = ref();
|
|
1364
|
-
const resizeObserver = new globalThis.ResizeObserver(
|
|
1365
|
-
throttle(() => {
|
|
1366
|
-
vsEditor?.layout();
|
|
1367
|
-
vsDiffEditor?.layout();
|
|
1368
|
-
}, 300)
|
|
1369
|
-
);
|
|
1370
|
-
const setEditorValue = (v, m) => {
|
|
1371
|
-
values.value = toString(v, props.language);
|
|
1372
|
-
if (props.type === "diff") {
|
|
1373
|
-
const originalModel = monaco.editor.createModel(values.value, "text/javascript");
|
|
1374
|
-
const modifiedModel = monaco.editor.createModel(toString(m, props.language), "text/javascript");
|
|
1375
|
-
return vsDiffEditor?.setModel({
|
|
1376
|
-
original: originalModel,
|
|
1377
|
-
modified: modifiedModel
|
|
1378
|
-
});
|
|
1379
|
-
}
|
|
1380
|
-
return vsEditor?.setValue(values.value);
|
|
1381
|
-
};
|
|
1382
|
-
const getEditorValue = () => (props.type === "diff" ? vsDiffEditor?.getModifiedEditor().getValue() : vsEditor?.getValue()) || "";
|
|
1383
|
-
const init = async () => {
|
|
1384
|
-
if (!codeEditor.value)
|
|
1385
|
-
return;
|
|
1386
|
-
const options = {
|
|
1387
|
-
value: values.value,
|
|
1388
|
-
language: props.language,
|
|
1389
|
-
theme: "vs-dark",
|
|
1390
|
-
...props.options
|
|
1391
|
-
};
|
|
1392
|
-
if (props.type === "diff") {
|
|
1393
|
-
vsDiffEditor = monaco.editor.createDiffEditor(codeEditor.value, options);
|
|
1394
|
-
} else {
|
|
1395
|
-
vsEditor = monaco.editor.create(codeEditor.value, options);
|
|
1396
|
-
}
|
|
1397
|
-
setEditorValue(props.initValues, props.modifiedValues);
|
|
1398
|
-
loading.value = false;
|
|
1399
|
-
emit("initd", vsEditor);
|
|
1400
|
-
codeEditor.value.addEventListener("keydown", (e) => {
|
|
1401
|
-
if (e.keyCode === 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
|
|
1402
|
-
e.preventDefault();
|
|
1403
|
-
e.stopPropagation();
|
|
1404
|
-
const newValue = getEditorValue();
|
|
1405
|
-
values.value = newValue;
|
|
1406
|
-
emit("save", newValue);
|
|
1407
|
-
}
|
|
1408
|
-
});
|
|
1409
|
-
if (props.type !== "diff" && props.autoSave) {
|
|
1410
|
-
vsEditor?.onDidBlurEditorWidget(() => {
|
|
1411
|
-
const newValue = getEditorValue();
|
|
1412
|
-
if (values.value !== newValue) {
|
|
1413
|
-
values.value = newValue;
|
|
1414
|
-
emit("save", newValue);
|
|
1415
|
-
}
|
|
1416
|
-
});
|
|
1417
|
-
}
|
|
1418
|
-
resizeObserver.observe(codeEditor.value);
|
|
1419
|
-
};
|
|
1420
|
-
watch(
|
|
1421
|
-
() => props.initValues,
|
|
1422
|
-
(v, preV) => {
|
|
1423
|
-
if (v !== preV) {
|
|
1424
|
-
setEditorValue(props.initValues, props.modifiedValues);
|
|
1425
|
-
}
|
|
1426
|
-
},
|
|
1427
|
-
{
|
|
1428
|
-
deep: true,
|
|
1429
|
-
immediate: true
|
|
1430
|
-
}
|
|
1431
|
-
);
|
|
1432
|
-
onMounted(async () => {
|
|
1433
|
-
loading.value = true;
|
|
1434
|
-
init();
|
|
1435
|
-
});
|
|
1436
|
-
onUnmounted(() => {
|
|
1437
|
-
resizeObserver.disconnect();
|
|
1438
|
-
});
|
|
1439
|
-
__expose({
|
|
1440
|
-
values,
|
|
1441
|
-
getEditor() {
|
|
1442
|
-
return vsEditor || vsDiffEditor;
|
|
1443
|
-
},
|
|
1444
|
-
getVsEditor() {
|
|
1445
|
-
return vsEditor;
|
|
1446
|
-
},
|
|
1447
|
-
getVsDiffEditor() {
|
|
1448
|
-
return vsDiffEditor;
|
|
1449
|
-
},
|
|
1450
|
-
setEditorValue,
|
|
1451
|
-
focus() {
|
|
1452
|
-
vsEditor?.focus();
|
|
1453
|
-
vsDiffEditor?.focus();
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
return (_ctx, _cache) => {
|
|
1457
|
-
return openBlock(), createElementBlock("div", {
|
|
1458
|
-
ref_key: "codeEditor",
|
|
1459
|
-
ref: codeEditor,
|
|
1460
|
-
class: "magic-code-editor"
|
|
1461
|
-
}, null, 512);
|
|
2008
|
+
placement: "top"
|
|
2009
|
+
}, {
|
|
2010
|
+
default: withCtx(() => [
|
|
2011
|
+
createVNode(unref(TMagicButton), {
|
|
2012
|
+
text: "",
|
|
2013
|
+
style: { "padding": "0", "margin": "0" },
|
|
2014
|
+
onClick: startSelect
|
|
2015
|
+
}, {
|
|
2016
|
+
default: withCtx(() => [
|
|
2017
|
+
createTextVNode("点击此处选择")
|
|
2018
|
+
]),
|
|
2019
|
+
_: 1
|
|
2020
|
+
})
|
|
2021
|
+
]),
|
|
2022
|
+
_: 1
|
|
2023
|
+
}))
|
|
2024
|
+
]));
|
|
1462
2025
|
};
|
|
1463
2026
|
}
|
|
1464
2027
|
});
|
|
1465
2028
|
|
|
1466
|
-
const
|
|
2029
|
+
const UISelect_vue_vue_type_style_index_0_lang = '';
|
|
2030
|
+
|
|
2031
|
+
const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
1467
2032
|
...{
|
|
1468
2033
|
name: "MEditorResizer"
|
|
1469
2034
|
},
|
|
@@ -1505,7 +2070,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
1505
2070
|
}
|
|
1506
2071
|
});
|
|
1507
2072
|
|
|
1508
|
-
const _sfc_main$
|
|
2073
|
+
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
1509
2074
|
...{
|
|
1510
2075
|
name: "MEditorLayout"
|
|
1511
2076
|
},
|
|
@@ -1617,7 +2182,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1617
2182
|
}, [
|
|
1618
2183
|
renderSlot(_ctx.$slots, "left")
|
|
1619
2184
|
], 6),
|
|
1620
|
-
createVNode(_sfc_main$
|
|
2185
|
+
createVNode(_sfc_main$u, { onChange: changeLeft })
|
|
1621
2186
|
], 64)) : createCommentVNode("", true),
|
|
1622
2187
|
createElementVNode("div", {
|
|
1623
2188
|
class: normalizeClass(["m-editor-layout-center", _ctx.centerClass]),
|
|
@@ -1626,7 +2191,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
1626
2191
|
renderSlot(_ctx.$slots, "center")
|
|
1627
2192
|
], 6),
|
|
1628
2193
|
hasRight.value && _ctx.$slots.right ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
1629
|
-
createVNode(_sfc_main$
|
|
2194
|
+
createVNode(_sfc_main$u, { onChange: changeRight }),
|
|
1630
2195
|
createElementVNode("div", {
|
|
1631
2196
|
class: normalizeClass(["m-editor-layout-right", _ctx.rightClass]),
|
|
1632
2197
|
style: normalizeStyle(`width: ${_ctx.right}px`)
|
|
@@ -3549,10 +4114,10 @@ const useStage = (stageOptions) => {
|
|
|
3549
4114
|
return stage;
|
|
3550
4115
|
};
|
|
3551
4116
|
|
|
3552
|
-
const _hoisted_1$
|
|
3553
|
-
const _hoisted_2$
|
|
3554
|
-
const _hoisted_3$
|
|
3555
|
-
const _sfc_main$
|
|
4117
|
+
const _hoisted_1$h = { class: "m-editor-empty-panel" };
|
|
4118
|
+
const _hoisted_2$8 = { class: "m-editor-empty-content" };
|
|
4119
|
+
const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面", -1);
|
|
4120
|
+
const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
3556
4121
|
...{
|
|
3557
4122
|
name: "MEditorAddPageBox"
|
|
3558
4123
|
},
|
|
@@ -3572,8 +4137,8 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
3572
4137
|
});
|
|
3573
4138
|
};
|
|
3574
4139
|
return (_ctx, _cache) => {
|
|
3575
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
3576
|
-
createElementVNode("div", _hoisted_2$
|
|
4140
|
+
return openBlock(), createElementBlock("div", _hoisted_1$h, [
|
|
4141
|
+
createElementVNode("div", _hoisted_2$8, [
|
|
3577
4142
|
createElementVNode("div", {
|
|
3578
4143
|
class: "m-editor-empty-button",
|
|
3579
4144
|
onClick: clickHandler
|
|
@@ -3581,7 +4146,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
3581
4146
|
createElementVNode("div", null, [
|
|
3582
4147
|
createVNode(_sfc_main$E, { icon: unref(Plus) }, null, 8, ["icon"])
|
|
3583
4148
|
]),
|
|
3584
|
-
_hoisted_3$
|
|
4149
|
+
_hoisted_3$4
|
|
3585
4150
|
])
|
|
3586
4151
|
])
|
|
3587
4152
|
]);
|
|
@@ -3589,12 +4154,11 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
3589
4154
|
}
|
|
3590
4155
|
});
|
|
3591
4156
|
|
|
3592
|
-
const _hoisted_1$i = { class: "m-editor" };
|
|
3593
4157
|
const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
3594
4158
|
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
3595
4159
|
const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
|
|
3596
4160
|
const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
|
|
3597
|
-
const _sfc_main$
|
|
4161
|
+
const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
3598
4162
|
...{
|
|
3599
4163
|
name: "MEditorFramework"
|
|
3600
4164
|
},
|
|
@@ -3602,6 +4166,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
3602
4166
|
setup(__props) {
|
|
3603
4167
|
const codeOptions = inject("codeOptions", {});
|
|
3604
4168
|
const { editorService, uiService } = inject("services") || {};
|
|
4169
|
+
const content = ref();
|
|
3605
4170
|
const root = computed(() => editorService?.get("root"));
|
|
3606
4171
|
const pageLength = computed(() => editorService?.get("pageLength") || 0);
|
|
3607
4172
|
const showSrc = computed(() => uiService?.get("showSrc"));
|
|
@@ -3617,13 +4182,14 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
3617
4182
|
(length) => {
|
|
3618
4183
|
const left = columnWidth.value.left || DEFAULT_LEFT_COLUMN_WIDTH;
|
|
3619
4184
|
columnWidth.value.left = left;
|
|
4185
|
+
const container = content.value || document.body;
|
|
3620
4186
|
if (length <= 0) {
|
|
3621
4187
|
columnWidth.value.right = void 0;
|
|
3622
|
-
columnWidth.value.center =
|
|
4188
|
+
columnWidth.value.center = container.clientWidth - left;
|
|
3623
4189
|
} else {
|
|
3624
4190
|
const right = columnWidth.value.right || RightColumnWidthCacheData || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
3625
4191
|
columnWidth.value.right = right;
|
|
3626
|
-
columnWidth.value.center =
|
|
4192
|
+
columnWidth.value.center = container.clientWidth - left - right;
|
|
3627
4193
|
}
|
|
3628
4194
|
uiService?.set("columnWidth", columnWidth.value);
|
|
3629
4195
|
},
|
|
@@ -3660,18 +4226,22 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
3660
4226
|
}
|
|
3661
4227
|
};
|
|
3662
4228
|
return (_ctx, _cache) => {
|
|
3663
|
-
return openBlock(), createElementBlock("div",
|
|
4229
|
+
return openBlock(), createElementBlock("div", {
|
|
4230
|
+
class: "m-editor",
|
|
4231
|
+
ref_key: "content",
|
|
4232
|
+
ref: content
|
|
4233
|
+
}, [
|
|
3664
4234
|
renderSlot(_ctx.$slots, "header"),
|
|
3665
4235
|
renderSlot(_ctx.$slots, "nav"),
|
|
3666
4236
|
renderSlot(_ctx.$slots, "content-before"),
|
|
3667
4237
|
showSrc.value ? renderSlot(_ctx.$slots, "src-code", { key: 0 }, () => [
|
|
3668
|
-
createVNode(_sfc_main$
|
|
4238
|
+
createVNode(_sfc_main$K, {
|
|
3669
4239
|
class: "m-editor-content",
|
|
3670
4240
|
"init-values": root.value,
|
|
3671
4241
|
options: unref(codeOptions),
|
|
3672
4242
|
onSave: saveCode
|
|
3673
4243
|
}, null, 8, ["init-values", "options"])
|
|
3674
|
-
]) : (openBlock(), createBlock(_sfc_main$
|
|
4244
|
+
]) : (openBlock(), createBlock(_sfc_main$t, {
|
|
3675
4245
|
key: 1,
|
|
3676
4246
|
class: "m-editor-content",
|
|
3677
4247
|
"left-class": "m-editor-framework-left",
|
|
@@ -3690,7 +4260,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
3690
4260
|
]),
|
|
3691
4261
|
center: withCtx(() => [
|
|
3692
4262
|
pageLength.value > 0 ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
3693
|
-
createVNode(_sfc_main$
|
|
4263
|
+
createVNode(_sfc_main$s)
|
|
3694
4264
|
])
|
|
3695
4265
|
]),
|
|
3696
4266
|
_: 2
|
|
@@ -3710,17 +4280,17 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
3710
4280
|
]), 1032, ["left", "right"])),
|
|
3711
4281
|
renderSlot(_ctx.$slots, "content-after"),
|
|
3712
4282
|
renderSlot(_ctx.$slots, "footer")
|
|
3713
|
-
]);
|
|
4283
|
+
], 512);
|
|
3714
4284
|
};
|
|
3715
4285
|
}
|
|
3716
4286
|
});
|
|
3717
4287
|
|
|
3718
|
-
const _hoisted_1$
|
|
4288
|
+
const _hoisted_1$g = {
|
|
3719
4289
|
key: 1,
|
|
3720
4290
|
class: "menu-item-text"
|
|
3721
4291
|
};
|
|
3722
|
-
const _hoisted_2$
|
|
3723
|
-
const _sfc_main$
|
|
4292
|
+
const _hoisted_2$7 = { class: "el-dropdown-link menubar-menu-button" };
|
|
4293
|
+
const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
3724
4294
|
...{
|
|
3725
4295
|
name: "MEditorToolButton"
|
|
3726
4296
|
},
|
|
@@ -3799,7 +4369,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
3799
4369
|
_ctx.data.type === "divider" ? (openBlock(), createBlock(unref(TMagicDivider), {
|
|
3800
4370
|
key: 0,
|
|
3801
4371
|
direction: _ctx.data.direction || "vertical"
|
|
3802
|
-
}, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$
|
|
4372
|
+
}, null, 8, ["direction"])) : _ctx.data.type === "text" ? (openBlock(), createElementBlock("div", _hoisted_1$g, toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
3803
4373
|
_ctx.data.tooltip ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
3804
4374
|
key: 0,
|
|
3805
4375
|
effect: "dark",
|
|
@@ -3863,7 +4433,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
3863
4433
|
})) : createCommentVNode("", true)
|
|
3864
4434
|
]),
|
|
3865
4435
|
default: withCtx(() => [
|
|
3866
|
-
createElementVNode("span", _hoisted_2$
|
|
4436
|
+
createElementVNode("span", _hoisted_2$7, [
|
|
3867
4437
|
createTextVNode(toDisplayString(_ctx.data.text), 1),
|
|
3868
4438
|
createVNode(unref(TMagicIcon), { class: "el-icon--right" }, {
|
|
3869
4439
|
default: withCtx(() => [
|
|
@@ -3880,7 +4450,7 @@ const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
|
3880
4450
|
}
|
|
3881
4451
|
});
|
|
3882
4452
|
|
|
3883
|
-
const _sfc_main$
|
|
4453
|
+
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
3884
4454
|
...{
|
|
3885
4455
|
name: "MEditorNavMenu"
|
|
3886
4456
|
},
|
|
@@ -4042,7 +4612,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
4042
4612
|
style: normalizeStyle(`width: ${columnWidth.value?.[key]}px`)
|
|
4043
4613
|
}, [
|
|
4044
4614
|
(openBlock(true), createElementBlock(Fragment, null, renderList(buttons.value[key], (item, index) => {
|
|
4045
|
-
return openBlock(), createBlock(_sfc_main$
|
|
4615
|
+
return openBlock(), createBlock(_sfc_main$q, {
|
|
4046
4616
|
data: item,
|
|
4047
4617
|
key: index
|
|
4048
4618
|
}, null, 8, ["data"]);
|
|
@@ -4054,8 +4624,8 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
4054
4624
|
}
|
|
4055
4625
|
});
|
|
4056
4626
|
|
|
4057
|
-
const _hoisted_1$
|
|
4058
|
-
const _sfc_main$
|
|
4627
|
+
const _hoisted_1$f = { class: "m-editor-props-panel" };
|
|
4628
|
+
const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
4059
4629
|
...{
|
|
4060
4630
|
name: "MEditorPropsPanel"
|
|
4061
4631
|
},
|
|
@@ -4108,7 +4678,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
4108
4678
|
};
|
|
4109
4679
|
__expose({ configForm, submit });
|
|
4110
4680
|
return (_ctx, _cache) => {
|
|
4111
|
-
return withDirectives((openBlock(), createElementBlock("div", _hoisted_1$
|
|
4681
|
+
return withDirectives((openBlock(), createElementBlock("div", _hoisted_1$f, [
|
|
4112
4682
|
renderSlot(_ctx.$slots, "props-panel-header"),
|
|
4113
4683
|
createVNode(unref(MForm), {
|
|
4114
4684
|
ref_key: "configForm",
|
|
@@ -4128,7 +4698,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
4128
4698
|
}
|
|
4129
4699
|
});
|
|
4130
4700
|
|
|
4131
|
-
const _sfc_main$
|
|
4701
|
+
const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
4132
4702
|
...{
|
|
4133
4703
|
name: "MEditorSearchInput"
|
|
4134
4704
|
},
|
|
@@ -4163,8 +4733,8 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
4163
4733
|
}
|
|
4164
4734
|
});
|
|
4165
4735
|
|
|
4166
|
-
const _hoisted_1$
|
|
4167
|
-
const _hoisted_2$
|
|
4736
|
+
const _hoisted_1$e = { xmlns: "http://www.w3.org/2000/svg" };
|
|
4737
|
+
const _hoisted_2$6 = /* @__PURE__ */ createElementVNode("g", {
|
|
4168
4738
|
fill: "#7C878E",
|
|
4169
4739
|
"fill-rule": "evenodd"
|
|
4170
4740
|
}, [
|
|
@@ -4174,488 +4744,60 @@ const _hoisted_2$8 = /* @__PURE__ */ createElementVNode("g", {
|
|
|
4174
4744
|
}),
|
|
4175
4745
|
/* @__PURE__ */ createElementVNode("path", { d: "M8 13.5L2.3 9.2 0.7 10.5 8 16 15.3 10.5 13.7 9.2z" })
|
|
4176
4746
|
], -1);
|
|
4177
|
-
const _hoisted_3$
|
|
4178
|
-
_hoisted_2$
|
|
4747
|
+
const _hoisted_3$3 = [
|
|
4748
|
+
_hoisted_2$6
|
|
4179
4749
|
];
|
|
4180
|
-
const _sfc_main$
|
|
4750
|
+
const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
4181
4751
|
...{
|
|
4182
4752
|
name: "MEditorAppManageIcon"
|
|
4183
4753
|
},
|
|
4184
4754
|
__name: "AppManageIcon",
|
|
4185
4755
|
setup(__props) {
|
|
4186
4756
|
return (_ctx, _cache) => {
|
|
4187
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
4757
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$e, _hoisted_3$3);
|
|
4188
4758
|
};
|
|
4189
4759
|
}
|
|
4190
4760
|
});
|
|
4191
4761
|
|
|
4192
|
-
const _hoisted_1$
|
|
4762
|
+
const _hoisted_1$d = {
|
|
4193
4763
|
viewBox: "0 0 32 32",
|
|
4194
4764
|
version: "1.1",
|
|
4195
4765
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4196
4766
|
"xmlns:xlink": "http://www.w3.org/1999/xlink"
|
|
4197
4767
|
};
|
|
4198
|
-
const _hoisted_2$
|
|
4199
|
-
const _hoisted_4$
|
|
4200
|
-
_hoisted_2$
|
|
4768
|
+
const _hoisted_2$5 = /* @__PURE__ */ createStaticVNode('<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs><g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="03图标" transform="translate(-561.000000, -2356.000000)"><g id="icon/line/Universal/code" transform="translate(561.000000, 2356.000000)"><g id="路径"><mask id="mask-2" fill="white"><use xlink:href="#path-1"></use></mask><use id="蒙版" fill="#D8D8D8" opacity="0" xlink:href="#path-1"></use><path d="M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z" id="形状" fill="#1D1F24" mask="url(#mask-2)"></path></g></g><g id="icon切图" transform="translate(226.000000, 1782.000000)"></g></g></g>', 2);
|
|
4769
|
+
const _hoisted_4$1 = [
|
|
4770
|
+
_hoisted_2$5
|
|
4201
4771
|
];
|
|
4202
|
-
const _sfc_main$
|
|
4772
|
+
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
4203
4773
|
...{
|
|
4204
4774
|
name: "MEditorCodeIcon"
|
|
4205
4775
|
},
|
|
4206
4776
|
__name: "CodeIcon",
|
|
4207
4777
|
setup(__props) {
|
|
4208
4778
|
return (_ctx, _cache) => {
|
|
4209
|
-
return openBlock(), createElementBlock("svg", _hoisted_1$
|
|
4210
|
-
};
|
|
4211
|
-
}
|
|
4212
|
-
});
|
|
4213
|
-
|
|
4214
|
-
const _hoisted_1$d = {
|
|
4215
|
-
key: 0,
|
|
4216
|
-
class: "m-editor-content-bottom"
|
|
4217
|
-
};
|
|
4218
|
-
const _hoisted_2$6 = {
|
|
4219
|
-
key: 1,
|
|
4220
|
-
class: "m-editor-content-bottom"
|
|
4221
|
-
};
|
|
4222
|
-
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
4223
|
-
...{
|
|
4224
|
-
name: "MEditorCodeDraftEditor"
|
|
4225
|
-
},
|
|
4226
|
-
__name: "CodeDraftEditor",
|
|
4227
|
-
props: {
|
|
4228
|
-
id: {},
|
|
4229
|
-
content: {},
|
|
4230
|
-
editable: { type: Boolean, default: true },
|
|
4231
|
-
autoSaveDraft: { type: Boolean, default: true },
|
|
4232
|
-
codeOptions: {},
|
|
4233
|
-
language: {}
|
|
4234
|
-
},
|
|
4235
|
-
emits: ["close", "saveAndClose"],
|
|
4236
|
-
setup(__props, { expose: __expose, emit }) {
|
|
4237
|
-
const props = __props;
|
|
4238
|
-
const services = inject("services");
|
|
4239
|
-
const codeContent = ref("");
|
|
4240
|
-
const editorContent = ref("");
|
|
4241
|
-
const codeEditor = ref();
|
|
4242
|
-
const originCodeContent = ref("");
|
|
4243
|
-
const isFullScreen = ref(false);
|
|
4244
|
-
const codeOptions = computed(() => ({
|
|
4245
|
-
...props.codeOptions,
|
|
4246
|
-
readOnly: !props.editable
|
|
4247
|
-
}));
|
|
4248
|
-
watchEffect(() => {
|
|
4249
|
-
codeContent.value = props.content;
|
|
4250
|
-
if (!originCodeContent.value) {
|
|
4251
|
-
originCodeContent.value = codeContent.value;
|
|
4252
|
-
}
|
|
4253
|
-
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
4254
|
-
if (codeDraft) {
|
|
4255
|
-
codeContent.value = codeDraft;
|
|
4256
|
-
}
|
|
4257
|
-
});
|
|
4258
|
-
const saveCodeDraft = async (codeValue) => {
|
|
4259
|
-
if (!props.autoSaveDraft)
|
|
4260
|
-
return;
|
|
4261
|
-
if (originCodeContent.value === codeValue) {
|
|
4262
|
-
services?.codeBlockService.removeCodeDraft(props.id);
|
|
4263
|
-
return;
|
|
4264
|
-
}
|
|
4265
|
-
services?.codeBlockService.setCodeDraft(props.id, codeValue);
|
|
4266
|
-
tMagicMessage.success(`代码草稿成功保存到本地 ${datetimeFormatter( new Date())}`);
|
|
4267
|
-
};
|
|
4268
|
-
const saveAndClose = () => {
|
|
4269
|
-
if (!codeEditor.value || !props.editable)
|
|
4270
|
-
return;
|
|
4271
|
-
editorContent.value = codeEditor.value.getEditor()?.getValue();
|
|
4272
|
-
emit("saveAndClose", editorContent.value);
|
|
4273
|
-
};
|
|
4274
|
-
const close = async () => {
|
|
4275
|
-
const codeDraft = services?.codeBlockService.getCodeDraft(props.id);
|
|
4276
|
-
if (codeDraft) {
|
|
4277
|
-
try {
|
|
4278
|
-
await tMagicMessageBox.confirm("您有代码修改未保存,是否保存后再关闭?", "提示", {
|
|
4279
|
-
confirmButtonText: "保存并关闭",
|
|
4280
|
-
cancelButtonText: "直接关闭",
|
|
4281
|
-
type: "warning",
|
|
4282
|
-
distinguishCancelAndClose: true
|
|
4283
|
-
});
|
|
4284
|
-
saveAndClose();
|
|
4285
|
-
} catch (action) {
|
|
4286
|
-
if (action === "cancel") {
|
|
4287
|
-
services?.codeBlockService.removeCodeDraft(props.id);
|
|
4288
|
-
emit("close");
|
|
4289
|
-
}
|
|
4290
|
-
}
|
|
4291
|
-
} else {
|
|
4292
|
-
emit("close");
|
|
4293
|
-
}
|
|
4294
|
-
};
|
|
4295
|
-
const toggleFullScreen = () => {
|
|
4296
|
-
isFullScreen.value = !isFullScreen.value;
|
|
4297
|
-
if (codeEditor.value) {
|
|
4298
|
-
codeEditor.value.focus();
|
|
4299
|
-
}
|
|
4300
|
-
};
|
|
4301
|
-
__expose({
|
|
4302
|
-
saveAndClose,
|
|
4303
|
-
close
|
|
4304
|
-
});
|
|
4305
|
-
return (_ctx, _cache) => {
|
|
4306
|
-
return openBlock(), createElementBlock("div", {
|
|
4307
|
-
class: normalizeClass(["m-editor-wrapper", isFullScreen.value ? "fullScreen" : "normal"])
|
|
4308
|
-
}, [
|
|
4309
|
-
createVNode(_sfc_main$w, {
|
|
4310
|
-
ref_key: "codeEditor",
|
|
4311
|
-
ref: codeEditor,
|
|
4312
|
-
class: "m-editor-container",
|
|
4313
|
-
"init-values": `${codeContent.value}`,
|
|
4314
|
-
onSave: saveCodeDraft,
|
|
4315
|
-
language: _ctx.language,
|
|
4316
|
-
options: codeOptions.value
|
|
4317
|
-
}, null, 8, ["init-values", "language", "options"]),
|
|
4318
|
-
_ctx.editable ? (openBlock(), createElementBlock("div", _hoisted_1$d, [
|
|
4319
|
-
createVNode(unref(TMagicButton), {
|
|
4320
|
-
type: "primary",
|
|
4321
|
-
class: "button",
|
|
4322
|
-
onClick: toggleFullScreen
|
|
4323
|
-
}, {
|
|
4324
|
-
default: withCtx(() => [
|
|
4325
|
-
createTextVNode(toDisplayString(isFullScreen.value ? "退出全屏" : "全屏"), 1)
|
|
4326
|
-
]),
|
|
4327
|
-
_: 1
|
|
4328
|
-
}),
|
|
4329
|
-
createVNode(unref(TMagicButton), {
|
|
4330
|
-
type: "primary",
|
|
4331
|
-
class: "button",
|
|
4332
|
-
onClick: saveAndClose
|
|
4333
|
-
}, {
|
|
4334
|
-
default: withCtx(() => [
|
|
4335
|
-
createTextVNode("确认")
|
|
4336
|
-
]),
|
|
4337
|
-
_: 1
|
|
4338
|
-
}),
|
|
4339
|
-
createVNode(unref(TMagicButton), {
|
|
4340
|
-
class: "button",
|
|
4341
|
-
onClick: close
|
|
4342
|
-
}, {
|
|
4343
|
-
default: withCtx(() => [
|
|
4344
|
-
createTextVNode("关闭")
|
|
4345
|
-
]),
|
|
4346
|
-
_: 1
|
|
4347
|
-
})
|
|
4348
|
-
])) : (openBlock(), createElementBlock("div", _hoisted_2$6, [
|
|
4349
|
-
createVNode(unref(TMagicButton), {
|
|
4350
|
-
type: "primary",
|
|
4351
|
-
class: "button",
|
|
4352
|
-
onClick: toggleFullScreen
|
|
4353
|
-
}, {
|
|
4354
|
-
default: withCtx(() => [
|
|
4355
|
-
createTextVNode(toDisplayString(isFullScreen.value ? "退出全屏" : "全屏"), 1)
|
|
4356
|
-
]),
|
|
4357
|
-
_: 1
|
|
4358
|
-
}),
|
|
4359
|
-
createVNode(unref(TMagicButton), {
|
|
4360
|
-
class: "button",
|
|
4361
|
-
onClick: close
|
|
4362
|
-
}, {
|
|
4363
|
-
default: withCtx(() => [
|
|
4364
|
-
createTextVNode("关闭")
|
|
4365
|
-
]),
|
|
4366
|
-
_: 1
|
|
4367
|
-
})
|
|
4368
|
-
]))
|
|
4369
|
-
], 2);
|
|
4370
|
-
};
|
|
4371
|
-
}
|
|
4372
|
-
});
|
|
4373
|
-
|
|
4374
|
-
const _hoisted_1$c = { class: "code-name-wrapper" };
|
|
4375
|
-
const _hoisted_2$5 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "代码块名称", -1);
|
|
4376
|
-
const _hoisted_3$3 = { class: "code-name-wrapper" };
|
|
4377
|
-
const _hoisted_4$3 = /* @__PURE__ */ createElementVNode("div", { class: "code-name-label" }, "参数", -1);
|
|
4378
|
-
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
4379
|
-
...{
|
|
4380
|
-
name: "MEditorFunctionEditor"
|
|
4381
|
-
},
|
|
4382
|
-
__name: "FunctionEditor",
|
|
4383
|
-
props: {
|
|
4384
|
-
id: {},
|
|
4385
|
-
name: {},
|
|
4386
|
-
content: {},
|
|
4387
|
-
editable: { type: Boolean, default: true },
|
|
4388
|
-
autoSaveDraft: { type: Boolean, default: true },
|
|
4389
|
-
codeOptions: {},
|
|
4390
|
-
paramsColConfig: {}
|
|
4391
|
-
},
|
|
4392
|
-
setup(__props, { expose: __expose }) {
|
|
4393
|
-
const props = __props;
|
|
4394
|
-
provide("mForm", null);
|
|
4395
|
-
const defaultParamColConfig = {
|
|
4396
|
-
type: "row",
|
|
4397
|
-
label: "参数类型",
|
|
4398
|
-
items: [
|
|
4399
|
-
{
|
|
4400
|
-
text: "参数类型",
|
|
4401
|
-
labelWidth: "70px",
|
|
4402
|
-
type: "select",
|
|
4403
|
-
name: "type",
|
|
4404
|
-
options: [
|
|
4405
|
-
{
|
|
4406
|
-
text: "数字",
|
|
4407
|
-
label: "数字",
|
|
4408
|
-
value: "number"
|
|
4409
|
-
},
|
|
4410
|
-
{
|
|
4411
|
-
text: "字符串",
|
|
4412
|
-
label: "字符串",
|
|
4413
|
-
value: "text"
|
|
4414
|
-
}
|
|
4415
|
-
]
|
|
4416
|
-
}
|
|
4417
|
-
]
|
|
4418
|
-
};
|
|
4419
|
-
const paramsColConfig = props.paramsColConfig || defaultParamColConfig;
|
|
4420
|
-
const tableConfig = {
|
|
4421
|
-
type: "table",
|
|
4422
|
-
border: true,
|
|
4423
|
-
enableFullscreen: false,
|
|
4424
|
-
name: "params",
|
|
4425
|
-
maxHeight: "300px",
|
|
4426
|
-
dropSort: false,
|
|
4427
|
-
items: [
|
|
4428
|
-
{
|
|
4429
|
-
type: "text",
|
|
4430
|
-
label: "参数名",
|
|
4431
|
-
name: "name",
|
|
4432
|
-
width: 200
|
|
4433
|
-
},
|
|
4434
|
-
{
|
|
4435
|
-
type: "text",
|
|
4436
|
-
label: "参数注释",
|
|
4437
|
-
name: "tip",
|
|
4438
|
-
width: 200
|
|
4439
|
-
},
|
|
4440
|
-
paramsColConfig
|
|
4441
|
-
]
|
|
4442
|
-
};
|
|
4443
|
-
const services = inject("services");
|
|
4444
|
-
const codeName = ref("");
|
|
4445
|
-
const codeContent = ref("");
|
|
4446
|
-
const evalRes = ref(true);
|
|
4447
|
-
const tableModel = ref();
|
|
4448
|
-
watchEffect(() => {
|
|
4449
|
-
codeName.value = props.name;
|
|
4450
|
-
codeContent.value = props.content;
|
|
4451
|
-
});
|
|
4452
|
-
const initTableModel = () => {
|
|
4453
|
-
const codeDsl = cloneDeep(services?.codeBlockService.getCodeDsl());
|
|
4454
|
-
if (!codeDsl)
|
|
4455
|
-
return;
|
|
4456
|
-
tableModel.value = {
|
|
4457
|
-
params: codeDsl[props.id]?.params || []
|
|
4458
|
-
};
|
|
4459
|
-
};
|
|
4460
|
-
initTableModel();
|
|
4461
|
-
const beforeSave = (codeValue) => {
|
|
4462
|
-
try {
|
|
4463
|
-
getConfig("parseDSL")(codeValue);
|
|
4464
|
-
return true;
|
|
4465
|
-
} catch (e) {
|
|
4466
|
-
tMagicMessage.error(e.stack);
|
|
4467
|
-
return false;
|
|
4468
|
-
}
|
|
4469
|
-
};
|
|
4470
|
-
const saveCode = async (codeValue) => {
|
|
4471
|
-
if (!props.editable)
|
|
4472
|
-
return;
|
|
4473
|
-
evalRes.value = beforeSave(codeValue);
|
|
4474
|
-
if (evalRes.value) {
|
|
4475
|
-
await services?.codeBlockService.setCodeDslById(props.id, {
|
|
4476
|
-
name: codeName.value,
|
|
4477
|
-
content: codeValue,
|
|
4478
|
-
params: tableModel.value?.params || []
|
|
4479
|
-
});
|
|
4480
|
-
tMagicMessage.success("代码成功保存到本地");
|
|
4481
|
-
services?.codeBlockService.removeCodeDraft(props.id);
|
|
4482
|
-
}
|
|
4483
|
-
};
|
|
4484
|
-
const saveAndClose = async (codeValue) => {
|
|
4485
|
-
await saveCode(codeValue);
|
|
4486
|
-
if (evalRes.value) {
|
|
4487
|
-
close();
|
|
4488
|
-
}
|
|
4489
|
-
};
|
|
4490
|
-
const close = () => {
|
|
4491
|
-
services?.codeBlockService.setCodeEditorShowStatus(false);
|
|
4492
|
-
};
|
|
4493
|
-
const codeDraftEditor = ref();
|
|
4494
|
-
__expose({
|
|
4495
|
-
codeDraftEditor
|
|
4496
|
-
});
|
|
4497
|
-
return (_ctx, _cache) => {
|
|
4498
|
-
const _component_m_form_table = resolveComponent("m-form-table");
|
|
4499
|
-
return openBlock(), createBlock(unref(TMagicCard), { shadow: "never" }, {
|
|
4500
|
-
header: withCtx(() => [
|
|
4501
|
-
createElementVNode("div", _hoisted_1$c, [
|
|
4502
|
-
_hoisted_2$5,
|
|
4503
|
-
createVNode(unref(TMagicInput), {
|
|
4504
|
-
class: "code-name-input",
|
|
4505
|
-
modelValue: codeName.value,
|
|
4506
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => codeName.value = $event),
|
|
4507
|
-
disabled: !_ctx.editable
|
|
4508
|
-
}, null, 8, ["modelValue", "disabled"])
|
|
4509
|
-
]),
|
|
4510
|
-
createElementVNode("div", _hoisted_3$3, [
|
|
4511
|
-
_hoisted_4$3,
|
|
4512
|
-
createVNode(_component_m_form_table, {
|
|
4513
|
-
style: { "width": "800px" },
|
|
4514
|
-
config: tableConfig,
|
|
4515
|
-
model: tableModel.value,
|
|
4516
|
-
enableToggleMode: false,
|
|
4517
|
-
name: "params",
|
|
4518
|
-
prop: "params",
|
|
4519
|
-
size: "small"
|
|
4520
|
-
}, null, 8, ["model"])
|
|
4521
|
-
])
|
|
4522
|
-
]),
|
|
4523
|
-
default: withCtx(() => [
|
|
4524
|
-
createVNode(_sfc_main$l, {
|
|
4525
|
-
ref_key: "codeDraftEditor",
|
|
4526
|
-
ref: codeDraftEditor,
|
|
4527
|
-
id: _ctx.id,
|
|
4528
|
-
content: codeContent.value,
|
|
4529
|
-
editable: _ctx.editable,
|
|
4530
|
-
autoSaveDraft: _ctx.autoSaveDraft,
|
|
4531
|
-
codeOptions: _ctx.codeOptions,
|
|
4532
|
-
language: "javascript",
|
|
4533
|
-
onSaveAndClose: saveAndClose,
|
|
4534
|
-
onClose: close
|
|
4535
|
-
}, null, 8, ["id", "content", "editable", "autoSaveDraft", "codeOptions"])
|
|
4536
|
-
]),
|
|
4537
|
-
_: 1
|
|
4538
|
-
});
|
|
4539
|
-
};
|
|
4540
|
-
}
|
|
4541
|
-
});
|
|
4542
|
-
|
|
4543
|
-
const _hoisted_1$b = {
|
|
4544
|
-
key: 0,
|
|
4545
|
-
class: "m-editor-code-block-editor-panel"
|
|
4546
|
-
};
|
|
4547
|
-
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
4548
|
-
...{
|
|
4549
|
-
name: "MEditorCodeBlockEditor"
|
|
4550
|
-
},
|
|
4551
|
-
__name: "CodeBlockEditor",
|
|
4552
|
-
props: {
|
|
4553
|
-
paramsColConfig: {}
|
|
4554
|
-
},
|
|
4555
|
-
setup(__props) {
|
|
4556
|
-
const services = inject("services");
|
|
4557
|
-
const codeOptions = inject("codeOptions", {});
|
|
4558
|
-
const size = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
|
|
4559
|
-
const left = ref(200);
|
|
4560
|
-
const currentTitle = ref("");
|
|
4561
|
-
const codeConfig = ref(null);
|
|
4562
|
-
const state = reactive({
|
|
4563
|
-
codeList: []
|
|
4564
|
-
});
|
|
4565
|
-
const id = computed(() => services?.codeBlockService.getId() || "");
|
|
4566
|
-
const editable = computed(() => services?.codeBlockService.getEditStatus());
|
|
4567
|
-
const selectedIds = computed(() => services?.codeBlockService.getCombineIds() || []);
|
|
4568
|
-
watchEffect(async () => {
|
|
4569
|
-
codeConfig.value = cloneDeep(await services?.codeBlockService.getCodeContentById(id.value)) || null;
|
|
4570
|
-
if (!codeConfig.value)
|
|
4571
|
-
return;
|
|
4572
|
-
codeConfig.value.content = serializeConfig(codeConfig.value.content);
|
|
4573
|
-
});
|
|
4574
|
-
watchEffect(async () => {
|
|
4575
|
-
const codeDsl = await services?.codeBlockService.getCodeDslByIds(selectedIds.value) || null;
|
|
4576
|
-
if (!codeDsl)
|
|
4577
|
-
return;
|
|
4578
|
-
state.codeList = [];
|
|
4579
|
-
forIn(codeDsl, (value, key) => {
|
|
4580
|
-
state.codeList.push({
|
|
4581
|
-
id: key,
|
|
4582
|
-
name: value.name
|
|
4583
|
-
});
|
|
4584
|
-
});
|
|
4585
|
-
currentTitle.value = state.codeList[0]?.name || "";
|
|
4586
|
-
});
|
|
4587
|
-
const functionEditor = ref();
|
|
4588
|
-
const handleClose = async () => {
|
|
4589
|
-
await functionEditor.value?.codeDraftEditor?.close();
|
|
4590
|
-
};
|
|
4591
|
-
return (_ctx, _cache) => {
|
|
4592
|
-
return openBlock(), createBlock(unref(TMagicDrawer), {
|
|
4593
|
-
class: "code-editor-dialog",
|
|
4594
|
-
"model-value": true,
|
|
4595
|
-
title: currentTitle.value,
|
|
4596
|
-
"close-on-press-escape": true,
|
|
4597
|
-
"append-to-body": true,
|
|
4598
|
-
"show-close": false,
|
|
4599
|
-
"close-on-click-modal": true,
|
|
4600
|
-
size: size.value,
|
|
4601
|
-
"before-close": handleClose
|
|
4602
|
-
}, {
|
|
4603
|
-
default: withCtx(() => [
|
|
4604
|
-
createVNode(_sfc_main$u, {
|
|
4605
|
-
left: left.value,
|
|
4606
|
-
"onUpdate:left": _cache[0] || (_cache[0] = ($event) => left.value = $event),
|
|
4607
|
-
"min-left": 45,
|
|
4608
|
-
class: "code-editor-layout"
|
|
4609
|
-
}, {
|
|
4610
|
-
center: withCtx(() => [
|
|
4611
|
-
!unref(isEmpty)(codeConfig.value) ? (openBlock(), createElementBlock("div", _hoisted_1$b, [
|
|
4612
|
-
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id: id.value }),
|
|
4613
|
-
codeConfig.value ? (openBlock(), createBlock(_sfc_main$k, {
|
|
4614
|
-
key: 0,
|
|
4615
|
-
ref_key: "functionEditor",
|
|
4616
|
-
ref: functionEditor,
|
|
4617
|
-
id: id.value,
|
|
4618
|
-
name: codeConfig.value.name,
|
|
4619
|
-
content: codeConfig.value.content,
|
|
4620
|
-
paramsColConfig: _ctx.paramsColConfig,
|
|
4621
|
-
editable: !!editable.value,
|
|
4622
|
-
autoSaveDraft: true,
|
|
4623
|
-
codeOptions: unref(codeOptions)
|
|
4624
|
-
}, null, 8, ["id", "name", "content", "paramsColConfig", "editable", "codeOptions"])) : createCommentVNode("", true)
|
|
4625
|
-
])) : createCommentVNode("", true)
|
|
4626
|
-
]),
|
|
4627
|
-
_: 3
|
|
4628
|
-
}, 8, ["left"])
|
|
4629
|
-
]),
|
|
4630
|
-
_: 3
|
|
4631
|
-
}, 8, ["title", "size"]);
|
|
4779
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$d, _hoisted_4$1);
|
|
4632
4780
|
};
|
|
4633
4781
|
}
|
|
4634
4782
|
});
|
|
4635
4783
|
|
|
4636
|
-
const _hoisted_1$
|
|
4637
|
-
const _hoisted_2$4 =
|
|
4638
|
-
const _hoisted_3$2 = {
|
|
4639
|
-
const _hoisted_4$2 = {
|
|
4784
|
+
const _hoisted_1$c = ["id"];
|
|
4785
|
+
const _hoisted_2$4 = { class: "list-item" };
|
|
4786
|
+
const _hoisted_3$2 = {
|
|
4640
4787
|
key: 2,
|
|
4641
4788
|
class: "right-tool"
|
|
4642
4789
|
};
|
|
4643
|
-
const _sfc_main$
|
|
4790
|
+
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
4644
4791
|
...{
|
|
4645
4792
|
name: "MEditorCodeBlockList"
|
|
4646
4793
|
},
|
|
4647
4794
|
__name: "CodeBlockList",
|
|
4648
4795
|
props: {
|
|
4649
|
-
customError: { type: Function }
|
|
4650
|
-
paramsColConfig: {}
|
|
4796
|
+
customError: { type: Function }
|
|
4651
4797
|
},
|
|
4652
|
-
|
|
4798
|
+
emits: ["edit", "remove"],
|
|
4799
|
+
setup(__props, { expose: __expose, emit }) {
|
|
4653
4800
|
const props = __props;
|
|
4654
|
-
const treeProps = {
|
|
4655
|
-
children: "children",
|
|
4656
|
-
label: "name",
|
|
4657
|
-
value: "id"
|
|
4658
|
-
};
|
|
4659
4801
|
const { codeBlockService, depService, editorService } = inject("services") || {};
|
|
4660
4802
|
const codeList = computed(
|
|
4661
4803
|
() => Object.values(depService?.targets["code-block"] || {}).map((target) => {
|
|
@@ -4676,167 +4818,192 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
4676
4818
|
);
|
|
4677
4819
|
const expandedKeys = computed(() => codeList.value.map((item) => item.id));
|
|
4678
4820
|
const editable = computed(() => codeBlockService?.getEditStatus());
|
|
4679
|
-
const
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4821
|
+
const filterNode = (value, data) => {
|
|
4822
|
+
if (!value) {
|
|
4823
|
+
return true;
|
|
4824
|
+
}
|
|
4825
|
+
return `${data.name}${data.id}`.toLocaleLowerCase().indexOf(value.toLocaleLowerCase()) !== -1;
|
|
4826
|
+
};
|
|
4827
|
+
const selectComp = (compId) => {
|
|
4828
|
+
const stage = editorService?.get("stage");
|
|
4829
|
+
editorService?.select(compId);
|
|
4830
|
+
stage?.select(compId);
|
|
4831
|
+
};
|
|
4832
|
+
const clickHandler = (data, node) => {
|
|
4833
|
+
if (data.type === "node") {
|
|
4834
|
+
selectComp(data.id);
|
|
4835
|
+
} else if (data.type === "key") {
|
|
4836
|
+
selectComp(node.parent.data.id);
|
|
4684
4837
|
}
|
|
4685
|
-
const codeConfig = {
|
|
4686
|
-
name: "代码块",
|
|
4687
|
-
content: `({app, params}) => {
|
|
4688
|
-
// place your code here
|
|
4689
|
-
}`,
|
|
4690
|
-
params: []
|
|
4691
|
-
};
|
|
4692
|
-
const id = await codeBlockService.getUniqueId();
|
|
4693
|
-
await codeBlockService.setCodeDslById(id, codeConfig);
|
|
4694
|
-
codeBlockService.setCodeEditorContent(true, id);
|
|
4695
4838
|
};
|
|
4696
|
-
const editCode =
|
|
4697
|
-
|
|
4839
|
+
const editCode = (id) => {
|
|
4840
|
+
emit("edit", id);
|
|
4698
4841
|
};
|
|
4699
|
-
const deleteCode = async (
|
|
4700
|
-
const currentCode = codeList.value.find((codeItem) => codeItem.id ===
|
|
4842
|
+
const deleteCode = async (id) => {
|
|
4843
|
+
const currentCode = codeList.value.find((codeItem) => codeItem.id === id);
|
|
4701
4844
|
const existBinds = Boolean(currentCode?.children.length);
|
|
4702
4845
|
const undeleteableList = codeBlockService?.getUndeletableList() || [];
|
|
4703
|
-
if (!existBinds && !undeleteableList.includes(
|
|
4846
|
+
if (!existBinds && !undeleteableList.includes(id)) {
|
|
4704
4847
|
await tMagicMessageBox.confirm("确定删除该代码块吗?", "提示", {
|
|
4705
4848
|
confirmButtonText: "确定",
|
|
4706
4849
|
cancelButtonText: "取消",
|
|
4707
4850
|
type: "warning"
|
|
4708
4851
|
});
|
|
4709
|
-
|
|
4852
|
+
emit("remove", id);
|
|
4710
4853
|
} else {
|
|
4711
4854
|
if (typeof props.customError === "function") {
|
|
4712
|
-
props.customError(
|
|
4855
|
+
props.customError(id, existBinds ? CodeDeleteErrorType.BIND : CodeDeleteErrorType.UNDELETEABLE);
|
|
4713
4856
|
} else {
|
|
4714
4857
|
tMagicMessage.error("代码块删除失败");
|
|
4715
4858
|
}
|
|
4716
4859
|
}
|
|
4717
4860
|
};
|
|
4718
4861
|
const tree = ref();
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4862
|
+
__expose({
|
|
4863
|
+
filter(val) {
|
|
4864
|
+
tree.value?.filter(val);
|
|
4722
4865
|
}
|
|
4723
|
-
|
|
4866
|
+
});
|
|
4867
|
+
return (_ctx, _cache) => {
|
|
4868
|
+
return openBlock(), createBlock(unref(TMagicTree), {
|
|
4869
|
+
ref_key: "tree",
|
|
4870
|
+
ref: tree,
|
|
4871
|
+
class: "magic-editor-layer-tree",
|
|
4872
|
+
"node-key": "id",
|
|
4873
|
+
"empty-text": "暂无代码块",
|
|
4874
|
+
"default-expanded-keys": expandedKeys.value,
|
|
4875
|
+
"expand-on-click-node": false,
|
|
4876
|
+
data: codeList.value,
|
|
4877
|
+
props: {
|
|
4878
|
+
children: "children",
|
|
4879
|
+
label: "name",
|
|
4880
|
+
value: "id"
|
|
4881
|
+
},
|
|
4882
|
+
"highlight-current": true,
|
|
4883
|
+
"filter-node-method": filterNode,
|
|
4884
|
+
onNodeClick: clickHandler
|
|
4885
|
+
}, {
|
|
4886
|
+
default: withCtx(({ data }) => [
|
|
4887
|
+
createElementVNode("div", {
|
|
4888
|
+
id: data.id,
|
|
4889
|
+
class: "list-container"
|
|
4890
|
+
}, [
|
|
4891
|
+
createElementVNode("div", _hoisted_2$4, [
|
|
4892
|
+
data.type === "code" ? (openBlock(), createBlock(_sfc_main$l, {
|
|
4893
|
+
key: 0,
|
|
4894
|
+
class: "codeIcon"
|
|
4895
|
+
})) : createCommentVNode("", true),
|
|
4896
|
+
data.type === "node" ? (openBlock(), createBlock(_sfc_main$m, {
|
|
4897
|
+
key: 1,
|
|
4898
|
+
class: "compIcon"
|
|
4899
|
+
})) : createCommentVNode("", true),
|
|
4900
|
+
createElementVNode("span", {
|
|
4901
|
+
class: normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
|
|
4902
|
+
}, toDisplayString(data.name) + " (" + toDisplayString(data.id) + ")", 3),
|
|
4903
|
+
data.type === "code" ? (openBlock(), createElementBlock("div", _hoisted_3$2, [
|
|
4904
|
+
createVNode(unref(TMagicTooltip), {
|
|
4905
|
+
effect: "dark",
|
|
4906
|
+
content: editable.value ? "编辑" : "查看",
|
|
4907
|
+
placement: "bottom"
|
|
4908
|
+
}, {
|
|
4909
|
+
default: withCtx(() => [
|
|
4910
|
+
createVNode(_sfc_main$E, {
|
|
4911
|
+
icon: editable.value ? unref(Edit) : unref(View),
|
|
4912
|
+
class: "edit-icon",
|
|
4913
|
+
onClick: withModifiers(($event) => editCode(data.id), ["stop"])
|
|
4914
|
+
}, null, 8, ["icon", "onClick"])
|
|
4915
|
+
]),
|
|
4916
|
+
_: 2
|
|
4917
|
+
}, 1032, ["content"]),
|
|
4918
|
+
editable.value ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
4919
|
+
key: 0,
|
|
4920
|
+
effect: "dark",
|
|
4921
|
+
content: "删除",
|
|
4922
|
+
placement: "bottom"
|
|
4923
|
+
}, {
|
|
4924
|
+
default: withCtx(() => [
|
|
4925
|
+
createVNode(_sfc_main$E, {
|
|
4926
|
+
icon: unref(Close),
|
|
4927
|
+
class: "edit-icon",
|
|
4928
|
+
onClick: withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
|
|
4929
|
+
}, null, 8, ["icon", "onClick"])
|
|
4930
|
+
]),
|
|
4931
|
+
_: 2
|
|
4932
|
+
}, 1024)) : createCommentVNode("", true),
|
|
4933
|
+
renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
4934
|
+
id: data.id,
|
|
4935
|
+
data: data.codeBlockContent
|
|
4936
|
+
})
|
|
4937
|
+
])) : createCommentVNode("", true)
|
|
4938
|
+
])
|
|
4939
|
+
], 8, _hoisted_1$c)
|
|
4940
|
+
]),
|
|
4941
|
+
_: 3
|
|
4942
|
+
}, 8, ["default-expanded-keys", "data"]);
|
|
4724
4943
|
};
|
|
4944
|
+
}
|
|
4945
|
+
});
|
|
4946
|
+
|
|
4947
|
+
const _hoisted_1$b = { class: "search-wrapper" };
|
|
4948
|
+
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
4949
|
+
...{
|
|
4950
|
+
name: "MEditorCodeBlockListPanel"
|
|
4951
|
+
},
|
|
4952
|
+
__name: "CodeBlockListPanel",
|
|
4953
|
+
props: {
|
|
4954
|
+
customError: { type: Function }
|
|
4955
|
+
},
|
|
4956
|
+
setup(__props) {
|
|
4957
|
+
const { codeBlockService } = inject("services") || {};
|
|
4958
|
+
const editable = computed(() => codeBlockService?.getEditStatus());
|
|
4959
|
+
const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } = useCodeBlockEdit(codeBlockService);
|
|
4960
|
+
const codeBlockList = ref();
|
|
4725
4961
|
const filterTextChangeHandler = (val) => {
|
|
4726
|
-
|
|
4727
|
-
};
|
|
4728
|
-
const selectComp = (compId) => {
|
|
4729
|
-
const stage = editorService?.get("stage");
|
|
4730
|
-
editorService?.select(compId);
|
|
4731
|
-
stage?.select(compId);
|
|
4732
|
-
};
|
|
4733
|
-
const clickHandler = (data, node) => {
|
|
4734
|
-
if (data.type === "node") {
|
|
4735
|
-
selectComp(data.id);
|
|
4736
|
-
} else if (data.type === "key") {
|
|
4737
|
-
selectComp(node.parent.data.id);
|
|
4738
|
-
}
|
|
4962
|
+
codeBlockList.value?.filter(val);
|
|
4739
4963
|
};
|
|
4740
4964
|
return (_ctx, _cache) => {
|
|
4741
4965
|
return openBlock(), createBlock(unref(TMagicScrollbar), { class: "m-editor-code-block-list m-editor-dep-list-panel" }, {
|
|
4742
4966
|
default: withCtx(() => [
|
|
4743
4967
|
renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
|
|
4744
|
-
createElementVNode("div", _hoisted_1$
|
|
4745
|
-
createVNode(_sfc_main$
|
|
4968
|
+
createElementVNode("div", _hoisted_1$b, [
|
|
4969
|
+
createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
|
|
4746
4970
|
editable.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
4747
4971
|
key: 0,
|
|
4748
4972
|
class: "create-code-button",
|
|
4749
4973
|
type: "primary",
|
|
4750
4974
|
size: "small",
|
|
4751
|
-
onClick: createCodeBlock
|
|
4975
|
+
onClick: unref(createCodeBlock)
|
|
4752
4976
|
}, {
|
|
4753
4977
|
default: withCtx(() => [
|
|
4754
4978
|
createTextVNode("新增")
|
|
4755
4979
|
]),
|
|
4756
4980
|
_: 1
|
|
4757
|
-
})) : createCommentVNode("", true)
|
|
4981
|
+
}, 8, ["onClick"])) : createCommentVNode("", true)
|
|
4758
4982
|
])
|
|
4759
4983
|
]),
|
|
4760
|
-
createVNode(
|
|
4761
|
-
ref_key: "
|
|
4762
|
-
ref:
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
"default-expanded-keys": expandedKeys.value,
|
|
4767
|
-
"expand-on-click-node": false,
|
|
4768
|
-
data: codeList.value,
|
|
4769
|
-
props: treeProps,
|
|
4770
|
-
"highlight-current": true,
|
|
4771
|
-
"filter-node-method": filterNode,
|
|
4772
|
-
onNodeClick: clickHandler
|
|
4984
|
+
createVNode(_sfc_main$k, {
|
|
4985
|
+
ref_key: "codeBlockList",
|
|
4986
|
+
ref: codeBlockList,
|
|
4987
|
+
"custom-error": _ctx.customError,
|
|
4988
|
+
onEdit: unref(editCode),
|
|
4989
|
+
onRemove: unref(deleteCode)
|
|
4773
4990
|
}, {
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
id
|
|
4777
|
-
|
|
4778
|
-
}
|
|
4779
|
-
createElementVNode("div", _hoisted_3$2, [
|
|
4780
|
-
data.type === "code" ? (openBlock(), createBlock(_sfc_main$m, {
|
|
4781
|
-
key: 0,
|
|
4782
|
-
class: "codeIcon"
|
|
4783
|
-
})) : createCommentVNode("", true),
|
|
4784
|
-
data.type === "node" ? (openBlock(), createBlock(_sfc_main$n, {
|
|
4785
|
-
key: 1,
|
|
4786
|
-
class: "compIcon"
|
|
4787
|
-
})) : createCommentVNode("", true),
|
|
4788
|
-
createElementVNode("span", {
|
|
4789
|
-
class: normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
|
|
4790
|
-
}, toDisplayString(data.name) + " (" + toDisplayString(data.id) + ")", 3),
|
|
4791
|
-
data.type === "code" ? (openBlock(), createElementBlock("div", _hoisted_4$2, [
|
|
4792
|
-
createVNode(unref(TMagicTooltip), {
|
|
4793
|
-
effect: "dark",
|
|
4794
|
-
content: editable.value ? "编辑" : "查看",
|
|
4795
|
-
placement: "bottom"
|
|
4796
|
-
}, {
|
|
4797
|
-
default: withCtx(() => [
|
|
4798
|
-
createVNode(_sfc_main$E, {
|
|
4799
|
-
icon: editable.value ? unref(Edit) : unref(View),
|
|
4800
|
-
class: "edit-icon",
|
|
4801
|
-
onClick: withModifiers(($event) => editCode(`${data.id}`), ["stop"])
|
|
4802
|
-
}, null, 8, ["icon", "onClick"])
|
|
4803
|
-
]),
|
|
4804
|
-
_: 2
|
|
4805
|
-
}, 1032, ["content"]),
|
|
4806
|
-
editable.value ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
4807
|
-
key: 0,
|
|
4808
|
-
effect: "dark",
|
|
4809
|
-
content: "删除",
|
|
4810
|
-
placement: "bottom"
|
|
4811
|
-
}, {
|
|
4812
|
-
default: withCtx(() => [
|
|
4813
|
-
createVNode(_sfc_main$E, {
|
|
4814
|
-
icon: unref(Close),
|
|
4815
|
-
class: "edit-icon",
|
|
4816
|
-
onClick: withModifiers(($event) => deleteCode(`${data.id}`), ["stop"])
|
|
4817
|
-
}, null, 8, ["icon", "onClick"])
|
|
4818
|
-
]),
|
|
4819
|
-
_: 2
|
|
4820
|
-
}, 1024)) : createCommentVNode("", true),
|
|
4821
|
-
renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
4822
|
-
id: data.id,
|
|
4823
|
-
data: data.codeBlockContent
|
|
4824
|
-
})
|
|
4825
|
-
])) : createCommentVNode("", true)
|
|
4826
|
-
])
|
|
4827
|
-
], 8, _hoisted_2$4)
|
|
4991
|
+
"code-block-panel-tool": withCtx(({ id, data }) => [
|
|
4992
|
+
renderSlot(_ctx.$slots, "code-block-panel-tool", {
|
|
4993
|
+
id,
|
|
4994
|
+
data
|
|
4995
|
+
})
|
|
4828
4996
|
]),
|
|
4829
4997
|
_: 3
|
|
4830
|
-
}, 8, ["
|
|
4831
|
-
|
|
4998
|
+
}, 8, ["custom-error", "onEdit", "onRemove"]),
|
|
4999
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$G, {
|
|
4832
5000
|
key: 0,
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
}, 8, ["paramsColConfig"])) : createCommentVNode("", true)
|
|
5001
|
+
ref_key: "codeBlockEditor",
|
|
5002
|
+
ref: codeBlockEditor,
|
|
5003
|
+
disabled: !editable.value,
|
|
5004
|
+
content: unref(codeConfig),
|
|
5005
|
+
onSubmit: unref(submitCodeBlockHandler)
|
|
5006
|
+
}, null, 8, ["disabled", "content", "onSubmit"])) : createCommentVNode("", true)
|
|
4840
5007
|
]),
|
|
4841
5008
|
_: 3
|
|
4842
5009
|
});
|
|
@@ -4844,14 +5011,15 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
4844
5011
|
}
|
|
4845
5012
|
});
|
|
4846
5013
|
|
|
4847
|
-
const _sfc_main$
|
|
5014
|
+
const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
4848
5015
|
...{
|
|
4849
5016
|
name: "MEditorDataSourceConfigPanel"
|
|
4850
5017
|
},
|
|
4851
5018
|
__name: "DataSourceConfigPanel",
|
|
4852
5019
|
props: {
|
|
4853
5020
|
title: {},
|
|
4854
|
-
values: {}
|
|
5021
|
+
values: {},
|
|
5022
|
+
disabled: { type: Boolean }
|
|
4855
5023
|
},
|
|
4856
5024
|
emits: ["submit"],
|
|
4857
5025
|
setup(__props, { expose: __expose, emit }) {
|
|
@@ -4860,7 +5028,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
4860
5028
|
const services = inject("services");
|
|
4861
5029
|
const size = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get("columnWidth").left || 0));
|
|
4862
5030
|
const dataSourceConfig = computed(() => services?.dataSourceService.getFormConfig(type.value) || []);
|
|
4863
|
-
const
|
|
5031
|
+
const fomDrawer = ref();
|
|
4864
5032
|
const initValues = ref({});
|
|
4865
5033
|
watchEffect(() => {
|
|
4866
5034
|
initValues.value = props.values;
|
|
@@ -4873,84 +5041,53 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
4873
5041
|
type.value = value.type || "base";
|
|
4874
5042
|
initValues.value = value;
|
|
4875
5043
|
};
|
|
4876
|
-
const submitHandler =
|
|
4877
|
-
|
|
4878
|
-
const values = await form.value?.submitForm();
|
|
4879
|
-
emit("submit", values);
|
|
4880
|
-
} catch (error) {
|
|
4881
|
-
tMagicMessage.error(error.message);
|
|
4882
|
-
}
|
|
5044
|
+
const submitHandler = (values) => {
|
|
5045
|
+
emit("submit", values);
|
|
4883
5046
|
};
|
|
4884
|
-
const
|
|
4885
|
-
|
|
4886
|
-
visible.value = false;
|
|
5047
|
+
const errorHandler = (error) => {
|
|
5048
|
+
tMagicMessage.error(error.message);
|
|
4887
5049
|
};
|
|
4888
5050
|
__expose({
|
|
4889
5051
|
show() {
|
|
4890
|
-
|
|
5052
|
+
fomDrawer.value?.show();
|
|
4891
5053
|
},
|
|
4892
|
-
hide
|
|
5054
|
+
hide() {
|
|
5055
|
+
fomDrawer.value?.hide();
|
|
5056
|
+
}
|
|
4893
5057
|
});
|
|
4894
5058
|
return (_ctx, _cache) => {
|
|
4895
|
-
return openBlock(), createBlock(unref(
|
|
4896
|
-
|
|
4897
|
-
|
|
5059
|
+
return openBlock(), createBlock(unref(MFormDrawer), {
|
|
5060
|
+
ref_key: "fomDrawer",
|
|
5061
|
+
ref: fomDrawer,
|
|
5062
|
+
"label-width": "80px",
|
|
4898
5063
|
title: _ctx.title,
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
createVNode(unref(TMagicButton), {
|
|
4908
|
-
type: "primary",
|
|
4909
|
-
onClick: submitHandler
|
|
4910
|
-
}, {
|
|
4911
|
-
default: withCtx(() => [
|
|
4912
|
-
createTextVNode("确定")
|
|
4913
|
-
]),
|
|
4914
|
-
_: 1
|
|
4915
|
-
}),
|
|
4916
|
-
createVNode(unref(TMagicButton), { onClick: hide }, {
|
|
4917
|
-
default: withCtx(() => [
|
|
4918
|
-
createTextVNode("关闭")
|
|
4919
|
-
]),
|
|
4920
|
-
_: 1
|
|
4921
|
-
})
|
|
4922
|
-
])
|
|
4923
|
-
]),
|
|
4924
|
-
default: withCtx(() => [
|
|
4925
|
-
createVNode(unref(MForm), {
|
|
4926
|
-
ref_key: "form",
|
|
4927
|
-
ref: form,
|
|
4928
|
-
config: dataSourceConfig.value,
|
|
4929
|
-
"init-values": initValues.value,
|
|
4930
|
-
onChange: changeHandler
|
|
4931
|
-
}, null, 8, ["config", "init-values"])
|
|
4932
|
-
]),
|
|
4933
|
-
_: 1
|
|
4934
|
-
}, 8, ["modelValue", "title", "size"]);
|
|
5064
|
+
width: size.value,
|
|
5065
|
+
config: dataSourceConfig.value,
|
|
5066
|
+
values: initValues.value,
|
|
5067
|
+
disabled: _ctx.disabled,
|
|
5068
|
+
onChange: changeHandler,
|
|
5069
|
+
onSubmit: submitHandler,
|
|
5070
|
+
onError: errorHandler
|
|
5071
|
+
}, null, 8, ["title", "width", "config", "values", "disabled"]);
|
|
4935
5072
|
};
|
|
4936
5073
|
}
|
|
4937
5074
|
});
|
|
4938
5075
|
|
|
4939
|
-
const _hoisted_1$
|
|
4940
|
-
const _hoisted_2$3 =
|
|
4941
|
-
const _hoisted_3$1 = {
|
|
4942
|
-
const _hoisted_4$1 = {
|
|
5076
|
+
const _hoisted_1$a = ["id"];
|
|
5077
|
+
const _hoisted_2$3 = { class: "list-item" };
|
|
5078
|
+
const _hoisted_3$1 = {
|
|
4943
5079
|
key: 2,
|
|
4944
5080
|
class: "right-tool"
|
|
4945
5081
|
};
|
|
4946
|
-
const _sfc_main$
|
|
5082
|
+
const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
4947
5083
|
...{
|
|
4948
|
-
name: "
|
|
5084
|
+
name: "MEditorDataSourceList"
|
|
4949
5085
|
},
|
|
4950
|
-
__name: "
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
const {
|
|
5086
|
+
__name: "DataSourceList",
|
|
5087
|
+
emits: ["edit", "remove"],
|
|
5088
|
+
setup(__props, { expose: __expose, emit }) {
|
|
5089
|
+
const { depService, editorService, dataSourceService } = inject("services") || {};
|
|
5090
|
+
const editable = computed(() => dataSourceService?.get("editable") ?? true);
|
|
4954
5091
|
const list = computed(
|
|
4955
5092
|
() => Object.values(depService?.targets["data-source"] || {}).map((target) => ({
|
|
4956
5093
|
id: target.id,
|
|
@@ -4964,8 +5101,123 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
4964
5101
|
}))
|
|
4965
5102
|
}))
|
|
4966
5103
|
);
|
|
5104
|
+
const editHandler = (id) => {
|
|
5105
|
+
emit("edit", id);
|
|
5106
|
+
};
|
|
5107
|
+
const removeHandler = async (id) => {
|
|
5108
|
+
await tMagicMessageBox.confirm("确定删除?", "提示", {
|
|
5109
|
+
confirmButtonText: "确定",
|
|
5110
|
+
cancelButtonText: "取消",
|
|
5111
|
+
type: "warning"
|
|
5112
|
+
});
|
|
5113
|
+
emit("remove", id);
|
|
5114
|
+
};
|
|
5115
|
+
const selectComp = (compId) => {
|
|
5116
|
+
const stage = editorService?.get("stage");
|
|
5117
|
+
editorService?.select(compId);
|
|
5118
|
+
stage?.select(compId);
|
|
5119
|
+
};
|
|
5120
|
+
const clickHandler = (data, node) => {
|
|
5121
|
+
if (data.type === "node") {
|
|
5122
|
+
selectComp(data.id);
|
|
5123
|
+
} else if (data.type === "key") {
|
|
5124
|
+
selectComp(node.parent.data.id);
|
|
5125
|
+
}
|
|
5126
|
+
};
|
|
5127
|
+
const tree = ref();
|
|
5128
|
+
__expose({
|
|
5129
|
+
filter(val) {
|
|
5130
|
+
debugger;
|
|
5131
|
+
tree.value?.filter(val);
|
|
5132
|
+
}
|
|
5133
|
+
});
|
|
5134
|
+
return (_ctx, _cache) => {
|
|
5135
|
+
return openBlock(), createBlock(unref(TMagicTree), {
|
|
5136
|
+
ref_key: "tree",
|
|
5137
|
+
ref: tree,
|
|
5138
|
+
class: "magic-editor-layer-tree",
|
|
5139
|
+
"node-key": "id",
|
|
5140
|
+
"empty-text": "暂无代码块",
|
|
5141
|
+
"default-expand-all": "",
|
|
5142
|
+
"expand-on-click-node": false,
|
|
5143
|
+
data: list.value,
|
|
5144
|
+
"highlight-current": true,
|
|
5145
|
+
onNodeClick: clickHandler
|
|
5146
|
+
}, {
|
|
5147
|
+
default: withCtx(({ data }) => [
|
|
5148
|
+
createElementVNode("div", {
|
|
5149
|
+
id: data.id,
|
|
5150
|
+
class: "list-container"
|
|
5151
|
+
}, [
|
|
5152
|
+
createElementVNode("div", _hoisted_2$3, [
|
|
5153
|
+
data.type === "code" ? (openBlock(), createBlock(_sfc_main$E, {
|
|
5154
|
+
key: 0,
|
|
5155
|
+
class: "codeIcon",
|
|
5156
|
+
icon: unref(Coin)
|
|
5157
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
5158
|
+
data.type === "node" ? (openBlock(), createBlock(_sfc_main$E, {
|
|
5159
|
+
key: 1,
|
|
5160
|
+
class: "compIcon",
|
|
5161
|
+
icon: unref(Aim)
|
|
5162
|
+
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
5163
|
+
createElementVNode("span", {
|
|
5164
|
+
class: normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
|
|
5165
|
+
}, toDisplayString(data.name) + "(" + toDisplayString(data.id) + ")", 3),
|
|
5166
|
+
data.type === "code" ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
|
|
5167
|
+
createVNode(unref(TMagicTooltip), {
|
|
5168
|
+
effect: "dark",
|
|
5169
|
+
content: editable.value ? "编辑" : "查看",
|
|
5170
|
+
placement: "bottom"
|
|
5171
|
+
}, {
|
|
5172
|
+
default: withCtx(() => [
|
|
5173
|
+
createVNode(_sfc_main$E, {
|
|
5174
|
+
icon: editable.value ? unref(Edit) : unref(View),
|
|
5175
|
+
class: "edit-icon",
|
|
5176
|
+
onClick: withModifiers(($event) => editHandler(`${data.id}`), ["stop"])
|
|
5177
|
+
}, null, 8, ["icon", "onClick"])
|
|
5178
|
+
]),
|
|
5179
|
+
_: 2
|
|
5180
|
+
}, 1032, ["content"]),
|
|
5181
|
+
editable.value ? (openBlock(), createBlock(unref(TMagicTooltip), {
|
|
5182
|
+
key: 0,
|
|
5183
|
+
effect: "dark",
|
|
5184
|
+
content: "删除",
|
|
5185
|
+
placement: "bottom"
|
|
5186
|
+
}, {
|
|
5187
|
+
default: withCtx(() => [
|
|
5188
|
+
createVNode(_sfc_main$E, {
|
|
5189
|
+
icon: unref(Close),
|
|
5190
|
+
class: "edit-icon",
|
|
5191
|
+
onClick: withModifiers(($event) => removeHandler(`${data.id}`), ["stop"])
|
|
5192
|
+
}, null, 8, ["icon", "onClick"])
|
|
5193
|
+
]),
|
|
5194
|
+
_: 2
|
|
5195
|
+
}, 1024)) : createCommentVNode("", true),
|
|
5196
|
+
renderSlot(_ctx.$slots, "data-source-panel-tool", {
|
|
5197
|
+
id: data.id,
|
|
5198
|
+
data: data.codeBlockContent
|
|
5199
|
+
})
|
|
5200
|
+
])) : createCommentVNode("", true)
|
|
5201
|
+
])
|
|
5202
|
+
], 8, _hoisted_1$a)
|
|
5203
|
+
]),
|
|
5204
|
+
_: 3
|
|
5205
|
+
}, 8, ["data"]);
|
|
5206
|
+
};
|
|
5207
|
+
}
|
|
5208
|
+
});
|
|
5209
|
+
|
|
5210
|
+
const _hoisted_1$9 = { class: "search-wrapper" };
|
|
5211
|
+
const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
5212
|
+
...{
|
|
5213
|
+
name: "MEditorDataSourceListPanel"
|
|
5214
|
+
},
|
|
5215
|
+
__name: "DataSourceListPanel",
|
|
5216
|
+
setup(__props) {
|
|
5217
|
+
const { dataSourceService } = inject("services") || {};
|
|
4967
5218
|
const editDialog = ref();
|
|
4968
5219
|
const dataSourceValues = ref({});
|
|
5220
|
+
const editable = computed(() => dataSourceService?.get("editable") ?? true);
|
|
4969
5221
|
const addHandler = () => {
|
|
4970
5222
|
if (!editDialog.value)
|
|
4971
5223
|
return;
|
|
@@ -4973,24 +5225,17 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
4973
5225
|
editDialog.value.show();
|
|
4974
5226
|
};
|
|
4975
5227
|
const editHandler = (id) => {
|
|
4976
|
-
if (!editDialog.value
|
|
5228
|
+
if (!editDialog.value)
|
|
4977
5229
|
return;
|
|
4978
5230
|
dataSourceValues.value = {
|
|
4979
5231
|
...dataSourceService?.getDataSourceById(id)
|
|
4980
5232
|
};
|
|
4981
5233
|
editDialog.value.show();
|
|
4982
5234
|
};
|
|
4983
|
-
const removeHandler =
|
|
4984
|
-
await tMagicMessageBox.confirm("确定删除?", "提示", {
|
|
4985
|
-
confirmButtonText: "确定",
|
|
4986
|
-
cancelButtonText: "取消",
|
|
4987
|
-
type: "warning"
|
|
4988
|
-
});
|
|
5235
|
+
const removeHandler = (id) => {
|
|
4989
5236
|
dataSourceService?.remove(id);
|
|
4990
5237
|
};
|
|
4991
5238
|
const submitDataSourceHandler = (value) => {
|
|
4992
|
-
if (!services)
|
|
4993
|
-
return;
|
|
4994
5239
|
if (value.id) {
|
|
4995
5240
|
dataSourceService?.update(value);
|
|
4996
5241
|
} else {
|
|
@@ -4998,28 +5243,17 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
4998
5243
|
}
|
|
4999
5244
|
editDialog.value?.hide();
|
|
5000
5245
|
};
|
|
5001
|
-
const
|
|
5246
|
+
const dataSourceList = ref();
|
|
5002
5247
|
const filterTextChangeHandler = (val) => {
|
|
5003
|
-
|
|
5004
|
-
};
|
|
5005
|
-
const selectComp = (compId) => {
|
|
5006
|
-
const stage = editorService?.get("stage");
|
|
5007
|
-
editorService?.select(compId);
|
|
5008
|
-
stage?.select(compId);
|
|
5009
|
-
};
|
|
5010
|
-
const clickHandler = (data, node) => {
|
|
5011
|
-
if (data.type === "node") {
|
|
5012
|
-
selectComp(data.id);
|
|
5013
|
-
} else if (data.type === "key") {
|
|
5014
|
-
selectComp(node.parent.data.id);
|
|
5015
|
-
}
|
|
5248
|
+
dataSourceList.value?.filter(val);
|
|
5016
5249
|
};
|
|
5017
5250
|
return (_ctx, _cache) => {
|
|
5018
5251
|
return openBlock(), createBlock(unref(TMagicScrollbar), { class: "data-source-list-panel m-editor-dep-list-panel" }, {
|
|
5019
5252
|
default: withCtx(() => [
|
|
5020
5253
|
createElementVNode("div", _hoisted_1$9, [
|
|
5021
|
-
createVNode(_sfc_main$
|
|
5022
|
-
|
|
5254
|
+
createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
|
|
5255
|
+
editable.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
5256
|
+
key: 0,
|
|
5023
5257
|
type: "primary",
|
|
5024
5258
|
size: "small",
|
|
5025
5259
|
onClick: addHandler
|
|
@@ -5028,87 +5262,22 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
5028
5262
|
createTextVNode("新增")
|
|
5029
5263
|
]),
|
|
5030
5264
|
_: 1
|
|
5031
|
-
})
|
|
5265
|
+
})) : createCommentVNode("", true)
|
|
5032
5266
|
]),
|
|
5033
|
-
createVNode(unref(TMagicTree), {
|
|
5034
|
-
ref_key: "tree",
|
|
5035
|
-
ref: tree,
|
|
5036
|
-
class: "magic-editor-layer-tree",
|
|
5037
|
-
"node-key": "id",
|
|
5038
|
-
"empty-text": "暂无代码块",
|
|
5039
|
-
"default-expand-all": "",
|
|
5040
|
-
"expand-on-click-node": false,
|
|
5041
|
-
data: list.value,
|
|
5042
|
-
"highlight-current": true,
|
|
5043
|
-
onNodeClick: clickHandler
|
|
5044
|
-
}, {
|
|
5045
|
-
default: withCtx(({ data }) => [
|
|
5046
|
-
createElementVNode("div", {
|
|
5047
|
-
id: data.id,
|
|
5048
|
-
class: "list-container"
|
|
5049
|
-
}, [
|
|
5050
|
-
createElementVNode("div", _hoisted_3$1, [
|
|
5051
|
-
data.type === "code" ? (openBlock(), createBlock(_sfc_main$E, {
|
|
5052
|
-
key: 0,
|
|
5053
|
-
class: "codeIcon",
|
|
5054
|
-
icon: unref(Coin)
|
|
5055
|
-
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
5056
|
-
data.type === "node" ? (openBlock(), createBlock(_sfc_main$E, {
|
|
5057
|
-
key: 1,
|
|
5058
|
-
class: "compIcon",
|
|
5059
|
-
icon: unref(Aim)
|
|
5060
|
-
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
5061
|
-
createElementVNode("span", {
|
|
5062
|
-
class: normalizeClass(["name", { code: data.type === "code", hook: data.type === "key" }])
|
|
5063
|
-
}, toDisplayString(data.name) + "(" + toDisplayString(data.id) + ")", 3),
|
|
5064
|
-
data.type === "code" ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
|
|
5065
|
-
createVNode(unref(TMagicTooltip), {
|
|
5066
|
-
effect: "dark",
|
|
5067
|
-
content: "编辑",
|
|
5068
|
-
placement: "bottom"
|
|
5069
|
-
}, {
|
|
5070
|
-
default: withCtx(() => [
|
|
5071
|
-
createVNode(_sfc_main$E, {
|
|
5072
|
-
class: "edit-icon",
|
|
5073
|
-
icon: unref(Edit),
|
|
5074
|
-
onClick: withModifiers(($event) => editHandler(`${data.id}`), ["stop"])
|
|
5075
|
-
}, null, 8, ["icon", "onClick"])
|
|
5076
|
-
]),
|
|
5077
|
-
_: 2
|
|
5078
|
-
}, 1024),
|
|
5079
|
-
createVNode(unref(TMagicTooltip), {
|
|
5080
|
-
effect: "dark",
|
|
5081
|
-
content: "删除",
|
|
5082
|
-
placement: "bottom"
|
|
5083
|
-
}, {
|
|
5084
|
-
default: withCtx(() => [
|
|
5085
|
-
createVNode(_sfc_main$E, {
|
|
5086
|
-
icon: unref(Close),
|
|
5087
|
-
class: "edit-icon",
|
|
5088
|
-
onClick: withModifiers(($event) => removeHandler(`${data.id}`), ["stop"])
|
|
5089
|
-
}, null, 8, ["icon", "onClick"])
|
|
5090
|
-
]),
|
|
5091
|
-
_: 2
|
|
5092
|
-
}, 1024),
|
|
5093
|
-
renderSlot(_ctx.$slots, "data-source-panel-tool", {
|
|
5094
|
-
id: data.id,
|
|
5095
|
-
data: data.codeBlockContent
|
|
5096
|
-
})
|
|
5097
|
-
])) : createCommentVNode("", true)
|
|
5098
|
-
])
|
|
5099
|
-
], 8, _hoisted_2$3)
|
|
5100
|
-
]),
|
|
5101
|
-
_: 3
|
|
5102
|
-
}, 8, ["data"]),
|
|
5103
5267
|
createVNode(_sfc_main$h, {
|
|
5268
|
+
onEdit: editHandler,
|
|
5269
|
+
onRemove: removeHandler
|
|
5270
|
+
}),
|
|
5271
|
+
createVNode(_sfc_main$i, {
|
|
5104
5272
|
ref_key: "editDialog",
|
|
5105
5273
|
ref: editDialog,
|
|
5274
|
+
disabled: !editable.value,
|
|
5106
5275
|
values: dataSourceValues.value,
|
|
5107
5276
|
title: typeof dataSourceValues.value.id !== "undefined" ? `编辑${dataSourceValues.value.title}` : "新增",
|
|
5108
5277
|
onSubmit: submitDataSourceHandler
|
|
5109
|
-
}, null, 8, ["values", "title"])
|
|
5278
|
+
}, null, 8, ["disabled", "values", "title"])
|
|
5110
5279
|
]),
|
|
5111
|
-
_:
|
|
5280
|
+
_: 1
|
|
5112
5281
|
});
|
|
5113
5282
|
};
|
|
5114
5283
|
}
|
|
@@ -5194,7 +5363,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
5194
5363
|
"model-value": collapseValue.value
|
|
5195
5364
|
}, {
|
|
5196
5365
|
default: withCtx(() => [
|
|
5197
|
-
createVNode(_sfc_main$
|
|
5366
|
+
createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
|
|
5198
5367
|
(openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (group, index) => {
|
|
5199
5368
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
5200
5369
|
group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
|
|
@@ -5351,7 +5520,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
5351
5520
|
}, [
|
|
5352
5521
|
createElementVNode("div", null, [
|
|
5353
5522
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
|
|
5354
|
-
return openBlock(), createBlock(_sfc_main$
|
|
5523
|
+
return openBlock(), createBlock(_sfc_main$q, {
|
|
5355
5524
|
"event-type": "mouseup",
|
|
5356
5525
|
ref_for: true,
|
|
5357
5526
|
ref_key: "buttons",
|
|
@@ -5674,7 +5843,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
5674
5843
|
return;
|
|
5675
5844
|
const { data: node } = e;
|
|
5676
5845
|
const parent = editorService?.getParentById(node.id, false);
|
|
5677
|
-
const layout = await editorService?.getLayout(parent);
|
|
5846
|
+
const layout = await editorService?.getLayout(parent, node);
|
|
5678
5847
|
node.style.position = layout;
|
|
5679
5848
|
if (layout === Layout.RELATIVE) {
|
|
5680
5849
|
node.style.top = 0;
|
|
@@ -5836,7 +6005,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
5836
6005
|
return openBlock(), createBlock(unref(TMagicScrollbar), { class: "magic-editor-layer-panel" }, {
|
|
5837
6006
|
default: withCtx(() => [
|
|
5838
6007
|
renderSlot(_ctx.$slots, "layer-panel-header"),
|
|
5839
|
-
createVNode(_sfc_main$
|
|
6008
|
+
createVNode(_sfc_main$n, { onSearch: filterTextChangeHandler }),
|
|
5840
6009
|
values.value.length ? (openBlock(), createBlock(unref(TMagicTree), {
|
|
5841
6010
|
key: 0,
|
|
5842
6011
|
class: "magic-editor-layer-tree",
|
|
@@ -5940,7 +6109,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
5940
6109
|
type: "component",
|
|
5941
6110
|
icon: EditPen,
|
|
5942
6111
|
text: "代码编辑",
|
|
5943
|
-
component: _sfc_main$
|
|
6112
|
+
component: _sfc_main$j,
|
|
5944
6113
|
slots: {}
|
|
5945
6114
|
},
|
|
5946
6115
|
"data-source": {
|
|
@@ -6034,16 +6203,6 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
6034
6203
|
]),
|
|
6035
6204
|
key: "4"
|
|
6036
6205
|
} : void 0,
|
|
6037
|
-
config.$key === "code-block" || config.slots?.codeBlockEditPanelHeader ? {
|
|
6038
|
-
name: "code-block-edit-panel-header",
|
|
6039
|
-
fn: withCtx(({ id }) => [
|
|
6040
|
-
config.$key === "code-block" ? renderSlot(_ctx.$slots, "code-block-edit-panel-header", {
|
|
6041
|
-
key: 0,
|
|
6042
|
-
id
|
|
6043
|
-
}) : config.slots?.codeBlockEditPanelHeader ? (openBlock(), createBlock(resolveDynamicComponent(config.slots.codeBlockEditPanelHeader), { key: 1 })) : createCommentVNode("", true)
|
|
6044
|
-
]),
|
|
6045
|
-
key: "5"
|
|
6046
|
-
} : void 0,
|
|
6047
6206
|
config.$key === "layer" || config.slots?.layerNodeContent ? {
|
|
6048
6207
|
name: "layer-node-content",
|
|
6049
6208
|
fn: withCtx(({ data: nodeData, node }) => [
|
|
@@ -6057,7 +6216,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
6057
6216
|
node
|
|
6058
6217
|
}, null, 8, ["data", "node"])) : createCommentVNode("", true)
|
|
6059
6218
|
]),
|
|
6060
|
-
key: "
|
|
6219
|
+
key: "5"
|
|
6061
6220
|
} : void 0
|
|
6062
6221
|
]), 1040)) : createCommentVNode("", true)
|
|
6063
6222
|
]),
|
|
@@ -6303,7 +6462,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
6303
6462
|
default: withCtx(() => [
|
|
6304
6463
|
createElementVNode("div", null, [
|
|
6305
6464
|
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
6306
|
-
createVNode(_sfc_main$
|
|
6465
|
+
createVNode(_sfc_main$q, {
|
|
6307
6466
|
data: {
|
|
6308
6467
|
type: "button",
|
|
6309
6468
|
text: "复制",
|
|
@@ -6311,7 +6470,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
6311
6470
|
handler: () => copy(item)
|
|
6312
6471
|
}
|
|
6313
6472
|
}, null, 8, ["data"]),
|
|
6314
|
-
createVNode(_sfc_main$
|
|
6473
|
+
createVNode(_sfc_main$q, {
|
|
6315
6474
|
data: {
|
|
6316
6475
|
type: "button",
|
|
6317
6476
|
text: "删除",
|
|
@@ -7046,22 +7205,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
7046
7205
|
|
|
7047
7206
|
class CodeBlock extends BaseService {
|
|
7048
7207
|
state = reactive({
|
|
7049
|
-
isShowCodeEditor: false,
|
|
7050
7208
|
codeDsl: null,
|
|
7051
|
-
id: "",
|
|
7052
7209
|
editable: true,
|
|
7053
7210
|
combineIds: [],
|
|
7054
|
-
undeletableList: []
|
|
7211
|
+
undeletableList: [],
|
|
7212
|
+
paramsColConfig: void 0
|
|
7055
7213
|
});
|
|
7056
7214
|
constructor() {
|
|
7057
|
-
super([
|
|
7058
|
-
"setCodeDslById",
|
|
7059
|
-
"setCodeEditorShowStatus",
|
|
7060
|
-
"setEditStatus",
|
|
7061
|
-
"setCombineIds",
|
|
7062
|
-
"setUndeleteableList",
|
|
7063
|
-
"deleteCodeDslByIds"
|
|
7064
|
-
]);
|
|
7215
|
+
super(["setCodeDslById", "setEditStatus", "setCombineIds", "setUndeleteableList", "deleteCodeDslByIds"]);
|
|
7065
7216
|
}
|
|
7066
7217
|
/**
|
|
7067
7218
|
* 设置活动的代码块dsl数据源
|
|
@@ -7108,7 +7259,10 @@ class CodeBlock extends BaseService {
|
|
|
7108
7259
|
const codeConfigProcessed = codeConfig;
|
|
7109
7260
|
if (codeConfig.content) {
|
|
7110
7261
|
const parseDSL = getConfig("parseDSL");
|
|
7111
|
-
|
|
7262
|
+
if (typeof codeConfig.content === "string") {
|
|
7263
|
+
codeConfig.content = parseDSL(codeConfig.content);
|
|
7264
|
+
}
|
|
7265
|
+
codeConfigProcessed.content = codeConfig.content;
|
|
7112
7266
|
}
|
|
7113
7267
|
const existContent = codeDsl[id] || {};
|
|
7114
7268
|
codeDsl[id] = {
|
|
@@ -7126,40 +7280,6 @@ class CodeBlock extends BaseService {
|
|
|
7126
7280
|
const codeDsl = this.getCodeDsl();
|
|
7127
7281
|
return pick(codeDsl, ids);
|
|
7128
7282
|
}
|
|
7129
|
-
/**
|
|
7130
|
-
* 设置代码编辑面板展示状态
|
|
7131
|
-
* @param {boolean} status 是否展示代码编辑面板
|
|
7132
|
-
* @returns {void}
|
|
7133
|
-
*/
|
|
7134
|
-
async setCodeEditorShowStatus(status) {
|
|
7135
|
-
this.state.isShowCodeEditor = status;
|
|
7136
|
-
}
|
|
7137
|
-
/**
|
|
7138
|
-
* 获取代码编辑面板展示状态
|
|
7139
|
-
* @returns {boolean} 是否展示代码编辑面板
|
|
7140
|
-
*/
|
|
7141
|
-
getCodeEditorShowStatus() {
|
|
7142
|
-
return this.state.isShowCodeEditor;
|
|
7143
|
-
}
|
|
7144
|
-
/**
|
|
7145
|
-
* 设置代码编辑面板展示状态及展示内容
|
|
7146
|
-
* @param {boolean} status 是否展示代码编辑面板
|
|
7147
|
-
* @param {Id} id 代码块id
|
|
7148
|
-
* @returns {void}
|
|
7149
|
-
*/
|
|
7150
|
-
setCodeEditorContent(status, id) {
|
|
7151
|
-
if (!id)
|
|
7152
|
-
return;
|
|
7153
|
-
this.setId(id);
|
|
7154
|
-
this.state.isShowCodeEditor = status;
|
|
7155
|
-
}
|
|
7156
|
-
/**
|
|
7157
|
-
* 获取当前选中的代码块内容
|
|
7158
|
-
* @returns {CodeBlockContent | null}
|
|
7159
|
-
*/
|
|
7160
|
-
getCurrentDsl() {
|
|
7161
|
-
return this.getCodeContentById(this.state.id);
|
|
7162
|
-
}
|
|
7163
7283
|
/**
|
|
7164
7284
|
* 获取编辑状态
|
|
7165
7285
|
* @returns {boolean} 是否可编辑
|
|
@@ -7175,23 +7295,6 @@ class CodeBlock extends BaseService {
|
|
|
7175
7295
|
async setEditStatus(status) {
|
|
7176
7296
|
this.state.editable = status;
|
|
7177
7297
|
}
|
|
7178
|
-
/**
|
|
7179
|
-
* 设置当前选中的代码块ID
|
|
7180
|
-
* @param {Id} id 代码块id
|
|
7181
|
-
* @returns {void}
|
|
7182
|
-
*/
|
|
7183
|
-
setId(id) {
|
|
7184
|
-
if (!id)
|
|
7185
|
-
return;
|
|
7186
|
-
this.state.id = id;
|
|
7187
|
-
}
|
|
7188
|
-
/**
|
|
7189
|
-
* 获取当前选中的代码块ID
|
|
7190
|
-
* @returns {Id} id 代码块id
|
|
7191
|
-
*/
|
|
7192
|
-
getId() {
|
|
7193
|
-
return this.state.id;
|
|
7194
|
-
}
|
|
7195
7298
|
/**
|
|
7196
7299
|
* 设置当前选中组件已关联绑定的代码块id数组
|
|
7197
7300
|
* @param {string[]} ids 代码块id数组
|
|
@@ -7253,6 +7356,12 @@ class CodeBlock extends BaseService {
|
|
|
7253
7356
|
this.emit("remove", id);
|
|
7254
7357
|
});
|
|
7255
7358
|
}
|
|
7359
|
+
setParamsColConfig(config) {
|
|
7360
|
+
this.state.paramsColConfig = config;
|
|
7361
|
+
}
|
|
7362
|
+
getParamsColConfig() {
|
|
7363
|
+
return this.state.paramsColConfig;
|
|
7364
|
+
}
|
|
7256
7365
|
/**
|
|
7257
7366
|
* 生成代码块唯一id
|
|
7258
7367
|
* @returns {Id} 代码块唯一id
|
|
@@ -7266,9 +7375,7 @@ class CodeBlock extends BaseService {
|
|
|
7266
7375
|
return await this.getUniqueId();
|
|
7267
7376
|
}
|
|
7268
7377
|
resetState() {
|
|
7269
|
-
this.state.isShowCodeEditor = false;
|
|
7270
7378
|
this.state.codeDsl = null;
|
|
7271
|
-
this.state.id = "";
|
|
7272
7379
|
this.state.editable = true;
|
|
7273
7380
|
this.state.combineIds = [];
|
|
7274
7381
|
this.state.undeletableList = [];
|
|
@@ -7401,6 +7508,17 @@ const fillConfig = (config) => [
|
|
|
7401
7508
|
defaultValue: []
|
|
7402
7509
|
}
|
|
7403
7510
|
]
|
|
7511
|
+
},
|
|
7512
|
+
{
|
|
7513
|
+
type: "panel",
|
|
7514
|
+
title: "方法定义",
|
|
7515
|
+
items: [
|
|
7516
|
+
{
|
|
7517
|
+
name: "methods",
|
|
7518
|
+
type: "data-source-methods",
|
|
7519
|
+
defaultValue: []
|
|
7520
|
+
}
|
|
7521
|
+
]
|
|
7404
7522
|
}
|
|
7405
7523
|
];
|
|
7406
7524
|
const getFormConfig = (type, configs) => {
|
|
@@ -7417,6 +7535,7 @@ const getFormConfig = (type, configs) => {
|
|
|
7417
7535
|
class DataSource extends BaseService {
|
|
7418
7536
|
state = reactive({
|
|
7419
7537
|
dataSources: [],
|
|
7538
|
+
editable: true,
|
|
7420
7539
|
configs: {}
|
|
7421
7540
|
});
|
|
7422
7541
|
set(name, value) {
|
|
@@ -8412,11 +8531,11 @@ const initServiceEvents = (props, emit, { editorService, codeBlockService, dataS
|
|
|
8412
8531
|
const _sfc_main = defineComponent({
|
|
8413
8532
|
name: "MEditor",
|
|
8414
8533
|
components: {
|
|
8415
|
-
TMagicNavMenu: _sfc_main$
|
|
8534
|
+
TMagicNavMenu: _sfc_main$p,
|
|
8416
8535
|
Sidebar: _sfc_main$a,
|
|
8417
8536
|
Workspace: _sfc_main$1,
|
|
8418
|
-
PropsPanel: _sfc_main$
|
|
8419
|
-
Framework: _sfc_main$
|
|
8537
|
+
PropsPanel: _sfc_main$o,
|
|
8538
|
+
Framework: _sfc_main$r
|
|
8420
8539
|
},
|
|
8421
8540
|
props: editorProps,
|
|
8422
8541
|
emits: ["props-panel-mounted", "update:modelValue"],
|
|
@@ -8519,9 +8638,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
8519
8638
|
data
|
|
8520
8639
|
})
|
|
8521
8640
|
]),
|
|
8522
|
-
"code-block-edit-panel-header": withCtx(({ id }) => [
|
|
8523
|
-
renderSlot(_ctx.$slots, "code-block-edit-panel-header", { id })
|
|
8524
|
-
]),
|
|
8525
8641
|
_: 3
|
|
8526
8642
|
}, 8, ["data", "layer-content-menu"])
|
|
8527
8643
|
])
|
|
@@ -8584,19 +8700,21 @@ const index = {
|
|
|
8584
8700
|
app.config.globalProperties.$TMAGIC_EDITOR = option;
|
|
8585
8701
|
setConfig(option);
|
|
8586
8702
|
app.component(Editor.name, Editor);
|
|
8587
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
8588
|
-
app.component("m-fields-code-link", _sfc_main$
|
|
8589
|
-
app.component("m-fields-vs-code", _sfc_main$
|
|
8590
|
-
app.component("magic-code-editor", _sfc_main$
|
|
8591
|
-
app.component("m-fields-code-select", _sfc_main$
|
|
8703
|
+
app.component("m-fields-ui-select", _sfc_main$v);
|
|
8704
|
+
app.component("m-fields-code-link", _sfc_main$I);
|
|
8705
|
+
app.component("m-fields-vs-code", _sfc_main$J);
|
|
8706
|
+
app.component("magic-code-editor", _sfc_main$K);
|
|
8707
|
+
app.component("m-fields-code-select", _sfc_main$H);
|
|
8592
8708
|
app.component("m-fields-code-select-col", _sfc_main$D);
|
|
8593
|
-
app.component("m-fields-event-select", _sfc_main$
|
|
8709
|
+
app.component("m-fields-event-select", _sfc_main$x);
|
|
8594
8710
|
app.component("m-fields-data-source-fields", _sfc_main$C);
|
|
8595
|
-
app.component("m-fields-key-value", _sfc_main$
|
|
8711
|
+
app.component("m-fields-key-value", _sfc_main$w);
|
|
8596
8712
|
app.component("m-fields-data-source-input", _sfc_main$B);
|
|
8597
|
-
app.component("m-fields-data-source-select", _sfc_main$
|
|
8713
|
+
app.component("m-fields-data-source-select", _sfc_main$y);
|
|
8714
|
+
app.component("m-fields-data-source-methods", _sfc_main$A);
|
|
8715
|
+
app.component("m-fields-data-source-method-select", _sfc_main$z);
|
|
8598
8716
|
}
|
|
8599
8717
|
};
|
|
8600
8718
|
|
|
8601
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$
|
|
8719
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$G as CodeBlockEditor, _sfc_main$k as CodeBlockList, _sfc_main$j as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$H as CodeSelect, _sfc_main$D as CodeSelectCol, ColumnLayout, _sfc_main$f as ComponentListPanel, _sfc_main$e as ContentMenu, _sfc_main$C as DataSourceFields, _sfc_main$B as DataSourceInput, _sfc_main$z as DataSourceMethodSelect, _sfc_main$A as DataSourceMethods, _sfc_main$y as DataSourceSelect, _sfc_main$x as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$E as Icon, KeyBindingCommand, _sfc_main$w as KeyValue, Keys, LayerOffset, _sfc_main$b as LayerPanel, Layout, _sfc_main$t as LayoutContainer, _sfc_main$o as PropsPanel, _sfc_main$u as Resizer, _sfc_main$t as SplitView, _sfc_main$K as TMagicCodeEditor, Editor as TMagicEditor, _sfc_main$q as ToolButton, V_GUIDE_LINE_STORAGE_KEY, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, editorService, error, eventsService, fillConfig$1 as fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, uiService, useStage, warn };
|
|
8602
8720
|
//# sourceMappingURL=tmagic-editor.js.map
|