@microi.net/cli 5.8.5 → 5.8.6
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/.codebuddy-plugin/marketplace.json +2 -2
- package/.codebuddy-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.mcp.json +1 -1
- package/.workbuddy-plugin/marketplace.json +2 -2
- package/.workbuddy-plugin/plugin.json +1 -1
- package/LICENSE +21 -21
- package/README.md +71 -71
- package/assets/build-meta.json +6 -6
- package/assets/feature-matrix.json +138 -138
- package/assets/logo.svg +4 -4
- package/cordis.patch.yml +1 -1
- package/package.json +1 -1
- package/scripts/codex-marketplace.json +20 -20
- package/scripts/mcp-codex-stdio-adapter.js +189 -189
- package/scripts/mcp-trae-windows-launcher.cmd +21 -21
- package/scripts/microi-cli-mcp.js +7 -7
- package/scripts/microi-cli.js +66 -65
- package/scripts/microi-codex-broker.js +450 -450
- package/scripts/microi-codex-router.js +618 -618
- package/scripts/microi-skills.meta.json +384 -384
- package/skills/.microi-skills-version.json +2 -2
- package/skills/.progressive-disclosure-manifest.json +3566 -3566
- package/skills/README.md +287 -287
- package/skills/ai-engine/SKILL.md +269 -265
- package/skills/ai-engine/agents/openai.yaml +4 -4
- package/skills/ai-engine/references/ai-employees.md +48 -48
- package/skills/ai-engine/references/self-hosted-digital-human.md +59 -59
- package/skills/ai-platform-governance/SKILL.md +177 -177
- package/skills/ai-platform-governance/references/progressive-01-/345/212/237/350/203/275/345/274/200/345/205/263.md +190 -190
- package/skills/app-store/SKILL.md +525 -525
- package/skills/app-store/agents/openai.yaml +4 -4
- package/skills/business-blueprint/SKILL.md +193 -193
- package/skills/datasource-engine/SKILL.md +93 -93
- package/skills/datasource-engine/agents/openai.yaml +4 -4
- package/skills/dos-orm/SKILL.md +97 -97
- package/skills/dos-orm/references/api-reference.md +229 -229
- package/skills/email-engine/SKILL.md +81 -81
- package/skills/email-engine/references/v8-email.md +34 -34
- package/skills/job-engine/SKILL.md +176 -176
- package/skills/job-engine/agents/openai.yaml +4 -4
- package/skills/message-notification/SKILL.md +156 -156
- package/skills/message-notification/agents/openai.yaml +5 -5
- package/skills/message-notification/references/contracts.md +102 -102
- package/skills/microi/SKILL.md +14 -14
- package/skills/microi-ai-app-auth.js +652 -652
- package/skills/microi-ai-application/SKILL.md +115 -115
- package/skills/microi-ai-application/agents/openai.yaml +4 -4
- package/skills/microi-ai-application/references/frontend-baseline.md +164 -164
- package/skills/microi-client-frontend/SKILL.md +244 -244
- 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
- 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
- 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
- package/skills/microi-codex/SKILL.md +102 -102
- package/skills/microi-codex-installer/SKILL.md +231 -231
- package/skills/microi-codex-installer/agents/openai.yaml +7 -7
- package/skills/microi-datasource-mapping/SKILL.md +122 -122
- package/skills/microi-db-schema/SKILL.md +175 -175
- package/skills/microi-db-schema/agents/openai.yaml +4 -4
- package/skills/microi-db-schema/references/core-tables.md +695 -695
- package/skills/microi-db-schema/references/form-component-options.md +256 -256
- package/skills/microi-db-schema/references/schema-overview.md +202 -202
- package/skills/microi-db-schema/references/schema.md +646 -646
- package/skills/microi-db-schema/references/table-catalog.md +1599 -1599
- package/skills/microi-deployment/SKILL.md +221 -221
- package/skills/microi-deployment/references/deployment-matrix.md +109 -109
- package/skills/microi-docs-coverage/SKILL.md +133 -133
- package/skills/microi-docs-coverage/references/capability-map.md +91 -91
- package/skills/microi-docs-coverage/scripts/audit-doc-skill-coverage.mjs +894 -894
- package/skills/microi-form-engine/SKILL.md +333 -333
- package/skills/microi-form-engine/references/component-catalog.md +218 -218
- package/skills/microi-form-engine/references/data-source-events.md +124 -124
- package/skills/microi-form-layout/SKILL.md +205 -205
- package/skills/microi-form-layout/references/progressive-01-3-/344/270/211/347/247/215/345/210/206/347/273/204/347/232/204/345/255/230/345/202/250/344/270/216/351/205/215/347/275/256.md +235 -235
- package/skills/microi-frontend-sdk/SKILL.md +194 -194
- 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
- package/skills/microi-left-right-layout/SKILL.md +141 -141
- package/skills/microi-microservice/SKILL.md +326 -324
- package/skills/microi-microservice/references/runtime-delivery.md +278 -278
- package/skills/microi-mobile-app-quality/SKILL.md +185 -185
- 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 +213 -213
- 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 +128 -128
- package/skills/microi-solution-quotation/SKILL.md +78 -78
- package/skills/microi-solution-quotation/agents/openai.yaml +4 -4
- package/skills/microi-solution-quotation/scripts/build_solution_quote.py +296 -296
- package/skills/microi-sso/SKILL.md +92 -92
- package/skills/microi-sso/references/acceptance.md +49 -49
- package/skills/microi-sso/references/configuration-and-security.md +53 -53
- package/skills/microi-sso/references/inbound.md +53 -53
- package/skills/microi-sso/references/outbound.md +39 -39
- package/skills/microi-system-delivery/SKILL.md +137 -137
- package/skills/microi-system-delivery/references/progressive-01-/346/240/207/345/207/206/345/267/245/344/275/234/346/265/201.md +193 -193
- package/skills/microi-system-delivery/references/progressive-02-/350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/345/277/205/351/241/273/350/246/206/347/233/226/347/232/204/345/235/221.md +217 -217
- package/skills/microi-ui/SKILL.md +192 -192
- 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
- package/skills/microi-uniapp-frontend/SKILL.md +193 -193
- 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 +225 -225
- 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
- package/skills/microi.v8.js +1921 -1921
- package/skills/module-engine/SKILL.md +255 -255
- package/skills/module-engine/references/module-config.md +204 -204
- package/skills/ocr-engine/SKILL.md +113 -113
- package/skills/ocr-engine/agents/openai.yaml +4 -4
- package/skills/page-engine/SKILL.md +206 -206
- package/skills/page-engine/examples/compact-dashboard.json +1444 -1444
- 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
- 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
- package/skills/performance-testing/SKILL.md +221 -221
- package/skills/playwright-e2e/SKILL.md +196 -196
- 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
- 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
- package/skills/playwright-e2e/references/progressive-03-microi-helper-/346/250/241/346/235/277.md +221 -221
- package/skills/playwright-e2e/references/progressive-04-ci-/345/273/272/350/256/256.md +115 -115
- package/skills/print-engine/SKILL.md +259 -259
- package/skills/production-readonly-audit/SKILL.md +41 -41
- package/skills/report-engine/SKILL.md +71 -71
- package/skills/report-engine/agents/openai.yaml +4 -4
- package/skills/scripts/optimize-progressive-disclosure.mjs +204 -204
- package/skills/scripts/refresh-progressive-disclosure.mjs +64 -64
- package/skills/scripts/sync-embedded-skills.mjs +46 -46
- package/skills/scripts/validate-progressive-disclosure.mjs +57 -57
- package/skills/search-engine/SKILL.md +75 -75
- package/skills/search-engine/agents/openai.yaml +4 -4
- package/skills/spider-engine/SKILL.md +190 -190
- package/skills/system-observability/SKILL.md +248 -248
- package/skills/system-observability/references/memory-incident-triage.md +77 -77
- package/skills/translate-engine/SKILL.md +140 -140
- package/skills/translate-engine/agents/openai.yaml +4 -4
- package/skills/ui-design/SKILL.md +223 -223
- package/skills/ui-design/assets/pattern-showcase/app.js +54 -54
- package/skills/ui-design/assets/pattern-showcase/index.html +163 -163
- package/skills/ui-design/assets/pattern-showcase/styles.css +311 -311
- package/skills/ui-design/assets/templates/MCI-DESIGN.md +206 -206
- package/skills/ui-design/references/design-pattern-library.md +184 -184
- package/skills/ui-design/references/mci-design-contract.md +163 -163
- package/skills/ui-design/references/motion-and-media.md +78 -78
- package/skills/ui-design/references/product-flow-recipes.md +94 -94
- 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
- package/skills/ui-design/references/progressive-02-/345/255/227/344/275/223.md +164 -164
- 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
- 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
- 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
- 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
- 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
- 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
- package/skills/uniapp-mall-assets/SKILL.md +176 -176
- package/skills/unity-integration/SKILL.md +171 -171
- package/skills/unity-integration/agents/openai.yaml +4 -4
- package/skills/unity-integration/references/ai-app-delivery.md +119 -119
- package/skills/unity-integration/references/sdk-api.md +82 -82
- package/skills/unity-integration/references/toolbox-migration.md +66 -66
- package/skills/unity-integration/references/webgl-hosting.md +57 -57
- package/skills/v8-api-config/SKILL.md +388 -388
- package/skills/v8-cache-pattern/SKILL.md +312 -312
- package/skills/v8-crud-api/SKILL.md +178 -178
- 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
- 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
- package/skills/v8-debugging/SKILL.md +284 -284
- package/skills/v8-explorer-tree/SKILL.md +228 -228
- package/skills/v8-export-import/SKILL.md +219 -219
- 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
- package/skills/v8-export-import/references/progressive-02-powerpoint-/345/257/274/345/207/272.md +202 -202
- 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
- package/skills/v8-file-upload/SKILL.md +284 -284
- 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
- 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
- package/skills/v8-formengine-http/SKILL.md +238 -238
- package/skills/v8-frontend-events/SKILL.md +180 -180
- package/skills/v8-frontend-events/references/bluetooth-print-api.md +135 -135
- package/skills/v8-frontend-events/references/bluetooth-print.md +258 -258
- package/skills/v8-frontend-events/references/progressive-01-/345/210/227/350/241/250/344/272/213/344/273/266.md +219 -219
- package/skills/v8-http-integration/SKILL.md +182 -182
- package/skills/v8-http-integration/references/progressive-01-get-/350/257/267/346/261/202.md +220 -220
- 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
- package/skills/v8-image-processing/SKILL.md +190 -190
- package/skills/v8-image-processing/agents/openai.yaml +4 -4
- package/skills/v8-image-processing/references/api-reference.md +623 -623
- package/skills/v8-menu-buttons/SKILL.md +186 -186
- 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
- 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
- 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
- package/skills/v8-mongodb/SKILL.md +200 -200
- package/skills/v8-mq-mqtt/SKILL.md +176 -176
- package/skills/v8-mq-mqtt/references/mqtt-production.md +342 -342
- package/skills/v8-mq-mqtt/references/progressive-01-v8-mqtt-iot-/347/211/251/350/201/224/347/275/221.md +181 -181
- package/skills/v8-mq-mqtt/scripts/check-mqtt-skill-coverage.mjs +203 -203
- package/skills/v8-saas-multi-tenant/SKILL.md +305 -305
- package/skills/v8-security/SKILL.md +210 -210
- package/skills/v8-security/references/progressive-01-2-/346/235/203/351/231/220/346/240/241/351/252/214.md +200 -200
- package/skills/v8-security/references/progressive-02-7-/346/227/245/345/277/227/350/256/260/345/275/225.md +160 -160
- package/skills/v8-sql-query/SKILL.md +302 -302
- package/skills/v8-table-event/SKILL.md +176 -176
- 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
- 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
- package/skills/v8-tcp-integration/SKILL.md +147 -147
- package/skills/v8-tcp-integration/agents/openai.yaml +4 -4
- package/skills/v8-template-engine/SKILL.md +167 -167
- package/skills/v8-utilities/SKILL.md +104 -104
- package/skills/v8-utilities/references/client-api-index.md +143 -143
- package/skills/v8-utilities/references/platform-http-routes.md +83 -83
- package/skills/v8-utilities/references/server-api-index.md +188 -188
- package/skills/v8-workflow/SKILL.md +252 -252
- 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
- package/skills/v8-workflow/references/workflow-configuration.md +49 -49
- package/skills/vision-engine/SKILL.md +160 -160
- package/skills/vision-engine/agents/openai.yaml +4 -4
- package/skills/vision-engine/references/architecture-and-acceptance.md +194 -194
- package/skills/workspace-conventions/SKILL.md +273 -273
- package/skills/workspace-conventions/references/progressive-01-/347/211/210/346/234/254/346/233/264/346/226/260/346/227/245/345/277/227/344/277/235/346/212/244/350/247/204/345/210/231-/345/274/272/345/210/266.md +209 -209
- package/skills/workspace-conventions/references/progressive-02-microi-net-api-/346/234/254/345/234/260/345/220/257/345/212/250/347/272/246/345/256/232.md +217 -217
- 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 +27 -27
|
@@ -1,180 +1,180 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: v8-frontend-events
|
|
3
|
-
description: Microi 前端 V8 事件与客户端能力指南。用于编写浏览器端字段、按钮、列表事件,或使用 V8.EventName、V8.Form、V8.Print 蓝牙打印(佳博 GP-M322、ZICOX CC4、TSPL、CPCL、ESC/POS、BLE、SPP)、扫码、弹窗、表单联动和界面交互。
|
|
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
|
-
你正在为 Microi 吾码平台编写 **前端 V8 事件** 代码。前端事件运行在浏览器,通过 `V8.EventName` 区分事件类型,可访问表单/列表/弹窗等丰富的客户端 API。
|
|
11
|
-
|
|
12
|
-
> **表单生命周期事件**(InFormV8、SubmitFormV8、SubmitBeforeServerV8、SubmitAfterServerV8、OutFormV8、DataFilterV8)见 `v8-table-event/SKILL.md`。
|
|
13
|
-
> **菜单按钮事件**(MoreBtns/FormBtns 等)见 `v8-menu-buttons/SKILL.md`。
|
|
14
|
-
> 本文重点是 **字段事件、按钮事件、列表事件、模板引擎、其它前端钩子**。
|
|
15
|
-
|
|
16
|
-
<!-- microi-progressive:begin -->
|
|
17
|
-
<!-- microi-progressive:chunk id=v8-frontend-events-000 sha256=69ad0ebf0c8aca6edcbc0bbfe7e280986525bf28f68da8cb33c8efbc4509f7da -->
|
|
18
|
-
## 能力路由
|
|
19
|
-
|
|
20
|
-
- 查询前端 V8 全部上下文、导航、表单、列表、网络、引擎与工具入口时,读取 `../v8-utilities/references/client-api-index.md`。
|
|
21
|
-
- 需求包含“蓝牙打印、标签打印、TSC/TSPL、CPCL、ESC/POS、小票打印、佳博/GP-M322、ZICOX/芝柯/CC4、BLE/SPP”时,必须先读取 `references/bluetooth-print.md`;需要完整指令签名、型号转换范围、编码或位图参数时,再读取 `references/bluetooth-print-api.md`。
|
|
22
|
-
- `microi.app` 是 5+ 在线壳,不能假设存在 `uni` 或 Web Bluetooth。BLE 连接、发现和写入必须统一使用 `plus.bluetooth`,禁止用 `uni.writeBLECharacteristicValue` 写入由 `plus.bluetooth` 建立的连接。5+ `V8.Print.getConnectionState()` 的 `mtu/maxWriteBytes/recommendedPacketSize/writeType/packetIntervalMs` 描述本次连接能力。Android GP-M322 在特征支持时优先 `writeNoResponse`,即使协商出 180 字节有效载荷也只采用 100 字节连续发送稳定档,并保留约 8ms 包间保护;不支持无响应写时兼容 `write`,空 MTU 成功、失败、超时或旧壳只用 20 字节。详见蓝牙参考。
|
|
23
|
-
- 浏览器模板打印、PDF/纸张模板、`mic_print`、`PageObj`、`PrintObj` 使用 `print-engine/SKILL.md`,不要与直接蓝牙指令混为一套 API。
|
|
24
|
-
- 扫码使用 `V8.Method.ScanCode`,结果从 Promise/回调取得;`V8.ScanCodeRes` 只作兼容结果槽,详见客户端 API 索引。
|
|
25
|
-
- 登录后的敏感操作使用 `V8.Identity.Verify` 完成 Passkey/严格人脸交互;前端只取得一次性 Ticket,后端接口引擎必须重算 `ActionHash` 并原子消费,不能把前端成功当作授权。
|
|
26
|
-
|
|
27
|
-
<!-- /microi-progressive:chunk -->
|
|
28
|
-
<!-- microi-progressive:chunk id=v8-frontend-events-001 sha256=eaab87d01b0fd2b6964326ee11edd7b793899c679930c575a0a2b309d36a367a -->
|
|
29
|
-
## 字段事件(在【字段属性】中配置)
|
|
30
|
-
|
|
31
|
-
### FieldValueChange — 值变更事件(最常用)
|
|
32
|
-
|
|
33
|
-
```javascript
|
|
34
|
-
// V8.EventName === 'FieldValueChange'
|
|
35
|
-
// V8.ThisValue — 当前字段新值
|
|
36
|
-
// V8.OldValue — 仅表格行内字段事件可靠提供;普通表单读取 V8.OldForm
|
|
37
|
-
// V8.Form — 整个表单数据
|
|
38
|
-
// V8.FormMode — 'Add' / 'Edit' / 'View'
|
|
39
|
-
// V8.LoadMode — 'Design' 表示设计器中,'View' 是真实表单
|
|
40
|
-
|
|
41
|
-
// ★ 关键:设计模式下不要执行业务逻辑(防止设计器卡顿)
|
|
42
|
-
if (V8.LoadMode === 'Design') return;
|
|
43
|
-
|
|
44
|
-
// 选择部门 → 联动加载该部门下的人员到 联系人 控件
|
|
45
|
-
var deptId = V8.ThisValue && V8.ThisValue.Id;
|
|
46
|
-
if (deptId) {
|
|
47
|
-
var users = await V8.FormEngine.GetTableData('Diy_Employee', {
|
|
48
|
-
_SelectFields: ['Id', 'Name', 'Account'],
|
|
49
|
-
_Where: [['DeptId', '=', deptId]]
|
|
50
|
-
});
|
|
51
|
-
V8.FieldSet('Contact', 'Data', users.Code === 1 ? users.Data : []);
|
|
52
|
-
} else {
|
|
53
|
-
V8.FieldSet('Contact', 'Data', []);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// 联动设置另一字段值
|
|
57
|
-
V8.FormSet('CustomerName', V8.ThisValue.Name);
|
|
58
|
-
|
|
59
|
-
// 联动显隐
|
|
60
|
-
V8.FieldSet('TaxNo', 'Visible', V8.ThisValue === '企业');
|
|
61
|
-
|
|
62
|
-
// 联动必填
|
|
63
|
-
V8.FieldSet('Reason', 'Required', V8.ThisValue === '退款');
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### FieldOnKeyup — 键盘抬起事件
|
|
67
|
-
|
|
68
|
-
```javascript
|
|
69
|
-
// V8.EventName === 'FieldOnKeyup'
|
|
70
|
-
// 表格行内键盘事件为 V8.EventName === 'TableFieldOnKeyup'
|
|
71
|
-
// V8.KeyCode — 键码;当前键盘 V8 不提供原生 V8.Event
|
|
72
|
-
|
|
73
|
-
if (V8.KeyCode === 13) {
|
|
74
|
-
V8.FormSubmit({ CloseForm: false });
|
|
75
|
-
}
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### V8CodeBlur — 失焦专用代码
|
|
79
|
-
|
|
80
|
-
```javascript
|
|
81
|
-
// 当前运行时仍使用 V8.EventName === 'FieldValueChange'
|
|
82
|
-
// V8.ThisValue 是失焦时的当前输入值
|
|
83
|
-
// 失焦校验手机号
|
|
84
|
-
if (V8.ThisValue && !/^1[3-9]\d{9}$/.test(V8.ThisValue)) {
|
|
85
|
-
V8.Tips('手机号格式不正确', false);
|
|
86
|
-
V8.Form.Phone = ''; // 静默清空,避免再次触发当前字段事件
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### FieldSlotButtonClick — 单行文本插槽按钮
|
|
91
|
-
|
|
92
|
-
单行文本 `Text` 开启【插槽按钮】后,必须在【插槽按钮V8代码】中配置行为,不要再写“弹出表格Id”。
|
|
93
|
-
|
|
94
|
-
```javascript
|
|
95
|
-
// V8.EventName === 'FieldSlotButtonClick'
|
|
96
|
-
// V8.ThisValue — 当前输入框值
|
|
97
|
-
// V8.Event — 原生点击事件
|
|
98
|
-
|
|
99
|
-
if (V8.LoadMode === 'Design') return;
|
|
100
|
-
|
|
101
|
-
V8.OpenAnyTable({
|
|
102
|
-
SysMenuId: '目标业务菜单Id',
|
|
103
|
-
MultipleSelect: false,
|
|
104
|
-
SubmitEvent: function (selectData, callback) {
|
|
105
|
-
callback({ Code: 1, Data: selectData });
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
// 或 V8.OpenAnyForm / V8.OpenAppDialog / V8.ApiEngine.Run 等任意前端 V8 能力
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
`ReadOnlyButton` 的产品文案是【禁用插槽按钮】:只控制按钮是否可点击,不等同于字段只读,应保留用于权限和状态控制。
|
|
112
|
-
|
|
113
|
-
<!-- /microi-progressive:chunk -->
|
|
114
|
-
<!-- microi-progressive:chunk id=v8-frontend-events-002 sha256=faf64dbf6ded2a086c347bea31edecb7d6fc8b765114290d17998b7370d17372 -->
|
|
115
|
-
## 按钮事件
|
|
116
|
-
|
|
117
|
-
### V8BtnRun — 按钮点击执行(菜单按钮、表单按钮)
|
|
118
|
-
|
|
119
|
-
```javascript
|
|
120
|
-
// V8.Form — 当前行/表单数据
|
|
121
|
-
// V8.FormMode — Add / Edit / View
|
|
122
|
-
// V8.TableId — 当前 diy_table 的 Id
|
|
123
|
-
// V8.TableRowSelected — 批量按钮中选中的行数组
|
|
124
|
-
// V8.ClientType — 'PC' / 'IOS' / 'Android' / 'H5' / 'WeChat'
|
|
125
|
-
|
|
126
|
-
V8.ConfirmTips('确认审核通过?', function() {
|
|
127
|
-
V8.ApiEngine.Run({
|
|
128
|
-
ApiEngineKey: 'order_approve',
|
|
129
|
-
Id: V8.Form.Id
|
|
130
|
-
}, function(r) {
|
|
131
|
-
if (r.Code === 1) { V8.Tips('审核成功', true); V8.RefreshTable({ _PageIndex: 1 }); }
|
|
132
|
-
else V8.Tips(r.Msg || '失败', false);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### V8BtnLimit — 按钮显隐(V8CodeShow)
|
|
138
|
-
|
|
139
|
-
```javascript
|
|
140
|
-
// 推荐:直接 return boolean
|
|
141
|
-
return V8.Form.Status === '待审核' && V8.CurrentUser.RoleName.indexOf('审批员') !== -1;
|
|
142
|
-
|
|
143
|
-
// 兼容旧写法:V8.Result = true/false
|
|
144
|
-
// V8.Result = V8.Form.Status === '待审核';
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
`V8CodeShow` 与点击事件使用同一套前端 V8 能力,允许直接使用 `await`。平台所有
|
|
148
|
-
按钮入口(列表按钮、表单顶部按钮、更多按钮和子表打开的嵌套表单按钮)都必须走
|
|
149
|
-
异步执行器并等待结果后再决定显隐;不得在某一层退回同步 `new Function`,否则同一段
|
|
150
|
-
代码在列表可用、进入嵌套表单后会报 `await is only valid in async functions`。回归测试
|
|
151
|
-
至少覆盖“主表详情 → 定制子表 → 子记录详情”链路中的含 `await` 显隐代码。
|
|
152
|
-
|
|
153
|
-
<!-- /microi-progressive:chunk -->
|
|
154
|
-
<!-- microi-progressive:chunk id=v8-frontend-events-003 sha256=6c44ac4b3bc74f128b5efb8b7b51851ca28bdfc3e8f8b52a3d50f9fc043d4977 -->
|
|
155
|
-
## 模板引擎事件
|
|
156
|
-
|
|
157
|
-
`TableTemplateEngine` / `FormTemplateEngine` — 见 `v8-template-engine/SKILL.md`。
|
|
158
|
-
|
|
159
|
-
<!-- /microi-progressive:chunk -->
|
|
160
|
-
<!-- microi-progressive:chunk id=v8-frontend-events-004 sha256=4071ce5e92d2352e455e4dbe5310cc3d8f8c349721ad53f734397d30dc0b2c4e -->
|
|
161
|
-
## 工作流事件(前端)
|
|
162
|
-
|
|
163
|
-
`WFNodeEnd` — 流程节点结束后前端通知。详见 `v8-workflow/SKILL.md`。
|
|
164
|
-
|
|
165
|
-
<!-- /microi-progressive:chunk -->
|
|
166
|
-
<!-- microi-progressive:chunk id=v8-frontend-events-005 sha256=717095c6c96b1895cf607d787854a6f99c9ac90cc9282bdc95b5f9b4cfa4095e -->
|
|
167
|
-
## 设计模式保护(CRITICAL)
|
|
168
|
-
|
|
169
|
-
```javascript
|
|
170
|
-
// 任何前端字段事件都应在头部加这个判断!
|
|
171
|
-
if (V8.LoadMode === 'Design') return;
|
|
172
|
-
```
|
|
173
|
-
否则在【表单设计器】中编辑字段时,事件会被误触发,可能弹提示、报错或触发副作用。
|
|
174
|
-
<!-- /microi-progressive:chunk -->
|
|
175
|
-
## 详细参考路由(渐进披露)
|
|
176
|
-
|
|
177
|
-
仅在当前任务涉及对应主题时读取;下列文件合计保留了原 SKILL.md 的全部详细知识。
|
|
178
|
-
|
|
179
|
-
- [references/progressive-01-列表事件.md](references/progressive-01-列表事件.md):列表事件;常用前端 API;前端 FormEngine 菜单上下文与兼容授权;异步写法(async/await vs 回调);死循环陷阱
|
|
180
|
-
<!-- microi-progressive:end -->
|
|
1
|
+
---
|
|
2
|
+
name: v8-frontend-events
|
|
3
|
+
description: Microi 前端 V8 事件与客户端能力指南。用于编写浏览器端字段、按钮、列表事件,或使用 V8.EventName、V8.Form、V8.Print 蓝牙打印(佳博 GP-M322、ZICOX CC4、TSPL、CPCL、ESC/POS、BLE、SPP)、扫码、弹窗、表单联动和界面交互。
|
|
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
|
+
你正在为 Microi 吾码平台编写 **前端 V8 事件** 代码。前端事件运行在浏览器,通过 `V8.EventName` 区分事件类型,可访问表单/列表/弹窗等丰富的客户端 API。
|
|
11
|
+
|
|
12
|
+
> **表单生命周期事件**(InFormV8、SubmitFormV8、SubmitBeforeServerV8、SubmitAfterServerV8、OutFormV8、DataFilterV8)见 `v8-table-event/SKILL.md`。
|
|
13
|
+
> **菜单按钮事件**(MoreBtns/FormBtns 等)见 `v8-menu-buttons/SKILL.md`。
|
|
14
|
+
> 本文重点是 **字段事件、按钮事件、列表事件、模板引擎、其它前端钩子**。
|
|
15
|
+
|
|
16
|
+
<!-- microi-progressive:begin -->
|
|
17
|
+
<!-- microi-progressive:chunk id=v8-frontend-events-000 sha256=69ad0ebf0c8aca6edcbc0bbfe7e280986525bf28f68da8cb33c8efbc4509f7da -->
|
|
18
|
+
## 能力路由
|
|
19
|
+
|
|
20
|
+
- 查询前端 V8 全部上下文、导航、表单、列表、网络、引擎与工具入口时,读取 `../v8-utilities/references/client-api-index.md`。
|
|
21
|
+
- 需求包含“蓝牙打印、标签打印、TSC/TSPL、CPCL、ESC/POS、小票打印、佳博/GP-M322、ZICOX/芝柯/CC4、BLE/SPP”时,必须先读取 `references/bluetooth-print.md`;需要完整指令签名、型号转换范围、编码或位图参数时,再读取 `references/bluetooth-print-api.md`。
|
|
22
|
+
- `microi.app` 是 5+ 在线壳,不能假设存在 `uni` 或 Web Bluetooth。BLE 连接、发现和写入必须统一使用 `plus.bluetooth`,禁止用 `uni.writeBLECharacteristicValue` 写入由 `plus.bluetooth` 建立的连接。5+ `V8.Print.getConnectionState()` 的 `mtu/maxWriteBytes/recommendedPacketSize/writeType/packetIntervalMs` 描述本次连接能力。Android GP-M322 在特征支持时优先 `writeNoResponse`,即使协商出 180 字节有效载荷也只采用 100 字节连续发送稳定档,并保留约 8ms 包间保护;不支持无响应写时兼容 `write`,空 MTU 成功、失败、超时或旧壳只用 20 字节。详见蓝牙参考。
|
|
23
|
+
- 浏览器模板打印、PDF/纸张模板、`mic_print`、`PageObj`、`PrintObj` 使用 `print-engine/SKILL.md`,不要与直接蓝牙指令混为一套 API。
|
|
24
|
+
- 扫码使用 `V8.Method.ScanCode`,结果从 Promise/回调取得;`V8.ScanCodeRes` 只作兼容结果槽,详见客户端 API 索引。
|
|
25
|
+
- 登录后的敏感操作使用 `V8.Identity.Verify` 完成 Passkey/严格人脸交互;前端只取得一次性 Ticket,后端接口引擎必须重算 `ActionHash` 并原子消费,不能把前端成功当作授权。
|
|
26
|
+
|
|
27
|
+
<!-- /microi-progressive:chunk -->
|
|
28
|
+
<!-- microi-progressive:chunk id=v8-frontend-events-001 sha256=eaab87d01b0fd2b6964326ee11edd7b793899c679930c575a0a2b309d36a367a -->
|
|
29
|
+
## 字段事件(在【字段属性】中配置)
|
|
30
|
+
|
|
31
|
+
### FieldValueChange — 值变更事件(最常用)
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
// V8.EventName === 'FieldValueChange'
|
|
35
|
+
// V8.ThisValue — 当前字段新值
|
|
36
|
+
// V8.OldValue — 仅表格行内字段事件可靠提供;普通表单读取 V8.OldForm
|
|
37
|
+
// V8.Form — 整个表单数据
|
|
38
|
+
// V8.FormMode — 'Add' / 'Edit' / 'View'
|
|
39
|
+
// V8.LoadMode — 'Design' 表示设计器中,'View' 是真实表单
|
|
40
|
+
|
|
41
|
+
// ★ 关键:设计模式下不要执行业务逻辑(防止设计器卡顿)
|
|
42
|
+
if (V8.LoadMode === 'Design') return;
|
|
43
|
+
|
|
44
|
+
// 选择部门 → 联动加载该部门下的人员到 联系人 控件
|
|
45
|
+
var deptId = V8.ThisValue && V8.ThisValue.Id;
|
|
46
|
+
if (deptId) {
|
|
47
|
+
var users = await V8.FormEngine.GetTableData('Diy_Employee', {
|
|
48
|
+
_SelectFields: ['Id', 'Name', 'Account'],
|
|
49
|
+
_Where: [['DeptId', '=', deptId]]
|
|
50
|
+
});
|
|
51
|
+
V8.FieldSet('Contact', 'Data', users.Code === 1 ? users.Data : []);
|
|
52
|
+
} else {
|
|
53
|
+
V8.FieldSet('Contact', 'Data', []);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 联动设置另一字段值
|
|
57
|
+
V8.FormSet('CustomerName', V8.ThisValue.Name);
|
|
58
|
+
|
|
59
|
+
// 联动显隐
|
|
60
|
+
V8.FieldSet('TaxNo', 'Visible', V8.ThisValue === '企业');
|
|
61
|
+
|
|
62
|
+
// 联动必填
|
|
63
|
+
V8.FieldSet('Reason', 'Required', V8.ThisValue === '退款');
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### FieldOnKeyup — 键盘抬起事件
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
// V8.EventName === 'FieldOnKeyup'
|
|
70
|
+
// 表格行内键盘事件为 V8.EventName === 'TableFieldOnKeyup'
|
|
71
|
+
// V8.KeyCode — 键码;当前键盘 V8 不提供原生 V8.Event
|
|
72
|
+
|
|
73
|
+
if (V8.KeyCode === 13) {
|
|
74
|
+
V8.FormSubmit({ CloseForm: false });
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### V8CodeBlur — 失焦专用代码
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
// 当前运行时仍使用 V8.EventName === 'FieldValueChange'
|
|
82
|
+
// V8.ThisValue 是失焦时的当前输入值
|
|
83
|
+
// 失焦校验手机号
|
|
84
|
+
if (V8.ThisValue && !/^1[3-9]\d{9}$/.test(V8.ThisValue)) {
|
|
85
|
+
V8.Tips('手机号格式不正确', false);
|
|
86
|
+
V8.Form.Phone = ''; // 静默清空,避免再次触发当前字段事件
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### FieldSlotButtonClick — 单行文本插槽按钮
|
|
91
|
+
|
|
92
|
+
单行文本 `Text` 开启【插槽按钮】后,必须在【插槽按钮V8代码】中配置行为,不要再写“弹出表格Id”。
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
// V8.EventName === 'FieldSlotButtonClick'
|
|
96
|
+
// V8.ThisValue — 当前输入框值
|
|
97
|
+
// V8.Event — 原生点击事件
|
|
98
|
+
|
|
99
|
+
if (V8.LoadMode === 'Design') return;
|
|
100
|
+
|
|
101
|
+
V8.OpenAnyTable({
|
|
102
|
+
SysMenuId: '目标业务菜单Id',
|
|
103
|
+
MultipleSelect: false,
|
|
104
|
+
SubmitEvent: function (selectData, callback) {
|
|
105
|
+
callback({ Code: 1, Data: selectData });
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
// 或 V8.OpenAnyForm / V8.OpenAppDialog / V8.ApiEngine.Run 等任意前端 V8 能力
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`ReadOnlyButton` 的产品文案是【禁用插槽按钮】:只控制按钮是否可点击,不等同于字段只读,应保留用于权限和状态控制。
|
|
112
|
+
|
|
113
|
+
<!-- /microi-progressive:chunk -->
|
|
114
|
+
<!-- microi-progressive:chunk id=v8-frontend-events-002 sha256=faf64dbf6ded2a086c347bea31edecb7d6fc8b765114290d17998b7370d17372 -->
|
|
115
|
+
## 按钮事件
|
|
116
|
+
|
|
117
|
+
### V8BtnRun — 按钮点击执行(菜单按钮、表单按钮)
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
// V8.Form — 当前行/表单数据
|
|
121
|
+
// V8.FormMode — Add / Edit / View
|
|
122
|
+
// V8.TableId — 当前 diy_table 的 Id
|
|
123
|
+
// V8.TableRowSelected — 批量按钮中选中的行数组
|
|
124
|
+
// V8.ClientType — 'PC' / 'IOS' / 'Android' / 'H5' / 'WeChat'
|
|
125
|
+
|
|
126
|
+
V8.ConfirmTips('确认审核通过?', function() {
|
|
127
|
+
V8.ApiEngine.Run({
|
|
128
|
+
ApiEngineKey: 'order_approve',
|
|
129
|
+
Id: V8.Form.Id
|
|
130
|
+
}, function(r) {
|
|
131
|
+
if (r.Code === 1) { V8.Tips('审核成功', true); V8.RefreshTable({ _PageIndex: 1 }); }
|
|
132
|
+
else V8.Tips(r.Msg || '失败', false);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### V8BtnLimit — 按钮显隐(V8CodeShow)
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
// 推荐:直接 return boolean
|
|
141
|
+
return V8.Form.Status === '待审核' && V8.CurrentUser.RoleName.indexOf('审批员') !== -1;
|
|
142
|
+
|
|
143
|
+
// 兼容旧写法:V8.Result = true/false
|
|
144
|
+
// V8.Result = V8.Form.Status === '待审核';
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
`V8CodeShow` 与点击事件使用同一套前端 V8 能力,允许直接使用 `await`。平台所有
|
|
148
|
+
按钮入口(列表按钮、表单顶部按钮、更多按钮和子表打开的嵌套表单按钮)都必须走
|
|
149
|
+
异步执行器并等待结果后再决定显隐;不得在某一层退回同步 `new Function`,否则同一段
|
|
150
|
+
代码在列表可用、进入嵌套表单后会报 `await is only valid in async functions`。回归测试
|
|
151
|
+
至少覆盖“主表详情 → 定制子表 → 子记录详情”链路中的含 `await` 显隐代码。
|
|
152
|
+
|
|
153
|
+
<!-- /microi-progressive:chunk -->
|
|
154
|
+
<!-- microi-progressive:chunk id=v8-frontend-events-003 sha256=6c44ac4b3bc74f128b5efb8b7b51851ca28bdfc3e8f8b52a3d50f9fc043d4977 -->
|
|
155
|
+
## 模板引擎事件
|
|
156
|
+
|
|
157
|
+
`TableTemplateEngine` / `FormTemplateEngine` — 见 `v8-template-engine/SKILL.md`。
|
|
158
|
+
|
|
159
|
+
<!-- /microi-progressive:chunk -->
|
|
160
|
+
<!-- microi-progressive:chunk id=v8-frontend-events-004 sha256=4071ce5e92d2352e455e4dbe5310cc3d8f8c349721ad53f734397d30dc0b2c4e -->
|
|
161
|
+
## 工作流事件(前端)
|
|
162
|
+
|
|
163
|
+
`WFNodeEnd` — 流程节点结束后前端通知。详见 `v8-workflow/SKILL.md`。
|
|
164
|
+
|
|
165
|
+
<!-- /microi-progressive:chunk -->
|
|
166
|
+
<!-- microi-progressive:chunk id=v8-frontend-events-005 sha256=717095c6c96b1895cf607d787854a6f99c9ac90cc9282bdc95b5f9b4cfa4095e -->
|
|
167
|
+
## 设计模式保护(CRITICAL)
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
// 任何前端字段事件都应在头部加这个判断!
|
|
171
|
+
if (V8.LoadMode === 'Design') return;
|
|
172
|
+
```
|
|
173
|
+
否则在【表单设计器】中编辑字段时,事件会被误触发,可能弹提示、报错或触发副作用。
|
|
174
|
+
<!-- /microi-progressive:chunk -->
|
|
175
|
+
## 详细参考路由(渐进披露)
|
|
176
|
+
|
|
177
|
+
仅在当前任务涉及对应主题时读取;下列文件合计保留了原 SKILL.md 的全部详细知识。
|
|
178
|
+
|
|
179
|
+
- [references/progressive-01-列表事件.md](references/progressive-01-列表事件.md):列表事件;常用前端 API;前端 FormEngine 菜单上下文与兼容授权;异步写法(async/await vs 回调);死循环陷阱
|
|
180
|
+
<!-- microi-progressive:end -->
|
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
# V8.Print TSC、CPCL 适配与 ESC/POS 源码 API
|
|
2
|
-
|
|
3
|
-
本表直接按 `Microi.Client/src/utils/ble/tsc.js`、`esc.js`、
|
|
4
|
-
`printer-compatibility.js` 与编码文件整理。方法名
|
|
5
|
-
(包括历史拼写)必须与源码完全一致,不能根据打印机手册自行改名。
|
|
6
|
-
|
|
7
|
-
## 目录
|
|
8
|
-
|
|
9
|
-
- [构建器与编码](#构建器与编码)
|
|
10
|
-
- [TSC/TSPL 的 28 个方法](#tsctspl-的-28-个方法)
|
|
11
|
-
- [ZICOX CC4 的 CPCL 映射](#zicox-cc4-的-cpcl-映射)
|
|
12
|
-
- [ESC/POS 的 25 个方法](#escpos-的-25-个方法)
|
|
13
|
-
- [参数与组合规则](#参数与组合规则)
|
|
14
|
-
|
|
15
|
-
## 构建器与编码
|
|
16
|
-
|
|
17
|
-
```javascript
|
|
18
|
-
var tsc = V8.Print.createNew();
|
|
19
|
-
var esc = V8.Print.createNewESC();
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
两个构建器都把指令累积到普通字节数组,`getData()` 返回该数组。TSC 返回值还带不可枚举
|
|
23
|
-
协议/操作元数据:普通遍历与 GP-M322 字节值不变,CC4 发送前据此生成 CPCL。不要复制或
|
|
24
|
-
序列化 TSC 数组后再交给 `prepareSend`。TSC 的全部文本命令、
|
|
25
|
-
ESC 的 `setText` 和二维码内容通过本地 `TextEncoder('gb18030', {
|
|
26
|
-
NONSTANDARD_allowLegacyEncoding: true })` 编码;映射表来自同目录的
|
|
27
|
-
`encoding-indexes.js`,不需要网络请求。
|
|
28
|
-
|
|
29
|
-
## TSC/TSPL 的 28 个方法
|
|
30
|
-
|
|
31
|
-
| 方法 | 当前生成的指令/作用 |
|
|
32
|
-
|---|---|
|
|
33
|
-
| `init()` | 空操作,历史兼容入口 |
|
|
34
|
-
| `addCommand(content)` | 以 GB18030 追加原始 TSC 文本;只用于固定可信命令 |
|
|
35
|
-
| `setSize(width,height)` | `SIZE width mm,height mm` |
|
|
36
|
-
| `setSpeed(speed)` | `SPEED speed` |
|
|
37
|
-
| `setDensity(density)` | `DENSITY density` |
|
|
38
|
-
| `setGap(gap)` | `GAP gap mm,0 mm` |
|
|
39
|
-
| `setBline(bline)` | `BLINE bline mm,0 mm`,黑标纸 |
|
|
40
|
-
| `setCountry(country)` | `COUNTRY country` |
|
|
41
|
-
| `setCodepage(codepage)` | `CODEPAGE codepage` |
|
|
42
|
-
| `setCls()` | `CLS`,清除图像缓冲区 |
|
|
43
|
-
| `setFeed(feed)` | `FEED feed`,向前走纸 |
|
|
44
|
-
| `setBackFeed(backup)` | `BACKFEED backup`,回拉 |
|
|
45
|
-
| `setDirection(direction)` | `DIRECTION direction` |
|
|
46
|
-
| `setReference(x,y)` | `REFERENCE x,y`,坐标原点 |
|
|
47
|
-
| `setFromfeed()` | 注意源码拼写;实际生成 `FORMFEED` |
|
|
48
|
-
| `setHome()` | `HOME`,定位下一张标签 |
|
|
49
|
-
| `setSound(level,interval)` | `SOUND level,interval` |
|
|
50
|
-
| `setLimitfeed(limit)` | `LIMITFEED limit` |
|
|
51
|
-
| `setBar(x,y,width,height)` | `BAR` 线条 |
|
|
52
|
-
| `setBox(x1,y1,x2,y2,thickness)` | `BOX` 方框 |
|
|
53
|
-
| `setErase(x,y,width,height)` | `ERASE` 清除区域 |
|
|
54
|
-
| `setReverse(x,y,width,height)` | `REVERSE` 区域反相 |
|
|
55
|
-
| `setText(x,y,font,xScale,yScale,text)` | `TEXT`;旋转值在源码中固定为 `0` |
|
|
56
|
-
| `setQR(x,y,level,width,mode,content)` | `QRCODE`;旋转值固定为 `0` |
|
|
57
|
-
| `setBarCode(x,y,type,height,readable,narrow,wide,content)` | `BARCODE`;旋转值固定为 `0` |
|
|
58
|
-
| `setBitmap(x,y,mode,imageData)` | 生成 TSC `BITMAP` 二进制数据 |
|
|
59
|
-
| `setPagePrint()` | `PRINT 1,1` |
|
|
60
|
-
| `getData()` | 返回当前字节数组 |
|
|
61
|
-
|
|
62
|
-
最小顺序通常是 `setSize` → `setGap`/`setBline` → `setCls` → 内容 →
|
|
63
|
-
`setPagePrint` → `getData`。字体名、条码类型、纸张传感器、速度和浓度由打印机固件决定,
|
|
64
|
-
构建器不验证范围。
|
|
65
|
-
|
|
66
|
-
## ZICOX CC4 的 CPCL 映射
|
|
67
|
-
|
|
68
|
-
| TSC 方法 | CC4 CPCL 结果 |
|
|
69
|
-
|---|---|
|
|
70
|
-
| `setSize(w,h)` | 203 dpi 下按 `8 dots/mm` 生成页宽/页高 |
|
|
71
|
-
| `setSpeed` / `setDensity` | `SPEED` / `CONTRAST`,钳制到当前安全范围 |
|
|
72
|
-
| `setGap` / `setBline` | `GAP-SENSE` / `BAR-SENSE` |
|
|
73
|
-
| `setFeed` / `setBackFeed` | `POSTFEED` / `PREFEED` |
|
|
74
|
-
| `setDirection(0/1)` | `ZPROTATE` / `ZPROTATE180` |
|
|
75
|
-
| `setReference` | 转换坐标时叠加参考点 |
|
|
76
|
-
| `setBar` / `setBox` / `setReverse` | `LINE` / `BOX` / `INVERSE-LINE` |
|
|
77
|
-
| `setText` | `SETMAG` + `T`,字体名按 16/24/32 档映射 |
|
|
78
|
-
| `setBarCode` | `BARCODE`,可选 `BARCODE-TEXT` |
|
|
79
|
-
| `setQR` | 厂家 SDK 格式 `BARCODE QR ...` + 数据 + `ENDQR` |
|
|
80
|
-
| `setBitmap` | `CG` + 原始单色位图字节 |
|
|
81
|
-
| `setPagePrint` | 最终统一补 `FORM` + `PRINT`,每份必须恰好一次 |
|
|
82
|
-
|
|
83
|
-
`init`、`setCls` 不输出。`addCommand`、`setCountry`、`setCodepage`、`setFromfeed`、
|
|
84
|
-
`setHome`、`setSound`、`setLimitfeed`、`setErase` 与未知方法会抛错,并且适配发生在分包前,
|
|
85
|
-
所以失败时不得写入任何一包。该白名单只表达当前有证据的等价转换,不代表 CC4 固件不具备
|
|
86
|
-
其它 CPCL 能力。
|
|
87
|
-
|
|
88
|
-
`createNewESC()` 的数组标记为 ESC/POS,CC4 直接原样发送,不进入 CPCL 转换。
|
|
89
|
-
|
|
90
|
-
## ESC/POS 的 25 个方法
|
|
91
|
-
|
|
92
|
-
| 方法 | 当前生成的指令/作用 |
|
|
93
|
-
|---|---|
|
|
94
|
-
| `init()` | ESC `@` 初始化 |
|
|
95
|
-
| `setText(content)` | 以 GB18030 追加文字 |
|
|
96
|
-
| `setFontSize(n)` | GS `! n` |
|
|
97
|
-
| `bold(n)` | ESC `E n` |
|
|
98
|
-
| `setUnderline(n)` | ESC `- n` |
|
|
99
|
-
| `setUnderline2(n)` | FS `- n` |
|
|
100
|
-
| `setSelectSizeOfModuleForQRCode(n)` | 设置二维码模块尺寸,源码钳制到 1–15 |
|
|
101
|
-
| `setSelectErrorCorrectionLevelForQRCode(n)` | 设置二维码纠错值,源码不验证范围 |
|
|
102
|
-
| `setStoreQRCodeData(content)` | 以 GB18030 暂存二维码内容 |
|
|
103
|
-
| `setPrintQRCode()` | 输出已暂存二维码 |
|
|
104
|
-
| `setHorTab()` | 水平 Tab |
|
|
105
|
-
| `setAbsolutePrintPosition(where)` | 设置绝对横向位置 |
|
|
106
|
-
| `setRelativePrintPositon(where)` | 设置相对横向位置;`Positon` 是现有公开拼写 |
|
|
107
|
-
| `setSelectJustification(which)` | 对齐:常见值 0 左、1 中、2 右 |
|
|
108
|
-
| `space(n)` | 设置水平制表位置 |
|
|
109
|
-
| `setLeftMargin(n)` | 设置左边距 |
|
|
110
|
-
| `textMarginRight(n)` | 设置字符右间距 |
|
|
111
|
-
| `rowSpace(n)` | 设置行间距 |
|
|
112
|
-
| `setPrintingAreaWidth(width)` | 设置打印区域宽度 |
|
|
113
|
-
| `setSound(n,t)` | 蜂鸣器;大于 9 钳制为 9,小于 0 改为 1,0 会原样保留 |
|
|
114
|
-
| `setBitmap(imageData)` | 生成 ESC/POS 光栅位图数据 |
|
|
115
|
-
| `setPrint()` | 换行/打印当前行 |
|
|
116
|
-
| `setPrintAndFeed(feed)` | 打印并走纸指定单位 |
|
|
117
|
-
| `setPrintAndFeedRow(row)` | 打印并走纸指定行数 |
|
|
118
|
-
| `getData()` | 返回当前字节数组 |
|
|
119
|
-
|
|
120
|
-
ESC/POS 二维码需要按顺序调用尺寸、纠错、`setStoreQRCodeData`、
|
|
121
|
-
`setPrintQRCode`。源码中虽保留条码类型数组,但没有公开 ESC/POS 条码方法,不能虚构
|
|
122
|
-
`setBarCode`;条码需求应先确认型号并扩展实现。
|
|
123
|
-
|
|
124
|
-
## 参数与组合规则
|
|
125
|
-
|
|
126
|
-
- `setBitmap` 的参数是 ImageData 风格对象:`width`、`height`、RGBA `data`。它不是图片
|
|
127
|
-
URL、Base64 或 DOM `<img>`;调用前先在 Canvas 得到 `getImageData()`。
|
|
128
|
-
- 当前位图算法按透明/非透明像素进行非常简单的黑白映射,不做通用抖动和灰度阈值处理;
|
|
129
|
-
大图先缩放、二值化,逐型号验证方向、颜色和内存。
|
|
130
|
-
- TSC `setText`、`setQR`、`setBarCode` 把值放入带双引号的协议字段。移除双引号、CR/LF、
|
|
131
|
-
NUL 和控制字符,限制长度;不要让接口返回值直达 `addCommand`。
|
|
132
|
-
- ESC 参数最终作为单字节或低/高字节写入,负数、浮点数、超范围值可能截断或生成无效命令。
|
|
133
|
-
坐标、宽度、走纸、字号和蜂鸣器参数应先转为目标机型允许的整数。
|
|
134
|
-
- GB18030 只解决字节编码,不能替代打印机代码页、中文字库和字体配置。二维码通常比文字
|
|
135
|
-
字库更能稳定承载 Unicode 业务标识,但仍受打印机二维码命令实现限制。
|
|
1
|
+
# V8.Print TSC、CPCL 适配与 ESC/POS 源码 API
|
|
2
|
+
|
|
3
|
+
本表直接按 `Microi.Client/src/utils/ble/tsc.js`、`esc.js`、
|
|
4
|
+
`printer-compatibility.js` 与编码文件整理。方法名
|
|
5
|
+
(包括历史拼写)必须与源码完全一致,不能根据打印机手册自行改名。
|
|
6
|
+
|
|
7
|
+
## 目录
|
|
8
|
+
|
|
9
|
+
- [构建器与编码](#构建器与编码)
|
|
10
|
+
- [TSC/TSPL 的 28 个方法](#tsctspl-的-28-个方法)
|
|
11
|
+
- [ZICOX CC4 的 CPCL 映射](#zicox-cc4-的-cpcl-映射)
|
|
12
|
+
- [ESC/POS 的 25 个方法](#escpos-的-25-个方法)
|
|
13
|
+
- [参数与组合规则](#参数与组合规则)
|
|
14
|
+
|
|
15
|
+
## 构建器与编码
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
var tsc = V8.Print.createNew();
|
|
19
|
+
var esc = V8.Print.createNewESC();
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
两个构建器都把指令累积到普通字节数组,`getData()` 返回该数组。TSC 返回值还带不可枚举
|
|
23
|
+
协议/操作元数据:普通遍历与 GP-M322 字节值不变,CC4 发送前据此生成 CPCL。不要复制或
|
|
24
|
+
序列化 TSC 数组后再交给 `prepareSend`。TSC 的全部文本命令、
|
|
25
|
+
ESC 的 `setText` 和二维码内容通过本地 `TextEncoder('gb18030', {
|
|
26
|
+
NONSTANDARD_allowLegacyEncoding: true })` 编码;映射表来自同目录的
|
|
27
|
+
`encoding-indexes.js`,不需要网络请求。
|
|
28
|
+
|
|
29
|
+
## TSC/TSPL 的 28 个方法
|
|
30
|
+
|
|
31
|
+
| 方法 | 当前生成的指令/作用 |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `init()` | 空操作,历史兼容入口 |
|
|
34
|
+
| `addCommand(content)` | 以 GB18030 追加原始 TSC 文本;只用于固定可信命令 |
|
|
35
|
+
| `setSize(width,height)` | `SIZE width mm,height mm` |
|
|
36
|
+
| `setSpeed(speed)` | `SPEED speed` |
|
|
37
|
+
| `setDensity(density)` | `DENSITY density` |
|
|
38
|
+
| `setGap(gap)` | `GAP gap mm,0 mm` |
|
|
39
|
+
| `setBline(bline)` | `BLINE bline mm,0 mm`,黑标纸 |
|
|
40
|
+
| `setCountry(country)` | `COUNTRY country` |
|
|
41
|
+
| `setCodepage(codepage)` | `CODEPAGE codepage` |
|
|
42
|
+
| `setCls()` | `CLS`,清除图像缓冲区 |
|
|
43
|
+
| `setFeed(feed)` | `FEED feed`,向前走纸 |
|
|
44
|
+
| `setBackFeed(backup)` | `BACKFEED backup`,回拉 |
|
|
45
|
+
| `setDirection(direction)` | `DIRECTION direction` |
|
|
46
|
+
| `setReference(x,y)` | `REFERENCE x,y`,坐标原点 |
|
|
47
|
+
| `setFromfeed()` | 注意源码拼写;实际生成 `FORMFEED` |
|
|
48
|
+
| `setHome()` | `HOME`,定位下一张标签 |
|
|
49
|
+
| `setSound(level,interval)` | `SOUND level,interval` |
|
|
50
|
+
| `setLimitfeed(limit)` | `LIMITFEED limit` |
|
|
51
|
+
| `setBar(x,y,width,height)` | `BAR` 线条 |
|
|
52
|
+
| `setBox(x1,y1,x2,y2,thickness)` | `BOX` 方框 |
|
|
53
|
+
| `setErase(x,y,width,height)` | `ERASE` 清除区域 |
|
|
54
|
+
| `setReverse(x,y,width,height)` | `REVERSE` 区域反相 |
|
|
55
|
+
| `setText(x,y,font,xScale,yScale,text)` | `TEXT`;旋转值在源码中固定为 `0` |
|
|
56
|
+
| `setQR(x,y,level,width,mode,content)` | `QRCODE`;旋转值固定为 `0` |
|
|
57
|
+
| `setBarCode(x,y,type,height,readable,narrow,wide,content)` | `BARCODE`;旋转值固定为 `0` |
|
|
58
|
+
| `setBitmap(x,y,mode,imageData)` | 生成 TSC `BITMAP` 二进制数据 |
|
|
59
|
+
| `setPagePrint()` | `PRINT 1,1` |
|
|
60
|
+
| `getData()` | 返回当前字节数组 |
|
|
61
|
+
|
|
62
|
+
最小顺序通常是 `setSize` → `setGap`/`setBline` → `setCls` → 内容 →
|
|
63
|
+
`setPagePrint` → `getData`。字体名、条码类型、纸张传感器、速度和浓度由打印机固件决定,
|
|
64
|
+
构建器不验证范围。
|
|
65
|
+
|
|
66
|
+
## ZICOX CC4 的 CPCL 映射
|
|
67
|
+
|
|
68
|
+
| TSC 方法 | CC4 CPCL 结果 |
|
|
69
|
+
|---|---|
|
|
70
|
+
| `setSize(w,h)` | 203 dpi 下按 `8 dots/mm` 生成页宽/页高 |
|
|
71
|
+
| `setSpeed` / `setDensity` | `SPEED` / `CONTRAST`,钳制到当前安全范围 |
|
|
72
|
+
| `setGap` / `setBline` | `GAP-SENSE` / `BAR-SENSE` |
|
|
73
|
+
| `setFeed` / `setBackFeed` | `POSTFEED` / `PREFEED` |
|
|
74
|
+
| `setDirection(0/1)` | `ZPROTATE` / `ZPROTATE180` |
|
|
75
|
+
| `setReference` | 转换坐标时叠加参考点 |
|
|
76
|
+
| `setBar` / `setBox` / `setReverse` | `LINE` / `BOX` / `INVERSE-LINE` |
|
|
77
|
+
| `setText` | `SETMAG` + `T`,字体名按 16/24/32 档映射 |
|
|
78
|
+
| `setBarCode` | `BARCODE`,可选 `BARCODE-TEXT` |
|
|
79
|
+
| `setQR` | 厂家 SDK 格式 `BARCODE QR ...` + 数据 + `ENDQR` |
|
|
80
|
+
| `setBitmap` | `CG` + 原始单色位图字节 |
|
|
81
|
+
| `setPagePrint` | 最终统一补 `FORM` + `PRINT`,每份必须恰好一次 |
|
|
82
|
+
|
|
83
|
+
`init`、`setCls` 不输出。`addCommand`、`setCountry`、`setCodepage`、`setFromfeed`、
|
|
84
|
+
`setHome`、`setSound`、`setLimitfeed`、`setErase` 与未知方法会抛错,并且适配发生在分包前,
|
|
85
|
+
所以失败时不得写入任何一包。该白名单只表达当前有证据的等价转换,不代表 CC4 固件不具备
|
|
86
|
+
其它 CPCL 能力。
|
|
87
|
+
|
|
88
|
+
`createNewESC()` 的数组标记为 ESC/POS,CC4 直接原样发送,不进入 CPCL 转换。
|
|
89
|
+
|
|
90
|
+
## ESC/POS 的 25 个方法
|
|
91
|
+
|
|
92
|
+
| 方法 | 当前生成的指令/作用 |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `init()` | ESC `@` 初始化 |
|
|
95
|
+
| `setText(content)` | 以 GB18030 追加文字 |
|
|
96
|
+
| `setFontSize(n)` | GS `! n` |
|
|
97
|
+
| `bold(n)` | ESC `E n` |
|
|
98
|
+
| `setUnderline(n)` | ESC `- n` |
|
|
99
|
+
| `setUnderline2(n)` | FS `- n` |
|
|
100
|
+
| `setSelectSizeOfModuleForQRCode(n)` | 设置二维码模块尺寸,源码钳制到 1–15 |
|
|
101
|
+
| `setSelectErrorCorrectionLevelForQRCode(n)` | 设置二维码纠错值,源码不验证范围 |
|
|
102
|
+
| `setStoreQRCodeData(content)` | 以 GB18030 暂存二维码内容 |
|
|
103
|
+
| `setPrintQRCode()` | 输出已暂存二维码 |
|
|
104
|
+
| `setHorTab()` | 水平 Tab |
|
|
105
|
+
| `setAbsolutePrintPosition(where)` | 设置绝对横向位置 |
|
|
106
|
+
| `setRelativePrintPositon(where)` | 设置相对横向位置;`Positon` 是现有公开拼写 |
|
|
107
|
+
| `setSelectJustification(which)` | 对齐:常见值 0 左、1 中、2 右 |
|
|
108
|
+
| `space(n)` | 设置水平制表位置 |
|
|
109
|
+
| `setLeftMargin(n)` | 设置左边距 |
|
|
110
|
+
| `textMarginRight(n)` | 设置字符右间距 |
|
|
111
|
+
| `rowSpace(n)` | 设置行间距 |
|
|
112
|
+
| `setPrintingAreaWidth(width)` | 设置打印区域宽度 |
|
|
113
|
+
| `setSound(n,t)` | 蜂鸣器;大于 9 钳制为 9,小于 0 改为 1,0 会原样保留 |
|
|
114
|
+
| `setBitmap(imageData)` | 生成 ESC/POS 光栅位图数据 |
|
|
115
|
+
| `setPrint()` | 换行/打印当前行 |
|
|
116
|
+
| `setPrintAndFeed(feed)` | 打印并走纸指定单位 |
|
|
117
|
+
| `setPrintAndFeedRow(row)` | 打印并走纸指定行数 |
|
|
118
|
+
| `getData()` | 返回当前字节数组 |
|
|
119
|
+
|
|
120
|
+
ESC/POS 二维码需要按顺序调用尺寸、纠错、`setStoreQRCodeData`、
|
|
121
|
+
`setPrintQRCode`。源码中虽保留条码类型数组,但没有公开 ESC/POS 条码方法,不能虚构
|
|
122
|
+
`setBarCode`;条码需求应先确认型号并扩展实现。
|
|
123
|
+
|
|
124
|
+
## 参数与组合规则
|
|
125
|
+
|
|
126
|
+
- `setBitmap` 的参数是 ImageData 风格对象:`width`、`height`、RGBA `data`。它不是图片
|
|
127
|
+
URL、Base64 或 DOM `<img>`;调用前先在 Canvas 得到 `getImageData()`。
|
|
128
|
+
- 当前位图算法按透明/非透明像素进行非常简单的黑白映射,不做通用抖动和灰度阈值处理;
|
|
129
|
+
大图先缩放、二值化,逐型号验证方向、颜色和内存。
|
|
130
|
+
- TSC `setText`、`setQR`、`setBarCode` 把值放入带双引号的协议字段。移除双引号、CR/LF、
|
|
131
|
+
NUL 和控制字符,限制长度;不要让接口返回值直达 `addCommand`。
|
|
132
|
+
- ESC 参数最终作为单字节或低/高字节写入,负数、浮点数、超范围值可能截断或生成无效命令。
|
|
133
|
+
坐标、宽度、走纸、字号和蜂鸣器参数应先转为目标机型允许的整数。
|
|
134
|
+
- GB18030 只解决字节编码,不能替代打印机代码页、中文字库和字体配置。二维码通常比文字
|
|
135
|
+
字库更能稳定承载 Unicode 业务标识,但仍受打印机二维码命令实现限制。
|