@tmagic/editor 1.3.0-beta.5 → 1.3.0-beta.6
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/tmagic-editor.js +121 -39
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +121 -38
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +11 -10
- package/src/fields/KeyValue.vue +1 -0
- package/src/layouts/CodeEditor.vue +1 -0
- package/src/services/dataSource.ts +2 -2
- package/src/utils/data-source/index.ts +117 -34
- package/types/layouts/CodeEditor.vue.d.ts +4 -1
- package/types/utils/data-source/index.d.ts +1 -0
package/dist/tmagic-editor.js
CHANGED
|
@@ -29,7 +29,7 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
|
|
|
29
29
|
},
|
|
30
30
|
__name: "CodeEditor",
|
|
31
31
|
props: {
|
|
32
|
-
initValues: {},
|
|
32
|
+
initValues: { default: "" },
|
|
33
33
|
modifiedValues: {},
|
|
34
34
|
type: {},
|
|
35
35
|
language: { default: "javascript" },
|
|
@@ -777,47 +777,72 @@ const fillConfig$1 = (config) => [
|
|
|
777
777
|
...BaseFormConfig(),
|
|
778
778
|
...config,
|
|
779
779
|
{
|
|
780
|
-
type: "
|
|
781
|
-
title: "数据定义",
|
|
780
|
+
type: "tab",
|
|
782
781
|
items: [
|
|
783
782
|
{
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
items: [
|
|
783
|
+
title: "数据定义",
|
|
784
|
+
items: [
|
|
785
|
+
{
|
|
786
|
+
name: "fields",
|
|
787
|
+
type: "data-source-fields",
|
|
788
|
+
defaultValue: () => []
|
|
789
|
+
}
|
|
790
|
+
]
|
|
791
|
+
},
|
|
794
792
|
{
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
display: false,
|
|
805
|
-
items: [
|
|
793
|
+
title: "方法定义",
|
|
794
|
+
items: [
|
|
795
|
+
{
|
|
796
|
+
name: "methods",
|
|
797
|
+
type: "data-source-methods",
|
|
798
|
+
defaultValue: () => []
|
|
799
|
+
}
|
|
800
|
+
]
|
|
801
|
+
},
|
|
806
802
|
{
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
803
|
+
title: "事件配置",
|
|
804
|
+
display: false,
|
|
805
|
+
items: [
|
|
806
|
+
{
|
|
807
|
+
name: "events",
|
|
808
|
+
src: "datasource",
|
|
809
|
+
type: "event-select"
|
|
810
|
+
}
|
|
811
|
+
]
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
title: "mock数据",
|
|
815
|
+
items: [
|
|
816
|
+
{
|
|
817
|
+
name: "mocks",
|
|
818
|
+
type: "data-source-mocks",
|
|
819
|
+
defaultValue: () => []
|
|
820
|
+
}
|
|
821
|
+
]
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
title: "请求参数裁剪",
|
|
825
|
+
display: (formState, { model }) => model.type === "http",
|
|
826
|
+
items: [
|
|
827
|
+
{
|
|
828
|
+
name: "beforeRequest",
|
|
829
|
+
type: "vs-code",
|
|
830
|
+
parse: true,
|
|
831
|
+
height: "600px"
|
|
832
|
+
}
|
|
833
|
+
]
|
|
834
|
+
},
|
|
817
835
|
{
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
836
|
+
title: "响应数据裁剪",
|
|
837
|
+
display: (formState, { model }) => model.type === "http",
|
|
838
|
+
items: [
|
|
839
|
+
{
|
|
840
|
+
name: "afterResponse",
|
|
841
|
+
type: "vs-code",
|
|
842
|
+
parse: true,
|
|
843
|
+
height: "600px"
|
|
844
|
+
}
|
|
845
|
+
]
|
|
821
846
|
}
|
|
822
847
|
]
|
|
823
848
|
}
|
|
@@ -832,6 +857,62 @@ const getFormConfig = (type, configs) => {
|
|
|
832
857
|
return fillConfig$1(configs[type] || []);
|
|
833
858
|
}
|
|
834
859
|
};
|
|
860
|
+
const getFormValue = (type, values) => {
|
|
861
|
+
if (type !== "http") {
|
|
862
|
+
return values;
|
|
863
|
+
}
|
|
864
|
+
return {
|
|
865
|
+
beforeRequest: `(options, context) => {
|
|
866
|
+
/**
|
|
867
|
+
* 用户可以直接编写函数,在原始接口调用之前,会运行该函数,将这个函数的返回值作为该数据源接口的入参
|
|
868
|
+
*
|
|
869
|
+
* options: HttpOptions
|
|
870
|
+
*
|
|
871
|
+
* interface HttpOptions {
|
|
872
|
+
* // 请求链接
|
|
873
|
+
* url: string;
|
|
874
|
+
* // query参数
|
|
875
|
+
* params?: Record<string, string>;
|
|
876
|
+
* // body数据
|
|
877
|
+
* data?: Record<string, any>;
|
|
878
|
+
* // 请求头
|
|
879
|
+
* headers?: Record<string, string>;
|
|
880
|
+
* // 请求方法 GET/POST
|
|
881
|
+
* method?: Method;
|
|
882
|
+
* }
|
|
883
|
+
*
|
|
884
|
+
* context:上下文对象
|
|
885
|
+
*
|
|
886
|
+
* interface Content {
|
|
887
|
+
* app: AppCore;
|
|
888
|
+
* dataSource: HttpDataSource;
|
|
889
|
+
* }
|
|
890
|
+
*
|
|
891
|
+
* return: HttpOptions
|
|
892
|
+
*/
|
|
893
|
+
|
|
894
|
+
// 此处的返回值会作为这个接口的入参
|
|
895
|
+
return options;
|
|
896
|
+
}`,
|
|
897
|
+
afterResponse: `(response, context) => {
|
|
898
|
+
/**
|
|
899
|
+
* 用户可以直接编写函数,在原始接口返回之后,会运行该函数,将这个函数的返回值作为该数据源接口的返回
|
|
900
|
+
|
|
901
|
+
* context:上下文对象
|
|
902
|
+
*
|
|
903
|
+
* interface Content {
|
|
904
|
+
* app: AppCore;
|
|
905
|
+
* dataSource: HttpDataSource;
|
|
906
|
+
* }
|
|
907
|
+
*
|
|
908
|
+
*/
|
|
909
|
+
|
|
910
|
+
// 此处的返回值会作为这个接口的返回值
|
|
911
|
+
return response;
|
|
912
|
+
}`,
|
|
913
|
+
...values
|
|
914
|
+
};
|
|
915
|
+
};
|
|
835
916
|
const getDisplayField = (dataSources, key) => {
|
|
836
917
|
const displayState = [];
|
|
837
918
|
const matches = key.matchAll(/\$\{([\s\S]+?)\}/g);
|
|
@@ -1017,7 +1098,7 @@ class DataSource extends BaseService {
|
|
|
1017
1098
|
this.get("configs")[type] = config;
|
|
1018
1099
|
}
|
|
1019
1100
|
getFormValue(type = "base") {
|
|
1020
|
-
return this.get("values")[type];
|
|
1101
|
+
return getFormValue(type, this.get("values")[type]);
|
|
1021
1102
|
}
|
|
1022
1103
|
setFormValue(type, value) {
|
|
1023
1104
|
this.get("values")[type] = value;
|
|
@@ -4616,6 +4697,7 @@ const _sfc_main$C = /* @__PURE__ */ defineComponent({
|
|
|
4616
4697
|
};
|
|
4617
4698
|
const deleteHandler = (index) => {
|
|
4618
4699
|
records.value.splice(index, 1);
|
|
4700
|
+
emit("change", getValue());
|
|
4619
4701
|
};
|
|
4620
4702
|
return (_ctx, _cache) => {
|
|
4621
4703
|
return openBlock(), createElementBlock("div", _hoisted_1$m, [
|
|
@@ -10305,5 +10387,5 @@ const index = {
|
|
|
10305
10387
|
}
|
|
10306
10388
|
};
|
|
10307
10389
|
|
|
10308
|
-
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$O as CodeBlockEditor, _sfc_main$q as CodeBlockList, _sfc_main$p as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$P as CodeSelect, _sfc_main$L as CodeSelectCol, ColumnLayout, _sfc_main$f as ComponentListPanel, _sfc_main$l as ContentMenu, _sfc_main$J as DataSourceFieldSelect, _sfc_main$K as DataSourceFields, _sfc_main$I as DataSourceInput, _sfc_main$G as DataSourceMethodSelect, _sfc_main$H as DataSourceMethods, _sfc_main$F as DataSourceMocks, _sfc_main$E as DataSourceSelect, DepTargetType, DragType, _sfc_main$D as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$M as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$g as LayerPanel, Layout, _sfc_main$z as LayoutContainer, _sfc_main$u as PropsPanel, _sfc_main$A as Resizer, _sfc_main$z as SplitView, _sfc_main$S as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$w 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, getGuideLineFromCache, getInitPositionStyle, getNodeIndex, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useStage, warn };
|
|
10390
|
+
export { CODE_DRAFT_STORAGE_KEY, COPY_STORAGE_KEY, _sfc_main$O as CodeBlockEditor, _sfc_main$q as CodeBlockList, _sfc_main$p as CodeBlockListPanel, CodeDeleteErrorType, _sfc_main$P as CodeSelect, _sfc_main$L as CodeSelectCol, ColumnLayout, _sfc_main$f as ComponentListPanel, _sfc_main$l as ContentMenu, _sfc_main$J as DataSourceFieldSelect, _sfc_main$K as DataSourceFields, _sfc_main$I as DataSourceInput, _sfc_main$G as DataSourceMethodSelect, _sfc_main$H as DataSourceMethods, _sfc_main$F as DataSourceMocks, _sfc_main$E as DataSourceSelect, DepTargetType, DragType, _sfc_main$D as EventSelect, Fixed2Other, H_GUIDE_LINE_STORAGE_KEY, _sfc_main$M as Icon, KeyBindingCommand, _sfc_main$C as KeyValue, Keys, LayerOffset, _sfc_main$g as LayerPanel, Layout, _sfc_main$z as LayoutContainer, _sfc_main$u as PropsPanel, _sfc_main$A as Resizer, _sfc_main$z as SplitView, _sfc_main$S as TMagicCodeEditor, _sfc_main as TMagicEditor, _sfc_main$w 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, getPageList, getPageNameList, getPositionInContainer, getRelativeStyle, historyService, info, isFixed, log, propsService, serializeConfig, setConfig, setLayout, storageService, styleTabConfig, traverseNode, uiService, useCodeBlockEdit, useDataSourceMethod, useStage, warn };
|
|
10309
10391
|
//# sourceMappingURL=tmagic-editor.js.map
|