@tmagic/editor 1.5.0-beta.14 → 1.5.0-beta.16
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 +61 -6
- package/dist/tmagic-editor.js +507 -242
- package/dist/tmagic-editor.umd.cjs +507 -243
- package/package.json +12 -10
- package/src/components/CodeBlockEditor.vue +11 -5
- package/src/components/CodeParams.vue +3 -3
- package/src/fields/Code.vue +1 -2
- package/src/fields/CodeSelect.vue +13 -11
- package/src/fields/CodeSelectCol.vue +32 -5
- package/src/fields/CondOpSelect.vue +5 -2
- package/src/fields/DataSourceFields.vue +31 -12
- package/src/fields/DataSourceMethods.vue +72 -14
- package/src/fields/DisplayConds.vue +8 -3
- package/src/fields/EventSelect.vue +25 -8
- package/src/fields/KeyValue.vue +15 -10
- package/src/hooks/index.ts +0 -1
- package/src/hooks/use-code-block-edit.ts +1 -1
- package/src/hooks/use-data-source-edit.ts +3 -2
- package/src/initService.ts +105 -25
- package/src/layouts/Framework.vue +0 -3
- package/src/layouts/PropsPanel.vue +3 -3
- package/src/layouts/page-bar/PageBar.vue +46 -3
- package/src/layouts/page-bar/PageBarScrollContainer.vue +49 -24
- package/src/layouts/page-bar/PageList.vue +4 -2
- package/src/layouts/sidebar/Sidebar.vue +3 -0
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +6 -1
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +7 -5
- package/src/layouts/sidebar/data-source/DataSourceList.vue +6 -1
- package/src/layouts/workspace/Workspace.vue +5 -2
- package/src/layouts/workspace/viewer/Stage.vue +12 -5
- package/src/services/dataSource.ts +12 -5
- package/src/services/dep.ts +49 -11
- package/src/services/editor.ts +26 -11
- package/src/theme/page-bar.scss +24 -9
- package/src/theme/search-input.scss +1 -0
- package/src/utils/data-source/formConfigs/http.ts +2 -0
- package/src/utils/data-source/index.ts +2 -2
- package/src/utils/editor.ts +78 -2
- package/src/utils/idle-task.ts +34 -3
- package/src/utils/props.ts +3 -3
- package/types/index.d.ts +805 -1170
- package/src/hooks/use-data-source-method.ts +0 -100
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tmagic/design'), require('@tmagic/form'), require('@tmagic/table'), require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('serialize-javascript'), require('emmet-monaco-es'), require('monaco-editor'), require('@tmagic/core'), require('@tmagic/utils'), require('moveable'), require('@tmagic/stage'), require('events'), require('gesto'), require('sortablejs'), require('keycon')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tmagic/design', '@tmagic/form', '@tmagic/table', 'vue', '@element-plus/icons-vue', 'lodash-es', 'serialize-javascript', 'emmet-monaco-es', 'monaco-editor', '@tmagic/core', '@tmagic/utils', 'moveable', '@tmagic/stage', 'events', 'gesto', 'sortablejs', 'keycon'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.designPlugin, global.formPlugin, global.tablePlugin, global.Vue, global.iconsVue, global.lodashEs, global.serialize, global.emmetMonacoEs, global.monaco, global.core, global.utils, global.VanillaMoveable, global.StageCore, global.events, global.Gesto, global.Sortable, global.KeyController));
|
|
5
|
-
})(this, (function (exports, designPlugin, formPlugin, tablePlugin, vue, iconsVue, lodashEs, serialize, emmetMonacoEs, monaco, core, utils, VanillaMoveable, StageCore, events, Gesto, Sortable, KeyController) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tmagic/design'), require('@tmagic/form'), require('@tmagic/table'), require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('serialize-javascript'), require('emmet-monaco-es'), require('monaco-editor'), require('@tmagic/core'), require('@tmagic/utils'), require('moveable'), require('@tmagic/stage'), require('events'), require('gesto'), require('deep-object-diff'), require('sortablejs'), require('keycon')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tmagic/design', '@tmagic/form', '@tmagic/table', 'vue', '@element-plus/icons-vue', 'lodash-es', 'serialize-javascript', 'emmet-monaco-es', 'monaco-editor', '@tmagic/core', '@tmagic/utils', 'moveable', '@tmagic/stage', 'events', 'gesto', 'deep-object-diff', 'sortablejs', 'keycon'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicEditor = {}, global.designPlugin, global.formPlugin, global.tablePlugin, global.Vue, global.iconsVue, global.lodashEs, global.serialize, global.emmetMonacoEs, global.monaco, global.core, global.utils, global.VanillaMoveable, global.StageCore, global.events, global.Gesto, global.deepObjectDiff, global.Sortable, global.KeyController));
|
|
5
|
+
})(this, (function (exports, designPlugin, formPlugin, tablePlugin, vue, iconsVue, lodashEs, serialize, emmetMonacoEs, monaco, core, utils, VanillaMoveable, StageCore, events, Gesto, deepObjectDiff, Sortable, KeyController) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
|
@@ -287,9 +287,7 @@
|
|
|
287
287
|
emits: ["change"],
|
|
288
288
|
setup(__props, { emit: __emit }) {
|
|
289
289
|
const emit = __emit;
|
|
290
|
-
const props = __props;
|
|
291
290
|
const save = (v) => {
|
|
292
|
-
props.model[props.name] = v;
|
|
293
291
|
emit("change", v);
|
|
294
292
|
};
|
|
295
293
|
return (_ctx, _cache) => {
|
|
@@ -439,11 +437,13 @@
|
|
|
439
437
|
{ value: core.HookCodeType.DATA_SOURCE_METHOD, text: "数据源方法" }
|
|
440
438
|
],
|
|
441
439
|
defaultValue: "code",
|
|
442
|
-
onChange: (mForm, v, { model }) => {
|
|
440
|
+
onChange: (mForm, v, { model, prop, changeRecords }) => {
|
|
443
441
|
if (v === core.HookCodeType.DATA_SOURCE_METHOD) {
|
|
444
442
|
model.codeId = [];
|
|
443
|
+
changeRecords.push({ propPath: prop.replace("codeType", "codeId"), value: [] });
|
|
445
444
|
} else {
|
|
446
445
|
model.codeId = "";
|
|
446
|
+
changeRecords.push({ propPath: prop.replace("codeType", "codeId"), value: "" });
|
|
447
447
|
}
|
|
448
448
|
return v;
|
|
449
449
|
}
|
|
@@ -482,9 +482,7 @@
|
|
|
482
482
|
immediate: true
|
|
483
483
|
}
|
|
484
484
|
);
|
|
485
|
-
const changeHandler =
|
|
486
|
-
emit("change", props.model[props.name]);
|
|
487
|
-
};
|
|
485
|
+
const changeHandler = (v, eventData) => emit("change", v, eventData);
|
|
488
486
|
return (_ctx, _cache) => {
|
|
489
487
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
490
488
|
class: vue.normalizeClass(["m-fields-code-select", _ctx.config.className])
|
|
@@ -566,7 +564,7 @@
|
|
|
566
564
|
fieldConfig: {
|
|
567
565
|
type: "text"
|
|
568
566
|
},
|
|
569
|
-
disabled: (
|
|
567
|
+
disabled: (_vm, { model }) => model.position === "fixed" && model._magic_position === "fixedBottom"
|
|
570
568
|
},
|
|
571
569
|
{
|
|
572
570
|
type: "data-source-field-select",
|
|
@@ -587,7 +585,7 @@
|
|
|
587
585
|
fieldConfig: {
|
|
588
586
|
type: "text"
|
|
589
587
|
},
|
|
590
|
-
disabled: (
|
|
588
|
+
disabled: (_vm, { model }) => model.position === "fixed" && model._magic_position === "fixedTop"
|
|
591
589
|
}
|
|
592
590
|
]
|
|
593
591
|
},
|
|
@@ -836,7 +834,7 @@
|
|
|
836
834
|
};
|
|
837
835
|
const displayTabConfig = {
|
|
838
836
|
title: "显示条件",
|
|
839
|
-
display: (
|
|
837
|
+
display: (_vm, { model }) => model.type !== "page",
|
|
840
838
|
items: [
|
|
841
839
|
{
|
|
842
840
|
type: "display-conds",
|
|
@@ -1160,6 +1158,55 @@
|
|
|
1160
1158
|
}
|
|
1161
1159
|
}
|
|
1162
1160
|
};
|
|
1161
|
+
const isIncludeDataSourceByDiffAddResult = (diffResult) => {
|
|
1162
|
+
for (const value of Object.values(diffResult)) {
|
|
1163
|
+
const result = utils.isValueIncludeDataSource(value);
|
|
1164
|
+
if (result) {
|
|
1165
|
+
return true;
|
|
1166
|
+
}
|
|
1167
|
+
if (lodashEs.isObject(value)) {
|
|
1168
|
+
return isIncludeDataSourceByDiffAddResult(value);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
return false;
|
|
1172
|
+
};
|
|
1173
|
+
const isIncludeDataSourceByDiffUpdatedResult = (diffResult, oldNode) => {
|
|
1174
|
+
for (const [key, value] of Object.entries(diffResult)) {
|
|
1175
|
+
if (utils.isValueIncludeDataSource(value)) {
|
|
1176
|
+
return true;
|
|
1177
|
+
}
|
|
1178
|
+
if (utils.isValueIncludeDataSource(oldNode[key])) {
|
|
1179
|
+
return true;
|
|
1180
|
+
}
|
|
1181
|
+
if (lodashEs.isObject(value)) {
|
|
1182
|
+
return isIncludeDataSourceByDiffUpdatedResult(value, oldNode[key]);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return false;
|
|
1186
|
+
};
|
|
1187
|
+
const isIncludeDataSource = (node, oldNode) => {
|
|
1188
|
+
const diffResult = deepObjectDiff.detailedDiff(oldNode, node);
|
|
1189
|
+
let isIncludeDataSource2 = false;
|
|
1190
|
+
if (diffResult.updated) {
|
|
1191
|
+
if (diffResult.updated[core.NODE_CONDS_KEY]) {
|
|
1192
|
+
return true;
|
|
1193
|
+
}
|
|
1194
|
+
isIncludeDataSource2 = isIncludeDataSourceByDiffUpdatedResult(diffResult.updated, oldNode);
|
|
1195
|
+
if (isIncludeDataSource2) return true;
|
|
1196
|
+
}
|
|
1197
|
+
if (diffResult.added) {
|
|
1198
|
+
isIncludeDataSource2 = isIncludeDataSourceByDiffAddResult(diffResult.added);
|
|
1199
|
+
if (isIncludeDataSource2) return true;
|
|
1200
|
+
}
|
|
1201
|
+
if (diffResult.deleted) {
|
|
1202
|
+
if (diffResult.deleted[core.NODE_CONDS_KEY]) {
|
|
1203
|
+
return true;
|
|
1204
|
+
}
|
|
1205
|
+
isIncludeDataSource2 = isIncludeDataSourceByDiffAddResult(diffResult.deleted);
|
|
1206
|
+
if (isIncludeDataSource2) return true;
|
|
1207
|
+
}
|
|
1208
|
+
return isIncludeDataSource2;
|
|
1209
|
+
};
|
|
1163
1210
|
|
|
1164
1211
|
const compose = (middleware, isAsync) => {
|
|
1165
1212
|
if (!Array.isArray(middleware)) throw new TypeError("Middleware 必须是一个数组!");
|
|
@@ -2112,13 +2159,13 @@
|
|
|
2112
2159
|
}
|
|
2113
2160
|
this.emit("remove", nodes);
|
|
2114
2161
|
}
|
|
2115
|
-
async doUpdate(config) {
|
|
2162
|
+
async doUpdate(config, { changeRecords = [] } = {}) {
|
|
2116
2163
|
const root = this.get("root");
|
|
2117
2164
|
if (!root) throw new Error("root为空");
|
|
2118
2165
|
if (!config?.id) throw new Error("没有配置或者配置缺少id值");
|
|
2119
2166
|
const info = this.getNodeInfo(config.id, false);
|
|
2120
2167
|
if (!info.node) throw new Error(`获取不到id为${config.id}的节点`);
|
|
2121
|
-
const node =
|
|
2168
|
+
const node = vue.toRaw(info.node);
|
|
2122
2169
|
let newConfig = await this.toggleFixedPosition(vue.toRaw(config), node, root);
|
|
2123
2170
|
newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue, key) => {
|
|
2124
2171
|
if (typeof srcValue === "undefined" && Object.hasOwn(newConfig, key)) {
|
|
@@ -2134,7 +2181,11 @@
|
|
|
2134
2181
|
if (!newConfig.type) throw new Error("配置缺少type值");
|
|
2135
2182
|
if (newConfig.type === core.NodeType.ROOT) {
|
|
2136
2183
|
this.set("root", newConfig);
|
|
2137
|
-
return
|
|
2184
|
+
return {
|
|
2185
|
+
oldNode: node,
|
|
2186
|
+
newNode: newConfig,
|
|
2187
|
+
changeRecords
|
|
2188
|
+
};
|
|
2138
2189
|
}
|
|
2139
2190
|
const { parent } = info;
|
|
2140
2191
|
if (!parent) throw new Error("获取不到父级节点");
|
|
@@ -2155,21 +2206,25 @@
|
|
|
2155
2206
|
this.set("page", newConfig);
|
|
2156
2207
|
}
|
|
2157
2208
|
this.addModifiedNodeId(newConfig.id);
|
|
2158
|
-
return
|
|
2209
|
+
return {
|
|
2210
|
+
oldNode: node,
|
|
2211
|
+
newNode: newConfig,
|
|
2212
|
+
changeRecords
|
|
2213
|
+
};
|
|
2159
2214
|
}
|
|
2160
2215
|
/**
|
|
2161
2216
|
* 更新节点
|
|
2162
2217
|
* @param config 新的节点配置,配置中需要有id信息
|
|
2163
2218
|
* @returns 更新后的节点配置
|
|
2164
2219
|
*/
|
|
2165
|
-
async update(config) {
|
|
2220
|
+
async update(config, data = {}) {
|
|
2166
2221
|
const nodes = Array.isArray(config) ? config : [config];
|
|
2167
|
-
const
|
|
2168
|
-
if (
|
|
2222
|
+
const updateData = await Promise.all(nodes.map((node) => this.doUpdate(node, data)));
|
|
2223
|
+
if (updateData[0].oldNode?.type !== core.NodeType.ROOT) {
|
|
2169
2224
|
this.pushHistoryState();
|
|
2170
2225
|
}
|
|
2171
|
-
this.emit("update",
|
|
2172
|
-
return Array.isArray(config) ?
|
|
2226
|
+
this.emit("update", updateData);
|
|
2227
|
+
return Array.isArray(config) ? updateData.map((item) => item.newNode) : updateData[0].newNode;
|
|
2173
2228
|
}
|
|
2174
2229
|
/**
|
|
2175
2230
|
* 将id为id1的组件移动到id为id2的组件位置上,例如:[1,2,3,4] -> sort(1,3) -> [2,1,3,4]
|
|
@@ -2363,7 +2418,7 @@
|
|
|
2363
2418
|
parent.items?.splice(index, 1);
|
|
2364
2419
|
await stage.remove({ id: node.id, parentId: parent.id, root: lodashEs.cloneDeep(root) });
|
|
2365
2420
|
const layout = await this.getLayout(target);
|
|
2366
|
-
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (
|
|
2421
|
+
const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (_objValue, srcValue) => {
|
|
2367
2422
|
if (Array.isArray(srcValue)) {
|
|
2368
2423
|
return srcValue;
|
|
2369
2424
|
}
|
|
@@ -2729,6 +2784,7 @@
|
|
|
2729
2784
|
name: "params",
|
|
2730
2785
|
type: "key-value",
|
|
2731
2786
|
defaultValue: {},
|
|
2787
|
+
advanced: true,
|
|
2732
2788
|
text: "参数"
|
|
2733
2789
|
},
|
|
2734
2790
|
{
|
|
@@ -2742,6 +2798,7 @@
|
|
|
2742
2798
|
name: "headers",
|
|
2743
2799
|
type: "key-value",
|
|
2744
2800
|
defaultValue: {},
|
|
2801
|
+
advanced: true,
|
|
2745
2802
|
text: "请求头"
|
|
2746
2803
|
}
|
|
2747
2804
|
]
|
|
@@ -2796,7 +2853,7 @@
|
|
|
2796
2853
|
},
|
|
2797
2854
|
{
|
|
2798
2855
|
title: "请求参数裁剪",
|
|
2799
|
-
display: (
|
|
2856
|
+
display: (_formState, { model }) => model.type === "http",
|
|
2800
2857
|
items: [
|
|
2801
2858
|
{
|
|
2802
2859
|
name: "beforeRequest",
|
|
@@ -2808,7 +2865,7 @@
|
|
|
2808
2865
|
},
|
|
2809
2866
|
{
|
|
2810
2867
|
title: "响应数据裁剪",
|
|
2811
|
-
display: (
|
|
2868
|
+
display: (_formState, { model }) => model.type === "http",
|
|
2812
2869
|
items: [
|
|
2813
2870
|
{
|
|
2814
2871
|
name: "afterResponse",
|
|
@@ -2975,6 +3032,10 @@
|
|
|
2975
3032
|
class IdleTask extends events.EventEmitter {
|
|
2976
3033
|
taskList = [];
|
|
2977
3034
|
taskHandle = null;
|
|
3035
|
+
constructor() {
|
|
3036
|
+
super();
|
|
3037
|
+
this.setMaxListeners(1e3);
|
|
3038
|
+
}
|
|
2978
3039
|
enqueueTask(taskHandler, taskData) {
|
|
2979
3040
|
this.taskList.push({
|
|
2980
3041
|
handler: taskHandler,
|
|
@@ -2984,6 +3045,9 @@
|
|
|
2984
3045
|
this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 1e4 });
|
|
2985
3046
|
}
|
|
2986
3047
|
}
|
|
3048
|
+
clearTasks() {
|
|
3049
|
+
this.taskList = [];
|
|
3050
|
+
}
|
|
2987
3051
|
on(eventName, listener) {
|
|
2988
3052
|
return super.on(eventName, listener);
|
|
2989
3053
|
}
|
|
@@ -2994,9 +3058,27 @@
|
|
|
2994
3058
|
return super.emit(eventName, ...args);
|
|
2995
3059
|
}
|
|
2996
3060
|
runTaskQueue(deadline) {
|
|
2997
|
-
while (
|
|
2998
|
-
const
|
|
2999
|
-
|
|
3061
|
+
while (deadline.timeRemaining() > 0 && this.taskList.length) {
|
|
3062
|
+
const timeRemaining = deadline.timeRemaining();
|
|
3063
|
+
let times = 0;
|
|
3064
|
+
if (timeRemaining <= 5) {
|
|
3065
|
+
times = 10;
|
|
3066
|
+
} else if (timeRemaining <= 10) {
|
|
3067
|
+
times = 100;
|
|
3068
|
+
} else if (timeRemaining <= 15) {
|
|
3069
|
+
times = 300;
|
|
3070
|
+
} else {
|
|
3071
|
+
times = 600;
|
|
3072
|
+
}
|
|
3073
|
+
for (let i = 0; i < times; i++) {
|
|
3074
|
+
const task = this.taskList.shift();
|
|
3075
|
+
if (task) {
|
|
3076
|
+
task.handler(task.data);
|
|
3077
|
+
}
|
|
3078
|
+
if (this.taskList.length === 0) {
|
|
3079
|
+
break;
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3000
3082
|
}
|
|
3001
3083
|
if (this.taskList.length) {
|
|
3002
3084
|
this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 300 });
|
|
@@ -3181,10 +3263,10 @@
|
|
|
3181
3263
|
}))
|
|
3182
3264
|
)
|
|
3183
3265
|
);
|
|
3184
|
-
const onParamsChangeHandler = async () => {
|
|
3266
|
+
const onParamsChangeHandler = async (v, eventData) => {
|
|
3185
3267
|
try {
|
|
3186
3268
|
const value = await form.value?.submitForm(true);
|
|
3187
|
-
emit("change", value);
|
|
3269
|
+
emit("change", value, eventData);
|
|
3188
3270
|
} catch (e) {
|
|
3189
3271
|
error(e);
|
|
3190
3272
|
}
|
|
@@ -3277,9 +3359,26 @@
|
|
|
3277
3359
|
return codeId;
|
|
3278
3360
|
}
|
|
3279
3361
|
};
|
|
3280
|
-
const
|
|
3362
|
+
const onCodeIdChangeHandler = (value) => {
|
|
3281
3363
|
props.model.params = value.params;
|
|
3282
|
-
emit("change", props.model
|
|
3364
|
+
emit("change", props.model, {
|
|
3365
|
+
changeRecords: [
|
|
3366
|
+
{
|
|
3367
|
+
propPath: props.prop,
|
|
3368
|
+
value: value[props.name]
|
|
3369
|
+
}
|
|
3370
|
+
]
|
|
3371
|
+
});
|
|
3372
|
+
};
|
|
3373
|
+
const onParamsChangeHandler = (value, eventData) => {
|
|
3374
|
+
props.model.params = value.params;
|
|
3375
|
+
emit("change", props.model, {
|
|
3376
|
+
...eventData,
|
|
3377
|
+
changeRecords: (eventData.changeRecords || []).map((item) => ({
|
|
3378
|
+
prop: `${props.prop.replace(props.name, "")}${item.propPath}`,
|
|
3379
|
+
value: item.value
|
|
3380
|
+
}))
|
|
3381
|
+
});
|
|
3283
3382
|
};
|
|
3284
3383
|
const editCode = (id) => {
|
|
3285
3384
|
eventBus?.emit("edit-code", id);
|
|
@@ -3292,7 +3391,7 @@
|
|
|
3292
3391
|
config: selectConfig,
|
|
3293
3392
|
model: _ctx.model,
|
|
3294
3393
|
size: _ctx.size,
|
|
3295
|
-
onChange:
|
|
3394
|
+
onChange: onCodeIdChangeHandler
|
|
3296
3395
|
}, null, 8, ["model", "size"]),
|
|
3297
3396
|
_ctx.model[_ctx.name] && hasCodeBlockSidePanel.value ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicButton), {
|
|
3298
3397
|
key: 0,
|
|
@@ -3591,7 +3690,7 @@
|
|
|
3591
3690
|
}
|
|
3592
3691
|
codeConfig.value = {
|
|
3593
3692
|
name: "",
|
|
3594
|
-
content: `({app, params}) => {
|
|
3693
|
+
content: `({app, params, flowState}) => {
|
|
3595
3694
|
// place your code here
|
|
3596
3695
|
}`,
|
|
3597
3696
|
params: []
|
|
@@ -3637,78 +3736,6 @@
|
|
|
3637
3736
|
};
|
|
3638
3737
|
};
|
|
3639
3738
|
|
|
3640
|
-
const useDataSourceMethod = () => {
|
|
3641
|
-
const codeConfig = vue.ref();
|
|
3642
|
-
const codeBlockEditor = vue.ref();
|
|
3643
|
-
const dataSource = vue.ref();
|
|
3644
|
-
const dataSourceMethod = vue.ref("");
|
|
3645
|
-
return {
|
|
3646
|
-
codeConfig,
|
|
3647
|
-
codeBlockEditor,
|
|
3648
|
-
createCode: async (model) => {
|
|
3649
|
-
codeConfig.value = {
|
|
3650
|
-
name: "",
|
|
3651
|
-
content: `({ params, dataSource, app }) => {
|
|
3652
|
-
// place your code here
|
|
3653
|
-
}`,
|
|
3654
|
-
params: []
|
|
3655
|
-
};
|
|
3656
|
-
await vue.nextTick();
|
|
3657
|
-
dataSource.value = model;
|
|
3658
|
-
dataSourceMethod.value = "";
|
|
3659
|
-
codeBlockEditor.value?.show();
|
|
3660
|
-
},
|
|
3661
|
-
editCode: async (model, methodName) => {
|
|
3662
|
-
const method = model.methods?.find((method2) => method2.name === methodName);
|
|
3663
|
-
if (!method) {
|
|
3664
|
-
designPlugin.tMagicMessage.error("获取数据源方法失败");
|
|
3665
|
-
return;
|
|
3666
|
-
}
|
|
3667
|
-
let codeContent = method.content || `({ params, dataSource, app }) => {
|
|
3668
|
-
// place your code here
|
|
3669
|
-
}`;
|
|
3670
|
-
if (typeof codeContent !== "string") {
|
|
3671
|
-
codeContent = codeContent.toString();
|
|
3672
|
-
}
|
|
3673
|
-
codeConfig.value = {
|
|
3674
|
-
...lodashEs.cloneDeep(method),
|
|
3675
|
-
content: codeContent
|
|
3676
|
-
};
|
|
3677
|
-
await vue.nextTick();
|
|
3678
|
-
dataSource.value = model;
|
|
3679
|
-
dataSourceMethod.value = methodName;
|
|
3680
|
-
codeBlockEditor.value?.show();
|
|
3681
|
-
},
|
|
3682
|
-
deleteCode: async (model, methodName) => {
|
|
3683
|
-
if (!model.methods) return;
|
|
3684
|
-
const index = model.methods.findIndex((method) => method.name === methodName);
|
|
3685
|
-
if (index === -1) {
|
|
3686
|
-
return;
|
|
3687
|
-
}
|
|
3688
|
-
model.methods.splice(index, 1);
|
|
3689
|
-
},
|
|
3690
|
-
submitCode: (values) => {
|
|
3691
|
-
if (!dataSource.value) return;
|
|
3692
|
-
if (!dataSource.value.methods) {
|
|
3693
|
-
dataSource.value.methods = [];
|
|
3694
|
-
}
|
|
3695
|
-
if (values.content) {
|
|
3696
|
-
const parseDSL = getEditorConfig("parseDSL");
|
|
3697
|
-
if (typeof values.content === "string") {
|
|
3698
|
-
values.content = parseDSL(values.content);
|
|
3699
|
-
}
|
|
3700
|
-
}
|
|
3701
|
-
if (dataSourceMethod.value) {
|
|
3702
|
-
const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
|
|
3703
|
-
dataSource.value.methods.splice(index, 1, values);
|
|
3704
|
-
} else {
|
|
3705
|
-
dataSource.value.methods.push(values);
|
|
3706
|
-
}
|
|
3707
|
-
codeBlockEditor.value?.hide();
|
|
3708
|
-
}
|
|
3709
|
-
};
|
|
3710
|
-
};
|
|
3711
|
-
|
|
3712
3739
|
const state = vue.reactive({
|
|
3713
3740
|
uiSelectMode: false,
|
|
3714
3741
|
showSrc: false,
|
|
@@ -4195,14 +4222,28 @@
|
|
|
4195
4222
|
calcBoxPosition();
|
|
4196
4223
|
addDialogVisible.value = true;
|
|
4197
4224
|
};
|
|
4198
|
-
const fieldChange = ({ index, ...value }) => {
|
|
4225
|
+
const fieldChange = ({ index, ...value }, data) => {
|
|
4226
|
+
addDialogVisible.value = false;
|
|
4199
4227
|
if (index > -1) {
|
|
4200
|
-
|
|
4228
|
+
emit("change", value, {
|
|
4229
|
+
modifyKey: index,
|
|
4230
|
+
changeRecords: (data.changeRecords || []).map((item) => ({
|
|
4231
|
+
propPath: `${props.prop}.${index}.${item.propPath}`,
|
|
4232
|
+
value: item.value
|
|
4233
|
+
}))
|
|
4234
|
+
});
|
|
4201
4235
|
} else {
|
|
4202
|
-
props.model[props.name].
|
|
4236
|
+
const modifyKey = props.model[props.name].length;
|
|
4237
|
+
emit("change", value, {
|
|
4238
|
+
modifyKey,
|
|
4239
|
+
changeRecords: [
|
|
4240
|
+
{
|
|
4241
|
+
propPath: `${props.prop}.${modifyKey}`,
|
|
4242
|
+
value
|
|
4243
|
+
}
|
|
4244
|
+
]
|
|
4245
|
+
});
|
|
4203
4246
|
}
|
|
4204
|
-
addDialogVisible.value = false;
|
|
4205
|
-
emit("change", props.model[props.name]);
|
|
4206
4247
|
};
|
|
4207
4248
|
const fieldColumns = [
|
|
4208
4249
|
{
|
|
@@ -4396,9 +4437,8 @@
|
|
|
4396
4437
|
const addFromJsonFromChange = ({ data }) => {
|
|
4397
4438
|
try {
|
|
4398
4439
|
const value = JSON.parse(data);
|
|
4399
|
-
props.model[props.name] = getFieldsConfig(value, props.model[props.name]);
|
|
4400
4440
|
addFromJsonDialogVisible.value = false;
|
|
4401
|
-
emit("change", props.model[props.name]);
|
|
4441
|
+
emit("change", getFieldsConfig(value, props.model[props.name]));
|
|
4402
4442
|
} catch (e) {
|
|
4403
4443
|
designPlugin.tMagicMessage.error(e.message);
|
|
4404
4444
|
}
|
|
@@ -5182,9 +5222,9 @@
|
|
|
5182
5222
|
}
|
|
5183
5223
|
}
|
|
5184
5224
|
]);
|
|
5185
|
-
const submitForm = (values) => {
|
|
5225
|
+
const submitForm = (values, data) => {
|
|
5186
5226
|
changedValue.value = void 0;
|
|
5187
|
-
emit("submit", values);
|
|
5227
|
+
emit("submit", values, data);
|
|
5188
5228
|
};
|
|
5189
5229
|
const errorHandler = (error) => {
|
|
5190
5230
|
designPlugin.tMagicMessage.error(error.message);
|
|
@@ -5205,7 +5245,7 @@
|
|
|
5205
5245
|
type: "warning",
|
|
5206
5246
|
distinguishCancelAndClose: true
|
|
5207
5247
|
}).then(() => {
|
|
5208
|
-
changedValue.value && submitForm(changedValue.value);
|
|
5248
|
+
changedValue.value && submitForm(changedValue.value, { changeRecords: formBox.value?.form?.changeRecords });
|
|
5209
5249
|
done();
|
|
5210
5250
|
}).catch((action) => {
|
|
5211
5251
|
done(action === "cancel");
|
|
@@ -5369,7 +5409,9 @@
|
|
|
5369
5409
|
setup(__props, { emit: __emit }) {
|
|
5370
5410
|
const props = __props;
|
|
5371
5411
|
const emit = __emit;
|
|
5372
|
-
const
|
|
5412
|
+
const codeConfig = vue.ref();
|
|
5413
|
+
const codeBlockEditor = vue.ref();
|
|
5414
|
+
let editIndex = -1;
|
|
5373
5415
|
const methodColumns = [
|
|
5374
5416
|
{
|
|
5375
5417
|
label: "名称",
|
|
@@ -5394,16 +5436,29 @@
|
|
|
5394
5436
|
actions: [
|
|
5395
5437
|
{
|
|
5396
5438
|
text: "编辑",
|
|
5397
|
-
handler: (
|
|
5398
|
-
|
|
5399
|
-
|
|
5439
|
+
handler: (method, index) => {
|
|
5440
|
+
let codeContent = method.content || `({ params, dataSource, app }) => {
|
|
5441
|
+
// place your code here
|
|
5442
|
+
}`;
|
|
5443
|
+
if (typeof codeContent !== "string") {
|
|
5444
|
+
codeContent = codeContent.toString();
|
|
5445
|
+
}
|
|
5446
|
+
codeConfig.value = {
|
|
5447
|
+
...lodashEs.cloneDeep(method),
|
|
5448
|
+
content: codeContent
|
|
5449
|
+
};
|
|
5450
|
+
editIndex = index;
|
|
5451
|
+
vue.nextTick(() => {
|
|
5452
|
+
codeBlockEditor.value?.show();
|
|
5453
|
+
});
|
|
5400
5454
|
}
|
|
5401
5455
|
},
|
|
5402
5456
|
{
|
|
5403
5457
|
text: "删除",
|
|
5404
5458
|
buttonType: "danger",
|
|
5405
|
-
handler: (row) => {
|
|
5406
|
-
|
|
5459
|
+
handler: async (row, index) => {
|
|
5460
|
+
await designPlugin.tMagicMessageBox.confirm(`确定删除${row.name}?`, "提示");
|
|
5461
|
+
props.model[props.name].splice(index, 1);
|
|
5407
5462
|
emit("change", props.model[props.name]);
|
|
5408
5463
|
}
|
|
5409
5464
|
}
|
|
@@ -5411,12 +5466,48 @@
|
|
|
5411
5466
|
}
|
|
5412
5467
|
];
|
|
5413
5468
|
const createCodeHandler = () => {
|
|
5414
|
-
|
|
5415
|
-
|
|
5469
|
+
codeConfig.value = {
|
|
5470
|
+
name: "",
|
|
5471
|
+
content: `({ params, dataSource, app, flowState }) => {
|
|
5472
|
+
// place your code here
|
|
5473
|
+
}`,
|
|
5474
|
+
params: []
|
|
5475
|
+
};
|
|
5476
|
+
editIndex = -1;
|
|
5477
|
+
vue.nextTick(() => {
|
|
5478
|
+
codeBlockEditor.value?.show();
|
|
5479
|
+
});
|
|
5416
5480
|
};
|
|
5417
|
-
const submitCodeHandler = (
|
|
5418
|
-
|
|
5419
|
-
|
|
5481
|
+
const submitCodeHandler = (value, data) => {
|
|
5482
|
+
if (value.content) {
|
|
5483
|
+
const parseDSL = getEditorConfig("parseDSL");
|
|
5484
|
+
if (typeof value.content === "string") {
|
|
5485
|
+
value.content = parseDSL(value.content);
|
|
5486
|
+
}
|
|
5487
|
+
}
|
|
5488
|
+
if (editIndex > -1) {
|
|
5489
|
+
emit("change", value, {
|
|
5490
|
+
modifyKey: editIndex,
|
|
5491
|
+
changeRecords: (data.changeRecords || []).map((item) => ({
|
|
5492
|
+
propPath: `${props.prop}.${editIndex}.${item.propPath}`,
|
|
5493
|
+
value: item.value
|
|
5494
|
+
}))
|
|
5495
|
+
});
|
|
5496
|
+
} else {
|
|
5497
|
+
const modifyKey = props.model[props.name].length;
|
|
5498
|
+
emit("change", value, {
|
|
5499
|
+
modifyKey,
|
|
5500
|
+
changeRecords: [
|
|
5501
|
+
{
|
|
5502
|
+
propPath: `${props.prop}.${modifyKey}`,
|
|
5503
|
+
value
|
|
5504
|
+
}
|
|
5505
|
+
]
|
|
5506
|
+
});
|
|
5507
|
+
}
|
|
5508
|
+
editIndex = -1;
|
|
5509
|
+
codeConfig.value = void 0;
|
|
5510
|
+
codeBlockEditor.value?.hide();
|
|
5420
5511
|
};
|
|
5421
5512
|
return (_ctx, _cache) => {
|
|
5422
5513
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$p, [
|
|
@@ -5438,12 +5529,12 @@
|
|
|
5438
5529
|
_: 1
|
|
5439
5530
|
}, 8, ["disabled"])
|
|
5440
5531
|
]),
|
|
5441
|
-
|
|
5532
|
+
codeConfig.value ? (vue.openBlock(), vue.createBlock(_sfc_main$L, {
|
|
5442
5533
|
key: 0,
|
|
5443
5534
|
ref_key: "codeBlockEditor",
|
|
5444
5535
|
ref: codeBlockEditor,
|
|
5445
5536
|
disabled: _ctx.disabled,
|
|
5446
|
-
content:
|
|
5537
|
+
content: codeConfig.value,
|
|
5447
5538
|
"is-data-source": true,
|
|
5448
5539
|
"data-source-type": _ctx.model.type,
|
|
5449
5540
|
onSubmit: submitCodeHandler
|
|
@@ -6041,8 +6132,11 @@
|
|
|
6041
6132
|
}
|
|
6042
6133
|
]
|
|
6043
6134
|
}));
|
|
6044
|
-
const changeHandler = (v) => {
|
|
6045
|
-
|
|
6135
|
+
const changeHandler = (v, eventData) => {
|
|
6136
|
+
if (!Array.isArray(props.model[props.name])) {
|
|
6137
|
+
props.model[props.name] = [];
|
|
6138
|
+
}
|
|
6139
|
+
emit("change", v, eventData);
|
|
6046
6140
|
};
|
|
6047
6141
|
return (_ctx, _cache) => {
|
|
6048
6142
|
return vue.openBlock(), vue.createBlock(vue.unref(formPlugin.MGroupList), {
|
|
@@ -6326,17 +6420,19 @@
|
|
|
6326
6420
|
if (!props.model[props.name]) {
|
|
6327
6421
|
props.model[props.name] = [];
|
|
6328
6422
|
}
|
|
6329
|
-
|
|
6330
|
-
|
|
6423
|
+
emit("change", defaultEvent, {
|
|
6424
|
+
modifyKey: props.model[props.name].length
|
|
6425
|
+
});
|
|
6331
6426
|
};
|
|
6332
6427
|
const removeEvent = (index) => {
|
|
6333
6428
|
if (!props.name) return;
|
|
6334
6429
|
props.model[props.name].splice(index, 1);
|
|
6335
|
-
|
|
6430
|
+
emit("change", props.model[props.name]);
|
|
6336
6431
|
};
|
|
6337
|
-
const
|
|
6338
|
-
emit("change", props.model);
|
|
6432
|
+
const eventNameChangeHandler = (v, eventData) => {
|
|
6433
|
+
emit("change", props.model[props.name], eventData);
|
|
6339
6434
|
};
|
|
6435
|
+
const onChangeHandler = (v, eventData) => emit("change", props.model[props.name], eventData);
|
|
6340
6436
|
return (_ctx, _cache) => {
|
|
6341
6437
|
const _component_m_form_table = vue.resolveComponent("m-form-table");
|
|
6342
6438
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$l, [
|
|
@@ -6367,6 +6463,7 @@
|
|
|
6367
6463
|
key: index,
|
|
6368
6464
|
disabled: _ctx.disabled,
|
|
6369
6465
|
size: _ctx.size,
|
|
6466
|
+
prop: `${_ctx.prop}.${index}`,
|
|
6370
6467
|
config: actionsConfig.value,
|
|
6371
6468
|
model: cardItem,
|
|
6372
6469
|
"label-width": _ctx.config.labelWidth || "100px",
|
|
@@ -6379,8 +6476,9 @@
|
|
|
6379
6476
|
model: cardItem,
|
|
6380
6477
|
disabled: _ctx.disabled,
|
|
6381
6478
|
size: _ctx.size,
|
|
6382
|
-
|
|
6383
|
-
|
|
6479
|
+
prop: `${_ctx.prop}.${index}`,
|
|
6480
|
+
onChange: eventNameChangeHandler
|
|
6481
|
+
}, null, 8, ["config", "model", "disabled", "size", "prop"]),
|
|
6384
6482
|
vue.createVNode(vue.unref(designPlugin.TMagicButton), {
|
|
6385
6483
|
style: { "color": "#f56c6c" },
|
|
6386
6484
|
link: "",
|
|
@@ -6391,7 +6489,7 @@
|
|
|
6391
6489
|
}, null, 8, ["icon", "disabled", "size", "onClick"])
|
|
6392
6490
|
]),
|
|
6393
6491
|
_: 2
|
|
6394
|
-
}, 1032, ["disabled", "size", "config", "model", "label-width"]);
|
|
6492
|
+
}, 1032, ["disabled", "size", "prop", "config", "model", "label-width"]);
|
|
6395
6493
|
}), 128))
|
|
6396
6494
|
]))
|
|
6397
6495
|
]);
|
|
@@ -6444,14 +6542,18 @@
|
|
|
6444
6542
|
const records = vue.ref([]);
|
|
6445
6543
|
const showCode = vue.ref(false);
|
|
6446
6544
|
vue.watchEffect(() => {
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6545
|
+
if (typeof props.model[props.name] === "function") {
|
|
6546
|
+
showCode.value = true;
|
|
6547
|
+
} else {
|
|
6548
|
+
const initValues = Object.entries(props.model[props.name] || {});
|
|
6549
|
+
for (const [, value] of initValues) {
|
|
6550
|
+
if (typeof value !== "string") {
|
|
6551
|
+
showCode.value = true;
|
|
6552
|
+
break;
|
|
6553
|
+
}
|
|
6452
6554
|
}
|
|
6555
|
+
records.value = initValues;
|
|
6453
6556
|
}
|
|
6454
|
-
records.value = initValues;
|
|
6455
6557
|
});
|
|
6456
6558
|
const getValue = () => {
|
|
6457
6559
|
const record = {};
|
|
@@ -6533,7 +6635,7 @@
|
|
|
6533
6635
|
key: 1,
|
|
6534
6636
|
height: "200px",
|
|
6535
6637
|
"init-values": _ctx.model[_ctx.name],
|
|
6536
|
-
language: "
|
|
6638
|
+
language: "javascript",
|
|
6537
6639
|
options: {
|
|
6538
6640
|
readOnly: _ctx.disabled
|
|
6539
6641
|
},
|
|
@@ -7201,7 +7303,7 @@
|
|
|
7201
7303
|
pageBarSortOptions: {},
|
|
7202
7304
|
length: {}
|
|
7203
7305
|
},
|
|
7204
|
-
setup(__props) {
|
|
7306
|
+
setup(__props, { expose: __expose }) {
|
|
7205
7307
|
const props = __props;
|
|
7206
7308
|
const services = vue.inject("services");
|
|
7207
7309
|
const editorService = services?.editorService;
|
|
@@ -7231,23 +7333,28 @@
|
|
|
7231
7333
|
});
|
|
7232
7334
|
let translateLeft = 0;
|
|
7233
7335
|
const scroll = (type) => {
|
|
7234
|
-
if (!itemsContainer.value) return;
|
|
7336
|
+
if (!itemsContainer.value || !canScroll.value) return;
|
|
7235
7337
|
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
7236
7338
|
if (type === "left") {
|
|
7237
|
-
translateLeft
|
|
7238
|
-
if (translateLeft > 0) {
|
|
7239
|
-
translateLeft = 0;
|
|
7240
|
-
}
|
|
7339
|
+
scrollTo(translateLeft + 200);
|
|
7241
7340
|
} else if (type === "right") {
|
|
7242
|
-
translateLeft
|
|
7243
|
-
if (-translateLeft > maxScrollLeft) {
|
|
7244
|
-
translateLeft = -maxScrollLeft;
|
|
7245
|
-
}
|
|
7341
|
+
scrollTo(translateLeft - 200);
|
|
7246
7342
|
} else if (type === "start") {
|
|
7247
|
-
|
|
7343
|
+
scrollTo(0);
|
|
7248
7344
|
} else if (type === "end") {
|
|
7249
|
-
|
|
7345
|
+
scrollTo(-maxScrollLeft);
|
|
7346
|
+
}
|
|
7347
|
+
};
|
|
7348
|
+
const scrollTo = (value) => {
|
|
7349
|
+
if (!itemsContainer.value || !canScroll.value) return;
|
|
7350
|
+
const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
|
|
7351
|
+
if (value >= 0) {
|
|
7352
|
+
value = 0;
|
|
7353
|
+
}
|
|
7354
|
+
if (-value > maxScrollLeft) {
|
|
7355
|
+
value = -maxScrollLeft;
|
|
7250
7356
|
}
|
|
7357
|
+
translateLeft = value;
|
|
7251
7358
|
itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
|
|
7252
7359
|
};
|
|
7253
7360
|
vue.watch(
|
|
@@ -7255,11 +7362,13 @@
|
|
|
7255
7362
|
(length = 0, preLength = 0) => {
|
|
7256
7363
|
setTimeout(() => {
|
|
7257
7364
|
setCanScroll();
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7365
|
+
vue.nextTick(() => {
|
|
7366
|
+
if (length < preLength || preLength === 0) {
|
|
7367
|
+
scroll("start");
|
|
7368
|
+
} else {
|
|
7369
|
+
scroll("end");
|
|
7370
|
+
}
|
|
7371
|
+
});
|
|
7263
7372
|
if (length > 1) {
|
|
7264
7373
|
const el = document.querySelector(".m-editor-page-bar-items");
|
|
7265
7374
|
let beforeDragList = [];
|
|
@@ -7296,6 +7405,14 @@
|
|
|
7296
7405
|
immediate: true
|
|
7297
7406
|
}
|
|
7298
7407
|
);
|
|
7408
|
+
__expose({
|
|
7409
|
+
itemsContainerWidth,
|
|
7410
|
+
scroll,
|
|
7411
|
+
scrollTo,
|
|
7412
|
+
getTranslateLeft() {
|
|
7413
|
+
return translateLeft;
|
|
7414
|
+
}
|
|
7415
|
+
});
|
|
7299
7416
|
return (_ctx, _cache) => {
|
|
7300
7417
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
7301
7418
|
class: "m-editor-page-bar",
|
|
@@ -7303,25 +7420,24 @@
|
|
|
7303
7420
|
ref: pageBar
|
|
7304
7421
|
}, [
|
|
7305
7422
|
vue.renderSlot(_ctx.$slots, "prepend"),
|
|
7306
|
-
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
7307
|
-
key: 0,
|
|
7308
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
7309
|
-
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
7310
|
-
}, [
|
|
7311
|
-
vue.createVNode(_sfc_main$Y, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
|
|
7312
|
-
])) : vue.createCommentVNode("", true),
|
|
7313
7423
|
_ctx.length ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
7314
|
-
key:
|
|
7424
|
+
key: 0,
|
|
7315
7425
|
class: "m-editor-page-bar-items",
|
|
7316
7426
|
ref_key: "itemsContainer",
|
|
7317
|
-
ref: itemsContainer
|
|
7318
|
-
style: vue.normalizeStyle(`width: ${itemsContainerWidth.value}px`)
|
|
7427
|
+
ref: itemsContainer
|
|
7319
7428
|
}, [
|
|
7320
7429
|
vue.renderSlot(_ctx.$slots, "default")
|
|
7321
|
-
],
|
|
7430
|
+
], 512)) : vue.createCommentVNode("", true),
|
|
7431
|
+
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
7432
|
+
key: 1,
|
|
7433
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon m-editor-page-bar-item-left-icon",
|
|
7434
|
+
onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
|
|
7435
|
+
}, [
|
|
7436
|
+
vue.createVNode(_sfc_main$Y, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
|
|
7437
|
+
])) : vue.createCommentVNode("", true),
|
|
7322
7438
|
canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
7323
7439
|
key: 2,
|
|
7324
|
-
class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
|
|
7440
|
+
class: "m-editor-page-bar-item m-editor-page-bar-item-icon m-editor-page-bar-item-right-icon",
|
|
7325
7441
|
onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
|
|
7326
7442
|
}, [
|
|
7327
7443
|
vue.createVNode(_sfc_main$Y, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
|
|
@@ -7349,8 +7465,9 @@
|
|
|
7349
7465
|
const uiService = services?.uiService;
|
|
7350
7466
|
const editorService = services?.editorService;
|
|
7351
7467
|
const showPageListButton = vue.computed(() => uiService?.get("showPageListButton"));
|
|
7352
|
-
const
|
|
7353
|
-
|
|
7468
|
+
const page = vue.computed(() => editorService?.get("page"));
|
|
7469
|
+
const switchPage = async (id) => {
|
|
7470
|
+
await editorService?.select(id);
|
|
7354
7471
|
};
|
|
7355
7472
|
return (_ctx, _cache) => {
|
|
7356
7473
|
return showPageListButton.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$e, [
|
|
@@ -7377,6 +7494,7 @@
|
|
|
7377
7494
|
data: {
|
|
7378
7495
|
type: "button",
|
|
7379
7496
|
text: item.devconfig?.tabName || item.name || item.id,
|
|
7497
|
+
className: item.id === page.value?.id ? "active" : "",
|
|
7380
7498
|
handler: () => switchPage(item.id)
|
|
7381
7499
|
},
|
|
7382
7500
|
key: index
|
|
@@ -7457,7 +7575,7 @@
|
|
|
7457
7575
|
});
|
|
7458
7576
|
|
|
7459
7577
|
const _hoisted_1$c = { class: "m-editor-page-bar-tabs" };
|
|
7460
|
-
const _hoisted_2$5 = ["page-id", "onClick"];
|
|
7578
|
+
const _hoisted_2$5 = ["data-page-id", "onClick"];
|
|
7461
7579
|
const _hoisted_3$2 = { class: "m-editor-page-bar-title" };
|
|
7462
7580
|
const _hoisted_4$2 = ["title"];
|
|
7463
7581
|
const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
|
|
@@ -7508,9 +7626,38 @@
|
|
|
7508
7626
|
const remove = (node) => {
|
|
7509
7627
|
editorService?.remove(node);
|
|
7510
7628
|
};
|
|
7629
|
+
const pageBarScrollContainer = vue.ref();
|
|
7630
|
+
const pageBarItems = vue.ref();
|
|
7631
|
+
vue.watch(page, (page2) => {
|
|
7632
|
+
if (!page2 || !pageBarScrollContainer.value?.itemsContainerWidth || !pageBarItems.value || pageBarItems.value.length < 2) {
|
|
7633
|
+
return;
|
|
7634
|
+
}
|
|
7635
|
+
const firstItem = pageBarItems.value[0];
|
|
7636
|
+
const lastItem = pageBarItems.value[pageBarItems.value.length - 1];
|
|
7637
|
+
if (page2.id === firstItem.dataset.pageId) {
|
|
7638
|
+
pageBarScrollContainer.value.scroll("start");
|
|
7639
|
+
} else if (page2.id === lastItem.dataset.pageId) {
|
|
7640
|
+
pageBarScrollContainer.value.scroll("end");
|
|
7641
|
+
} else {
|
|
7642
|
+
const pageItem = pageBarItems.value.find((item) => item.dataset.pageId === page2.id);
|
|
7643
|
+
if (!pageItem) {
|
|
7644
|
+
return;
|
|
7645
|
+
}
|
|
7646
|
+
const pageItemRect = pageItem.getBoundingClientRect();
|
|
7647
|
+
const offsetLeft = pageItemRect.left - firstItem.getBoundingClientRect().left;
|
|
7648
|
+
const { itemsContainerWidth } = pageBarScrollContainer.value;
|
|
7649
|
+
const left = itemsContainerWidth - offsetLeft - pageItemRect.width;
|
|
7650
|
+
const translateLeft = pageBarScrollContainer.value.getTranslateLeft();
|
|
7651
|
+
if (offsetLeft + translateLeft < 0 || offsetLeft + pageItemRect.width > itemsContainerWidth - translateLeft) {
|
|
7652
|
+
pageBarScrollContainer.value.scrollTo(left);
|
|
7653
|
+
}
|
|
7654
|
+
}
|
|
7655
|
+
});
|
|
7511
7656
|
return (_ctx, _cache) => {
|
|
7512
7657
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
|
|
7513
7658
|
vue.createVNode(_sfc_main$w, {
|
|
7659
|
+
ref_key: "pageBarScrollContainer",
|
|
7660
|
+
ref: pageBarScrollContainer,
|
|
7514
7661
|
"page-bar-sort-options": _ctx.pageBarSortOptions,
|
|
7515
7662
|
length: list.value.length
|
|
7516
7663
|
}, {
|
|
@@ -7533,8 +7680,11 @@
|
|
|
7533
7680
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(list.value, (item) => {
|
|
7534
7681
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
7535
7682
|
class: vue.normalizeClass(["m-editor-page-bar-item", { active: page.value?.id === item.id }]),
|
|
7683
|
+
ref_for: true,
|
|
7684
|
+
ref_key: "pageBarItems",
|
|
7685
|
+
ref: pageBarItems,
|
|
7536
7686
|
key: item.id,
|
|
7537
|
-
"page-id": item.id,
|
|
7687
|
+
"data-page-id": item.id,
|
|
7538
7688
|
onClick: ($event) => switchPage(item.id)
|
|
7539
7689
|
}, [
|
|
7540
7690
|
vue.createElementVNode("div", _hoisted_3$2, [
|
|
@@ -7666,7 +7816,6 @@
|
|
|
7666
7816
|
const root = vue.computed(() => editorService?.get("root"));
|
|
7667
7817
|
const page = vue.computed(() => editorService?.get("page"));
|
|
7668
7818
|
const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
|
|
7669
|
-
const stageLoading = vue.computed(() => editorService?.get("stageLoading") || false);
|
|
7670
7819
|
const showSrc = vue.computed(() => uiService?.get("showSrc"));
|
|
7671
7820
|
const getLeftColumnWidthCacheData = () => Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
|
|
7672
7821
|
const getRightColumnWidthCacheData = () => Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
|
|
@@ -7717,7 +7866,6 @@
|
|
|
7717
7866
|
}
|
|
7718
7867
|
};
|
|
7719
7868
|
return (_ctx, _cache) => {
|
|
7720
|
-
const _directive_loading = vue.resolveDirective("loading");
|
|
7721
7869
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
7722
7870
|
class: "m-editor",
|
|
7723
7871
|
ref_key: "content",
|
|
@@ -7734,9 +7882,8 @@
|
|
|
7734
7882
|
options: vue.unref(codeOptions),
|
|
7735
7883
|
onSave: saveCode
|
|
7736
7884
|
}, null, 8, ["init-values", "options"])
|
|
7737
|
-
]) :
|
|
7885
|
+
]) : (vue.openBlock(), vue.createBlock(_sfc_main$z, {
|
|
7738
7886
|
key: 1,
|
|
7739
|
-
"element-loading-text": "Runtime 加载中...",
|
|
7740
7887
|
ref_key: "splitView",
|
|
7741
7888
|
ref: splitView,
|
|
7742
7889
|
class: "m-editor-content",
|
|
@@ -7796,9 +7943,7 @@
|
|
|
7796
7943
|
]),
|
|
7797
7944
|
key: "0"
|
|
7798
7945
|
} : void 0
|
|
7799
|
-
]), 1032, ["left", "right", "width"])),
|
|
7800
|
-
[_directive_loading, stageLoading.value]
|
|
7801
|
-
]),
|
|
7946
|
+
]), 1032, ["left", "right", "width"])),
|
|
7802
7947
|
vue.renderSlot(_ctx.$slots, "content-after"),
|
|
7803
7948
|
vue.renderSlot(_ctx.$slots, "footer")
|
|
7804
7949
|
], 512);
|
|
@@ -8047,10 +8192,10 @@
|
|
|
8047
8192
|
configForm.value.formState.stage = stage.value;
|
|
8048
8193
|
}
|
|
8049
8194
|
});
|
|
8050
|
-
const submit = async () => {
|
|
8195
|
+
const submit = async (v, eventData) => {
|
|
8051
8196
|
try {
|
|
8052
8197
|
const values2 = await configForm.value?.submitForm();
|
|
8053
|
-
services?.editorService.update(values2);
|
|
8198
|
+
services?.editorService.update(values2, { changeRecords: eventData.changeRecords });
|
|
8054
8199
|
} catch (e) {
|
|
8055
8200
|
emit("submit-error", e);
|
|
8056
8201
|
}
|
|
@@ -8352,6 +8497,7 @@
|
|
|
8352
8497
|
const emit = __emit;
|
|
8353
8498
|
const services = vue.inject("services");
|
|
8354
8499
|
const { codeBlockService, depService, editorService } = services || {};
|
|
8500
|
+
const collecting = vue.computed(() => depService?.get("collecting"));
|
|
8355
8501
|
const codeList = vue.computed(
|
|
8356
8502
|
() => Object.entries(codeBlockService?.getCodeDsl() || {}).map(([codeId, code]) => {
|
|
8357
8503
|
const target = depService?.getTarget(codeId, core.DepTargetType.CODE_BLOCK);
|
|
@@ -8451,8 +8597,19 @@
|
|
|
8451
8597
|
}, vue.toDisplayString(data.name) + " " + vue.toDisplayString(data.key ? `(${data.key})` : ""), 3)
|
|
8452
8598
|
]),
|
|
8453
8599
|
"tree-node-tool": vue.withCtx(({ data }) => [
|
|
8454
|
-
data.type === "code" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.
|
|
8600
|
+
collecting.value && data.type === "code" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTag), {
|
|
8455
8601
|
key: 0,
|
|
8602
|
+
type: "info",
|
|
8603
|
+
size: "small",
|
|
8604
|
+
style: { "margin-right": "5px" }
|
|
8605
|
+
}, {
|
|
8606
|
+
default: vue.withCtx(() => _cache[0] || (_cache[0] = [
|
|
8607
|
+
vue.createTextVNode("依赖收集中")
|
|
8608
|
+
])),
|
|
8609
|
+
_: 1
|
|
8610
|
+
})) : vue.createCommentVNode("", true),
|
|
8611
|
+
data.type === "code" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
|
|
8612
|
+
key: 1,
|
|
8456
8613
|
effect: "dark",
|
|
8457
8614
|
content: editable.value ? "编辑" : "查看",
|
|
8458
8615
|
placement: "bottom"
|
|
@@ -8467,7 +8624,7 @@
|
|
|
8467
8624
|
_: 2
|
|
8468
8625
|
}, 1032, ["content"])) : vue.createCommentVNode("", true),
|
|
8469
8626
|
data.type === "code" && editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
|
|
8470
|
-
key:
|
|
8627
|
+
key: 2,
|
|
8471
8628
|
effect: "dark",
|
|
8472
8629
|
content: "删除",
|
|
8473
8630
|
placement: "bottom"
|
|
@@ -8583,9 +8740,9 @@
|
|
|
8583
8740
|
dialogTitle.value = `编辑${dataSourceValues.value.title || ""}`;
|
|
8584
8741
|
editDialog.value.show();
|
|
8585
8742
|
};
|
|
8586
|
-
const submitDataSourceHandler = (value) => {
|
|
8743
|
+
const submitDataSourceHandler = (value, eventData) => {
|
|
8587
8744
|
if (value.id) {
|
|
8588
|
-
dataSourceService?.update(value);
|
|
8745
|
+
dataSourceService?.update(value, { changeRecords: eventData.changeRecords });
|
|
8589
8746
|
} else {
|
|
8590
8747
|
dataSourceService?.add(value);
|
|
8591
8748
|
}
|
|
@@ -8632,8 +8789,8 @@
|
|
|
8632
8789
|
initValues.value = props.values;
|
|
8633
8790
|
dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
|
|
8634
8791
|
});
|
|
8635
|
-
const submitHandler = (values) => {
|
|
8636
|
-
emit("submit", values);
|
|
8792
|
+
const submitHandler = (values, data) => {
|
|
8793
|
+
emit("submit", values, data);
|
|
8637
8794
|
};
|
|
8638
8795
|
const errorHandler = (error) => {
|
|
8639
8796
|
designPlugin.tMagicMessage.error(error.message);
|
|
@@ -8689,6 +8846,7 @@
|
|
|
8689
8846
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
8690
8847
|
const emit = __emit;
|
|
8691
8848
|
const { depService, editorService, dataSourceService } = vue.inject("services") || {};
|
|
8849
|
+
const collecting = vue.computed(() => depService?.get("collecting"));
|
|
8692
8850
|
const editable = vue.computed(() => dataSourceService?.get("editable") ?? true);
|
|
8693
8851
|
const dataSources = vue.computed(() => dataSourceService?.get("dataSources") || []);
|
|
8694
8852
|
const dsDep = vue.computed(() => depService?.getTargets(core.DepTargetType.DATA_SOURCE) || {});
|
|
@@ -8794,8 +8952,19 @@
|
|
|
8794
8952
|
}, vue.toDisplayString(data.name) + " " + vue.toDisplayString(data.key ? `(${data.key})` : ""), 3)
|
|
8795
8953
|
]),
|
|
8796
8954
|
"tree-node-tool": vue.withCtx(({ data }) => [
|
|
8797
|
-
data.type === "ds" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.
|
|
8955
|
+
collecting.value && data.type === "ds" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTag), {
|
|
8798
8956
|
key: 0,
|
|
8957
|
+
type: "info",
|
|
8958
|
+
size: "small",
|
|
8959
|
+
style: { "margin-right": "5px" }
|
|
8960
|
+
}, {
|
|
8961
|
+
default: vue.withCtx(() => _cache[0] || (_cache[0] = [
|
|
8962
|
+
vue.createTextVNode("依赖收集中")
|
|
8963
|
+
])),
|
|
8964
|
+
_: 1
|
|
8965
|
+
})) : vue.createCommentVNode("", true),
|
|
8966
|
+
data.type === "ds" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
|
|
8967
|
+
key: 1,
|
|
8799
8968
|
effect: "dark",
|
|
8800
8969
|
content: editable.value ? "编辑" : "查看",
|
|
8801
8970
|
placement: "bottom"
|
|
@@ -8810,7 +8979,7 @@
|
|
|
8810
8979
|
_: 2
|
|
8811
8980
|
}, 1032, ["content"])) : vue.createCommentVNode("", true),
|
|
8812
8981
|
data.type === "ds" && editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
|
|
8813
|
-
key:
|
|
8982
|
+
key: 2,
|
|
8814
8983
|
effect: "dark",
|
|
8815
8984
|
content: "删除",
|
|
8816
8985
|
placement: "bottom"
|
|
@@ -10076,6 +10245,7 @@
|
|
|
10076
10245
|
setup(__props, { expose: __expose }) {
|
|
10077
10246
|
const props = __props;
|
|
10078
10247
|
const services = vue.inject("services");
|
|
10248
|
+
const collecting = vue.computed(() => services?.depService.get("collecting"));
|
|
10079
10249
|
const columnLeftWidth = vue.computed(() => services?.uiService.get("columnWidth")[ColumnLayout.LEFT] || 0);
|
|
10080
10250
|
const { height: editorContentHeight } = useEditorContentHeight();
|
|
10081
10251
|
const columnLeftHeight = vue.ref(0);
|
|
@@ -10218,7 +10388,7 @@
|
|
|
10218
10388
|
]),
|
|
10219
10389
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(sideBarItems.value, (config, index) => {
|
|
10220
10390
|
return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
|
|
10221
|
-
class: "m-editor-sidebar-content",
|
|
10391
|
+
class: vue.normalizeClass(["m-editor-sidebar-content", { "m-editor-dep-collecting": collecting.value }]),
|
|
10222
10392
|
key: config.$key ?? index
|
|
10223
10393
|
}, [
|
|
10224
10394
|
config?.component && !vue.unref(floatBoxStates)[config.$key]?.status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.component), vue.mergeProps({
|
|
@@ -10344,7 +10514,7 @@
|
|
|
10344
10514
|
key: "11"
|
|
10345
10515
|
} : void 0
|
|
10346
10516
|
]), 1040)) : vue.createCommentVNode("", true)
|
|
10347
|
-
])), [
|
|
10517
|
+
], 2)), [
|
|
10348
10518
|
[vue.vShow, [config.text, config.$key, `${index}`].includes(activeTabName.value)]
|
|
10349
10519
|
]);
|
|
10350
10520
|
}), 128))
|
|
@@ -10925,15 +11095,17 @@
|
|
|
10925
11095
|
},
|
|
10926
11096
|
__name: "Stage",
|
|
10927
11097
|
props: {
|
|
11098
|
+
stageOptions: {},
|
|
10928
11099
|
stageContentMenu: {},
|
|
10929
11100
|
disabledStageOverlay: { type: Boolean, default: false },
|
|
10930
11101
|
customContentMenu: {}
|
|
10931
11102
|
},
|
|
10932
11103
|
setup(__props) {
|
|
11104
|
+
const props = __props;
|
|
10933
11105
|
let stage = null;
|
|
10934
11106
|
let runtime = null;
|
|
10935
11107
|
const services = vue.inject("services");
|
|
10936
|
-
const
|
|
11108
|
+
const stageLoading = vue.computed(() => services?.editorService.get("stageLoading") || false);
|
|
10937
11109
|
const stageWrap = vue.ref();
|
|
10938
11110
|
const stageContainer = vue.ref();
|
|
10939
11111
|
const menu = vue.ref();
|
|
@@ -10948,8 +11120,8 @@
|
|
|
10948
11120
|
vue.watchEffect(() => {
|
|
10949
11121
|
if (stage || !page.value) return;
|
|
10950
11122
|
if (!stageContainer.value) return;
|
|
10951
|
-
if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value) return;
|
|
10952
|
-
stage = useStage(stageOptions);
|
|
11123
|
+
if (!(props.stageOptions?.runtimeUrl || props.stageOptions?.render) || !root.value) return;
|
|
11124
|
+
stage = useStage(props.stageOptions);
|
|
10953
11125
|
stage.on("select", () => {
|
|
10954
11126
|
stageWrap.value?.container?.focus();
|
|
10955
11127
|
});
|
|
@@ -10969,6 +11141,7 @@
|
|
|
10969
11141
|
});
|
|
10970
11142
|
vue.onBeforeUnmount(() => {
|
|
10971
11143
|
stage?.destroy();
|
|
11144
|
+
services?.editorService.set("stage", null);
|
|
10972
11145
|
});
|
|
10973
11146
|
vue.watch(zoom, (zoom2) => {
|
|
10974
11147
|
if (!stage || !zoom2) return;
|
|
@@ -11036,7 +11209,9 @@
|
|
|
11036
11209
|
if (!config || config.dragType !== DragType.COMPONENT_LIST) return;
|
|
11037
11210
|
e.preventDefault();
|
|
11038
11211
|
const doc = stage?.renderer?.contentWindow?.document;
|
|
11039
|
-
const parentEl = doc?.querySelector(
|
|
11212
|
+
const parentEl = doc?.querySelector(
|
|
11213
|
+
`.${props.stageOptions?.containerHighlightClassName}`
|
|
11214
|
+
);
|
|
11040
11215
|
let parent = page.value;
|
|
11041
11216
|
const parentId = utils.getIdFromEl()(parentEl);
|
|
11042
11217
|
if (parentId) {
|
|
@@ -11075,11 +11250,13 @@
|
|
|
11075
11250
|
}
|
|
11076
11251
|
};
|
|
11077
11252
|
return (_ctx, _cache) => {
|
|
11078
|
-
|
|
11253
|
+
const _directive_loading = vue.resolveDirective("loading");
|
|
11254
|
+
return vue.withDirectives((vue.openBlock(), vue.createBlock(_sfc_main$8, {
|
|
11079
11255
|
class: "m-editor-stage",
|
|
11080
11256
|
ref_key: "stageWrap",
|
|
11081
11257
|
ref: stageWrap,
|
|
11082
11258
|
tabindex: "-1",
|
|
11259
|
+
"element-loading-text": "Runtime 加载中...",
|
|
11083
11260
|
width: stageRect.value?.width,
|
|
11084
11261
|
height: stageRect.value?.height,
|
|
11085
11262
|
"wrap-width": stageContainerRect.value?.width,
|
|
@@ -11116,7 +11293,9 @@
|
|
|
11116
11293
|
vue.createVNode(_sfc_main$7)
|
|
11117
11294
|
]),
|
|
11118
11295
|
_: 1
|
|
11119
|
-
}, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"])
|
|
11296
|
+
}, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"])), [
|
|
11297
|
+
[_directive_loading, stageLoading.value]
|
|
11298
|
+
]);
|
|
11120
11299
|
};
|
|
11121
11300
|
}
|
|
11122
11301
|
});
|
|
@@ -11178,18 +11357,20 @@
|
|
|
11178
11357
|
customContentMenu: {}
|
|
11179
11358
|
},
|
|
11180
11359
|
setup(__props) {
|
|
11360
|
+
const stageOptions = vue.inject("stageOptions");
|
|
11181
11361
|
const services = vue.inject("services");
|
|
11182
11362
|
const page = vue.computed(() => services?.editorService.get("page"));
|
|
11183
11363
|
return (_ctx, _cache) => {
|
|
11184
11364
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
11185
11365
|
vue.createVNode(_sfc_main$2),
|
|
11186
11366
|
vue.renderSlot(_ctx.$slots, "stage", {}, () => [
|
|
11187
|
-
page.value ? (vue.openBlock(), vue.createBlock(_sfc_main$3, {
|
|
11367
|
+
page.value && (vue.unref(stageOptions)?.render || vue.unref(stageOptions)?.runtimeUrl) ? (vue.openBlock(), vue.createBlock(_sfc_main$3, {
|
|
11188
11368
|
key: 0,
|
|
11369
|
+
"stage-options": vue.unref(stageOptions),
|
|
11189
11370
|
"disabled-stage-overlay": _ctx.disabledStageOverlay,
|
|
11190
11371
|
"stage-content-menu": _ctx.stageContentMenu,
|
|
11191
11372
|
"custom-content-menu": _ctx.customContentMenu
|
|
11192
|
-
}, null, 8, ["disabled-stage-overlay", "stage-content-menu", "custom-content-menu"])) : vue.createCommentVNode("", true)
|
|
11373
|
+
}, null, 8, ["stage-options", "disabled-stage-overlay", "stage-content-menu", "custom-content-menu"])) : vue.createCommentVNode("", true)
|
|
11193
11374
|
]),
|
|
11194
11375
|
vue.renderSlot(_ctx.$slots, "workspace-content")
|
|
11195
11376
|
]);
|
|
@@ -11539,12 +11720,17 @@
|
|
|
11539
11720
|
this.emit("add", newConfig);
|
|
11540
11721
|
return newConfig;
|
|
11541
11722
|
}
|
|
11542
|
-
update(config) {
|
|
11723
|
+
update(config, { changeRecords = [] } = {}) {
|
|
11543
11724
|
const dataSources = this.get("dataSources");
|
|
11544
11725
|
const index = dataSources.findIndex((ds) => ds.id === config.id);
|
|
11545
|
-
dataSources[index]
|
|
11546
|
-
|
|
11547
|
-
|
|
11726
|
+
const oldConfig = dataSources[index];
|
|
11727
|
+
const newConfig = lodashEs.cloneDeep(config);
|
|
11728
|
+
dataSources[index] = newConfig;
|
|
11729
|
+
this.emit("update", newConfig, {
|
|
11730
|
+
oldConfig,
|
|
11731
|
+
changeRecords
|
|
11732
|
+
});
|
|
11733
|
+
return newConfig;
|
|
11548
11734
|
}
|
|
11549
11735
|
remove(id) {
|
|
11550
11736
|
const dataSources = this.get("dataSources");
|
|
@@ -11620,7 +11806,16 @@
|
|
|
11620
11806
|
|
|
11621
11807
|
const idleTask = new IdleTask();
|
|
11622
11808
|
class Dep extends BaseService {
|
|
11809
|
+
state = vue.reactive({
|
|
11810
|
+
collecting: false
|
|
11811
|
+
});
|
|
11623
11812
|
watcher = new core.Watcher({ initialTargets: vue.reactive({}) });
|
|
11813
|
+
set(name, value) {
|
|
11814
|
+
this.state[name] = value;
|
|
11815
|
+
}
|
|
11816
|
+
get(name) {
|
|
11817
|
+
return this.state[name];
|
|
11818
|
+
}
|
|
11624
11819
|
removeTargets(type = core.DepTargetType.DEFAULT) {
|
|
11625
11820
|
this.watcher.removeTargets(type);
|
|
11626
11821
|
const targets = this.watcher.getTargets(type);
|
|
@@ -11647,34 +11842,30 @@
|
|
|
11647
11842
|
this.watcher.clearTargets();
|
|
11648
11843
|
}
|
|
11649
11844
|
collect(nodes, depExtendedData = {}, deep = false, type) {
|
|
11845
|
+
this.set("collecting", true);
|
|
11650
11846
|
this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
|
|
11651
11847
|
this.collectNode(node, target, depExtendedData, deep);
|
|
11652
11848
|
});
|
|
11849
|
+
this.set("collecting", false);
|
|
11653
11850
|
this.emit("collected", nodes, deep);
|
|
11654
11851
|
}
|
|
11655
11852
|
collectIdle(nodes, depExtendedData = {}, deep = false, type) {
|
|
11853
|
+
this.set("collecting", true);
|
|
11656
11854
|
let startTask = false;
|
|
11657
11855
|
this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
|
|
11658
11856
|
startTask = true;
|
|
11659
|
-
|
|
11660
|
-
({ node: node2, deep: deep2, target: target2 }) => {
|
|
11661
|
-
this.collectNode(node2, target2, depExtendedData, deep2);
|
|
11662
|
-
},
|
|
11663
|
-
{
|
|
11664
|
-
node,
|
|
11665
|
-
deep,
|
|
11666
|
-
target
|
|
11667
|
-
}
|
|
11668
|
-
);
|
|
11857
|
+
this.enqueueTask(node, target, depExtendedData, deep);
|
|
11669
11858
|
});
|
|
11670
11859
|
return new Promise((resolve) => {
|
|
11671
11860
|
if (!startTask) {
|
|
11672
11861
|
this.emit("collected", nodes, deep);
|
|
11862
|
+
this.set("collecting", false);
|
|
11673
11863
|
resolve();
|
|
11674
11864
|
return;
|
|
11675
11865
|
}
|
|
11676
11866
|
idleTask.once("finish", () => {
|
|
11677
11867
|
this.emit("collected", nodes, deep);
|
|
11868
|
+
this.set("collecting", false);
|
|
11678
11869
|
resolve();
|
|
11679
11870
|
});
|
|
11680
11871
|
});
|
|
@@ -11703,6 +11894,9 @@
|
|
|
11703
11894
|
hasSpecifiedTypeTarget(type = core.DepTargetType.DEFAULT) {
|
|
11704
11895
|
return this.watcher.hasSpecifiedTypeTarget(type);
|
|
11705
11896
|
}
|
|
11897
|
+
clearIdleTasks() {
|
|
11898
|
+
idleTask.clearTasks();
|
|
11899
|
+
}
|
|
11706
11900
|
on(eventName, listener) {
|
|
11707
11901
|
return super.on(eventName, listener);
|
|
11708
11902
|
}
|
|
@@ -11712,6 +11906,23 @@
|
|
|
11712
11906
|
emit(eventName, ...args) {
|
|
11713
11907
|
return super.emit(eventName, ...args);
|
|
11714
11908
|
}
|
|
11909
|
+
enqueueTask(node, target, depExtendedData, deep) {
|
|
11910
|
+
idleTask.enqueueTask(
|
|
11911
|
+
({ node: node2, deep: deep2, target: target2 }) => {
|
|
11912
|
+
this.collectNode(node2, target2, depExtendedData, deep2);
|
|
11913
|
+
},
|
|
11914
|
+
{
|
|
11915
|
+
node,
|
|
11916
|
+
deep: false,
|
|
11917
|
+
target
|
|
11918
|
+
}
|
|
11919
|
+
);
|
|
11920
|
+
if (deep && Array.isArray(node.items) && node.items.length) {
|
|
11921
|
+
node.items.forEach((item) => {
|
|
11922
|
+
this.enqueueTask(item, target, depExtendedData, deep);
|
|
11923
|
+
});
|
|
11924
|
+
}
|
|
11925
|
+
}
|
|
11715
11926
|
}
|
|
11716
11927
|
const depService = new Dep();
|
|
11717
11928
|
|
|
@@ -12285,6 +12496,7 @@
|
|
|
12285
12496
|
initDataSourceDepTarget(ds);
|
|
12286
12497
|
});
|
|
12287
12498
|
if (Array.isArray(value.items)) {
|
|
12499
|
+
depService.clearIdleTasks();
|
|
12288
12500
|
collectIdle(value.items, true);
|
|
12289
12501
|
} else {
|
|
12290
12502
|
depService.clear();
|
|
@@ -12309,10 +12521,20 @@
|
|
|
12309
12521
|
emit("update:modelValue", value);
|
|
12310
12522
|
}
|
|
12311
12523
|
};
|
|
12312
|
-
const
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
|
|
12524
|
+
const stage = vue.computed(() => editorService.get("stage"));
|
|
12525
|
+
vue.watch(stage, (stage2) => {
|
|
12526
|
+
if (!stage2) {
|
|
12527
|
+
return;
|
|
12528
|
+
}
|
|
12529
|
+
stage2.on("rerender", () => {
|
|
12530
|
+
const node = editorService.get("node");
|
|
12531
|
+
if (!node) return;
|
|
12532
|
+
collectIdle([node], true).then(() => {
|
|
12533
|
+
afterUpdateNodes([node]);
|
|
12534
|
+
});
|
|
12535
|
+
});
|
|
12536
|
+
});
|
|
12537
|
+
const getApp = () => stage.value?.renderer?.runtime?.getApp?.();
|
|
12316
12538
|
const updateDataSourceSchema = (nodes, deep) => {
|
|
12317
12539
|
const root = editorService.get("root");
|
|
12318
12540
|
const app = getApp();
|
|
@@ -12324,8 +12546,7 @@
|
|
|
12324
12546
|
if (root?.dataSources) {
|
|
12325
12547
|
getApp()?.dataSourceManager?.updateSchema(root.dataSources);
|
|
12326
12548
|
}
|
|
12327
|
-
|
|
12328
|
-
if (!root || !stage) return;
|
|
12549
|
+
if (!root || !stage.value) return;
|
|
12329
12550
|
const allNodes = [];
|
|
12330
12551
|
if (deep) {
|
|
12331
12552
|
nodes.forEach((node) => {
|
|
@@ -12342,7 +12563,7 @@
|
|
|
12342
12563
|
deps.forEach((dep) => {
|
|
12343
12564
|
Object.keys(dep).forEach((id) => {
|
|
12344
12565
|
const node = allNodes.find((node2) => node2.id === id);
|
|
12345
|
-
node && stage.update({
|
|
12566
|
+
node && stage.value?.update({
|
|
12346
12567
|
config: lodashEs.cloneDeep(node),
|
|
12347
12568
|
parentId: editorService.getParentById(node.id)?.id,
|
|
12348
12569
|
root: lodashEs.cloneDeep(root)
|
|
@@ -12353,13 +12574,8 @@
|
|
|
12353
12574
|
const afterUpdateNodes = (nodes) => {
|
|
12354
12575
|
const root = editorService.get("root");
|
|
12355
12576
|
if (!root) return;
|
|
12356
|
-
const stage = editorService.get("stage");
|
|
12357
|
-
const app = getApp();
|
|
12358
|
-
if (app?.dsl) {
|
|
12359
|
-
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
12360
|
-
}
|
|
12361
12577
|
for (const node of nodes) {
|
|
12362
|
-
stage?.update({
|
|
12578
|
+
stage.value?.update({
|
|
12363
12579
|
config: lodashEs.cloneDeep(node),
|
|
12364
12580
|
parentId: editorService.getParentById(node.id)?.id,
|
|
12365
12581
|
root: lodashEs.cloneDeep(root)
|
|
@@ -12392,8 +12608,17 @@
|
|
|
12392
12608
|
delete root.dataSourceCondDeps[id];
|
|
12393
12609
|
}
|
|
12394
12610
|
};
|
|
12611
|
+
const depCollectedHandler = () => {
|
|
12612
|
+
const root = editorService.get("root");
|
|
12613
|
+
if (!root) return;
|
|
12614
|
+
const app = getApp();
|
|
12615
|
+
if (app?.dsl) {
|
|
12616
|
+
app.dsl.dataSourceDeps = root.dataSourceDeps;
|
|
12617
|
+
}
|
|
12618
|
+
};
|
|
12395
12619
|
depService.on("add-target", targetAddHandler);
|
|
12396
12620
|
depService.on("remove-target", targetRemoveHandler);
|
|
12621
|
+
depService.on("collected", depCollectedHandler);
|
|
12397
12622
|
const initDataSourceDepTarget = (ds) => {
|
|
12398
12623
|
depService.addTarget(core.createDataSourceTarget(ds, vue.reactive({})));
|
|
12399
12624
|
depService.addTarget(core.createDataSourceMethodTarget(ds, vue.reactive({})));
|
|
@@ -12416,10 +12641,31 @@
|
|
|
12416
12641
|
afterUpdateNodes(nodes);
|
|
12417
12642
|
});
|
|
12418
12643
|
};
|
|
12419
|
-
const nodeUpdateHandler = (
|
|
12420
|
-
|
|
12421
|
-
|
|
12644
|
+
const nodeUpdateHandler = (data) => {
|
|
12645
|
+
const needRecollectNodes = [];
|
|
12646
|
+
const normalNodes = [];
|
|
12647
|
+
data.forEach(({ newNode, oldNode, changeRecords }) => {
|
|
12648
|
+
if (changeRecords?.length) {
|
|
12649
|
+
for (const record of changeRecords) {
|
|
12650
|
+
if (!record.propPath || new RegExp(`${core.NODE_CONDS_KEY}.(\\d)+.cond`).test(record.propPath) || new RegExp(`${core.NODE_CONDS_KEY}.(\\d)+.cond.(\\d)+.value`).test(record.propPath) || record.propPath === core.NODE_CONDS_KEY || utils.isValueIncludeDataSource(record.value)) {
|
|
12651
|
+
needRecollectNodes.push(newNode);
|
|
12652
|
+
} else {
|
|
12653
|
+
normalNodes.push(newNode);
|
|
12654
|
+
}
|
|
12655
|
+
}
|
|
12656
|
+
} else if (isIncludeDataSource(newNode, oldNode)) {
|
|
12657
|
+
needRecollectNodes.push(newNode);
|
|
12658
|
+
} else {
|
|
12659
|
+
normalNodes.push(newNode);
|
|
12660
|
+
}
|
|
12422
12661
|
});
|
|
12662
|
+
if (needRecollectNodes.length) {
|
|
12663
|
+
collectIdle(needRecollectNodes, true).then(() => {
|
|
12664
|
+
afterUpdateNodes(needRecollectNodes);
|
|
12665
|
+
});
|
|
12666
|
+
} else if (normalNodes.length) {
|
|
12667
|
+
afterUpdateNodes(normalNodes);
|
|
12668
|
+
}
|
|
12423
12669
|
};
|
|
12424
12670
|
const nodeRemoveHandler = (nodes) => {
|
|
12425
12671
|
depService.clear(nodes);
|
|
@@ -12450,13 +12696,30 @@
|
|
|
12450
12696
|
initDataSourceDepTarget(config);
|
|
12451
12697
|
getApp()?.dataSourceManager?.addDataSource(config);
|
|
12452
12698
|
};
|
|
12453
|
-
const dataSourceUpdateHandler = (config) => {
|
|
12699
|
+
const dataSourceUpdateHandler = (config, { changeRecords }) => {
|
|
12700
|
+
let needRecollectDep = false;
|
|
12701
|
+
for (const changeRecord of changeRecords) {
|
|
12702
|
+
if (!changeRecord.propPath) {
|
|
12703
|
+
continue;
|
|
12704
|
+
}
|
|
12705
|
+
needRecollectDep = changeRecord.propPath === "fields" || changeRecord.propPath === "methods" || /fields.(\d)+.name/.test(changeRecord.propPath) || /fields.(\d)+$/.test(changeRecord.propPath) || /methods.(\d)+.name/.test(changeRecord.propPath) || /methods.(\d)+$/.test(changeRecord.propPath);
|
|
12706
|
+
if (needRecollectDep) {
|
|
12707
|
+
break;
|
|
12708
|
+
}
|
|
12709
|
+
}
|
|
12454
12710
|
const root = editorService.get("root");
|
|
12455
|
-
|
|
12456
|
-
|
|
12457
|
-
|
|
12458
|
-
|
|
12459
|
-
|
|
12711
|
+
if (needRecollectDep) {
|
|
12712
|
+
if (Array.isArray(root?.items)) {
|
|
12713
|
+
depService.clearIdleTasks();
|
|
12714
|
+
removeDataSourceTarget(config.id);
|
|
12715
|
+
initDataSourceDepTarget(config);
|
|
12716
|
+
collectIdle(root.items, true).then(() => {
|
|
12717
|
+
updateDataSourceSchema(root?.items || [], true);
|
|
12718
|
+
});
|
|
12719
|
+
}
|
|
12720
|
+
} else if (root?.dataSources) {
|
|
12721
|
+
getApp()?.dataSourceManager?.updateSchema(root.dataSources);
|
|
12722
|
+
}
|
|
12460
12723
|
};
|
|
12461
12724
|
const removeDataSourceTarget = (id) => {
|
|
12462
12725
|
depService.removeTarget(id, core.DepTargetType.DATA_SOURCE);
|
|
@@ -12478,6 +12741,7 @@
|
|
|
12478
12741
|
vue.onBeforeUnmount(() => {
|
|
12479
12742
|
depService.off("add-target", targetAddHandler);
|
|
12480
12743
|
depService.off("remove-target", targetRemoveHandler);
|
|
12744
|
+
depService.off("collected", depCollectedHandler);
|
|
12481
12745
|
editorService.off("history-change", historyChangeHandler);
|
|
12482
12746
|
editorService.off("root-change", rootChangeHandler);
|
|
12483
12747
|
editorService.off("add", nodeAddHandler);
|
|
@@ -12846,6 +13110,7 @@
|
|
|
12846
13110
|
exports.getRelativeStyle = getRelativeStyle;
|
|
12847
13111
|
exports.historyService = historyService;
|
|
12848
13112
|
exports.info = info;
|
|
13113
|
+
exports.isIncludeDataSource = isIncludeDataSource;
|
|
12849
13114
|
exports.log = log;
|
|
12850
13115
|
exports.moveItemsInContainer = moveItemsInContainer;
|
|
12851
13116
|
exports.numberOptions = numberOptions;
|
|
@@ -12861,7 +13126,6 @@
|
|
|
12861
13126
|
exports.uiService = uiService;
|
|
12862
13127
|
exports.updateStatus = updateStatus;
|
|
12863
13128
|
exports.useCodeBlockEdit = useCodeBlockEdit;
|
|
12864
|
-
exports.useDataSourceMethod = useDataSourceMethod;
|
|
12865
13129
|
exports.useEditorContentHeight = useEditorContentHeight;
|
|
12866
13130
|
exports.useFilter = useFilter;
|
|
12867
13131
|
exports.useFloatBox = useFloatBox;
|