@tmagic/editor 1.5.0-beta.8 → 1.5.0

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.
Files changed (52) hide show
  1. package/dist/style.css +75 -16
  2. package/dist/tmagic-editor.js +797 -518
  3. package/dist/tmagic-editor.umd.cjs +802 -525
  4. package/package.json +13 -10
  5. package/src/Editor.vue +6 -1
  6. package/src/components/CodeBlockEditor.vue +11 -5
  7. package/src/components/CodeParams.vue +3 -3
  8. package/src/editorProps.ts +3 -1
  9. package/src/fields/Code.vue +1 -2
  10. package/src/fields/CodeSelect.vue +13 -11
  11. package/src/fields/CodeSelectCol.vue +32 -5
  12. package/src/fields/CondOpSelect.vue +5 -2
  13. package/src/fields/DataSourceFields.vue +31 -12
  14. package/src/fields/DataSourceMethods.vue +72 -14
  15. package/src/fields/DisplayConds.vue +8 -3
  16. package/src/fields/EventSelect.vue +28 -11
  17. package/src/fields/KeyValue.vue +15 -10
  18. package/src/fields/UISelect.vue +6 -3
  19. package/src/hooks/index.ts +0 -1
  20. package/src/hooks/use-code-block-edit.ts +1 -1
  21. package/src/hooks/use-data-source-edit.ts +3 -2
  22. package/src/hooks/use-filter.ts +1 -1
  23. package/src/hooks/use-node-status.ts +2 -2
  24. package/src/initService.ts +177 -74
  25. package/src/layouts/Framework.vue +8 -4
  26. package/src/layouts/PropsPanel.vue +3 -3
  27. package/src/layouts/page-bar/AddButton.vue +29 -9
  28. package/src/layouts/page-bar/PageBar.vue +78 -65
  29. package/src/layouts/page-bar/PageBarScrollContainer.vue +82 -96
  30. package/src/layouts/page-bar/PageList.vue +5 -3
  31. package/src/layouts/page-bar/Search.vue +67 -0
  32. package/src/layouts/sidebar/Sidebar.vue +3 -0
  33. package/src/layouts/sidebar/code-block/CodeBlockList.vue +6 -1
  34. package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +7 -5
  35. package/src/layouts/sidebar/data-source/DataSourceList.vue +6 -1
  36. package/src/layouts/sidebar/layer/use-node-status.ts +2 -3
  37. package/src/layouts/workspace/Workspace.vue +5 -2
  38. package/src/layouts/workspace/viewer/Stage.vue +23 -5
  39. package/src/services/dataSource.ts +12 -5
  40. package/src/services/dep.ts +61 -13
  41. package/src/services/editor.ts +46 -51
  42. package/src/theme/page-bar.scss +38 -16
  43. package/src/theme/search-input.scss +1 -0
  44. package/src/type.ts +2 -1
  45. package/src/utils/data-source/formConfigs/http.ts +2 -0
  46. package/src/utils/data-source/index.ts +2 -2
  47. package/src/utils/editor.ts +78 -22
  48. package/src/utils/idle-task.ts +36 -4
  49. package/src/utils/props.ts +3 -3
  50. package/types/index.d.ts +835 -1169
  51. package/src/hooks/use-data-source-method.ts +0 -100
  52. package/src/layouts/page-bar/SwitchTypeButton.vue +0 -45
@@ -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' } });
@@ -23,7 +23,7 @@
23
23
 
24
24
  const monaco__namespace = /*#__PURE__*/_interopNamespaceDefault(monaco);
25
25
 
26
- const _hoisted_1$w = ["src"];
26
+ const _hoisted_1$x = ["src"];
27
27
  const _sfc_main$Y = /* @__PURE__ */ vue.defineComponent({
28
28
  ...{
29
29
  name: "MEditorIcon"
@@ -48,7 +48,7 @@
48
48
  class: "magic-editor-icon"
49
49
  }, {
50
50
  default: vue.withCtx(() => [
51
- vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$w)
51
+ vue.createElementVNode("img", { src: _ctx.icon }, null, 8, _hoisted_1$x)
52
52
  ]),
53
53
  _: 1
54
54
  })) : typeof _ctx.icon === "string" ? (vue.openBlock(), vue.createElementBlock("i", {
@@ -76,7 +76,7 @@
76
76
  emmetMonacoEs.emmetHTML(monaco__namespace);
77
77
  emmetMonacoEs.emmetCSS(monaco__namespace, ["css", "scss"]);
78
78
 
79
- const _hoisted_1$v = {
79
+ const _hoisted_1$w = {
80
80
  class: /* @__PURE__ */ vue.normalizeClass(`magic-code-editor`)
81
81
  };
82
82
  const _sfc_main$X = /* @__PURE__ */ vue.defineComponent({
@@ -236,7 +236,7 @@
236
236
  }
237
237
  });
238
238
  return (_ctx, _cache) => {
239
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$v, [
239
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$w, [
240
240
  (vue.openBlock(), vue.createBlock(vue.Teleport, {
241
241
  to: "body",
242
242
  disabled: !fullScreen.value
@@ -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 = async () => {
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: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedBottom"
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: (vm, { model }) => model.position === "fixed" && model._magic_position === "fixedTop"
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: (vm, { model }) => model.type !== "page",
837
+ display: (_vm, { model }) => model.type !== "page",
840
838
  items: [
841
839
  {
842
840
  type: "display-conds",
@@ -1144,15 +1142,6 @@
1144
1142
  space: 2,
1145
1143
  unsafe: true
1146
1144
  }).replace(/"(\w+)":\s/g, "$1: ");
1147
- const traverseNode = (node, cb, parents = []) => {
1148
- cb(node, parents);
1149
- if (Array.isArray(node.items) && node.items.length) {
1150
- parents.push(node);
1151
- node.items.forEach((item) => {
1152
- traverseNode(item, cb, [...parents]);
1153
- });
1154
- }
1155
- };
1156
1145
  const moveItemsInContainer = (sourceIndices, parent, targetIndex) => {
1157
1146
  sourceIndices.sort((a, b) => a - b);
1158
1147
  for (let i = sourceIndices.length - 1; i >= 0; i--) {
@@ -1169,6 +1158,55 @@
1169
1158
  }
1170
1159
  }
1171
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
+ };
1172
1210
 
1173
1211
  const compose = (middleware, isAsync) => {
1174
1212
  if (!Array.isArray(middleware)) throw new TypeError("Middleware 必须是一个数组!");
@@ -1874,28 +1912,7 @@
1874
1912
  if (raw) {
1875
1913
  root = vue.toRaw(root);
1876
1914
  }
1877
- const info = {
1878
- node: null,
1879
- parent: null,
1880
- page: null
1881
- };
1882
- if (!root) return info;
1883
- if (id === root.id) {
1884
- info.node = root;
1885
- return info;
1886
- }
1887
- const path = utils.getNodePath(id, root.items);
1888
- if (!path.length) return info;
1889
- path.unshift(root);
1890
- info.node = path[path.length - 1];
1891
- info.parent = path[path.length - 2];
1892
- path.forEach((item) => {
1893
- if (utils.isPage(item) || utils.isPageFragment(item)) {
1894
- info.page = item;
1895
- return;
1896
- }
1897
- });
1898
- return info;
1915
+ return utils.getNodeInfo(id, root);
1899
1916
  }
1900
1917
  /**
1901
1918
  * 根据ID获取指点节点配置
@@ -2116,10 +2133,10 @@
2116
2133
  const rootItems = root.items || [];
2117
2134
  if (utils.isPage(node)) {
2118
2135
  this.state.pageLength -= 1;
2119
- await selectDefault(getPageList(root));
2136
+ await selectDefault(rootItems);
2120
2137
  } else if (utils.isPageFragment(node)) {
2121
2138
  this.state.pageFragmentLength -= 1;
2122
- await selectDefault(getPageFragmentList(root));
2139
+ await selectDefault(rootItems);
2123
2140
  } else {
2124
2141
  await this.select(parent);
2125
2142
  stage?.select(parent.id);
@@ -2142,13 +2159,13 @@
2142
2159
  }
2143
2160
  this.emit("remove", nodes);
2144
2161
  }
2145
- async doUpdate(config) {
2162
+ async doUpdate(config, { changeRecords = [] } = {}) {
2146
2163
  const root = this.get("root");
2147
2164
  if (!root) throw new Error("root为空");
2148
2165
  if (!config?.id) throw new Error("没有配置或者配置缺少id值");
2149
2166
  const info = this.getNodeInfo(config.id, false);
2150
2167
  if (!info.node) throw new Error(`获取不到id为${config.id}的节点`);
2151
- const node = lodashEs.cloneDeep(vue.toRaw(info.node));
2168
+ const node = vue.toRaw(info.node);
2152
2169
  let newConfig = await this.toggleFixedPosition(vue.toRaw(config), node, root);
2153
2170
  newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), newConfig, (objValue, srcValue, key) => {
2154
2171
  if (typeof srcValue === "undefined" && Object.hasOwn(newConfig, key)) {
@@ -2164,7 +2181,11 @@
2164
2181
  if (!newConfig.type) throw new Error("配置缺少type值");
2165
2182
  if (newConfig.type === core.NodeType.ROOT) {
2166
2183
  this.set("root", newConfig);
2167
- return newConfig;
2184
+ return {
2185
+ oldNode: node,
2186
+ newNode: newConfig,
2187
+ changeRecords
2188
+ };
2168
2189
  }
2169
2190
  const { parent } = info;
2170
2191
  if (!parent) throw new Error("获取不到父级节点");
@@ -2181,30 +2202,29 @@
2181
2202
  const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
2182
2203
  nodes.splice(targetIndex, 1, newConfig);
2183
2204
  this.set("nodes", [...nodes]);
2184
- this.get("stage")?.update({
2185
- config: lodashEs.cloneDeep(newConfig),
2186
- parentId: parent.id,
2187
- root: lodashEs.cloneDeep(root)
2188
- });
2189
2205
  if (utils.isPage(newConfig) || utils.isPageFragment(newConfig)) {
2190
2206
  this.set("page", newConfig);
2191
2207
  }
2192
2208
  this.addModifiedNodeId(newConfig.id);
2193
- return newConfig;
2209
+ return {
2210
+ oldNode: node,
2211
+ newNode: newConfig,
2212
+ changeRecords
2213
+ };
2194
2214
  }
2195
2215
  /**
2196
2216
  * 更新节点
2197
2217
  * @param config 新的节点配置,配置中需要有id信息
2198
2218
  * @returns 更新后的节点配置
2199
2219
  */
2200
- async update(config) {
2220
+ async update(config, data = {}) {
2201
2221
  const nodes = Array.isArray(config) ? config : [config];
2202
- const newNodes = await Promise.all(nodes.map((node) => this.doUpdate(node)));
2203
- if (newNodes[0]?.type !== core.NodeType.ROOT) {
2222
+ const updateData = await Promise.all(nodes.map((node) => this.doUpdate(node, data)));
2223
+ if (updateData[0].oldNode?.type !== core.NodeType.ROOT) {
2204
2224
  this.pushHistoryState();
2205
2225
  }
2206
- this.emit("update", newNodes);
2207
- return Array.isArray(config) ? newNodes : newNodes[0];
2226
+ this.emit("update", updateData);
2227
+ return Array.isArray(config) ? updateData.map((item) => item.newNode) : updateData[0].newNode;
2208
2228
  }
2209
2229
  /**
2210
2230
  * 将id为id1的组件移动到id为id2的组件位置上,例如:[1,2,3,4] -> sort(1,3) -> [2,1,3,4]
@@ -2398,7 +2418,7 @@
2398
2418
  parent.items?.splice(index, 1);
2399
2419
  await stage.remove({ id: node.id, parentId: parent.id, root: lodashEs.cloneDeep(root) });
2400
2420
  const layout = await this.getLayout(target);
2401
- const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (objValue, srcValue) => {
2421
+ const newConfig = lodashEs.mergeWith(lodashEs.cloneDeep(node), config, (_objValue, srcValue) => {
2402
2422
  if (Array.isArray(srcValue)) {
2403
2423
  return srcValue;
2404
2424
  }
@@ -2407,7 +2427,11 @@
2407
2427
  target.items.push(newConfig);
2408
2428
  await stage.select(targetId);
2409
2429
  const targetParent = this.getParentById(target.id);
2410
- await stage.update({ config: lodashEs.cloneDeep(target), parentId: targetParent?.id, root: lodashEs.cloneDeep(root) });
2430
+ await stage.update({
2431
+ config: lodashEs.cloneDeep(target),
2432
+ parentId: targetParent?.id,
2433
+ root: lodashEs.cloneDeep(root)
2434
+ });
2411
2435
  await this.select(newConfig);
2412
2436
  stage.select(newConfig.id);
2413
2437
  this.addModifiedNodeId(target.id);
@@ -2760,6 +2784,7 @@
2760
2784
  name: "params",
2761
2785
  type: "key-value",
2762
2786
  defaultValue: {},
2787
+ advanced: true,
2763
2788
  text: "参数"
2764
2789
  },
2765
2790
  {
@@ -2773,6 +2798,7 @@
2773
2798
  name: "headers",
2774
2799
  type: "key-value",
2775
2800
  defaultValue: {},
2801
+ advanced: true,
2776
2802
  text: "请求头"
2777
2803
  }
2778
2804
  ]
@@ -2827,7 +2853,7 @@
2827
2853
  },
2828
2854
  {
2829
2855
  title: "请求参数裁剪",
2830
- display: (formState, { model }) => model.type === "http",
2856
+ display: (_formState, { model }) => model.type === "http",
2831
2857
  items: [
2832
2858
  {
2833
2859
  name: "beforeRequest",
@@ -2839,7 +2865,7 @@
2839
2865
  },
2840
2866
  {
2841
2867
  title: "响应数据裁剪",
2842
- display: (formState, { model }) => model.type === "http",
2868
+ display: (_formState, { model }) => model.type === "http",
2843
2869
  items: [
2844
2870
  {
2845
2871
  name: "afterResponse",
@@ -3006,6 +3032,10 @@
3006
3032
  class IdleTask extends events.EventEmitter {
3007
3033
  taskList = [];
3008
3034
  taskHandle = null;
3035
+ constructor() {
3036
+ super();
3037
+ this.setMaxListeners(1e3);
3038
+ }
3009
3039
  enqueueTask(taskHandler, taskData) {
3010
3040
  this.taskList.push({
3011
3041
  handler: taskHandler,
@@ -3015,6 +3045,9 @@
3015
3045
  this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 1e4 });
3016
3046
  }
3017
3047
  }
3048
+ clearTasks() {
3049
+ this.taskList = [];
3050
+ }
3018
3051
  on(eventName, listener) {
3019
3052
  return super.on(eventName, listener);
3020
3053
  }
@@ -3025,12 +3058,30 @@
3025
3058
  return super.emit(eventName, ...args);
3026
3059
  }
3027
3060
  runTaskQueue(deadline) {
3028
- while ((deadline.timeRemaining() > 15 || deadline.didTimeout) && this.taskList.length) {
3029
- const task = this.taskList.shift();
3030
- task.handler(task.data);
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
+ }
3031
3082
  }
3032
3083
  if (this.taskList.length) {
3033
- this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 1e4 });
3084
+ this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 300 });
3034
3085
  } else {
3035
3086
  this.taskHandle = 0;
3036
3087
  this.emit("finish");
@@ -3212,10 +3263,10 @@
3212
3263
  }))
3213
3264
  )
3214
3265
  );
3215
- const onParamsChangeHandler = async () => {
3266
+ const onParamsChangeHandler = async (v, eventData) => {
3216
3267
  try {
3217
3268
  const value = await form.value?.submitForm(true);
3218
- emit("change", value);
3269
+ emit("change", value, eventData);
3219
3270
  } catch (e) {
3220
3271
  error(e);
3221
3272
  }
@@ -3235,8 +3286,8 @@
3235
3286
  }
3236
3287
  });
3237
3288
 
3238
- const _hoisted_1$u = { class: "m-fields-code-select-col" };
3239
- const _hoisted_2$g = { class: "code-select-container" };
3289
+ const _hoisted_1$v = { class: "m-fields-code-select-col" };
3290
+ const _hoisted_2$h = { class: "code-select-container" };
3240
3291
  const _sfc_main$S = /* @__PURE__ */ vue.defineComponent({
3241
3292
  ...{
3242
3293
  name: "MFieldsCodeSelectCol"
@@ -3308,22 +3359,39 @@
3308
3359
  return codeId;
3309
3360
  }
3310
3361
  };
3311
- const onParamsChangeHandler = (value) => {
3362
+ const onCodeIdChangeHandler = (value) => {
3312
3363
  props.model.params = value.params;
3313
- 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
+ });
3314
3382
  };
3315
3383
  const editCode = (id) => {
3316
3384
  eventBus?.emit("edit-code", id);
3317
3385
  };
3318
3386
  return (_ctx, _cache) => {
3319
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$u, [
3320
- vue.createElementVNode("div", _hoisted_2$g, [
3387
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$v, [
3388
+ vue.createElementVNode("div", _hoisted_2$h, [
3321
3389
  vue.createVNode(vue.unref(formPlugin.MContainer), {
3322
3390
  class: "select",
3323
3391
  config: selectConfig,
3324
3392
  model: _ctx.model,
3325
3393
  size: _ctx.size,
3326
- onChange: onParamsChangeHandler
3394
+ onChange: onCodeIdChangeHandler
3327
3395
  }, null, 8, ["model", "size"]),
3328
3396
  _ctx.model[_ctx.name] && hasCodeBlockSidePanel.value ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicButton), {
3329
3397
  key: 0,
@@ -3622,7 +3690,7 @@
3622
3690
  }
3623
3691
  codeConfig.value = {
3624
3692
  name: "",
3625
- content: `({app, params}) => {
3693
+ content: `({app, params, flowState}) => {
3626
3694
  // place your code here
3627
3695
  }`,
3628
3696
  params: []
@@ -3668,78 +3736,6 @@
3668
3736
  };
3669
3737
  };
3670
3738
 
3671
- const useDataSourceMethod = () => {
3672
- const codeConfig = vue.ref();
3673
- const codeBlockEditor = vue.ref();
3674
- const dataSource = vue.ref();
3675
- const dataSourceMethod = vue.ref("");
3676
- return {
3677
- codeConfig,
3678
- codeBlockEditor,
3679
- createCode: async (model) => {
3680
- codeConfig.value = {
3681
- name: "",
3682
- content: `({ params, dataSource, app }) => {
3683
- // place your code here
3684
- }`,
3685
- params: []
3686
- };
3687
- await vue.nextTick();
3688
- dataSource.value = model;
3689
- dataSourceMethod.value = "";
3690
- codeBlockEditor.value?.show();
3691
- },
3692
- editCode: async (model, methodName) => {
3693
- const method = model.methods?.find((method2) => method2.name === methodName);
3694
- if (!method) {
3695
- designPlugin.tMagicMessage.error("获取数据源方法失败");
3696
- return;
3697
- }
3698
- let codeContent = method.content || `({ params, dataSource, app }) => {
3699
- // place your code here
3700
- }`;
3701
- if (typeof codeContent !== "string") {
3702
- codeContent = codeContent.toString();
3703
- }
3704
- codeConfig.value = {
3705
- ...lodashEs.cloneDeep(method),
3706
- content: codeContent
3707
- };
3708
- await vue.nextTick();
3709
- dataSource.value = model;
3710
- dataSourceMethod.value = methodName;
3711
- codeBlockEditor.value?.show();
3712
- },
3713
- deleteCode: async (model, methodName) => {
3714
- if (!model.methods) return;
3715
- const index = model.methods.findIndex((method) => method.name === methodName);
3716
- if (index === -1) {
3717
- return;
3718
- }
3719
- model.methods.splice(index, 1);
3720
- },
3721
- submitCode: (values) => {
3722
- if (!dataSource.value) return;
3723
- if (!dataSource.value.methods) {
3724
- dataSource.value.methods = [];
3725
- }
3726
- if (values.content) {
3727
- const parseDSL = getEditorConfig("parseDSL");
3728
- if (typeof values.content === "string") {
3729
- values.content = parseDSL(values.content);
3730
- }
3731
- }
3732
- if (dataSourceMethod.value) {
3733
- const index = dataSource.value.methods.findIndex((method) => method.name === dataSourceMethod.value);
3734
- dataSource.value.methods.splice(index, 1, values);
3735
- } else {
3736
- dataSource.value.methods.push(values);
3737
- }
3738
- codeBlockEditor.value?.hide();
3739
- }
3740
- };
3741
- };
3742
-
3743
3739
  const state = vue.reactive({
3744
3740
  uiSelectMode: false,
3745
3741
  showSrc: false,
@@ -4078,7 +4074,7 @@
4078
4074
  const filter = (text) => {
4079
4075
  if (!nodeData.value.length) return;
4080
4076
  nodeData.value.forEach((node) => {
4081
- traverseNode(node, (node2, parents) => {
4077
+ utils.traverseNode(node, (node2, parents) => {
4082
4078
  if (!nodeStatusMap.value) return;
4083
4079
  const visible = filterIsMatch(text, node2);
4084
4080
  if (visible && parents.length) {
@@ -4156,7 +4152,7 @@
4156
4152
  const createPageNodeStatus$1 = (nodeData, initialLayerNodeStatus) => {
4157
4153
  const map = /* @__PURE__ */ new Map();
4158
4154
  nodeData.forEach(
4159
- (node) => traverseNode(node, (node2) => {
4155
+ (node) => utils.traverseNode(node, (node2) => {
4160
4156
  map.set(
4161
4157
  node2.id,
4162
4158
  initialLayerNodeStatus?.get(node2.id) || {
@@ -4187,8 +4183,8 @@
4187
4183
  };
4188
4184
  };
4189
4185
 
4190
- const _hoisted_1$t = { class: "m-editor-data-source-fields" };
4191
- const _hoisted_2$f = { class: "m-editor-data-source-fields-footer" };
4186
+ const _hoisted_1$u = { class: "m-editor-data-source-fields" };
4187
+ const _hoisted_2$g = { class: "m-editor-data-source-fields-footer" };
4192
4188
  const _sfc_main$P = /* @__PURE__ */ vue.defineComponent({
4193
4189
  ...{
4194
4190
  name: "MFieldsDataSourceFields"
@@ -4226,14 +4222,28 @@
4226
4222
  calcBoxPosition();
4227
4223
  addDialogVisible.value = true;
4228
4224
  };
4229
- const fieldChange = ({ index, ...value }) => {
4225
+ const fieldChange = ({ index, ...value }, data) => {
4226
+ addDialogVisible.value = false;
4230
4227
  if (index > -1) {
4231
- props.model[props.name][index] = value;
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
+ });
4232
4235
  } else {
4233
- props.model[props.name].push(value);
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
+ });
4234
4246
  }
4235
- addDialogVisible.value = false;
4236
- emit("change", props.model[props.name]);
4237
4247
  };
4238
4248
  const fieldColumns = [
4239
4249
  {
@@ -4427,9 +4437,8 @@
4427
4437
  const addFromJsonFromChange = ({ data }) => {
4428
4438
  try {
4429
4439
  const value = JSON.parse(data);
4430
- props.model[props.name] = getFieldsConfig(value, props.model[props.name]);
4431
4440
  addFromJsonDialogVisible.value = false;
4432
- emit("change", props.model[props.name]);
4441
+ emit("change", getFieldsConfig(value, props.model[props.name]));
4433
4442
  } catch (e) {
4434
4443
  designPlugin.tMagicMessage.error(e.message);
4435
4444
  }
@@ -4440,12 +4449,12 @@
4440
4449
  const parentFloating = vue.inject("parentFloating", vue.ref(null));
4441
4450
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
4442
4451
  return (_ctx, _cache) => {
4443
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$t, [
4452
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$u, [
4444
4453
  vue.createVNode(vue.unref(tablePlugin.MagicTable), {
4445
4454
  data: _ctx.model[_ctx.name],
4446
4455
  columns: fieldColumns
4447
4456
  }, null, 8, ["data"]),
4448
- vue.createElementVNode("div", _hoisted_2$f, [
4457
+ vue.createElementVNode("div", _hoisted_2$g, [
4449
4458
  vue.createVNode(vue.unref(designPlugin.TMagicButton), {
4450
4459
  size: "small",
4451
4460
  disabled: _ctx.disabled,
@@ -4518,7 +4527,7 @@
4518
4527
  }
4519
4528
  });
4520
4529
 
4521
- const _hoisted_1$s = { class: "m-editor-data-source-field-select" };
4530
+ const _hoisted_1$t = { class: "m-editor-data-source-field-select" };
4522
4531
  const _sfc_main$O = /* @__PURE__ */ vue.defineComponent({
4523
4532
  __name: "FieldSelect",
4524
4533
  props: /* @__PURE__ */ vue.mergeModels({
@@ -4600,7 +4609,7 @@
4600
4609
  eventBus?.emit("edit-data-source", removeDataSourceFieldPrefix(id));
4601
4610
  };
4602
4611
  return (_ctx, _cache) => {
4603
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$s, [
4612
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$t, [
4604
4613
  _ctx.checkStrictly ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
4605
4614
  vue.createVNode(vue.unref(designPlugin.TMagicSelect), {
4606
4615
  "model-value": selectDataSourceId.value,
@@ -4682,7 +4691,7 @@
4682
4691
  }
4683
4692
  });
4684
4693
 
4685
- const _hoisted_1$r = { class: "m-fields-data-source-field-select" };
4694
+ const _hoisted_1$s = { class: "m-fields-data-source-field-select" };
4686
4695
  const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
4687
4696
  ...{
4688
4697
  name: "MFieldsDataSourceFieldSelect"
@@ -4784,7 +4793,7 @@
4784
4793
  }
4785
4794
  };
4786
4795
  return (_ctx, _cache) => {
4787
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$r, [
4796
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$s, [
4788
4797
  showDataSourceFieldSelect.value || !_ctx.config.fieldConfig ? (vue.openBlock(), vue.createBlock(_sfc_main$O, {
4789
4798
  key: 0,
4790
4799
  "model-value": _ctx.model[_ctx.name],
@@ -4832,8 +4841,8 @@
4832
4841
  }
4833
4842
  });
4834
4843
 
4835
- const _hoisted_1$q = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
4836
- const _hoisted_2$e = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
4844
+ const _hoisted_1$r = { style: { "display": "flex", "flex-direction": "column", "line-height": "1.2em" } };
4845
+ const _hoisted_2$f = { style: { "font-size": "10px", "color": "rgba(0, 0, 0, 0.6)" } };
4837
4846
  const _hoisted_3$4 = { class: "el-input__inner t-input__inner" };
4838
4847
  const _sfc_main$M = /* @__PURE__ */ vue.defineComponent({
4839
4848
  ...{
@@ -5038,9 +5047,9 @@
5038
5047
  vue.createVNode(_sfc_main$Y, { icon: vue.unref(iconsVue.Coin) }, null, 8, ["icon"])
5039
5048
  ]),
5040
5049
  default: vue.withCtx(({ item }) => [
5041
- vue.createElementVNode("div", _hoisted_1$q, [
5050
+ vue.createElementVNode("div", _hoisted_1$r, [
5042
5051
  vue.createElementVNode("div", null, vue.toDisplayString(item.text), 1),
5043
- vue.createElementVNode("span", _hoisted_2$e, vue.toDisplayString(item.value), 1)
5052
+ vue.createElementVNode("span", _hoisted_2$f, vue.toDisplayString(item.value), 1)
5044
5053
  ])
5045
5054
  ]),
5046
5055
  _: 1
@@ -5081,8 +5090,8 @@
5081
5090
  }
5082
5091
  });
5083
5092
 
5084
- const _hoisted_1$p = { style: { "display": "flex", "margin-bottom": "10px" } };
5085
- const _hoisted_2$d = { style: { "flex": "1" } };
5093
+ const _hoisted_1$q = { style: { "display": "flex", "margin-bottom": "10px" } };
5094
+ const _hoisted_2$e = { style: { "flex": "1" } };
5086
5095
  const _hoisted_3$3 = { style: { "flex": "1" } };
5087
5096
  const _hoisted_4$3 = { class: "dialog-footer" };
5088
5097
  const _sfc_main$L = /* @__PURE__ */ vue.defineComponent({
@@ -5213,9 +5222,9 @@
5213
5222
  }
5214
5223
  }
5215
5224
  ]);
5216
- const submitForm = (values) => {
5225
+ const submitForm = (values, data) => {
5217
5226
  changedValue.value = void 0;
5218
- emit("submit", values);
5227
+ emit("submit", values, data);
5219
5228
  };
5220
5229
  const errorHandler = (error) => {
5221
5230
  designPlugin.tMagicMessage.error(error.message);
@@ -5236,7 +5245,7 @@
5236
5245
  type: "warning",
5237
5246
  distinguishCancelAndClose: true
5238
5247
  }).then(() => {
5239
- changedValue.value && submitForm(changedValue.value);
5248
+ changedValue.value && submitForm(changedValue.value, { changeRecords: formBox.value?.form?.changeRecords });
5240
5249
  done();
5241
5250
  }).catch((action) => {
5242
5251
  done(action === "cancel");
@@ -5335,8 +5344,8 @@
5335
5344
  ])
5336
5345
  ]),
5337
5346
  default: vue.withCtx(() => [
5338
- vue.createElementVNode("div", _hoisted_1$p, [
5339
- vue.createElementVNode("div", _hoisted_2$d, [
5347
+ vue.createElementVNode("div", _hoisted_1$q, [
5348
+ vue.createElementVNode("div", _hoisted_2$e, [
5340
5349
  vue.createVNode(vue.unref(designPlugin.TMagicTag), {
5341
5350
  size: "small",
5342
5351
  type: "info"
@@ -5378,8 +5387,8 @@
5378
5387
  }
5379
5388
  });
5380
5389
 
5381
- const _hoisted_1$o = { class: "m-editor-data-source-methods" };
5382
- const _hoisted_2$c = { class: "m-editor-data-source-methods-footer" };
5390
+ const _hoisted_1$p = { class: "m-editor-data-source-methods" };
5391
+ const _hoisted_2$d = { class: "m-editor-data-source-methods-footer" };
5383
5392
  const _sfc_main$K = /* @__PURE__ */ vue.defineComponent({
5384
5393
  ...{
5385
5394
  name: "MFieldsDataSourceMethods"
@@ -5400,7 +5409,9 @@
5400
5409
  setup(__props, { emit: __emit }) {
5401
5410
  const props = __props;
5402
5411
  const emit = __emit;
5403
- const { codeConfig, codeBlockEditor, createCode, editCode, deleteCode, submitCode } = useDataSourceMethod();
5412
+ const codeConfig = vue.ref();
5413
+ const codeBlockEditor = vue.ref();
5414
+ let editIndex = -1;
5404
5415
  const methodColumns = [
5405
5416
  {
5406
5417
  label: "名称",
@@ -5425,16 +5436,29 @@
5425
5436
  actions: [
5426
5437
  {
5427
5438
  text: "编辑",
5428
- handler: (row) => {
5429
- editCode(props.model, row.name);
5430
- emit("change", props.model[props.name]);
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
+ });
5431
5454
  }
5432
5455
  },
5433
5456
  {
5434
5457
  text: "删除",
5435
5458
  buttonType: "danger",
5436
- handler: (row) => {
5437
- deleteCode(props.model, row.name);
5459
+ handler: async (row, index) => {
5460
+ await designPlugin.tMagicMessageBox.confirm(`确定删除${row.name}?`, "提示");
5461
+ props.model[props.name].splice(index, 1);
5438
5462
  emit("change", props.model[props.name]);
5439
5463
  }
5440
5464
  }
@@ -5442,20 +5466,56 @@
5442
5466
  }
5443
5467
  ];
5444
5468
  const createCodeHandler = () => {
5445
- createCode(props.model);
5446
- emit("change", props.model[props.name]);
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
+ });
5447
5480
  };
5448
- const submitCodeHandler = (values) => {
5449
- submitCode(values);
5450
- emit("change", props.model[props.name]);
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();
5451
5511
  };
5452
5512
  return (_ctx, _cache) => {
5453
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$o, [
5513
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$p, [
5454
5514
  vue.createVNode(vue.unref(tablePlugin.MagicTable), {
5455
5515
  data: _ctx.model[_ctx.name],
5456
5516
  columns: methodColumns
5457
5517
  }, null, 8, ["data"]),
5458
- vue.createElementVNode("div", _hoisted_2$c, [
5518
+ vue.createElementVNode("div", _hoisted_2$d, [
5459
5519
  vue.createVNode(vue.unref(designPlugin.TMagicButton), {
5460
5520
  size: "small",
5461
5521
  type: "primary",
@@ -5469,12 +5529,12 @@
5469
5529
  _: 1
5470
5530
  }, 8, ["disabled"])
5471
5531
  ]),
5472
- vue.unref(codeConfig) ? (vue.openBlock(), vue.createBlock(_sfc_main$L, {
5532
+ codeConfig.value ? (vue.openBlock(), vue.createBlock(_sfc_main$L, {
5473
5533
  key: 0,
5474
5534
  ref_key: "codeBlockEditor",
5475
5535
  ref: codeBlockEditor,
5476
5536
  disabled: _ctx.disabled,
5477
- content: vue.unref(codeConfig),
5537
+ content: codeConfig.value,
5478
5538
  "is-data-source": true,
5479
5539
  "data-source-type": _ctx.model.type,
5480
5540
  onSubmit: submitCodeHandler
@@ -5484,8 +5544,8 @@
5484
5544
  }
5485
5545
  });
5486
5546
 
5487
- const _hoisted_1$n = { class: "m-fields-data-source-method-select" };
5488
- const _hoisted_2$b = { class: "data-source-method-select-container" };
5547
+ const _hoisted_1$o = { class: "m-fields-data-source-method-select" };
5548
+ const _hoisted_2$c = { class: "data-source-method-select-container" };
5489
5549
  const _sfc_main$J = /* @__PURE__ */ vue.defineComponent({
5490
5550
  ...{
5491
5551
  name: "MFieldsDataSourceMethodSelect"
@@ -5572,8 +5632,8 @@
5572
5632
  eventBus?.emit("edit-data-source", id);
5573
5633
  };
5574
5634
  return (_ctx, _cache) => {
5575
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$n, [
5576
- vue.createElementVNode("div", _hoisted_2$b, [
5635
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$o, [
5636
+ vue.createElementVNode("div", _hoisted_2$c, [
5577
5637
  vue.createVNode(vue.unref(formPlugin.MContainer), {
5578
5638
  class: "select",
5579
5639
  config: cascaderConfig.value,
@@ -5616,8 +5676,8 @@
5616
5676
  }
5617
5677
  });
5618
5678
 
5619
- const _hoisted_1$m = { class: "m-editor-data-source-fields" };
5620
- const _hoisted_2$a = { class: "m-editor-data-source-fields-footer" };
5679
+ const _hoisted_1$n = { class: "m-editor-data-source-fields" };
5680
+ const _hoisted_2$b = { class: "m-editor-data-source-fields-footer" };
5621
5681
  const _sfc_main$I = /* @__PURE__ */ vue.defineComponent({
5622
5682
  ...{
5623
5683
  name: "MFieldsDataSourceMocks"
@@ -5822,12 +5882,12 @@
5822
5882
  const parentFloating = vue.inject("parentFloating", vue.ref(null));
5823
5883
  const { boxPosition, calcBoxPosition } = useNextFloatBoxPosition(services?.uiService, parentFloating);
5824
5884
  return (_ctx, _cache) => {
5825
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$m, [
5885
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$n, [
5826
5886
  vue.createVNode(vue.unref(tablePlugin.MagicTable), {
5827
5887
  data: _ctx.model[_ctx.name],
5828
5888
  columns
5829
5889
  }, null, 8, ["data"]),
5830
- vue.createElementVNode("div", _hoisted_2$a, [
5890
+ vue.createElementVNode("div", _hoisted_2$b, [
5831
5891
  vue.createVNode(vue.unref(designPlugin.TMagicButton), {
5832
5892
  size: "small",
5833
5893
  type: "primary",
@@ -5869,7 +5929,7 @@
5869
5929
  }
5870
5930
  });
5871
5931
 
5872
- const _hoisted_1$l = { class: "m-fields-data-source-select" };
5932
+ const _hoisted_1$m = { class: "m-fields-data-source-select" };
5873
5933
  const _sfc_main$H = /* @__PURE__ */ vue.defineComponent({
5874
5934
  ...{
5875
5935
  name: "MFieldsDataSourceSelect"
@@ -5927,7 +5987,7 @@
5927
5987
  eventBus?.emit("edit-data-source", id);
5928
5988
  };
5929
5989
  return (_ctx, _cache) => {
5930
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$l, [
5990
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$m, [
5931
5991
  vue.createVNode(vue.unref(formPlugin.MSelect), {
5932
5992
  model: _ctx.model,
5933
5993
  name: _ctx.name,
@@ -6072,8 +6132,11 @@
6072
6132
  }
6073
6133
  ]
6074
6134
  }));
6075
- const changeHandler = (v) => {
6076
- emit("change", v);
6135
+ const changeHandler = (v, eventData) => {
6136
+ if (!Array.isArray(props.model[props.name])) {
6137
+ props.model[props.name] = [];
6138
+ }
6139
+ emit("change", v, eventData);
6077
6140
  };
6078
6141
  return (_ctx, _cache) => {
6079
6142
  return vue.openBlock(), vue.createBlock(vue.unref(formPlugin.MGroupList), {
@@ -6091,8 +6154,8 @@
6091
6154
  }
6092
6155
  });
6093
6156
 
6094
- const _hoisted_1$k = { class: "m-fields-event-select" };
6095
- const _hoisted_2$9 = {
6157
+ const _hoisted_1$l = { class: "m-fields-event-select" };
6158
+ const _hoisted_2$a = {
6096
6159
  key: 1,
6097
6160
  class: "fullWidth"
6098
6161
  };
@@ -6144,13 +6207,13 @@
6144
6207
  if (pageFragment) {
6145
6208
  events = [
6146
6209
  {
6147
- label: pageFragment.name || "迭代器容器",
6210
+ label: pageFragment.name || "页面片容器",
6148
6211
  value: pageFragment.id,
6149
6212
  children: events
6150
6213
  }
6151
6214
  ];
6152
6215
  pageFragment.items.forEach((node) => {
6153
- traverseNode(node, (node2) => {
6216
+ utils.traverseNode(node, (node2) => {
6154
6217
  const nodeEvents = node2.type && eventsService.getEvent(node2.type) || [];
6155
6218
  events.push({
6156
6219
  label: `${node2.name}_${node2.id}`,
@@ -6251,7 +6314,7 @@
6251
6314
  if (pageFragment) {
6252
6315
  methods = [];
6253
6316
  pageFragment.items.forEach((node2) => {
6254
- traverseNode(node2, (node3) => {
6317
+ utils.traverseNode(node2, (node3) => {
6255
6318
  const nodeMethods = node3.type && eventsService?.getMethod(node3.type) || [];
6256
6319
  if (nodeMethods.length) {
6257
6320
  methods.push({
@@ -6357,20 +6420,22 @@
6357
6420
  if (!props.model[props.name]) {
6358
6421
  props.model[props.name] = [];
6359
6422
  }
6360
- props.model[props.name].push(defaultEvent);
6361
- onChangeHandler();
6423
+ emit("change", defaultEvent, {
6424
+ modifyKey: props.model[props.name].length
6425
+ });
6362
6426
  };
6363
6427
  const removeEvent = (index) => {
6364
6428
  if (!props.name) return;
6365
6429
  props.model[props.name].splice(index, 1);
6366
- onChangeHandler();
6430
+ emit("change", props.model[props.name]);
6367
6431
  };
6368
- const onChangeHandler = () => {
6369
- emit("change", props.model);
6432
+ const eventNameChangeHandler = (v, eventData) => {
6433
+ emit("change", props.model[props.name], eventData);
6370
6434
  };
6435
+ const onChangeHandler = (v, eventData) => emit("change", props.model[props.name], eventData);
6371
6436
  return (_ctx, _cache) => {
6372
6437
  const _component_m_form_table = vue.resolveComponent("m-form-table");
6373
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$k, [
6438
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$l, [
6374
6439
  isOldVersion.value ? (vue.openBlock(), vue.createBlock(_component_m_form_table, {
6375
6440
  key: 0,
6376
6441
  ref: "eventForm",
@@ -6380,7 +6445,7 @@
6380
6445
  model: _ctx.model,
6381
6446
  config: tableConfig.value,
6382
6447
  onChange: onChangeHandler
6383
- }, null, 8, ["size", "disabled", "model", "config"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$9, [
6448
+ }, null, 8, ["size", "disabled", "model", "config"])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$a, [
6384
6449
  vue.createVNode(vue.unref(designPlugin.TMagicButton), {
6385
6450
  class: "create-button",
6386
6451
  type: "primary",
@@ -6398,6 +6463,7 @@
6398
6463
  key: index,
6399
6464
  disabled: _ctx.disabled,
6400
6465
  size: _ctx.size,
6466
+ prop: `${_ctx.prop}.${index}`,
6401
6467
  config: actionsConfig.value,
6402
6468
  model: cardItem,
6403
6469
  "label-width": _ctx.config.labelWidth || "100px",
@@ -6410,8 +6476,9 @@
6410
6476
  model: cardItem,
6411
6477
  disabled: _ctx.disabled,
6412
6478
  size: _ctx.size,
6413
- onChange: onChangeHandler
6414
- }, null, 8, ["config", "model", "disabled", "size"]),
6479
+ prop: `${_ctx.prop}.${index}`,
6480
+ onChange: eventNameChangeHandler
6481
+ }, null, 8, ["config", "model", "disabled", "size", "prop"]),
6415
6482
  vue.createVNode(vue.unref(designPlugin.TMagicButton), {
6416
6483
  style: { "color": "#f56c6c" },
6417
6484
  link: "",
@@ -6422,7 +6489,7 @@
6422
6489
  }, null, 8, ["icon", "disabled", "size", "onClick"])
6423
6490
  ]),
6424
6491
  _: 2
6425
- }, 1032, ["disabled", "size", "config", "model", "label-width"]);
6492
+ }, 1032, ["disabled", "size", "prop", "config", "model", "label-width"]);
6426
6493
  }), 128))
6427
6494
  ]))
6428
6495
  ]);
@@ -6430,7 +6497,7 @@
6430
6497
  }
6431
6498
  });
6432
6499
 
6433
- const _hoisted_1$j = {
6500
+ const _hoisted_1$k = {
6434
6501
  viewBox: "0 0 32 32",
6435
6502
  version: "1.1",
6436
6503
  xmlns: "http://www.w3.org/2000/svg",
@@ -6443,15 +6510,15 @@
6443
6510
  __name: "CodeIcon",
6444
6511
  setup(__props) {
6445
6512
  return (_ctx, _cache) => {
6446
- return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$j, _cache[0] || (_cache[0] = [
6513
+ return vue.openBlock(), vue.createElementBlock("svg", _hoisted_1$k, _cache[0] || (_cache[0] = [
6447
6514
  vue.createStaticVNode('<defs><rect id="path-1" x="0" y="0" width="32" height="32"></rect></defs><g id="组件规范" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="03图标" transform="translate(-561.000000, -2356.000000)"><g id="icon/line/Universal/code" transform="translate(561.000000, 2356.000000)"><g id="路径"><mask id="mask-2" fill="white"><use xlink:href="#path-1"></use></mask><use id="蒙版" fill="#D8D8D8" opacity="0" xlink:href="#path-1"></use><path d="M21.9284587,7.9482233 L29.8079004,15.827665 C29.9055315,15.9252961 29.9055315,16.0835874 29.8079004,16.1812184 L21.9284587,24.0606602 C21.8308276,24.1582912 21.6725364,24.1582912 21.5749053,24.0606602 L20.3374684,22.8232233 C20.2419143,22.7276698 20.2398813,22.5740096 20.331369,22.4759832 L20.3374687,22.4696702 L26.8027181,16.0044417 L20.3374687,9.53921328 C20.2398372,9.44158265 20.2398369,9.2832914 20.3374679,9.18566017 L21.5749053,7.9482233 C21.6725364,7.85059223 21.8308276,7.85059223 21.9284587,7.9482233 Z M10.3999684,7.9482233 L11.6374053,9.18566017 C11.7329594,9.28121371 11.7349925,9.43487387 11.6435048,9.53290029 L11.637405,9.53921328 L5.17215562,16.0044417 L11.637405,22.4696702 C11.7329593,22.5652236 11.7349926,22.7188837 11.643505,22.8169103 L11.6374053,22.8232233 L10.3999684,24.0606602 C10.3023374,24.1582912 10.1440461,24.1582912 10.046415,24.0606602 L2.1669733,16.1812184 C2.06934223,16.0835874 2.06934223,15.9252961 2.1669733,15.827665 L10.046415,7.9482233 C10.1440461,7.85059223 10.3023374,7.85059223 10.3999684,7.9482233 Z M17.2612532,9.29310422 L18.9262468,9.83189578 C19.0576112,9.87440526 19.1296423,10.0153579 19.0871328,10.1467222 L15.0848232,22.514807 C15.0423138,22.6461714 14.9013612,22.7182025 14.7699968,22.675693 L13.1050032,22.1369014 C12.9736388,22.0943919 12.9016077,21.9534393 12.9441172,21.822075 L16.9464268,9.45399022 C16.9889362,9.32262585 17.1298888,9.25059474 17.2612532,9.29310422 Z" id="形状" fill="#1D1F24" mask="url(#mask-2)"></path></g></g><g id="icon切图" transform="translate(226.000000, 1782.000000)"></g></g></g>', 2)
6448
6515
  ]));
6449
6516
  };
6450
6517
  }
6451
6518
  });
6452
6519
 
6453
- const _hoisted_1$i = { class: "m-fields-key-value" };
6454
- const _hoisted_2$8 = { key: 0 };
6520
+ const _hoisted_1$j = { class: "m-fields-key-value" };
6521
+ const _hoisted_2$9 = { key: 0 };
6455
6522
  const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
6456
6523
  ...{
6457
6524
  name: "MFieldsKeyValue"
@@ -6475,14 +6542,18 @@
6475
6542
  const records = vue.ref([]);
6476
6543
  const showCode = vue.ref(false);
6477
6544
  vue.watchEffect(() => {
6478
- const initValues = Object.entries(props.model[props.name] || {});
6479
- for (const [, value] of initValues) {
6480
- if (typeof value !== "string") {
6481
- showCode.value = true;
6482
- break;
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
+ }
6483
6554
  }
6555
+ records.value = initValues;
6484
6556
  }
6485
- records.value = initValues;
6486
6557
  });
6487
6558
  const getValue = () => {
6488
6559
  const record = {};
@@ -6510,8 +6581,8 @@
6510
6581
  emit("change", v);
6511
6582
  };
6512
6583
  return (_ctx, _cache) => {
6513
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$i, [
6514
- !showCode.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$8, [
6584
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$j, [
6585
+ !showCode.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$9, [
6515
6586
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(records.value, (item, index) => {
6516
6587
  return vue.openBlock(), vue.createElementBlock("div", {
6517
6588
  class: "m-fields-key-value-item",
@@ -6564,7 +6635,7 @@
6564
6635
  key: 1,
6565
6636
  height: "200px",
6566
6637
  "init-values": _ctx.model[_ctx.name],
6567
- language: "json",
6638
+ language: "javascript",
6568
6639
  options: {
6569
6640
  readOnly: _ctx.disabled
6570
6641
  },
@@ -6584,8 +6655,8 @@
6584
6655
  }
6585
6656
  });
6586
6657
 
6587
- const _hoisted_1$h = { class: "m-fields-page-fragment-select" };
6588
- const _hoisted_2$7 = { class: "page-fragment-select-container" };
6658
+ const _hoisted_1$i = { class: "m-fields-page-fragment-select" };
6659
+ const _hoisted_2$8 = { class: "page-fragment-select-container" };
6589
6660
  const _sfc_main$C = /* @__PURE__ */ vue.defineComponent({
6590
6661
  ...{
6591
6662
  name: "MFieldsPageFragmentSelect"
@@ -6632,8 +6703,8 @@
6632
6703
  };
6633
6704
  return (_ctx, _cache) => {
6634
6705
  const _component_m_form_container = vue.resolveComponent("m-form-container");
6635
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$h, [
6636
- vue.createElementVNode("div", _hoisted_2$7, [
6706
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$i, [
6707
+ vue.createElementVNode("div", _hoisted_2$8, [
6637
6708
  vue.createVNode(_component_m_form_container, {
6638
6709
  class: "select",
6639
6710
  config: selectConfig,
@@ -6653,7 +6724,7 @@
6653
6724
  }
6654
6725
  });
6655
6726
 
6656
- const _hoisted_1$g = {
6727
+ const _hoisted_1$h = {
6657
6728
  key: 1,
6658
6729
  class: "m-fields-ui-select",
6659
6730
  style: { "display": "flex" }
@@ -6689,7 +6760,10 @@
6689
6760
  globalThis.document.removeEventListener(UI_SELECT_MODE_EVENT_NAME, clickHandler);
6690
6761
  };
6691
6762
  const clickHandler = ({ detail }) => {
6692
- const id = utils.getIdFromEl()(detail);
6763
+ let { id } = detail;
6764
+ if (detail.nodeType) {
6765
+ id = utils.getIdFromEl()(detail) || id;
6766
+ }
6693
6767
  if (id) {
6694
6768
  props.model[props.name] = id;
6695
6769
  emit("change", id);
@@ -6753,7 +6827,7 @@
6753
6827
  ])),
6754
6828
  _: 1
6755
6829
  }, 8, ["icon", "disabled", "size"])
6756
- ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$g, [
6830
+ ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$h, [
6757
6831
  val.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
6758
6832
  vue.createVNode(vue.unref(designPlugin.TMagicTooltip), {
6759
6833
  content: "清除",
@@ -7002,11 +7076,11 @@
7002
7076
  }
7003
7077
  });
7004
7078
 
7005
- const _hoisted_1$f = {
7079
+ const _hoisted_1$g = {
7006
7080
  key: 1,
7007
7081
  class: "menu-item-text"
7008
7082
  };
7009
- const _hoisted_2$6 = { class: "el-dropdown-link menubar-menu-button" };
7083
+ const _hoisted_2$7 = { class: "el-dropdown-link menubar-menu-button" };
7010
7084
  const _sfc_main$y = /* @__PURE__ */ vue.defineComponent({
7011
7085
  ...{
7012
7086
  name: "MEditorToolButton"
@@ -7078,7 +7152,7 @@
7078
7152
  _ctx.data.type === "divider" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicDivider), {
7079
7153
  key: 0,
7080
7154
  direction: _ctx.data.direction || "vertical"
7081
- }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$f, vue.toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
7155
+ }, null, 8, ["direction"])) : _ctx.data.type === "text" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$g, vue.toDisplayString(_ctx.data.text), 1)) : _ctx.data.type === "button" ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
7082
7156
  _ctx.data.tooltip ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
7083
7157
  key: 0,
7084
7158
  effect: "dark",
@@ -7143,7 +7217,7 @@
7143
7217
  })) : vue.createCommentVNode("", true)
7144
7218
  ]),
7145
7219
  default: vue.withCtx(() => [
7146
- vue.createElementVNode("span", _hoisted_2$6, [
7220
+ vue.createElementVNode("span", _hoisted_2$7, [
7147
7221
  vue.createTextVNode(vue.toDisplayString(_ctx.data.text), 1),
7148
7222
  vue.createVNode(vue.unref(designPlugin.TMagicIcon), { class: "el-icon--right" }, {
7149
7223
  default: vue.withCtx(() => [
@@ -7160,7 +7234,12 @@
7160
7234
  }
7161
7235
  });
7162
7236
 
7163
- const _hoisted_1$e = {
7237
+ const _hoisted_1$f = {
7238
+ key: 0,
7239
+ id: "m-editor-page-bar-add-icon",
7240
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon"
7241
+ };
7242
+ const _hoisted_2$6 = {
7164
7243
  key: 1,
7165
7244
  style: { "width": "21px" }
7166
7245
  };
@@ -7169,35 +7248,51 @@
7169
7248
  name: "MEditorPageBarAddButton"
7170
7249
  },
7171
7250
  __name: "AddButton",
7172
- props: {
7173
- type: {}
7174
- },
7175
7251
  setup(__props) {
7176
- const props = __props;
7177
7252
  const services = vue.inject("services");
7178
7253
  const uiService = services?.uiService;
7179
7254
  const editorService = services?.editorService;
7180
7255
  const showAddPageButton = vue.computed(() => uiService?.get("showAddPageButton"));
7181
- const addPage = () => {
7256
+ const addPage = (type) => {
7182
7257
  if (!editorService) return;
7183
7258
  const root = vue.toRaw(editorService.get("root"));
7184
7259
  if (!root) throw new Error("root 不能为空");
7185
7260
  const pageConfig = {
7186
- type: props.type,
7187
- name: generatePageNameByApp(root, props.type),
7261
+ type,
7262
+ name: generatePageNameByApp(root, type),
7188
7263
  items: []
7189
7264
  };
7190
7265
  editorService.add(pageConfig);
7191
7266
  };
7192
7267
  return (_ctx, _cache) => {
7193
- return showAddPageButton.value ? (vue.openBlock(), vue.createElementBlock("div", {
7194
- key: 0,
7195
- id: "m-editor-page-bar-add-icon",
7196
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
7197
- onClick: addPage
7198
- }, [
7199
- vue.createVNode(_sfc_main$Y, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
7200
- ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$e));
7268
+ return showAddPageButton.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$f, [
7269
+ vue.createVNode(vue.unref(designPlugin.TMagicPopover), { "popper-class": "data-source-list-panel-add-menu" }, {
7270
+ reference: vue.withCtx(() => [
7271
+ vue.createVNode(_sfc_main$Y, { icon: vue.unref(iconsVue.Plus) }, null, 8, ["icon"])
7272
+ ]),
7273
+ default: vue.withCtx(() => [
7274
+ vue.createVNode(_sfc_main$y, {
7275
+ data: {
7276
+ type: "button",
7277
+ text: "页面",
7278
+ handler: () => {
7279
+ addPage(vue.unref(core.NodeType).PAGE);
7280
+ }
7281
+ }
7282
+ }, null, 8, ["data"]),
7283
+ vue.createVNode(_sfc_main$y, {
7284
+ data: {
7285
+ type: "button",
7286
+ text: "页面片",
7287
+ handler: () => {
7288
+ addPage(vue.unref(core.NodeType).PAGE_FRAGMENT);
7289
+ }
7290
+ }
7291
+ }, null, 8, ["data"])
7292
+ ]),
7293
+ _: 1
7294
+ })
7295
+ ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$6));
7201
7296
  };
7202
7297
  }
7203
7298
  });
@@ -7208,10 +7303,10 @@
7208
7303
  },
7209
7304
  __name: "PageBarScrollContainer",
7210
7305
  props: {
7211
- type: {},
7212
- pageBarSortOptions: {}
7306
+ pageBarSortOptions: {},
7307
+ length: {}
7213
7308
  },
7214
- setup(__props) {
7309
+ setup(__props, { expose: __expose }) {
7215
7310
  const props = __props;
7216
7311
  const services = vue.inject("services");
7217
7312
  const editorService = services?.editorService;
@@ -7222,7 +7317,7 @@
7222
7317
  const showPageListButton = vue.computed(() => uiService?.get("showPageListButton"));
7223
7318
  const itemsContainerWidth = vue.ref(0);
7224
7319
  const setCanScroll = () => {
7225
- itemsContainerWidth.value = (pageBar.value?.clientWidth || 0) - 37 * 2 - (showAddPageButton.value ? 37 : 21) - (showPageListButton.value ? 37 : 0);
7320
+ itemsContainerWidth.value = (pageBar.value?.clientWidth || 0) - 37 * 2 - 37 - (showAddPageButton.value ? 37 : 21) - (showPageListButton.value ? 37 : 0);
7226
7321
  vue.nextTick(() => {
7227
7322
  if (itemsContainer.value) {
7228
7323
  canScroll.value = itemsContainer.value.scrollWidth - itemsContainerWidth.value > 1;
@@ -7241,38 +7336,43 @@
7241
7336
  });
7242
7337
  let translateLeft = 0;
7243
7338
  const scroll = (type) => {
7244
- if (!itemsContainer.value) return;
7339
+ if (!itemsContainer.value || !canScroll.value) return;
7245
7340
  const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
7246
7341
  if (type === "left") {
7247
- translateLeft += 100;
7248
- if (translateLeft > 0) {
7249
- translateLeft = 0;
7250
- }
7342
+ scrollTo(translateLeft + 200);
7251
7343
  } else if (type === "right") {
7252
- translateLeft -= 100;
7253
- if (-translateLeft > maxScrollLeft) {
7254
- translateLeft = -maxScrollLeft;
7255
- }
7344
+ scrollTo(translateLeft - 200);
7256
7345
  } else if (type === "start") {
7257
- translateLeft = 0;
7346
+ scrollTo(0);
7258
7347
  } else if (type === "end") {
7259
- translateLeft = -maxScrollLeft;
7348
+ scrollTo(-maxScrollLeft);
7349
+ }
7350
+ };
7351
+ const scrollTo = (value) => {
7352
+ if (!itemsContainer.value || !canScroll.value) return;
7353
+ const maxScrollLeft = itemsContainer.value.scrollWidth - itemsContainerWidth.value;
7354
+ if (value >= 0) {
7355
+ value = 0;
7356
+ }
7357
+ if (-value > maxScrollLeft) {
7358
+ value = -maxScrollLeft;
7260
7359
  }
7360
+ translateLeft = value;
7261
7361
  itemsContainer.value.style.transform = `translate(${translateLeft}px, 0px)`;
7262
7362
  };
7263
- const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
7264
- const pageFragmentLength = vue.computed(() => editorService?.get("pageFragmentLength") || 0);
7265
- const crateWatchLength = (length) => vue.watch(
7266
- length,
7267
- (length2 = 0, preLength = 0) => {
7363
+ vue.watch(
7364
+ () => props.length,
7365
+ (length = 0, preLength = 0) => {
7268
7366
  setTimeout(() => {
7269
7367
  setCanScroll();
7270
- if (length2 < preLength) {
7271
- scroll("start");
7272
- } else {
7273
- scroll("end");
7274
- }
7275
- if (length2 > 1) {
7368
+ vue.nextTick(() => {
7369
+ if (length < preLength || preLength === 0) {
7370
+ scroll("start");
7371
+ } else {
7372
+ scroll("end");
7373
+ }
7374
+ });
7375
+ if (length > 1) {
7276
7376
  const el = document.querySelector(".m-editor-page-bar-items");
7277
7377
  let beforeDragList = [];
7278
7378
  const options = {
@@ -7308,25 +7408,14 @@
7308
7408
  immediate: true
7309
7409
  }
7310
7410
  );
7311
- let unWatchPageLength;
7312
- let unWatchPageFragmentLength;
7313
- vue.watch(
7314
- () => props.type,
7315
- (type) => {
7316
- if (type === core.NodeType.PAGE) {
7317
- unWatchPageFragmentLength?.();
7318
- unWatchPageFragmentLength = null;
7319
- unWatchPageLength = crateWatchLength(pageLength);
7320
- } else {
7321
- unWatchPageLength?.();
7322
- unWatchPageLength = null;
7323
- unWatchPageFragmentLength = crateWatchLength(pageFragmentLength);
7324
- }
7325
- },
7326
- {
7327
- immediate: true
7411
+ __expose({
7412
+ itemsContainerWidth,
7413
+ scroll,
7414
+ scrollTo,
7415
+ getTranslateLeft() {
7416
+ return translateLeft;
7328
7417
  }
7329
- );
7418
+ });
7330
7419
  return (_ctx, _cache) => {
7331
7420
  return vue.openBlock(), vue.createElementBlock("div", {
7332
7421
  class: "m-editor-page-bar",
@@ -7334,25 +7423,24 @@
7334
7423
  ref: pageBar
7335
7424
  }, [
7336
7425
  vue.renderSlot(_ctx.$slots, "prepend"),
7337
- canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
7426
+ _ctx.length ? (vue.openBlock(), vue.createElementBlock("div", {
7338
7427
  key: 0,
7339
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
7340
- onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
7341
- }, [
7342
- vue.createVNode(_sfc_main$Y, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
7343
- ])) : vue.createCommentVNode("", true),
7344
- _ctx.type === vue.unref(core.NodeType).PAGE && pageLength.value || _ctx.type === vue.unref(core.NodeType).PAGE_FRAGMENT && pageFragmentLength.value ? (vue.openBlock(), vue.createElementBlock("div", {
7345
- key: 1,
7346
7428
  class: "m-editor-page-bar-items",
7347
7429
  ref_key: "itemsContainer",
7348
- ref: itemsContainer,
7349
- style: vue.normalizeStyle(`width: ${itemsContainerWidth.value}px`)
7430
+ ref: itemsContainer
7350
7431
  }, [
7351
7432
  vue.renderSlot(_ctx.$slots, "default")
7352
- ], 4)) : vue.createCommentVNode("", true),
7433
+ ], 512)) : vue.createCommentVNode("", true),
7434
+ canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
7435
+ key: 1,
7436
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon m-editor-page-bar-item-left-icon",
7437
+ onClick: _cache[0] || (_cache[0] = ($event) => scroll("left"))
7438
+ }, [
7439
+ vue.createVNode(_sfc_main$Y, { icon: vue.unref(iconsVue.ArrowLeftBold) }, null, 8, ["icon"])
7440
+ ])) : vue.createCommentVNode("", true),
7353
7441
  canScroll.value ? (vue.openBlock(), vue.createElementBlock("div", {
7354
7442
  key: 2,
7355
- class: "m-editor-page-bar-item m-editor-page-bar-item-icon",
7443
+ class: "m-editor-page-bar-item m-editor-page-bar-item-icon m-editor-page-bar-item-right-icon",
7356
7444
  onClick: _cache[1] || (_cache[1] = ($event) => scroll("right"))
7357
7445
  }, [
7358
7446
  vue.createVNode(_sfc_main$Y, { icon: vue.unref(iconsVue.ArrowRightBold) }, null, 8, ["icon"])
@@ -7362,7 +7450,7 @@
7362
7450
  }
7363
7451
  });
7364
7452
 
7365
- const _hoisted_1$d = {
7453
+ const _hoisted_1$e = {
7366
7454
  key: 0,
7367
7455
  id: "m-editor-page-bar-list-icon",
7368
7456
  class: "m-editor-page-bar-item m-editor-page-bar-item-icon"
@@ -7380,11 +7468,12 @@
7380
7468
  const uiService = services?.uiService;
7381
7469
  const editorService = services?.editorService;
7382
7470
  const showPageListButton = vue.computed(() => uiService?.get("showPageListButton"));
7383
- const switchPage = (id) => {
7384
- editorService?.select(id);
7471
+ const page = vue.computed(() => editorService?.get("page"));
7472
+ const switchPage = async (id) => {
7473
+ await editorService?.select(id);
7385
7474
  };
7386
7475
  return (_ctx, _cache) => {
7387
- return showPageListButton.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d, [
7476
+ return showPageListButton.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$e, [
7388
7477
  vue.createVNode(vue.unref(designPlugin.TMagicPopover), {
7389
7478
  "popper-class": "page-bar-popover",
7390
7479
  placement: "top",
@@ -7408,6 +7497,7 @@
7408
7497
  data: {
7409
7498
  type: "button",
7410
7499
  text: item.devconfig?.tabName || item.name || item.id,
7500
+ className: item.id === page.value?.id ? "active" : "",
7411
7501
  handler: () => switchPage(item.id)
7412
7502
  },
7413
7503
  key: index
@@ -7423,52 +7513,72 @@
7423
7513
  }
7424
7514
  });
7425
7515
 
7516
+ const _hoisted_1$d = { class: "m-editor-page-bar-item m-editor-page-bar-item-icon m-editor-page-bar-search" };
7426
7517
  const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
7427
- ...{
7428
- name: "MEditorPageBarSwitchTypeButton"
7429
- },
7430
- __name: "SwitchTypeButton",
7518
+ __name: "Search",
7431
7519
  props: {
7432
- modelValue: {}
7520
+ "query": {},
7521
+ "queryModifiers": {}
7433
7522
  },
7434
- emits: ["update:modelValue"],
7523
+ emits: /* @__PURE__ */ vue.mergeModels(["search"], ["update:query"]),
7435
7524
  setup(__props, { emit: __emit }) {
7436
- const data = [
7525
+ const emit = __emit;
7526
+ const query = vue.useModel(__props, "query");
7527
+ const formConfig = formPlugin.createForm([
7437
7528
  {
7438
- type: core.NodeType.PAGE,
7439
- text: "页面"
7529
+ type: "checkbox-group",
7530
+ name: "pageType",
7531
+ options: [
7532
+ {
7533
+ value: core.NodeType.PAGE,
7534
+ text: "页面"
7535
+ },
7536
+ {
7537
+ value: core.NodeType.PAGE_FRAGMENT,
7538
+ text: "页面片段"
7539
+ }
7540
+ ]
7440
7541
  },
7441
7542
  {
7442
- type: core.NodeType.PAGE_FRAGMENT,
7443
- text: "页面片"
7543
+ name: "keyword",
7544
+ type: "text",
7545
+ placeholder: "请输入关键字",
7546
+ clearable: true
7444
7547
  }
7445
- ];
7446
- const emit = __emit;
7447
- const clickHandler = (value) => {
7448
- emit("update:modelValue", value);
7548
+ ]);
7549
+ const visible = vue.ref(false);
7550
+ const onFormChange = (values) => {
7551
+ query.value = values;
7552
+ emit("search", values);
7449
7553
  };
7450
7554
  return (_ctx, _cache) => {
7451
- return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, vue.renderList(data, (item) => {
7452
- return vue.createVNode(vue.unref(designPlugin.TMagicButton), {
7453
- class: vue.normalizeClass(["m-editor-page-bar-switch-type-button", { active: _ctx.modelValue === item.type }]),
7454
- size: "small",
7455
- key: item.type,
7456
- link: "",
7457
- type: _ctx.modelValue === item.type ? "primary" : "",
7458
- onClick: ($event) => clickHandler(item.type)
7459
- }, {
7460
- default: vue.withCtx(() => [
7461
- vue.createTextVNode(vue.toDisplayString(item.text), 1)
7462
- ]),
7463
- _: 2
7464
- }, 1032, ["class", "type", "onClick"]);
7465
- }), 64);
7555
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$d, [
7556
+ vue.createVNode(_sfc_main$Y, {
7557
+ icon: vue.unref(iconsVue.Search),
7558
+ onClick: _cache[0] || (_cache[0] = ($event) => visible.value = !visible.value),
7559
+ class: vue.normalizeClass({ "icon-active": visible.value })
7560
+ }, null, 8, ["icon", "class"]),
7561
+ visible.value ? (vue.openBlock(), vue.createBlock(vue.Teleport, {
7562
+ key: 0,
7563
+ to: ".m-editor-page-bar-tabs"
7564
+ }, [
7565
+ query.value ? (vue.openBlock(), vue.createBlock(vue.unref(formPlugin.MForm), {
7566
+ key: 0,
7567
+ class: "m-editor-page-bar-search-panel",
7568
+ inline: true,
7569
+ config: vue.unref(formConfig),
7570
+ "init-values": query.value,
7571
+ "prevent-submit-default": true,
7572
+ onChange: onFormChange
7573
+ }, null, 8, ["config", "init-values"])) : vue.createCommentVNode("", true)
7574
+ ])) : vue.createCommentVNode("", true)
7575
+ ]);
7466
7576
  };
7467
7577
  }
7468
7578
  });
7469
7579
 
7470
7580
  const _hoisted_1$c = { class: "m-editor-page-bar-tabs" };
7471
- const _hoisted_2$5 = ["page-id", "onClick"];
7581
+ const _hoisted_2$5 = ["data-page-id", "onClick"];
7472
7582
  const _hoisted_3$2 = { class: "m-editor-page-bar-title" };
7473
7583
  const _hoisted_4$2 = ["title"];
7474
7584
  const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
@@ -7478,63 +7588,33 @@
7478
7588
  __name: "PageBar",
7479
7589
  props: {
7480
7590
  disabledPageFragment: { type: Boolean },
7481
- pageBarSortOptions: {}
7591
+ pageBarSortOptions: {},
7592
+ filterFunction: { type: Function, default: (page, keyword) => page.name?.includes(keyword) || `${page.id}`.includes(keyword) }
7482
7593
  },
7483
7594
  setup(__props) {
7484
- const active = vue.ref(core.NodeType.PAGE);
7595
+ const props = __props;
7485
7596
  const services = vue.inject("services");
7486
7597
  const editorService = services?.editorService;
7487
7598
  const root = vue.computed(() => editorService?.get("root"));
7488
7599
  const page = vue.computed(() => editorService?.get("page"));
7489
- const pageList = vue.computed(() => getPageList(root.value));
7490
- const pageFragmentList = vue.computed(() => getPageFragmentList(root.value));
7491
- const list = vue.computed(() => active.value === core.NodeType.PAGE ? pageList.value : pageFragmentList.value);
7492
- const activePage = vue.ref("");
7493
- const activePageFragment = vue.ref("");
7494
- vue.watch(
7495
- page,
7496
- (page2) => {
7497
- if (!page2) {
7498
- if (active.value === core.NodeType.PAGE) {
7499
- activePage.value = "";
7500
- }
7501
- if (active.value === core.NodeType.PAGE_FRAGMENT) {
7502
- activePageFragment.value = "";
7503
- }
7504
- return;
7505
- }
7506
- if (utils.isPage(page2)) {
7507
- activePage.value = page2?.id;
7508
- if (active.value !== core.NodeType.PAGE) {
7509
- active.value = core.NodeType.PAGE;
7510
- }
7511
- } else if (utils.isPageFragment(page2)) {
7512
- activePageFragment.value = page2?.id;
7513
- if (active.value !== core.NodeType.PAGE_FRAGMENT) {
7514
- active.value = core.NodeType.PAGE_FRAGMENT;
7515
- }
7516
- }
7517
- },
7518
- {
7519
- immediate: true
7520
- }
7521
- );
7522
- vue.watch(active, (active2) => {
7523
- if (active2 === core.NodeType.PAGE) {
7524
- if (!activePage.value && !pageList.value.length) {
7525
- editorService?.selectRoot();
7526
- return;
7527
- }
7528
- switchPage(activePage.value);
7529
- return;
7600
+ const query = vue.ref({
7601
+ pageType: [core.NodeType.PAGE, core.NodeType.PAGE_FRAGMENT],
7602
+ keyword: ""
7603
+ });
7604
+ const list = vue.computed(() => {
7605
+ const { pageType, keyword } = query.value;
7606
+ if (pageType.length === 0) {
7607
+ return [];
7530
7608
  }
7531
- if (active2 === core.NodeType.PAGE_FRAGMENT) {
7532
- if (!activePageFragment.value && !pageFragmentList.value.length) {
7533
- editorService?.selectRoot();
7534
- return;
7609
+ return (root.value?.items || []).filter((item) => {
7610
+ if (pageType.includes(item.type)) {
7611
+ if (keyword) {
7612
+ return props.filterFunction(item, keyword);
7613
+ }
7614
+ return true;
7535
7615
  }
7536
- switchPage(activePageFragment.value || pageFragmentList.value[0].id);
7537
- }
7616
+ return false;
7617
+ });
7538
7618
  });
7539
7619
  const switchPage = (id) => {
7540
7620
  editorService?.select(id);
@@ -7549,19 +7629,49 @@
7549
7629
  const remove = (node) => {
7550
7630
  editorService?.remove(node);
7551
7631
  };
7632
+ const pageBarScrollContainer = vue.ref();
7633
+ const pageBarItems = vue.ref();
7634
+ vue.watch(page, (page2) => {
7635
+ if (!page2 || !pageBarScrollContainer.value?.itemsContainerWidth || !pageBarItems.value || pageBarItems.value.length < 2) {
7636
+ return;
7637
+ }
7638
+ const firstItem = pageBarItems.value[0];
7639
+ const lastItem = pageBarItems.value[pageBarItems.value.length - 1];
7640
+ if (page2.id === firstItem.dataset.pageId) {
7641
+ pageBarScrollContainer.value.scroll("start");
7642
+ } else if (page2.id === lastItem.dataset.pageId) {
7643
+ pageBarScrollContainer.value.scroll("end");
7644
+ } else {
7645
+ const pageItem = pageBarItems.value.find((item) => item.dataset.pageId === page2.id);
7646
+ if (!pageItem) {
7647
+ return;
7648
+ }
7649
+ const pageItemRect = pageItem.getBoundingClientRect();
7650
+ const offsetLeft = pageItemRect.left - firstItem.getBoundingClientRect().left;
7651
+ const { itemsContainerWidth } = pageBarScrollContainer.value;
7652
+ const left = itemsContainerWidth - offsetLeft - pageItemRect.width;
7653
+ const translateLeft = pageBarScrollContainer.value.getTranslateLeft();
7654
+ if (offsetLeft + translateLeft < 0 || offsetLeft + pageItemRect.width > itemsContainerWidth - translateLeft) {
7655
+ pageBarScrollContainer.value.scrollTo(left);
7656
+ }
7657
+ }
7658
+ });
7552
7659
  return (_ctx, _cache) => {
7553
7660
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$c, [
7554
- !_ctx.disabledPageFragment ? (vue.openBlock(), vue.createBlock(_sfc_main$u, {
7555
- key: 0,
7556
- modelValue: active.value,
7557
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => active.value = $event)
7558
- }, null, 8, ["modelValue"])) : vue.createCommentVNode("", true),
7559
7661
  vue.createVNode(_sfc_main$w, {
7560
- type: active.value,
7561
- "page-bar-sort-options": _ctx.pageBarSortOptions
7662
+ ref_key: "pageBarScrollContainer",
7663
+ ref: pageBarScrollContainer,
7664
+ "page-bar-sort-options": _ctx.pageBarSortOptions,
7665
+ length: list.value.length
7562
7666
  }, {
7563
7667
  prepend: vue.withCtx(() => [
7564
- vue.createVNode(_sfc_main$x, { type: active.value }, null, 8, ["type"]),
7668
+ vue.renderSlot(_ctx.$slots, "page-bar-add-button", {}, () => [
7669
+ vue.createVNode(_sfc_main$x)
7670
+ ]),
7671
+ vue.createVNode(_sfc_main$u, {
7672
+ query: query.value,
7673
+ "onUpdate:query": _cache[0] || (_cache[0] = ($event) => query.value = $event)
7674
+ }, null, 8, ["query"]),
7565
7675
  vue.createVNode(_sfc_main$v, { list: list.value }, {
7566
7676
  "page-list-popover": vue.withCtx(({ list: list2 }) => [
7567
7677
  vue.renderSlot(_ctx.$slots, "page-list-popover", { list: list2 })
@@ -7573,8 +7683,11 @@
7573
7683
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(list.value, (item) => {
7574
7684
  return vue.openBlock(), vue.createElementBlock("div", {
7575
7685
  class: vue.normalizeClass(["m-editor-page-bar-item", { active: page.value?.id === item.id }]),
7686
+ ref_for: true,
7687
+ ref_key: "pageBarItems",
7688
+ ref: pageBarItems,
7576
7689
  key: item.id,
7577
- "page-id": item.id,
7690
+ "data-page-id": item.id,
7578
7691
  onClick: ($event) => switchPage(item.id)
7579
7692
  }, [
7580
7693
  vue.createElementVNode("div", _hoisted_3$2, [
@@ -7627,7 +7740,7 @@
7627
7740
  }), 128))
7628
7741
  ]),
7629
7742
  _: 3
7630
- }, 8, ["type", "page-bar-sort-options"])
7743
+ }, 8, ["page-bar-sort-options", "length"])
7631
7744
  ]);
7632
7745
  };
7633
7746
  }
@@ -7695,7 +7808,8 @@
7695
7808
  __name: "Framework",
7696
7809
  props: {
7697
7810
  disabledPageFragment: { type: Boolean },
7698
- pageBarSortOptions: {}
7811
+ pageBarSortOptions: {},
7812
+ pageFilterFunction: { type: Function }
7699
7813
  },
7700
7814
  setup(__props) {
7701
7815
  const codeOptions = vue.inject("codeOptions", {});
@@ -7705,7 +7819,6 @@
7705
7819
  const root = vue.computed(() => editorService?.get("root"));
7706
7820
  const page = vue.computed(() => editorService?.get("page"));
7707
7821
  const pageLength = vue.computed(() => editorService?.get("pageLength") || 0);
7708
- const stageLoading = vue.computed(() => editorService?.get("stageLoading") || false);
7709
7822
  const showSrc = vue.computed(() => uiService?.get("showSrc"));
7710
7823
  const getLeftColumnWidthCacheData = () => Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
7711
7824
  const getRightColumnWidthCacheData = () => Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
@@ -7756,7 +7869,6 @@
7756
7869
  }
7757
7870
  };
7758
7871
  return (_ctx, _cache) => {
7759
- const _directive_loading = vue.resolveDirective("loading");
7760
7872
  return vue.openBlock(), vue.createElementBlock("div", {
7761
7873
  class: "m-editor",
7762
7874
  ref_key: "content",
@@ -7773,9 +7885,8 @@
7773
7885
  options: vue.unref(codeOptions),
7774
7886
  onSave: saveCode
7775
7887
  }, null, 8, ["init-values", "options"])
7776
- ]) : vue.withDirectives((vue.openBlock(), vue.createBlock(_sfc_main$z, {
7888
+ ]) : (vue.openBlock(), vue.createBlock(_sfc_main$z, {
7777
7889
  key: 1,
7778
- "element-loading-text": "Runtime 加载中...",
7779
7890
  ref_key: "splitView",
7780
7891
  ref: splitView,
7781
7892
  class: "m-editor-content",
@@ -7802,8 +7913,12 @@
7802
7913
  vue.renderSlot(_ctx.$slots, "page-bar", {}, () => [
7803
7914
  vue.createVNode(_sfc_main$t, {
7804
7915
  "disabled-page-fragment": _ctx.disabledPageFragment,
7805
- "page-bar-sort-options": _ctx.pageBarSortOptions
7916
+ "page-bar-sort-options": _ctx.pageBarSortOptions,
7917
+ "filter-function": _ctx.pageFilterFunction
7806
7918
  }, {
7919
+ "page-bar-add-button": vue.withCtx(() => [
7920
+ vue.renderSlot(_ctx.$slots, "page-bar-add-button")
7921
+ ]),
7807
7922
  "page-bar-title": vue.withCtx(({ page: page2 }) => [
7808
7923
  vue.renderSlot(_ctx.$slots, "page-bar-title", { page: page2 })
7809
7924
  ]),
@@ -7814,7 +7929,7 @@
7814
7929
  vue.renderSlot(_ctx.$slots, "page-list-popover", { list })
7815
7930
  ]),
7816
7931
  _: 3
7817
- }, 8, ["disabled-page-fragment", "page-bar-sort-options"])
7932
+ }, 8, ["disabled-page-fragment", "page-bar-sort-options", "filter-function"])
7818
7933
  ])
7819
7934
  ]),
7820
7935
  _: 2
@@ -7831,9 +7946,7 @@
7831
7946
  ]),
7832
7947
  key: "0"
7833
7948
  } : void 0
7834
- ]), 1032, ["left", "right", "width"])), [
7835
- [_directive_loading, stageLoading.value]
7836
- ]),
7949
+ ]), 1032, ["left", "right", "width"])),
7837
7950
  vue.renderSlot(_ctx.$slots, "content-after"),
7838
7951
  vue.renderSlot(_ctx.$slots, "footer")
7839
7952
  ], 512);
@@ -8082,10 +8195,10 @@
8082
8195
  configForm.value.formState.stage = stage.value;
8083
8196
  }
8084
8197
  });
8085
- const submit = async () => {
8198
+ const submit = async (v, eventData) => {
8086
8199
  try {
8087
8200
  const values2 = await configForm.value?.submitForm();
8088
- services?.editorService.update(values2);
8201
+ services?.editorService.update(values2, { changeRecords: eventData.changeRecords });
8089
8202
  } catch (e) {
8090
8203
  emit("submit-error", e);
8091
8204
  }
@@ -8387,6 +8500,7 @@
8387
8500
  const emit = __emit;
8388
8501
  const services = vue.inject("services");
8389
8502
  const { codeBlockService, depService, editorService } = services || {};
8503
+ const collecting = vue.computed(() => depService?.get("collecting"));
8390
8504
  const codeList = vue.computed(
8391
8505
  () => Object.entries(codeBlockService?.getCodeDsl() || {}).map(([codeId, code]) => {
8392
8506
  const target = depService?.getTarget(codeId, core.DepTargetType.CODE_BLOCK);
@@ -8486,8 +8600,19 @@
8486
8600
  }, vue.toDisplayString(data.name) + " " + vue.toDisplayString(data.key ? `(${data.key})` : ""), 3)
8487
8601
  ]),
8488
8602
  "tree-node-tool": vue.withCtx(({ data }) => [
8489
- data.type === "code" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
8603
+ collecting.value && data.type === "code" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTag), {
8490
8604
  key: 0,
8605
+ type: "info",
8606
+ size: "small",
8607
+ style: { "margin-right": "5px" }
8608
+ }, {
8609
+ default: vue.withCtx(() => _cache[0] || (_cache[0] = [
8610
+ vue.createTextVNode("依赖收集中")
8611
+ ])),
8612
+ _: 1
8613
+ })) : vue.createCommentVNode("", true),
8614
+ data.type === "code" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
8615
+ key: 1,
8491
8616
  effect: "dark",
8492
8617
  content: editable.value ? "编辑" : "查看",
8493
8618
  placement: "bottom"
@@ -8502,7 +8627,7 @@
8502
8627
  _: 2
8503
8628
  }, 1032, ["content"])) : vue.createCommentVNode("", true),
8504
8629
  data.type === "code" && editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
8505
- key: 1,
8630
+ key: 2,
8506
8631
  effect: "dark",
8507
8632
  content: "删除",
8508
8633
  placement: "bottom"
@@ -8618,9 +8743,9 @@
8618
8743
  dialogTitle.value = `编辑${dataSourceValues.value.title || ""}`;
8619
8744
  editDialog.value.show();
8620
8745
  };
8621
- const submitDataSourceHandler = (value) => {
8746
+ const submitDataSourceHandler = (value, eventData) => {
8622
8747
  if (value.id) {
8623
- dataSourceService?.update(value);
8748
+ dataSourceService?.update(value, { changeRecords: eventData.changeRecords });
8624
8749
  } else {
8625
8750
  dataSourceService?.add(value);
8626
8751
  }
@@ -8667,8 +8792,8 @@
8667
8792
  initValues.value = props.values;
8668
8793
  dataSourceConfig.value = services?.dataSourceService.getFormConfig(initValues.value.type) || [];
8669
8794
  });
8670
- const submitHandler = (values) => {
8671
- emit("submit", values);
8795
+ const submitHandler = (values, data) => {
8796
+ emit("submit", values, data);
8672
8797
  };
8673
8798
  const errorHandler = (error) => {
8674
8799
  designPlugin.tMagicMessage.error(error.message);
@@ -8724,6 +8849,7 @@
8724
8849
  setup(__props, { expose: __expose, emit: __emit }) {
8725
8850
  const emit = __emit;
8726
8851
  const { depService, editorService, dataSourceService } = vue.inject("services") || {};
8852
+ const collecting = vue.computed(() => depService?.get("collecting"));
8727
8853
  const editable = vue.computed(() => dataSourceService?.get("editable") ?? true);
8728
8854
  const dataSources = vue.computed(() => dataSourceService?.get("dataSources") || []);
8729
8855
  const dsDep = vue.computed(() => depService?.getTargets(core.DepTargetType.DATA_SOURCE) || {});
@@ -8829,8 +8955,19 @@
8829
8955
  }, vue.toDisplayString(data.name) + " " + vue.toDisplayString(data.key ? `(${data.key})` : ""), 3)
8830
8956
  ]),
8831
8957
  "tree-node-tool": vue.withCtx(({ data }) => [
8832
- data.type === "ds" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
8958
+ collecting.value && data.type === "ds" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTag), {
8833
8959
  key: 0,
8960
+ type: "info",
8961
+ size: "small",
8962
+ style: { "margin-right": "5px" }
8963
+ }, {
8964
+ default: vue.withCtx(() => _cache[0] || (_cache[0] = [
8965
+ vue.createTextVNode("依赖收集中")
8966
+ ])),
8967
+ _: 1
8968
+ })) : vue.createCommentVNode("", true),
8969
+ data.type === "ds" ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
8970
+ key: 1,
8834
8971
  effect: "dark",
8835
8972
  content: editable.value ? "编辑" : "查看",
8836
8973
  placement: "bottom"
@@ -8845,7 +8982,7 @@
8845
8982
  _: 2
8846
8983
  }, 1032, ["content"])) : vue.createCommentVNode("", true),
8847
8984
  data.type === "ds" && editable.value ? (vue.openBlock(), vue.createBlock(vue.unref(designPlugin.TMagicTooltip), {
8848
- key: 1,
8985
+ key: 2,
8849
8986
  effect: "dark",
8850
8987
  content: "删除",
8851
8988
  placement: "bottom"
@@ -9767,7 +9904,7 @@
9767
9904
  draggable: false
9768
9905
  });
9769
9906
  page.items.forEach(
9770
- (node) => traverseNode(node, (node2) => {
9907
+ (node) => utils.traverseNode(node, (node2) => {
9771
9908
  map.set(
9772
9909
  node2.id,
9773
9910
  initialLayerNodeStatus?.get(node2.id) || {
@@ -9822,7 +9959,7 @@
9822
9959
  services?.editorService.on("add", (newNodes) => {
9823
9960
  newNodes.forEach((node) => {
9824
9961
  if (utils.isPage(node) || utils.isPageFragment(node)) return;
9825
- traverseNode(node, (node2) => {
9962
+ utils.traverseNode(node, (node2) => {
9826
9963
  nodeStatusMap.value?.set(node2.id, {
9827
9964
  visible: true,
9828
9965
  expand: Array.isArray(node2.items),
@@ -9834,7 +9971,7 @@
9834
9971
  });
9835
9972
  services?.editorService.on("remove", (nodes2) => {
9836
9973
  nodes2.forEach((node) => {
9837
- traverseNode(node, (node2) => {
9974
+ utils.traverseNode(node, (node2) => {
9838
9975
  nodeStatusMap.value?.delete(node2.id);
9839
9976
  });
9840
9977
  });
@@ -10111,6 +10248,7 @@
10111
10248
  setup(__props, { expose: __expose }) {
10112
10249
  const props = __props;
10113
10250
  const services = vue.inject("services");
10251
+ const collecting = vue.computed(() => services?.depService.get("collecting"));
10114
10252
  const columnLeftWidth = vue.computed(() => services?.uiService.get("columnWidth")[ColumnLayout.LEFT] || 0);
10115
10253
  const { height: editorContentHeight } = useEditorContentHeight();
10116
10254
  const columnLeftHeight = vue.ref(0);
@@ -10253,7 +10391,7 @@
10253
10391
  ]),
10254
10392
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(sideBarItems.value, (config, index) => {
10255
10393
  return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
10256
- class: "m-editor-sidebar-content",
10394
+ class: vue.normalizeClass(["m-editor-sidebar-content", { "m-editor-dep-collecting": collecting.value }]),
10257
10395
  key: config.$key ?? index
10258
10396
  }, [
10259
10397
  config?.component && !vue.unref(floatBoxStates)[config.$key]?.status ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(config.component), vue.mergeProps({
@@ -10379,7 +10517,7 @@
10379
10517
  key: "11"
10380
10518
  } : void 0
10381
10519
  ]), 1040)) : vue.createCommentVNode("", true)
10382
- ])), [
10520
+ ], 2)), [
10383
10521
  [vue.vShow, [config.text, config.$key, `${index}`].includes(activeTabName.value)]
10384
10522
  ]);
10385
10523
  }), 128))
@@ -10960,15 +11098,17 @@
10960
11098
  },
10961
11099
  __name: "Stage",
10962
11100
  props: {
11101
+ stageOptions: {},
10963
11102
  stageContentMenu: {},
10964
11103
  disabledStageOverlay: { type: Boolean, default: false },
10965
11104
  customContentMenu: {}
10966
11105
  },
10967
11106
  setup(__props) {
11107
+ const props = __props;
10968
11108
  let stage = null;
10969
11109
  let runtime = null;
10970
11110
  const services = vue.inject("services");
10971
- const stageOptions = vue.inject("stageOptions");
11111
+ const stageLoading = vue.computed(() => services?.editorService.get("stageLoading") || false);
10972
11112
  const stageWrap = vue.ref();
10973
11113
  const stageContainer = vue.ref();
10974
11114
  const menu = vue.ref();
@@ -10983,8 +11123,8 @@
10983
11123
  vue.watchEffect(() => {
10984
11124
  if (stage || !page.value) return;
10985
11125
  if (!stageContainer.value) return;
10986
- if (!(stageOptions?.runtimeUrl || stageOptions?.render) || !root.value) return;
10987
- stage = useStage(stageOptions);
11126
+ if (!(props.stageOptions?.runtimeUrl || props.stageOptions?.render) || !root.value) return;
11127
+ stage = useStage(props.stageOptions);
10988
11128
  stage.on("select", () => {
10989
11129
  stageWrap.value?.container?.focus();
10990
11130
  });
@@ -11004,14 +11144,23 @@
11004
11144
  });
11005
11145
  vue.onBeforeUnmount(() => {
11006
11146
  stage?.destroy();
11147
+ services?.editorService.set("stage", null);
11007
11148
  });
11008
11149
  vue.watch(zoom, (zoom2) => {
11009
11150
  if (!stage || !zoom2) return;
11010
11151
  stage.setZoom(zoom2);
11011
11152
  });
11153
+ let timeoutId = null;
11012
11154
  vue.watch(page, (page2) => {
11013
11155
  if (runtime && page2) {
11014
11156
  services?.editorService.set("stageLoading", true);
11157
+ if (timeoutId) {
11158
+ globalThis.clearTimeout(timeoutId);
11159
+ }
11160
+ timeoutId = globalThis.setTimeout(() => {
11161
+ services?.editorService.set("stageLoading", false);
11162
+ timeoutId = null;
11163
+ }, 3e3);
11015
11164
  runtime.updatePageId?.(page2.id);
11016
11165
  vue.nextTick(() => {
11017
11166
  stage?.select(page2.id);
@@ -11063,7 +11212,9 @@
11063
11212
  if (!config || config.dragType !== DragType.COMPONENT_LIST) return;
11064
11213
  e.preventDefault();
11065
11214
  const doc = stage?.renderer?.contentWindow?.document;
11066
- const parentEl = doc?.querySelector(`.${stageOptions?.containerHighlightClassName}`);
11215
+ const parentEl = doc?.querySelector(
11216
+ `.${props.stageOptions?.containerHighlightClassName}`
11217
+ );
11067
11218
  let parent = page.value;
11068
11219
  const parentId = utils.getIdFromEl()(parentEl);
11069
11220
  if (parentId) {
@@ -11102,11 +11253,13 @@
11102
11253
  }
11103
11254
  };
11104
11255
  return (_ctx, _cache) => {
11105
- return vue.openBlock(), vue.createBlock(_sfc_main$8, {
11256
+ const _directive_loading = vue.resolveDirective("loading");
11257
+ return vue.withDirectives((vue.openBlock(), vue.createBlock(_sfc_main$8, {
11106
11258
  class: "m-editor-stage",
11107
11259
  ref_key: "stageWrap",
11108
11260
  ref: stageWrap,
11109
11261
  tabindex: "-1",
11262
+ "element-loading-text": "Runtime 加载中...",
11110
11263
  width: stageRect.value?.width,
11111
11264
  height: stageRect.value?.height,
11112
11265
  "wrap-width": stageContainerRect.value?.width,
@@ -11143,7 +11296,9 @@
11143
11296
  vue.createVNode(_sfc_main$7)
11144
11297
  ]),
11145
11298
  _: 1
11146
- }, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"]);
11299
+ }, 8, ["width", "height", "wrap-width", "wrap-height", "zoom"])), [
11300
+ [_directive_loading, stageLoading.value]
11301
+ ]);
11147
11302
  };
11148
11303
  }
11149
11304
  });
@@ -11205,18 +11360,20 @@
11205
11360
  customContentMenu: {}
11206
11361
  },
11207
11362
  setup(__props) {
11363
+ const stageOptions = vue.inject("stageOptions");
11208
11364
  const services = vue.inject("services");
11209
11365
  const page = vue.computed(() => services?.editorService.get("page"));
11210
11366
  return (_ctx, _cache) => {
11211
11367
  return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
11212
11368
  vue.createVNode(_sfc_main$2),
11213
11369
  vue.renderSlot(_ctx.$slots, "stage", {}, () => [
11214
- page.value ? (vue.openBlock(), vue.createBlock(_sfc_main$3, {
11370
+ page.value && (vue.unref(stageOptions)?.render || vue.unref(stageOptions)?.runtimeUrl) ? (vue.openBlock(), vue.createBlock(_sfc_main$3, {
11215
11371
  key: 0,
11372
+ "stage-options": vue.unref(stageOptions),
11216
11373
  "disabled-stage-overlay": _ctx.disabledStageOverlay,
11217
11374
  "stage-content-menu": _ctx.stageContentMenu,
11218
11375
  "custom-content-menu": _ctx.customContentMenu
11219
- }, null, 8, ["disabled-stage-overlay", "stage-content-menu", "custom-content-menu"])) : vue.createCommentVNode("", true)
11376
+ }, null, 8, ["stage-options", "disabled-stage-overlay", "stage-content-menu", "custom-content-menu"])) : vue.createCommentVNode("", true)
11220
11377
  ]),
11221
11378
  vue.renderSlot(_ctx.$slots, "workspace-content")
11222
11379
  ]);
@@ -11566,12 +11723,17 @@
11566
11723
  this.emit("add", newConfig);
11567
11724
  return newConfig;
11568
11725
  }
11569
- update(config) {
11726
+ update(config, { changeRecords = [] } = {}) {
11570
11727
  const dataSources = this.get("dataSources");
11571
11728
  const index = dataSources.findIndex((ds) => ds.id === config.id);
11572
- dataSources[index] = lodashEs.cloneDeep(config);
11573
- this.emit("update", config);
11574
- return config;
11729
+ const oldConfig = dataSources[index];
11730
+ const newConfig = lodashEs.cloneDeep(config);
11731
+ dataSources[index] = newConfig;
11732
+ this.emit("update", newConfig, {
11733
+ oldConfig,
11734
+ changeRecords
11735
+ });
11736
+ return newConfig;
11575
11737
  }
11576
11738
  remove(id) {
11577
11739
  const dataSources = this.get("dataSources");
@@ -11647,7 +11809,16 @@
11647
11809
 
11648
11810
  const idleTask = new IdleTask();
11649
11811
  class Dep extends BaseService {
11812
+ state = vue.reactive({
11813
+ collecting: false
11814
+ });
11650
11815
  watcher = new core.Watcher({ initialTargets: vue.reactive({}) });
11816
+ set(name, value) {
11817
+ this.state[name] = value;
11818
+ }
11819
+ get(name) {
11820
+ return this.state[name];
11821
+ }
11651
11822
  removeTargets(type = core.DepTargetType.DEFAULT) {
11652
11823
  this.watcher.removeTargets(type);
11653
11824
  const targets = this.watcher.getTargets(type);
@@ -11674,26 +11845,32 @@
11674
11845
  this.watcher.clearTargets();
11675
11846
  }
11676
11847
  collect(nodes, depExtendedData = {}, deep = false, type) {
11848
+ this.set("collecting", true);
11677
11849
  this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
11678
11850
  this.collectNode(node, target, depExtendedData, deep);
11679
11851
  });
11852
+ this.set("collecting", false);
11680
11853
  this.emit("collected", nodes, deep);
11681
11854
  }
11682
11855
  collectIdle(nodes, depExtendedData = {}, deep = false, type) {
11856
+ this.set("collecting", true);
11857
+ let startTask = false;
11683
11858
  this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
11684
- idleTask.enqueueTask(
11685
- ({ node: node2, deep: deep2, target: target2 }) => {
11686
- this.collectNode(node2, target2, depExtendedData, deep2);
11687
- },
11688
- {
11689
- node,
11690
- deep,
11691
- target
11692
- }
11693
- );
11694
- });
11695
- idleTask.once("finish", () => {
11696
- this.emit("collected", nodes, deep);
11859
+ startTask = true;
11860
+ this.enqueueTask(node, target, depExtendedData, deep);
11861
+ });
11862
+ return new Promise((resolve) => {
11863
+ if (!startTask) {
11864
+ this.emit("collected", nodes, deep);
11865
+ this.set("collecting", false);
11866
+ resolve();
11867
+ return;
11868
+ }
11869
+ idleTask.once("finish", () => {
11870
+ this.emit("collected", nodes, deep);
11871
+ this.set("collecting", false);
11872
+ resolve();
11873
+ });
11697
11874
  });
11698
11875
  }
11699
11876
  collectNode(node, target, depExtendedData = {}, deep = false) {
@@ -11720,6 +11897,9 @@
11720
11897
  hasSpecifiedTypeTarget(type = core.DepTargetType.DEFAULT) {
11721
11898
  return this.watcher.hasSpecifiedTypeTarget(type);
11722
11899
  }
11900
+ clearIdleTasks() {
11901
+ idleTask.clearTasks();
11902
+ }
11723
11903
  on(eventName, listener) {
11724
11904
  return super.on(eventName, listener);
11725
11905
  }
@@ -11729,6 +11909,23 @@
11729
11909
  emit(eventName, ...args) {
11730
11910
  return super.emit(eventName, ...args);
11731
11911
  }
11912
+ enqueueTask(node, target, depExtendedData, deep) {
11913
+ idleTask.enqueueTask(
11914
+ ({ node: node2, deep: deep2, target: target2 }) => {
11915
+ this.collectNode(node2, target2, depExtendedData, deep2);
11916
+ },
11917
+ {
11918
+ node,
11919
+ deep: false,
11920
+ target
11921
+ }
11922
+ );
11923
+ if (deep && Array.isArray(node.items) && node.items.length) {
11924
+ node.items.forEach((item) => {
11925
+ this.enqueueTask(item, target, depExtendedData, deep);
11926
+ });
11927
+ }
11928
+ }
11732
11929
  }
11733
11930
  const depService = new Dep();
11734
11931
 
@@ -12302,6 +12499,7 @@
12302
12499
  initDataSourceDepTarget(ds);
12303
12500
  });
12304
12501
  if (Array.isArray(value.items)) {
12502
+ depService.clearIdleTasks();
12305
12503
  collectIdle(value.items, true);
12306
12504
  } else {
12307
12505
  depService.clear();
@@ -12326,15 +12524,66 @@
12326
12524
  emit("update:modelValue", value);
12327
12525
  }
12328
12526
  };
12329
- const getApp = () => {
12330
- const stage = editorService.get("stage");
12331
- return stage?.renderer?.runtime?.getApp?.();
12332
- };
12333
- const updateDataSourceSchema = () => {
12527
+ const stage = vue.computed(() => editorService.get("stage"));
12528
+ vue.watch(stage, (stage2) => {
12529
+ if (!stage2) {
12530
+ return;
12531
+ }
12532
+ stage2.on("rerender", () => {
12533
+ const node = editorService.get("node");
12534
+ if (!node) return;
12535
+ collectIdle([node], true).then(() => {
12536
+ afterUpdateNodes([node]);
12537
+ });
12538
+ });
12539
+ });
12540
+ const getApp = () => stage.value?.renderer?.runtime?.getApp?.();
12541
+ const updateDataSourceSchema = (nodes, deep) => {
12334
12542
  const root = editorService.get("root");
12543
+ const app = getApp();
12544
+ if (root && app?.dsl) {
12545
+ app.dsl.dataSourceDeps = root.dataSourceDeps;
12546
+ app.dsl.dataSourceCondDeps = root.dataSourceCondDeps;
12547
+ app.dsl.dataSources = root.dataSources;
12548
+ }
12335
12549
  if (root?.dataSources) {
12336
12550
  getApp()?.dataSourceManager?.updateSchema(root.dataSources);
12337
12551
  }
12552
+ if (!root || !stage.value) return;
12553
+ const allNodes = [];
12554
+ if (deep) {
12555
+ nodes.forEach((node) => {
12556
+ utils.traverseNode(node, (node2) => {
12557
+ if (!allNodes.includes(node2)) {
12558
+ allNodes.push(node2);
12559
+ }
12560
+ });
12561
+ });
12562
+ } else {
12563
+ allNodes.push(...nodes);
12564
+ }
12565
+ const deps = Object.values(root.dataSourceDeps || {});
12566
+ deps.forEach((dep) => {
12567
+ Object.keys(dep).forEach((id) => {
12568
+ const node = allNodes.find((node2) => node2.id === id);
12569
+ node && stage.value?.update({
12570
+ config: lodashEs.cloneDeep(node),
12571
+ parentId: editorService.getParentById(node.id)?.id,
12572
+ root: lodashEs.cloneDeep(root)
12573
+ });
12574
+ });
12575
+ });
12576
+ };
12577
+ const afterUpdateNodes = (nodes) => {
12578
+ const root = editorService.get("root");
12579
+ if (!root) return;
12580
+ for (const node of nodes) {
12581
+ stage.value?.update({
12582
+ config: lodashEs.cloneDeep(node),
12583
+ parentId: editorService.getParentById(node.id)?.id,
12584
+ root: lodashEs.cloneDeep(root)
12585
+ });
12586
+ }
12338
12587
  };
12339
12588
  const targetAddHandler = (target) => {
12340
12589
  const root = editorService.get("root");
@@ -12354,59 +12603,32 @@
12354
12603
  };
12355
12604
  const targetRemoveHandler = (id) => {
12356
12605
  const root = editorService.get("root");
12357
- if (root?.dataSourceDeps) {
12606
+ if (!root) return;
12607
+ if (root.dataSourceDeps) {
12358
12608
  delete root.dataSourceDeps[id];
12359
12609
  }
12360
- if (root?.dataSourceCondDeps) {
12610
+ if (root.dataSourceCondDeps) {
12361
12611
  delete root.dataSourceCondDeps[id];
12362
12612
  }
12363
12613
  };
12364
- const collectedHandler = (nodes, deep) => {
12614
+ const depCollectedHandler = () => {
12365
12615
  const root = editorService.get("root");
12366
- const stage = editorService.get("stage");
12367
- if (!root || !stage) return;
12616
+ if (!root) return;
12368
12617
  const app = getApp();
12369
- if (!app) return;
12370
- if (app.dsl) {
12618
+ if (app?.dsl) {
12371
12619
  app.dsl.dataSourceDeps = root.dataSourceDeps;
12372
- app.dsl.dataSourceCondDeps = root.dataSourceCondDeps;
12373
- app.dsl.dataSources = root.dataSources;
12374
- }
12375
- updateDataSourceSchema();
12376
- const allNodes = [];
12377
- if (deep) {
12378
- nodes.forEach((node) => {
12379
- traverseNode(node, (node2) => {
12380
- if (!allNodes.includes(node2)) {
12381
- allNodes.push(node2);
12382
- }
12383
- });
12384
- });
12385
- } else {
12386
- allNodes.push(...nodes);
12387
12620
  }
12388
- const deps = Object.values(root.dataSourceDeps || {});
12389
- deps.forEach((dep) => {
12390
- Object.keys(dep).forEach((id) => {
12391
- const node = allNodes.find((node2) => node2.id === id);
12392
- node && stage.update({
12393
- config: lodashEs.cloneDeep(node),
12394
- parentId: editorService.getParentById(node.id)?.id,
12395
- root: lodashEs.cloneDeep(root)
12396
- });
12397
- });
12398
- });
12399
12621
  };
12400
12622
  depService.on("add-target", targetAddHandler);
12401
12623
  depService.on("remove-target", targetRemoveHandler);
12402
- depService.on("collected", collectedHandler);
12624
+ depService.on("collected", depCollectedHandler);
12403
12625
  const initDataSourceDepTarget = (ds) => {
12404
12626
  depService.addTarget(core.createDataSourceTarget(ds, vue.reactive({})));
12405
12627
  depService.addTarget(core.createDataSourceMethodTarget(ds, vue.reactive({})));
12406
12628
  depService.addTarget(core.createDataSourceCondTarget(ds, vue.reactive({})));
12407
12629
  };
12408
- const collectIdle = (nodes, deep) => {
12409
- nodes.forEach((node) => {
12630
+ const collectIdle = (nodes, deep) => Promise.all(
12631
+ nodes.map((node) => {
12410
12632
  let pageId;
12411
12633
  if (utils.isPage(node)) {
12412
12634
  pageId = node.id;
@@ -12414,20 +12636,47 @@
12414
12636
  const info = editorService.getNodeInfo(node.id);
12415
12637
  pageId = info.page?.id;
12416
12638
  }
12417
- depService.collectIdle([node], { pageId }, deep);
12418
- });
12419
- };
12639
+ return depService.collectIdle([node], { pageId }, deep);
12640
+ })
12641
+ );
12420
12642
  const nodeAddHandler = (nodes) => {
12421
- collectIdle(nodes, true);
12643
+ collectIdle(nodes, true).then(() => {
12644
+ afterUpdateNodes(nodes);
12645
+ });
12422
12646
  };
12423
- const nodeUpdateHandler = (nodes) => {
12424
- collectIdle(nodes, true);
12647
+ const nodeUpdateHandler = (data) => {
12648
+ const needRecollectNodes = [];
12649
+ const normalNodes = [];
12650
+ data.forEach(({ newNode, oldNode, changeRecords }) => {
12651
+ if (changeRecords?.length) {
12652
+ for (const record of changeRecords) {
12653
+ 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)) {
12654
+ needRecollectNodes.push(newNode);
12655
+ } else {
12656
+ normalNodes.push(newNode);
12657
+ }
12658
+ }
12659
+ } else if (isIncludeDataSource(newNode, oldNode)) {
12660
+ needRecollectNodes.push(newNode);
12661
+ } else {
12662
+ normalNodes.push(newNode);
12663
+ }
12664
+ });
12665
+ if (needRecollectNodes.length) {
12666
+ collectIdle(needRecollectNodes, true).then(() => {
12667
+ afterUpdateNodes(needRecollectNodes);
12668
+ });
12669
+ } else if (normalNodes.length) {
12670
+ afterUpdateNodes(normalNodes);
12671
+ }
12425
12672
  };
12426
12673
  const nodeRemoveHandler = (nodes) => {
12427
12674
  depService.clear(nodes);
12428
12675
  };
12429
12676
  const historyChangeHandler = (page) => {
12430
- collectIdle([page], true);
12677
+ collectIdle([page], true).then(() => {
12678
+ updateDataSourceSchema([page], true);
12679
+ });
12431
12680
  };
12432
12681
  editorService.on("history-change", historyChangeHandler);
12433
12682
  editorService.on("root-change", rootChangeHandler);
@@ -12450,11 +12699,30 @@
12450
12699
  initDataSourceDepTarget(config);
12451
12700
  getApp()?.dataSourceManager?.addDataSource(config);
12452
12701
  };
12453
- const dataSourceUpdateHandler = (config) => {
12702
+ const dataSourceUpdateHandler = (config, { changeRecords }) => {
12703
+ let needRecollectDep = false;
12704
+ for (const changeRecord of changeRecords) {
12705
+ if (!changeRecord.propPath) {
12706
+ continue;
12707
+ }
12708
+ 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);
12709
+ if (needRecollectDep) {
12710
+ break;
12711
+ }
12712
+ }
12454
12713
  const root = editorService.get("root");
12455
- removeDataSourceTarget(config.id);
12456
- initDataSourceDepTarget(config);
12457
- collectIdle(root?.items || [], true);
12714
+ if (needRecollectDep) {
12715
+ if (Array.isArray(root?.items)) {
12716
+ depService.clearIdleTasks();
12717
+ removeDataSourceTarget(config.id);
12718
+ initDataSourceDepTarget(config);
12719
+ collectIdle(root.items, true).then(() => {
12720
+ updateDataSourceSchema(root?.items || [], true);
12721
+ });
12722
+ }
12723
+ } else if (root?.dataSources) {
12724
+ getApp()?.dataSourceManager?.updateSchema(root.dataSources);
12725
+ }
12458
12726
  };
12459
12727
  const removeDataSourceTarget = (id) => {
12460
12728
  depService.removeTarget(id, core.DepTargetType.DATA_SOURCE);
@@ -12462,8 +12730,13 @@
12462
12730
  depService.removeTarget(id, core.DepTargetType.DATA_SOURCE_METHOD);
12463
12731
  };
12464
12732
  const dataSourceRemoveHandler = (id) => {
12733
+ const root = editorService.get("root");
12734
+ const nodeIds = Object.keys(root?.dataSourceDeps?.[id] || {});
12735
+ const nodes = utils.getNodes(nodeIds, root?.items);
12736
+ collectIdle(nodes, false).then(() => {
12737
+ updateDataSourceSchema(nodes, false);
12738
+ });
12465
12739
  removeDataSourceTarget(id);
12466
- getApp()?.dataSourceManager?.removeDataSource(id);
12467
12740
  };
12468
12741
  dataSourceService.on("add", dataSourceAddHandler);
12469
12742
  dataSourceService.on("update", dataSourceUpdateHandler);
@@ -12471,7 +12744,7 @@
12471
12744
  vue.onBeforeUnmount(() => {
12472
12745
  depService.off("add-target", targetAddHandler);
12473
12746
  depService.off("remove-target", targetRemoveHandler);
12474
- depService.off("collected", collectedHandler);
12747
+ depService.off("collected", depCollectedHandler);
12475
12748
  editorService.off("history-change", historyChangeHandler);
12476
12749
  editorService.off("root-change", rootChangeHandler);
12477
12750
  editorService.off("add", nodeAddHandler);
@@ -12528,7 +12801,8 @@
12528
12801
  isContainer: { type: Function },
12529
12802
  customContentMenu: { type: Function },
12530
12803
  extendFormState: { type: Function },
12531
- pageBarSortOptions: {}
12804
+ pageBarSortOptions: {},
12805
+ pageFilterFunction: { type: Function }
12532
12806
  }, defaultEditorProps),
12533
12807
  emits: ["props-panel-mounted", "update:modelValue", "props-form-error", "props-submit-error"],
12534
12808
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -12577,7 +12851,8 @@
12577
12851
  return (_ctx, _cache) => {
12578
12852
  return vue.openBlock(), vue.createBlock(_sfc_main$r, {
12579
12853
  "disabled-page-fragment": _ctx.disabledPageFragment,
12580
- "page-bar-sort-options": _ctx.pageBarSortOptions
12854
+ "page-bar-sort-options": _ctx.pageBarSortOptions,
12855
+ "page-filter-function": _ctx.pageFilterFunction
12581
12856
  }, {
12582
12857
  header: vue.withCtx(() => [
12583
12858
  vue.renderSlot(_ctx.$slots, "header")
@@ -12690,6 +12965,9 @@
12690
12965
  "page-bar": vue.withCtx(() => [
12691
12966
  vue.renderSlot(_ctx.$slots, "page-bar")
12692
12967
  ]),
12968
+ "page-bar-add-button": vue.withCtx(() => [
12969
+ vue.renderSlot(_ctx.$slots, "page-bar-add-button")
12970
+ ]),
12693
12971
  "page-bar-title": vue.withCtx(({ page }) => [
12694
12972
  vue.renderSlot(_ctx.$slots, "page-bar-title", { page })
12695
12973
  ]),
@@ -12700,7 +12978,7 @@
12700
12978
  vue.renderSlot(_ctx.$slots, "page-list-popover", { list })
12701
12979
  ]),
12702
12980
  _: 3
12703
- }, 8, ["disabled-page-fragment", "page-bar-sort-options"]);
12981
+ }, 8, ["disabled-page-fragment", "page-bar-sort-options", "page-filter-function"]);
12704
12982
  };
12705
12983
  }
12706
12984
  });
@@ -12835,6 +13113,7 @@
12835
13113
  exports.getRelativeStyle = getRelativeStyle;
12836
13114
  exports.historyService = historyService;
12837
13115
  exports.info = info;
13116
+ exports.isIncludeDataSource = isIncludeDataSource;
12838
13117
  exports.log = log;
12839
13118
  exports.moveItemsInContainer = moveItemsInContainer;
12840
13119
  exports.numberOptions = numberOptions;
@@ -12847,11 +13126,9 @@
12847
13126
  exports.stageOverlayService = stageOverlayService;
12848
13127
  exports.storageService = storageService;
12849
13128
  exports.styleTabConfig = styleTabConfig;
12850
- exports.traverseNode = traverseNode;
12851
13129
  exports.uiService = uiService;
12852
13130
  exports.updateStatus = updateStatus;
12853
13131
  exports.useCodeBlockEdit = useCodeBlockEdit;
12854
- exports.useDataSourceMethod = useDataSourceMethod;
12855
13132
  exports.useEditorContentHeight = useEditorContentHeight;
12856
13133
  exports.useFilter = useFilter;
12857
13134
  exports.useFloatBox = useFloatBox;