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:
2026-09-23 23:45:50 +08:00
parent 4a16cbd215
commit efe5db2e88
4 changed files with 82 additions and 3 deletions
+26 -1
View File
@@ -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>