data-page模板补「返回应用」FAB(评审方案按库内实际修正):returnToApp优先级链=APK JS桥(Android.backToApp/webkit handler)→?from=(限站内绝对路径,堵开放重定向)→history.back→根路径——不写死'/chat'(本库主界面是public根,已核实),纯浏览器自然落在回上一页/首页无需环境判断;位置选FAB弃footer(桌面优先方针下footer吃垂直空间,看板列高/长表分页首当其冲);图标用内联SVG(⌂码位WebView字体不保证);SKILL.md成文:每个app/*.html(含index)必带,检查清单同步;线上四页一并补齐
This commit is contained in:
@@ -83,6 +83,7 @@ const taskId = location.pathname.split('/').filter(Boolean)[1];
|
||||
- 桌面优先、移动兼容的样式:容器宽度按页面类型给足(表格类 1200px、看板类 1400px 或不设、统计类 1080px),不要照搬 800px 级别的移动端尺寸
|
||||
- 通过 `fetch` 调用数据 API
|
||||
- 错误处理和加载状态
|
||||
- **返回应用入口**:右下角 FAB(.fab,内联 SVG 图标),onclick 走 `returnToApp()`,优先级链:APK 注册的 JS 桥(`window.Android.backToApp` / webkit handler,有则最干净)→ `?from=` 参数(须站内绝对路径,防开放重定向)→ `history.back()` → 根路径。**每一个 `app/*.html` 页面(含 index.html)都要带**——用户可能从任意子页直入,缺入口即被困住
|
||||
|
||||
## 模板
|
||||
|
||||
@@ -215,4 +216,5 @@ const taskId = location.pathname.split('/').filter(Boolean)[1];
|
||||
- [ ] 页面动态解析 task_id
|
||||
- [ ] 包含错误处理和加载状态
|
||||
- [ ] 用户输入渲染时已转义
|
||||
- [ ] 每个 `app/*.html` 页面右下角都有「返回应用」FAB(returnToApp 链完整)
|
||||
- [ ] 已告知用户完整访问 URL(run 输出「访问地址」那行,含域名,非相对路径)
|
||||
|
||||
@@ -43,10 +43,18 @@ tr:last-child td { border-bottom: none; }
|
||||
.msg { text-align: center; padding: 40px 20px; color: var(--text-2); }
|
||||
.msg.err { color: #d70015; }
|
||||
@media (max-width: 480px) {
|
||||
body { padding: 8px; }
|
||||
body { padding: 8px; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
|
||||
h1 { font-size: 18px; margin-bottom: 14px; }
|
||||
.stat .val { font-size: 20px; }
|
||||
}
|
||||
/* 返回应用 FAB:固定右下、零版面占用;图标用内联 SVG 不用 ⌂ 字符(WebView 字体不保证) */
|
||||
.fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
|
||||
width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #fff;
|
||||
border: none; box-shadow: 0 4px 12px rgba(0,113,227,0.3); cursor: pointer; z-index: 100;
|
||||
display: flex; align-items: center; justify-content: center; }
|
||||
.fab:hover { filter: brightness(1.08); }
|
||||
.fab:active { transform: scale(0.94); }
|
||||
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -63,6 +71,10 @@ tr:last-child td { border-bottom: none; }
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="fab" aria-label="返回应用" title="返回应用" onclick="returnToApp()">
|
||||
<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>
|
||||
const CONFIG = {
|
||||
table: 'items',
|
||||
@@ -128,6 +140,19 @@ async function init() {
|
||||
document.getElementById('table').innerHTML = '';
|
||||
}
|
||||
}
|
||||
// 返回应用主界面(APK WebView 场景):① APK 注册的 JS 桥(Android.backToApp / iOS handler,有则最干净)
|
||||
// ② ?from=(限站内绝对路径,防开放重定向)③ history.back ④ 根路径(agent 主界面)。
|
||||
// 纯浏览器里 ③④ 恰好落在「回上一页/首页」,无需环境判断也行为合理。
|
||||
function returnToApp() {
|
||||
if (window.Android && typeof window.Android.backToApp === 'function') { window.Android.backToApp(); return; }
|
||||
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.backToApp) {
|
||||
window.webkit.messageHandlers.backToApp.postMessage({}); return;
|
||||
}
|
||||
const from = new URLSearchParams(location.search).get('from');
|
||||
if (from && /^\/(?!\/)/.test(from)) { location.href = from; return; }
|
||||
if (history.length > 1) history.back(); else location.href = '/';
|
||||
}
|
||||
|
||||
init();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -45,7 +45,16 @@ h1 { font-size: 20px; margin: 4px 0 20px; letter-spacing: -0.02em; }
|
||||
.col-bd .empty { text-align: center; color: var(--text-2); padding: 20px 8px; font-size: 12px; }
|
||||
.msg { text-align: center; padding: 40px 20px; color: var(--text-2); }
|
||||
.msg.err { color: #d70015; }
|
||||
@media (max-width: 480px) { body { padding: 8px; } h1 { font-size: 18px; margin-bottom: 14px; } }
|
||||
@media (max-width: 480px) { body { padding: 8px; padding-bottom: calc(64px + env(safe-area-inset-bottom)); } h1 { font-size: 18px; margin-bottom: 14px; } }
|
||||
/* 返回应用 FAB:固定右下、零版面占用(看板列高按视口算,footer 会直接吃掉一截);
|
||||
图标用内联 SVG 不用 ⌂ 字符(WebView 字体不保证有该码位) */
|
||||
.fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
|
||||
width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #fff;
|
||||
border: none; box-shadow: 0 4px 12px rgba(0,113,227,0.3); cursor: pointer; z-index: 100;
|
||||
display: flex; align-items: center; justify-content: center; }
|
||||
.fab:hover { filter: brightness(1.08); }
|
||||
.fab:active { transform: scale(0.94); }
|
||||
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -54,6 +63,10 @@ h1 { font-size: 20px; margin: 4px 0 20px; letter-spacing: -0.02em; }
|
||||
<div class="board-outer" id="outer"><div class="msg">加载中…</div></div>
|
||||
</div>
|
||||
|
||||
<button class="fab" aria-label="返回应用" title="返回应用" onclick="returnToApp()">
|
||||
<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>
|
||||
const CONFIG = {
|
||||
table: 'tasks',
|
||||
@@ -147,6 +160,19 @@ function bind() {
|
||||
});
|
||||
}
|
||||
|
||||
// 返回应用主界面(APK WebView 场景):① APK 注册的 JS 桥(Android.backToApp / iOS handler,有则最干净)
|
||||
// ② ?from=(限站内绝对路径,防开放重定向)③ history.back ④ 根路径(agent 主界面)。
|
||||
// 纯浏览器里 ③④ 恰好落在「回上一页/首页」,无需环境判断也行为合理。
|
||||
function returnToApp() {
|
||||
if (window.Android && typeof window.Android.backToApp === 'function') { window.Android.backToApp(); return; }
|
||||
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.backToApp) {
|
||||
window.webkit.messageHandlers.backToApp.postMessage({}); return;
|
||||
}
|
||||
const from = new URLSearchParams(location.search).get('from');
|
||||
if (from && /^\/(?!\/)/.test(from)) { location.href = from; return; }
|
||||
if (history.length > 1) history.back(); else location.href = '/';
|
||||
}
|
||||
|
||||
load();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -68,8 +68,17 @@ dialog::backdrop { background: rgba(0,0,0,0.35); }
|
||||
.acts .pri { background: var(--accent); color: #fff; border-color: var(--accent); }
|
||||
.acts .pri:hover { background: var(--accent-h); }
|
||||
@media (max-width: 480px) {
|
||||
body { padding: 8px; } th, td { padding: 8px 12px; font-size: 13px; }
|
||||
body { padding: 8px; padding-bottom: calc(64px + env(safe-area-inset-bottom)); } th, td { padding: 8px 12px; font-size: 13px; }
|
||||
}
|
||||
/* 返回应用 FAB:固定右下、零版面占用(桌面优先方针下 footer 会吃掉长表/看板的垂直空间)。
|
||||
图标用内联 SVG 不用 ⌂ 字符——WebView 字体不保证有该码位,缺字即变豆腐块。 */
|
||||
.fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
|
||||
width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #fff;
|
||||
border: none; box-shadow: 0 4px 12px rgba(0,113,227,0.3); cursor: pointer; z-index: 100;
|
||||
display: flex; align-items: center; justify-content: center; }
|
||||
.fab:hover { filter: brightness(1.08); }
|
||||
.fab:active { transform: scale(0.94); }
|
||||
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -97,6 +106,10 @@ dialog::backdrop { background: rgba(0,0,0,0.35); }
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<button class="fab" aria-label="返回应用" title="返回应用" onclick="returnToApp()">
|
||||
<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>
|
||||
const CONFIG = {
|
||||
table: 'items', // ← 修改为你的表名
|
||||
@@ -266,6 +279,19 @@ document.getElementById('dlgForm').onsubmit = async e => {
|
||||
} catch (e) { alert('新增失败:' + e.message); }
|
||||
};
|
||||
|
||||
// 返回应用主界面(APK WebView 场景):① APK 注册的 JS 桥(Android.backToApp / iOS handler,有则最干净)
|
||||
// ② ?from=(限站内绝对路径,防开放重定向)③ history.back ④ 根路径(agent 主界面)。
|
||||
// 纯浏览器里 ③④ 恰好落在「回上一页/首页」,无需环境判断也行为合理。
|
||||
function returnToApp() {
|
||||
if (window.Android && typeof window.Android.backToApp === 'function') { window.Android.backToApp(); return; }
|
||||
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.backToApp) {
|
||||
window.webkit.messageHandlers.backToApp.postMessage({}); return;
|
||||
}
|
||||
const from = new URLSearchParams(location.search).get('from');
|
||||
if (from && /^\/(?!\/)/.test(from)) { location.href = from; return; }
|
||||
if (history.length > 1) history.back(); else location.href = '/';
|
||||
}
|
||||
|
||||
load();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user