@jzg223/design-runtime 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +176 -0
- package/README.md +275 -2
- package/dist/_virtual/_plugin-vue_export-helper.js +10 -0
- package/dist/api.js +149 -0
- package/dist/comb/design-comb.vue.js +7 -0
- package/dist/comb/design-comb2.vue.js +591 -0
- package/dist/compat.js +74 -0
- package/dist/components/ApiSwitch.vue.js +7 -0
- package/dist/components/ApiSwitch2.vue.js +98 -0
- package/dist/components/design-debug/dev-mode-toggle.vue.js +7 -0
- package/dist/components/design-debug/dev-mode-toggle2.vue.js +41 -0
- package/dist/components/design-debug/dev-mode.js +45 -0
- package/dist/components/design-debug/dev-state-button.vue.js +7 -0
- package/dist/components/design-debug/dev-state-button2.vue.js +447 -0
- package/dist/components/design-debug/expr-eval.js +81 -0
- package/dist/components/design-shared/host-api.js +47 -0
- package/dist/components/design-shared/popup-host.js +11 -0
- package/dist/components/design-table/design-table-inner.vue.js +7 -0
- package/dist/components/design-table/design-table-inner2.vue.js +39 -0
- package/dist/components/design-table/design-table.vue.js +7 -0
- package/dist/components/design-table/design-table2.vue.js +937 -0
- package/dist/components/design-table/row-actions/delete-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/delete-action2.vue.js +42 -0
- package/dist/components/design-table/row-actions/edit-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/edit-action2.vue.js +145 -0
- package/dist/components/design-table/row-actions/index.js +36 -0
- package/dist/components/design-table/row-actions/modal-comb-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/modal-comb-action2.vue.js +66 -0
- package/dist/components/design-table/row-actions/modal-custom-action.vue.js +7 -0
- package/dist/components/design-table/row-actions/modal-custom-action2.vue.js +105 -0
- package/dist/components/design-table/row-actions/modal-form-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/modal-form-action2.vue.js +82 -0
- package/dist/components/design-table/row-actions/modal-table-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/modal-table-action2.vue.js +67 -0
- package/dist/components/design-table/row-actions/modal-tree-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/modal-tree-action2.vue.js +70 -0
- package/dist/components/design-table/row-actions/navigate-comb-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/navigate-comb-action2.vue.js +47 -0
- package/dist/components/design-table/row-actions/navigate-form-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/navigate-form-action2.vue.js +47 -0
- package/dist/components/design-table/row-actions/navigate-table-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/navigate-table-action2.vue.js +47 -0
- package/dist/components/design-table/row-actions/navigate-tree-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/navigate-tree-action2.vue.js +47 -0
- package/dist/components/design-table/row-actions/other-action.vue.js +4 -0
- package/dist/components/design-table/row-actions/other-action2.vue.js +44 -0
- package/dist/components/design-tools/add-tool.vue.js +4 -0
- package/dist/components/design-tools/add-tool2.vue.js +136 -0
- package/dist/components/design-tools/command-executor.js +135 -0
- package/dist/components/design-tools/export-tool.vue.js +4 -0
- package/dist/components/design-tools/export-tool2.vue.js +46 -0
- package/dist/components/design-tools/import-tool.vue.js +4 -0
- package/dist/components/design-tools/import-tool2.vue.js +101 -0
- package/dist/components/design-tools/index.js +36 -0
- package/dist/components/design-tools/modal-comb-tool.vue.js +4 -0
- package/dist/components/design-tools/modal-comb-tool2.vue.js +56 -0
- package/dist/components/design-tools/modal-form-tool.vue.js +4 -0
- package/dist/components/design-tools/modal-form-tool2.vue.js +66 -0
- package/dist/components/design-tools/modal-hcm-tool.vue.js +7 -0
- package/dist/components/design-tools/modal-hcm-tool2.vue.js +85 -0
- package/dist/components/design-tools/modal-table-tool.vue.js +4 -0
- package/dist/components/design-tools/modal-table-tool2.vue.js +54 -0
- package/dist/components/design-tools/modal-tree-tool.vue.js +4 -0
- package/dist/components/design-tools/modal-tree-tool2.vue.js +57 -0
- package/dist/components/design-tools/navigate-comb-tool.vue.js +4 -0
- package/dist/components/design-tools/navigate-comb-tool2.vue.js +34 -0
- package/dist/components/design-tools/navigate-form-tool.vue.js +4 -0
- package/dist/components/design-tools/navigate-form-tool2.vue.js +34 -0
- package/dist/components/design-tools/navigate-table-tool.vue.js +4 -0
- package/dist/components/design-tools/navigate-table-tool2.vue.js +33 -0
- package/dist/components/design-tools/other-tool.vue.js +4 -0
- package/dist/components/design-tools/other-tool2.vue.js +34 -0
- package/dist/components/flow-status-cell/flow-status-cell.vue.js +7 -0
- package/dist/components/flow-status-cell/flow-status-cell2.vue.js +124 -0
- package/dist/flow.js +22 -0
- package/dist/form/cell-condition.js +122 -0
- package/dist/form/derived-express.js +34 -0
- package/dist/form/design-form-inner.vue.js +7 -0
- package/dist/form/design-form-inner2.vue.js +449 -0
- package/dist/form/design-form.vue.js +7 -0
- package/dist/form/design-form2.vue.js +681 -0
- package/dist/form/fields/checkbox-field.vue.js +88 -0
- package/dist/form/fields/checkbox-field2.vue.js +4 -0
- package/dist/form/fields/custom-field.vue.js +36 -0
- package/dist/form/fields/custom-field2.vue.js +4 -0
- package/dist/form/fields/date-field.vue.js +64 -0
- package/dist/form/fields/date-field2.vue.js +4 -0
- package/dist/form/fields/embedded-list-field.vue.js +7 -0
- package/dist/form/fields/embedded-list-field2.vue.js +437 -0
- package/dist/form/fields/file-field.vue.js +88 -0
- package/dist/form/fields/file-field2.vue.js +4 -0
- package/dist/form/fields/image-field.vue.js +90 -0
- package/dist/form/fields/image-field2.vue.js +4 -0
- package/dist/form/fields/index.js +106 -0
- package/dist/form/fields/month-field.vue.js +51 -0
- package/dist/form/fields/month-field2.vue.js +4 -0
- package/dist/form/fields/org-select-field.vue.js +7 -0
- package/dist/form/fields/org-select-field2.vue.js +187 -0
- package/dist/form/fields/orgs-select-field.vue.js +182 -0
- package/dist/form/fields/orgs-select-field2.vue.js +4 -0
- package/dist/form/fields/radio-field.vue.js +91 -0
- package/dist/form/fields/radio-field2.vue.js +4 -0
- package/dist/form/fields/select-field.vue.js +7 -0
- package/dist/form/fields/select-field2.vue.js +317 -0
- package/dist/form/fields/splitline-field.vue.js +7 -0
- package/dist/form/fields/splitline-field2.vue.js +50 -0
- package/dist/form/fields/switch-field.vue.js +32 -0
- package/dist/form/fields/switch-field2.vue.js +4 -0
- package/dist/form/fields/text-field.vue.js +78 -0
- package/dist/form/fields/text-field2.vue.js +4 -0
- package/dist/form/fields/time-field.vue.js +50 -0
- package/dist/form/fields/time-field2.vue.js +4 -0
- package/dist/form/fields/tree-field.vue.js +157 -0
- package/dist/form/fields/tree-field2.vue.js +4 -0
- package/dist/form/number-precision.js +18 -0
- package/dist/form/transformer.js +162 -0
- package/dist/host.js +76 -0
- package/dist/http.js +19 -0
- package/dist/index.js +166 -0
- package/dist/mapping.js +44 -0
- package/dist/org/dept-api.js +30 -0
- package/dist/org/dept-tree-source.js +53 -0
- package/dist/org/dept-tree.js +122 -0
- package/dist/registry.js +77 -0
- package/dist/search/design-search.vue.js +7 -0
- package/dist/search/design-search2.vue.js +232 -0
- package/dist/search/transformer.js +115 -0
- package/dist/style.css +1220 -0
- package/dist/table/data.js +18 -0
- package/dist/table/load-gate.js +19 -0
- package/dist/table/query-body.js +59 -0
- package/dist/table/query-dedupe.js +54 -0
- package/dist/table/query-search.js +9 -0
- package/dist/table/row-action-mapping.js +34 -0
- package/dist/table/transformer.js +328 -0
- package/dist/tree/design-tree.vue.js +7 -0
- package/dist/tree/design-tree2.vue.js +783 -0
- package/dist/types/api.d.ts +83 -0
- package/dist/types/comb/design-comb.vue.d.ts +38 -0
- package/dist/types/compat.d.ts +46 -0
- package/dist/types/components/ApiSwitch.vue.d.ts +31 -0
- package/dist/types/components/design-debug/dev-mode-toggle.vue.d.ts +2 -0
- package/dist/types/components/design-debug/dev-mode.d.ts +8 -0
- package/dist/types/components/design-debug/dev-state-button.vue.d.ts +55 -0
- package/dist/types/components/design-debug/expr-eval.d.ts +55 -0
- package/dist/types/components/design-shared/host-api.d.ts +60 -0
- package/dist/types/components/design-shared/popup-host.d.ts +13 -0
- package/dist/types/components/design-table/design-table-inner.vue.d.ts +19 -0
- package/dist/types/components/design-table/design-table.vue.d.ts +70 -0
- package/dist/types/components/design-table/row-actions/delete-action.vue.d.ts +12 -0
- package/dist/types/components/design-table/row-actions/edit-action.vue.d.ts +14 -0
- package/dist/types/components/design-table/row-actions/index.d.ts +25 -0
- package/dist/types/components/design-table/row-actions/modal-comb-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/modal-custom-action.vue.d.ts +15 -0
- package/dist/types/components/design-table/row-actions/modal-form-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/modal-table-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/modal-tree-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/navigate-comb-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/navigate-form-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/navigate-table-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/navigate-tree-action.vue.d.ts +10 -0
- package/dist/types/components/design-table/row-actions/other-action.vue.d.ts +14 -0
- package/dist/types/components/design-tools/add-tool.vue.d.ts +23 -0
- package/dist/types/components/design-tools/command-executor.d.ts +80 -0
- package/dist/types/components/design-tools/export-tool.vue.d.ts +9 -0
- package/dist/types/components/design-tools/import-tool.vue.d.ts +14 -0
- package/dist/types/components/design-tools/index.d.ts +23 -0
- package/dist/types/components/design-tools/modal-comb-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/modal-form-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/modal-hcm-tool.vue.d.ts +23 -0
- package/dist/types/components/design-tools/modal-table-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/modal-tree-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/navigate-comb-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/navigate-form-tool.vue.d.ts +11 -0
- package/dist/types/components/design-tools/navigate-table-tool.vue.d.ts +12 -0
- package/dist/types/components/design-tools/other-tool.vue.d.ts +16 -0
- package/dist/types/components/flow-status-cell/flow-status-cell.vue.d.ts +14 -0
- package/dist/types/components/index.d.ts +33 -0
- package/dist/types/flow.d.ts +50 -0
- package/dist/types/form/cell-condition.d.ts +35 -0
- package/dist/types/form/derived-express.d.ts +28 -0
- package/dist/types/form/design-form-inner.vue.d.ts +55 -0
- package/dist/types/form/design-form.vue.d.ts +96 -0
- package/dist/types/form/fields/checkbox-field.vue.d.ts +14 -0
- package/dist/types/form/fields/custom-field.vue.d.ts +22 -0
- package/dist/types/form/fields/date-field.vue.d.ts +12 -0
- package/dist/types/form/fields/embedded-list-field.vue.d.ts +26 -0
- package/dist/types/form/fields/file-field.vue.d.ts +12 -0
- package/dist/types/form/fields/image-field.vue.d.ts +12 -0
- package/dist/types/form/fields/index.d.ts +34 -0
- package/dist/types/form/fields/month-field.vue.d.ts +12 -0
- package/dist/types/form/fields/org-select-field.vue.d.ts +14 -0
- package/dist/types/form/fields/orgs-select-field.vue.d.ts +12 -0
- package/dist/types/form/fields/radio-field.vue.d.ts +14 -0
- package/dist/types/form/fields/select-field.vue.d.ts +14 -0
- package/dist/types/form/fields/splitline-field.vue.d.ts +7 -0
- package/dist/types/form/fields/switch-field.vue.d.ts +12 -0
- package/dist/types/form/fields/text-field.vue.d.ts +12 -0
- package/dist/types/form/fields/time-field.vue.d.ts +12 -0
- package/dist/types/form/fields/tree-field.vue.d.ts +12 -0
- package/dist/types/form/number-precision.d.ts +15 -0
- package/dist/types/form/transformer.d.ts +27 -0
- package/dist/types/host.d.ts +182 -0
- package/dist/types/http.d.ts +59 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types/mapping.d.ts +39 -0
- package/dist/types/org/dept-api.d.ts +12 -0
- package/dist/types/org/dept-tree-source.d.ts +15 -0
- package/dist/types/org/dept-tree.d.ts +62 -0
- package/dist/types/registry.d.ts +79 -0
- package/dist/types/search/design-search.vue.d.ts +46 -0
- package/dist/types/search/transformer.d.ts +36 -0
- package/dist/types/table/data.d.ts +30 -0
- package/dist/types/table/index.d.ts +20 -0
- package/dist/types/table/load-gate.d.ts +24 -0
- package/dist/types/table/query-body.d.ts +46 -0
- package/dist/types/table/query-dedupe.d.ts +42 -0
- package/dist/types/table/query-search.d.ts +21 -0
- package/dist/types/table/row-action-mapping.d.ts +36 -0
- package/dist/types/table/transformer.d.ts +59 -0
- package/dist/types/tree/design-tree.vue.d.ts +33 -0
- package/dist/types/types.d.ts +525 -0
- package/dist/types/utils/default-value.d.ts +16 -0
- package/dist/types/utils/download.d.ts +9 -0
- package/dist/types/utils/popup-width.d.ts +21 -0
- package/dist/utils/default-value.js +38 -0
- package/dist/utils/download.js +19 -0
- package/dist/utils/popup-width.js +19 -0
- package/package.json +73 -4
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
import { defineComponent, computed, ref, watch, openBlock, createElementBlock, createVNode, unref, createBlock, withCtx, Fragment, renderList, createTextVNode, toDisplayString, resolveDynamicComponent, createCommentVNode, createElementVNode, normalizeClass, withDirectives, vShow } from "vue";
|
|
2
|
+
import { useRoute, useRouter } from "vue-router";
|
|
3
|
+
import { Spin, Alert, Result, Card, Space, Button } from "antdv-next";
|
|
4
|
+
import { fetchCombConfig, fetchCombData } from "../api.js";
|
|
5
|
+
import DesignTable from "../components/design-table/design-table.vue.js";
|
|
6
|
+
import { resolveToolComponent } from "../components/design-tools/index.js";
|
|
7
|
+
import DesignDevStateButton from "../components/design-debug/dev-state-button.vue.js";
|
|
8
|
+
import DesignForm from "../form/design-form.vue.js";
|
|
9
|
+
import { isOwnRoutePage, buildExtraParams, buildMappedParams } from "../mapping.js";
|
|
10
|
+
const _hoisted_1 = { class: "design-comb" };
|
|
11
|
+
const _hoisted_2 = {
|
|
12
|
+
key: 0,
|
|
13
|
+
class: "flex-center py-20"
|
|
14
|
+
};
|
|
15
|
+
const _hoisted_3 = {
|
|
16
|
+
key: 1,
|
|
17
|
+
class: "py-8"
|
|
18
|
+
};
|
|
19
|
+
const _hoisted_4 = {
|
|
20
|
+
key: 0,
|
|
21
|
+
class: "design-comb-toolbar"
|
|
22
|
+
};
|
|
23
|
+
const _hoisted_5 = {
|
|
24
|
+
key: 1,
|
|
25
|
+
class: "design-comb__flat"
|
|
26
|
+
};
|
|
27
|
+
const _hoisted_6 = { class: "design-comb__flat-title" };
|
|
28
|
+
const _hoisted_7 = {
|
|
29
|
+
key: 0,
|
|
30
|
+
class: "design-comb__pane"
|
|
31
|
+
};
|
|
32
|
+
const _hoisted_8 = {
|
|
33
|
+
key: 1,
|
|
34
|
+
class: "design-comb__pane"
|
|
35
|
+
};
|
|
36
|
+
const _hoisted_9 = {
|
|
37
|
+
key: 2,
|
|
38
|
+
class: "design-comb__tabs"
|
|
39
|
+
};
|
|
40
|
+
const _hoisted_10 = {
|
|
41
|
+
class: "design-comb__tabnav",
|
|
42
|
+
role: "tablist"
|
|
43
|
+
};
|
|
44
|
+
const _hoisted_11 = ["aria-selected", "onClick"];
|
|
45
|
+
const _hoisted_12 = { class: "design-comb__tabbody" };
|
|
46
|
+
const _hoisted_13 = {
|
|
47
|
+
key: 0,
|
|
48
|
+
class: "design-comb__pane"
|
|
49
|
+
};
|
|
50
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
51
|
+
...{ name: "DesignComb" },
|
|
52
|
+
__name: "design-comb",
|
|
53
|
+
props: {
|
|
54
|
+
category: { default: "" },
|
|
55
|
+
name: { default: "" },
|
|
56
|
+
config: { default: null },
|
|
57
|
+
sourceId: { default: void 0 },
|
|
58
|
+
parentParams: { default: () => ({}) },
|
|
59
|
+
devButtonTop: { default: 10 }
|
|
60
|
+
},
|
|
61
|
+
emits: ["update:title", "update:remarks", "config-loaded", "tool-command"],
|
|
62
|
+
setup(__props, { emit: __emit }) {
|
|
63
|
+
const emit = __emit;
|
|
64
|
+
const props = __props;
|
|
65
|
+
const route = useRoute();
|
|
66
|
+
const extraParams = computed(() => {
|
|
67
|
+
const routeParams = isOwnRoutePage(route.path, props.category, props.name) ? { ...route.params, ...route.query } : {};
|
|
68
|
+
return buildExtraParams(routeParams, props.parentParams);
|
|
69
|
+
});
|
|
70
|
+
const combSourceId = computed(() => {
|
|
71
|
+
const raw = props.sourceId;
|
|
72
|
+
if (raw === void 0 || raw === null || raw === "") return void 0;
|
|
73
|
+
const s = String(raw);
|
|
74
|
+
return s === "undefined" || s === "null" ? void 0 : s;
|
|
75
|
+
});
|
|
76
|
+
const loading = ref(false);
|
|
77
|
+
const error = ref(null);
|
|
78
|
+
const config = ref(null);
|
|
79
|
+
const data = ref(null);
|
|
80
|
+
const activeKey = ref("0");
|
|
81
|
+
function normalizeItems(raw) {
|
|
82
|
+
if (Array.isArray(raw)) return raw;
|
|
83
|
+
if (typeof raw === "string") {
|
|
84
|
+
try {
|
|
85
|
+
const parsed = JSON.parse(raw);
|
|
86
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
87
|
+
} catch {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
const displayMode = computed(() => {
|
|
94
|
+
var _a;
|
|
95
|
+
const mode = (_a = config.value) == null ? void 0 : _a.displayMode;
|
|
96
|
+
return mode === "flat" || mode === "tabs" ? mode : "tabs";
|
|
97
|
+
});
|
|
98
|
+
const items = computed(() => {
|
|
99
|
+
if (!config.value) return [];
|
|
100
|
+
return normalizeItems(config.value.config);
|
|
101
|
+
});
|
|
102
|
+
const mountedKeys = ref(/* @__PURE__ */ new Set([activeKey.value]));
|
|
103
|
+
watch(activeKey, (key) => {
|
|
104
|
+
if (!mountedKeys.value.has(key)) {
|
|
105
|
+
mountedKeys.value = new Set(mountedKeys.value).add(key);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
const compiledExprs = /* @__PURE__ */ new Map();
|
|
109
|
+
function patchPlaceholders(expr) {
|
|
110
|
+
return expr.replace(/\$\{([^}]+)\}/g, (_m, path) => {
|
|
111
|
+
const p = path.trim();
|
|
112
|
+
const isSimplePath = /^[A-Za-z_$][\w$]*(?:\.[\w$]+)*$/.test(p);
|
|
113
|
+
if (isSimplePath && !p.startsWith("data.") && !p.startsWith("params.")) {
|
|
114
|
+
return `\${data.${p}}`;
|
|
115
|
+
}
|
|
116
|
+
return `\${${p}}`;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function compileExpr(expr) {
|
|
120
|
+
const cached = compiledExprs.get(expr);
|
|
121
|
+
if (cached) return cached;
|
|
122
|
+
const trimmed = expr.trim();
|
|
123
|
+
const isTemplateLiteral = trimmed.length > 1 && trimmed.startsWith("`") && trimmed.endsWith("`");
|
|
124
|
+
let js;
|
|
125
|
+
if (isTemplateLiteral) {
|
|
126
|
+
js = `return (${patchPlaceholders(expr)});`;
|
|
127
|
+
} else if (/\$\{/.test(expr)) {
|
|
128
|
+
js = `return (\`${patchPlaceholders(expr)}\`);`;
|
|
129
|
+
} else {
|
|
130
|
+
js = `return (${expr});`;
|
|
131
|
+
}
|
|
132
|
+
const fn = new Function("data", "params", js);
|
|
133
|
+
compiledExprs.set(expr, fn);
|
|
134
|
+
return fn;
|
|
135
|
+
}
|
|
136
|
+
function renderExpress(expr, record, params) {
|
|
137
|
+
try {
|
|
138
|
+
const result = compileExpr(expr)(record, params ?? {});
|
|
139
|
+
return result === null || result === void 0 ? "" : String(result);
|
|
140
|
+
} catch (err) {
|
|
141
|
+
console.warn(`[design-comb] 表达式错误: ${expr}`, (err == null ? void 0 : err.message) ?? err);
|
|
142
|
+
return "";
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function debugEvalExpress(expr, record, params) {
|
|
146
|
+
const raw = (expr ?? "").trim();
|
|
147
|
+
if (!raw) return { configured: false, ok: true };
|
|
148
|
+
try {
|
|
149
|
+
const result = compileExpr(raw)(record, params ?? {});
|
|
150
|
+
const value = result === null || result === void 0 ? "" : String(result);
|
|
151
|
+
return { configured: true, ok: true, value };
|
|
152
|
+
} catch (err) {
|
|
153
|
+
return { configured: true, ok: false, error: (err == null ? void 0 : err.message) ?? String(err) };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const title = computed(() => {
|
|
157
|
+
const cfg = config.value;
|
|
158
|
+
if (!cfg) return "";
|
|
159
|
+
const runtimeTitle = String(cfg.runtimeTitle ?? "").trim();
|
|
160
|
+
if (runtimeTitle) {
|
|
161
|
+
return runtimeTitle;
|
|
162
|
+
}
|
|
163
|
+
if (cfg.expressTitle && data.value) {
|
|
164
|
+
return renderExpress(cfg.expressTitle, data.value, extraParams.value) || "";
|
|
165
|
+
}
|
|
166
|
+
return "";
|
|
167
|
+
});
|
|
168
|
+
watch(title, (val) => {
|
|
169
|
+
if (val) {
|
|
170
|
+
emit("update:title", val);
|
|
171
|
+
}
|
|
172
|
+
}, { immediate: true });
|
|
173
|
+
watch(
|
|
174
|
+
() => config.value,
|
|
175
|
+
(cfg) => emit("config-loaded", cfg ?? null),
|
|
176
|
+
{ immediate: true }
|
|
177
|
+
);
|
|
178
|
+
watch(
|
|
179
|
+
() => {
|
|
180
|
+
var _a;
|
|
181
|
+
return (_a = config.value) == null ? void 0 : _a.remarks;
|
|
182
|
+
},
|
|
183
|
+
(val) => emit("update:remarks", val ?? ""),
|
|
184
|
+
{ immediate: true }
|
|
185
|
+
);
|
|
186
|
+
const expressContext = computed(() => {
|
|
187
|
+
const ctx = { ...data.value ?? {}, ...extraParams.value };
|
|
188
|
+
if (combSourceId.value !== void 0) ctx.id = combSourceId.value;
|
|
189
|
+
return ctx;
|
|
190
|
+
});
|
|
191
|
+
function getItemSourceId(item) {
|
|
192
|
+
const expr = item.expressId;
|
|
193
|
+
if (!expr) return void 0;
|
|
194
|
+
const val = renderExpress(expr, expressContext.value, extraParams.value);
|
|
195
|
+
return val === "" || val === "undefined" || val === "null" ? void 0 : val;
|
|
196
|
+
}
|
|
197
|
+
const itemScope = computed(() => ({
|
|
198
|
+
params: extraParams.value,
|
|
199
|
+
data: data.value ?? {}
|
|
200
|
+
}));
|
|
201
|
+
const itemParamsCache = /* @__PURE__ */ new Map();
|
|
202
|
+
let itemParamsScopeKey = "";
|
|
203
|
+
function getItemParams(item) {
|
|
204
|
+
const scopeKey = JSON.stringify(itemScope.value);
|
|
205
|
+
if (scopeKey !== itemParamsScopeKey) {
|
|
206
|
+
itemParamsScopeKey = scopeKey;
|
|
207
|
+
itemParamsCache.clear();
|
|
208
|
+
}
|
|
209
|
+
let hit = itemParamsCache.get(item);
|
|
210
|
+
if (!hit) {
|
|
211
|
+
hit = buildMappedParams(item, itemScope.value);
|
|
212
|
+
itemParamsCache.set(item, hit);
|
|
213
|
+
}
|
|
214
|
+
return hit;
|
|
215
|
+
}
|
|
216
|
+
watch(
|
|
217
|
+
() => [items.value, itemScope.value],
|
|
218
|
+
() => {
|
|
219
|
+
if (!Array.isArray(items.value) || items.value.length === 0) return;
|
|
220
|
+
const scope = itemScope.value;
|
|
221
|
+
console.log(
|
|
222
|
+
"[design-comb:映射]",
|
|
223
|
+
JSON.stringify({
|
|
224
|
+
params: scope.params,
|
|
225
|
+
dataKeys: Object.keys(scope.data),
|
|
226
|
+
data: scope.data,
|
|
227
|
+
items: items.value.map((it) => ({
|
|
228
|
+
type: it.type,
|
|
229
|
+
name: it.name,
|
|
230
|
+
title: it.title,
|
|
231
|
+
mappings: Array.isArray(it.mappings) ? it.mappings : [],
|
|
232
|
+
passed: buildMappedParams(it, scope)
|
|
233
|
+
}))
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
},
|
|
237
|
+
{ immediate: true }
|
|
238
|
+
);
|
|
239
|
+
const typeLabelMap = {
|
|
240
|
+
form: "表单",
|
|
241
|
+
table: "表格",
|
|
242
|
+
view: "视图"
|
|
243
|
+
};
|
|
244
|
+
function itemTabLabel(item) {
|
|
245
|
+
return item.title || typeLabelMap[item.type] || item.name || item.type;
|
|
246
|
+
}
|
|
247
|
+
function itemCategory(item) {
|
|
248
|
+
return item.module || props.category || "";
|
|
249
|
+
}
|
|
250
|
+
watch(items, () => {
|
|
251
|
+
activeKey.value = "0";
|
|
252
|
+
mountedKeys.value = /* @__PURE__ */ new Set(["0"]);
|
|
253
|
+
});
|
|
254
|
+
async function loadConfig() {
|
|
255
|
+
var _a, _b;
|
|
256
|
+
data.value = null;
|
|
257
|
+
if (props.config) {
|
|
258
|
+
config.value = props.config;
|
|
259
|
+
loading.value = false;
|
|
260
|
+
} else if (props.category && props.name) {
|
|
261
|
+
loading.value = true;
|
|
262
|
+
error.value = null;
|
|
263
|
+
try {
|
|
264
|
+
config.value = await fetchCombConfig(props.category, props.name);
|
|
265
|
+
} catch (err) {
|
|
266
|
+
const msg = (err == null ? void 0 : err.message) ?? "";
|
|
267
|
+
if (msg.includes("未发现")) {
|
|
268
|
+
config.value = null;
|
|
269
|
+
} else {
|
|
270
|
+
error.value = msg || "加载组合视图配置失败";
|
|
271
|
+
config.value = null;
|
|
272
|
+
}
|
|
273
|
+
} finally {
|
|
274
|
+
loading.value = false;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
const dataUrl = (_a = config.value) == null ? void 0 : _a.dataUrl;
|
|
278
|
+
if (dataUrl) {
|
|
279
|
+
let id = combSourceId.value;
|
|
280
|
+
if (id === void 0) {
|
|
281
|
+
const expr = (_b = config.value) == null ? void 0 : _b.expressId;
|
|
282
|
+
if (expr) {
|
|
283
|
+
const val = renderExpress(expr, extraParams.value, extraParams.value);
|
|
284
|
+
id = val === "" || val === "undefined" || val === "null" ? void 0 : val;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (id !== void 0) {
|
|
288
|
+
try {
|
|
289
|
+
data.value = await fetchCombData(dataUrl, { id, params: extraParams.value });
|
|
290
|
+
} catch (err) {
|
|
291
|
+
data.value = null;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
watch(
|
|
297
|
+
() => [
|
|
298
|
+
props.category,
|
|
299
|
+
props.name,
|
|
300
|
+
props.config,
|
|
301
|
+
props.sourceId,
|
|
302
|
+
extraParams.value
|
|
303
|
+
],
|
|
304
|
+
() => loadConfig(),
|
|
305
|
+
{ immediate: true }
|
|
306
|
+
);
|
|
307
|
+
const router = useRouter();
|
|
308
|
+
const parsedTools = computed(() => {
|
|
309
|
+
var _a;
|
|
310
|
+
return ((_a = config.value) == null ? void 0 : _a.toolBars) ?? [];
|
|
311
|
+
});
|
|
312
|
+
const toolLabelMap = {
|
|
313
|
+
add: "新增",
|
|
314
|
+
"navigate-form": "跳转表单",
|
|
315
|
+
"navigate-table": "跳转列表",
|
|
316
|
+
"navigate-combo": "跳转组合视图",
|
|
317
|
+
other: "其他"
|
|
318
|
+
};
|
|
319
|
+
function getToolLabel(tool) {
|
|
320
|
+
return tool.title || tool.label || toolLabelMap[tool.type ?? ""] || tool.type || "";
|
|
321
|
+
}
|
|
322
|
+
const navigateRouteMap = {
|
|
323
|
+
"navigate-form": "/design/form",
|
|
324
|
+
"navigate-table": "/design/table",
|
|
325
|
+
"navigate-combo": "/design/comb"
|
|
326
|
+
};
|
|
327
|
+
const toolScope = computed(() => ({
|
|
328
|
+
params: extraParams.value,
|
|
329
|
+
data: data.value ?? {}
|
|
330
|
+
}));
|
|
331
|
+
const toolRefs = ref({});
|
|
332
|
+
function setToolRef(idx) {
|
|
333
|
+
return (el) => {
|
|
334
|
+
toolRefs.value[idx] = el;
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function handleToolClick(tool, idx) {
|
|
338
|
+
var _a;
|
|
339
|
+
if (tool.type === "add") {
|
|
340
|
+
const inst = toolRefs.value[idx];
|
|
341
|
+
(_a = inst == null ? void 0 : inst.trigger) == null ? void 0 : _a.call(inst);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const prefix = navigateRouteMap[tool.type ?? ""];
|
|
345
|
+
if (prefix) {
|
|
346
|
+
const targetCategory = tool.targetFormCategory || tool.targetTableCategory || tool.targetComboCategory || props.category;
|
|
347
|
+
const targetName = tool.targetFormName || tool.targetTableName || tool.targetComboName;
|
|
348
|
+
if (targetCategory && targetName) {
|
|
349
|
+
const query = buildMappedParams(tool, toolScope.value);
|
|
350
|
+
router.push({ path: `${prefix}/${targetCategory}/${targetName}`, query });
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (tool.type === "other") {
|
|
355
|
+
emit("tool-command", tool);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const devState = computed(() => {
|
|
359
|
+
var _a, _b, _c;
|
|
360
|
+
return {
|
|
361
|
+
props: {
|
|
362
|
+
category: props.category,
|
|
363
|
+
name: props.name,
|
|
364
|
+
sourceId: props.sourceId,
|
|
365
|
+
config: props.config ? { id: props.config.id, name: props.config.name, title: props.config.title } : null,
|
|
366
|
+
parentParams: props.parentParams
|
|
367
|
+
},
|
|
368
|
+
route: {
|
|
369
|
+
params: route.params,
|
|
370
|
+
query: route.query
|
|
371
|
+
},
|
|
372
|
+
extraParams: extraParams.value,
|
|
373
|
+
config: config.value ? {
|
|
374
|
+
name: config.value.name,
|
|
375
|
+
title: config.value.title,
|
|
376
|
+
displayMode: displayMode.value,
|
|
377
|
+
dataUrl: config.value.dataUrl,
|
|
378
|
+
expressTitle: config.value.expressTitle,
|
|
379
|
+
expressId: config.value.expressId,
|
|
380
|
+
remarks: config.value.remarks,
|
|
381
|
+
toolBars: config.value.toolBars
|
|
382
|
+
} : null,
|
|
383
|
+
items: items.value.map((item) => ({
|
|
384
|
+
type: item.type,
|
|
385
|
+
name: item.name,
|
|
386
|
+
module: item.module,
|
|
387
|
+
title: item.title,
|
|
388
|
+
expressId: item.expressId
|
|
389
|
+
})),
|
|
390
|
+
activeKey: activeKey.value,
|
|
391
|
+
data: data.value,
|
|
392
|
+
expressContext: expressContext.value,
|
|
393
|
+
// 表达式求值实时诊断(与运行逻辑同一作用域):
|
|
394
|
+
// 组合级 dataUrl 的 expressId 作用域=extraParams;expressTitle 作用域=data;
|
|
395
|
+
// 组合项(表单)expressId 作用域=expressContext(data+extraParams),sourceId 即内嵌表单拿到的 id
|
|
396
|
+
exprEval: {
|
|
397
|
+
comb: {
|
|
398
|
+
dataUrl: ((_a = config.value) == null ? void 0 : _a.dataUrl) ?? "",
|
|
399
|
+
// 权威 id:上级 source-id(归一化后);未提供则看 config 级 expressId 对 extraParams 的求值
|
|
400
|
+
sourceIdProvided: combSourceId.value ?? "(未提供)",
|
|
401
|
+
dataReady: !!data.value,
|
|
402
|
+
dataKeys: data.value ? Object.keys(data.value) : [],
|
|
403
|
+
dataUrlId: debugEvalExpress((_b = config.value) == null ? void 0 : _b.expressId, extraParams.value, extraParams.value),
|
|
404
|
+
title: debugEvalExpress((_c = config.value) == null ? void 0 : _c.expressTitle, data.value ?? {}, extraParams.value)
|
|
405
|
+
},
|
|
406
|
+
items: items.value.map((item) => ({
|
|
407
|
+
type: item.type,
|
|
408
|
+
name: item.name,
|
|
409
|
+
title: item.title,
|
|
410
|
+
expressId: item.expressId ?? "",
|
|
411
|
+
sourceId: getItemSourceId(item) ?? "(空 → 按新增/不取数)",
|
|
412
|
+
eval: debugEvalExpress(item.expressId, expressContext.value, extraParams.value)
|
|
413
|
+
}))
|
|
414
|
+
},
|
|
415
|
+
loading: loading.value,
|
|
416
|
+
error: error.value
|
|
417
|
+
};
|
|
418
|
+
});
|
|
419
|
+
watch(
|
|
420
|
+
() => parsedTools.value.map((tool) => tool.type),
|
|
421
|
+
(types) => types.forEach((type) => resolveToolComponent(type)),
|
|
422
|
+
{ immediate: true }
|
|
423
|
+
);
|
|
424
|
+
return (_ctx, _cache) => {
|
|
425
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
426
|
+
loading.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
427
|
+
createVNode(unref(Spin), {
|
|
428
|
+
spinning: true,
|
|
429
|
+
tip: "加载组合视图配置中..."
|
|
430
|
+
})
|
|
431
|
+
])) : error.value ? (openBlock(), createElementBlock("div", _hoisted_3, [
|
|
432
|
+
createVNode(unref(Alert), {
|
|
433
|
+
message: error.value,
|
|
434
|
+
type: "error",
|
|
435
|
+
"show-icon": "",
|
|
436
|
+
closable: "",
|
|
437
|
+
onClose: _cache[0] || (_cache[0] = ($event) => error.value = null)
|
|
438
|
+
}, null, 8, ["message"])
|
|
439
|
+
])) : items.value.length === 0 ? (openBlock(), createBlock(unref(Result), {
|
|
440
|
+
key: 2,
|
|
441
|
+
status: "404",
|
|
442
|
+
title: "未发现组合视图配置",
|
|
443
|
+
"sub-title": "该视图尚未在构建端完成配置,或配置名称有误"
|
|
444
|
+
})) : (openBlock(), createBlock(unref(Card), {
|
|
445
|
+
key: 3,
|
|
446
|
+
bordered: false,
|
|
447
|
+
class: "design-comb__card"
|
|
448
|
+
}, {
|
|
449
|
+
default: withCtx(() => [
|
|
450
|
+
parsedTools.value.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
451
|
+
createVNode(unref(Space), null, {
|
|
452
|
+
default: withCtx(() => [
|
|
453
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(parsedTools.value, (tool, idx) => {
|
|
454
|
+
return openBlock(), createBlock(unref(Button), {
|
|
455
|
+
key: idx,
|
|
456
|
+
type: tool.type === "add" ? "primary" : "default",
|
|
457
|
+
onClick: ($event) => handleToolClick(tool, idx)
|
|
458
|
+
}, {
|
|
459
|
+
default: withCtx(() => [
|
|
460
|
+
createTextVNode(toDisplayString(getToolLabel(tool)), 1)
|
|
461
|
+
]),
|
|
462
|
+
_: 2
|
|
463
|
+
}, 1032, ["type", "onClick"]);
|
|
464
|
+
}), 128))
|
|
465
|
+
]),
|
|
466
|
+
_: 1
|
|
467
|
+
}),
|
|
468
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(parsedTools.value, (tool, idx) => {
|
|
469
|
+
return openBlock(), createBlock(resolveDynamicComponent(unref(resolveToolComponent)(tool.type)), {
|
|
470
|
+
key: "drawer-" + idx,
|
|
471
|
+
ref_for: true,
|
|
472
|
+
ref: setToolRef(idx),
|
|
473
|
+
tool,
|
|
474
|
+
category: __props.category,
|
|
475
|
+
"extra-params": extraParams.value,
|
|
476
|
+
"mapping-scope": toolScope.value
|
|
477
|
+
}, null, 8, ["tool", "category", "extra-params", "mapping-scope"]);
|
|
478
|
+
}), 128))
|
|
479
|
+
])) : createCommentVNode("", true),
|
|
480
|
+
displayMode.value === "flat" ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
481
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item, idx) => {
|
|
482
|
+
return openBlock(), createElementBlock("div", {
|
|
483
|
+
key: String(idx),
|
|
484
|
+
class: "design-comb__flat-item"
|
|
485
|
+
}, [
|
|
486
|
+
createElementVNode("div", _hoisted_6, toDisplayString(itemTabLabel(item)), 1),
|
|
487
|
+
item.type === "form" ? (openBlock(), createElementBlock("div", _hoisted_7, [
|
|
488
|
+
createVNode(DesignForm, {
|
|
489
|
+
category: itemCategory(item),
|
|
490
|
+
name: item.name,
|
|
491
|
+
"source-id": getItemSourceId(item),
|
|
492
|
+
"parent-params": getItemParams(item),
|
|
493
|
+
"dev-button-top": 48,
|
|
494
|
+
mode: "standalone"
|
|
495
|
+
}, null, 8, ["category", "name", "source-id", "parent-params"])
|
|
496
|
+
])) : item.type === "table" ? (openBlock(), createElementBlock("div", _hoisted_8, [
|
|
497
|
+
createVNode(DesignTable, {
|
|
498
|
+
category: itemCategory(item),
|
|
499
|
+
name: item.name,
|
|
500
|
+
"parent-params": getItemParams(item),
|
|
501
|
+
"no-page": true,
|
|
502
|
+
"dev-button-top": 48
|
|
503
|
+
}, null, 8, ["category", "name", "parent-params"])
|
|
504
|
+
])) : item.type === "view" ? (openBlock(), createBlock(unref(Alert), {
|
|
505
|
+
key: 2,
|
|
506
|
+
type: "info",
|
|
507
|
+
"show-icon": "",
|
|
508
|
+
message: "design-view 未迁移到 design-runtime(用户确认该组件未使用)"
|
|
509
|
+
})) : (openBlock(), createBlock(unref(Alert), {
|
|
510
|
+
key: 3,
|
|
511
|
+
type: "warning",
|
|
512
|
+
"show-icon": "",
|
|
513
|
+
message: `不支持的类型: ${item.type}`
|
|
514
|
+
}, null, 8, ["message"]))
|
|
515
|
+
]);
|
|
516
|
+
}), 128))
|
|
517
|
+
])) : (openBlock(), createElementBlock("div", _hoisted_9, [
|
|
518
|
+
createElementVNode("div", _hoisted_10, [
|
|
519
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item, idx) => {
|
|
520
|
+
return openBlock(), createElementBlock("button", {
|
|
521
|
+
key: String(idx),
|
|
522
|
+
type: "button",
|
|
523
|
+
role: "tab",
|
|
524
|
+
class: normalizeClass(["design-comb__tab", { "design-comb__tab--active": activeKey.value === String(idx) }]),
|
|
525
|
+
"aria-selected": activeKey.value === String(idx),
|
|
526
|
+
onClick: ($event) => activeKey.value = String(idx)
|
|
527
|
+
}, toDisplayString(itemTabLabel(item)), 11, _hoisted_11);
|
|
528
|
+
}), 128))
|
|
529
|
+
]),
|
|
530
|
+
createElementVNode("div", _hoisted_12, [
|
|
531
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item, idx) => {
|
|
532
|
+
return openBlock(), createElementBlock(Fragment, {
|
|
533
|
+
key: String(idx)
|
|
534
|
+
}, [
|
|
535
|
+
mountedKeys.value.has(String(idx)) ? withDirectives((openBlock(), createElementBlock("div", _hoisted_13, [
|
|
536
|
+
item.type === "form" ? (openBlock(), createBlock(DesignForm, {
|
|
537
|
+
key: 0,
|
|
538
|
+
category: itemCategory(item),
|
|
539
|
+
name: item.name,
|
|
540
|
+
"source-id": getItemSourceId(item),
|
|
541
|
+
"parent-params": getItemParams(item),
|
|
542
|
+
"dev-button-top": 48,
|
|
543
|
+
mode: "standalone"
|
|
544
|
+
}, null, 8, ["category", "name", "source-id", "parent-params"])) : item.type === "table" ? (openBlock(), createBlock(DesignTable, {
|
|
545
|
+
key: 1,
|
|
546
|
+
category: itemCategory(item),
|
|
547
|
+
name: item.name,
|
|
548
|
+
"parent-params": getItemParams(item),
|
|
549
|
+
"no-page": true,
|
|
550
|
+
"dev-button-top": 48
|
|
551
|
+
}, null, 8, ["category", "name", "parent-params"])) : item.type === "view" ? (openBlock(), createBlock(unref(Alert), {
|
|
552
|
+
key: 2,
|
|
553
|
+
type: "info",
|
|
554
|
+
"show-icon": "",
|
|
555
|
+
message: "design-view 未迁移到 design-runtime(用户确认该组件未使用)"
|
|
556
|
+
})) : (openBlock(), createBlock(unref(Alert), {
|
|
557
|
+
key: 3,
|
|
558
|
+
type: "warning",
|
|
559
|
+
"show-icon": "",
|
|
560
|
+
message: `不支持的类型: ${item.type}`
|
|
561
|
+
}, null, 8, ["message"]))
|
|
562
|
+
], 512)), [
|
|
563
|
+
[vShow, activeKey.value === String(idx)]
|
|
564
|
+
]) : createCommentVNode("", true)
|
|
565
|
+
], 64);
|
|
566
|
+
}), 128))
|
|
567
|
+
])
|
|
568
|
+
]))
|
|
569
|
+
]),
|
|
570
|
+
_: 1
|
|
571
|
+
})),
|
|
572
|
+
createVNode(DesignDevStateButton, {
|
|
573
|
+
"designer-category": __props.category,
|
|
574
|
+
"designer-name": __props.name,
|
|
575
|
+
"expr-scope": itemScope.value,
|
|
576
|
+
"expr-scope-labels": {
|
|
577
|
+
params: "组合视图自身参数(extraParams)",
|
|
578
|
+
data: "dataUrl 返回的数据"
|
|
579
|
+
},
|
|
580
|
+
state: devState.value,
|
|
581
|
+
top: __props.devButtonTop,
|
|
582
|
+
"designer-type": "combo",
|
|
583
|
+
title: "DesignComb"
|
|
584
|
+
}, null, 8, ["designer-category", "designer-name", "expr-scope", "state", "top"])
|
|
585
|
+
]);
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
export {
|
|
590
|
+
_sfc_main as default
|
|
591
|
+
};
|
package/dist/compat.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { version as version$1 } from "antdv-next";
|
|
2
|
+
import { version } from "vue";
|
|
3
|
+
const SUPPORTED_VERSIONS = {
|
|
4
|
+
// 2026-10-27 按**宿主实测**重定:demo-ui(vben 基座)实装 antdv-next 1.5.2。
|
|
5
|
+
// 原来的 ^1.7.0 是照本库 devDeps 写的,宿主装不进去 ⇒ 改为宿主真实起点,
|
|
6
|
+
// devDependencies 也一起降到 ^1.5.2,保证编译期与宿主看到的是同一套类型。
|
|
7
|
+
"antdv-next": "^1.5.2",
|
|
8
|
+
vue: "^3.5.0"
|
|
9
|
+
};
|
|
10
|
+
function parseVersion(raw) {
|
|
11
|
+
const matched = /^(\d+)\.(\d+)\.(\d+)/.exec(String(raw ?? "").trim());
|
|
12
|
+
if (!matched) return null;
|
|
13
|
+
return [Number(matched[1]), Number(matched[2]), Number(matched[3])];
|
|
14
|
+
}
|
|
15
|
+
function compare(a, b) {
|
|
16
|
+
for (let i = 0; i < 3; i += 1) {
|
|
17
|
+
if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1;
|
|
18
|
+
}
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
function satisfiesRange(version2, range) {
|
|
22
|
+
const found = parseVersion(version2);
|
|
23
|
+
const base = parseVersion(range.replace(/^[\^~><=*\s]+/, ""));
|
|
24
|
+
if (!found || !base) return false;
|
|
25
|
+
const expr = range.trim();
|
|
26
|
+
if (expr === "*" || expr === "") return true;
|
|
27
|
+
if (expr.startsWith("^")) {
|
|
28
|
+
if (compare(found, base) < 0) return false;
|
|
29
|
+
if (base[0] > 0) return found[0] === base[0];
|
|
30
|
+
if (base[1] > 0) return found[0] === 0 && found[1] === base[1];
|
|
31
|
+
return found[0] === 0 && found[1] === 0 && found[2] === base[2];
|
|
32
|
+
}
|
|
33
|
+
if (expr.startsWith("~")) {
|
|
34
|
+
if (compare(found, base) < 0) return false;
|
|
35
|
+
return found[0] === base[0] && found[1] === base[1];
|
|
36
|
+
}
|
|
37
|
+
if (expr.startsWith(">=")) return compare(found, base) >= 0;
|
|
38
|
+
if (expr.startsWith(">")) return compare(found, base) > 0;
|
|
39
|
+
if (expr.startsWith("<=")) return compare(found, base) <= 0;
|
|
40
|
+
if (expr.startsWith("<")) return compare(found, base) < 0;
|
|
41
|
+
return compare(found, base) === 0;
|
|
42
|
+
}
|
|
43
|
+
function checkDesignRuntimeCompat(options = {}) {
|
|
44
|
+
const actual = {
|
|
45
|
+
"antdv-next": String(version$1 ?? ""),
|
|
46
|
+
vue: String(version ?? "")
|
|
47
|
+
};
|
|
48
|
+
const items = Object.entries(SUPPORTED_VERSIONS).map(
|
|
49
|
+
([pkg, supported]) => {
|
|
50
|
+
const found = actual[pkg] ?? "(unknown)";
|
|
51
|
+
return { found, ok: satisfiesRange(found, supported), pkg, supported };
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
const bad = items.filter((item) => !item.ok);
|
|
55
|
+
const ok = bad.length === 0;
|
|
56
|
+
const message = ok ? `design-runtime 版本自检通过:${items.map((i) => `${i.pkg}@${i.found}`).join(" / ")}` : `design-runtime 依赖版本不在支持区间:${bad.map((i) => `${i.pkg}@${i.found}(支持 ${i.supported})`).join(";")}。请在宿主升级/降级对应依赖,或升级 design-runtime 大版本。`;
|
|
57
|
+
if (!options.silent) {
|
|
58
|
+
if (ok) {
|
|
59
|
+
console.info(`[design-runtime] ${message}`);
|
|
60
|
+
} else {
|
|
61
|
+
console.error(`[design-runtime] ${message}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const report = { items, message, ok };
|
|
65
|
+
if (!ok && options.throwOnError) {
|
|
66
|
+
throw new Error(`[design-runtime] ${message}`);
|
|
67
|
+
}
|
|
68
|
+
return report;
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
SUPPORTED_VERSIONS,
|
|
72
|
+
checkDesignRuntimeCompat,
|
|
73
|
+
satisfiesRange
|
|
74
|
+
};
|