data-page补导航通路(测试暴露:AI按步骤5分支一cp模板为index,dashboard/kanban成孤儿页——分支二「做导航」无模板无约定不可执行,与重构「只写config别即兴」哲学自相矛盾):①新增nav.html静态导航模板(三卡片链table/dashboard/kanban,复用base.css+FAB,零config,run.py的glob自动纳入);②三数据页顶部加「←首页」面包屑(href=./,与右下FAB分职:FAB=跨应用退出回会话,crumb=应用内回导航页,评审分层「顶部页面内/底部跨应用」补齐下半),尾行守卫:URL为站点根或index.html时自动移除(单页场景index=本页副本,crumb指自身);③SKILL.md步骤5改可执行双分支(≥2页cp nav为index+删未启用卡片防no such table裸奔;单页维持cp模板,守卫自动隐藏crumb无需处理),初始化/页面配置/检查清单同步nav;旧会话重跑skill幂等补nav.html不伤已改文件

This commit is contained in:
2026-09-24 10:02:13 +08:00
parent 920fac9b6e
commit 2f53c6f57e
7 changed files with 65 additions and 5 deletions
+8 -4
View File
@@ -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
+1 -1
View File
@@ -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 不会被覆盖回默认)。
+3
View File
@@ -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; }
/* ── 卡片 ─────────────────────────────────────────────── */
@@ -11,6 +11,7 @@
</head>
<body>
<div class="container">
<a class="crumb" href="./">← 首页</a>
<h1 id="title">数据看板</h1>
<div class="stats" id="stats"></div>
<div class="card card-pad">
@@ -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();
</script>
</body>
+4
View File
@@ -11,6 +11,7 @@
</head>
<body>
<div class="container">
<a class="crumb" href="./">← 首页</a>
<h1 id="title">看板</h1>
<div class="board-outer" id="outer"><div class="msg">加载中…</div></div>
</div>
@@ -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();
</script>
</body>
+41
View File
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>数据导航</title>
<link rel="stylesheet" href="./base.css">
<style>
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
a.navcard { display: block; background: var(--surface); border-radius: var(--r); padding: 18px;
text-decoration: none; color: inherit; box-shadow: var(--shadow);
border: 1px solid transparent; transition: border-color .15s, transform .05s; }
a.navcard:hover { border-color: var(--accent); }
a.navcard:active { transform: scale(0.99); }
a.navcard .t { font-weight: 600; margin-bottom: 4px; }
a.navcard .d { color: var(--text-2); font-size: 12px; }
</style>
</head>
<body>
<div class="container">
<h1>数据导航</h1>
<div class="grid">
<a class="navcard" href="./table.html"><div class="t">📋 明细表格</div><div class="d">浏览、搜索、在线增删改</div></a>
<a class="navcard" href="./dashboard.html"><div class="t">📊 统计看板</div><div class="d">汇总指标与分组分布</div></a>
<a class="navcard" href="./kanban.html"><div class="t">🗂️ 分组看板</div><div class="d">按状态分列流转</div></a>
</div>
</div>
<button class="fab" aria-label="返回对话" title="返回发起本数据的对话" onclick="backToApp()">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/></svg>
</button>
<script>
// 静态导航页,无 config:卡片文字/链接允许在 .app/index.html 副本上按场景编辑(模板本体不动)。
function backToApp() {
const id = location.pathname.split('/').filter(Boolean)[1];
location.href = id ? '/?s=' + encodeURIComponent(id) : '/';
}
</script>
</body>
</html>
+4
View File
@@ -8,6 +8,7 @@
</head>
<body>
<div class="container">
<a class="crumb" href="./">← 首页</a>
<div class="card">
<div class="hd">
<h1 id="title">数据表格</h1>
@@ -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();
</script>
</body>