Web 端数据交互与 design2 布局修复
统一门户 JSON 契约:新增 GET /templates/{id},模板/云文件/保存/打开走虚拟 key;
layer 保存弹层替代 prompt,本地 .soon 已登录后台 POST 登记;修复保存静默失败与 design2 全宽布局。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+36
-3
@@ -162,13 +162,45 @@ GET /api/v1/pay/orders?page=1&size=8
|
||||
| 路径 | 形态 |
|
||||
|------|------|
|
||||
| `GET /api/v1/plans` | `{ items: [...] }` 全量活跃套餐 |
|
||||
| `GET /api/v1/plans/me` | 会员信息 + `recent_orders`(默认 8 条,非翻页) |
|
||||
| `GET /api/v1/auth/me` | 当前用户 + 会员摘要(`is_member` / `tier` / `name`) |
|
||||
| `GET /api/v1/plans/me` | 完整会员配额信息(云端用量等,按需调用) |
|
||||
| `GET /api/v1/settings` | 扁平 key-value 对象,非 `items` 数组 |
|
||||
| `GET /api/v1/templates` | 首页模板列表(仅 `id/name/type`;缩略图与文件按需拉取) |
|
||||
| `GET /api/v1/templates` | 首页模板列表(仅 `id/name/type/updated_at`;缩略图按需拉取) |
|
||||
| `GET /api/v1/templates/{id}` | 模板 JSON 数据(门户标准读取端点,见下) |
|
||||
| `GET /api/v1/templates/{id}/thumb` | 模板缩略图(从 `.soon` 内 `frontDisplayPic` 提取) |
|
||||
| `GET /api/v1/templates/{id}/file` | 完整 `.soon` JSON(点击使用时再下载) |
|
||||
| `GET /api/v1/templates/{id}/file` | **legacy**:裸 `.soon` 流;门户禁止调用,仅供兼容 |
|
||||
| `GET /api/v1/soon-models` | 兼容别名,同 `GET /api/v1/templates` |
|
||||
|
||||
#### `GET /api/v1/templates/{id}`(门户读取模板数据)
|
||||
|
||||
与 `GET /api/v1/files/{id}` 对齐,返回 JSON 包装,**非**裸文件流:
|
||||
|
||||
```json
|
||||
{
|
||||
"ok": true,
|
||||
"data": {
|
||||
"id": 1,
|
||||
"name": "示例模版",
|
||||
"type": 1,
|
||||
"updated_at": "2026-06-09 00:23:29",
|
||||
"json": "{...}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- `data.json` 为 **字符串**(与 `files/{id}` 一致),前端 `JSON.parse(data.json)` 后加载画布
|
||||
- 公开接口,无需登录
|
||||
|
||||
### Web 虚拟 key 前缀(门户设计页)
|
||||
|
||||
| 前缀 | 含义 | readJsonFile | 保存 writeFile |
|
||||
|------|------|--------------|----------------|
|
||||
| `soondesign_file:{id}:v{ver}` | 云端已登记文件 | `GET /files/{id}` | `PUT /files/{id}` |
|
||||
| `soondesign_template:{id}` | 云端模板(只读源) | `GET /templates/{id}` | `POST /files`(首次保存新建) |
|
||||
| `soondesign_session:...` | 本地/临时会话 | sessionStorage | 已登录 `POST /files`;未登录写 session |
|
||||
|
||||
- **保存/打开**走 JSON API;**仅**首页「下载」走 `GET /files/{id}/download` 落盘 `.soon`
|
||||
|
||||
---
|
||||
|
||||
## 前端约定
|
||||
@@ -203,3 +235,4 @@ GET /api/v1/pay/orders?page=1&size=8
|
||||
| 日期 | 说明 |
|
||||
|------|------|
|
||||
| 2026-06-08 | 初版:统一 page/size/total;files 兼容 limit/offset;pay/orders 分页 |
|
||||
| 2026-06-08 | 新增 GET /templates/{id} JSON 契约;Web 虚拟 key 前缀;/file 标 legacy |
|
||||
|
||||
Reference in New Issue
Block a user