From 2f53c6f57e9456c345ca7eee6a81df44dcb15d41 Mon Sep 17 00:00:00 2001 From: kicer Date: Thu, 24 Sep 2026 10:02:13 +0800 Subject: [PATCH] =?UTF-8?q?data-page=E8=A1=A5=E5=AF=BC=E8=88=AA=E9=80=9A?= =?UTF-8?q?=E8=B7=AF(=E6=B5=8B=E8=AF=95=E6=9A=B4=E9=9C=B2:AI=E6=8C=89?= =?UTF-8?q?=E6=AD=A5=E9=AA=A45=E5=88=86=E6=94=AF=E4=B8=80cp=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E4=B8=BAindex,dashboard/kanban=E6=88=90=E5=AD=A4?= =?UTF-8?q?=E5=84=BF=E9=A1=B5=E2=80=94=E2=80=94=E5=88=86=E6=94=AF=E4=BA=8C?= =?UTF-8?q?=E3=80=8C=E5=81=9A=E5=AF=BC=E8=88=AA=E3=80=8D=E6=97=A0=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E6=97=A0=E7=BA=A6=E5=AE=9A=E4=B8=8D=E5=8F=AF=E6=89=A7?= =?UTF-8?q?=E8=A1=8C,=E4=B8=8E=E9=87=8D=E6=9E=84=E3=80=8C=E5=8F=AA?= =?UTF-8?q?=E5=86=99config=E5=88=AB=E5=8D=B3=E5=85=B4=E3=80=8D=E5=93=B2?= =?UTF-8?q?=E5=AD=A6=E8=87=AA=E7=9B=B8=E7=9F=9B=E7=9B=BE):=E2=91=A0?= =?UTF-8?q?=E6=96=B0=E5=A2=9Enav.html=E9=9D=99=E6=80=81=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF(=E4=B8=89=E5=8D=A1=E7=89=87=E9=93=BEtable/da?= =?UTF-8?q?shboard/kanban,=E5=A4=8D=E7=94=A8base.css+FAB,=E9=9B=B6config,r?= =?UTF-8?q?un.py=E7=9A=84glob=E8=87=AA=E5=8A=A8=E7=BA=B3=E5=85=A5);?= =?UTF-8?q?=E2=91=A1=E4=B8=89=E6=95=B0=E6=8D=AE=E9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=90=AF=E7=94=A8=E5=8D=A1=E7=89=87=E9=98=B2?= =?UTF-8?q?no=20such=20table=E8=A3=B8=E5=A5=94;=E5=8D=95=E9=A1=B5=E7=BB=B4?= =?UTF-8?q?=E6=8C=81cp=E6=A8=A1=E6=9D=BF,=E5=AE=88=E5=8D=AB=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=9A=90=E8=97=8Fcrumb=E6=97=A0=E9=9C=80=E5=A4=84?= =?UTF-8?q?=E7=90=86),=E5=88=9D=E5=A7=8B=E5=8C=96/=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E9=85=8D=E7=BD=AE/=E6=A3=80=E6=9F=A5=E6=B8=85=E5=8D=95?= =?UTF-8?q?=E5=90=8C=E6=AD=A5nav;=E6=97=A7=E4=BC=9A=E8=AF=9D=E9=87=8D?= =?UTF-8?q?=E8=B7=91skill=E5=B9=82=E7=AD=89=E8=A1=A5nav.html=E4=B8=8D?= =?UTF-8?q?=E4=BC=A4=E5=B7=B2=E6=94=B9=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skills/data-page/SKILL.md | 12 ++++--- skills/data-page/run.py | 2 +- skills/data-page/templates/base.css | 3 ++ skills/data-page/templates/dashboard.html | 4 +++ skills/data-page/templates/kanban.html | 4 +++ skills/data-page/templates/nav.html | 41 +++++++++++++++++++++++ skills/data-page/templates/table.html | 4 +++ 7 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 skills/data-page/templates/nav.html diff --git a/skills/data-page/SKILL.md b/skills/data-page/SKILL.md index 7a76f32..52dddda 100644 --- a/skills/data-page/SKILL.md +++ b/skills/data-page/SKILL.md @@ -33,7 +33,8 @@ visit_url: /app/{task_id}/ 调用 `skill(name="data-page", op="run")`,无需参数。它会把以下文件复制到 `.app/`: -- `table.html` / `dashboard.html` / `kanban.html` —— 三个页面模板 +- `table.html` / `dashboard.html` / `kanban.html` —— 三个数据页模板 +- `nav.html` —— 多页导航首页模板(静态卡片,无 config) - `base.css` —— 共用样式 - `config-table.js` / `config-dashboard.js` / `config-kanban.js` —— 配置骨架 @@ -81,14 +82,16 @@ const taskId = location.pathname.split('/').filter(Boolean)[1]; 2. **创建表并录入数据**:用 `db` 工具完成。 3. **初始化**:调用 `skill(name="data-page", op="run")`。 4. **为每个要生成的页面写 config 文件**(见下一节)。**不要读也不要改模板本身**。 -5. **选定入口页**:把要作为首页的模板复制为 `.app/index.html`(同目录复制,引用路径不变),或直接保留多个页面并在 index.html 里做导航。 +5. **选定入口页 `.app/index.html`**(index 是副本,允许编辑;模板本体不动): + - **用到 ≥2 个模板页** → `cp .app/nav.html .app/index.html`,改标题为业务名,并把未启用页面的卡片删掉(没配过的页点开会报 no such table)。子页顶部的「← 首页」链回此导航页。 + - **只用 1 个模板** → `cp .app/<模板>.html .app/index.html`(同目录复制,引用路径不变)。副本指向自身时「← 首页」会被页面脚本自动隐藏,无需处理。 6. **告知用户**:把 run 输出末尾「访问地址」那行的完整 URL 发给用户,再简要说明页面功能。 默认只写 config 就够。模板无法覆盖需求时,才走自定义路径(见「自定义页面」一节)。 ## 页面配置 -三个模板对应三份 config: +三个数据页模板对应三份 config(`nav.html` 为静态导航,无 config): | 模板 | config 文件 | 用途 | |---|---|---| @@ -168,7 +171,8 @@ window.PAGE_CONFIG = { - [ ] 数据库表已创建、数据已录入 - [ ] 调用了 `skill run` - [ ] 写好了对应的 `config-*.js` -- [ ] 选定入口页(复制为 `.app/index.html` 或保留多页 + 导航) +- [ ] 选定入口页:多页用 nav 副本且卡片只留启用页;单页用模板副本 +- [ ] 启用页互相连通:首页 ≤1 击可达每页,每页可回首页 - [ ] 页面动态解析 task_id - [ ] 每个 `.app/*.html` 都有返回会话入口 - [ ] 自定义页面:引用了 `base.css`、数据渲染已转义、SQL 参数化、大表加 LIMIT diff --git a/skills/data-page/run.py b/skills/data-page/run.py index 7a69075..33727f7 100644 --- a/skills/data-page/run.py +++ b/skills/data-page/run.py @@ -3,7 +3,7 @@ # 目标目录固定为 <任务目录>/.app/(不带 dest 参数:manager 对绝对路径参数不做沙箱 # 校验,开放 dest 等于开放任意目录写入;路径也已写死在文档流程里,可配置只会造成漂移)。 # 复制内容: -# *.html → .app/ 页面模板(table / dashboard / kanban) +# *.html → .app/ 页面模板(table / dashboard / kanban / nav 导航首页) # base.css → .app/ 共用样式 # config-*.js → .app/ 配置骨架(AI 只改这些) # 已存在的同名文件跳过不覆盖(重跑幂等,AI 改过的 config 不会被覆盖回默认)。 diff --git a/skills/data-page/templates/base.css b/skills/data-page/templates/base.css index 0921688..6399444 100644 --- a/skills/data-page/templates/base.css +++ b/skills/data-page/templates/base.css @@ -19,6 +19,9 @@ body { padding: 16px; padding-bottom: calc(72px + env(safe-area-inset-bottom)); } .container { max-width: 1200px; margin: 0 auto; } +/* 子页→首页面包屑(单页场景脚本会自动移除,见各模板尾部守卫) */ +.crumb { display: inline-block; color: var(--text-2); text-decoration: none; font-size: 13px; margin: 0 0 8px; } +.crumb:hover { color: var(--accent); } h1 { font-size: 20px; margin: 4px 0 20px; letter-spacing: -0.02em; } /* ── 卡片 ─────────────────────────────────────────────── */ diff --git a/skills/data-page/templates/dashboard.html b/skills/data-page/templates/dashboard.html index 243eea8..bf35b74 100644 --- a/skills/data-page/templates/dashboard.html +++ b/skills/data-page/templates/dashboard.html @@ -11,6 +11,7 @@
+ ← 首页

数据看板

@@ -104,6 +105,9 @@ function backToApp() { location.href = id ? '/?s=' + encodeURIComponent(id) : '/'; } +// 单页场景:本页的副本就是 index.html,「← 首页」指向自身 → 移除(多页导航不受影响) +if (/\/(index\.html)?$/.test(location.pathname)) { const c = document.querySelector('.crumb'); if (c) c.remove(); } + init(); diff --git a/skills/data-page/templates/kanban.html b/skills/data-page/templates/kanban.html index 294be65..d151b26 100644 --- a/skills/data-page/templates/kanban.html +++ b/skills/data-page/templates/kanban.html @@ -11,6 +11,7 @@
+← 首页

看板

加载中…
@@ -117,6 +118,9 @@ function backToApp() { location.href = id ? '/?s=' + encodeURIComponent(id) : '/'; } +// 单页场景:本页的副本就是 index.html,「← 首页」指向自身 → 移除(多页导航不受影响) +if (/\/(index\.html)?$/.test(location.pathname)) { const c = document.querySelector('.crumb'); if (c) c.remove(); } + load(); diff --git a/skills/data-page/templates/nav.html b/skills/data-page/templates/nav.html new file mode 100644 index 0000000..a9ff02f --- /dev/null +++ b/skills/data-page/templates/nav.html @@ -0,0 +1,41 @@ + + + + + +数据导航 + + + + + + + + + + + diff --git a/skills/data-page/templates/table.html b/skills/data-page/templates/table.html index ced75e9..5b7f61b 100644 --- a/skills/data-page/templates/table.html +++ b/skills/data-page/templates/table.html @@ -8,6 +8,7 @@
+ ← 首页

数据表格

@@ -240,6 +241,9 @@ function backToApp() { location.href = id ? '/?s=' + encodeURIComponent(id) : '/'; } +// 单页场景:本页的副本就是 index.html,「← 首页」指向自身 → 移除(多页导航不受影响) +if (/\/(index\.html)?$/.test(location.pathname)) { const c = document.querySelector('.crumb'); if (c) c.remove(); } + load();