@tmagic/editor 1.4.2 → 1.4.4
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 +15 -1
- package/dist/tmagic-editor.js +1242 -1163
- package/dist/tmagic-editor.umd.cjs +1260 -1180
- package/package.json +11 -11
- package/src/Editor.vue +6 -1
- package/src/editorProps.ts +3 -0
- package/src/fields/CodeSelectCol.vue +26 -18
- package/src/fields/DataSourceFieldSelect.vue +38 -33
- package/src/fields/DataSourceMethodSelect.vue +25 -31
- package/src/fields/DataSourceSelect.vue +49 -13
- package/src/fields/EventSelect.vue +8 -6
- package/src/hooks/use-editor-content-height.ts +11 -5
- package/src/layouts/PropsPanel.vue +3 -1
- package/src/layouts/sidebar/Sidebar.vue +24 -8
- package/src/layouts/sidebar/code-block/CodeBlockListPanel.vue +6 -1
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +6 -1
- package/src/services/ui.ts +1 -0
- package/src/theme/data-source-field.scss +12 -0
- package/src/theme/props-panel.scss +1 -1
- package/src/theme/theme.scss +1 -0
- package/src/type.ts +31 -2
- package/types/components/ContentMenu.vue.d.ts +3 -3
- package/types/components/ToolButton.vue.d.ts +2 -2
- package/types/editorProps.d.ts +3 -0
- package/types/layouts/PropsPanel.vue.d.ts +2 -0
- package/types/layouts/sidebar/Sidebar.vue.d.ts +7 -7
- package/types/layouts/sidebar/layer/LayerMenu.vue.d.ts +2 -2
- package/types/layouts/sidebar/layer/LayerPanel.vue.d.ts +4 -4
- package/types/layouts/sidebar/layer/use-click.d.ts +13 -13
- package/types/layouts/workspace/Workspace.vue.d.ts +4 -4
- package/types/layouts/workspace/viewer/ViewerMenu.vue.d.ts +2 -2
- package/types/services/ui.d.ts +18 -0
- package/types/type.d.ts +26 -2
package/dist/tmagic-editor.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, createElementVNode, createElementBlock, normalizeClass, resolveDynamicComponent, toRaw, ref, watch, onMounted, onBeforeUnmount, Teleport, normalizeStyle, computed, reactive, resolveComponent, inject, mergeModels, useModel, nextTick, provide, renderSlot, toDisplayString,
|
|
2
|
-
import { Edit, FullScreen,
|
|
1
|
+
import { defineComponent, openBlock, createBlock, unref, withCtx, createVNode, createElementVNode, createElementBlock, normalizeClass, resolveDynamicComponent, toRaw, ref, watch, onMounted, onBeforeUnmount, Teleport, normalizeStyle, computed, reactive, resolveComponent, inject, createCommentVNode, mergeModels, useModel, nextTick, provide, renderSlot, toDisplayString, createTextVNode, isRef, mergeProps, Fragment, renderList, createStaticVNode, watchEffect, withModifiers, toHandlers, resolveDirective, withDirectives, createSlots, markRaw, getCurrentInstance, vShow, Transition, mergeDefaults } from 'vue';
|
|
2
|
+
import { Edit, FullScreen, View, Close, Coin, Delete, Plus, ArrowDown, ArrowLeftBold, ArrowRightBold, CaretBottom, DocumentCopy, Grid, Memo, ScaleToOriginal, ZoomOut, ZoomIn, Right, Back, Document, Search, ArrowRight, CopyDocument, Files, Hide, Goods, List, EditPen, CloseBold, Top, Bottom } from '@element-plus/icons-vue';
|
|
3
3
|
import { throttle, isEmpty, cloneDeep, mergeWith, isObject, uniq, get, map, has, pick, keys } from 'lodash-es';
|
|
4
4
|
import serialize from 'serialize-javascript';
|
|
5
|
-
import { TMagicIcon, TMagicButton, TMagicCard, useZIndex, tMagicMessage,
|
|
5
|
+
import { TMagicIcon, TMagicButton, TMagicCard, useZIndex, tMagicMessage, tMagicMessageBox, getConfig as getConfig$1, TMagicTag, TMagicDialog, TMagicSwitch, TMagicInput, TMagicTooltip, TMagicDivider, TMagicDropdown, TMagicDropdownMenu, TMagicDropdownItem, TMagicPopover, TMagicScrollbar, TMagicCollapse, TMagicCollapseItem } from '@tmagic/design';
|
|
6
6
|
import { emmetHTML, emmetCSS } from 'emmet-monaco-es';
|
|
7
7
|
import * as monaco from 'monaco-editor';
|
|
8
|
-
import { MContainer,
|
|
8
|
+
import { MContainer, MForm, filterFunction, createValues, MFormBox, MCascader, MSelect, MPanel } from '@tmagic/form';
|
|
9
9
|
import { HookCodeType, HookType, NodeType, ActionType } from '@tmagic/schema';
|
|
10
|
-
import VanillaMoveable from 'moveable';
|
|
11
10
|
import { MagicTable } from '@tmagic/table';
|
|
12
11
|
import { toLine, guid, isPage, isPageFragment, isPop, getNodePath, isNumber, getValueByKeyPath, setValueByKeyPath, convertToNumber, getDefaultValueFromFields, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, getKeys, addClassName, removeClassName, removeClassNameByClassName, getNodes } from '@tmagic/utils';
|
|
12
|
+
import VanillaMoveable from 'moveable';
|
|
13
13
|
import { Watcher, DepTargetType, createRelatedCompTarget, createCodeBlockTarget, createDataSourceTarget, createDataSourceMethodTarget, createDataSourceCondTarget } from '@tmagic/dep';
|
|
14
14
|
export { DepTargetType } from '@tmagic/dep';
|
|
15
|
+
import { EventEmitter } from 'events';
|
|
15
16
|
import Gesto from 'gesto';
|
|
16
17
|
import StageCore, { GuidesType, getOffset, calcValueByFontsize, RenderType, CONTAINER_HIGHLIGHT_CLASS_NAME, ContainerHighlightType } from '@tmagic/stage';
|
|
17
|
-
import { EventEmitter } from 'events';
|
|
18
18
|
import { DEFAULT_EVENTS, DEFAULT_METHODS } from '@tmagic/core';
|
|
19
19
|
import KeyController from 'keycon';
|
|
20
20
|
|
|
21
|
-
const _hoisted_1$
|
|
21
|
+
const _hoisted_1$u = ["src"];
|
|
22
22
|
const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
23
23
|
...{
|
|
24
24
|
name: "MEditorIcon"
|
|
@@ -43,7 +43,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
|
43
43
|
class: "magic-editor-icon"
|
|
44
44
|
}, {
|
|
45
45
|
default: withCtx(() => [
|
|
46
|
-
createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$
|
|
46
|
+
createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$u)
|
|
47
47
|
]),
|
|
48
48
|
_: 1
|
|
49
49
|
})) : typeof _ctx.icon === "string" ? (openBlock(), createElementBlock("i", {
|
|
@@ -71,7 +71,7 @@ const getConfig = (key) => $TMAGIC_EDITOR[key];
|
|
|
71
71
|
emmetHTML(monaco);
|
|
72
72
|
emmetCSS(monaco, ["css", "scss"]);
|
|
73
73
|
|
|
74
|
-
const _hoisted_1$
|
|
74
|
+
const _hoisted_1$t = {
|
|
75
75
|
class: /* @__PURE__ */ normalizeClass(`magic-code-editor`)
|
|
76
76
|
};
|
|
77
77
|
const _sfc_main$T = /* @__PURE__ */ defineComponent({
|
|
@@ -232,7 +232,7 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
|
|
|
232
232
|
}
|
|
233
233
|
});
|
|
234
234
|
return (_ctx, _cache) => {
|
|
235
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
235
|
+
return openBlock(), createElementBlock("div", _hoisted_1$t, [
|
|
236
236
|
(openBlock(), createBlock(Teleport, {
|
|
237
237
|
to: "body",
|
|
238
238
|
disabled: !fullScreen.value
|
|
@@ -505,689 +505,164 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
505
505
|
}
|
|
506
506
|
});
|
|
507
507
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
508
|
+
function BaseFormConfig() {
|
|
509
|
+
return [
|
|
510
|
+
{
|
|
511
|
+
name: "id",
|
|
512
|
+
type: "hidden"
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
name: "type",
|
|
516
|
+
text: "类型",
|
|
517
|
+
type: "hidden",
|
|
518
|
+
defaultValue: "base"
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: "title",
|
|
522
|
+
text: "名称",
|
|
523
|
+
rules: [
|
|
524
|
+
{
|
|
525
|
+
required: true,
|
|
526
|
+
message: "请输入名称"
|
|
527
|
+
}
|
|
528
|
+
]
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
name: "description",
|
|
532
|
+
text: "描述"
|
|
533
|
+
}
|
|
534
|
+
];
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
const HttpFormConfig = [
|
|
538
|
+
{
|
|
539
|
+
name: "autoFetch",
|
|
540
|
+
text: "自动请求",
|
|
541
|
+
type: "switch",
|
|
542
|
+
defaultValue: true
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
name: "responseOptions",
|
|
546
|
+
items: [
|
|
547
|
+
{
|
|
548
|
+
name: "dataPath",
|
|
549
|
+
text: "数据路径"
|
|
539
550
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
551
|
+
]
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
type: "fieldset",
|
|
555
|
+
name: "options",
|
|
556
|
+
legend: "HTTP 配置",
|
|
557
|
+
items: [
|
|
558
|
+
{
|
|
559
|
+
name: "url",
|
|
560
|
+
text: "URL"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
name: "method",
|
|
564
|
+
text: "Method",
|
|
565
|
+
type: "select",
|
|
566
|
+
options: [
|
|
567
|
+
{ text: "GET", value: "GET" },
|
|
568
|
+
{ text: "POST", value: "POST" },
|
|
569
|
+
{ text: "PUT", value: "PUT" },
|
|
570
|
+
{ text: "DELETE", value: "DELETE" }
|
|
571
|
+
]
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
name: "params",
|
|
575
|
+
type: "key-value",
|
|
576
|
+
defaultValue: {},
|
|
577
|
+
text: "参数"
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
name: "data",
|
|
581
|
+
type: "key-value",
|
|
582
|
+
defaultValue: {},
|
|
583
|
+
advanced: true,
|
|
584
|
+
text: "请求体"
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
name: "headers",
|
|
588
|
+
type: "key-value",
|
|
589
|
+
defaultValue: {},
|
|
590
|
+
text: "请求头"
|
|
548
591
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
snappable: true,
|
|
567
|
-
dragTarget: titleEl.value,
|
|
568
|
-
dragTargetSelf: false,
|
|
569
|
-
linePadding: 10,
|
|
570
|
-
controlPadding: 10,
|
|
571
|
-
bounds: { left: 0, top: 0, right: 0, bottom: 0, position: "css" }
|
|
572
|
-
});
|
|
573
|
-
moveable.on("drag", (e) => {
|
|
574
|
-
e.target.style.transform = e.transform;
|
|
575
|
-
});
|
|
576
|
-
moveable.on("resize", (e) => {
|
|
577
|
-
width.value = e.width;
|
|
578
|
-
height.value = e.height;
|
|
579
|
-
e.target.style.width = `${e.width}px`;
|
|
580
|
-
e.target.style.height = `${e.height}px`;
|
|
581
|
-
e.target.style.transform = e.drag.transform;
|
|
582
|
-
});
|
|
583
|
-
};
|
|
584
|
-
const destroyMoveable = () => {
|
|
585
|
-
moveable?.destroy();
|
|
586
|
-
moveable = null;
|
|
587
|
-
};
|
|
588
|
-
watch(
|
|
589
|
-
visible,
|
|
590
|
-
async (visible2) => {
|
|
591
|
-
if (visible2) {
|
|
592
|
-
await nextTick();
|
|
593
|
-
curZIndex.value = zIndex.nextZIndex();
|
|
594
|
-
const targetRect = target.value?.getBoundingClientRect();
|
|
595
|
-
if (targetRect) {
|
|
596
|
-
width.value = targetRect.width;
|
|
597
|
-
height.value = targetRect.height;
|
|
598
|
-
initMoveable();
|
|
592
|
+
]
|
|
593
|
+
}
|
|
594
|
+
];
|
|
595
|
+
|
|
596
|
+
const fillConfig$1 = (config) => [
|
|
597
|
+
...BaseFormConfig(),
|
|
598
|
+
...config,
|
|
599
|
+
{
|
|
600
|
+
type: "tab",
|
|
601
|
+
items: [
|
|
602
|
+
{
|
|
603
|
+
title: "数据定义",
|
|
604
|
+
items: [
|
|
605
|
+
{
|
|
606
|
+
name: "fields",
|
|
607
|
+
type: "data-source-fields",
|
|
608
|
+
defaultValue: () => []
|
|
599
609
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
610
|
+
]
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
title: "方法定义",
|
|
614
|
+
items: [
|
|
615
|
+
{
|
|
616
|
+
name: "methods",
|
|
617
|
+
type: "data-source-methods",
|
|
618
|
+
defaultValue: () => []
|
|
603
619
|
}
|
|
604
|
-
|
|
605
|
-
destroyMoveable();
|
|
606
|
-
}
|
|
620
|
+
]
|
|
607
621
|
},
|
|
608
622
|
{
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
},
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
}, [
|
|
653
|
-
renderSlot(_ctx.$slots, "title", {}, () => [
|
|
654
|
-
createElementVNode("span", null, toDisplayString(_ctx.title), 1)
|
|
655
|
-
]),
|
|
656
|
-
createElementVNode("div", null, [
|
|
657
|
-
createVNode(unref(TMagicButton), {
|
|
658
|
-
link: "",
|
|
659
|
-
size: "small",
|
|
660
|
-
onClick: closeHandler
|
|
661
|
-
}, {
|
|
662
|
-
default: withCtx(() => [
|
|
663
|
-
createVNode(_sfc_main$U, { icon: unref(Close) }, null, 8, ["icon"])
|
|
664
|
-
]),
|
|
665
|
-
_: 1
|
|
666
|
-
})
|
|
667
|
-
])
|
|
668
|
-
], 512),
|
|
669
|
-
createElementVNode("div", {
|
|
670
|
-
class: "m-editor-float-box-body",
|
|
671
|
-
style: normalizeStyle({ height: `${bodyHeight.value}px` })
|
|
672
|
-
}, [
|
|
673
|
-
renderSlot(_ctx.$slots, "body")
|
|
674
|
-
], 4)
|
|
675
|
-
], 36)
|
|
676
|
-
])) : createCommentVNode("", true);
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
const useEditorContentHeight = () => {
|
|
682
|
-
const services = inject("services");
|
|
683
|
-
const frameworkHeight = computed(() => services?.uiService.get("frameworkRect").height || 0);
|
|
684
|
-
const navMenuHeight = computed(() => services?.uiService.get("navMenuRect").height || 0);
|
|
685
|
-
const editorContentHeight = computed(() => frameworkHeight.value - navMenuHeight.value);
|
|
686
|
-
const height = ref(0);
|
|
687
|
-
watchEffect(() => {
|
|
688
|
-
if (height.value > 0 && height.value === editorContentHeight.value)
|
|
689
|
-
return;
|
|
690
|
-
height.value = editorContentHeight.value;
|
|
691
|
-
});
|
|
692
|
-
return {
|
|
693
|
-
height
|
|
694
|
-
};
|
|
695
|
-
};
|
|
696
|
-
|
|
697
|
-
const useNextFloatBoxPosition = (uiService, parent) => {
|
|
698
|
-
const boxPosition = ref({
|
|
699
|
-
left: 0,
|
|
700
|
-
top: 0
|
|
701
|
-
});
|
|
702
|
-
const calcBoxPosition = () => {
|
|
703
|
-
const columnWidth = uiService?.get("columnWidth");
|
|
704
|
-
const navMenuRect = uiService?.get("navMenuRect");
|
|
705
|
-
let left = columnWidth?.left ?? 0;
|
|
706
|
-
if (parent?.value) {
|
|
707
|
-
const rect = parent?.value?.getBoundingClientRect();
|
|
708
|
-
left = (rect?.left ?? 0) + (rect?.width ?? 0);
|
|
709
|
-
}
|
|
710
|
-
boxPosition.value = {
|
|
711
|
-
left,
|
|
712
|
-
top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
|
|
713
|
-
};
|
|
714
|
-
};
|
|
715
|
-
return {
|
|
716
|
-
boxPosition,
|
|
717
|
-
calcBoxPosition
|
|
718
|
-
};
|
|
719
|
-
};
|
|
720
|
-
|
|
721
|
-
const useWindowRect = () => {
|
|
722
|
-
const rect = reactive({ width: globalThis.innerWidth, height: globalThis.innerHeight });
|
|
723
|
-
const windowResizeHandler = () => {
|
|
724
|
-
rect.width = globalThis.innerWidth;
|
|
725
|
-
rect.height = globalThis.innerHeight;
|
|
726
|
-
};
|
|
727
|
-
globalThis.addEventListener("resize", windowResizeHandler);
|
|
728
|
-
onBeforeUnmount(() => {
|
|
729
|
-
globalThis.removeEventListener("resize", windowResizeHandler);
|
|
730
|
-
});
|
|
731
|
-
return {
|
|
732
|
-
rect
|
|
733
|
-
};
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
const _hoisted_1$r = { style: { "display": "flex", "margin-bottom": "10px" } };
|
|
737
|
-
const _hoisted_2$k = { style: { "flex": "1" } };
|
|
738
|
-
const _hoisted_3$8 = { style: { "flex": "1" } };
|
|
739
|
-
const _hoisted_4$7 = { class: "dialog-footer" };
|
|
740
|
-
const _sfc_main$O = /* @__PURE__ */ defineComponent({
|
|
741
|
-
...{
|
|
742
|
-
name: "MEditorCodeBlockEditor"
|
|
743
|
-
},
|
|
744
|
-
__name: "CodeBlockEditor",
|
|
745
|
-
props: /* @__PURE__ */ mergeModels({
|
|
746
|
-
content: {},
|
|
747
|
-
disabled: { type: Boolean },
|
|
748
|
-
isDataSource: { type: Boolean },
|
|
749
|
-
dataSourceType: {}
|
|
750
|
-
}, {
|
|
751
|
-
"width": { default: 670 },
|
|
752
|
-
"widthModifiers": {},
|
|
753
|
-
"visible": { type: Boolean, ...{ default: false } },
|
|
754
|
-
"visibleModifiers": {}
|
|
755
|
-
}),
|
|
756
|
-
emits: /* @__PURE__ */ mergeModels(["submit"], ["update:width", "update:visible"]),
|
|
757
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
758
|
-
const width = useModel(__props, "width");
|
|
759
|
-
const boxVisible = useModel(__props, "visible");
|
|
760
|
-
const props = __props;
|
|
761
|
-
const emit = __emit;
|
|
762
|
-
const services = inject("services");
|
|
763
|
-
const { height: codeBlockEditorHeight } = useEditorContentHeight();
|
|
764
|
-
const difVisible = ref(false);
|
|
765
|
-
const { rect: windowRect } = useWindowRect();
|
|
766
|
-
const magicVsEditor = ref();
|
|
767
|
-
const diffChange = () => {
|
|
768
|
-
if (!magicVsEditor.value || !formBox.value?.form) {
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
formBox.value.form.values.content = magicVsEditor.value.getEditorValue();
|
|
772
|
-
difVisible.value = false;
|
|
773
|
-
};
|
|
774
|
-
const defaultParamColConfig = {
|
|
775
|
-
type: "row",
|
|
776
|
-
label: "参数类型",
|
|
777
|
-
items: [
|
|
778
|
-
{
|
|
779
|
-
text: "参数类型",
|
|
780
|
-
labelWidth: "70px",
|
|
781
|
-
type: "select",
|
|
782
|
-
name: "type",
|
|
783
|
-
options: [
|
|
784
|
-
{
|
|
785
|
-
text: "数字",
|
|
786
|
-
label: "数字",
|
|
787
|
-
value: "number"
|
|
788
|
-
},
|
|
789
|
-
{
|
|
790
|
-
text: "字符串",
|
|
791
|
-
label: "字符串",
|
|
792
|
-
value: "text"
|
|
793
|
-
},
|
|
794
|
-
{
|
|
795
|
-
text: "组件",
|
|
796
|
-
label: "组件",
|
|
797
|
-
value: "ui-select"
|
|
798
|
-
}
|
|
799
|
-
]
|
|
800
|
-
}
|
|
801
|
-
]
|
|
802
|
-
};
|
|
803
|
-
const functionConfig = computed(() => [
|
|
804
|
-
{
|
|
805
|
-
text: "名称",
|
|
806
|
-
name: "name",
|
|
807
|
-
rules: [{ required: true, message: "请输入名称", trigger: "blur" }]
|
|
808
|
-
},
|
|
809
|
-
{
|
|
810
|
-
text: "描述",
|
|
811
|
-
name: "desc"
|
|
812
|
-
},
|
|
813
|
-
{
|
|
814
|
-
text: "执行时机",
|
|
815
|
-
name: "timing",
|
|
816
|
-
type: "select",
|
|
817
|
-
options: () => {
|
|
818
|
-
const options = [
|
|
819
|
-
{ text: "初始化前", value: "beforeInit" },
|
|
820
|
-
{ text: "初始化后", value: "afterInit" }
|
|
821
|
-
];
|
|
822
|
-
if (props.dataSourceType !== "base") {
|
|
823
|
-
options.push({ text: "请求前", value: "beforeRequest" });
|
|
824
|
-
options.push({ text: "请求后", value: "afterRequest" });
|
|
825
|
-
}
|
|
826
|
-
return options;
|
|
827
|
-
},
|
|
828
|
-
display: () => props.isDataSource
|
|
829
|
-
},
|
|
830
|
-
{
|
|
831
|
-
type: "table",
|
|
832
|
-
border: true,
|
|
833
|
-
text: "参数",
|
|
834
|
-
enableFullscreen: false,
|
|
835
|
-
enableToggleMode: false,
|
|
836
|
-
name: "params",
|
|
837
|
-
dropSort: false,
|
|
838
|
-
items: [
|
|
839
|
-
{
|
|
840
|
-
type: "text",
|
|
841
|
-
label: "参数名",
|
|
842
|
-
name: "name"
|
|
843
|
-
},
|
|
844
|
-
{
|
|
845
|
-
type: "text",
|
|
846
|
-
label: "描述",
|
|
847
|
-
name: "extra"
|
|
848
|
-
},
|
|
849
|
-
services?.codeBlockService.getParamsColConfig() || defaultParamColConfig
|
|
850
|
-
]
|
|
851
|
-
},
|
|
852
|
-
{
|
|
853
|
-
name: "content",
|
|
854
|
-
type: "vs-code",
|
|
855
|
-
options: inject("codeOptions", {}),
|
|
856
|
-
height: "500px",
|
|
857
|
-
onChange: (formState, code) => {
|
|
858
|
-
try {
|
|
859
|
-
getConfig("parseDSL")(code);
|
|
860
|
-
return code;
|
|
861
|
-
} catch (error) {
|
|
862
|
-
tMagicMessage.error(error.message);
|
|
863
|
-
throw error;
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
]);
|
|
868
|
-
const submitForm = (values) => {
|
|
869
|
-
changedValue.value = void 0;
|
|
870
|
-
emit("submit", values);
|
|
871
|
-
};
|
|
872
|
-
const errorHandler = (error) => {
|
|
873
|
-
tMagicMessage.error(error.message);
|
|
874
|
-
};
|
|
875
|
-
const formBox = ref();
|
|
876
|
-
const changedValue = ref();
|
|
877
|
-
const changeHandler = (values) => {
|
|
878
|
-
changedValue.value = values;
|
|
879
|
-
};
|
|
880
|
-
const beforeClose = (done) => {
|
|
881
|
-
if (!changedValue.value) {
|
|
882
|
-
done();
|
|
883
|
-
return;
|
|
884
|
-
}
|
|
885
|
-
tMagicMessageBox.confirm("当前代码块已修改,是否保存?", "提示", {
|
|
886
|
-
confirmButtonText: "保存并关闭",
|
|
887
|
-
cancelButtonText: "不保存并关闭",
|
|
888
|
-
type: "warning",
|
|
889
|
-
distinguishCancelAndClose: true
|
|
890
|
-
}).then(() => {
|
|
891
|
-
changedValue.value && submitForm(changedValue.value);
|
|
892
|
-
done();
|
|
893
|
-
}).catch((action) => {
|
|
894
|
-
done(action === "cancel");
|
|
895
|
-
});
|
|
896
|
-
};
|
|
897
|
-
const closedHandler = () => {
|
|
898
|
-
changedValue.value = void 0;
|
|
899
|
-
};
|
|
900
|
-
const parentFloating = inject("parentFloating", ref(null));
|
|
901
|
-
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
902
|
-
__expose({
|
|
903
|
-
async show() {
|
|
904
|
-
calcBoxPosition();
|
|
905
|
-
boxVisible.value = true;
|
|
906
|
-
},
|
|
907
|
-
async hide() {
|
|
908
|
-
boxVisible.value = false;
|
|
909
|
-
}
|
|
910
|
-
});
|
|
911
|
-
return (_ctx, _cache) => {
|
|
912
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
913
|
-
createVNode(_sfc_main$P, {
|
|
914
|
-
visible: boxVisible.value,
|
|
915
|
-
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => boxVisible.value = $event),
|
|
916
|
-
width: width.value,
|
|
917
|
-
"onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
|
|
918
|
-
height: unref(codeBlockEditorHeight),
|
|
919
|
-
"onUpdate:height": _cache[3] || (_cache[3] = ($event) => isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
|
|
920
|
-
title: _ctx.content.name ? `${_ctx.disabled ? "查看" : "编辑"}${_ctx.content.name}` : "新增代码",
|
|
921
|
-
position: unref(boxPosition),
|
|
922
|
-
"before-close": beforeClose
|
|
923
|
-
}, {
|
|
924
|
-
body: withCtx(() => [
|
|
925
|
-
createVNode(unref(MFormBox), {
|
|
926
|
-
class: "m-editor-code-block-editor",
|
|
927
|
-
ref_key: "formBox",
|
|
928
|
-
ref: formBox,
|
|
929
|
-
"label-width": "80px",
|
|
930
|
-
"close-on-press-escape": false,
|
|
931
|
-
title: _ctx.content.name,
|
|
932
|
-
config: functionConfig.value,
|
|
933
|
-
values: _ctx.content,
|
|
934
|
-
disabled: _ctx.disabled,
|
|
935
|
-
style: { "height": "100%" },
|
|
936
|
-
onChange: changeHandler,
|
|
937
|
-
onSubmit: submitForm,
|
|
938
|
-
onError: errorHandler,
|
|
939
|
-
onClosed: closedHandler
|
|
940
|
-
}, {
|
|
941
|
-
left: withCtx(() => [
|
|
942
|
-
!_ctx.disabled ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
943
|
-
key: 0,
|
|
944
|
-
type: "primary",
|
|
945
|
-
link: "",
|
|
946
|
-
onClick: _cache[0] || (_cache[0] = ($event) => difVisible.value = true)
|
|
947
|
-
}, {
|
|
948
|
-
default: withCtx(() => [
|
|
949
|
-
createTextVNode("查看修改")
|
|
950
|
-
]),
|
|
951
|
-
_: 1
|
|
952
|
-
})) : createCommentVNode("", true)
|
|
953
|
-
]),
|
|
954
|
-
_: 1
|
|
955
|
-
}, 8, ["title", "config", "values", "disabled"])
|
|
956
|
-
]),
|
|
957
|
-
_: 1
|
|
958
|
-
}, 8, ["visible", "width", "height", "title", "position"]),
|
|
959
|
-
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
960
|
-
createVNode(unref(TMagicDialog), {
|
|
961
|
-
title: "查看修改",
|
|
962
|
-
modelValue: difVisible.value,
|
|
963
|
-
"onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
|
|
964
|
-
fullscreen: ""
|
|
965
|
-
}, {
|
|
966
|
-
footer: withCtx(() => [
|
|
967
|
-
createElementVNode("span", _hoisted_4$7, [
|
|
968
|
-
createVNode(unref(TMagicButton), {
|
|
969
|
-
size: "small",
|
|
970
|
-
onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
|
|
971
|
-
}, {
|
|
972
|
-
default: withCtx(() => [
|
|
973
|
-
createTextVNode("取消")
|
|
974
|
-
]),
|
|
975
|
-
_: 1
|
|
976
|
-
}),
|
|
977
|
-
createVNode(unref(TMagicButton), {
|
|
978
|
-
size: "small",
|
|
979
|
-
type: "primary",
|
|
980
|
-
onClick: diffChange
|
|
981
|
-
}, {
|
|
982
|
-
default: withCtx(() => [
|
|
983
|
-
createTextVNode("确定")
|
|
984
|
-
]),
|
|
985
|
-
_: 1
|
|
986
|
-
})
|
|
987
|
-
])
|
|
988
|
-
]),
|
|
989
|
-
default: withCtx(() => [
|
|
990
|
-
createElementVNode("div", _hoisted_1$r, [
|
|
991
|
-
createElementVNode("div", _hoisted_2$k, [
|
|
992
|
-
createVNode(unref(TMagicTag), {
|
|
993
|
-
size: "small",
|
|
994
|
-
type: "info"
|
|
995
|
-
}, {
|
|
996
|
-
default: withCtx(() => [
|
|
997
|
-
createTextVNode("修改前")
|
|
998
|
-
]),
|
|
999
|
-
_: 1
|
|
1000
|
-
})
|
|
1001
|
-
]),
|
|
1002
|
-
createElementVNode("div", _hoisted_3$8, [
|
|
1003
|
-
createVNode(unref(TMagicTag), {
|
|
1004
|
-
size: "small",
|
|
1005
|
-
type: "success"
|
|
1006
|
-
}, {
|
|
1007
|
-
default: withCtx(() => [
|
|
1008
|
-
createTextVNode("修改后")
|
|
1009
|
-
]),
|
|
1010
|
-
_: 1
|
|
1011
|
-
})
|
|
1012
|
-
])
|
|
1013
|
-
]),
|
|
1014
|
-
difVisible.value ? (openBlock(), createBlock(_sfc_main$T, {
|
|
1015
|
-
key: 0,
|
|
1016
|
-
ref_key: "magicVsEditor",
|
|
1017
|
-
ref: magicVsEditor,
|
|
1018
|
-
type: "diff",
|
|
1019
|
-
language: "json",
|
|
1020
|
-
initValues: _ctx.content.content,
|
|
1021
|
-
modifiedValues: formBox.value?.form?.values.content,
|
|
1022
|
-
style: normalizeStyle(`height: ${unref(windowRect).height - 150}px`)
|
|
1023
|
-
}, null, 8, ["initValues", "modifiedValues", "style"])) : createCommentVNode("", true)
|
|
1024
|
-
]),
|
|
1025
|
-
_: 1
|
|
1026
|
-
}, 8, ["modelValue"])
|
|
1027
|
-
]))
|
|
1028
|
-
], 64);
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
});
|
|
1032
|
-
|
|
1033
|
-
function BaseFormConfig() {
|
|
1034
|
-
return [
|
|
1035
|
-
{
|
|
1036
|
-
name: "id",
|
|
1037
|
-
type: "hidden"
|
|
1038
|
-
},
|
|
1039
|
-
{
|
|
1040
|
-
name: "type",
|
|
1041
|
-
text: "类型",
|
|
1042
|
-
type: "hidden",
|
|
1043
|
-
defaultValue: "base"
|
|
1044
|
-
},
|
|
1045
|
-
{
|
|
1046
|
-
name: "title",
|
|
1047
|
-
text: "名称",
|
|
1048
|
-
rules: [
|
|
1049
|
-
{
|
|
1050
|
-
required: true,
|
|
1051
|
-
message: "请输入名称"
|
|
1052
|
-
}
|
|
1053
|
-
]
|
|
1054
|
-
},
|
|
1055
|
-
{
|
|
1056
|
-
name: "description",
|
|
1057
|
-
text: "描述"
|
|
1058
|
-
}
|
|
1059
|
-
];
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
const HttpFormConfig = [
|
|
1063
|
-
{
|
|
1064
|
-
name: "autoFetch",
|
|
1065
|
-
text: "自动请求",
|
|
1066
|
-
type: "switch",
|
|
1067
|
-
defaultValue: true
|
|
1068
|
-
},
|
|
1069
|
-
{
|
|
1070
|
-
name: "responseOptions",
|
|
1071
|
-
items: [
|
|
1072
|
-
{
|
|
1073
|
-
name: "dataPath",
|
|
1074
|
-
text: "数据路径"
|
|
1075
|
-
}
|
|
1076
|
-
]
|
|
1077
|
-
},
|
|
1078
|
-
{
|
|
1079
|
-
type: "fieldset",
|
|
1080
|
-
name: "options",
|
|
1081
|
-
legend: "HTTP 配置",
|
|
1082
|
-
items: [
|
|
1083
|
-
{
|
|
1084
|
-
name: "url",
|
|
1085
|
-
text: "URL"
|
|
1086
|
-
},
|
|
1087
|
-
{
|
|
1088
|
-
name: "method",
|
|
1089
|
-
text: "Method",
|
|
1090
|
-
type: "select",
|
|
1091
|
-
options: [
|
|
1092
|
-
{ text: "GET", value: "GET" },
|
|
1093
|
-
{ text: "POST", value: "POST" },
|
|
1094
|
-
{ text: "PUT", value: "PUT" },
|
|
1095
|
-
{ text: "DELETE", value: "DELETE" }
|
|
1096
|
-
]
|
|
1097
|
-
},
|
|
1098
|
-
{
|
|
1099
|
-
name: "params",
|
|
1100
|
-
type: "key-value",
|
|
1101
|
-
defaultValue: {},
|
|
1102
|
-
text: "参数"
|
|
1103
|
-
},
|
|
1104
|
-
{
|
|
1105
|
-
name: "data",
|
|
1106
|
-
type: "key-value",
|
|
1107
|
-
defaultValue: {},
|
|
1108
|
-
advanced: true,
|
|
1109
|
-
text: "请求体"
|
|
1110
|
-
},
|
|
1111
|
-
{
|
|
1112
|
-
name: "headers",
|
|
1113
|
-
type: "key-value",
|
|
1114
|
-
defaultValue: {},
|
|
1115
|
-
text: "请求头"
|
|
1116
|
-
}
|
|
1117
|
-
]
|
|
1118
|
-
}
|
|
1119
|
-
];
|
|
1120
|
-
|
|
1121
|
-
const fillConfig$1 = (config) => [
|
|
1122
|
-
...BaseFormConfig(),
|
|
1123
|
-
...config,
|
|
1124
|
-
{
|
|
1125
|
-
type: "tab",
|
|
1126
|
-
items: [
|
|
1127
|
-
{
|
|
1128
|
-
title: "数据定义",
|
|
1129
|
-
items: [
|
|
1130
|
-
{
|
|
1131
|
-
name: "fields",
|
|
1132
|
-
type: "data-source-fields",
|
|
1133
|
-
defaultValue: () => []
|
|
1134
|
-
}
|
|
1135
|
-
]
|
|
1136
|
-
},
|
|
1137
|
-
{
|
|
1138
|
-
title: "方法定义",
|
|
1139
|
-
items: [
|
|
1140
|
-
{
|
|
1141
|
-
name: "methods",
|
|
1142
|
-
type: "data-source-methods",
|
|
1143
|
-
defaultValue: () => []
|
|
1144
|
-
}
|
|
1145
|
-
]
|
|
1146
|
-
},
|
|
1147
|
-
{
|
|
1148
|
-
title: "事件配置",
|
|
1149
|
-
display: false,
|
|
1150
|
-
items: [
|
|
1151
|
-
{
|
|
1152
|
-
name: "events",
|
|
1153
|
-
src: "datasource",
|
|
1154
|
-
type: "event-select"
|
|
1155
|
-
}
|
|
1156
|
-
]
|
|
1157
|
-
},
|
|
1158
|
-
{
|
|
1159
|
-
title: "mock数据",
|
|
1160
|
-
items: [
|
|
1161
|
-
{
|
|
1162
|
-
name: "mocks",
|
|
1163
|
-
type: "data-source-mocks",
|
|
1164
|
-
defaultValue: () => []
|
|
1165
|
-
}
|
|
1166
|
-
]
|
|
1167
|
-
},
|
|
1168
|
-
{
|
|
1169
|
-
title: "请求参数裁剪",
|
|
1170
|
-
display: (formState, { model }) => model.type === "http",
|
|
1171
|
-
items: [
|
|
1172
|
-
{
|
|
1173
|
-
name: "beforeRequest",
|
|
1174
|
-
type: "vs-code",
|
|
1175
|
-
parse: true,
|
|
1176
|
-
height: "600px"
|
|
1177
|
-
}
|
|
1178
|
-
]
|
|
1179
|
-
},
|
|
1180
|
-
{
|
|
1181
|
-
title: "响应数据裁剪",
|
|
1182
|
-
display: (formState, { model }) => model.type === "http",
|
|
1183
|
-
items: [
|
|
1184
|
-
{
|
|
1185
|
-
name: "afterResponse",
|
|
1186
|
-
type: "vs-code",
|
|
1187
|
-
parse: true,
|
|
1188
|
-
height: "600px"
|
|
1189
|
-
}
|
|
1190
|
-
]
|
|
623
|
+
title: "事件配置",
|
|
624
|
+
display: false,
|
|
625
|
+
items: [
|
|
626
|
+
{
|
|
627
|
+
name: "events",
|
|
628
|
+
src: "datasource",
|
|
629
|
+
type: "event-select"
|
|
630
|
+
}
|
|
631
|
+
]
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
title: "mock数据",
|
|
635
|
+
items: [
|
|
636
|
+
{
|
|
637
|
+
name: "mocks",
|
|
638
|
+
type: "data-source-mocks",
|
|
639
|
+
defaultValue: () => []
|
|
640
|
+
}
|
|
641
|
+
]
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
title: "请求参数裁剪",
|
|
645
|
+
display: (formState, { model }) => model.type === "http",
|
|
646
|
+
items: [
|
|
647
|
+
{
|
|
648
|
+
name: "beforeRequest",
|
|
649
|
+
type: "vs-code",
|
|
650
|
+
parse: true,
|
|
651
|
+
height: "600px"
|
|
652
|
+
}
|
|
653
|
+
]
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
title: "响应数据裁剪",
|
|
657
|
+
display: (formState, { model }) => model.type === "http",
|
|
658
|
+
items: [
|
|
659
|
+
{
|
|
660
|
+
name: "afterResponse",
|
|
661
|
+
type: "vs-code",
|
|
662
|
+
parse: true,
|
|
663
|
+
height: "600px"
|
|
664
|
+
}
|
|
665
|
+
]
|
|
1191
666
|
}
|
|
1192
667
|
]
|
|
1193
668
|
}
|
|
@@ -2052,6 +1527,13 @@ var ColumnLayout = /* @__PURE__ */ ((ColumnLayout2) => {
|
|
|
2052
1527
|
ColumnLayout2["RIGHT"] = "right";
|
|
2053
1528
|
return ColumnLayout2;
|
|
2054
1529
|
})(ColumnLayout || {});
|
|
1530
|
+
var SideItemKey = /* @__PURE__ */ ((SideItemKey2) => {
|
|
1531
|
+
SideItemKey2["COMPONENT_LIST"] = "component-list";
|
|
1532
|
+
SideItemKey2["LAYER"] = "layer";
|
|
1533
|
+
SideItemKey2["CODE_BLOCK"] = "code-block";
|
|
1534
|
+
SideItemKey2["DATA_SOURCE"] = "data-source";
|
|
1535
|
+
return SideItemKey2;
|
|
1536
|
+
})(SideItemKey || {});
|
|
2055
1537
|
var LayerOffset = /* @__PURE__ */ ((LayerOffset2) => {
|
|
2056
1538
|
LayerOffset2["TOP"] = "top";
|
|
2057
1539
|
LayerOffset2["BOTTOM"] = "bottom";
|
|
@@ -3703,7 +3185,7 @@ const getDefaultConfig = async (addNode, parentNode) => {
|
|
|
3703
3185
|
return newNode;
|
|
3704
3186
|
};
|
|
3705
3187
|
|
|
3706
|
-
const _sfc_main$
|
|
3188
|
+
const _sfc_main$P = /* @__PURE__ */ defineComponent({
|
|
3707
3189
|
...{
|
|
3708
3190
|
name: "MEditorCodeParams"
|
|
3709
3191
|
},
|
|
@@ -3753,68 +3235,9 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
3753
3235
|
}
|
|
3754
3236
|
});
|
|
3755
3237
|
|
|
3756
|
-
const
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
const codeBlockEditor = ref();
|
|
3760
|
-
const createCodeBlock = async () => {
|
|
3761
|
-
if (!codeBlockService) {
|
|
3762
|
-
tMagicMessage.error("新增代码块失败");
|
|
3763
|
-
return;
|
|
3764
|
-
}
|
|
3765
|
-
codeConfig.value = {
|
|
3766
|
-
name: "",
|
|
3767
|
-
content: `({app, params}) => {
|
|
3768
|
-
// place your code here
|
|
3769
|
-
}`,
|
|
3770
|
-
params: []
|
|
3771
|
-
};
|
|
3772
|
-
codeId.value = await codeBlockService.getUniqueId();
|
|
3773
|
-
await nextTick();
|
|
3774
|
-
codeBlockEditor.value?.show();
|
|
3775
|
-
};
|
|
3776
|
-
const editCode = async (id) => {
|
|
3777
|
-
const codeBlock = await codeBlockService?.getCodeContentById(id);
|
|
3778
|
-
if (!codeBlock) {
|
|
3779
|
-
tMagicMessage.error("获取代码块内容失败");
|
|
3780
|
-
return;
|
|
3781
|
-
}
|
|
3782
|
-
let codeContent = codeBlock.content;
|
|
3783
|
-
if (typeof codeContent !== "string") {
|
|
3784
|
-
codeContent = codeContent.toString();
|
|
3785
|
-
}
|
|
3786
|
-
codeConfig.value = {
|
|
3787
|
-
...cloneDeep(codeBlock),
|
|
3788
|
-
content: codeContent
|
|
3789
|
-
};
|
|
3790
|
-
codeId.value = id;
|
|
3791
|
-
await nextTick();
|
|
3792
|
-
codeBlockEditor.value?.show();
|
|
3793
|
-
};
|
|
3794
|
-
const deleteCode = async (key) => {
|
|
3795
|
-
codeBlockService?.deleteCodeDslByIds([key]);
|
|
3796
|
-
};
|
|
3797
|
-
const submitCodeBlockHandler = async (values) => {
|
|
3798
|
-
if (!codeId.value)
|
|
3799
|
-
return;
|
|
3800
|
-
await codeBlockService?.setCodeDslById(codeId.value, values);
|
|
3801
|
-
tMagicMessage.success("代码块保存成功");
|
|
3802
|
-
codeBlockEditor.value?.hide();
|
|
3803
|
-
};
|
|
3804
|
-
return {
|
|
3805
|
-
codeId,
|
|
3806
|
-
codeConfig,
|
|
3807
|
-
codeBlockEditor,
|
|
3808
|
-
createCodeBlock,
|
|
3809
|
-
editCode,
|
|
3810
|
-
deleteCode,
|
|
3811
|
-
submitCodeBlockHandler
|
|
3812
|
-
};
|
|
3813
|
-
};
|
|
3814
|
-
|
|
3815
|
-
const _hoisted_1$q = { class: "m-fields-code-select-col" };
|
|
3816
|
-
const _hoisted_2$j = { class: "code-select-container" };
|
|
3817
|
-
const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
3238
|
+
const _hoisted_1$s = { class: "m-fields-code-select-col" };
|
|
3239
|
+
const _hoisted_2$k = { class: "code-select-container" };
|
|
3240
|
+
const _sfc_main$O = /* @__PURE__ */ defineComponent({
|
|
3818
3241
|
...{
|
|
3819
3242
|
name: "MFieldsCodeSelectCol"
|
|
3820
3243
|
},
|
|
@@ -3834,9 +3257,13 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
3834
3257
|
setup(__props, { emit: __emit }) {
|
|
3835
3258
|
const mForm = inject("mForm");
|
|
3836
3259
|
const services = inject("services");
|
|
3260
|
+
const eventBus = inject("eventBus");
|
|
3837
3261
|
const emit = __emit;
|
|
3838
|
-
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
3839
3262
|
const props = __props;
|
|
3263
|
+
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
3264
|
+
const hasCodeBlockSidePanel = computed(
|
|
3265
|
+
() => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.CODE_BLOCK)
|
|
3266
|
+
);
|
|
3840
3267
|
const getParamItemsConfig = (codeId) => {
|
|
3841
3268
|
if (!codeDsl.value || !codeId)
|
|
3842
3269
|
return [];
|
|
@@ -3887,46 +3314,278 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
3887
3314
|
props.model.params = value.params;
|
|
3888
3315
|
emit("change", props.model);
|
|
3889
3316
|
};
|
|
3890
|
-
const
|
|
3317
|
+
const editCode = (id) => {
|
|
3318
|
+
eventBus?.emit("edit-code", id);
|
|
3319
|
+
};
|
|
3891
3320
|
return (_ctx, _cache) => {
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
createVNode(_component_m_form_container, {
|
|
3321
|
+
return openBlock(), createElementBlock("div", _hoisted_1$s, [
|
|
3322
|
+
createElementVNode("div", _hoisted_2$k, [
|
|
3323
|
+
createVNode(unref(MContainer), {
|
|
3896
3324
|
class: "select",
|
|
3897
3325
|
config: selectConfig,
|
|
3898
3326
|
model: _ctx.model,
|
|
3899
3327
|
size: _ctx.size,
|
|
3900
3328
|
onChange: onParamsChangeHandler
|
|
3901
3329
|
}, null, 8, ["model", "size"]),
|
|
3902
|
-
_ctx.model[_ctx.name] ? (openBlock(), createBlock(
|
|
3330
|
+
_ctx.model[_ctx.name] && hasCodeBlockSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
3903
3331
|
key: 0,
|
|
3904
|
-
class: "
|
|
3905
|
-
|
|
3906
|
-
onClick: _cache[0] || (_cache[0] = ($event) =>
|
|
3907
|
-
},
|
|
3332
|
+
class: "m-fields-select-action-button",
|
|
3333
|
+
size: _ctx.size,
|
|
3334
|
+
onClick: _cache[0] || (_cache[0] = ($event) => editCode(_ctx.model[_ctx.name]))
|
|
3335
|
+
}, {
|
|
3336
|
+
default: withCtx(() => [
|
|
3337
|
+
createVNode(_sfc_main$U, {
|
|
3338
|
+
icon: !notEditable.value ? unref(Edit) : unref(View)
|
|
3339
|
+
}, null, 8, ["icon"])
|
|
3340
|
+
]),
|
|
3341
|
+
_: 1
|
|
3342
|
+
}, 8, ["size"])) : createCommentVNode("", true)
|
|
3908
3343
|
]),
|
|
3909
|
-
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$
|
|
3344
|
+
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$P, {
|
|
3910
3345
|
name: "params",
|
|
3911
3346
|
key: _ctx.model[_ctx.name],
|
|
3912
3347
|
model: _ctx.model,
|
|
3913
3348
|
size: _ctx.size,
|
|
3914
3349
|
"params-config": paramsConfig.value,
|
|
3915
3350
|
onChange: onParamsChangeHandler
|
|
3916
|
-
}, null, 8, ["model", "size", "params-config"])) : createCommentVNode("", true)
|
|
3917
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
|
|
3918
|
-
key: 1,
|
|
3919
|
-
ref_key: "codeBlockEditor",
|
|
3920
|
-
ref: codeBlockEditor,
|
|
3921
|
-
disabled: notEditable.value,
|
|
3922
|
-
content: unref(codeConfig),
|
|
3923
|
-
onSubmit: unref(submitCodeBlockHandler)
|
|
3924
|
-
}, null, 8, ["disabled", "content", "onSubmit"])) : createCommentVNode("", true)
|
|
3351
|
+
}, null, 8, ["model", "size", "params-config"])) : createCommentVNode("", true)
|
|
3925
3352
|
]);
|
|
3926
3353
|
};
|
|
3927
3354
|
}
|
|
3928
3355
|
});
|
|
3929
3356
|
|
|
3357
|
+
const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
3358
|
+
__name: "FloatingBox",
|
|
3359
|
+
props: /* @__PURE__ */ mergeModels({
|
|
3360
|
+
position: { default: () => ({ left: 0, top: 0 }) },
|
|
3361
|
+
title: { default: "" },
|
|
3362
|
+
beforeClose: {}
|
|
3363
|
+
}, {
|
|
3364
|
+
"width": { default: 0 },
|
|
3365
|
+
"widthModifiers": {},
|
|
3366
|
+
"height": { default: 0 },
|
|
3367
|
+
"heightModifiers": {},
|
|
3368
|
+
"visible": { type: Boolean, ...{ default: false } },
|
|
3369
|
+
"visibleModifiers": {}
|
|
3370
|
+
}),
|
|
3371
|
+
emits: ["update:width", "update:height", "update:visible"],
|
|
3372
|
+
setup(__props, { expose: __expose }) {
|
|
3373
|
+
const width = useModel(__props, "width");
|
|
3374
|
+
const height = useModel(__props, "height");
|
|
3375
|
+
const visible = useModel(__props, "visible");
|
|
3376
|
+
const props = __props;
|
|
3377
|
+
const target = ref();
|
|
3378
|
+
const titleEl = ref();
|
|
3379
|
+
const zIndex = useZIndex();
|
|
3380
|
+
const curZIndex = ref(0);
|
|
3381
|
+
const titleHeight = ref(0);
|
|
3382
|
+
const bodyHeight = computed(() => {
|
|
3383
|
+
if (height.value) {
|
|
3384
|
+
return height.value - titleHeight.value;
|
|
3385
|
+
}
|
|
3386
|
+
if (target.value) {
|
|
3387
|
+
return target.value.clientHeight - titleHeight.value;
|
|
3388
|
+
}
|
|
3389
|
+
return "auto";
|
|
3390
|
+
});
|
|
3391
|
+
const services = inject("services");
|
|
3392
|
+
const frameworkWidth = computed(() => services?.uiService.get("frameworkRect").width || 0);
|
|
3393
|
+
const style = computed(() => {
|
|
3394
|
+
let { left } = props.position;
|
|
3395
|
+
if (width.value) {
|
|
3396
|
+
left = left + width.value > frameworkWidth.value ? frameworkWidth.value - width.value : left;
|
|
3397
|
+
}
|
|
3398
|
+
return {
|
|
3399
|
+
left: `${left}px`,
|
|
3400
|
+
top: `${props.position.top}px`,
|
|
3401
|
+
width: width.value ? `${width.value}px` : "auto",
|
|
3402
|
+
height: height.value ? `${height.value}px` : "auto"
|
|
3403
|
+
};
|
|
3404
|
+
});
|
|
3405
|
+
let moveable = null;
|
|
3406
|
+
const initMoveable = () => {
|
|
3407
|
+
moveable = new VanillaMoveable(globalThis.document.body, {
|
|
3408
|
+
className: "m-editor-floating-box-moveable",
|
|
3409
|
+
target: target.value,
|
|
3410
|
+
draggable: true,
|
|
3411
|
+
resizable: true,
|
|
3412
|
+
edge: true,
|
|
3413
|
+
keepRatio: false,
|
|
3414
|
+
origin: false,
|
|
3415
|
+
snappable: true,
|
|
3416
|
+
dragTarget: titleEl.value,
|
|
3417
|
+
dragTargetSelf: false,
|
|
3418
|
+
linePadding: 10,
|
|
3419
|
+
controlPadding: 10,
|
|
3420
|
+
bounds: { left: 0, top: 0, right: 0, bottom: 0, position: "css" }
|
|
3421
|
+
});
|
|
3422
|
+
moveable.on("drag", (e) => {
|
|
3423
|
+
e.target.style.transform = e.transform;
|
|
3424
|
+
});
|
|
3425
|
+
moveable.on("resize", (e) => {
|
|
3426
|
+
width.value = e.width;
|
|
3427
|
+
height.value = e.height;
|
|
3428
|
+
e.target.style.width = `${e.width}px`;
|
|
3429
|
+
e.target.style.height = `${e.height}px`;
|
|
3430
|
+
e.target.style.transform = e.drag.transform;
|
|
3431
|
+
});
|
|
3432
|
+
};
|
|
3433
|
+
const destroyMoveable = () => {
|
|
3434
|
+
moveable?.destroy();
|
|
3435
|
+
moveable = null;
|
|
3436
|
+
};
|
|
3437
|
+
watch(
|
|
3438
|
+
visible,
|
|
3439
|
+
async (visible2) => {
|
|
3440
|
+
if (visible2) {
|
|
3441
|
+
await nextTick();
|
|
3442
|
+
curZIndex.value = zIndex.nextZIndex();
|
|
3443
|
+
const targetRect = target.value?.getBoundingClientRect();
|
|
3444
|
+
if (targetRect) {
|
|
3445
|
+
width.value = targetRect.width;
|
|
3446
|
+
height.value = targetRect.height;
|
|
3447
|
+
initMoveable();
|
|
3448
|
+
}
|
|
3449
|
+
if (titleEl.value) {
|
|
3450
|
+
const titleRect = titleEl.value.getBoundingClientRect();
|
|
3451
|
+
titleHeight.value = titleRect.height;
|
|
3452
|
+
}
|
|
3453
|
+
} else {
|
|
3454
|
+
destroyMoveable();
|
|
3455
|
+
}
|
|
3456
|
+
},
|
|
3457
|
+
{
|
|
3458
|
+
immediate: true
|
|
3459
|
+
}
|
|
3460
|
+
);
|
|
3461
|
+
onBeforeUnmount(() => {
|
|
3462
|
+
destroyMoveable();
|
|
3463
|
+
});
|
|
3464
|
+
const hide = (cancel) => {
|
|
3465
|
+
if (cancel !== false) {
|
|
3466
|
+
visible.value = false;
|
|
3467
|
+
}
|
|
3468
|
+
};
|
|
3469
|
+
const closeHandler = () => {
|
|
3470
|
+
if (typeof props.beforeClose === "function") {
|
|
3471
|
+
props.beforeClose(hide);
|
|
3472
|
+
} else {
|
|
3473
|
+
hide();
|
|
3474
|
+
}
|
|
3475
|
+
};
|
|
3476
|
+
const nextZIndex = () => {
|
|
3477
|
+
curZIndex.value = zIndex.nextZIndex();
|
|
3478
|
+
};
|
|
3479
|
+
provide("parentFloating", target);
|
|
3480
|
+
__expose({
|
|
3481
|
+
bodyHeight,
|
|
3482
|
+
target,
|
|
3483
|
+
titleEl
|
|
3484
|
+
});
|
|
3485
|
+
return (_ctx, _cache) => {
|
|
3486
|
+
return visible.value ? (openBlock(), createBlock(Teleport, {
|
|
3487
|
+
key: 0,
|
|
3488
|
+
to: "body"
|
|
3489
|
+
}, [
|
|
3490
|
+
createElementVNode("div", {
|
|
3491
|
+
ref_key: "target",
|
|
3492
|
+
ref: target,
|
|
3493
|
+
class: "m-editor-float-box",
|
|
3494
|
+
style: normalizeStyle({ ...style.value, zIndex: curZIndex.value }),
|
|
3495
|
+
onMousedown: nextZIndex
|
|
3496
|
+
}, [
|
|
3497
|
+
createElementVNode("div", {
|
|
3498
|
+
ref_key: "titleEl",
|
|
3499
|
+
ref: titleEl,
|
|
3500
|
+
class: "m-editor-float-box-title"
|
|
3501
|
+
}, [
|
|
3502
|
+
renderSlot(_ctx.$slots, "title", {}, () => [
|
|
3503
|
+
createElementVNode("span", null, toDisplayString(_ctx.title), 1)
|
|
3504
|
+
]),
|
|
3505
|
+
createElementVNode("div", null, [
|
|
3506
|
+
createVNode(unref(TMagicButton), {
|
|
3507
|
+
link: "",
|
|
3508
|
+
size: "small",
|
|
3509
|
+
onClick: closeHandler
|
|
3510
|
+
}, {
|
|
3511
|
+
default: withCtx(() => [
|
|
3512
|
+
createVNode(_sfc_main$U, { icon: unref(Close) }, null, 8, ["icon"])
|
|
3513
|
+
]),
|
|
3514
|
+
_: 1
|
|
3515
|
+
})
|
|
3516
|
+
])
|
|
3517
|
+
], 512),
|
|
3518
|
+
createElementVNode("div", {
|
|
3519
|
+
class: "m-editor-float-box-body",
|
|
3520
|
+
style: normalizeStyle({ height: `${bodyHeight.value}px` })
|
|
3521
|
+
}, [
|
|
3522
|
+
renderSlot(_ctx.$slots, "body")
|
|
3523
|
+
], 4)
|
|
3524
|
+
], 36)
|
|
3525
|
+
])) : createCommentVNode("", true);
|
|
3526
|
+
};
|
|
3527
|
+
}
|
|
3528
|
+
});
|
|
3529
|
+
|
|
3530
|
+
const useCodeBlockEdit = (codeBlockService) => {
|
|
3531
|
+
const codeConfig = ref();
|
|
3532
|
+
const codeId = ref();
|
|
3533
|
+
const codeBlockEditor = ref();
|
|
3534
|
+
const createCodeBlock = async () => {
|
|
3535
|
+
if (!codeBlockService) {
|
|
3536
|
+
tMagicMessage.error("新增代码块失败");
|
|
3537
|
+
return;
|
|
3538
|
+
}
|
|
3539
|
+
codeConfig.value = {
|
|
3540
|
+
name: "",
|
|
3541
|
+
content: `({app, params}) => {
|
|
3542
|
+
// place your code here
|
|
3543
|
+
}`,
|
|
3544
|
+
params: []
|
|
3545
|
+
};
|
|
3546
|
+
codeId.value = await codeBlockService.getUniqueId();
|
|
3547
|
+
await nextTick();
|
|
3548
|
+
codeBlockEditor.value?.show();
|
|
3549
|
+
};
|
|
3550
|
+
const editCode = async (id) => {
|
|
3551
|
+
const codeBlock = await codeBlockService?.getCodeContentById(id);
|
|
3552
|
+
if (!codeBlock) {
|
|
3553
|
+
tMagicMessage.error("获取代码块内容失败");
|
|
3554
|
+
return;
|
|
3555
|
+
}
|
|
3556
|
+
let codeContent = codeBlock.content;
|
|
3557
|
+
if (typeof codeContent !== "string") {
|
|
3558
|
+
codeContent = codeContent.toString();
|
|
3559
|
+
}
|
|
3560
|
+
codeConfig.value = {
|
|
3561
|
+
...cloneDeep(codeBlock),
|
|
3562
|
+
content: codeContent
|
|
3563
|
+
};
|
|
3564
|
+
codeId.value = id;
|
|
3565
|
+
await nextTick();
|
|
3566
|
+
codeBlockEditor.value?.show();
|
|
3567
|
+
};
|
|
3568
|
+
const deleteCode = async (key) => {
|
|
3569
|
+
codeBlockService?.deleteCodeDslByIds([key]);
|
|
3570
|
+
};
|
|
3571
|
+
const submitCodeBlockHandler = async (values) => {
|
|
3572
|
+
if (!codeId.value)
|
|
3573
|
+
return;
|
|
3574
|
+
await codeBlockService?.setCodeDslById(codeId.value, values);
|
|
3575
|
+
tMagicMessage.success("代码块保存成功");
|
|
3576
|
+
codeBlockEditor.value?.hide();
|
|
3577
|
+
};
|
|
3578
|
+
return {
|
|
3579
|
+
codeId,
|
|
3580
|
+
codeConfig,
|
|
3581
|
+
codeBlockEditor,
|
|
3582
|
+
createCodeBlock,
|
|
3583
|
+
editCode,
|
|
3584
|
+
deleteCode,
|
|
3585
|
+
submitCodeBlockHandler
|
|
3586
|
+
};
|
|
3587
|
+
};
|
|
3588
|
+
|
|
3930
3589
|
const useDataSourceMethod = () => {
|
|
3931
3590
|
const codeConfig = ref();
|
|
3932
3591
|
const codeBlockEditor = ref();
|
|
@@ -4021,6 +3680,7 @@ const state = reactive({
|
|
|
4021
3680
|
propsPanelSize: "small",
|
|
4022
3681
|
showAddPageButton: true,
|
|
4023
3682
|
hideSlideBar: false,
|
|
3683
|
+
sideBarItems: [],
|
|
4024
3684
|
navMenuRect: {
|
|
4025
3685
|
left: 0,
|
|
4026
3686
|
top: 0,
|
|
@@ -4264,9 +3924,70 @@ const useFloatBox = (slideKeys) => {
|
|
|
4264
3924
|
};
|
|
4265
3925
|
};
|
|
4266
3926
|
|
|
4267
|
-
const
|
|
4268
|
-
const
|
|
4269
|
-
const
|
|
3927
|
+
const useWindowRect = () => {
|
|
3928
|
+
const rect = reactive({ width: globalThis.innerWidth, height: globalThis.innerHeight });
|
|
3929
|
+
const windowResizeHandler = () => {
|
|
3930
|
+
rect.width = globalThis.innerWidth;
|
|
3931
|
+
rect.height = globalThis.innerHeight;
|
|
3932
|
+
};
|
|
3933
|
+
globalThis.addEventListener("resize", windowResizeHandler);
|
|
3934
|
+
onBeforeUnmount(() => {
|
|
3935
|
+
globalThis.removeEventListener("resize", windowResizeHandler);
|
|
3936
|
+
});
|
|
3937
|
+
return {
|
|
3938
|
+
rect
|
|
3939
|
+
};
|
|
3940
|
+
};
|
|
3941
|
+
|
|
3942
|
+
const useEditorContentHeight = () => {
|
|
3943
|
+
const services = inject("services");
|
|
3944
|
+
const frameworkHeight = computed(() => services?.uiService.get("frameworkRect").height || 0);
|
|
3945
|
+
const navMenuHeight = computed(() => services?.uiService.get("navMenuRect").height || 0);
|
|
3946
|
+
const editorContentHeight = computed(() => frameworkHeight.value - navMenuHeight.value);
|
|
3947
|
+
const height = ref(0);
|
|
3948
|
+
watch(
|
|
3949
|
+
editorContentHeight,
|
|
3950
|
+
() => {
|
|
3951
|
+
if (height.value > 0 && height.value === editorContentHeight.value)
|
|
3952
|
+
return;
|
|
3953
|
+
height.value = editorContentHeight.value;
|
|
3954
|
+
},
|
|
3955
|
+
{
|
|
3956
|
+
immediate: true
|
|
3957
|
+
}
|
|
3958
|
+
);
|
|
3959
|
+
return {
|
|
3960
|
+
height
|
|
3961
|
+
};
|
|
3962
|
+
};
|
|
3963
|
+
|
|
3964
|
+
const useNextFloatBoxPosition = (uiService, parent) => {
|
|
3965
|
+
const boxPosition = ref({
|
|
3966
|
+
left: 0,
|
|
3967
|
+
top: 0
|
|
3968
|
+
});
|
|
3969
|
+
const calcBoxPosition = () => {
|
|
3970
|
+
const columnWidth = uiService?.get("columnWidth");
|
|
3971
|
+
const navMenuRect = uiService?.get("navMenuRect");
|
|
3972
|
+
let left = columnWidth?.left ?? 0;
|
|
3973
|
+
if (parent?.value) {
|
|
3974
|
+
const rect = parent?.value?.getBoundingClientRect();
|
|
3975
|
+
left = (rect?.left ?? 0) + (rect?.width ?? 0);
|
|
3976
|
+
}
|
|
3977
|
+
boxPosition.value = {
|
|
3978
|
+
left,
|
|
3979
|
+
top: (navMenuRect?.top ?? 0) + (navMenuRect?.height ?? 0)
|
|
3980
|
+
};
|
|
3981
|
+
};
|
|
3982
|
+
return {
|
|
3983
|
+
boxPosition,
|
|
3984
|
+
calcBoxPosition
|
|
3985
|
+
};
|
|
3986
|
+
};
|
|
3987
|
+
|
|
3988
|
+
const _hoisted_1$r = { class: "m-editor-data-source-fields" };
|
|
3989
|
+
const _hoisted_2$j = { class: "m-editor-data-source-fields-footer" };
|
|
3990
|
+
const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
4270
3991
|
...{
|
|
4271
3992
|
name: "MFieldsDataSourceFields"
|
|
4272
3993
|
},
|
|
@@ -4521,12 +4242,12 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4521
4242
|
const parentFloating = inject("parentFloating", ref(null));
|
|
4522
4243
|
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
4523
4244
|
return (_ctx, _cache) => {
|
|
4524
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
4245
|
+
return openBlock(), createElementBlock("div", _hoisted_1$r, [
|
|
4525
4246
|
createVNode(unref(MagicTable), {
|
|
4526
4247
|
data: _ctx.model[_ctx.name],
|
|
4527
4248
|
columns: fieldColumns
|
|
4528
4249
|
}, null, 8, ["data"]),
|
|
4529
|
-
createElementVNode("div", _hoisted_2$
|
|
4250
|
+
createElementVNode("div", _hoisted_2$j, [
|
|
4530
4251
|
createVNode(unref(TMagicButton), {
|
|
4531
4252
|
size: "small",
|
|
4532
4253
|
disabled: _ctx.disabled,
|
|
@@ -4551,7 +4272,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4551
4272
|
_: 1
|
|
4552
4273
|
}, 8, ["disabled"])
|
|
4553
4274
|
]),
|
|
4554
|
-
createVNode(_sfc_main$
|
|
4275
|
+
createVNode(_sfc_main$N, {
|
|
4555
4276
|
visible: addDialogVisible.value,
|
|
4556
4277
|
"onUpdate:visible": _cache[2] || (_cache[2] = ($event) => addDialogVisible.value = $event),
|
|
4557
4278
|
width: width.value,
|
|
@@ -4574,7 +4295,7 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4574
4295
|
]),
|
|
4575
4296
|
_: 1
|
|
4576
4297
|
}, 8, ["visible", "width", "height", "title", "position"]),
|
|
4577
|
-
createVNode(_sfc_main$
|
|
4298
|
+
createVNode(_sfc_main$N, {
|
|
4578
4299
|
visible: addFromJsonDialogVisible.value,
|
|
4579
4300
|
"onUpdate:visible": _cache[5] || (_cache[5] = ($event) => addFromJsonDialogVisible.value = $event),
|
|
4580
4301
|
width: width.value,
|
|
@@ -4599,115 +4320,8 @@ const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
|
4599
4320
|
}
|
|
4600
4321
|
});
|
|
4601
4322
|
|
|
4602
|
-
const
|
|
4603
|
-
|
|
4604
|
-
const editDialog = ref();
|
|
4605
|
-
const dataSourceValues = ref({});
|
|
4606
|
-
const editable = computed(() => dataSourceService?.get("editable") ?? true);
|
|
4607
|
-
const editHandler = (id) => {
|
|
4608
|
-
if (!editDialog.value)
|
|
4609
|
-
return;
|
|
4610
|
-
dataSourceValues.value = {
|
|
4611
|
-
...dataSourceService?.getDataSourceById(id)
|
|
4612
|
-
};
|
|
4613
|
-
dialogTitle.value = `编辑${dataSourceValues.value.title || ""}`;
|
|
4614
|
-
editDialog.value.show();
|
|
4615
|
-
};
|
|
4616
|
-
const submitDataSourceHandler = (value) => {
|
|
4617
|
-
if (value.id) {
|
|
4618
|
-
dataSourceService?.update(value);
|
|
4619
|
-
} else {
|
|
4620
|
-
dataSourceService?.add(value);
|
|
4621
|
-
}
|
|
4622
|
-
editDialog.value?.hide();
|
|
4623
|
-
};
|
|
4624
|
-
return {
|
|
4625
|
-
dialogTitle,
|
|
4626
|
-
editDialog,
|
|
4627
|
-
dataSourceValues,
|
|
4628
|
-
editable,
|
|
4629
|
-
editHandler,
|
|
4630
|
-
submitDataSourceHandler
|
|
4631
|
-
};
|
|
4632
|
-
};
|
|
4633
|
-
|
|
4634
|
-
const _sfc_main$K = /* @__PURE__ */ defineComponent({
|
|
4635
|
-
...{
|
|
4636
|
-
name: "MEditorDataSourceConfigPanel"
|
|
4637
|
-
},
|
|
4638
|
-
__name: "DataSourceConfigPanel",
|
|
4639
|
-
props: /* @__PURE__ */ mergeModels({
|
|
4640
|
-
title: {},
|
|
4641
|
-
values: {},
|
|
4642
|
-
disabled: { type: Boolean }
|
|
4643
|
-
}, {
|
|
4644
|
-
"visible": { type: Boolean, ...{ default: false } },
|
|
4645
|
-
"visibleModifiers": {},
|
|
4646
|
-
"width": { default: 670 },
|
|
4647
|
-
"widthModifiers": {}
|
|
4648
|
-
}),
|
|
4649
|
-
emits: /* @__PURE__ */ mergeModels(["submit"], ["update:visible", "update:width"]),
|
|
4650
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4651
|
-
const props = __props;
|
|
4652
|
-
const boxVisible = useModel(__props, "visible");
|
|
4653
|
-
const width = useModel(__props, "width");
|
|
4654
|
-
const emit = __emit;
|
|
4655
|
-
const services = inject("services");
|
|
4656
|
-
const initValues = ref({});
|
|
4657
|
-
const dataSourceConfig = ref([]);
|
|
4658
|
-
const { height: editorHeight } = useEditorContentHeight();
|
|
4659
|
-
const parentFloating = inject("parentFloating", ref(null));
|
|
4660
|
-
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
4661
|
-
watchEffect(() => {
|
|
4662
|
-
initValues.value = props.values;
|
|
4663
|
-
dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
|
|
4664
|
-
});
|
|
4665
|
-
const submitHandler = (values) => {
|
|
4666
|
-
emit("submit", values);
|
|
4667
|
-
};
|
|
4668
|
-
const errorHandler = (error) => {
|
|
4669
|
-
tMagicMessage.error(error.message);
|
|
4670
|
-
};
|
|
4671
|
-
__expose({
|
|
4672
|
-
show() {
|
|
4673
|
-
calcBoxPosition();
|
|
4674
|
-
boxVisible.value = true;
|
|
4675
|
-
},
|
|
4676
|
-
hide() {
|
|
4677
|
-
boxVisible.value = false;
|
|
4678
|
-
}
|
|
4679
|
-
});
|
|
4680
|
-
return (_ctx, _cache) => {
|
|
4681
|
-
return openBlock(), createBlock(_sfc_main$P, {
|
|
4682
|
-
visible: boxVisible.value,
|
|
4683
|
-
"onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
|
|
4684
|
-
width: width.value,
|
|
4685
|
-
"onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
|
|
4686
|
-
height: unref(editorHeight),
|
|
4687
|
-
"onUpdate:height": _cache[2] || (_cache[2] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
|
|
4688
|
-
title: _ctx.title,
|
|
4689
|
-
position: unref(boxPosition)
|
|
4690
|
-
}, {
|
|
4691
|
-
body: withCtx(() => [
|
|
4692
|
-
createVNode(unref(MFormBox), {
|
|
4693
|
-
"label-width": "80px",
|
|
4694
|
-
title: _ctx.title,
|
|
4695
|
-
config: dataSourceConfig.value,
|
|
4696
|
-
values: initValues.value,
|
|
4697
|
-
disabled: _ctx.disabled,
|
|
4698
|
-
style: { "height": "100%" },
|
|
4699
|
-
onSubmit: submitHandler,
|
|
4700
|
-
onError: errorHandler
|
|
4701
|
-
}, null, 8, ["title", "config", "values", "disabled"])
|
|
4702
|
-
]),
|
|
4703
|
-
_: 1
|
|
4704
|
-
}, 8, ["visible", "width", "height", "title", "position"]);
|
|
4705
|
-
};
|
|
4706
|
-
}
|
|
4707
|
-
});
|
|
4708
|
-
|
|
4709
|
-
const _hoisted_1$o = { style: { "width": "100%", "display": "flex", "align-items": "center" } };
|
|
4710
|
-
const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
4323
|
+
const _hoisted_1$q = { class: "m-fields-data-source-field-select" };
|
|
4324
|
+
const _sfc_main$L = /* @__PURE__ */ defineComponent({
|
|
4711
4325
|
...{
|
|
4712
4326
|
name: "MFieldsDataSourceFieldSelect"
|
|
4713
4327
|
},
|
|
@@ -4726,8 +4340,13 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
4726
4340
|
emits: ["change"],
|
|
4727
4341
|
setup(__props, { emit: __emit }) {
|
|
4728
4342
|
const services = inject("services");
|
|
4343
|
+
const eventBus = inject("eventBus");
|
|
4729
4344
|
const emit = __emit;
|
|
4730
4345
|
const props = __props;
|
|
4346
|
+
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
4347
|
+
const hasDataSourceSidePanel = computed(
|
|
4348
|
+
() => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
|
|
4349
|
+
);
|
|
4731
4350
|
const selectedDataSourceId = computed(() => {
|
|
4732
4351
|
const value = props.model[props.name];
|
|
4733
4352
|
if (!Array.isArray(value) || !value.length) {
|
|
@@ -4780,12 +4399,19 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
4780
4399
|
};
|
|
4781
4400
|
});
|
|
4782
4401
|
const showDataSourceFieldSelect = ref(false);
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4402
|
+
watch(
|
|
4403
|
+
() => props.model[props.name],
|
|
4404
|
+
(value) => {
|
|
4405
|
+
if (Array.isArray(value) && typeof value[0] === "string" && value[0].startsWith(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX)) {
|
|
4406
|
+
showDataSourceFieldSelect.value = true;
|
|
4407
|
+
} else {
|
|
4408
|
+
showDataSourceFieldSelect.value = false;
|
|
4409
|
+
}
|
|
4410
|
+
},
|
|
4411
|
+
{
|
|
4412
|
+
immediate: true
|
|
4787
4413
|
}
|
|
4788
|
-
|
|
4414
|
+
);
|
|
4789
4415
|
const mForm = inject("mForm");
|
|
4790
4416
|
const type = computed(() => {
|
|
4791
4417
|
let type2 = props.config.fieldConfig?.type;
|
|
@@ -4812,11 +4438,11 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
4812
4438
|
const onChangeHandler = (value) => {
|
|
4813
4439
|
emit("change", value);
|
|
4814
4440
|
};
|
|
4815
|
-
const
|
|
4816
|
-
|
|
4817
|
-
|
|
4441
|
+
const editHandler = (id) => {
|
|
4442
|
+
eventBus?.emit("edit-data-source", id);
|
|
4443
|
+
};
|
|
4818
4444
|
return (_ctx, _cache) => {
|
|
4819
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
4445
|
+
return openBlock(), createElementBlock("div", _hoisted_1$q, [
|
|
4820
4446
|
(openBlock(), createBlock(resolveDynamicComponent(tagName.value), {
|
|
4821
4447
|
style: { "width": "100%" },
|
|
4822
4448
|
config: showDataSourceFieldSelect.value || !_ctx.config.fieldConfig ? cascaderConfig.value : _ctx.config.fieldConfig,
|
|
@@ -4830,22 +4456,22 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
4830
4456
|
prop: `${_ctx.prop}${_ctx.prop ? "." : ""}${_ctx.name}`,
|
|
4831
4457
|
onChange: onChangeHandler
|
|
4832
4458
|
}, null, 40, ["config", "model", "name", "disabled", "size", "last-values", "init-values", "values", "prop"])),
|
|
4833
|
-
(showDataSourceFieldSelect.value || !_ctx.config.fieldConfig) && selectedDataSourceId.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
4459
|
+
(showDataSourceFieldSelect.value || !_ctx.config.fieldConfig) && selectedDataSourceId.value && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
4834
4460
|
key: 0,
|
|
4835
|
-
|
|
4836
|
-
link: "",
|
|
4461
|
+
class: "m-fields-select-action-button",
|
|
4837
4462
|
size: _ctx.size,
|
|
4838
|
-
onClick: _cache[0] || (_cache[0] = ($event) =>
|
|
4463
|
+
onClick: _cache[0] || (_cache[0] = ($event) => editHandler(selectedDataSourceId.value))
|
|
4839
4464
|
}, {
|
|
4840
4465
|
default: withCtx(() => [
|
|
4841
|
-
createVNode(_sfc_main$U, {
|
|
4466
|
+
createVNode(_sfc_main$U, {
|
|
4467
|
+
icon: !notEditable.value ? unref(Edit) : unref(View)
|
|
4468
|
+
}, null, 8, ["icon"])
|
|
4842
4469
|
]),
|
|
4843
4470
|
_: 1
|
|
4844
4471
|
}, 8, ["size"])) : createCommentVNode("", true),
|
|
4845
4472
|
_ctx.config.fieldConfig ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
4846
4473
|
key: 1,
|
|
4847
4474
|
style: { "margin-left": "5px" },
|
|
4848
|
-
link: "",
|
|
4849
4475
|
type: showDataSourceFieldSelect.value ? "primary" : "default",
|
|
4850
4476
|
size: _ctx.size,
|
|
4851
4477
|
onClick: _cache[1] || (_cache[1] = ($event) => showDataSourceFieldSelect.value = !showDataSourceFieldSelect.value)
|
|
@@ -4854,24 +4480,16 @@ const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
|
4854
4480
|
createVNode(_sfc_main$U, { icon: unref(Coin) }, null, 8, ["icon"])
|
|
4855
4481
|
]),
|
|
4856
4482
|
_: 1
|
|
4857
|
-
}, 8, ["type", "size"])) : createCommentVNode("", true)
|
|
4858
|
-
createVNode(_sfc_main$K, {
|
|
4859
|
-
ref_key: "editDialog",
|
|
4860
|
-
ref: editDialog,
|
|
4861
|
-
disabled: !unref(editable),
|
|
4862
|
-
values: unref(dataSourceValues),
|
|
4863
|
-
title: unref(dialogTitle),
|
|
4864
|
-
onSubmit: unref(submitDataSourceHandler)
|
|
4865
|
-
}, null, 8, ["disabled", "values", "title", "onSubmit"])
|
|
4483
|
+
}, 8, ["type", "size"])) : createCommentVNode("", true)
|
|
4866
4484
|
]);
|
|
4867
4485
|
};
|
|
4868
4486
|
}
|
|
4869
4487
|
});
|
|
4870
4488
|
|
|
4871
|
-
const _hoisted_1$
|
|
4872
|
-
const _hoisted_2$
|
|
4873
|
-
const _hoisted_3$
|
|
4874
|
-
const _sfc_main$
|
|
4489
|
+
const _hoisted_1$p = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
|
|
4490
|
+
const _hoisted_2$i = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
|
|
4491
|
+
const _hoisted_3$8 = { class: "el-input__inner t-input__inner" };
|
|
4492
|
+
const _sfc_main$K = /* @__PURE__ */ defineComponent({
|
|
4875
4493
|
...{
|
|
4876
4494
|
name: "MFieldsDataSourceInput"
|
|
4877
4495
|
},
|
|
@@ -4978,138 +4596,435 @@ const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
|
4978
4596
|
}
|
|
4979
4597
|
}
|
|
4980
4598
|
}
|
|
4981
|
-
if (curCharIsDot(dotIndex)) {
|
|
4982
|
-
result = fields || [];
|
|
4983
|
-
} else if (dotIndex > -1) {
|
|
4984
|
-
const queryName = queryString.substring(dotIndex + 1).toLowerCase();
|
|
4985
|
-
result = fields.filter(
|
|
4986
|
-
(field) => field.name?.toLowerCase().includes(queryName) || field.title?.toLowerCase().includes(queryName)
|
|
4987
|
-
) || [];
|
|
4988
|
-
}
|
|
4989
|
-
cb(
|
|
4990
|
-
result.map((field) => ({
|
|
4991
|
-
value: field.name,
|
|
4992
|
-
text: field.title,
|
|
4993
|
-
type: "field"
|
|
4994
|
-
}))
|
|
4995
|
-
);
|
|
4599
|
+
if (curCharIsDot(dotIndex)) {
|
|
4600
|
+
result = fields || [];
|
|
4601
|
+
} else if (dotIndex > -1) {
|
|
4602
|
+
const queryName = queryString.substring(dotIndex + 1).toLowerCase();
|
|
4603
|
+
result = fields.filter(
|
|
4604
|
+
(field) => field.name?.toLowerCase().includes(queryName) || field.title?.toLowerCase().includes(queryName)
|
|
4605
|
+
) || [];
|
|
4606
|
+
}
|
|
4607
|
+
cb(
|
|
4608
|
+
result.map((field) => ({
|
|
4609
|
+
value: field.name,
|
|
4610
|
+
text: field.title,
|
|
4611
|
+
type: "field"
|
|
4612
|
+
}))
|
|
4613
|
+
);
|
|
4614
|
+
};
|
|
4615
|
+
const querySearch = (queryString, cb) => {
|
|
4616
|
+
inputText = queryString;
|
|
4617
|
+
const selectionStart = getSelectionStart();
|
|
4618
|
+
const curQueryString = queryString.substring(0, selectionStart);
|
|
4619
|
+
const fieldKeyStringLastIndex = curQueryString.lastIndexOf(".");
|
|
4620
|
+
const dsKeyStringLastIndex = curQueryString.lastIndexOf("${") + 1;
|
|
4621
|
+
const isFieldTip = fieldKeyStringLastIndex > dsKeyStringLastIndex;
|
|
4622
|
+
if (isFieldTip) {
|
|
4623
|
+
fieldQuerySearch(curQueryString, dsKeyStringLastIndex, fieldKeyStringLastIndex, cb);
|
|
4624
|
+
} else {
|
|
4625
|
+
dsQuerySearch(curQueryString, dsKeyStringLastIndex, cb);
|
|
4626
|
+
}
|
|
4627
|
+
};
|
|
4628
|
+
const selectHandler = async ({ value, type }) => {
|
|
4629
|
+
const isDataSource = type === "dataSource";
|
|
4630
|
+
const selectionStart = input.value?.selectionStart || 0;
|
|
4631
|
+
let startText = inputText.substring(0, selectionStart);
|
|
4632
|
+
const dotIndex = startText.lastIndexOf(".");
|
|
4633
|
+
const leftCurlyBracketIndex = startText.lastIndexOf("${") + 1;
|
|
4634
|
+
const endText = inputText.substring(selectionStart);
|
|
4635
|
+
let suggestText = value;
|
|
4636
|
+
if (isDataSource) {
|
|
4637
|
+
if (!curCharIsLeftCurlyBracket(leftCurlyBracketIndex)) {
|
|
4638
|
+
startText = startText.substring(0, leftCurlyBracketIndex + 1);
|
|
4639
|
+
}
|
|
4640
|
+
if (!isRightCurlyBracket(selectionStart + 1)) {
|
|
4641
|
+
suggestText = `${suggestText}}`;
|
|
4642
|
+
}
|
|
4643
|
+
} else if (!curCharIsDot(dotIndex)) {
|
|
4644
|
+
startText = startText.substring(0, dotIndex + 1);
|
|
4645
|
+
}
|
|
4646
|
+
state.value = `${startText}${suggestText}${endText}`;
|
|
4647
|
+
await nextTick();
|
|
4648
|
+
let newSelectionStart = 0;
|
|
4649
|
+
if (isDataSource) {
|
|
4650
|
+
newSelectionStart = leftCurlyBracketIndex + suggestText.length;
|
|
4651
|
+
} else {
|
|
4652
|
+
newSelectionStart = dotIndex + suggestText.length + 1;
|
|
4653
|
+
}
|
|
4654
|
+
input.value?.setSelectionRange(newSelectionStart, newSelectionStart);
|
|
4655
|
+
changeHandler(state.value);
|
|
4656
|
+
};
|
|
4657
|
+
return (_ctx, _cache) => {
|
|
4658
|
+
return _ctx.disabled || isFocused.value ? (openBlock(), createBlock(resolveDynamicComponent(unref(getConfig$1)("components")?.autocomplete.component || "el-autocomplete"), mergeProps(
|
|
4659
|
+
{
|
|
4660
|
+
key: 0,
|
|
4661
|
+
class: "tmagic-design-auto-complete",
|
|
4662
|
+
ref_key: "autocomplete",
|
|
4663
|
+
ref: autocomplete,
|
|
4664
|
+
modelValue: state.value,
|
|
4665
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => state.value = $event)
|
|
4666
|
+
},
|
|
4667
|
+
unref(getConfig$1)("components")?.autocomplete.props({
|
|
4668
|
+
disabled: _ctx.disabled,
|
|
4669
|
+
size: _ctx.size,
|
|
4670
|
+
fetchSuggestions: querySearch,
|
|
4671
|
+
triggerOnFocus: false,
|
|
4672
|
+
clearable: true
|
|
4673
|
+
}) || {},
|
|
4674
|
+
{
|
|
4675
|
+
style: { "width": "100%" },
|
|
4676
|
+
onBlur: blurHandler,
|
|
4677
|
+
onInput: inputHandler,
|
|
4678
|
+
onSelect: selectHandler
|
|
4679
|
+
}
|
|
4680
|
+
), {
|
|
4681
|
+
suffix: withCtx(() => [
|
|
4682
|
+
createVNode(_sfc_main$U, { icon: unref(Coin) }, null, 8, ["icon"])
|
|
4683
|
+
]),
|
|
4684
|
+
default: withCtx(({ item }) => [
|
|
4685
|
+
createElementVNode("div", _hoisted_1$p, [
|
|
4686
|
+
createElementVNode("div", null, toDisplayString(item.text), 1),
|
|
4687
|
+
createElementVNode("span", _hoisted_2$i, toDisplayString(item.value), 1)
|
|
4688
|
+
])
|
|
4689
|
+
]),
|
|
4690
|
+
_: 1
|
|
4691
|
+
}, 16, ["modelValue"])) : (openBlock(), createElementBlock("div", {
|
|
4692
|
+
key: 1,
|
|
4693
|
+
class: normalizeClass(`tmagic-data-source-input-text el-input t-input t-size-${_ctx.size?.[0]} el-input--${_ctx.size}`),
|
|
4694
|
+
onMouseup: mouseupHandler
|
|
4695
|
+
}, [
|
|
4696
|
+
createElementVNode("div", {
|
|
4697
|
+
class: normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
|
|
4698
|
+
}, [
|
|
4699
|
+
createElementVNode("div", _hoisted_3$8, [
|
|
4700
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(displayState.value, (item, index) => {
|
|
4701
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
4702
|
+
item.type === "text" ? (openBlock(), createElementBlock("span", {
|
|
4703
|
+
key: index,
|
|
4704
|
+
style: { "margin-right": "2px" }
|
|
4705
|
+
}, toDisplayString(item.value), 1)) : createCommentVNode("", true),
|
|
4706
|
+
item.type === "var" ? (openBlock(), createBlock(unref(TMagicTag), {
|
|
4707
|
+
key: index,
|
|
4708
|
+
size: _ctx.size
|
|
4709
|
+
}, {
|
|
4710
|
+
default: withCtx(() => [
|
|
4711
|
+
createTextVNode(toDisplayString(item.value), 1)
|
|
4712
|
+
]),
|
|
4713
|
+
_: 2
|
|
4714
|
+
}, 1032, ["size"])) : createCommentVNode("", true)
|
|
4715
|
+
], 64);
|
|
4716
|
+
}), 256)),
|
|
4717
|
+
createVNode(_sfc_main$U, {
|
|
4718
|
+
class: "tmagic-data-source-input-icon",
|
|
4719
|
+
icon: unref(Coin)
|
|
4720
|
+
}, null, 8, ["icon"])
|
|
4721
|
+
])
|
|
4722
|
+
], 2)
|
|
4723
|
+
], 34));
|
|
4724
|
+
};
|
|
4725
|
+
}
|
|
4726
|
+
});
|
|
4727
|
+
|
|
4728
|
+
const _hoisted_1$o = { style: { "display": "flex", "margin-bottom": "10px" } };
|
|
4729
|
+
const _hoisted_2$h = { style: { "flex": "1" } };
|
|
4730
|
+
const _hoisted_3$7 = { style: { "flex": "1" } };
|
|
4731
|
+
const _hoisted_4$7 = { class: "dialog-footer" };
|
|
4732
|
+
const _sfc_main$J = /* @__PURE__ */ defineComponent({
|
|
4733
|
+
...{
|
|
4734
|
+
name: "MEditorCodeBlockEditor"
|
|
4735
|
+
},
|
|
4736
|
+
__name: "CodeBlockEditor",
|
|
4737
|
+
props: /* @__PURE__ */ mergeModels({
|
|
4738
|
+
content: {},
|
|
4739
|
+
disabled: { type: Boolean },
|
|
4740
|
+
isDataSource: { type: Boolean },
|
|
4741
|
+
dataSourceType: {}
|
|
4742
|
+
}, {
|
|
4743
|
+
"width": { default: 670 },
|
|
4744
|
+
"widthModifiers": {},
|
|
4745
|
+
"visible": { type: Boolean, ...{ default: false } },
|
|
4746
|
+
"visibleModifiers": {}
|
|
4747
|
+
}),
|
|
4748
|
+
emits: /* @__PURE__ */ mergeModels(["submit"], ["update:width", "update:visible"]),
|
|
4749
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4750
|
+
const width = useModel(__props, "width");
|
|
4751
|
+
const boxVisible = useModel(__props, "visible");
|
|
4752
|
+
const props = __props;
|
|
4753
|
+
const emit = __emit;
|
|
4754
|
+
const services = inject("services");
|
|
4755
|
+
const { height: codeBlockEditorHeight } = useEditorContentHeight();
|
|
4756
|
+
const difVisible = ref(false);
|
|
4757
|
+
const { rect: windowRect } = useWindowRect();
|
|
4758
|
+
const magicVsEditor = ref();
|
|
4759
|
+
const diffChange = () => {
|
|
4760
|
+
if (!magicVsEditor.value || !formBox.value?.form) {
|
|
4761
|
+
return;
|
|
4762
|
+
}
|
|
4763
|
+
formBox.value.form.values.content = magicVsEditor.value.getEditorValue();
|
|
4764
|
+
difVisible.value = false;
|
|
4765
|
+
};
|
|
4766
|
+
const defaultParamColConfig = {
|
|
4767
|
+
type: "row",
|
|
4768
|
+
label: "参数类型",
|
|
4769
|
+
items: [
|
|
4770
|
+
{
|
|
4771
|
+
text: "参数类型",
|
|
4772
|
+
labelWidth: "70px",
|
|
4773
|
+
type: "select",
|
|
4774
|
+
name: "type",
|
|
4775
|
+
options: [
|
|
4776
|
+
{
|
|
4777
|
+
text: "数字",
|
|
4778
|
+
label: "数字",
|
|
4779
|
+
value: "number"
|
|
4780
|
+
},
|
|
4781
|
+
{
|
|
4782
|
+
text: "字符串",
|
|
4783
|
+
label: "字符串",
|
|
4784
|
+
value: "text"
|
|
4785
|
+
},
|
|
4786
|
+
{
|
|
4787
|
+
text: "组件",
|
|
4788
|
+
label: "组件",
|
|
4789
|
+
value: "ui-select"
|
|
4790
|
+
}
|
|
4791
|
+
]
|
|
4792
|
+
}
|
|
4793
|
+
]
|
|
4794
|
+
};
|
|
4795
|
+
const functionConfig = computed(() => [
|
|
4796
|
+
{
|
|
4797
|
+
text: "名称",
|
|
4798
|
+
name: "name",
|
|
4799
|
+
rules: [{ required: true, message: "请输入名称", trigger: "blur" }]
|
|
4800
|
+
},
|
|
4801
|
+
{
|
|
4802
|
+
text: "描述",
|
|
4803
|
+
name: "desc"
|
|
4804
|
+
},
|
|
4805
|
+
{
|
|
4806
|
+
text: "执行时机",
|
|
4807
|
+
name: "timing",
|
|
4808
|
+
type: "select",
|
|
4809
|
+
options: () => {
|
|
4810
|
+
const options = [
|
|
4811
|
+
{ text: "初始化前", value: "beforeInit" },
|
|
4812
|
+
{ text: "初始化后", value: "afterInit" }
|
|
4813
|
+
];
|
|
4814
|
+
if (props.dataSourceType !== "base") {
|
|
4815
|
+
options.push({ text: "请求前", value: "beforeRequest" });
|
|
4816
|
+
options.push({ text: "请求后", value: "afterRequest" });
|
|
4817
|
+
}
|
|
4818
|
+
return options;
|
|
4819
|
+
},
|
|
4820
|
+
display: () => props.isDataSource
|
|
4821
|
+
},
|
|
4822
|
+
{
|
|
4823
|
+
type: "table",
|
|
4824
|
+
border: true,
|
|
4825
|
+
text: "参数",
|
|
4826
|
+
enableFullscreen: false,
|
|
4827
|
+
enableToggleMode: false,
|
|
4828
|
+
name: "params",
|
|
4829
|
+
dropSort: false,
|
|
4830
|
+
items: [
|
|
4831
|
+
{
|
|
4832
|
+
type: "text",
|
|
4833
|
+
label: "参数名",
|
|
4834
|
+
name: "name"
|
|
4835
|
+
},
|
|
4836
|
+
{
|
|
4837
|
+
type: "text",
|
|
4838
|
+
label: "描述",
|
|
4839
|
+
name: "extra"
|
|
4840
|
+
},
|
|
4841
|
+
services?.codeBlockService.getParamsColConfig() || defaultParamColConfig
|
|
4842
|
+
]
|
|
4843
|
+
},
|
|
4844
|
+
{
|
|
4845
|
+
name: "content",
|
|
4846
|
+
type: "vs-code",
|
|
4847
|
+
options: inject("codeOptions", {}),
|
|
4848
|
+
height: "500px",
|
|
4849
|
+
onChange: (formState, code) => {
|
|
4850
|
+
try {
|
|
4851
|
+
getConfig("parseDSL")(code);
|
|
4852
|
+
return code;
|
|
4853
|
+
} catch (error) {
|
|
4854
|
+
tMagicMessage.error(error.message);
|
|
4855
|
+
throw error;
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4858
|
+
}
|
|
4859
|
+
]);
|
|
4860
|
+
const submitForm = (values) => {
|
|
4861
|
+
changedValue.value = void 0;
|
|
4862
|
+
emit("submit", values);
|
|
4996
4863
|
};
|
|
4997
|
-
const
|
|
4998
|
-
|
|
4999
|
-
const selectionStart = getSelectionStart();
|
|
5000
|
-
const curQueryString = queryString.substring(0, selectionStart);
|
|
5001
|
-
const fieldKeyStringLastIndex = curQueryString.lastIndexOf(".");
|
|
5002
|
-
const dsKeyStringLastIndex = curQueryString.lastIndexOf("${") + 1;
|
|
5003
|
-
const isFieldTip = fieldKeyStringLastIndex > dsKeyStringLastIndex;
|
|
5004
|
-
if (isFieldTip) {
|
|
5005
|
-
fieldQuerySearch(curQueryString, dsKeyStringLastIndex, fieldKeyStringLastIndex, cb);
|
|
5006
|
-
} else {
|
|
5007
|
-
dsQuerySearch(curQueryString, dsKeyStringLastIndex, cb);
|
|
5008
|
-
}
|
|
4864
|
+
const errorHandler = (error) => {
|
|
4865
|
+
tMagicMessage.error(error.message);
|
|
5009
4866
|
};
|
|
5010
|
-
const
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
if (!curCharIsLeftCurlyBracket(leftCurlyBracketIndex)) {
|
|
5020
|
-
startText = startText.substring(0, leftCurlyBracketIndex + 1);
|
|
5021
|
-
}
|
|
5022
|
-
if (!isRightCurlyBracket(selectionStart + 1)) {
|
|
5023
|
-
suggestText = `${suggestText}}`;
|
|
5024
|
-
}
|
|
5025
|
-
} else if (!curCharIsDot(dotIndex)) {
|
|
5026
|
-
startText = startText.substring(0, dotIndex + 1);
|
|
5027
|
-
}
|
|
5028
|
-
state.value = `${startText}${suggestText}${endText}`;
|
|
5029
|
-
await nextTick();
|
|
5030
|
-
let newSelectionStart = 0;
|
|
5031
|
-
if (isDataSource) {
|
|
5032
|
-
newSelectionStart = leftCurlyBracketIndex + suggestText.length;
|
|
5033
|
-
} else {
|
|
5034
|
-
newSelectionStart = dotIndex + suggestText.length + 1;
|
|
4867
|
+
const formBox = ref();
|
|
4868
|
+
const changedValue = ref();
|
|
4869
|
+
const changeHandler = (values) => {
|
|
4870
|
+
changedValue.value = values;
|
|
4871
|
+
};
|
|
4872
|
+
const beforeClose = (done) => {
|
|
4873
|
+
if (!changedValue.value) {
|
|
4874
|
+
done();
|
|
4875
|
+
return;
|
|
5035
4876
|
}
|
|
5036
|
-
|
|
5037
|
-
|
|
4877
|
+
tMagicMessageBox.confirm("当前代码块已修改,是否保存?", "提示", {
|
|
4878
|
+
confirmButtonText: "保存并关闭",
|
|
4879
|
+
cancelButtonText: "不保存并关闭",
|
|
4880
|
+
type: "warning",
|
|
4881
|
+
distinguishCancelAndClose: true
|
|
4882
|
+
}).then(() => {
|
|
4883
|
+
changedValue.value && submitForm(changedValue.value);
|
|
4884
|
+
done();
|
|
4885
|
+
}).catch((action) => {
|
|
4886
|
+
done(action === "cancel");
|
|
4887
|
+
});
|
|
5038
4888
|
};
|
|
4889
|
+
const closedHandler = () => {
|
|
4890
|
+
changedValue.value = void 0;
|
|
4891
|
+
};
|
|
4892
|
+
const parentFloating = inject("parentFloating", ref(null));
|
|
4893
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
4894
|
+
__expose({
|
|
4895
|
+
async show() {
|
|
4896
|
+
calcBoxPosition();
|
|
4897
|
+
boxVisible.value = true;
|
|
4898
|
+
},
|
|
4899
|
+
async hide() {
|
|
4900
|
+
boxVisible.value = false;
|
|
4901
|
+
}
|
|
4902
|
+
});
|
|
5039
4903
|
return (_ctx, _cache) => {
|
|
5040
|
-
return
|
|
5041
|
-
{
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
"onUpdate:
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
class: normalizeClass(`tmagic-data-source-input-text el-input t-input t-size-${_ctx.size?.[0]} el-input--${_ctx.size}`),
|
|
5076
|
-
onMouseup: mouseupHandler
|
|
5077
|
-
}, [
|
|
5078
|
-
createElementVNode("div", {
|
|
5079
|
-
class: normalizeClass(`tmagic-data-source-input-text-wrapper el-input__wrapper ${isFocused.value ? " is-focus" : ""}`)
|
|
5080
|
-
}, [
|
|
5081
|
-
createElementVNode("div", _hoisted_3$7, [
|
|
5082
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(displayState.value, (item, index) => {
|
|
5083
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
5084
|
-
item.type === "text" ? (openBlock(), createElementBlock("span", {
|
|
5085
|
-
key: index,
|
|
5086
|
-
style: { "margin-right": "2px" }
|
|
5087
|
-
}, toDisplayString(item.value), 1)) : createCommentVNode("", true),
|
|
5088
|
-
item.type === "var" ? (openBlock(), createBlock(unref(TMagicTag), {
|
|
5089
|
-
key: index,
|
|
5090
|
-
size: _ctx.size
|
|
4904
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
4905
|
+
createVNode(_sfc_main$N, {
|
|
4906
|
+
visible: boxVisible.value,
|
|
4907
|
+
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => boxVisible.value = $event),
|
|
4908
|
+
width: width.value,
|
|
4909
|
+
"onUpdate:width": _cache[2] || (_cache[2] = ($event) => width.value = $event),
|
|
4910
|
+
height: unref(codeBlockEditorHeight),
|
|
4911
|
+
"onUpdate:height": _cache[3] || (_cache[3] = ($event) => isRef(codeBlockEditorHeight) ? codeBlockEditorHeight.value = $event : null),
|
|
4912
|
+
title: _ctx.content.name ? `${_ctx.disabled ? "查看" : "编辑"}${_ctx.content.name}` : "新增代码",
|
|
4913
|
+
position: unref(boxPosition),
|
|
4914
|
+
"before-close": beforeClose
|
|
4915
|
+
}, {
|
|
4916
|
+
body: withCtx(() => [
|
|
4917
|
+
createVNode(unref(MFormBox), {
|
|
4918
|
+
class: "m-editor-code-block-editor",
|
|
4919
|
+
ref_key: "formBox",
|
|
4920
|
+
ref: formBox,
|
|
4921
|
+
"label-width": "80px",
|
|
4922
|
+
"close-on-press-escape": false,
|
|
4923
|
+
title: _ctx.content.name,
|
|
4924
|
+
config: functionConfig.value,
|
|
4925
|
+
values: _ctx.content,
|
|
4926
|
+
disabled: _ctx.disabled,
|
|
4927
|
+
style: { "height": "100%" },
|
|
4928
|
+
onChange: changeHandler,
|
|
4929
|
+
onSubmit: submitForm,
|
|
4930
|
+
onError: errorHandler,
|
|
4931
|
+
onClosed: closedHandler
|
|
4932
|
+
}, {
|
|
4933
|
+
left: withCtx(() => [
|
|
4934
|
+
!_ctx.disabled ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
4935
|
+
key: 0,
|
|
4936
|
+
type: "primary",
|
|
4937
|
+
link: "",
|
|
4938
|
+
onClick: _cache[0] || (_cache[0] = ($event) => difVisible.value = true)
|
|
5091
4939
|
}, {
|
|
5092
4940
|
default: withCtx(() => [
|
|
5093
|
-
createTextVNode(
|
|
4941
|
+
createTextVNode("查看修改")
|
|
5094
4942
|
]),
|
|
5095
|
-
_:
|
|
5096
|
-
}
|
|
5097
|
-
],
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
4943
|
+
_: 1
|
|
4944
|
+
})) : createCommentVNode("", true)
|
|
4945
|
+
]),
|
|
4946
|
+
_: 1
|
|
4947
|
+
}, 8, ["title", "config", "values", "disabled"])
|
|
4948
|
+
]),
|
|
4949
|
+
_: 1
|
|
4950
|
+
}, 8, ["visible", "width", "height", "title", "position"]),
|
|
4951
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4952
|
+
createVNode(unref(TMagicDialog), {
|
|
4953
|
+
title: "查看修改",
|
|
4954
|
+
modelValue: difVisible.value,
|
|
4955
|
+
"onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => difVisible.value = $event),
|
|
4956
|
+
fullscreen: ""
|
|
4957
|
+
}, {
|
|
4958
|
+
footer: withCtx(() => [
|
|
4959
|
+
createElementVNode("span", _hoisted_4$7, [
|
|
4960
|
+
createVNode(unref(TMagicButton), {
|
|
4961
|
+
size: "small",
|
|
4962
|
+
onClick: _cache[4] || (_cache[4] = ($event) => difVisible.value = false)
|
|
4963
|
+
}, {
|
|
4964
|
+
default: withCtx(() => [
|
|
4965
|
+
createTextVNode("取消")
|
|
4966
|
+
]),
|
|
4967
|
+
_: 1
|
|
4968
|
+
}),
|
|
4969
|
+
createVNode(unref(TMagicButton), {
|
|
4970
|
+
size: "small",
|
|
4971
|
+
type: "primary",
|
|
4972
|
+
onClick: diffChange
|
|
4973
|
+
}, {
|
|
4974
|
+
default: withCtx(() => [
|
|
4975
|
+
createTextVNode("确定")
|
|
4976
|
+
]),
|
|
4977
|
+
_: 1
|
|
4978
|
+
})
|
|
4979
|
+
])
|
|
4980
|
+
]),
|
|
4981
|
+
default: withCtx(() => [
|
|
4982
|
+
createElementVNode("div", _hoisted_1$o, [
|
|
4983
|
+
createElementVNode("div", _hoisted_2$h, [
|
|
4984
|
+
createVNode(unref(TMagicTag), {
|
|
4985
|
+
size: "small",
|
|
4986
|
+
type: "info"
|
|
4987
|
+
}, {
|
|
4988
|
+
default: withCtx(() => [
|
|
4989
|
+
createTextVNode("修改前")
|
|
4990
|
+
]),
|
|
4991
|
+
_: 1
|
|
4992
|
+
})
|
|
4993
|
+
]),
|
|
4994
|
+
createElementVNode("div", _hoisted_3$7, [
|
|
4995
|
+
createVNode(unref(TMagicTag), {
|
|
4996
|
+
size: "small",
|
|
4997
|
+
type: "success"
|
|
4998
|
+
}, {
|
|
4999
|
+
default: withCtx(() => [
|
|
5000
|
+
createTextVNode("修改后")
|
|
5001
|
+
]),
|
|
5002
|
+
_: 1
|
|
5003
|
+
})
|
|
5004
|
+
])
|
|
5005
|
+
]),
|
|
5006
|
+
difVisible.value ? (openBlock(), createBlock(_sfc_main$T, {
|
|
5007
|
+
key: 0,
|
|
5008
|
+
ref_key: "magicVsEditor",
|
|
5009
|
+
ref: magicVsEditor,
|
|
5010
|
+
type: "diff",
|
|
5011
|
+
language: "json",
|
|
5012
|
+
initValues: _ctx.content.content,
|
|
5013
|
+
modifiedValues: formBox.value?.form?.values.content,
|
|
5014
|
+
style: normalizeStyle(`height: ${unref(windowRect).height - 150}px`)
|
|
5015
|
+
}, null, 8, ["initValues", "modifiedValues", "style"])) : createCommentVNode("", true)
|
|
5016
|
+
]),
|
|
5017
|
+
_: 1
|
|
5018
|
+
}, 8, ["modelValue"])
|
|
5019
|
+
]))
|
|
5020
|
+
], 64);
|
|
5106
5021
|
};
|
|
5107
5022
|
}
|
|
5108
5023
|
});
|
|
5109
5024
|
|
|
5110
|
-
const _hoisted_1$
|
|
5025
|
+
const _hoisted_1$n = { class: "m-editor-data-source-methods" };
|
|
5111
5026
|
const _hoisted_2$g = { class: "m-editor-data-source-methods-footer" };
|
|
5112
|
-
const _sfc_main$
|
|
5027
|
+
const _sfc_main$I = /* @__PURE__ */ defineComponent({
|
|
5113
5028
|
...{
|
|
5114
5029
|
name: "MFieldsDataSourceMethods"
|
|
5115
5030
|
},
|
|
@@ -5179,7 +5094,7 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
5179
5094
|
emit("change", props.model[props.name]);
|
|
5180
5095
|
};
|
|
5181
5096
|
return (_ctx, _cache) => {
|
|
5182
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
5097
|
+
return openBlock(), createElementBlock("div", _hoisted_1$n, [
|
|
5183
5098
|
createVNode(unref(MagicTable), {
|
|
5184
5099
|
data: _ctx.model[_ctx.name],
|
|
5185
5100
|
columns: methodColumns
|
|
@@ -5198,7 +5113,7 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
5198
5113
|
_: 1
|
|
5199
5114
|
}, 8, ["disabled"])
|
|
5200
5115
|
]),
|
|
5201
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$
|
|
5116
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$J, {
|
|
5202
5117
|
key: 0,
|
|
5203
5118
|
ref_key: "codeBlockEditor",
|
|
5204
5119
|
ref: codeBlockEditor,
|
|
@@ -5213,9 +5128,9 @@ const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
|
5213
5128
|
}
|
|
5214
5129
|
});
|
|
5215
5130
|
|
|
5216
|
-
const _hoisted_1$
|
|
5131
|
+
const _hoisted_1$m = { class: "m-fields-data-source-method-select" };
|
|
5217
5132
|
const _hoisted_2$f = { class: "data-source-method-select-container" };
|
|
5218
|
-
const _sfc_main$
|
|
5133
|
+
const _sfc_main$H = /* @__PURE__ */ defineComponent({
|
|
5219
5134
|
...{
|
|
5220
5135
|
name: "MFieldsDataSourceMethodSelect"
|
|
5221
5136
|
},
|
|
@@ -5235,9 +5150,13 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5235
5150
|
setup(__props, { emit: __emit }) {
|
|
5236
5151
|
const mForm = inject("mForm");
|
|
5237
5152
|
const services = inject("services");
|
|
5153
|
+
const eventBus = inject("eventBus");
|
|
5238
5154
|
const emit = __emit;
|
|
5239
5155
|
const dataSourceService = services?.dataSourceService;
|
|
5240
5156
|
const props = __props;
|
|
5157
|
+
const hasDataSourceSidePanel = computed(
|
|
5158
|
+
() => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
|
|
5159
|
+
);
|
|
5241
5160
|
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
5242
5161
|
const dataSources = computed(() => dataSourceService?.get("dataSources"));
|
|
5243
5162
|
const isCustomMethod = computed(() => {
|
|
@@ -5292,36 +5211,38 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5292
5211
|
props.model.params = value.params;
|
|
5293
5212
|
emit("change", props.model);
|
|
5294
5213
|
};
|
|
5295
|
-
const { codeBlockEditor, codeConfig, editCode, submitCode } = useDataSourceMethod();
|
|
5296
5214
|
const editCodeHandler = () => {
|
|
5297
|
-
const [id
|
|
5215
|
+
const [id] = props.model[props.name];
|
|
5298
5216
|
const dataSource = dataSourceService?.getDataSourceById(id);
|
|
5299
5217
|
if (!dataSource)
|
|
5300
5218
|
return;
|
|
5301
|
-
|
|
5302
|
-
setParamsConfig([id, name]);
|
|
5303
|
-
};
|
|
5304
|
-
const submitCodeBlockHandler = (value) => {
|
|
5305
|
-
submitCode(value);
|
|
5219
|
+
eventBus?.emit("edit-data-source", id);
|
|
5306
5220
|
};
|
|
5307
5221
|
return (_ctx, _cache) => {
|
|
5308
|
-
|
|
5309
|
-
return openBlock(), createElementBlock("div", _hoisted_1$l, [
|
|
5222
|
+
return openBlock(), createElementBlock("div", _hoisted_1$m, [
|
|
5310
5223
|
createElementVNode("div", _hoisted_2$f, [
|
|
5311
|
-
createVNode(
|
|
5224
|
+
createVNode(unref(MContainer), {
|
|
5312
5225
|
class: "select",
|
|
5313
5226
|
config: cascaderConfig.value,
|
|
5314
5227
|
model: _ctx.model,
|
|
5228
|
+
size: _ctx.size,
|
|
5315
5229
|
onChange: onChangeHandler
|
|
5316
|
-
}, null, 8, ["config", "model"]),
|
|
5317
|
-
_ctx.model[_ctx.name] && isCustomMethod.value ? (openBlock(), createBlock(
|
|
5230
|
+
}, null, 8, ["config", "model", "size"]),
|
|
5231
|
+
_ctx.model[_ctx.name] && isCustomMethod.value && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
5318
5232
|
key: 0,
|
|
5319
|
-
class: "
|
|
5320
|
-
|
|
5233
|
+
class: "m-fields-select-action-button",
|
|
5234
|
+
size: _ctx.size,
|
|
5321
5235
|
onClick: editCodeHandler
|
|
5322
|
-
},
|
|
5236
|
+
}, {
|
|
5237
|
+
default: withCtx(() => [
|
|
5238
|
+
createVNode(_sfc_main$U, {
|
|
5239
|
+
icon: !notEditable.value ? unref(Edit) : unref(View)
|
|
5240
|
+
}, null, 8, ["icon"])
|
|
5241
|
+
]),
|
|
5242
|
+
_: 1
|
|
5243
|
+
}, 8, ["size"])) : createCommentVNode("", true)
|
|
5323
5244
|
]),
|
|
5324
|
-
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$
|
|
5245
|
+
paramsConfig.value.length ? (openBlock(), createBlock(_sfc_main$P, {
|
|
5325
5246
|
key: 0,
|
|
5326
5247
|
name: "params",
|
|
5327
5248
|
model: _ctx.model,
|
|
@@ -5329,23 +5250,15 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5329
5250
|
disabled: _ctx.disabled,
|
|
5330
5251
|
"params-config": paramsConfig.value,
|
|
5331
5252
|
onChange: onChangeHandler
|
|
5332
|
-
}, null, 8, ["model", "size", "disabled", "params-config"])) : createCommentVNode("", true)
|
|
5333
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$O, {
|
|
5334
|
-
key: 1,
|
|
5335
|
-
ref_key: "codeBlockEditor",
|
|
5336
|
-
ref: codeBlockEditor,
|
|
5337
|
-
disabled: notEditable.value,
|
|
5338
|
-
content: unref(codeConfig),
|
|
5339
|
-
onSubmit: submitCodeBlockHandler
|
|
5340
|
-
}, null, 8, ["disabled", "content"])) : createCommentVNode("", true)
|
|
5253
|
+
}, null, 8, ["model", "size", "disabled", "params-config"])) : createCommentVNode("", true)
|
|
5341
5254
|
]);
|
|
5342
5255
|
};
|
|
5343
5256
|
}
|
|
5344
5257
|
});
|
|
5345
5258
|
|
|
5346
|
-
const _hoisted_1$
|
|
5259
|
+
const _hoisted_1$l = { class: "m-editor-data-source-fields" };
|
|
5347
5260
|
const _hoisted_2$e = { class: "m-editor-data-source-fields-footer" };
|
|
5348
|
-
const _sfc_main$
|
|
5261
|
+
const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
5349
5262
|
...{
|
|
5350
5263
|
name: "MFieldsDataSourceMocks"
|
|
5351
5264
|
},
|
|
@@ -5551,7 +5464,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
5551
5464
|
const parentFloating = inject("parentFloating", ref(null));
|
|
5552
5465
|
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
5553
5466
|
return (_ctx, _cache) => {
|
|
5554
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
5467
|
+
return openBlock(), createElementBlock("div", _hoisted_1$l, [
|
|
5555
5468
|
createVNode(unref(MagicTable), {
|
|
5556
5469
|
data: _ctx.model[_ctx.name],
|
|
5557
5470
|
columns
|
|
@@ -5570,7 +5483,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
5570
5483
|
_: 1
|
|
5571
5484
|
}, 8, ["disabled"])
|
|
5572
5485
|
]),
|
|
5573
|
-
createVNode(_sfc_main$
|
|
5486
|
+
createVNode(_sfc_main$N, {
|
|
5574
5487
|
visible: addDialogVisible.value,
|
|
5575
5488
|
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => addDialogVisible.value = $event),
|
|
5576
5489
|
width: width.value,
|
|
@@ -5598,7 +5511,8 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
5598
5511
|
}
|
|
5599
5512
|
});
|
|
5600
5513
|
|
|
5601
|
-
const
|
|
5514
|
+
const _hoisted_1$k = { class: "m-fields-data-source-select" };
|
|
5515
|
+
const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
5602
5516
|
...{
|
|
5603
5517
|
name: "MFieldsDataSourceSelect"
|
|
5604
5518
|
},
|
|
@@ -5618,8 +5532,14 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5618
5532
|
setup(__props, { emit: __emit }) {
|
|
5619
5533
|
const emit = __emit;
|
|
5620
5534
|
const props = __props;
|
|
5621
|
-
const
|
|
5535
|
+
const mForm = inject("mForm");
|
|
5536
|
+
const { dataSourceService, uiService } = inject("services") || {};
|
|
5537
|
+
const eventBus = inject("eventBus");
|
|
5622
5538
|
const dataSources = computed(() => dataSourceService?.get("dataSources") || []);
|
|
5539
|
+
const notEditable = computed(() => filterFunction(mForm, props.config.notEditable, props));
|
|
5540
|
+
const hasDataSourceSidePanel = computed(
|
|
5541
|
+
() => (uiService?.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
|
|
5542
|
+
);
|
|
5623
5543
|
const selectConfig = computed(() => {
|
|
5624
5544
|
const { type, dataSourceType, value, ...config } = props.config;
|
|
5625
5545
|
const valueIsId = props.config.value === "id";
|
|
@@ -5640,17 +5560,42 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
5640
5560
|
const changeHandler = (value) => {
|
|
5641
5561
|
emit("change", value);
|
|
5642
5562
|
};
|
|
5563
|
+
const editHandler = () => {
|
|
5564
|
+
const value = props.model[props.name];
|
|
5565
|
+
if (!value)
|
|
5566
|
+
return;
|
|
5567
|
+
const id = typeof value === "string" ? value : value.dataSourceId;
|
|
5568
|
+
const dataSource = dataSourceService?.getDataSourceById(id);
|
|
5569
|
+
if (!dataSource)
|
|
5570
|
+
return;
|
|
5571
|
+
eventBus?.emit("edit-data-source", id);
|
|
5572
|
+
};
|
|
5643
5573
|
return (_ctx, _cache) => {
|
|
5644
|
-
return openBlock(),
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5574
|
+
return openBlock(), createElementBlock("div", _hoisted_1$k, [
|
|
5575
|
+
createVNode(unref(MSelect), {
|
|
5576
|
+
model: _ctx.model,
|
|
5577
|
+
name: _ctx.name,
|
|
5578
|
+
size: _ctx.size,
|
|
5579
|
+
prop: _ctx.prop,
|
|
5580
|
+
disabled: _ctx.disabled,
|
|
5581
|
+
config: selectConfig.value,
|
|
5582
|
+
"last-values": _ctx.lastValues,
|
|
5583
|
+
onChange: changeHandler
|
|
5584
|
+
}, null, 8, ["model", "name", "size", "prop", "disabled", "config", "last-values"]),
|
|
5585
|
+
_ctx.model[_ctx.name] && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
5586
|
+
key: 0,
|
|
5587
|
+
class: "m-fields-select-action-button",
|
|
5588
|
+
size: _ctx.size,
|
|
5589
|
+
onClick: editHandler
|
|
5590
|
+
}, {
|
|
5591
|
+
default: withCtx(() => [
|
|
5592
|
+
createVNode(_sfc_main$U, {
|
|
5593
|
+
icon: !notEditable.value ? unref(Edit) : unref(View)
|
|
5594
|
+
}, null, 8, ["icon"])
|
|
5595
|
+
]),
|
|
5596
|
+
_: 1
|
|
5597
|
+
}, 8, ["size"])) : createCommentVNode("", true)
|
|
5598
|
+
]);
|
|
5654
5599
|
};
|
|
5655
5600
|
}
|
|
5656
5601
|
});
|
|
@@ -5660,7 +5605,7 @@ const _hoisted_2$d = {
|
|
|
5660
5605
|
key: 1,
|
|
5661
5606
|
class: "fullWidth"
|
|
5662
5607
|
};
|
|
5663
|
-
const _sfc_main$
|
|
5608
|
+
const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
5664
5609
|
...{
|
|
5665
5610
|
name: "MFieldsEventSelect"
|
|
5666
5611
|
},
|
|
@@ -5818,6 +5763,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
5818
5763
|
]
|
|
5819
5764
|
}));
|
|
5820
5765
|
const actionsConfig = computed(() => ({
|
|
5766
|
+
type: "panel",
|
|
5821
5767
|
items: [
|
|
5822
5768
|
{
|
|
5823
5769
|
type: "group-list",
|
|
@@ -5862,8 +5808,6 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
5862
5808
|
};
|
|
5863
5809
|
return (_ctx, _cache) => {
|
|
5864
5810
|
const _component_m_form_table = resolveComponent("m-form-table");
|
|
5865
|
-
const _component_m_form_container = resolveComponent("m-form-container");
|
|
5866
|
-
const _component_m_form_panel = resolveComponent("m-form-panel");
|
|
5867
5811
|
return openBlock(), createElementBlock("div", _hoisted_1$j, [
|
|
5868
5812
|
isOldVersion.value ? (openBlock(), createBlock(_component_m_form_table, {
|
|
5869
5813
|
key: 0,
|
|
@@ -5888,7 +5832,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
5888
5832
|
_: 1
|
|
5889
5833
|
}, 8, ["size", "disabled"]),
|
|
5890
5834
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.model[_ctx.name], (cardItem, index) => {
|
|
5891
|
-
return openBlock(), createBlock(
|
|
5835
|
+
return openBlock(), createBlock(unref(MPanel), {
|
|
5892
5836
|
key: index,
|
|
5893
5837
|
disabled: _ctx.disabled,
|
|
5894
5838
|
size: _ctx.size,
|
|
@@ -5898,7 +5842,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
5898
5842
|
onChange: onChangeHandler
|
|
5899
5843
|
}, {
|
|
5900
5844
|
header: withCtx(() => [
|
|
5901
|
-
createVNode(
|
|
5845
|
+
createVNode(unref(MContainer), {
|
|
5902
5846
|
class: "fullWidth",
|
|
5903
5847
|
config: eventNameConfig.value,
|
|
5904
5848
|
model: cardItem,
|
|
@@ -5934,7 +5878,7 @@ const _hoisted_2$c = /* @__PURE__ */ createStaticVNode('<defs><rect id="path-1"
|
|
|
5934
5878
|
const _hoisted_4$6 = [
|
|
5935
5879
|
_hoisted_2$c
|
|
5936
5880
|
];
|
|
5937
|
-
const _sfc_main$
|
|
5881
|
+
const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
5938
5882
|
...{
|
|
5939
5883
|
name: "MEditorCodeIcon"
|
|
5940
5884
|
},
|
|
@@ -5949,7 +5893,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
5949
5893
|
const _hoisted_1$h = { class: "m-fields-key-value" };
|
|
5950
5894
|
const _hoisted_2$b = { key: 0 };
|
|
5951
5895
|
const _hoisted_3$6 = /* @__PURE__ */ createElementVNode("span", { class: "m-fileds-key-value-delimiter" }, ":", -1);
|
|
5952
|
-
const _sfc_main$
|
|
5896
|
+
const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
5953
5897
|
...{
|
|
5954
5898
|
name: "MFieldsKeyValue"
|
|
5955
5899
|
},
|
|
@@ -6073,7 +6017,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
6073
6017
|
size: "default",
|
|
6074
6018
|
disabled: _ctx.disabled,
|
|
6075
6019
|
link: "",
|
|
6076
|
-
icon: _sfc_main$
|
|
6020
|
+
icon: _sfc_main$D,
|
|
6077
6021
|
onClick: _cache[0] || (_cache[0] = ($event) => showCode.value = !showCode.value)
|
|
6078
6022
|
}, null, 8, ["disabled"])) : createCommentVNode("", true)
|
|
6079
6023
|
]);
|
|
@@ -6083,7 +6027,7 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
6083
6027
|
|
|
6084
6028
|
const _hoisted_1$g = { class: "m-fields-page-fragment-select" };
|
|
6085
6029
|
const _hoisted_2$a = { class: "page-fragment-select-container" };
|
|
6086
|
-
const _sfc_main$
|
|
6030
|
+
const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
6087
6031
|
...{
|
|
6088
6032
|
name: "MFieldsPageFragmentSelect"
|
|
6089
6033
|
},
|
|
@@ -6155,7 +6099,7 @@ const _hoisted_1$f = {
|
|
|
6155
6099
|
class: "m-fields-ui-select",
|
|
6156
6100
|
style: { "display": "flex" }
|
|
6157
6101
|
};
|
|
6158
|
-
const _sfc_main$
|
|
6102
|
+
const _sfc_main$A = /* @__PURE__ */ defineComponent({
|
|
6159
6103
|
...{
|
|
6160
6104
|
name: "MFieldsUISelect"
|
|
6161
6105
|
},
|
|
@@ -6343,7 +6287,7 @@ const useGetSo = (target, emit) => {
|
|
|
6343
6287
|
};
|
|
6344
6288
|
};
|
|
6345
6289
|
|
|
6346
|
-
const _sfc_main$
|
|
6290
|
+
const _sfc_main$z = /* @__PURE__ */ defineComponent({
|
|
6347
6291
|
...{
|
|
6348
6292
|
name: "MEditorResizer"
|
|
6349
6293
|
},
|
|
@@ -6365,7 +6309,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
|
6365
6309
|
}
|
|
6366
6310
|
});
|
|
6367
6311
|
|
|
6368
|
-
const _sfc_main$
|
|
6312
|
+
const _sfc_main$y = /* @__PURE__ */ defineComponent({
|
|
6369
6313
|
...{
|
|
6370
6314
|
name: "MEditorSplitView"
|
|
6371
6315
|
},
|
|
@@ -6506,7 +6450,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6506
6450
|
}, [
|
|
6507
6451
|
renderSlot(_ctx.$slots, "left")
|
|
6508
6452
|
], 6),
|
|
6509
|
-
createVNode(_sfc_main$
|
|
6453
|
+
createVNode(_sfc_main$z, { onChange: changeLeft })
|
|
6510
6454
|
], 64)) : createCommentVNode("", true),
|
|
6511
6455
|
createElementVNode("div", {
|
|
6512
6456
|
class: normalizeClass(["m-editor-layout-center", _ctx.centerClass]),
|
|
@@ -6515,7 +6459,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
6515
6459
|
renderSlot(_ctx.$slots, "center")
|
|
6516
6460
|
], 6),
|
|
6517
6461
|
hasRight.value && _ctx.$slots.right ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
6518
|
-
createVNode(_sfc_main$
|
|
6462
|
+
createVNode(_sfc_main$z, { onChange: changeRight }),
|
|
6519
6463
|
createElementVNode("div", {
|
|
6520
6464
|
class: normalizeClass(["m-editor-layout-right", _ctx.rightClass]),
|
|
6521
6465
|
style: normalizeStyle(`width: ${_ctx.right}px`)
|
|
@@ -6533,7 +6477,7 @@ const _hoisted_1$e = {
|
|
|
6533
6477
|
class: "menu-item-text"
|
|
6534
6478
|
};
|
|
6535
6479
|
const _hoisted_2$9 = { class: "el-dropdown-link menubar-menu-button" };
|
|
6536
|
-
const _sfc_main$
|
|
6480
|
+
const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
6537
6481
|
...{
|
|
6538
6482
|
name: "MEditorToolButton"
|
|
6539
6483
|
},
|
|
@@ -6698,7 +6642,7 @@ const _hoisted_1$d = {
|
|
|
6698
6642
|
key: 1,
|
|
6699
6643
|
style: { "width": "21px" }
|
|
6700
6644
|
};
|
|
6701
|
-
const _sfc_main$
|
|
6645
|
+
const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
6702
6646
|
...{
|
|
6703
6647
|
name: "MEditorPageBarAddButton"
|
|
6704
6648
|
},
|
|
@@ -6738,7 +6682,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
6738
6682
|
}
|
|
6739
6683
|
});
|
|
6740
6684
|
|
|
6741
|
-
const _sfc_main$
|
|
6685
|
+
const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
6742
6686
|
...{
|
|
6743
6687
|
name: "MEditorPageBarScrollContainer"
|
|
6744
6688
|
},
|
|
@@ -6867,7 +6811,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
6867
6811
|
}
|
|
6868
6812
|
});
|
|
6869
6813
|
|
|
6870
|
-
const _sfc_main$
|
|
6814
|
+
const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
6871
6815
|
...{
|
|
6872
6816
|
name: "MEditorPageBarSwitchTypeButton"
|
|
6873
6817
|
},
|
|
@@ -6915,7 +6859,7 @@ const _hoisted_1$c = { class: "m-editor-page-bar-tabs" };
|
|
|
6915
6859
|
const _hoisted_2$8 = ["onClick"];
|
|
6916
6860
|
const _hoisted_3$5 = { class: "m-editor-page-bar-title" };
|
|
6917
6861
|
const _hoisted_4$5 = ["title"];
|
|
6918
|
-
const _sfc_main$
|
|
6862
|
+
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
6919
6863
|
...{
|
|
6920
6864
|
name: "MEditorPageBar"
|
|
6921
6865
|
},
|
|
@@ -6994,14 +6938,14 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
6994
6938
|
};
|
|
6995
6939
|
return (_ctx, _cache) => {
|
|
6996
6940
|
return openBlock(), createElementBlock("div", _hoisted_1$c, [
|
|
6997
|
-
!_ctx.disabledPageFragment ? (openBlock(), createBlock(_sfc_main$
|
|
6941
|
+
!_ctx.disabledPageFragment ? (openBlock(), createBlock(_sfc_main$u, {
|
|
6998
6942
|
key: 0,
|
|
6999
6943
|
modelValue: active.value,
|
|
7000
6944
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => active.value = $event)
|
|
7001
6945
|
}, null, 8, ["modelValue"])) : createCommentVNode("", true),
|
|
7002
|
-
createVNode(_sfc_main$
|
|
6946
|
+
createVNode(_sfc_main$v, { type: active.value }, {
|
|
7003
6947
|
prepend: withCtx(() => [
|
|
7004
|
-
createVNode(_sfc_main$
|
|
6948
|
+
createVNode(_sfc_main$w, { type: active.value }, null, 8, ["type"])
|
|
7005
6949
|
]),
|
|
7006
6950
|
default: withCtx(() => [
|
|
7007
6951
|
(openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (item) => {
|
|
@@ -7034,7 +6978,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
7034
6978
|
default: withCtx(() => [
|
|
7035
6979
|
createElementVNode("div", null, [
|
|
7036
6980
|
renderSlot(_ctx.$slots, "page-bar-popover", { page: item }, () => [
|
|
7037
|
-
createVNode(_sfc_main$
|
|
6981
|
+
createVNode(_sfc_main$x, {
|
|
7038
6982
|
data: {
|
|
7039
6983
|
type: "button",
|
|
7040
6984
|
text: "复制",
|
|
@@ -7042,7 +6986,7 @@ const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
|
7042
6986
|
handler: () => copy(item)
|
|
7043
6987
|
}
|
|
7044
6988
|
}, null, 8, ["data"]),
|
|
7045
|
-
createVNode(_sfc_main$
|
|
6989
|
+
createVNode(_sfc_main$x, {
|
|
7046
6990
|
data: {
|
|
7047
6991
|
type: "button",
|
|
7048
6992
|
text: "删除",
|
|
@@ -7069,7 +7013,7 @@ const _hoisted_1$b = { class: "m-editor-empty-panel" };
|
|
|
7069
7013
|
const _hoisted_2$7 = { class: "m-editor-empty-content" };
|
|
7070
7014
|
const _hoisted_3$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面", -1);
|
|
7071
7015
|
const _hoisted_4$4 = /* @__PURE__ */ createElementVNode("p", null, "新增页面片", -1);
|
|
7072
|
-
const _sfc_main$
|
|
7016
|
+
const _sfc_main$s = /* @__PURE__ */ defineComponent({
|
|
7073
7017
|
...{
|
|
7074
7018
|
name: "MEditorAddPageBox"
|
|
7075
7019
|
},
|
|
@@ -7124,7 +7068,7 @@ const DEFAULT_LEFT_COLUMN_WIDTH = 310;
|
|
|
7124
7068
|
const DEFAULT_RIGHT_COLUMN_WIDTH = 480;
|
|
7125
7069
|
const LEFT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorLeftColumnWidthData";
|
|
7126
7070
|
const RIGHT_COLUMN_WIDTH_STORAGE_KEY = "$MagicEditorRightColumnWidthData";
|
|
7127
|
-
const _sfc_main$
|
|
7071
|
+
const _sfc_main$r = /* @__PURE__ */ defineComponent({
|
|
7128
7072
|
...{
|
|
7129
7073
|
name: "MEditorFramework"
|
|
7130
7074
|
},
|
|
@@ -7208,7 +7152,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
7208
7152
|
options: unref(codeOptions),
|
|
7209
7153
|
onSave: saveCode
|
|
7210
7154
|
}, null, 8, ["init-values", "options"])
|
|
7211
|
-
]) : withDirectives((openBlock(), createBlock(_sfc_main$
|
|
7155
|
+
]) : withDirectives((openBlock(), createBlock(_sfc_main$y, {
|
|
7212
7156
|
key: 1,
|
|
7213
7157
|
"element-loading-text": "Runtime 加载中...",
|
|
7214
7158
|
ref_key: "splitView",
|
|
@@ -7232,10 +7176,10 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
7232
7176
|
]),
|
|
7233
7177
|
center: withCtx(() => [
|
|
7234
7178
|
page.value ? renderSlot(_ctx.$slots, "workspace", { key: 0 }) : renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
7235
|
-
createVNode(_sfc_main$
|
|
7179
|
+
createVNode(_sfc_main$s, { "disabled-page-fragment": _ctx.disabledPageFragment }, null, 8, ["disabled-page-fragment"])
|
|
7236
7180
|
]),
|
|
7237
7181
|
renderSlot(_ctx.$slots, "page-bar", {}, () => [
|
|
7238
|
-
createVNode(_sfc_main$
|
|
7182
|
+
createVNode(_sfc_main$t, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
|
|
7239
7183
|
"page-bar-title": withCtx(({ page: page2 }) => [
|
|
7240
7184
|
renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
|
|
7241
7185
|
]),
|
|
@@ -7270,7 +7214,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
7270
7214
|
}
|
|
7271
7215
|
});
|
|
7272
7216
|
|
|
7273
|
-
const _sfc_main$
|
|
7217
|
+
const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
7274
7218
|
...{
|
|
7275
7219
|
name: "MEditorNavMenu"
|
|
7276
7220
|
},
|
|
@@ -7452,7 +7396,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
7452
7396
|
style: normalizeStyle(`width: ${columnWidth.value?.[key]}px`)
|
|
7453
7397
|
}, [
|
|
7454
7398
|
(openBlock(true), createElementBlock(Fragment, null, renderList(buttons.value[key], (item, index) => {
|
|
7455
|
-
return openBlock(), createBlock(_sfc_main$
|
|
7399
|
+
return openBlock(), createBlock(_sfc_main$x, {
|
|
7456
7400
|
data: item,
|
|
7457
7401
|
key: index
|
|
7458
7402
|
}, null, 8, ["data"]);
|
|
@@ -7465,12 +7409,13 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
7465
7409
|
});
|
|
7466
7410
|
|
|
7467
7411
|
const _hoisted_1$a = { class: "m-editor-props-panel" };
|
|
7468
|
-
const _sfc_main$
|
|
7412
|
+
const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
7469
7413
|
...{
|
|
7470
7414
|
name: "MEditorPropsPanel"
|
|
7471
7415
|
},
|
|
7472
7416
|
__name: "PropsPanel",
|
|
7473
7417
|
props: {
|
|
7418
|
+
disabledShowSrc: { type: Boolean },
|
|
7474
7419
|
extendState: { type: Function }
|
|
7475
7420
|
},
|
|
7476
7421
|
emits: ["mounted", "submit-error", "form-error"],
|
|
@@ -7531,7 +7476,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
7531
7476
|
createVNode(unref(MForm), {
|
|
7532
7477
|
ref_key: "configForm",
|
|
7533
7478
|
ref: configForm,
|
|
7534
|
-
class: normalizeClass(
|
|
7479
|
+
class: normalizeClass(propsPanelSize.value),
|
|
7535
7480
|
"popper-class": `m-editor-props-panel-popper ${propsPanelSize.value}`,
|
|
7536
7481
|
size: propsPanelSize.value,
|
|
7537
7482
|
"init-values": values.value,
|
|
@@ -7540,7 +7485,8 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
7540
7485
|
onChange: submit,
|
|
7541
7486
|
onError: errorHandler
|
|
7542
7487
|
}, null, 8, ["class", "popper-class", "size", "init-values", "config", "extend-state"]),
|
|
7543
|
-
|
|
7488
|
+
!_ctx.disabledShowSrc ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
7489
|
+
key: 0,
|
|
7544
7490
|
class: "m-editor-props-panel-src-icon",
|
|
7545
7491
|
circle: "",
|
|
7546
7492
|
size: "large",
|
|
@@ -7552,9 +7498,9 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
7552
7498
|
createVNode(_sfc_main$U, { icon: unref(Document) }, null, 8, ["icon"])
|
|
7553
7499
|
]),
|
|
7554
7500
|
_: 1
|
|
7555
|
-
}, 8, ["type"]),
|
|
7501
|
+
}, 8, ["type"])) : createCommentVNode("", true),
|
|
7556
7502
|
showSrc.value ? (openBlock(), createBlock(_sfc_main$T, {
|
|
7557
|
-
key:
|
|
7503
|
+
key: 1,
|
|
7558
7504
|
height: `${unref(editorContentHeight)}px`,
|
|
7559
7505
|
"init-values": values.value,
|
|
7560
7506
|
options: unref(codeOptions),
|
|
@@ -7568,7 +7514,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
|
7568
7514
|
}
|
|
7569
7515
|
});
|
|
7570
7516
|
|
|
7571
|
-
const _sfc_main$
|
|
7517
|
+
const _sfc_main$o = /* @__PURE__ */ defineComponent({
|
|
7572
7518
|
...{
|
|
7573
7519
|
name: "MEditorSearchInput"
|
|
7574
7520
|
},
|
|
@@ -7626,7 +7572,7 @@ const _hoisted_4$3 = {
|
|
|
7626
7572
|
key: 0,
|
|
7627
7573
|
class: "m-editor-tree-node-children"
|
|
7628
7574
|
};
|
|
7629
|
-
const _sfc_main$
|
|
7575
|
+
const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
7630
7576
|
...{
|
|
7631
7577
|
name: "MEditorTreeNode"
|
|
7632
7578
|
},
|
|
@@ -7747,7 +7693,7 @@ const _hoisted_1$8 = {
|
|
|
7747
7693
|
key: 1,
|
|
7748
7694
|
class: "m-editor-tree-empty"
|
|
7749
7695
|
};
|
|
7750
|
-
const _sfc_main$
|
|
7696
|
+
const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
7751
7697
|
...{
|
|
7752
7698
|
name: "MEditorTree"
|
|
7753
7699
|
},
|
|
@@ -7771,7 +7717,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
|
7771
7717
|
onDragover: handleDragOver
|
|
7772
7718
|
}, [
|
|
7773
7719
|
_ctx.data?.length ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.data, (item) => {
|
|
7774
|
-
return openBlock(), createBlock(_sfc_main$
|
|
7720
|
+
return openBlock(), createBlock(_sfc_main$n, {
|
|
7775
7721
|
key: item.id,
|
|
7776
7722
|
data: item,
|
|
7777
7723
|
indent: _ctx.indent,
|
|
@@ -7868,7 +7814,7 @@ const useNodeStatus$1 = (nodeData) => {
|
|
|
7868
7814
|
};
|
|
7869
7815
|
};
|
|
7870
7816
|
|
|
7871
|
-
const _sfc_main$
|
|
7817
|
+
const _sfc_main$l = /* @__PURE__ */ defineComponent({
|
|
7872
7818
|
...{
|
|
7873
7819
|
name: "MEditorCodeBlockList"
|
|
7874
7820
|
},
|
|
@@ -7950,7 +7896,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
7950
7896
|
filter: filterTextChangeHandler
|
|
7951
7897
|
});
|
|
7952
7898
|
return (_ctx, _cache) => {
|
|
7953
|
-
return openBlock(), createBlock(_sfc_main$
|
|
7899
|
+
return openBlock(), createBlock(_sfc_main$m, {
|
|
7954
7900
|
data: codeList.value,
|
|
7955
7901
|
"node-status-map": unref(nodeStatusMap),
|
|
7956
7902
|
onNodeClick: clickHandler
|
|
@@ -8007,7 +7953,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
|
8007
7953
|
});
|
|
8008
7954
|
|
|
8009
7955
|
const _hoisted_1$7 = { class: "search-wrapper" };
|
|
8010
|
-
const _sfc_main$
|
|
7956
|
+
const _sfc_main$k = /* @__PURE__ */ defineComponent({
|
|
8011
7957
|
...{
|
|
8012
7958
|
name: "MEditorCodeBlockListPanel"
|
|
8013
7959
|
},
|
|
@@ -8016,6 +7962,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
8016
7962
|
customError: { type: Function }
|
|
8017
7963
|
},
|
|
8018
7964
|
setup(__props) {
|
|
7965
|
+
const eventBus = inject("eventBus");
|
|
8019
7966
|
const { codeBlockService } = inject("services") || {};
|
|
8020
7967
|
const editable = computed(() => codeBlockService?.getEditStatus());
|
|
8021
7968
|
const { codeBlockEditor, codeConfig, editCode, deleteCode, createCodeBlock, submitCodeBlockHandler } = useCodeBlockEdit(codeBlockService);
|
|
@@ -8023,13 +7970,16 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
8023
7970
|
const filterTextChangeHandler = (val) => {
|
|
8024
7971
|
codeBlockList.value?.filter(val);
|
|
8025
7972
|
};
|
|
7973
|
+
eventBus?.on("edit-code", (id) => {
|
|
7974
|
+
editCode(id);
|
|
7975
|
+
});
|
|
8026
7976
|
return (_ctx, _cache) => {
|
|
8027
7977
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
8028
7978
|
createVNode(unref(TMagicScrollbar), { class: "m-editor-code-block-list m-editor-layer-panel" }, {
|
|
8029
7979
|
default: withCtx(() => [
|
|
8030
7980
|
renderSlot(_ctx.$slots, "code-block-panel-header", {}, () => [
|
|
8031
7981
|
createElementVNode("div", _hoisted_1$7, [
|
|
8032
|
-
createVNode(_sfc_main$
|
|
7982
|
+
createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
|
|
8033
7983
|
editable.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
8034
7984
|
key: 0,
|
|
8035
7985
|
class: "create-code-button",
|
|
@@ -8045,7 +7995,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
8045
7995
|
renderSlot(_ctx.$slots, "code-block-panel-search")
|
|
8046
7996
|
])
|
|
8047
7997
|
]),
|
|
8048
|
-
createVNode(_sfc_main$
|
|
7998
|
+
createVNode(_sfc_main$l, {
|
|
8049
7999
|
ref_key: "codeBlockList",
|
|
8050
8000
|
ref: codeBlockList,
|
|
8051
8001
|
"custom-error": _ctx.customError,
|
|
@@ -8063,7 +8013,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
8063
8013
|
]),
|
|
8064
8014
|
_: 3
|
|
8065
8015
|
}),
|
|
8066
|
-
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$
|
|
8016
|
+
unref(codeConfig) ? (openBlock(), createBlock(_sfc_main$J, {
|
|
8067
8017
|
key: 0,
|
|
8068
8018
|
ref_key: "codeBlockEditor",
|
|
8069
8019
|
ref: codeBlockEditor,
|
|
@@ -8076,6 +8026,113 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
8076
8026
|
}
|
|
8077
8027
|
});
|
|
8078
8028
|
|
|
8029
|
+
const useDataSourceEdit = (dataSourceService) => {
|
|
8030
|
+
const dialogTitle = ref("");
|
|
8031
|
+
const editDialog = ref();
|
|
8032
|
+
const dataSourceValues = ref({});
|
|
8033
|
+
const editable = computed(() => dataSourceService?.get("editable") ?? true);
|
|
8034
|
+
const editHandler = (id) => {
|
|
8035
|
+
if (!editDialog.value)
|
|
8036
|
+
return;
|
|
8037
|
+
dataSourceValues.value = {
|
|
8038
|
+
...dataSourceService?.getDataSourceById(id)
|
|
8039
|
+
};
|
|
8040
|
+
dialogTitle.value = `编辑${dataSourceValues.value.title || ""}`;
|
|
8041
|
+
editDialog.value.show();
|
|
8042
|
+
};
|
|
8043
|
+
const submitDataSourceHandler = (value) => {
|
|
8044
|
+
if (value.id) {
|
|
8045
|
+
dataSourceService?.update(value);
|
|
8046
|
+
} else {
|
|
8047
|
+
dataSourceService?.add(value);
|
|
8048
|
+
}
|
|
8049
|
+
editDialog.value?.hide();
|
|
8050
|
+
};
|
|
8051
|
+
return {
|
|
8052
|
+
dialogTitle,
|
|
8053
|
+
editDialog,
|
|
8054
|
+
dataSourceValues,
|
|
8055
|
+
editable,
|
|
8056
|
+
editHandler,
|
|
8057
|
+
submitDataSourceHandler
|
|
8058
|
+
};
|
|
8059
|
+
};
|
|
8060
|
+
|
|
8061
|
+
const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
8062
|
+
...{
|
|
8063
|
+
name: "MEditorDataSourceConfigPanel"
|
|
8064
|
+
},
|
|
8065
|
+
__name: "DataSourceConfigPanel",
|
|
8066
|
+
props: /* @__PURE__ */ mergeModels({
|
|
8067
|
+
title: {},
|
|
8068
|
+
values: {},
|
|
8069
|
+
disabled: { type: Boolean }
|
|
8070
|
+
}, {
|
|
8071
|
+
"visible": { type: Boolean, ...{ default: false } },
|
|
8072
|
+
"visibleModifiers": {},
|
|
8073
|
+
"width": { default: 670 },
|
|
8074
|
+
"widthModifiers": {}
|
|
8075
|
+
}),
|
|
8076
|
+
emits: /* @__PURE__ */ mergeModels(["submit"], ["update:visible", "update:width"]),
|
|
8077
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
8078
|
+
const props = __props;
|
|
8079
|
+
const boxVisible = useModel(__props, "visible");
|
|
8080
|
+
const width = useModel(__props, "width");
|
|
8081
|
+
const emit = __emit;
|
|
8082
|
+
const services = inject("services");
|
|
8083
|
+
const initValues = ref({});
|
|
8084
|
+
const dataSourceConfig = ref([]);
|
|
8085
|
+
const { height: editorHeight } = useEditorContentHeight();
|
|
8086
|
+
const parentFloating = inject("parentFloating", ref(null));
|
|
8087
|
+
const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
|
|
8088
|
+
watchEffect(() => {
|
|
8089
|
+
initValues.value = props.values;
|
|
8090
|
+
dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
|
|
8091
|
+
});
|
|
8092
|
+
const submitHandler = (values) => {
|
|
8093
|
+
emit("submit", values);
|
|
8094
|
+
};
|
|
8095
|
+
const errorHandler = (error) => {
|
|
8096
|
+
tMagicMessage.error(error.message);
|
|
8097
|
+
};
|
|
8098
|
+
__expose({
|
|
8099
|
+
show() {
|
|
8100
|
+
calcBoxPosition();
|
|
8101
|
+
boxVisible.value = true;
|
|
8102
|
+
},
|
|
8103
|
+
hide() {
|
|
8104
|
+
boxVisible.value = false;
|
|
8105
|
+
}
|
|
8106
|
+
});
|
|
8107
|
+
return (_ctx, _cache) => {
|
|
8108
|
+
return openBlock(), createBlock(_sfc_main$N, {
|
|
8109
|
+
visible: boxVisible.value,
|
|
8110
|
+
"onUpdate:visible": _cache[0] || (_cache[0] = ($event) => boxVisible.value = $event),
|
|
8111
|
+
width: width.value,
|
|
8112
|
+
"onUpdate:width": _cache[1] || (_cache[1] = ($event) => width.value = $event),
|
|
8113
|
+
height: unref(editorHeight),
|
|
8114
|
+
"onUpdate:height": _cache[2] || (_cache[2] = ($event) => isRef(editorHeight) ? editorHeight.value = $event : null),
|
|
8115
|
+
title: _ctx.title,
|
|
8116
|
+
position: unref(boxPosition)
|
|
8117
|
+
}, {
|
|
8118
|
+
body: withCtx(() => [
|
|
8119
|
+
createVNode(unref(MFormBox), {
|
|
8120
|
+
"label-width": "80px",
|
|
8121
|
+
title: _ctx.title,
|
|
8122
|
+
config: dataSourceConfig.value,
|
|
8123
|
+
values: initValues.value,
|
|
8124
|
+
disabled: _ctx.disabled,
|
|
8125
|
+
style: { "height": "100%" },
|
|
8126
|
+
onSubmit: submitHandler,
|
|
8127
|
+
onError: errorHandler
|
|
8128
|
+
}, null, 8, ["title", "config", "values", "disabled"])
|
|
8129
|
+
]),
|
|
8130
|
+
_: 1
|
|
8131
|
+
}, 8, ["visible", "width", "height", "title", "position"]);
|
|
8132
|
+
};
|
|
8133
|
+
}
|
|
8134
|
+
});
|
|
8135
|
+
|
|
8079
8136
|
const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
8080
8137
|
...{
|
|
8081
8138
|
name: "MEditorDataSourceList"
|
|
@@ -8165,7 +8222,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
8165
8222
|
filter: filterTextChangeHandler
|
|
8166
8223
|
});
|
|
8167
8224
|
return (_ctx, _cache) => {
|
|
8168
|
-
return openBlock(), createBlock(_sfc_main$
|
|
8225
|
+
return openBlock(), createBlock(_sfc_main$m, {
|
|
8169
8226
|
data: list.value,
|
|
8170
8227
|
"node-status-map": unref(nodeStatusMap),
|
|
8171
8228
|
onNodeClick: clickHandler
|
|
@@ -8226,6 +8283,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8226
8283
|
},
|
|
8227
8284
|
__name: "DataSourceListPanel",
|
|
8228
8285
|
setup(__props) {
|
|
8286
|
+
const eventBus = inject("eventBus");
|
|
8229
8287
|
const { dataSourceService } = inject("services") || {};
|
|
8230
8288
|
const { editDialog, dataSourceValues, dialogTitle, editable, editHandler, submitDataSourceHandler } = useDataSourceEdit(dataSourceService);
|
|
8231
8289
|
const datasourceTypeList = computed(
|
|
@@ -8257,12 +8315,15 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8257
8315
|
const filterTextChangeHandler = (val) => {
|
|
8258
8316
|
dataSourceList.value?.filter(val);
|
|
8259
8317
|
};
|
|
8318
|
+
eventBus?.on("edit-data-source", (id) => {
|
|
8319
|
+
editHandler(id);
|
|
8320
|
+
});
|
|
8260
8321
|
return (_ctx, _cache) => {
|
|
8261
8322
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
8262
8323
|
createVNode(unref(TMagicScrollbar), { class: "data-source-list-panel m-editor-layer-panel" }, {
|
|
8263
8324
|
default: withCtx(() => [
|
|
8264
8325
|
createElementVNode("div", _hoisted_1$6, [
|
|
8265
|
-
createVNode(_sfc_main$
|
|
8326
|
+
createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
|
|
8266
8327
|
unref(editable) ? (openBlock(), createBlock(unref(TMagicPopover), {
|
|
8267
8328
|
key: 0,
|
|
8268
8329
|
placement: "right"
|
|
@@ -8281,7 +8342,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8281
8342
|
default: withCtx(() => [
|
|
8282
8343
|
createElementVNode("div", _hoisted_2$5, [
|
|
8283
8344
|
(openBlock(true), createElementBlock(Fragment, null, renderList(datasourceTypeList.value, (item, index) => {
|
|
8284
|
-
return openBlock(), createBlock(_sfc_main$
|
|
8345
|
+
return openBlock(), createBlock(_sfc_main$x, {
|
|
8285
8346
|
data: {
|
|
8286
8347
|
type: "button",
|
|
8287
8348
|
text: item.text,
|
|
@@ -8307,7 +8368,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
|
|
|
8307
8368
|
]),
|
|
8308
8369
|
_: 3
|
|
8309
8370
|
}),
|
|
8310
|
-
createVNode(_sfc_main$
|
|
8371
|
+
createVNode(_sfc_main$j, {
|
|
8311
8372
|
ref_key: "editDialog",
|
|
8312
8373
|
ref: editDialog,
|
|
8313
8374
|
disabled: !unref(editable),
|
|
@@ -8451,7 +8512,7 @@ const _sfc_main$g = /* @__PURE__ */ defineComponent({
|
|
|
8451
8512
|
renderSlot(_ctx.$slots, "title"),
|
|
8452
8513
|
createElementVNode("div", null, [
|
|
8453
8514
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menuData, (item, index) => {
|
|
8454
|
-
return openBlock(), createBlock(_sfc_main$
|
|
8515
|
+
return openBlock(), createBlock(_sfc_main$x, {
|
|
8455
8516
|
"event-type": "mouseup",
|
|
8456
8517
|
ref_for: true,
|
|
8457
8518
|
ref_key: "buttons",
|
|
@@ -9227,8 +9288,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
9227
9288
|
return openBlock(), createBlock(unref(TMagicScrollbar), { class: "m-editor-layer-panel" }, {
|
|
9228
9289
|
default: withCtx(() => [
|
|
9229
9290
|
renderSlot(_ctx.$slots, "layer-panel-header"),
|
|
9230
|
-
createVNode(_sfc_main$
|
|
9231
|
-
page.value && unref(nodeStatusMap) ? (openBlock(), createBlock(_sfc_main$
|
|
9291
|
+
createVNode(_sfc_main$o, { onSearch: unref(filterTextChangeHandler) }, null, 8, ["onSearch"]),
|
|
9292
|
+
page.value && unref(nodeStatusMap) ? (openBlock(), createBlock(_sfc_main$m, {
|
|
9232
9293
|
key: 0,
|
|
9233
9294
|
tabindex: "-1",
|
|
9234
9295
|
ref_key: "tree",
|
|
@@ -9354,7 +9415,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
|
9354
9415
|
"model-value": collapseValue.value
|
|
9355
9416
|
}, {
|
|
9356
9417
|
default: withCtx(() => [
|
|
9357
|
-
createVNode(_sfc_main$
|
|
9418
|
+
createVNode(_sfc_main$o, { onSearch: filterTextChangeHandler }),
|
|
9358
9419
|
(openBlock(true), createElementBlock(Fragment, null, renderList(list.value, (group, index) => {
|
|
9359
9420
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
9360
9421
|
group.items && group.items.length ? (openBlock(), createBlock(unref(TMagicCollapseItem), {
|
|
@@ -9427,7 +9488,11 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9427
9488
|
},
|
|
9428
9489
|
__name: "Sidebar",
|
|
9429
9490
|
props: {
|
|
9430
|
-
data: { default: () => ({
|
|
9491
|
+
data: { default: () => ({
|
|
9492
|
+
type: "tabs",
|
|
9493
|
+
status: "组件",
|
|
9494
|
+
items: [SideItemKey.COMPONENT_LIST, SideItemKey.LAYER, SideItemKey.CODE_BLOCK, SideItemKey.DATA_SOURCE]
|
|
9495
|
+
}) },
|
|
9431
9496
|
layerContentMenu: {},
|
|
9432
9497
|
customContentMenu: {}
|
|
9433
9498
|
},
|
|
@@ -9439,8 +9504,8 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9439
9504
|
const activeTabName = ref(props.data?.status);
|
|
9440
9505
|
const getItemConfig = (data) => {
|
|
9441
9506
|
const map = {
|
|
9442
|
-
|
|
9443
|
-
$key:
|
|
9507
|
+
[SideItemKey.COMPONENT_LIST]: {
|
|
9508
|
+
$key: SideItemKey.COMPONENT_LIST,
|
|
9444
9509
|
type: "component",
|
|
9445
9510
|
icon: Goods,
|
|
9446
9511
|
text: "组件",
|
|
@@ -9459,16 +9524,16 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9459
9524
|
component: _sfc_main$c,
|
|
9460
9525
|
slots: {}
|
|
9461
9526
|
},
|
|
9462
|
-
|
|
9527
|
+
[SideItemKey.CODE_BLOCK]: {
|
|
9463
9528
|
$key: "code-block",
|
|
9464
9529
|
type: "component",
|
|
9465
9530
|
icon: EditPen,
|
|
9466
9531
|
text: "代码编辑",
|
|
9467
|
-
component: _sfc_main$
|
|
9532
|
+
component: _sfc_main$k,
|
|
9468
9533
|
slots: {}
|
|
9469
9534
|
},
|
|
9470
|
-
|
|
9471
|
-
$key:
|
|
9535
|
+
[SideItemKey.DATA_SOURCE]: {
|
|
9536
|
+
$key: SideItemKey.DATA_SOURCE,
|
|
9472
9537
|
type: "component",
|
|
9473
9538
|
icon: Coin,
|
|
9474
9539
|
text: "数据源",
|
|
@@ -9479,6 +9544,15 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9479
9544
|
return typeof data === "string" ? map[data] : data;
|
|
9480
9545
|
};
|
|
9481
9546
|
const sideBarItems = computed(() => props.data.items.map((item) => getItemConfig(item)));
|
|
9547
|
+
watch(
|
|
9548
|
+
sideBarItems,
|
|
9549
|
+
(items) => {
|
|
9550
|
+
services?.uiService.set("sideBarItems", items);
|
|
9551
|
+
},
|
|
9552
|
+
{
|
|
9553
|
+
immediate: true
|
|
9554
|
+
}
|
|
9555
|
+
);
|
|
9482
9556
|
watch(
|
|
9483
9557
|
() => props.data.status,
|
|
9484
9558
|
(status) => {
|
|
@@ -9517,7 +9591,8 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9517
9591
|
class: normalizeClass(["m-editor-sidebar-header-item", { "is-active": activeTabName.value === config.text }]),
|
|
9518
9592
|
draggable: "true",
|
|
9519
9593
|
key: config.$key ?? index,
|
|
9520
|
-
|
|
9594
|
+
style: normalizeStyle(config.tabStyle || {}),
|
|
9595
|
+
onClick: ($event) => activeTabName.value = config.text || config.$key || `${index}`,
|
|
9521
9596
|
onDragstart: _cache[0] || (_cache[0] = //@ts-ignore
|
|
9522
9597
|
(...args) => unref(dragstartHandler) && unref(dragstartHandler)(...args)),
|
|
9523
9598
|
onDragend: ($event) => unref(dragendHandler)(config.$key, $event)
|
|
@@ -9527,7 +9602,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9527
9602
|
icon: config.icon
|
|
9528
9603
|
}, null, 8, ["icon"])) : createCommentVNode("", true),
|
|
9529
9604
|
config.text ? (openBlock(), createElementBlock("div", _hoisted_4$1, toDisplayString(config.text), 1)) : createCommentVNode("", true)
|
|
9530
|
-
],
|
|
9605
|
+
], 46, _hoisted_3$1)), [
|
|
9531
9606
|
[vShow, !unref(floatBoxStates)[config.$key]?.status]
|
|
9532
9607
|
]);
|
|
9533
9608
|
}), 128))
|
|
@@ -9648,14 +9723,14 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
|
9648
9723
|
} : void 0
|
|
9649
9724
|
]), 1040)) : createCommentVNode("", true)
|
|
9650
9725
|
])), [
|
|
9651
|
-
[vShow,
|
|
9726
|
+
[vShow, [config.text, config.$key, `${index}`].includes(activeTabName.value)]
|
|
9652
9727
|
]);
|
|
9653
9728
|
}), 128))
|
|
9654
9729
|
])) : createCommentVNode("", true),
|
|
9655
9730
|
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
9656
9731
|
(openBlock(true), createElementBlock(Fragment, null, renderList(sideBarItems.value, (config, index) => {
|
|
9657
9732
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
9658
|
-
unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(_sfc_main$
|
|
9733
|
+
unref(floatBoxStates)[config.$key]?.status ? (openBlock(), createBlock(_sfc_main$N, {
|
|
9659
9734
|
key: config.$key ?? index,
|
|
9660
9735
|
visible: unref(floatBoxStates)[config.$key].status,
|
|
9661
9736
|
"onUpdate:visible": ($event) => unref(floatBoxStates)[config.$key].status = $event,
|
|
@@ -10088,7 +10163,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
10088
10163
|
]),
|
|
10089
10164
|
_: 1
|
|
10090
10165
|
})) : createCommentVNode("", true),
|
|
10091
|
-
page.value && unref(nodeStatusMap) && buttonVisible.value ? (openBlock(), createBlock(_sfc_main$
|
|
10166
|
+
page.value && unref(nodeStatusMap) && buttonVisible.value ? (openBlock(), createBlock(_sfc_main$N, {
|
|
10092
10167
|
key: 1,
|
|
10093
10168
|
ref_key: "box",
|
|
10094
10169
|
ref: box,
|
|
@@ -10098,7 +10173,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
10098
10173
|
position: menuPosition.value
|
|
10099
10174
|
}, {
|
|
10100
10175
|
body: withCtx(() => [
|
|
10101
|
-
createVNode(_sfc_main$
|
|
10176
|
+
createVNode(_sfc_main$m, {
|
|
10102
10177
|
class: "m-editor-node-list-menu magic-editor-layer-tree",
|
|
10103
10178
|
data: nodeData.value,
|
|
10104
10179
|
"node-status-map": unref(nodeStatusMap),
|
|
@@ -11248,6 +11323,7 @@ const defaultEditorProps = {
|
|
|
11248
11323
|
containerHighlightClassName: CONTAINER_HIGHLIGHT_CLASS_NAME,
|
|
11249
11324
|
containerHighlightDuration: 800,
|
|
11250
11325
|
containerHighlightType: ContainerHighlightType.DEFAULT,
|
|
11326
|
+
disabledShowSrc: false,
|
|
11251
11327
|
componentGroupList: () => [],
|
|
11252
11328
|
datasourceList: () => [],
|
|
11253
11329
|
menu: () => ({ left: [], right: [] }),
|
|
@@ -11629,6 +11705,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
11629
11705
|
disabledMultiSelect: { type: Boolean },
|
|
11630
11706
|
disabledPageFragment: { type: Boolean },
|
|
11631
11707
|
disabledStageOverlay: { type: Boolean },
|
|
11708
|
+
disabledShowSrc: { type: Boolean },
|
|
11632
11709
|
render: { type: Function },
|
|
11633
11710
|
updateDragEl: { type: Function },
|
|
11634
11711
|
canSelect: { type: Function },
|
|
@@ -11678,15 +11755,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
11678
11755
|
provide("services", services);
|
|
11679
11756
|
provide("codeOptions", props.codeOptions);
|
|
11680
11757
|
provide("stageOptions", stageOptions);
|
|
11758
|
+
provide("eventBus", new EventEmitter());
|
|
11681
11759
|
__expose(services);
|
|
11682
11760
|
return (_ctx, _cache) => {
|
|
11683
|
-
return openBlock(), createBlock(_sfc_main$
|
|
11761
|
+
return openBlock(), createBlock(_sfc_main$r, { "disabled-page-fragment": _ctx.disabledPageFragment }, {
|
|
11684
11762
|
header: withCtx(() => [
|
|
11685
11763
|
renderSlot(_ctx.$slots, "header")
|
|
11686
11764
|
]),
|
|
11687
11765
|
nav: withCtx(() => [
|
|
11688
11766
|
renderSlot(_ctx.$slots, "nav", { editorService: unref(editorService) }, () => [
|
|
11689
|
-
createVNode(_sfc_main$
|
|
11767
|
+
createVNode(_sfc_main$q, { data: _ctx.menu }, null, 8, ["data"])
|
|
11690
11768
|
])
|
|
11691
11769
|
]),
|
|
11692
11770
|
"content-before": withCtx(() => [
|
|
@@ -11761,8 +11839,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
11761
11839
|
]),
|
|
11762
11840
|
"props-panel": withCtx(() => [
|
|
11763
11841
|
renderSlot(_ctx.$slots, "props-panel", {}, () => [
|
|
11764
|
-
createVNode(_sfc_main$
|
|
11842
|
+
createVNode(_sfc_main$p, {
|
|
11765
11843
|
"extend-state": _ctx.extendFormState,
|
|
11844
|
+
"disabled-show-src": _ctx.disabledShowSrc,
|
|
11766
11845
|
onMounted: _cache[0] || (_cache[0] = (instance) => _ctx.$emit("props-panel-mounted", instance)),
|
|
11767
11846
|
onFormError: _cache[1] || (_cache[1] = (e) => _ctx.$emit("props-form-error", e)),
|
|
11768
11847
|
onSubmitError: _cache[2] || (_cache[2] = (e) => _ctx.$emit("props-submit-error", e))
|
|
@@ -11771,7 +11850,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
11771
11850
|
renderSlot(_ctx.$slots, "props-panel-header")
|
|
11772
11851
|
]),
|
|
11773
11852
|
_: 3
|
|
11774
|
-
}, 8, ["extend-state"])
|
|
11853
|
+
}, 8, ["extend-state", "disabled-show-src"])
|
|
11775
11854
|
])
|
|
11776
11855
|
]),
|
|
11777
11856
|
empty: withCtx(() => [
|
|
@@ -11809,22 +11888,22 @@ const index = {
|
|
|
11809
11888
|
setConfig(option);
|
|
11810
11889
|
app.component(`${_sfc_main.name || "MEditor"}`, _sfc_main);
|
|
11811
11890
|
app.component("magic-code-editor", _sfc_main$T);
|
|
11812
|
-
app.component("m-fields-ui-select", _sfc_main$
|
|
11891
|
+
app.component("m-fields-ui-select", _sfc_main$A);
|
|
11813
11892
|
app.component("m-fields-code-link", _sfc_main$R);
|
|
11814
11893
|
app.component("m-fields-vs-code", _sfc_main$S);
|
|
11815
11894
|
app.component("m-fields-code-select", _sfc_main$Q);
|
|
11816
|
-
app.component("m-fields-code-select-col", _sfc_main$
|
|
11817
|
-
app.component("m-fields-event-select", _sfc_main$
|
|
11818
|
-
app.component("m-fields-data-source-fields", _sfc_main$
|
|
11819
|
-
app.component("m-fields-data-source-mocks", _sfc_main$
|
|
11820
|
-
app.component("m-fields-key-value", _sfc_main$
|
|
11821
|
-
app.component("m-fields-data-source-input", _sfc_main$
|
|
11822
|
-
app.component("m-fields-data-source-select", _sfc_main$
|
|
11823
|
-
app.component("m-fields-data-source-methods", _sfc_main$
|
|
11824
|
-
app.component("m-fields-data-source-method-select", _sfc_main$
|
|
11825
|
-
app.component("m-fields-data-source-field-select", _sfc_main$
|
|
11826
|
-
app.component("m-fields-page-fragment-select", _sfc_main$
|
|
11895
|
+
app.component("m-fields-code-select-col", _sfc_main$O);
|
|
11896
|
+
app.component("m-fields-event-select", _sfc_main$E);
|
|
11897
|
+
app.component("m-fields-data-source-fields", _sfc_main$M);
|
|
11898
|
+
app.component("m-fields-data-source-mocks", _sfc_main$G);
|
|
11899
|
+
app.component("m-fields-key-value", _sfc_main$C);
|
|
11900
|
+
app.component("m-fields-data-source-input", _sfc_main$K);
|
|
11901
|
+
app.component("m-fields-data-source-select", _sfc_main$F);
|
|
11902
|
+
app.component("m-fields-data-source-methods", _sfc_main$I);
|
|
11903
|
+
app.component("m-fields-data-source-method-select", _sfc_main$H);
|
|
11904
|
+
app.component("m-fields-data-source-field-select", _sfc_main$L);
|
|
11905
|
+
app.component("m-fields-page-fragment-select", _sfc_main$B);
|
|
11827
11906
|
}
|
|
11828
11907
|
};
|
|
11829
11908
|
|
|
11830
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$
|
|
11909
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$J as CodeBlockEditor, _sfc_main$l as CodeBlockList, _sfc_main$k as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$Q as CodeSelect, _sfc_main$O as CodeSelectCol, ColumnLayout, _sfc_main$b as ComponentListPanel, _sfc_main$g as ContentMenu, _sfc_main$j as DataSourceConfigPanel, _sfc_main$L as DataSourceFieldSelect, _sfc_main$M as DataSourceFields, _sfc_main$K as DataSourceInput, _sfc_main$H as DataSourceMethodSelect, _sfc_main$I as DataSourceMethods, _sfc_main$G as DataSourceMocks, _sfc_main$F as DataSourceSelect, DragType, _sfc_main$E as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$U as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$c as LayerPanel, Layout, _sfc_main$y as LayoutContainer, _sfc_main$B as PageFragmentSelect, _sfc_main$p as PropsPanel, _sfc_main$z as Resizer, SideItemKey, _sfc_main$y as SplitView, _sfc_main$T as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$x as ToolButton, UI_SELECT_MODE_EVENT_NAME, V_GUIDE_LINE_STORAGE_KEY, advancedTabConfig, beforePaste, change2Fixed, codeBlockService, dataSourceService, debug, index as default, depService, displayTabConfig, editorService, error, eventTabConfig, eventsService, fillConfig, fixNodeLeft, fixNodePosition, generatePageName, generatePageNameByApp, getAddParent, getConfig, getDefaultConfig, getDisplayField, getFormConfig, getFormValue, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageFragmentList, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setChildrenLayout, setConfig, setLayout, stageOverlayService, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useEditorContentHeight, useFloatBox, useStage, useWindowRect, warn };
|