@microi.net/cli 5.9.2 → 5.9.4

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 (171) hide show
  1. package/.codebuddy-plugin/marketplace.json +2 -2
  2. package/.codebuddy-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/.mcp.json +1 -1
  5. package/.workbuddy-plugin/marketplace.json +2 -2
  6. package/.workbuddy-plugin/plugin.json +1 -1
  7. package/assets/build-meta.json +6 -6
  8. package/cordis.patch.yml +1 -1
  9. package/package.json +1 -1
  10. package/scripts/codex-marketplace.json +20 -20
  11. package/scripts/mcp-codex-stdio-adapter.js +189 -189
  12. package/scripts/mcp-server.js +81 -81
  13. package/scripts/mcp-trae-windows-launcher.cmd +21 -21
  14. package/scripts/microi-cli-mcp.js +7 -7
  15. package/scripts/microi-codex-broker.js +21 -5
  16. package/scripts/microi-codex-router.js +17 -1
  17. package/scripts/microi-skills.meta.json +354 -348
  18. package/skills/.microi-skills-version.json +2 -2
  19. package/skills/.progressive-disclosure-manifest.json +122 -115
  20. package/skills/README.md +287 -287
  21. package/skills/ai-engine/SKILL.md +269 -269
  22. package/skills/ai-engine/references/ai-employees.md +48 -48
  23. package/skills/ai-engine/references/self-hosted-digital-human.md +59 -59
  24. package/skills/ai-platform-governance/SKILL.md +177 -177
  25. package/skills/ai-platform-governance/references/progressive-01-/345/212/237/350/203/275/345/274/200/345/205/263.md +190 -190
  26. package/skills/app-store/SKILL.md +525 -525
  27. package/skills/business-blueprint/SKILL.md +193 -193
  28. package/skills/datasource-engine/SKILL.md +93 -93
  29. package/skills/dos-orm/SKILL.md +101 -95
  30. package/skills/dos-orm/references/api-reference.md +229 -229
  31. package/skills/email-engine/SKILL.md +81 -81
  32. package/skills/email-engine/references/v8-email.md +34 -34
  33. package/skills/job-engine/SKILL.md +176 -176
  34. package/skills/message-notification/SKILL.md +156 -156
  35. package/skills/message-notification/references/contracts.md +102 -102
  36. package/skills/microi/SKILL.md +14 -14
  37. package/skills/microi-ai-application/SKILL.md +115 -115
  38. package/skills/microi-ai-application/references/frontend-baseline.md +164 -164
  39. package/skills/microi-client-frontend/SKILL.md +242 -242
  40. package/skills/microi-client-frontend/references/progressive-01-3-/345/212/250/346/200/201/346/214/211/351/222/256/347/263/273/347/273/237.md +144 -144
  41. package/skills/microi-client-frontend/references/progressive-02-8-/350/277/220/350/241/214/346/227/266/351/253/230/351/242/221/345/235/221/345/244/215/347/233/230.md +196 -196
  42. package/skills/microi-client-frontend/references/progressive-03-vue3-/345/211/215/347/253/257/345/276/256/346/234/215/345/212/241/345/256/277/344/270/273/350/247/204/345/210/231.md +167 -167
  43. package/skills/microi-codex-installer/SKILL.md +231 -231
  44. package/skills/microi-datasource-mapping/SKILL.md +122 -122
  45. package/skills/microi-db-schema/SKILL.md +175 -175
  46. package/skills/microi-db-schema/references/core-tables.md +695 -695
  47. package/skills/microi-db-schema/references/form-component-options.md +256 -256
  48. package/skills/microi-db-schema/references/schema-overview.md +202 -202
  49. package/skills/microi-db-schema/references/schema.md +646 -646
  50. package/skills/microi-db-schema/references/table-catalog.md +1599 -1599
  51. package/skills/microi-deployment/SKILL.md +239 -220
  52. package/skills/microi-deployment/references/deployment-matrix.md +109 -109
  53. package/skills/microi-docs-coverage/SKILL.md +133 -133
  54. package/skills/microi-docs-coverage/references/capability-map.md +90 -90
  55. package/skills/microi-form-engine/SKILL.md +338 -333
  56. package/skills/microi-form-engine/references/component-catalog.md +218 -218
  57. package/skills/microi-form-engine/references/data-source-events.md +124 -124
  58. package/skills/microi-frontend-sdk/SKILL.md +194 -194
  59. package/skills/microi-frontend-sdk/references/progressive-01-token-/345/275/223/345/211/215/347/231/273/345/275/225/347/224/250/346/210/267/344/270/216/345/275/223/345/211/215/347/273/210/347/253/257/347/231/273/345/275/225/345/215/217/350/256/256.md +176 -176
  60. package/skills/microi-left-right-layout/SKILL.md +141 -141
  61. package/skills/microi-microservice/SKILL.md +332 -328
  62. package/skills/microi-microservice/references/runtime-delivery.md +282 -278
  63. package/skills/microi-mobile-app-quality/SKILL.md +203 -203
  64. package/skills/microi-mobile-app-quality/references/progressive-01-4-/351/207/215/350/246/201/346/214/211/351/222/256/345/277/205/351/241/273/345/270/246/345/233/276/346/240/207.md +227 -227
  65. package/skills/microi-mobile-app-quality/references/progressive-02-9-/344/270/273/351/242/230/345/210/207/346/215/242/345/277/205/351/241/273/347/234/237/345/256/236/344/270/224/345/205/250/345/261/200/347/224/237/346/225/210.md +129 -129
  66. package/skills/microi-solution-quotation/SKILL.md +78 -78
  67. package/skills/microi-sso/SKILL.md +95 -91
  68. package/skills/microi-sso/references/acceptance.md +51 -49
  69. package/skills/microi-sso/references/configuration-and-security.md +53 -53
  70. package/skills/microi-sso/references/inbound.md +53 -53
  71. package/skills/microi-sso/references/outbound.md +43 -39
  72. package/skills/microi-ui/SKILL.md +192 -192
  73. package/skills/microi-ui/references/progressive-01-/347/247/273/345/212/250/347/253/257/345/234/272/346/231/257/350/223/235/345/233/276.md +183 -183
  74. package/skills/microi-uniapp-frontend/SKILL.md +206 -204
  75. package/skills/microi-uniapp-frontend/references/progressive-01-/347/247/273/345/212/250/347/253/257/345/210/206/347/261/273-/345/217/214/346/240/217/345/210/227/350/241/250/347/213/254/347/253/213/346/273/232/345/212/250.md +261 -261
  76. package/skills/microi-uniapp-frontend/references/progressive-02-/345/205/263/351/224/256/344/270/232/345/212/241/350/265/204/344/272/247/344/270/215/345/276/227/351/273/230/350/256/244/351/200/211/344/270/255.md +154 -154
  77. package/skills/module-engine/SKILL.md +255 -255
  78. package/skills/module-engine/references/module-config.md +204 -204
  79. package/skills/ocr-engine/SKILL.md +113 -113
  80. package/skills/page-engine/SKILL.md +206 -206
  81. package/skills/page-engine/references/progressive-01-/346/211/200/346/234/211/347/273/204/344/273/266/347/261/273/345/236/213.md +234 -234
  82. package/skills/page-engine/references/progressive-02-/347/211/210/346/234/254/345/216/206/345/217/262-/345/271/266/345/217/221/344/277/235/345/255/230/344/270/216/345/233/236/346/273/232.md +60 -60
  83. package/skills/performance-testing/SKILL.md +227 -221
  84. package/skills/playwright-e2e/SKILL.md +197 -196
  85. package/skills/playwright-e2e/references/progressive-01-/345/205/250/350/207/252/345/212/250/347/231/273/345/275/225-/345/205/215/351/252/214/350/257/201/347/240/201-/344/275/206/344/270/215/345/205/215/345/257/206/347/240/201-/345/277/205/350/257/273.md +173 -173
  86. package/skills/playwright-e2e/references/progressive-02-/346/226/207/345/255/227/345/257/271/346/257/224/345/272/246/344/270/216/345/217/257/350/257/273/346/200/247/350/207/252/345/212/250/345/214/226/346/243/200/346/237/245-/345/277/205/345/201/232.md +183 -183
  87. package/skills/playwright-e2e/references/progressive-03-microi-helper-/346/250/241/346/235/277.md +221 -221
  88. package/skills/playwright-e2e/references/progressive-04-ci-/345/273/272/350/256/256.md +115 -115
  89. package/skills/print-engine/SKILL.md +259 -259
  90. package/skills/production-readonly-audit/SKILL.md +41 -41
  91. package/skills/report-engine/SKILL.md +71 -71
  92. package/skills/search-engine/SKILL.md +75 -75
  93. package/skills/spider-engine/SKILL.md +190 -190
  94. package/skills/system-observability/SKILL.md +259 -246
  95. package/skills/system-observability/references/memory-incident-triage.md +77 -77
  96. package/skills/translate-engine/SKILL.md +140 -140
  97. package/skills/ui-design/SKILL.md +223 -223
  98. package/skills/ui-design/assets/templates/MCI-DESIGN.md +206 -206
  99. package/skills/ui-design/references/design-pattern-library.md +184 -184
  100. package/skills/ui-design/references/mci-design-contract.md +163 -163
  101. package/skills/ui-design/references/motion-and-media.md +78 -78
  102. package/skills/ui-design/references/product-flow-recipes.md +94 -94
  103. package/skills/ui-design/references/progressive-01-/351/242/234/350/211/262/344/275/223/347/263/273-css-variables-/346/224/257/346/214/201/344/270/273/351/242/230/345/210/207/346/215/242.md +218 -218
  104. package/skills/ui-design/references/progressive-02-/345/255/227/344/275/223.md +164 -164
  105. package/skills/ui-design/references/progressive-03-/345/212/250/346/225/210/350/247/204/350/214/203-/344/270/260/345/257/214/344/275/206/344/270/215/345/215/241.md +235 -235
  106. package/skills/ui-design/references/progressive-04-/347/273/204/344/273/266/351/243/216/346/240/274/351/200/237/346/237/245.md +152 -152
  107. package/skills/ui-design/references/progressive-05-/347/247/273/345/212/250/347/253/257/344/270/223/347/224/250/350/247/204/350/214/203.md +238 -238
  108. package/skills/ui-design/references/progressive-06-/344/270/273/351/242/230/345/210/207/346/215/242/345/256/236/347/216/260.md +194 -194
  109. package/skills/ui-design/references/progressive-07-/351/200/237/346/237/245-/344/273/216/345/244/264/346/220/255/345/273/272/344/270/200/344/270/252/347/247/273/345/212/250/347/253/257/351/241/265/351/235/242.md +207 -207
  110. package/skills/ui-design/references/progressive-08-/350/241/250/345/215/225/345/210/206/347/273/204/350/247/204/350/214/203-tabs-vs-collapsegroup-/345/274/272/345/210/266.md +142 -142
  111. package/skills/uniapp-mall-assets/SKILL.md +176 -176
  112. package/skills/unity-integration/SKILL.md +178 -171
  113. package/skills/unity-integration/references/ai-app-delivery.md +119 -119
  114. package/skills/unity-integration/references/sdk-api.md +82 -82
  115. package/skills/unity-integration/references/toolbox-migration.md +66 -66
  116. package/skills/unity-integration/references/webgl-hosting.md +57 -57
  117. package/skills/v8-api-config/SKILL.md +388 -388
  118. package/skills/v8-cache-pattern/SKILL.md +312 -312
  119. package/skills/v8-crud-api/SKILL.md +179 -178
  120. package/skills/v8-crud-api/references/progressive-01-/346/237/245/350/257/242/345/210/227/350/241/250-/345/210/206/351/241/265.md +226 -226
  121. package/skills/v8-crud-api/references/progressive-02-where-/346/235/241/344/273/266/350/257/255/346/263/225/351/200/237/346/237/245.md +49 -49
  122. package/skills/v8-debugging/SKILL.md +284 -284
  123. package/skills/v8-explorer-tree/SKILL.md +228 -228
  124. package/skills/v8-export-import/SKILL.md +219 -219
  125. package/skills/v8-export-import/references/progressive-01-excellayout-/351/253/230/347/272/247/350/207/252/347/224/261/345/270/203/345/261/200.md +211 -211
  126. package/skills/v8-export-import/references/progressive-02-powerpoint-/345/257/274/345/207/272.md +202 -202
  127. package/skills/v8-export-import/references/progressive-03-/345/256/211/345/205/250-/346/200/247/350/203/275/346/263/250/346/204/217.md +42 -42
  128. package/skills/v8-file-upload/SKILL.md +255 -284
  129. package/skills/v8-file-upload/references/cdn-alias-repair.md +13 -0
  130. package/skills/v8-file-upload/references/progressive-01-/345/205/254/346/234/211/346/241/266-vs-/347/247/201/346/234/211/346/241/266.md +263 -263
  131. package/skills/v8-file-upload/references/progressive-02-office-/346/226/207/344/273/266/345/234/250/347/272/277/347/274/226/350/276/221/347/211/210/346/234/254/345/217/267/350/247/204/345/210/231.md +161 -161
  132. package/skills/v8-file-upload/references/progressive-03-/347/251/272/347/233/256/345/275/225/346/240/207/350/256/260/344/270/216/350/277/234/347/250/213/344/270/213/350/275/275.md +36 -0
  133. package/skills/v8-formengine-http/SKILL.md +238 -238
  134. package/skills/v8-frontend-events/SKILL.md +180 -180
  135. package/skills/v8-frontend-events/references/bluetooth-print-api.md +135 -135
  136. package/skills/v8-frontend-events/references/bluetooth-print.md +258 -258
  137. package/skills/v8-frontend-events/references/progressive-01-/345/210/227/350/241/250/344/272/213/344/273/266.md +219 -219
  138. package/skills/v8-http-integration/SKILL.md +182 -182
  139. package/skills/v8-http-integration/references/progressive-01-get-/350/257/267/346/261/202.md +220 -220
  140. package/skills/v8-http-integration/references/progressive-02-/351/224/231/350/257/257/345/244/204/347/220/206/346/250/241/345/274/217.md +44 -44
  141. package/skills/v8-image-processing/SKILL.md +190 -190
  142. package/skills/v8-image-processing/references/api-reference.md +623 -623
  143. package/skills/v8-menu-buttons/SKILL.md +186 -186
  144. package/skills/v8-menu-buttons/references/progressive-01-2-/346/214/211/351/222/256/345/257/271/350/261/241-schema.md +222 -222
  145. package/skills/v8-menu-buttons/references/progressive-02-8-/346/250/241/345/274/217-f-/345/220/216/345/217/260/344/273/273/345/212/241/346/214/211/351/222/256-/351/225/277/344/273/273/345/212/241.md +228 -228
  146. package/skills/v8-menu-buttons/references/progressive-03-10-/345/217/215/346/250/241/345/274/217-/351/201/277/345/205/215.md +104 -104
  147. package/skills/v8-mongodb/SKILL.md +200 -200
  148. package/skills/v8-mq-mqtt/SKILL.md +178 -176
  149. package/skills/v8-mq-mqtt/references/mqtt-production.md +352 -342
  150. package/skills/v8-mq-mqtt/references/progressive-01-v8-mqtt-iot-/347/211/251/350/201/224/347/275/221.md +181 -181
  151. package/skills/v8-saas-multi-tenant/SKILL.md +305 -305
  152. package/skills/v8-security/SKILL.md +227 -210
  153. package/skills/v8-security/references/progressive-01-2-/346/235/203/351/231/220/346/240/241/351/252/214.md +200 -200
  154. package/skills/v8-security/references/progressive-02-7-/346/227/245/345/277/227/350/256/260/345/275/225.md +160 -160
  155. package/skills/v8-sql-query/SKILL.md +302 -302
  156. package/skills/v8-table-event/SKILL.md +176 -176
  157. package/skills/v8-table-event/references/progressive-01-informv8-js-/350/241/250/345/215/225/346/211/223/345/274/200/344/272/213/344/273/266.md +216 -216
  158. package/skills/v8-table-event/references/progressive-02-/345/211/215/347/253/257/344/272/213/344/273/266/345/220/215-v8-eventname-/345/217/257/350/203/275/347/232/204/345/200/274.md +46 -46
  159. package/skills/v8-tcp-integration/SKILL.md +158 -147
  160. package/skills/v8-template-engine/SKILL.md +167 -167
  161. package/skills/v8-utilities/SKILL.md +104 -104
  162. package/skills/v8-utilities/references/client-api-index.md +143 -143
  163. package/skills/v8-utilities/references/platform-http-routes.md +83 -83
  164. package/skills/v8-utilities/references/server-api-index.md +188 -188
  165. package/skills/v8-workflow/SKILL.md +252 -252
  166. package/skills/v8-workflow/references/progressive-01-/350/212/202/347/202/271/345/274/200/345/247/213-v8-/344/272/213/344/273/266.md +180 -180
  167. package/skills/v8-workflow/references/workflow-configuration.md +49 -49
  168. package/skills/vision-engine/SKILL.md +160 -160
  169. package/skills/vision-engine/references/architecture-and-acceptance.md +194 -194
  170. package/skills/workspace-conventions/SKILL.md +13 -13
  171. package/skills/workspace-conventions/references/progressive-03-cli-/344/270/216-ide-/346/217/222/344/273/266/351/224/231/347/211/210/345/205/261/345/255/230/347/272/246/345/256/232.md +2 -2
@@ -1,167 +1,167 @@
1
- ---
2
- name: v8-template-engine
3
- description: Microi V8 模板引擎指南。用于编写表格/表单模板渲染、V8.Result HTML/text 输出、行格式化、徽章、图片和自定义显示逻辑。
4
- ---
5
-
6
- > **Microi吾码基础规范(强制):** 任何 AI 模型与宿主每次新建或接续吾码任务,先完整读取 `../workspace-conventions/SKILL.md`,必须执行版本播报、`@microi.net/cli` 后台自动升级、Skills/MCP 同步和进度播报。安装与诊断读取 `../microi-codex-installer/SKILL.md`;更新失败延后重试,不阻断当前工作。
7
-
8
- # Microi V8 模板引擎(表格/表单 V8 模板)
9
-
10
- 你正在为 Microi 吾码平台编写 **表格 V8 模板引擎**、**表单 V8 模板引擎** 代码。模板引擎用于在数据渲染后自定义最终展示效果(颜色、徽章、图片、HTML),是表单引擎的高级特性。
11
-
12
- ## 核心规则
13
-
14
- - 模板引擎绑定在【表单属性】的【表格 V8 模板引擎】或【表单 V8 模板引擎】
15
- - 通过给 `V8.Result` 赋值字符串(HTML 或纯文本)来控制最终渲染结果
16
- - 在 **表格模板** 中:每行数据都会执行一次,`V8.Form` 是当前行数据
17
- - 注意:`V8.Form` 此时只能访问到【模块引擎】配置的【查询列】字段;若查询列为空则可访问全部字段
18
- - 支持 `bootstrap`、`element-ui` 样式类名
19
- - `V8.EventName` 可能为 `TableTemplateEngine` 或 `FormTemplateEngine`
20
- - 表格模板同步执行,输出优先级是 `V8.Result` → JavaScript `return` → 原字段值;表单模板异步执行并以 `V8.Result` 为输出
21
- - 模板结果通过 `v-safe-html`/DOMPurify 净化。`script`、`iframe`、`on*` 事件属性、`javascript:` 等危险内容会被剥离,禁止依赖内联点击事件
22
- - 业务文本必须 HTML 转义后再拼接;权限、校验、状态写入等业务逻辑必须放后端
23
-
24
- 模板中需要拼 HTML 时,先定义安全转义函数:
25
-
26
- ```javascript
27
- var escapeHtml = function (value) {
28
- return String(value == null ? '' : value)
29
- .replace(/&/g, '&')
30
- .replace(/</g, '&lt;')
31
- .replace(/>/g, '&gt;')
32
- .replace(/"/g, '&quot;')
33
- .replace(/'/g, '&#39;');
34
- };
35
- ```
36
-
37
- ## 状态徽章(Bootstrap 样式)
38
-
39
- ```javascript
40
- var value = V8.Form.Zhuangtai;
41
- if (V8.IsNull(value)) {
42
- V8.Result = '';
43
- } else {
44
- var classStr = 'badge-primary';
45
- if (value === '禁用') classStr = 'badge-danger';
46
- else if (value === '未通过') classStr = 'badge-warning';
47
- else if (value === '待审核') classStr = 'badge-info';
48
- else if (value === '通过') classStr = 'badge-success';
49
- V8.Result = '<span class="badge badge-pill ' + classStr + '">' + escapeHtml(value) + '</span>';
50
- }
51
- ```
52
-
53
- 可用 Bootstrap 徽章类:`badge-primary`, `badge-secondary`, `badge-success`, `badge-danger`, `badge-warning`, `badge-info`, `badge-light`, `badge-dark`
54
-
55
- ## 内联样式(颜色高亮)
56
-
57
- ```javascript
58
- // 不同业务状态显示不同字体颜色
59
- if (V8.Form.XuqiuLX === '合并') {
60
- V8.Result = '<span style="color:blue;">' + escapeHtml(V8.Form.XuqiuDDH) + '</span>';
61
- } else if (V8.Form.HebingID) {
62
- V8.Result = '<span style="color:#999;">' + escapeHtml(V8.Form.XuqiuDDH) + '</span>';
63
- } else {
64
- V8.Result = escapeHtml(V8.Form.XuqiuDDH);
65
- }
66
- ```
67
-
68
- ## 单图列渲染
69
-
70
- ```javascript
71
- var html = '';
72
- var fileServer = V8.SysConfig.FileServer;
73
- if (!V8.IsNull(V8.Form.GongsiLOGO)) {
74
- html = '<img src="' + escapeHtml(fileServer + V8.Form.GongsiLOGO) + '" '
75
- + 'alt="公司Logo" '
76
- + 'style="height:40px;width:40px;object-fit:cover;margin:5px 0;" />';
77
- }
78
- V8.Result = html;
79
- ```
80
-
81
- ## 多图列渲染(带点击放大)
82
-
83
- ```javascript
84
- var html = '';
85
- var fileServer = V8.SysConfig.FileServer;
86
- if (!V8.IsNull(V8.Form.TupianMS) && V8.Form.TupianMS.indexOf('[') !== -1) {
87
- var imgs = JSON.parse(V8.Form.TupianMS);
88
- imgs.forEach(function(item) {
89
- var url = escapeHtml(fileServer + item.Path);
90
- html += '<a href="' + url + '" target="_blank" rel="noopener noreferrer">'
91
- + '<img src="' + url + '" alt="图片" '
92
- + 'style="width:40px;height:40px;object-fit:cover;margin:5px 5px 5px 0;" />'
93
- + '</a>';
94
- });
95
- }
96
- V8.Result = html;
97
- ```
98
-
99
- ## 进度条渲染
100
-
101
- ```javascript
102
- var percent = V8.Form.Progress || 0;
103
- var color = '#67C23A';
104
- if (percent < 30) color = '#F56C6C';
105
- else if (percent < 70) color = '#E6A23C';
106
-
107
- V8.Result =
108
- '<div style="width:100%;background:#eee;border-radius:4px;height:16px;position:relative;">'
109
- + '<div style="width:' + percent + '%;background:' + color + ';height:100%;border-radius:4px;"></div>'
110
- + '<span style="position:absolute;left:50%;top:0;transform:translateX(-50%);color:#333;font-size:12px;line-height:16px;">' + percent + '%</span>'
111
- + '</div>';
112
- ```
113
-
114
- ## 多字段合并显示
115
-
116
- ```javascript
117
- // 联系人姓名 + 电话脱敏
118
- var name = V8.Form.LianxiR || '';
119
- var phone = V8.Form.LianxiPhone || '';
120
- if (phone.length === 11) phone = phone.substring(0, 3) + '****' + phone.substring(7);
121
- V8.Result = '<div><b>' + escapeHtml(name) + '</b><br/><small style="color:#999;">'
122
- + escapeHtml(phone) + '</small></div>';
123
- ```
124
-
125
- 模块引擎已有更轻量的声明式方案:`ViewSchema.Layout.List.Columns` 可用 `Field + Lines +
126
- TrailingFields` 组成多行列,`Layout.Card` 可配置移动端顶部、右侧、正文、元信息和底部字段。
127
- 仅需要多字段排版、图标、`Tone/Color/Prefix/Suffix` 时优先使用声明式配置;需要复杂条件
128
- HTML 时再给被引用的 `diy_field` 配置 `V8TmpEngineTable`。两种方式都会复用净化后的模板
129
- 结果,且所有引用字段仍必须在模块查询列或 `_SelectFields` 中。
130
-
131
- ## 条件性图标
132
-
133
- ```javascript
134
- var html = escapeHtml(V8.Form.Title || '');
135
- if (V8.Form.IsHot === 1) html += ' <i class="fas fa-fire" style="color:#F56C6C;"></i>';
136
- if (V8.Form.IsNew === 1) html += ' <span class="badge badge-danger">NEW</span>';
137
- V8.Result = html;
138
- ```
139
-
140
- ## 与字段值变更事件配合(动态计算)
141
-
142
- ```javascript
143
- // 表格模板中根据多个字段计算
144
- var price = parseFloat(V8.Form.Price) || 0;
145
- var discount = parseFloat(V8.Form.Discount) || 1;
146
- var total = (price * discount).toFixed(2);
147
- var color = total > 1000 ? '#F56C6C' : '#67C23A';
148
- V8.Result = '<span style="color:' + color + ';font-weight:bold;">¥' + total + '</span>';
149
- ```
150
-
151
- ## 常见错误
152
-
153
- ❌ 不要在模板中调用 `V8.FormEngine`(每行都查 → N+1 性能问题);需要关联数据时在查询列、接口引擎或后端 `DataFilterV8` 预取,只有 `DataFilterV8` 才提供 `V8.CacheData`
154
- ❌ 不要依赖对象/数组的隐式字符串化;`V8.Result` 建议显式输出字符串
155
- ❌ 模板中 `V8.Form` 默认只有【查询列】字段;缺字段就要去模块引擎补查询列
156
- ❌ 不要在模板里写复杂业务逻辑(应放到接口引擎或 DataFilterV8)
157
- ❌ 不要输出 `onclick/onerror`、`script/iframe` 或 `javascript:` URL;DOMPurify 会剥离这些内容
158
-
159
- ## 与 DataFilterV8 的区别
160
-
161
- | | DataFilterV8(后端) | 模板引擎(前端) |
162
- |---|---|---|
163
- | 运行端 | 服务器 | 浏览器 |
164
- | 用途 | 加工数据、脱敏、补字段 | 渲染 HTML 样式 |
165
- | 输出 | `V8.Form.字段 = ...` | `V8.Result = '<html>...</html>'` |
166
- | 字段范围 | 全部数据 | 仅查询列 |
167
- | 性能 | 每行执行(可用 `V8.CacheData`) | 浏览器渲染时执行 |
1
+ ---
2
+ name: v8-template-engine
3
+ description: Microi V8 模板引擎指南。用于编写表格/表单模板渲染、V8.Result HTML/text 输出、行格式化、徽章、图片和自定义显示逻辑。
4
+ ---
5
+
6
+ > **Microi吾码基础规范(强制):** 任何 AI 模型与宿主每次新建或接续吾码任务,先完整读取 `../workspace-conventions/SKILL.md`,必须执行版本播报、`@microi.net/cli` 后台自动升级、Skills/MCP 同步和进度播报。安装与诊断读取 `../microi-codex-installer/SKILL.md`;更新失败延后重试,不阻断当前工作。
7
+
8
+ # Microi V8 模板引擎(表格/表单 V8 模板)
9
+
10
+ 你正在为 Microi 吾码平台编写 **表格 V8 模板引擎**、**表单 V8 模板引擎** 代码。模板引擎用于在数据渲染后自定义最终展示效果(颜色、徽章、图片、HTML),是表单引擎的高级特性。
11
+
12
+ ## 核心规则
13
+
14
+ - 模板引擎绑定在【表单属性】的【表格 V8 模板引擎】或【表单 V8 模板引擎】
15
+ - 通过给 `V8.Result` 赋值字符串(HTML 或纯文本)来控制最终渲染结果
16
+ - 在 **表格模板** 中:每行数据都会执行一次,`V8.Form` 是当前行数据
17
+ - 注意:`V8.Form` 此时只能访问到【模块引擎】配置的【查询列】字段;若查询列为空则可访问全部字段
18
+ - 支持 `bootstrap`、`element-ui` 样式类名
19
+ - `V8.EventName` 可能为 `TableTemplateEngine` 或 `FormTemplateEngine`
20
+ - 表格模板同步执行,输出优先级是 `V8.Result` → JavaScript `return` → 原字段值;表单模板异步执行并以 `V8.Result` 为输出
21
+ - 模板结果通过 `v-safe-html`/DOMPurify 净化。`script`、`iframe`、`on*` 事件属性、`javascript:` 等危险内容会被剥离,禁止依赖内联点击事件
22
+ - 业务文本必须 HTML 转义后再拼接;权限、校验、状态写入等业务逻辑必须放后端
23
+
24
+ 模板中需要拼 HTML 时,先定义安全转义函数:
25
+
26
+ ```javascript
27
+ var escapeHtml = function (value) {
28
+ return String(value == null ? '' : value)
29
+ .replace(/&/g, '&amp;')
30
+ .replace(/</g, '&lt;')
31
+ .replace(/>/g, '&gt;')
32
+ .replace(/"/g, '&quot;')
33
+ .replace(/'/g, '&#39;');
34
+ };
35
+ ```
36
+
37
+ ## 状态徽章(Bootstrap 样式)
38
+
39
+ ```javascript
40
+ var value = V8.Form.Zhuangtai;
41
+ if (V8.IsNull(value)) {
42
+ V8.Result = '';
43
+ } else {
44
+ var classStr = 'badge-primary';
45
+ if (value === '禁用') classStr = 'badge-danger';
46
+ else if (value === '未通过') classStr = 'badge-warning';
47
+ else if (value === '待审核') classStr = 'badge-info';
48
+ else if (value === '通过') classStr = 'badge-success';
49
+ V8.Result = '<span class="badge badge-pill ' + classStr + '">' + escapeHtml(value) + '</span>';
50
+ }
51
+ ```
52
+
53
+ 可用 Bootstrap 徽章类:`badge-primary`, `badge-secondary`, `badge-success`, `badge-danger`, `badge-warning`, `badge-info`, `badge-light`, `badge-dark`
54
+
55
+ ## 内联样式(颜色高亮)
56
+
57
+ ```javascript
58
+ // 不同业务状态显示不同字体颜色
59
+ if (V8.Form.XuqiuLX === '合并') {
60
+ V8.Result = '<span style="color:blue;">' + escapeHtml(V8.Form.XuqiuDDH) + '</span>';
61
+ } else if (V8.Form.HebingID) {
62
+ V8.Result = '<span style="color:#999;">' + escapeHtml(V8.Form.XuqiuDDH) + '</span>';
63
+ } else {
64
+ V8.Result = escapeHtml(V8.Form.XuqiuDDH);
65
+ }
66
+ ```
67
+
68
+ ## 单图列渲染
69
+
70
+ ```javascript
71
+ var html = '';
72
+ var fileServer = V8.SysConfig.FileServer;
73
+ if (!V8.IsNull(V8.Form.GongsiLOGO)) {
74
+ html = '<img src="' + escapeHtml(fileServer + V8.Form.GongsiLOGO) + '" '
75
+ + 'alt="公司Logo" '
76
+ + 'style="height:40px;width:40px;object-fit:cover;margin:5px 0;" />';
77
+ }
78
+ V8.Result = html;
79
+ ```
80
+
81
+ ## 多图列渲染(带点击放大)
82
+
83
+ ```javascript
84
+ var html = '';
85
+ var fileServer = V8.SysConfig.FileServer;
86
+ if (!V8.IsNull(V8.Form.TupianMS) && V8.Form.TupianMS.indexOf('[') !== -1) {
87
+ var imgs = JSON.parse(V8.Form.TupianMS);
88
+ imgs.forEach(function(item) {
89
+ var url = escapeHtml(fileServer + item.Path);
90
+ html += '<a href="' + url + '" target="_blank" rel="noopener noreferrer">'
91
+ + '<img src="' + url + '" alt="图片" '
92
+ + 'style="width:40px;height:40px;object-fit:cover;margin:5px 5px 5px 0;" />'
93
+ + '</a>';
94
+ });
95
+ }
96
+ V8.Result = html;
97
+ ```
98
+
99
+ ## 进度条渲染
100
+
101
+ ```javascript
102
+ var percent = V8.Form.Progress || 0;
103
+ var color = '#67C23A';
104
+ if (percent < 30) color = '#F56C6C';
105
+ else if (percent < 70) color = '#E6A23C';
106
+
107
+ V8.Result =
108
+ '<div style="width:100%;background:#eee;border-radius:4px;height:16px;position:relative;">'
109
+ + '<div style="width:' + percent + '%;background:' + color + ';height:100%;border-radius:4px;"></div>'
110
+ + '<span style="position:absolute;left:50%;top:0;transform:translateX(-50%);color:#333;font-size:12px;line-height:16px;">' + percent + '%</span>'
111
+ + '</div>';
112
+ ```
113
+
114
+ ## 多字段合并显示
115
+
116
+ ```javascript
117
+ // 联系人姓名 + 电话脱敏
118
+ var name = V8.Form.LianxiR || '';
119
+ var phone = V8.Form.LianxiPhone || '';
120
+ if (phone.length === 11) phone = phone.substring(0, 3) + '****' + phone.substring(7);
121
+ V8.Result = '<div><b>' + escapeHtml(name) + '</b><br/><small style="color:#999;">'
122
+ + escapeHtml(phone) + '</small></div>';
123
+ ```
124
+
125
+ 模块引擎已有更轻量的声明式方案:`ViewSchema.Layout.List.Columns` 可用 `Field + Lines +
126
+ TrailingFields` 组成多行列,`Layout.Card` 可配置移动端顶部、右侧、正文、元信息和底部字段。
127
+ 仅需要多字段排版、图标、`Tone/Color/Prefix/Suffix` 时优先使用声明式配置;需要复杂条件
128
+ HTML 时再给被引用的 `diy_field` 配置 `V8TmpEngineTable`。两种方式都会复用净化后的模板
129
+ 结果,且所有引用字段仍必须在模块查询列或 `_SelectFields` 中。
130
+
131
+ ## 条件性图标
132
+
133
+ ```javascript
134
+ var html = escapeHtml(V8.Form.Title || '');
135
+ if (V8.Form.IsHot === 1) html += ' <i class="fas fa-fire" style="color:#F56C6C;"></i>';
136
+ if (V8.Form.IsNew === 1) html += ' <span class="badge badge-danger">NEW</span>';
137
+ V8.Result = html;
138
+ ```
139
+
140
+ ## 与字段值变更事件配合(动态计算)
141
+
142
+ ```javascript
143
+ // 表格模板中根据多个字段计算
144
+ var price = parseFloat(V8.Form.Price) || 0;
145
+ var discount = parseFloat(V8.Form.Discount) || 1;
146
+ var total = (price * discount).toFixed(2);
147
+ var color = total > 1000 ? '#F56C6C' : '#67C23A';
148
+ V8.Result = '<span style="color:' + color + ';font-weight:bold;">¥' + total + '</span>';
149
+ ```
150
+
151
+ ## 常见错误
152
+
153
+ ❌ 不要在模板中调用 `V8.FormEngine`(每行都查 → N+1 性能问题);需要关联数据时在查询列、接口引擎或后端 `DataFilterV8` 预取,只有 `DataFilterV8` 才提供 `V8.CacheData`
154
+ ❌ 不要依赖对象/数组的隐式字符串化;`V8.Result` 建议显式输出字符串
155
+ ❌ 模板中 `V8.Form` 默认只有【查询列】字段;缺字段就要去模块引擎补查询列
156
+ ❌ 不要在模板里写复杂业务逻辑(应放到接口引擎或 DataFilterV8)
157
+ ❌ 不要输出 `onclick/onerror`、`script/iframe` 或 `javascript:` URL;DOMPurify 会剥离这些内容
158
+
159
+ ## 与 DataFilterV8 的区别
160
+
161
+ | | DataFilterV8(后端) | 模板引擎(前端) |
162
+ |---|---|---|
163
+ | 运行端 | 服务器 | 浏览器 |
164
+ | 用途 | 加工数据、脱敏、补字段 | 渲染 HTML 样式 |
165
+ | 输出 | `V8.Form.字段 = ...` | `V8.Result = '<html>...</html>'` |
166
+ | 字段范围 | 全部数据 | 仅查询列 |
167
+ | 性能 | 每行执行(可用 `V8.CacheData`) | 浏览器渲染时执行 |
@@ -1,104 +1,104 @@
1
- ---
2
- name: v8-utilities
3
- description: Microi V8 全局对象、上下文变量和通用函数索引。用于查询某个 V8 函数是否存在、区分前端与后端 API,或使用 V8.Method、Base64、EncryptHelper、V8.WeChat、Action、CurrentUser、SysConfig、OsClient、扫码和客户端导航工具。
4
- ---
5
-
6
- > **Microi吾码基础规范(强制):** 任何 AI 模型与宿主每次新建或接续吾码任务,先完整读取 `../workspace-conventions/SKILL.md`,必须执行版本播报、`@microi.net/cli` 后台自动升级、Skills/MCP 同步和进度播报。安装与诊断读取 `../microi-codex-installer/SKILL.md`;更新失败延后重试,不阻断当前工作。
7
-
8
- # Microi V8 通用能力与函数索引
9
-
10
- 本 Skill 是 V8 能力的路由入口,不替代 CRUD、HTTP、缓存、文件、图片、Office、
11
- 工作流等专项 Skill。遇到“吾码有没有某个函数”“这个 API 在前端还是后端”
12
- 或官网函数列表同步任务时,先在这里确定运行端和正式名称,再读取专项 Skill。
13
-
14
- ## 先判断运行端
15
-
16
- | 运行端 | 典型位置 | API 特征 |
17
- |---|---|---|
18
- | 前端 | 字段事件、按钮、列表、InFormV8、SubmitFormV8、OutFormV8 | 浏览器 Promise/回调、弹窗、路由、`V8.Print`、扫码 |
19
- | 后端 | 接口引擎、SubmitBeforeServerV8、SubmitAfterServerV8、DataFilterV8 | `V8.Db`、事务、缓存、Office、加密、服务端 HTTP |
20
-
21
- 同名对象不保证两端方法一致。例如前端 `V8.Base64.encode/decode` 与后端
22
- `V8.Base64.StringToBase64/Base64ToString` 不同;前端标准运行时没有公开
23
- `V8.ModuleEngine`,后端才有模块引擎对象。
24
-
25
- ## 必读索引
26
-
27
- - 前端全部上下文、表单/列表、导航、网络、引擎和工具:
28
- `references/client-api-index.md`
29
- - 后端上下文、`V8.Method`、Base64、加密、异步与扩展对象:
30
- `references/server-api-index.md`
31
- - 平台 HTTP 路由、动态路由与管理接口边界:
32
- `references/platform-http-routes.md`
33
- - 蓝牙标签/小票打印:
34
- `../v8-frontend-events/references/bluetooth-print.md`
35
-
36
- 若函数未出现在上述索引或当前源码定义中,不得按名字猜测。先搜索
37
- `Microi.Client/src/views/form-engine/diy-components/v8-api-definitions.js`、
38
- `v8-api-server-definitions.js`、V8 宿主接口和官网中文函数列表。
39
-
40
- 邮箱相关能力读取 [email-engine](../email-engine/SKILL.md):`V8.Email` 包含
41
- `ProtectCredential / TestConnection / ListFolders / Fetch / Inspect / GetMessage /
42
- GetAttachment / SetFlags / Move / Send / StoreSent`。
43
- 业务使用 `mci-email` 接口引擎,MCP 使用 `microi_email_query / microi_email_manage / microi_email_send`。
44
-
45
- ## 常用通用写法
46
-
47
- ```javascript
48
- // 两端通用的租户/用户上下文,具体字段按当前上下文判空
49
- var osClient = V8.OsClient;
50
- var userId = V8.CurrentUser && V8.CurrentUser.Id;
51
-
52
- // 后端稳定标识与时间
53
- var id = V8.Method.NewUlid();
54
- var now = DateNow('yyyy-MM-dd HH:mm:ss');
55
- var timestamp = V8.Method.GetTimestamp();
56
-
57
- // 后端 Base64
58
- var encoded = V8.Base64.StringToBase64('吾码');
59
- var decoded = V8.Base64.Base64ToString(encoded);
60
-
61
- // 前端 Base64
62
- var clientEncoded = V8.Base64.encode('吾码');
63
- var clientDecoded = V8.Base64.decode(clientEncoded);
64
- ```
65
-
66
- ## 能力选择
67
-
68
- - 日期基础函数由新版后端运行时自举,不能要求租户先配置 DateNow 才能安装应用。全局函数管理使用系统设置子表 `mci_global_function`,按 `SysConfigId + Runtime(Client/Server) + FunctionName` 隔离,一行一个同名 function 声明;用 `V8.Method.ValidateGlobalFunction` 只解析验证,不执行源码。
69
- - 原有前后端全局 V8 必须保留,合并顺序为内置日期、函数库、租户原有代码;同名原有函数优先。不得用官方全局脚本整段覆盖客户脚本。函数库种子 `InsertIfMissing`,不得升级覆盖客户已改源码。
70
- - 列表和合并代码走 L1/Redis,表单引擎真实提交后更新租户版本并通知其它节点;回滚不变更版本。禁止通过直接 SQL 修改函数库规避失效。前端已打开页面需要刷新。
71
-
72
- ## 受信固定步长运行时发现
73
-
74
- `V8.Method.RunPlatformApiRuntime({RuntimeKey:'fixed-step-simulation',Action,Param})` 属于需后端正式安装的通用原子。动作是 DescribeInvocation/CreateInitialState/AdvanceBatch/Project/ObserveOwnedRoom/StopOwnedRoom/DrainOwnedRoom;精确引擎Key由后台已审批目录限制,不能用通用private转发接口原样接受玩家信封。Param只能承载经接口引擎授权后的数据,不能指定Tenant/EngineKey/NodeId/客户端时钟作为真实上下文。Observe是提交前有界调度提示,后续须重新核DB,不是提交回执;终局用Drain保留当前请求提交机会,Stop则立即取消。规则程序集入口与hash须由私有后端发行组合固定,V8/MCP不提供上传即执行的注册能力。详细边界见unity-integration及后端V8主文档;线上缺原子时明确未安装,不能用Job/SignalR冒充。
75
-
76
- 固定步运行时的临时拒绝仅使用 `DataAppend.ErrorCode` 六码白名单:KernelBusy/HostMemoryPressure/RoomStillDraining/CoordinatorStopping/StaleLease/ComputeBudgetExceeded,并要求 `Retryable===true`。Managed须显式catch-return稳定Code0并回滚,客户端有界同键重试;禁止按中文Msg或带行号异常猜测重试,更不能把授权/来源/未知失败当临时成功。此兼容扩展不增加审批表/配置或MCP任意注册入口。
77
-
78
- 普通租户的编译证明默认 `TenantInstallation`,保留真实 Installed 回执及旧摘要。官方同租户发布源禁止安装自己,只能由后端发行组合明确固定 `OfficialPublishedSnapshot`:`InstallRecordId` 绑定 `mic_data_version.Id`,原始 `Data` 的UTF-8 SHA-256另固定于编译回执并参与独立审批摘要。该类别与快照摘要不从Param或自由表字段选择、不新增表字段、不伪造Installed。受信官方身份、当前Published/审批有效指针、Verified包hash/size/HDFS、不可变快照、V3 Completed源码hash及实际DLL依赖须全部匹配;当前状态变化、软删或主库不可用下次调用立即拒绝,旧历史存在不足以授权。跨租户仍拒绝,结构发布不等于后端安装或代码审批。审批表纳入通用强制管理员清单,普通用户即使误授表/菜单权限仍不得改授权状态;V8Limit和ReadPrimary不是写权限。
79
-
80
- ## 平台兼容入口索引
81
-
82
- 下列旧 HTTP 地址仍由受控兼容链路识别,不能据此绕过 DiyToken、租户或权限校验:`/api/FormEngine/GetSysConfig`、`/api/Os/GetDateTimeNow`、`/api/SysLog/AddSysLog`、`/api/SysUser/`。畅捷通 V2 回调在接口引擎中编排,可信后端只提供当前租户绑定的 `V8.Method.DecodeChanjetCallbackV2` 原子。
83
-
84
- | 需求 | 专项 Skill |
85
- |---|---|
86
- | 表单 CRUD、`_Where` | `v8-crud-api`、`v8-sql-query` |
87
- | HTTP/第三方接口 | `v8-http-integration` |
88
- | TCP 原始字节/网络小票机/设备 | `v8-tcp-integration` |
89
- | Redis/Hash | `v8-cache-pattern` |
90
- | 文件/HDFS | `v8-file-upload` |
91
- | 图片 | `v8-image-processing` |
92
- | Excel/Word/PPT/邮件 | `v8-export-import` |
93
- | 微信支付签名、授权头、API v3 AES-GCM 解密 | `references/server-api-index.md`;安全边界见 `v8-security` |
94
- | 前端事件/打印/扫码 | `v8-frontend-events` |
95
- | 后端表单事件 | `v8-table-event` |
96
- | 接口配置/流式响应/异步/后台任务 | `v8-api-config` |
97
-
98
- ## 不可越过的边界
99
-
100
- - 平台能力优先使用 `V8.*`,不要假设全局 `System` 可访问任意 CLR 类型。
101
- - `V8.SysConfig`、`V8.OsClientModel`、`V8.ClientModel` 可能含连接串、密钥和供应商配置,不直接返回前端或写日志。
102
- - 摘要算法不是密码存储。新密码不使用 MD5/SHA1/SHA256 直接保存。
103
- - `setTimeout`、`Task.Run` 不能承担请求返回后的可靠后台执行。
104
- - 前端值只可用于交互;权限、事务和最终业务校验必须在可信后端执行。
1
+ ---
2
+ name: v8-utilities
3
+ description: Microi V8 全局对象、上下文变量和通用函数索引。用于查询某个 V8 函数是否存在、区分前端与后端 API,或使用 V8.Method、Base64、EncryptHelper、V8.WeChat、Action、CurrentUser、SysConfig、OsClient、扫码和客户端导航工具。
4
+ ---
5
+
6
+ > **Microi吾码基础规范(强制):** 任何 AI 模型与宿主每次新建或接续吾码任务,先完整读取 `../workspace-conventions/SKILL.md`,必须执行版本播报、`@microi.net/cli` 后台自动升级、Skills/MCP 同步和进度播报。安装与诊断读取 `../microi-codex-installer/SKILL.md`;更新失败延后重试,不阻断当前工作。
7
+
8
+ # Microi V8 通用能力与函数索引
9
+
10
+ 本 Skill 是 V8 能力的路由入口,不替代 CRUD、HTTP、缓存、文件、图片、Office、
11
+ 工作流等专项 Skill。遇到“吾码有没有某个函数”“这个 API 在前端还是后端”
12
+ 或官网函数列表同步任务时,先在这里确定运行端和正式名称,再读取专项 Skill。
13
+
14
+ ## 先判断运行端
15
+
16
+ | 运行端 | 典型位置 | API 特征 |
17
+ |---|---|---|
18
+ | 前端 | 字段事件、按钮、列表、InFormV8、SubmitFormV8、OutFormV8 | 浏览器 Promise/回调、弹窗、路由、`V8.Print`、扫码 |
19
+ | 后端 | 接口引擎、SubmitBeforeServerV8、SubmitAfterServerV8、DataFilterV8 | `V8.Db`、事务、缓存、Office、加密、服务端 HTTP |
20
+
21
+ 同名对象不保证两端方法一致。例如前端 `V8.Base64.encode/decode` 与后端
22
+ `V8.Base64.StringToBase64/Base64ToString` 不同;前端标准运行时没有公开
23
+ `V8.ModuleEngine`,后端才有模块引擎对象。
24
+
25
+ ## 必读索引
26
+
27
+ - 前端全部上下文、表单/列表、导航、网络、引擎和工具:
28
+ `references/client-api-index.md`
29
+ - 后端上下文、`V8.Method`、Base64、加密、异步与扩展对象:
30
+ `references/server-api-index.md`
31
+ - 平台 HTTP 路由、动态路由与管理接口边界:
32
+ `references/platform-http-routes.md`
33
+ - 蓝牙标签/小票打印:
34
+ `../v8-frontend-events/references/bluetooth-print.md`
35
+
36
+ 若函数未出现在上述索引或当前源码定义中,不得按名字猜测。先搜索
37
+ `Microi.Client/src/views/form-engine/diy-components/v8-api-definitions.js`、
38
+ `v8-api-server-definitions.js`、V8 宿主接口和官网中文函数列表。
39
+
40
+ 邮箱相关能力读取 [email-engine](../email-engine/SKILL.md):`V8.Email` 包含
41
+ `ProtectCredential / TestConnection / ListFolders / Fetch / Inspect / GetMessage /
42
+ GetAttachment / SetFlags / Move / Send / StoreSent`。
43
+ 业务使用 `mci-email` 接口引擎,MCP 使用 `microi_email_query / microi_email_manage / microi_email_send`。
44
+
45
+ ## 常用通用写法
46
+
47
+ ```javascript
48
+ // 两端通用的租户/用户上下文,具体字段按当前上下文判空
49
+ var osClient = V8.OsClient;
50
+ var userId = V8.CurrentUser && V8.CurrentUser.Id;
51
+
52
+ // 后端稳定标识与时间
53
+ var id = V8.Method.NewUlid();
54
+ var now = DateNow('yyyy-MM-dd HH:mm:ss');
55
+ var timestamp = V8.Method.GetTimestamp();
56
+
57
+ // 后端 Base64
58
+ var encoded = V8.Base64.StringToBase64('吾码');
59
+ var decoded = V8.Base64.Base64ToString(encoded);
60
+
61
+ // 前端 Base64
62
+ var clientEncoded = V8.Base64.encode('吾码');
63
+ var clientDecoded = V8.Base64.decode(clientEncoded);
64
+ ```
65
+
66
+ ## 能力选择
67
+
68
+ - 日期基础函数由新版后端运行时自举,不能要求租户先配置 DateNow 才能安装应用。全局函数管理使用系统设置子表 `mci_global_function`,按 `SysConfigId + Runtime(Client/Server) + FunctionName` 隔离,一行一个同名 function 声明;用 `V8.Method.ValidateGlobalFunction` 只解析验证,不执行源码。
69
+ - 原有前后端全局 V8 必须保留,合并顺序为内置日期、函数库、租户原有代码;同名原有函数优先。不得用官方全局脚本整段覆盖客户脚本。函数库种子 `InsertIfMissing`,不得升级覆盖客户已改源码。
70
+ - 列表和合并代码走 L1/Redis,表单引擎真实提交后更新租户版本并通知其它节点;回滚不变更版本。禁止通过直接 SQL 修改函数库规避失效。前端已打开页面需要刷新。
71
+
72
+ ## 受信固定步长运行时发现
73
+
74
+ `V8.Method.RunPlatformApiRuntime({RuntimeKey:'fixed-step-simulation',Action,Param})` 属于需后端正式安装的通用原子。动作是 DescribeInvocation/CreateInitialState/AdvanceBatch/Project/ObserveOwnedRoom/StopOwnedRoom/DrainOwnedRoom;精确引擎Key由后台已审批目录限制,不能用通用private转发接口原样接受玩家信封。Param只能承载经接口引擎授权后的数据,不能指定Tenant/EngineKey/NodeId/客户端时钟作为真实上下文。Observe是提交前有界调度提示,后续须重新核DB,不是提交回执;终局用Drain保留当前请求提交机会,Stop则立即取消。规则程序集入口与hash须由私有后端发行组合固定,V8/MCP不提供上传即执行的注册能力。详细边界见unity-integration及后端V8主文档;线上缺原子时明确未安装,不能用Job/SignalR冒充。
75
+
76
+ 固定步运行时的临时拒绝仅使用 `DataAppend.ErrorCode` 六码白名单:KernelBusy/HostMemoryPressure/RoomStillDraining/CoordinatorStopping/StaleLease/ComputeBudgetExceeded,并要求 `Retryable===true`。Managed须显式catch-return稳定Code0并回滚,客户端有界同键重试;禁止按中文Msg或带行号异常猜测重试,更不能把授权/来源/未知失败当临时成功。此兼容扩展不增加审批表/配置或MCP任意注册入口。
77
+
78
+ 普通租户的编译证明默认 `TenantInstallation`,保留真实 Installed 回执及旧摘要。官方同租户发布源禁止安装自己,只能由后端发行组合明确固定 `OfficialPublishedSnapshot`:`InstallRecordId` 绑定 `mic_data_version.Id`,原始 `Data` 的UTF-8 SHA-256另固定于编译回执并参与独立审批摘要。该类别与快照摘要不从Param或自由表字段选择、不新增表字段、不伪造Installed。受信官方身份、当前Published/审批有效指针、Verified包hash/size/HDFS、不可变快照、V3 Completed源码hash及实际DLL依赖须全部匹配;当前状态变化、软删或主库不可用下次调用立即拒绝,旧历史存在不足以授权。跨租户仍拒绝,结构发布不等于后端安装或代码审批。审批表纳入通用强制管理员清单,普通用户即使误授表/菜单权限仍不得改授权状态;V8Limit和ReadPrimary不是写权限。
79
+
80
+ ## 平台兼容入口索引
81
+
82
+ 下列旧 HTTP 地址仍由受控兼容链路识别,不能据此绕过 DiyToken、租户或权限校验:`/api/FormEngine/GetSysConfig`、`/api/Os/GetDateTimeNow`、`/api/SysLog/AddSysLog`、`/api/SysUser/`。畅捷通 V2 回调在接口引擎中编排,可信后端只提供当前租户绑定的 `V8.Method.DecodeChanjetCallbackV2` 原子。
83
+
84
+ | 需求 | 专项 Skill |
85
+ |---|---|
86
+ | 表单 CRUD、`_Where` | `v8-crud-api`、`v8-sql-query` |
87
+ | HTTP/第三方接口 | `v8-http-integration` |
88
+ | TCP 原始字节/网络小票机/设备 | `v8-tcp-integration` |
89
+ | Redis/Hash | `v8-cache-pattern` |
90
+ | 文件/HDFS | `v8-file-upload` |
91
+ | 图片 | `v8-image-processing` |
92
+ | Excel/Word/PPT/邮件 | `v8-export-import` |
93
+ | 微信支付签名、授权头、API v3 AES-GCM 解密 | `references/server-api-index.md`;安全边界见 `v8-security` |
94
+ | 前端事件/打印/扫码 | `v8-frontend-events` |
95
+ | 后端表单事件 | `v8-table-event` |
96
+ | 接口配置/流式响应/异步/后台任务 | `v8-api-config` |
97
+
98
+ ## 不可越过的边界
99
+
100
+ - 平台能力优先使用 `V8.*`,不要假设全局 `System` 可访问任意 CLR 类型。
101
+ - `V8.SysConfig`、`V8.OsClientModel`、`V8.ClientModel` 可能含连接串、密钥和供应商配置,不直接返回前端或写日志。
102
+ - 摘要算法不是密码存储。新密码不使用 MD5/SHA1/SHA256 直接保存。
103
+ - `setTimeout`、`Task.Run` 不能承担请求返回后的可靠后台执行。
104
+ - 前端值只可用于交互;权限、事务和最终业务校验必须在可信后端执行。