「返回应用」升级为回到源会话:FAB链简化为深链——数据页task_id即会话id(engine里1:1),backToApp()直接跳/?s=<id>;前端启动(settings.js文末init)消费一次:命中即openSession+replaceState抹参数(防刷新钉回),会话已删走openSession自带报错落在welcome。JS桥/?from=/history.back整条链移除——back在多页数据应用里退的是上一张数据页(那是「上一页」语义,归顶部返回导航管),桥与from均无真实消费方,确定性跳转胜过猜环境;按钮文案返回应用→返回对话(房子图标不变,语义终于配得上图标);SKILL.md契约同步

This commit is contained in:
2026-09-23 23:57:26 +08:00
parent efe5db2e88
commit 04a2e436d6
5 changed files with 32 additions and 39 deletions
+7 -12
View File
@@ -106,7 +106,7 @@ body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
</form>
</dialog>
<button class="fab" aria-label="返回应用" title="返回应用" onclick="returnToApp()">
<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>
@@ -279,17 +279,12 @@ 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 = '/';
// 返回应用=回到发起本页的对话:主界面深链 /?s=<会话id>(数据页的 task_id 就是会话 id,
// engine 里 1:1),前端启动时消费一次打开该会话。刻意不用 history.back():多页数据应用里
// back 退的是上一张数据页——那是「上一页」语义,归顶部「返回导航」管。
function backToApp() {
const id = location.pathname.split('/').filter(Boolean)[1];
location.href = id ? '/?s=' + encodeURIComponent(id) : '/';
}
load();