这套接口是为了让 AI 直接操作画布:生成图 → 推进来 → 建跳转 → 人只需要看和改。 人也能用同一套接口,但主要入口是 AI。
接口不需要任何凭证,知道地址就能调。
层级是三层:项目 → 页面 → 容器。
一个产品的整套原型。{ id, name, pages[] }
一张画布,装容器和连线。{ id, name, screens[], links[] }
见下面两张卡。
页面里只有两种对象:
唯一能画出来的对象。有名字、坐标、宽高、父容器、背景色、圆角。
图片是它的背景层,不是独立对象。
{ id, from, to } —— 两个容器 id 就能画一条线。
播放时点 from 就跳到 to。
x/y 相对父容器。世界坐标 = 自身 + 所有祖先。| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 服务端分配。保存时不要改,连线靠它。 |
name | string | 容器名字。导入时可以用名字当连线端点。 |
img | string | 图片 URL。空字符串 = 空容器。 |
imgName | string | 图片层的名字,可改。 |
bg | string | null | 背景色 #RRGGBB。空 = 透明(或有图时由图片盖住)。 |
radius | number | 圆角 px。圆角外的内容(图片、子容器)会被裁掉。 |
x / y | number | 相对父容器的坐标;没有父容器时就是世界坐标。 |
w / h | number | 宽高,最小 20。 |
z | number | 叠放顺序,越大越靠前。 |
parentId | string | null | 父容器 id。坐标跟着父容器走。 |
ratioLocked | boolean | 锁宽高比。 |
hit | boolean | 透明点击区域:不显示轮廓,但能被点中。 |
/api/proto/schema机器可读的完整说明。AI 建议先读这个,再动手。{ version, model: { container, link, behavior }, endpoints, example_import }/api/proto/upload传一张图,返回可用的 URL。AI 生成的图必须先传这里。{ "dataUrl": "data:image/png;base64,iVBORw0KGgo..." }{ "url": "/api/proto/file/b2bbe763c7e1828c.png", "bytes": 12345, "mime": "image/png" }/api/proto/usage查上传空间占用(默认 200MB,超了上传会 413){ "usedBytes": 5242880, "quotaBytes": 209715200, "usedMB": 5, "quotaMB": 200, "percent": 2.5, "full": false }/api/proto新建项目(自动带一个空页面){ "name": "Meetly" }{ "id": "p-1762...", "name": "Meetly", "pages": [ { "id": "pg1", "name": "页面 1", "screens": [], "links": [] } ] }/api/proto列出全部项目{ "list": [ { "id": "meetly", "name": "Meetly 原型", "screens": 83, "updatedAt": 1762... } ] }/api/proto/:id读一个项目(含全部页面、容器、连线){
"id": "meetly", "name": "Meetly 原型", "updatedAt": 1762...,
"nextId": 84,
"screens": [
{ "id": "7", "name": "07 首页推荐", "img": "/proto/meetly/s07.png",
"imgName": "图片", "bg": null, "radius": 0,
"x": 0, "y": 880, "w": 360, "h": 780, "z": 7,
"parentId": null, "ratioLocked": false },
{ "id": "42", "name": "匹配成功", "img": "", "x": 210, "y": 640,
"w": 100, "h": 90, "parentId": "7", "hit": true }
],
"links": [ { "id": "L1", "from": "42", "to": "17" } ]
}/api/proto/:id整份保存项目。改完读出来的对象,原样 POST 回去即可。完整的 ProtoDoc(结构同 GET 返回)
{ "id": "meetly", "updatedAt": 1762... }/api/proto/:id删除一份原型{ "ok": 1 }/api/proto/import批量导入:新建一个项目(含一个页面),建容器 + 连线{
"name": "示例原型", "cols": 6,
"screens": [
{ "name": "01 启动页", "img": "https://…/s01.png",
"links": [ { "to": "02 登录" } ] },
{ "name": "02 登录", "img": "https://…/s02.png",
"children": [
{ "name": "登录按钮", "x": 36, "y": 620, "w": 288, "h": 48,
"links": [ { "to": "03 基础资料" } ] }
] },
{ "name": "03 基础资料", "img": "https://…/s03.png" }
]
}{ "id": "proto-1762...", "screens": [...], "links": [...] }POST /api/proto/upload,拿到 url(也可以直接用 OSS 外链)POST /api/proto/import,每张图一个屏幕,跳转写目标的名字curl -X POST http://localhost:3020/api/proto/import \
-H 'content-type: application/json' \
-d '{
"name": "Meetly 原型",
"cols": 6,
"screens": [
{ "name": "01 启动页", "img": "https://…/s01.png",
"links": [ { "to": "02 登录" } ] },
{ "name": "02 登录", "img": "https://…/s02.png",
"children": [
{ "name": "登录按钮", "x": 36, "y": 620, "w": 288, "h": 48,
"links": [ { "to": "03 基础资料" } ] }
] },
{ "name": "03 基础资料", "img": "https://…/s03.png" }
]
}'GET /api/proto/meetly 拿到整份screens 里加一个 parentId 指向目标页、hit: true 的小容器links 里加 { id: 'L100', from: '新容器id', to: '目标页id' }POST /api/proto/meetly 整份存回读出来改 bg / radius / w / h,再整份存回即可。同一份文档不要并发写。
改 x / y 就行。父容器的坐标变了,子容器跟着走,不用一个个改。
import 里的 to 写目标容器名字,名字必须唯一,解析不到就不建线(不报错)。object-fit: cover 裁切。/api/proto/upload 返回 413,不会偷偷写盘。同一张图(内容哈希相同)重复传不占额外空间。