| 机型标识 | 机型名称 | 设备类型 | 区域数 | 模板类型数 |
|---|---|---|---|---|
| x11 | X11 洗衣机 | wash | 2 | 8 |
| x11_dry | X11 干衣机 | dry | 1 | 6 |
| hplus | Hplus | wash+dry | 2 | 3 |
| ultra | Ultra | wash | 6 | 9 |
| f2_multi | F2 Multi | wash | 1 | 9 |
| seeker | Seeker | wash+dry | 4 | 6 |
| seeker_dry | Seeker 干衣机 | dry | 1 | 6 |
| x11_ultra | X11 Ultra | dry | 3 | 6 |
common - 通用模板time_popular - 人气推荐time_custom - 用户定制time_season - 季节推荐time_season_storage - 季节收纳(多卡)time_season_in - 季节上新(多卡)time_care - 关怀提醒time_environmental - 环保错峰time_weather - 天气建议time_health - 健康清洁time_health_2 - 杀菌模板(Ultra)只需 3 步:
编辑 backend/app/config/machine_config.py:
MACHINE_MODELS["new_model"] = MachineModel(
model_id="new_model",
model_name="新机型",
type_id="201c51890c31c308...", # Redis type_id
zones=[
ZoneConfig(zone_id="1", zone_name="洗衣机", device_type="wash"),
],
template_mappings=[
TemplateMapping(
template_type="common",
redis_key_pattern="broadcast-template-jinja:single_card:wash:common",
description="通用模板"
),
# 添加其他模板类型...
]
)
mkdir templates/new_model
cp daping项目模板文件 templates/new_model/
系统自动读取配置,无需修改前端代码。
{
"id": "template_id",
"name": "X11洗衣机-通用模板",
"category": "单卡洗涤",
"device_type": "wash",
"machine_model": "x11",
"template_type": "common",
"reusable_from": "", // 复用来源(空=独立模板)
"reuse_targets": [], // 被哪些模板复用
"template_body": "{% macro ... %}",
"input_variables": [...],
"description": "...",
"created_at": "2026-09-08T00:00:00Z",
"updated_at": "2026-09-08T00:00:00Z"
}
GET /api/templates?machine_model=x11&device_type=wash&template_type=commonGET /api/templates/{id}POST /api/templatesPUT /api/templates/{id}DELETE /api/templates/{id}GET /api/templates/machine-models - 所有机型GET /api/templates/device-types?machine_model=x11 - 设备类型GET /api/templates/template-types?machine_model=x11&device_type=wash - 模板类型POST /api/templates/preview - 预览(含 program_name_map)POST /api/templates/render - 渲染已保存模板# 后端
conda activate rec
cd backend
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# 前端
cd frontend
npm install # 首次
npm run dev
或一键启动:
.\start.ps1
x11_template_vue/
├── backend/
│ ├── app/
│ │ ├── config/
│ │ │ └── machine_config.py # 机型配置(核心)
│ │ ├── services/
│ │ │ ├── template_store.py # 模板存储(支持复用)
│ │ │ └── renderer.py # 渲染器(含 program_name_map)
│ │ ├── schemas.py # 数据模型
│ │ └── main.py # API 路由
│ └── data/
│ └── templates.json # 模板数据
├── frontend/
│ └── src/
│ ├── App.vue # 主界面
│ └── services/
│ └── api.js # API 调用
├── templates/ # 原始模板文件(按机型分)
│ ├── x11/
│ ├── hplus/
│ ├── ultra/
│ ├── f2_multi/
│ ├── seeker/
│ ├── x11Ultra/
│ └── seekerR2/
└── start.ps1 # 一键启动
write_jinja_*.py 中粘贴或直接导出 JSON,用脚本批量导入 Redis。