@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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
版本规则:semver。**破坏性改动**(`installDesignPlatform` 的参数、公开导出、组件 props)
|
|
4
|
+
必须升大版本,并在本文件写清「宿主需要改什么」。
|
|
5
|
+
|
|
6
|
+
## 0.0.1(2026-10-27 首次发布)
|
|
7
|
+
|
|
8
|
+
首个对外可用版本。**本版本包含**:
|
|
9
|
+
|
|
10
|
+
- 组件:`DesignTable`(+ inner / 流程状态列)、`DesignForm`(+ inner)、`DesignComb`、`DesignTree`、
|
|
11
|
+
`DesignSearch`;**不包含** `DesignView`(已确认用不到,留在宿主)
|
|
12
|
+
- 行操作 12/12、工具条 12/12、表单字段 16/16 —— 全部按 `type` 走 `defineAsyncComponent` 懒加载
|
|
13
|
+
- 调试台:`DesignDevStateButton` / `DesignDevModeToggle`(默认零渲染,`?dev=1` 或
|
|
14
|
+
localStorage `design-dev-mode=1` 才出现)
|
|
15
|
+
- 宿主耦合一律**注入**:只有 `http` 必注入,其余(`ui` / `dict` / `workflow` / `upload` / `message` /
|
|
16
|
+
`modal` / `t` / `getAuth`)缺失时降级并 warn 一次
|
|
17
|
+
- peerDependencies:`vue ^3.5.0`、`antdv-next ^1.5.2`、`vue-router ^5.0.4`、
|
|
18
|
+
`@antdv-next/icons ^1.1.2`、`dayjs ^1.11.0`(**不含** `@vben/*`:那是源码导出,只能注入)
|
|
19
|
+
|
|
20
|
+
以下按迁移顺序记录各批改动。
|
|
21
|
+
|
|
22
|
+
### `DesignForm` 主组件迁入
|
|
23
|
+
|
|
24
|
+
- 新增组件 `DesignForm`(`src/form/design-form.vue`,约 960 行):配置加载 / 网格渲染 / 保存 /
|
|
25
|
+
「提交并走流程」/ 工具条,**行为保留**
|
|
26
|
+
- 迁移改动(6 条写在文件头):`useVbenModal`→`host.ui.useVbenModal`、
|
|
27
|
+
`applyModal`→`host.workflow.applyModal`(**任一缺失则提交降级为只保存不发起流程 + warn**)、
|
|
28
|
+
`alovaInstance`→`requireHttp()`(并去掉宿主的 `successMessageMode` 选项)、
|
|
29
|
+
`window.message`→`platformMessage()`、`DevStateButton` 不搬(`defineExpose({ devState, toolScope })`)、
|
|
30
|
+
工具条只渲染已迁的 3 个 navigate 工具(其余渲染前 warn 一次)
|
|
31
|
+
- 新增组件 `DesignFormInner`(`src/form/design-form-inner.vue`):单元格条件 / 派生回填 / 标签格 /
|
|
32
|
+
分割线 / 样式合并;`embedded-list` 未迁 → 渲染明确提示行
|
|
33
|
+
- 测试:`test:component` 扩到 13 条(含两条表单 SSR 用例);`npm test` 合计 **114 条**
|
|
34
|
+
|
|
35
|
+
### 表单逻辑层(design-form 第一步)
|
|
36
|
+
|
|
37
|
+
- 新增 `src/form/cell-condition.ts`(渲染条件 `vif` / 显示条件 `vshow`,**fail-open**:求值抛错按不隐藏)、
|
|
38
|
+
`src/form/derived-express.ts`(派生取值表达式与回填)、`src/form/number-precision.ts`(小数位/四舍五入)、
|
|
39
|
+
`src/form/transformer.ts`(表单配置 → schema + 网格布局)
|
|
40
|
+
- 新增 `src/form/fields/`:字段注册中心 + **11 个字段组件**
|
|
41
|
+
(text/select/date/month/time/switch/radio/checkbox/tree/splitline/custom)
|
|
42
|
+
- **注册表合并**:宿主那份 `fields/index.ts` 里有 `builtin`(字段类型)与 `custom`(comname)两份注册表,
|
|
43
|
+
后者与本库 `src/registry.ts` 是同一件事 ⇒ 迁移后 `custom` 相关 API 全部转发到 `registry.ts`,
|
|
44
|
+
于是「表单自定义单元格 / 表格自定义列 / 弹窗自定义组件」永远是同一份清单
|
|
45
|
+
- **修了一个宿主漏实现**:`transformFormConfig` 的注释承诺「新格式 config + 旧格式 content 两种」,
|
|
46
|
+
但代码只写了新格式分支 ⇒ 老配置(content 非空)会被静默转成空表单。已按注释补上旧格式解析
|
|
47
|
+
- 未迁字段:`file` / `image`(要宿主 `uploadApi`)、`org-select` / `orgs-select`(要部门懒加载树)、
|
|
48
|
+
`embedded-list`(要表格 + 工具条)—— 命中即回退占位输入框并 warn 一次
|
|
49
|
+
- peerDependencies 新增 **`dayjs ^1.11.0`**(日期/月份/时间字段用)
|
|
50
|
+
- 发现但**未改**的宿主老问题:`splitline-field` 把设计端的 `orientation`(left/center/right)传给
|
|
51
|
+
antdv-next 的 `Divider.orientation`(该 prop 只接受 horizontal/vertical)⇒ 取值被忽略、永远居中。
|
|
52
|
+
本库保持这个实际行为,要不要改用 `titlePlacement` 待产品拍板(已记 TODO)
|
|
53
|
+
- 测试:新增 `npm run test:form`(19 条);`npm test` 合计 **112 条**
|
|
54
|
+
|
|
55
|
+
### `DesignTable` 主组件迁入(P2-9 的核心目标)
|
|
56
|
+
|
|
57
|
+
- 新增组件 `DesignTable`(`src/components/design-table/design-table.vue`,1490 行)——
|
|
58
|
+
从宿主逐字搬迁,行为保留:列配置转换 / 查询表单 / 工具条(含列设置·刷新·全屏)/ 行操作 /
|
|
59
|
+
合计行 / 流程状态列 / 高度自适应 / 重复取数抑制 / 加载条件门禁
|
|
60
|
+
- 迁移改动(9 条都写在文件头注释里):`Page`→`host.ui.Page`(可退化)、6 个图标→`@antdv-next/icons`、
|
|
61
|
+
`useVbenVxeGrid`→`requireVxeGrid()`、`alovaInstance`→`requireHttp()`、`window.message`→`platformMessage()`、
|
|
62
|
+
`resolveCellComponent`→`resolveDesignComponent`、**删掉 DevStateButton**(状态改由
|
|
63
|
+
`defineExpose({ devState, exprScope })` 给宿主调试台读)、未迁类型不渲染(渲染前各自 warn 一次)、
|
|
64
|
+
CSS 设计令牌加兜底值(换宿主不至于变透明)
|
|
65
|
+
- 新增测试:`test:component` 扩到 11 条(含「注入 vxeGrid 能挂载」「未注入 vxeGrid 明确报错」两条表格用例);
|
|
66
|
+
`npm test` 合计 **93 条**
|
|
67
|
+
|
|
68
|
+
### 行操作(design-table/row-actions,先迁 7 个)
|
|
69
|
+
|
|
70
|
+
- 新增 `src/components/design-table/row-actions/`:`delete-action` / `other-action` /
|
|
71
|
+
`modal-custom-action` / 四个 `navigate-*-action` + `index.ts`
|
|
72
|
+
(`rowActionComponentMap` / `resolveRowActionComponent` / `pendingRowActionTypes`)
|
|
73
|
+
- 迁移改动:`#/router` → `useRouter()`(vue-router 已是 peer);`<a-button>` → 显式 `Button`;
|
|
74
|
+
`resolveCellComponent`(宿主 fields)→ `resolveDesignComponent`(本库注册表,宿主是双注册,只剩一份);
|
|
75
|
+
未注册的 `modal-custom` 从"占位输入框"改为**明确提示行**
|
|
76
|
+
- 未迁 5 个(`edit` / `modal-form` / `modal-table` / `modal-tree` / `modal-combo`)卡在兄弟组件本体:
|
|
77
|
+
表单 / 表格 / 树 / 组合视图还没搬,解析时 warn 一次并返回 undefined
|
|
78
|
+
- 测试:`test:component` 扩到 9 条(含行操作解析);`npm test` 合计 **91 条**
|
|
79
|
+
|
|
80
|
+
### 查询表单 + 工具条(design-search / design-tools 逻辑层)
|
|
81
|
+
|
|
82
|
+
- 新增 `src/search/transformer.ts`:`normalizeSearchCells` / `buildSearchFormOptions`
|
|
83
|
+
(查询配置 → 表单 schema:字段类型映射 / 字典选项合并 SQL 整行 / month+dateType / readonly / 默认值)
|
|
84
|
+
- 新增 `src/utils/default-value.ts`:`formatNow` / `resolveDefaultValue`(`defaultNow`、`${now}`、`${now:格式}`)
|
|
85
|
+
- `src/mapping.ts` 补 `isOwnRoutePage`(组件是否位于自己的路由页)
|
|
86
|
+
- 新增 `src/components/design-tools/command-executor.ts`:`executeCommand` / `openComponent`。
|
|
87
|
+
改的四处:`#/router` → 上下文的 `nav`(组件传 `useRouter()`);`window.message` / `window.modal` →
|
|
88
|
+
`host.message` / `host.modal`;**源码路径动态加载 → comname 注册表**;
|
|
89
|
+
**删除 UMD 远程组件**(宿主已全面退役)
|
|
90
|
+
- 新增工具条组件:`NavigateFormTool` / `NavigateTableTool` / `NavigateCombTool` / `OtherTool`
|
|
91
|
+
+ `resolveToolComponent`(未迁类型 warn 一次并返回 undefined,不静默渲染空按钮)
|
|
92
|
+
- peerDependencies 新增 **`vue-router ^5.0.4`**(按宿主实测 5.3.0)与 **`@antdv-next/icons ^1.1.2`**
|
|
93
|
+
- 新增测试 `npm run test:search`(23 条);`npm test` 合计 **88 条**(32 + 18 + 9 + 23 + 6)
|
|
94
|
+
|
|
95
|
+
### 表格叶子层(design-table 迁移第一段)+ design-view 不再迁移
|
|
96
|
+
|
|
97
|
+
> 2026-10-27 用户拍板:**图标改用 `@antdv-next/icons`**(真 npm 包、语义等价、零注入),
|
|
98
|
+
> 不用 `@vben/icons`(基座包只能注入);**`design-view` 实际没在用,不再迁移**
|
|
99
|
+
> ⇒ 也就不用处理 `@vben/plugins/echarts` 的 `EchartsUI`。
|
|
100
|
+
|
|
101
|
+
- 新增 `src/utils/popup-width.ts`:`resolvePopupWidth` / `toPopupWidth` / `DEFAULT_POPUP_WIDTH`
|
|
102
|
+
(antd 弹层宽度只吃 number,配置里的 `"800"` / `"0"` 直接传会 0px 只剩遮罩)
|
|
103
|
+
- 新增 `src/table/load-gate.ts`:`evaluateLoadGate`(`extra_config.query.when`,表达式出错**拦截**)
|
|
104
|
+
- 新增 `src/components/design-shared/popup-host.ts`:`usePopupHost` / `DESIGN_POPUP_HOST_KEY`
|
|
105
|
+
(页面级用 vben 抽屉;嵌进 antd `Modal` 时切换成 antd 弹窗,避免焦点管理冲突)
|
|
106
|
+
- 新增 `src/components/design-shared/host-api.ts`:`buildHostApi` / `hostRequest`
|
|
107
|
+
(交给业务自定义组件的平台能力;`request` 走注入的 http,`message` 优先用 `host.message`)
|
|
108
|
+
- 新增组件 `DesignTableInner`:把 `gridOptions` 交给注入的 `ui.useVbenVxeGrid`,透出 `gridApi`
|
|
109
|
+
- 新增测试 `npm run test:shared`(9 条);`npm test` 合计 **65 条**(32 + 18 + 9 + 6)
|
|
110
|
+
- 迁移发现(记在 TODO P2-9):`design-form.vue` 直接 import 了宿主 app 的
|
|
111
|
+
`#/views/workflow/components`(`applyModal`)—— 这条属于**宿主应用私有**,
|
|
112
|
+
搬表单时必须改成注入(`host.workflow.applyModal`),否则表单搬不动。
|
|
113
|
+
|
|
114
|
+
### DesignHost 扩展面 + 取数层 + 第一个组件(TODO P2-9 起步)
|
|
115
|
+
|
|
116
|
+
- `DesignHost` 新增三组能力(分组内**按键合并**,可分多次 install):
|
|
117
|
+
- `ui`: `Page` / `useVbenVxeGrid` / `useVbenModal` / `useVbenDrawer`
|
|
118
|
+
- `dict`: `render` / `getOptions`
|
|
119
|
+
- `workflow`: `cancelProcessApply`
|
|
120
|
+
新增读取器 `getHostUi` / `getHostDict` / `getHostWorkflow` / `getHostPopup` / `requireVxeGrid`
|
|
121
|
+
(只有 `http` 与 `useVbenVxeGrid` 缺失时抛错,其余降级且只 warn 一次)
|
|
122
|
+
- 定下**判断规则**(写进 `src/host.ts` 文件头与 README):真 npm 包 → peer;宿主私有/业务数据 → 注入;
|
|
123
|
+
`@vben/*`(源码导出)→ 只能注入。`npm run verify` 现在**硬禁** `@vben/*`,
|
|
124
|
+
且裸导入白名单改为从 `package.json` 的 `peerDependencies` 推导(用了没声明 = 构建失败)
|
|
125
|
+
- 新增 `src/api.ts`:配置取数(表格/表单/查询表单/视图/组合视图/树形视图)+ 数据集取数 +
|
|
126
|
+
`clearDesignApiCache()`;保留宿主的**会话级缓存 + 在途去重**与「缓存键对象参数稳定序列化」两个行为
|
|
127
|
+
- 新增 `src/flow.ts`:`designFlowSubmit` / `designFlowStatus`(静默)/ `designFlowRemove`
|
|
128
|
+
- 新增组件 `DesignTableFlowStatusCell`(P2-9 的第一个迁移组件):流程接口改为注入,
|
|
129
|
+
未注入时**不显示撤销按钮**并 warn 一次;`<a-button>` → 显式 `Button`;宿主全局类 `text-muted` →
|
|
130
|
+
库自带 `design-platform-muted`
|
|
131
|
+
- 新增契约类型:`PlatformFormConfig` / `PlatformFormCell` / `PlatformFormContent` / `PlatformDictItem` /
|
|
132
|
+
`PlatformCellStyle` / `PlatformDerivedField` / `PlatformViewConfig` / `PlatformViewComponent` /
|
|
133
|
+
`PlatformViewContent` / `SearchFieldCell` / `PlatformSearchConfig` / `SearchFormConfig` /
|
|
134
|
+
`PlatformCombConfig` / `PlatformCombItem` / `PlatformTreeMapping` / `TreeNodeCountConfig` /
|
|
135
|
+
`PlatformTreeViewConfig` / `DataSetMeta`
|
|
136
|
+
- 新增测试:`npm test` = `test:table`(32)+ `test:host`(18)+ `test:component`(6);
|
|
137
|
+
组件用例用 `vue/server-renderer` 做 SSR 断言(不需要 jsdom)
|
|
138
|
+
|
|
139
|
+
### 表格纯逻辑层(P2-8 表格切片)
|
|
140
|
+
|
|
141
|
+
- 新增 `src/table/`:`buildQuerySearch`(查询条件)、`buildTableDataBody` / `parseConfigParams`
|
|
142
|
+
(`pager` 请求体与「查询参数」解析)、`createQueryDedupe`(重建后重复取数抑制)、
|
|
143
|
+
`fetchTableData`(走注入的 http,`silent: true`)
|
|
144
|
+
- 新增 `transformTableConfig`(平台表格配置 → vxe-grid 配置:列/字典/自定义列/合计/分页)+
|
|
145
|
+
`TransformHost`(注入 `renderDict` / `resolveCustom` / `getParams` / `getApi` /
|
|
146
|
+
`getSummaries` / `onSummaries` / `onRuntimeTitle`)
|
|
147
|
+
- 新增行操作映射:`evaluateExpress` / `buildNavigateQuery` / `buildCustomParams`
|
|
148
|
+
(复用 `evaluateMappedExpress`,作用域 `{ params, row }`,行为与宿主逐字一致)
|
|
149
|
+
- 新增契约类型:`PlatformTableConfig` / `PlatformColumn` / `RowAction` / `RowActionMapping` /
|
|
150
|
+
`TableDataResponse`
|
|
151
|
+
- 新增 `npm run test:table`(32 条断言,跑 `dist` 产物,零依赖离线可跑)
|
|
152
|
+
- 迁移时改的两处:`renderDict`(宿主字典能力)改为**调用方注入**,缺失时降级显示原值 + warn 一次;
|
|
153
|
+
`gridOptions` 类型改为宽类型(不引用 `#/adapter/vxe-table` 的 `VxeGridProps`,
|
|
154
|
+
因为 vben 的 `@vben/*` 是源码导出,写进 .d.ts 会让外部解析不到)
|
|
155
|
+
- 尚未迁移(P2-9):`design-table.vue` 等 25 个 `.vue` 组件,以及 design-tree / design-form /
|
|
156
|
+
design-comb / design-view / design-search
|
|
157
|
+
|
|
158
|
+
### 首个骨架:对外 API / 网络层 / 注册表 / 版本自检
|
|
159
|
+
|
|
160
|
+
0.0.1 的起步切片,先把「独立发布 + 宿主注入」这条链跑通:
|
|
161
|
+
|
|
162
|
+
- 对外 API:`installDesignPlatform` / `getDesignHost` / `hostT` / `requireHttp`
|
|
163
|
+
- 网络层契约:`DesignHttp`(`get` / `post` + 可选 `download` / `upload`)、`createMemoryHttp`
|
|
164
|
+
- 配置契约类型:`DesignMapping`、`DesignTableTool`
|
|
165
|
+
- 参数与表达式:`buildExtraParams`、`buildMappedParams`、`buildExpressId`、`evaluateMappedExpress`
|
|
166
|
+
- 组件:`ApiSwitch`(迁移自 vben `#/components/global/api-switch.vue`,宿主依赖改为注入)
|
|
167
|
+
- 自定义组件注册表:`registerComponents` / `resolveDesignComponent` / `requireDesignComponent` /
|
|
168
|
+
`listDesignComponents` / `buildComponentsManifest`(只认 comname,废弃源码路径解析)
|
|
169
|
+
- 版本兼容自检:`checkDesignRuntimeCompat` / `satisfiesRange` / `SUPPORTED_VERSIONS`;
|
|
170
|
+
`installDesignPlatform()` 首次调用自动执行,`strictCompat: true` 时启动即抛错
|
|
171
|
+
- peer 范围:`antdv-next ^1.5.2`、`vue ^3.5.0`
|
|
172
|
+
(2026-10-27 按**宿主实测**重定:demo-ui 实装 antdv-next 1.5.2;
|
|
173
|
+
原先写 `^1.7.1` 是照本库 devDeps 收的,宿主装不进去。devDependencies 同步降到 1.5.2,
|
|
174
|
+
编译期与宿主看到同一套类型)
|
|
175
|
+
- 构建产物自检:`npm run verify`(体积预算 + 裸导入白名单 + 禁 sourcemap + 关键产物存在性),已挂在 `build` 末尾
|
|
176
|
+
- 样式约束落地:`ApiSwitch` 不再覆盖 `.ant-switch`,改用自有 `dr-` 前缀 class(避免与宿主主题定制打架)
|
package/README.md
CHANGED
|
@@ -1,3 +1,276 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @jzg223/design-runtime
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
低代码设计平台的**运行端组件库**:设计端(design-ui)构建出的配置,由本库在 vben 基座上渲染。
|
|
4
|
+
它夹在「基座」和「业务项目」之间,**版本化、可复用、不拷贝**。
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
基座 design-ui(构建端)+ ruo-yi-vue-plus(后端)
|
|
8
|
+
↓
|
|
9
|
+
本库 @jzg223/design-runtime ← 设计端的配置在这里被解释成表格 / 表单 / 树 / 组合视图
|
|
10
|
+
↓
|
|
11
|
+
业务 hcm-ui(vben 项目)里只写业务页面与业务组件
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm i @jzg223/design-runtime
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
需要宿主提供(peerDependencies,**不会**打进本库产物):
|
|
21
|
+
`vue` >= 3.5、`antdv-next` >= 1.5、`vue-router` ^5.0.4、`@antdv-next/icons` ^1.1.2、`dayjs` ^1.11。
|
|
22
|
+
|
|
23
|
+
## 接入宿主(三步)
|
|
24
|
+
|
|
25
|
+
### 1. 注入宿主能力(**必须**注入 `http`)
|
|
26
|
+
|
|
27
|
+
本库**不创建**请求实例,用的是宿主那一个 —— token 头、clientid、401 跳登录、刷新 token、
|
|
28
|
+
baseURL、租户、错误提示策略全都自动一致。适配只要 3 行:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { installDesignPlatform } from '@jzg223/design-runtime'
|
|
32
|
+
import { alovaInstance } from '#/utils/http' // 宿主自己的实例
|
|
33
|
+
|
|
34
|
+
installDesignPlatform({
|
|
35
|
+
// alova(vben 就是这个):直接转发;注意方法的 this 绑定
|
|
36
|
+
http: {
|
|
37
|
+
get: (url, o) =>
|
|
38
|
+
alovaInstance.get(url, {
|
|
39
|
+
params: o?.params, headers: o?.headers, signal: o?.signal,
|
|
40
|
+
meta: { successMessageMode: o?.silent ? 'none' : 'message',
|
|
41
|
+
errorMessageMode: o?.silent ? 'none' : 'message' },
|
|
42
|
+
}),
|
|
43
|
+
post: (url, data, o) =>
|
|
44
|
+
alovaInstance.post(url, data, {
|
|
45
|
+
params: o?.params, headers: o?.headers, signal: o?.signal,
|
|
46
|
+
meta: { successMessageMode: o?.silent ? 'none' : 'message',
|
|
47
|
+
errorMessageMode: o?.silent ? 'none' : 'message' },
|
|
48
|
+
}),
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
// 可选,缺了走内置兜底
|
|
52
|
+
t: (key) => $t(key), // 未注入 → 内置中文
|
|
53
|
+
message: window.message, // antd message
|
|
54
|
+
modal: window.modal, // antd modal
|
|
55
|
+
getAuth: () => ({ loggedIn: !!accessStore.accessToken }),
|
|
56
|
+
|
|
57
|
+
// —— 下面三组按需注入;分组内是「按键合并」,可以分多次 install ——
|
|
58
|
+
// 1) vben 基座能力(@vben/* 是源码导出,只能注入,见下节)
|
|
59
|
+
ui: {
|
|
60
|
+
Page, // @vben/common-ui 的 Page 容器
|
|
61
|
+
useVbenVxeGrid, // #/adapter/vxe-table 里那个包装过的版本(表格/树必须要)
|
|
62
|
+
useVbenModal, // @vben/common-ui
|
|
63
|
+
useVbenDrawer,
|
|
64
|
+
},
|
|
65
|
+
// 2) 字典(业务数据在宿主)
|
|
66
|
+
dict: {
|
|
67
|
+
render: (value, dictName) => renderDict(value, dictName), // #/utils/render
|
|
68
|
+
getOptions: (dictName) => getDictOptions(dictName),
|
|
69
|
+
},
|
|
70
|
+
// 3) 文件上传(file / image 字段用;接口与返回口径都是平台相关的,所以只注入「给 File、还 url」)
|
|
71
|
+
upload: (file) => uploadApi(file), // 宿主 #/api 的 uploadApi
|
|
72
|
+
// 4) 业务后端能力
|
|
73
|
+
workflow: {
|
|
74
|
+
cancelProcessApply, // #/api/workflow/instance,缺了流程列的「撤销」按钮不显示
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 哪些能力该 peer、哪些该注入(定死的规则)
|
|
80
|
+
|
|
81
|
+
| 能力 | 处理方式 | 原因 |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| `vue` / `vue-router` / `antdv-next` / `@antdv-next/icons` / `vxe-table` | **peer + external** | 外部使用方 `npm i` 拿到的就是构建产物与 `.d.ts` |
|
|
84
|
+
| `http` / `message` / `modal` / `t` / `getAuth` | **注入** | 宿主单例:token、401、i18n、鉴权口径必须与宿主一致 |
|
|
85
|
+
| `dict` / `workflow` | **注入** | 业务数据与业务后端接口,库里没有也不能自建 |
|
|
86
|
+
| `Page` / `useVbenModal` / `useVbenDrawer` / `useVbenVxeGrid` | **注入** | `@vben/*` 的 `exports` 指向 `./src/*.ts`(源码导出),声明成 peer 会让外部装不到产物、也解析不了类型 |
|
|
87
|
+
|
|
88
|
+
> 结论:**本库任何 import 里出现 `@vben/*` 都是 bug**,`npm run verify` 会直接让构建失败。
|
|
89
|
+
> 新增能力时先按上表判断;判断不了就问「外部使用者 `npm i` 能不能装到它」。
|
|
90
|
+
|
|
91
|
+
> axios 宿主同理:把 `requestClient.get/post` 包一层即可,**拦截器链还是宿主那一条**。
|
|
92
|
+
> 返回口径:resolve 业务数据(宿主拦截器已剥掉 `{code,data}`),库内不再判 `code`。
|
|
93
|
+
|
|
94
|
+
### 2. 引一次样式
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import '@jzg223/design-runtime/style.css'
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 3. 注册业务自定义组件
|
|
101
|
+
|
|
102
|
+
设计端配置里的自定义组件用 **comname 字符串**引用;这些组件属于业务项目,由宿主注册:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
// apps/web-antd/src/components/hcm/registry.ts —— 宿主侧唯一真源
|
|
106
|
+
import { registerComponents } from '@jzg223/design-runtime'
|
|
107
|
+
|
|
108
|
+
registerComponents({
|
|
109
|
+
'employee-select': {
|
|
110
|
+
loader: () => import('./form-field/employee-select/index.vue'),
|
|
111
|
+
title: '员工选择',
|
|
112
|
+
slots: ['form-field'],
|
|
113
|
+
},
|
|
114
|
+
'salary-issue': {
|
|
115
|
+
loader: () => import('./row-action/salary-issue/index.vue'),
|
|
116
|
+
title: '薪资发放',
|
|
117
|
+
slots: ['row-action'],
|
|
118
|
+
modalWidth: 1000,
|
|
119
|
+
},
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- 值写成 `() => import(...)` —— 组件本体按需加载,不进首屏 bundle;加载中有占位、失败有明确提示;
|
|
124
|
+
- 库内五类插槽(表单单元格 / 自定义列 / 工具条 / 行操作弹窗 / 整页)统一走
|
|
125
|
+
`resolveDesignComponent()` / `requireDesignComponent()`,**未注册时报同一句话**并带插槽名;
|
|
126
|
+
- 已注册清单用 `listDesignComponents()` / `buildComponentsManifest()` 取(诊断 / 启动日志 / 自检)。
|
|
127
|
+
- **不给设计端下发清单**(2026-10-27 拍板):design-ui 里的 comname 是**手填**,真源就是宿主工程的
|
|
128
|
+
注册表文件(demo 工程:`apps/web-antd/src/components/hcm/registry.ts`)。
|
|
129
|
+
约定与已登记清单见工作区 `documents/comname-contract.md`;不做 `ext-components.json`、
|
|
130
|
+
也不做 `GET /design/extComponents`(多一条通道 = 多一份会漂移的副本)。
|
|
131
|
+
|
|
132
|
+
## 已迁入的组件与取数层
|
|
133
|
+
|
|
134
|
+
| 导出 | 作用 |
|
|
135
|
+
|---|---|
|
|
136
|
+
| `DesignTable` | **表格主组件**:列配置 / 查询表单 / 工具条 / 行操作 / 合计 / 流程状态列。需要注入 `ui.useVbenVxeGrid`;`Page` 可选(缺了用普通容器) |
|
|
137
|
+
| `DesignSearch` | **查询表单**:按 sform 配置渲染查询字段 + 查询/重置,透出 `getQueryValues()` 等 |
|
|
138
|
+
| `DesignTree` | **树形视图**:左侧可拖拽宽度的树 + 右侧关联目标(表单/列表/组合/树),支持节点数量徽标 |
|
|
139
|
+
| `DesignComb` | **组合视图**:tabs / flat 两种模式,内嵌表单与列表。`design-view` 未迁(用户确认没用),`view` 类型只显示提示 |
|
|
140
|
+
| `DesignForm` / `DesignFormInner` | **表单主组件** + 网格渲染层。`host.ui.useVbenModal` + `host.workflow.applyModal` 缺了则「提交」降级为只保存不发起流程 |
|
|
141
|
+
| `DesignTableFlowStatusCell` | 流程状态单元格(状态标签 + waiting 行「撤销」)。`host.workflow.cancelProcessApply` 未注入时撤销按钮不显示 |
|
|
142
|
+
| `DesignTableInner` | 表格内层壳:把 `gridOptions` 交给注入的 `ui.useVbenVxeGrid`,透出 `gridApi`(reload / 选中行) |
|
|
143
|
+
| `buildHostApi` / `hostRequest` | **交给业务自定义组件**的平台能力(`request` / `message` / `reload` / `close`),业务组件不 import 基座 |
|
|
144
|
+
| `usePopupHost` / `DESIGN_POPUP_HOST_KEY` | 弹层体系切换:页面级用 vben 抽屉,嵌在 antd `Modal` 里时改用 antd 弹窗(避免焦点管理冲突) |
|
|
145
|
+
| `resolvePopupWidth` / `toPopupWidth` | 配置宽度归一化(`"800"` / `"0"` / `""` → number)。antd 弹层宽度只吃 number,传字符串会 0px 只剩遮罩 |
|
|
146
|
+
| `evaluateLoadGate` | 列表加载条件(`extra_config.query.when`):表达式出错**拦截**而不是放行(放行=静默加载全量数据) |
|
|
147
|
+
| `designFlowSubmit` / `designFlowStatus` / `designFlowRemove` | 业务-流程关联接口(`/design/flowData/*`),状态查询自带 `silent: true` |
|
|
148
|
+
| `fetchTableConfig` / `fetchFormConfig` / `fetchSearchConfig` / `fetchViewConfig` / `fetchCombConfig` / `fetchTreeViewConfig` | 各视图配置取数,**带会话级缓存 + 在途去重**(切标签页重新挂载不会重复请求;失败不缓存) |
|
|
149
|
+
| `fetchDataSetData` / `fetchDataSetListData` / `fetchDataSetTreeSync` / `fetchDataSetTreeAsync` / `fetchDataSetMeta` / `fetchTreeNodeCount` / `fetchCombData` | 数据集与组合视图取数 |
|
|
150
|
+
| `fetchDesignUiConfig` | 构建端地址(开发模式「编辑/设计」跳转用) |
|
|
151
|
+
| `clearDesignApiCache()` | 清配置缓存(登出 / 切换租户后必须调,否则拿到上一个身份的配置) |
|
|
152
|
+
| `buildSearchFormOptions` / `normalizeSearchCells` | 查询表单配置 → 表单 schema(字段类型映射 / 字典选项 / 默认值 / 只读) |
|
|
153
|
+
| `formatNow` / `resolveDefaultValue` | 查询表单默认值(`defaultNow`、`${now}`、`${now:YYYY/MM/DD}`) |
|
|
154
|
+
| `isOwnRoutePage` | 组件是否位于**自己的**路由页(决定 extraParams 是否并入路由参数) |
|
|
155
|
+
| `executeCommand` / `openComponent` | 执行后台配置的 JS 脚本(`api.navigate` / `message` / `confirm` / `openComponent`…) |
|
|
156
|
+
| `transformFormConfig` | 表单配置 → schema + 网格布局(新格式 `config` / 旧格式 `content` JSON 都支持) |
|
|
157
|
+
| `evalCellCondition` / `buildConditionScope` / `isConditionHidden` | 渲染条件 `vif` / 显示条件 `vshow`(求值抛错按「不隐藏」处理) |
|
|
158
|
+
| `evalDerivedExpress` / `computeDerivedFills` / `buildDerivedScope` | 派生取值表达式与回填 |
|
|
159
|
+
| `parsePrecision` / `roundToPrecision` | 数字字段的小数位与四舍五入 |
|
|
160
|
+
| `resolveCellComponent` / `resolveComponent` / `register` / `registerFields` / `hasCustomComponent` / `listCustomComponents` | 表单字段注册中心(内置字段 + comname 注册表**同一份**) |
|
|
161
|
+
| `downloadByData` | 文件下载落盘(导出类工具用) |
|
|
162
|
+
| `createDeptTreeSource` / `createLazyDeptTree` / `attachChildren` / `normalizeParentId` + `deptList` / `deptChildren` / `deptInfo` / `getDeptSubTree` | 组织(部门树):ruoyi `/system/dept/**` 接口 + 懒加载内核(一层一取 / 缓存 / 在途合并 / 全名路径) |
|
|
163
|
+
| `resolveToolComponent` / `toolComponentMap` / `toolTypes` | **工具条 12 种全部迁入**,按 `type` 懒加载(add / export / import / hcm-tool / modal-* / navigate-* / other) |
|
|
164
|
+
| `resolveRowActionComponent` / `rowActionComponentMap` / `rowActionTypes` | **行操作 12 种全部迁入**,按 `type` 懒加载(`delete` / `edit` / `modal-*` / `navigate-*` / `other`) |
|
|
165
|
+
|
|
166
|
+
## 表格:配置 → 渲染(已迁入的逻辑层)
|
|
167
|
+
|
|
168
|
+
`design-table` 的**纯逻辑**已经在本库(`src/table/`),可以独立使用、也可以等组件迁移后由库内组件调用:
|
|
169
|
+
|
|
170
|
+
| 导出 | 作用 |
|
|
171
|
+
|---|---|
|
|
172
|
+
| `buildQuerySearch(pageSearch, formValues)` | 组装查询条件(页面 search 覆盖查询表单同名键) |
|
|
173
|
+
| `buildTableDataBody(...)` / `parseConfigParams(raw)` | 组装 `pager` 请求体(`search` 与 `params` 严格分开);解析列表「查询参数」JSON |
|
|
174
|
+
| `fetchTableData(url, params)` | 走**注入的 http** 取数,`silent: true`(并发取数不弹 toast) |
|
|
175
|
+
| `createQueryDedupe()` | 重建后的重复取数抑制(同 key 并发合并、重建窗口内复用结果) |
|
|
176
|
+
| `transformTableConfig(config, height?, host?)` | 平台表格配置 → vxe-grid 配置(列/字典/自定义列/合计/分页) |
|
|
177
|
+
| `buildNavigateQuery` / `buildCustomParams` / `evaluateExpress` | 行操作参数映射(跳转 query 字符串化;弹窗保留原值) |
|
|
178
|
+
| 类型:`PlatformTableConfig` / `PlatformColumn` / `RowAction` / `TableDataResponse` | 与后端配置一致的契约面 |
|
|
179
|
+
|
|
180
|
+
`transformTableConfig` 的 `host` 是**调用方注入**的能力(不注入也能跑,只是降级):
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
transformTableConfig(config, '100%', {
|
|
184
|
+
// 字典列(formater: 'dict-SYS_YES_NO')的渲染:宿主用自己那份字典
|
|
185
|
+
renderDict: (value, dictName) => renderDict(value, dictName), // 宿主 #/utils/render
|
|
186
|
+
resolveCustom: (comname) => resolveDesignComponent(comname), // 自定义列(edit.type='hcm')
|
|
187
|
+
getParams: () => extraParams,
|
|
188
|
+
getApi: () => platformApi,
|
|
189
|
+
// 合计行 / 运行时标题:数据响应里带 summaries / runtimeTitle 时回调
|
|
190
|
+
getSummaries: () => summaries,
|
|
191
|
+
onSummaries: (s) => (summaries = s),
|
|
192
|
+
onRuntimeTitle: (title) => emit('update:title', title),
|
|
193
|
+
})
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
> ⚠ 不注入 `renderDict` 时字典列**降级显示原值**并 warn 一次 —— 字典数据在宿主(读宿主的字典 store),
|
|
197
|
+
> 库里既没有数据也不能自建一份。
|
|
198
|
+
|
|
199
|
+
回归用例:`npm run test:table`(32 条,零依赖,跑的是 `dist` 产物,离线可跑)。
|
|
200
|
+
|
|
201
|
+
## 开发
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
cd code/design-runtime
|
|
205
|
+
npm i
|
|
206
|
+
npm run build # dist/(js + style.css + types/)
|
|
207
|
+
npm test # 表格逻辑 32 条 + 宿主/取数 18 条 + 组件 6 条(都跑 dist,离线可跑)
|
|
208
|
+
npm run typecheck
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
本地验证「消费者只拿到 dist」:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
npm run pack:tgz # 生成 jzg223-design-runtime-0.0.1.tgz
|
|
215
|
+
cd playground && npm i ../jzg223-design-runtime-0.0.1.tgz
|
|
216
|
+
npm run build && npm run smoke
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## 发布
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npm run build # 含产物自检:体积预算 + 裸导入白名单 + 无 sourcemap
|
|
223
|
+
npm publish # 命名空间 @jzg223(账号 jzg223),首次发布前确认 2FA/权益
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
发布纪律:
|
|
227
|
+
|
|
228
|
+
- `files` 只含 `dist`、`README.md`、`CHANGELOG.md` —— **不发源码、不发 sourcemap**(外界只能使用不能修改);
|
|
229
|
+
- semver;破坏性改动(`installDesignPlatform` 参数、公开导出、组件 props、注册表语义)必须升大版本,并在 `CHANGELOG.md` 写清「宿主需要改什么」;
|
|
230
|
+
- `@vben/*` 等基座包与本库**同一 release train**(同一版本号一起发)。
|
|
231
|
+
|
|
232
|
+
## 版本兼容与支持矩阵
|
|
233
|
+
|
|
234
|
+
本库把 `vue` / `antdv-next` 声明为 **peerDependencies**(构建时 external),运行时用的是**宿主那一份**
|
|
235
|
+
—— 全站只有一个实例,代价是「宿主装什么版本就用什么版本」。版本对不上的典型症状是
|
|
236
|
+
「某个 prop 不生效」「样式不对」「Teleport 错位」,很难查,所以要主动检查。
|
|
237
|
+
|
|
238
|
+
| design-runtime | vue | antdv-next | vue-router | @antdv-next/icons | dayjs |
|
|
239
|
+
|---|---|---|---|---|---|
|
|
240
|
+
| 0.0.x | ^3.5.0 | ^1.5.2 | ^5.0.4 | ^1.1.2 | ^1.11.0 |
|
|
241
|
+
|
|
242
|
+
> `antdv-next` 的下限是**按宿主实测**定的:demo-ui(vben 基座)实装 1.5.2
|
|
243
|
+
> (2026-10-27 核对 `pnpm-lock.yaml` 与 `apps/web-antd/node_modules`)。
|
|
244
|
+
> 原先写 `^1.7.1` 是照本库 devDeps 收的,宿主根本装不进去 —— devDependencies 现已同步降到 `^1.5.2`,
|
|
245
|
+
> 保证编译期与宿主看到同一套类型。
|
|
246
|
+
> `vue-router` 同理按宿主实测:demo-ui 是 **5.3.0**(`pnpm-workspace.yaml` catalog `^5.0.4`)。
|
|
247
|
+
|
|
248
|
+
> 以后用到 `vxe-table` / `@vben/*` 时,同样加进 `peerDependencies`(并按需标 `optional`),
|
|
249
|
+
> 并在本表与 `src/compat.ts` 的 `SUPPORTED_VERSIONS` 里同步。
|
|
250
|
+
|
|
251
|
+
**运行时自检**:`installDesignPlatform()` 首次调用会自动跑一次,不匹配时 `console.error` 输出
|
|
252
|
+
一条能照着改的提示;需要「启动即失败」的宿主这样开:
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
installDesignPlatform({ http, strictCompat: true }) // 版本不符直接抛错
|
|
256
|
+
// 或主动调:checkDesignRuntimeCompat({ throwOnError: true })
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**构建期自检**:`npm run build` 末尾会跑 `scripts/assert-bundle.mjs` ——
|
|
260
|
+
体积预算 + 裸导入白名单 + 禁止 sourcemap + 关键产物存在性。
|
|
261
|
+
白名单**直接从 `package.json` 的 `peerDependencies` 推导**(用了却没声明 peer 会当场失败),
|
|
262
|
+
另外 `@vben/*` / `@vben-core/*` 是**硬禁**(源码导出,只能注入;加进 peer 也不放行)。
|
|
263
|
+
|
|
264
|
+
## 设计约束(改代码前先读)
|
|
265
|
+
|
|
266
|
+
| 约束 | 原因 |
|
|
267
|
+
|---|---|
|
|
268
|
+
| 不得 `import` 宿主模块(`#/…`、app 内部路径) | 本库要能独立发 npm,宿主路径在包内不存在 |
|
|
269
|
+
| 不得自带请求实例 | 会出现两套拦截器:库里请求不带 token、宿主 401 处理不生效 |
|
|
270
|
+
| `vue` / `antdv-next` / `vxe-table` / `@vben/*` 一律 external + peer | 双实例会导致「组件内拿不到登录态」「antd 样式错乱」 |
|
|
271
|
+
| 取数默认 `silent: true` | 列表/树一页并发多条请求,否则一次弹十条 toast |
|
|
272
|
+
| 自定义组件只认 `comname`,不认源码路径 | 路径式会把配置绑死在宿主源码结构上,一重构全废 |
|
|
273
|
+
| 对外只导出稳定 API | 内部实现属于可改范围,导出去就锁死升级空间 |
|
|
274
|
+
| 不覆盖宿主 CSS(禁止 `:deep(.ant-*)`),只用自有 `dr-` 前缀 class | 会和宿主主题定制打架,且 antd 内部类名随版本变 |
|
|
275
|
+
| 不自己建 `ConfigProvider` | 主题、`prefixCls`、locale 必须由宿主统一提供 |
|
|
276
|
+
| 不用深层私有导入(`antdv-next/dist/…`) | 版本间的私有结构不稳;只用公开导出与公开类型 |
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { requireHttp } from "./host.js";
|
|
2
|
+
function stableKey(value) {
|
|
3
|
+
if (value === null || typeof value !== "object") {
|
|
4
|
+
return String(value);
|
|
5
|
+
}
|
|
6
|
+
if (Array.isArray(value)) {
|
|
7
|
+
return `[${value.map(stableKey).join(",")}]`;
|
|
8
|
+
}
|
|
9
|
+
const obj = value;
|
|
10
|
+
return `{${Object.keys(obj).sort().map((k) => `${k}:${stableKey(obj[k])}`).join(",")}}`;
|
|
11
|
+
}
|
|
12
|
+
const configCaches = /* @__PURE__ */ new Set();
|
|
13
|
+
function memoizeConfig(fn, keyOf) {
|
|
14
|
+
const cache = /* @__PURE__ */ new Map();
|
|
15
|
+
configCaches.add(cache);
|
|
16
|
+
return (...args) => {
|
|
17
|
+
const key = keyOf ? keyOf(...args) : args.map(String).join("/");
|
|
18
|
+
let promise = cache.get(key);
|
|
19
|
+
if (!promise) {
|
|
20
|
+
promise = Promise.resolve(fn(...args)).catch((error) => {
|
|
21
|
+
cache.delete(key);
|
|
22
|
+
throw error;
|
|
23
|
+
});
|
|
24
|
+
cache.set(key, promise);
|
|
25
|
+
}
|
|
26
|
+
return promise;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function clearDesignApiCache() {
|
|
30
|
+
for (const cache of configCaches) {
|
|
31
|
+
cache.clear();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const fetchTableConfig = memoizeConfig(
|
|
35
|
+
(category, name, params = {}) => requireHttp().post(
|
|
36
|
+
`/${category}/${name}/table`,
|
|
37
|
+
{ params, search: {} },
|
|
38
|
+
{ silent: true }
|
|
39
|
+
),
|
|
40
|
+
(category, name, params) => `${category}/${name}/${stableKey(params ?? {})}`
|
|
41
|
+
);
|
|
42
|
+
const fetchFormConfig = memoizeConfig(
|
|
43
|
+
(category, name) => requireHttp().post(
|
|
44
|
+
`/${category}/${name}/form`,
|
|
45
|
+
{ params: {}, search: {} },
|
|
46
|
+
{ silent: true }
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
const fetchSearchConfig = memoizeConfig(
|
|
50
|
+
(category, name) => requireHttp().post(
|
|
51
|
+
`/${category}/${name}/sform`,
|
|
52
|
+
{ params: {}, search: {} },
|
|
53
|
+
{ silent: true }
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
const fetchViewConfig = memoizeConfig(
|
|
57
|
+
(category, name) => requireHttp().post(
|
|
58
|
+
`/${category}/${name}/view`,
|
|
59
|
+
{ params: {}, search: {} },
|
|
60
|
+
{ silent: true }
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
const fetchCombConfig = memoizeConfig(
|
|
64
|
+
(category, name) => requireHttp().post(
|
|
65
|
+
`/${category}/${name}/comb`,
|
|
66
|
+
{ params: {}, search: {} },
|
|
67
|
+
{ silent: true }
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
function fetchCombData(url, params = {}) {
|
|
71
|
+
const clean = {};
|
|
72
|
+
for (const [key, val] of Object.entries(params)) {
|
|
73
|
+
if (val === void 0 || val === null || val === "") continue;
|
|
74
|
+
const sv = typeof val === "string" ? val : "";
|
|
75
|
+
if (sv === "undefined" || sv === "null") continue;
|
|
76
|
+
clean[key] = val;
|
|
77
|
+
}
|
|
78
|
+
return requireHttp().post(url, clean);
|
|
79
|
+
}
|
|
80
|
+
const fetchTreeViewConfig = memoizeConfig(
|
|
81
|
+
(category, name) => requireHttp().post(
|
|
82
|
+
`/${category}/${name}/tree`,
|
|
83
|
+
{ params: {}, search: {} },
|
|
84
|
+
{ silent: true }
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
const fetchDesignUiConfig = memoizeConfig(
|
|
88
|
+
() => requireHttp().get("/design/uiConfig", {
|
|
89
|
+
params: {},
|
|
90
|
+
silent: true
|
|
91
|
+
})
|
|
92
|
+
);
|
|
93
|
+
function fetchDataSetData(dataSetName) {
|
|
94
|
+
return requireHttp().post(`/system/dataset/${dataSetName}/data`, void 0, {
|
|
95
|
+
silent: true
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function fetchDataSetListData(setCode, params = {}) {
|
|
99
|
+
return requireHttp().post(
|
|
100
|
+
"/design/dataSet/listData",
|
|
101
|
+
{ params, setCode },
|
|
102
|
+
{ silent: true }
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
function fetchDataSetTreeSync(setCode, params = {}) {
|
|
106
|
+
return requireHttp().post(
|
|
107
|
+
"/design/dataSet/tree/sync",
|
|
108
|
+
{ params, setCode },
|
|
109
|
+
{ silent: true }
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function fetchDataSetTreeAsync(setCode, parentId, params = {}) {
|
|
113
|
+
return requireHttp().post(
|
|
114
|
+
"/design/dataSet/tree/async",
|
|
115
|
+
{ parentId: parentId ?? "", params, setCode },
|
|
116
|
+
{ silent: true }
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
function fetchDataSetMeta(setCode) {
|
|
120
|
+
return requireHttp().post(
|
|
121
|
+
"/design/dataSet/meta",
|
|
122
|
+
{ setCode },
|
|
123
|
+
{ silent: true }
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
function fetchTreeNodeCount(moduleName, code, keys, params = {}) {
|
|
127
|
+
return requireHttp().post(
|
|
128
|
+
"/design/treeView/nodeCount",
|
|
129
|
+
{ code, keys, moduleName, params },
|
|
130
|
+
{ silent: true }
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
clearDesignApiCache,
|
|
135
|
+
fetchCombConfig,
|
|
136
|
+
fetchCombData,
|
|
137
|
+
fetchDataSetData,
|
|
138
|
+
fetchDataSetListData,
|
|
139
|
+
fetchDataSetMeta,
|
|
140
|
+
fetchDataSetTreeAsync,
|
|
141
|
+
fetchDataSetTreeSync,
|
|
142
|
+
fetchDesignUiConfig,
|
|
143
|
+
fetchFormConfig,
|
|
144
|
+
fetchSearchConfig,
|
|
145
|
+
fetchTableConfig,
|
|
146
|
+
fetchTreeNodeCount,
|
|
147
|
+
fetchTreeViewConfig,
|
|
148
|
+
fetchViewConfig
|
|
149
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _sfc_main from "./design-comb2.vue.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import _export_sfc from "../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const DesignComb = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-902e3400"]]);
|
|
5
|
+
export {
|
|
6
|
+
DesignComb as default
|
|
7
|
+
};
|