跳到主要内容

Sample 合同 · AUP 跨设备 · ARC 2.0.0-beta.28

`action` primitive

声明按钮或导航 action,不在 document target 上承诺 exec。

action 是 AUP 跨设备 primitive,不是 Web Device 的 layout 组件,也不是 Web-only widget。它属于 AUP_PRIMITIVES 中的 18 个名称之一,并出现在每个 target 的 DeviceCaps.primitives map 中(取值为 native、webview、partial 或 unsupported)。

合同

字段值
Primitive 名称action
层级AUP 跨设备 primitive(AUP_PRIMITIVES)
公共状态released
Document 能力native
共享 degradation chain无(document 报告 native)
作者入口AUP tree · Markdown ::action(常嵌在 action-card 内)· DSL
Document renderer / 备注renderer/primitives/action.ts(safeHref);cards 会合成 action 节点
Showcase 证据form / portal 页;document cards 路径见 markdown 单元页

何时使用

需要带标签的操作:导航 href,或(在交互 target 上)events.click / exec。

何时不要使用

在公开 docs 上使用仅导航 action。不要从静态 document sample 承诺 AFS exec 或破坏性确认。

Sample 合同

字段值
目的document 上仅导航的 action
边界无 exec、无 AFS 写入、无 session
作者入口::action{…}
表面Web Device document
公共状态released
Fallback / 失败不安全 href scheme 被拒绝;缺 href → 非链接 span/button chrome
验证下方路由 · arc --version = 2.0.0-beta.28

Document sample(导航 action)

本示例放置普通导航 href,无 event、exec 或数据写入。

源码:

markdown
::action{label="Open live example contract" href="/en/docs/aup/live-example-contract/" variant="primary"}

渲染:

Open live example contract

无 href 的标签

源码:

markdown
::action{label="Label only — not a navigation target" variant="secondary"}

渲染:

Label only — not a navigation target

卡片组合:action-card。

失败与限制

情形预期结果
javascript: / data: href被 safeHref 拒绝;不是可点击的特权链接
缺 href非链接呈现(无导航的 span / button 路径)
期望 exec 或 AFS 写入超出静态 document sample 合同
嵌在 action-card 内除非另证交互 runtime,否则仍仅导航

验证证据

项值
基线2026-08-09 · arc --version → 2.0.0-beta.28
能力行docs/aup/capability-matrix.md(内部,不对外路由)· action
实现content-reader.ts(通用 ::action);renderer/primitives/action.ts(safeHref)
公开路由/en/docs/aup/primitives/action/ · /zh/docs/aup/primitives/action/
本地运行arc service start --blocklet blocklets/arcblock --port 4900 · 点击导航 action → 仅普通导航
接受标准primary action 导航;仅标签 action 非特权写入;无 exec

证据锚点

项值
注册表packages/aup/src/aup-types.ts · AUP_PRIMITIVES
Document capsproviders/runtime/web-device/src/device-caps.ts · DEVICE_CAPS_DOCUMENT
Degradationpackages/aup/src/degradation.ts · DEGRADATION_CHAINS
内部矩阵docs/aup/capability-matrix.md(内部,不对外路由)
Taxonomy hubPrimitive 类型分类与证据
Sample 合同规则Live 示例:范围与合同

相关页面