data-page模板桌面优先修正(线上三症状均为模板缺陷,AI只是照搬):①kanban窄板靠左——board拆外层滚+内层fit-content+auto margin居中(列少居中、列多正常滚,直接justify-content:center会在溢出时裁掉首列)②桌面端容器820px小气——按页面类型放宽:table1200/dashboard1080/kanban1400③dashboard明细表nowrap撞破卡片——.card overflow:hidden+包.table-scroll(负margin贴卡片边缘滚动不撞圆角);SKILL.md同步成桌面优先移动兼容通则(溢出内容包overflow-x:auto、flex居中禁justify-content:center)

This commit is contained in:
2026-09-23 23:41:46 +08:00
parent 5ede5cfd4e
commit 4a16cbd215
4 changed files with 20 additions and 10 deletions
+4 -2
View File
@@ -80,7 +80,7 @@ const taskId = location.pathname.split('/').filter(Boolean)[1];
页面必须包含:
- HTML 骨架(`<!DOCTYPE html>`、`<meta viewport>`、UTF-8)
- 移动端友好的样式
- 桌面优先、移动兼容的样式:容器宽度按页面类型给足(表格类 1200px、看板类 1400px 或不设、统计类 1080px),不要照搬 800px 级别的移动端尺寸
- 通过 `fetch` 调用数据 API
- 错误处理和加载状态
@@ -176,7 +176,9 @@ const taskId = location.pathname.split('/').filter(Boolean)[1];
- 用原生 JS + fetch,不引入框架
- 样式用内联 `<style>` 或独立 CSS,不依赖外部 CSS 库
- 图表用纯 SVG 或 CSS 绘制
- 移动优先
- 桌面优先、移动兼容:数据页面主要在电脑上看,窄屏靠横向滚动兑底
- 所有可能横向溢出的内容(表格、长文本、代码)包一层 `overflow-x: auto` 容器;卡片内滚动可配合负 margin 贴边
- flex 居中用 `width: fit-content; margin: 0 auto`,不用 `justify-content: center`(内容超出滚动容器时居中会裁掉首屏左侧)
- 显示加载状态和错误提示
- 提交类按钮加禁用状态,避免重复点击
+5 -3
View File
@@ -18,14 +18,16 @@ body {
-webkit-font-smoothing: antialiased;
padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.container { max-width: 820px; margin: 0 auto; }
.container { max-width: 1080px; margin: 0 auto; }
h1 { font-size: 20px; margin: 4px 0 20px; letter-spacing: -0.02em; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 18px; }
.stat .lbl { color: var(--text-2); font-size: 12px; margin-bottom: 4px; }
.stat .val { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; overflow: hidden; }
.card h2 { font-size: 14px; font-weight: 600; margin: 0 0 14px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }
/* 表格可能横向溢出:滚动容器用负 margin 贴到卡片边缘,不撞破圆角 */
.table-scroll { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 140px) 1fr auto; gap: 12px; align-items: center; }
.bar-row .k { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -57,7 +59,7 @@ tr:last-child td { border-bottom: none; }
</div>
<div class="card" id="tableCard">
<h2>明细</h2>
<div id="table"></div>
<div class="table-scroll" id="table"></div>
</div>
</div>
+10 -4
View File
@@ -18,7 +18,11 @@ body {
padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
h1 { font-size: 20px; margin: 4px 0 20px; letter-spacing: -0.02em; }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.container { max-width: 1400px; margin: 0 auto; }
/* 外层滚、内层居中:board 用 fit-content+auto margin——列少居中、列多靠边滚动;
若在滚动容器上直接 justify-content:center,溢出时首列会被裁掉(滚动起点落在中间)。 */
.board-outer { overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.board { display: flex; gap: 12px; width: fit-content; margin: 0 auto; }
.col { flex: 0 0 260px; scroll-snap-align: start; background: var(--surface); border-radius: var(--r);
box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: calc(100vh - 140px); }
.col-hd { display: flex; align-items: center; justify-content: space-between;
@@ -45,8 +49,10 @@ h1 { font-size: 20px; margin: 4px 0 20px; letter-spacing: -0.02em; }
</style>
</head>
<body>
<div class="container">
<h1 id="title">看板</h1>
<div id="root"><div class="msg">加载中…</div></div>
<div class="board-outer" id="outer"><div class="msg">加载中…</div></div>
</div>
<script>
const CONFIG = {
@@ -81,7 +87,7 @@ async function load() {
rows = await q(`SELECT * FROM ${CONFIG.table}`);
render();
} catch (e) {
document.getElementById('root').innerHTML = `<div class="msg err">加载失败:${esc(e.message)}</div>`;
document.getElementById('outer').innerHTML = `<div class="msg err">加载失败:${esc(e.message)}</div>`;
}
}
@@ -97,7 +103,7 @@ function render() {
</div>
</div>`;
}).join('')}</div>`;
document.getElementById('root').innerHTML = html;
document.getElementById('outer').innerHTML = html;
bind();
}
+1 -1
View File
@@ -20,7 +20,7 @@ body {
-webkit-font-smoothing: antialiased;
padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.container { max-width: 820px; margin: 0 auto; }
.container { max-width: 1200px; margin: 0 auto; }
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.hd { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.hd h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }