「返回应用」升级为回到源会话: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:
@@ -1465,5 +1465,13 @@
|
||||
}
|
||||
} catch (_) { /* 网络错误放过,让后续请求正常走 */ }
|
||||
loadSessionList();
|
||||
loadDrawerUser(verifiedUser); // 侧边栏底部展示真实登录用户(未启用认证/拉取失败时静默回退默认占位)
|
||||
loadDrawerUser(verifiedUser); // 侧边栏底部展示真实登录用户(未启用鉴权/拉取失败时静默回退默认占位)
|
||||
// 会话深链 /?s=<session_id>:数据页面(/app/{task_id}/...)的「返回会话」FAB 用——
|
||||
// task_id 即会话 id(engine 里 1:1),启动时消费一次即 replaceState 抹掉参数,
|
||||
// 避免刷新/分享时被钉回该会话;会话已删则 openSession 自行报错,落在 welcome。
|
||||
const deep = new URLSearchParams(location.search).get('s');
|
||||
if (deep) {
|
||||
history.replaceState(null, '', '/');
|
||||
openSession(deep);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -83,7 +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)都要带**——用户可能从任意子页直入,缺入口即被困住
|
||||
- **返回应用入口**:右下角 FAB(房子图标),`backToApp()` 跳主界面深链 `/?s=<task_id>`——数据页面的 task_id 就是会话 id,一点直达发起本页的对话;若未来 APK 提供 JS 桥,只需替换 `backToApp()` 一处。**每一个 `app/*.html` 页面(含 index.html)都要带**——用户可能从任意子页直入,缺出口即被困住
|
||||
|
||||
## 模板
|
||||
|
||||
@@ -216,5 +216,5 @@ const taskId = location.pathname.split('/').filter(Boolean)[1];
|
||||
- [ ] 页面动态解析 task_id
|
||||
- [ ] 包含错误处理和加载状态
|
||||
- [ ] 用户输入渲染时已转义
|
||||
- [ ] 每个 `app/*.html` 页面右下角都有「返回应用」FAB(returnToApp 链完整)
|
||||
- [ ] 每个 `app/*.html` 页面右下角都有「返回会话」FAB(backToApp → `/?s=<task_id>` 深链)
|
||||
- [ ] 已告知用户完整访问 URL(run 输出「访问地址」那行,含域名,非相对路径)
|
||||
|
||||
@@ -71,7 +71,7 @@ body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
|
||||
@@ -140,17 +140,12 @@ 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 = '/';
|
||||
// 返回应用=回到发起本页的对话:主界面深链 /?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) : '/';
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
@@ -63,7 +63,7 @@ body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
|
||||
<div class="board-outer" id="outer"><div class="msg">加载中…</div></div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
|
||||
@@ -160,17 +160,12 @@ 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 = '/';
|
||||
// 返回应用=回到发起本页的对话:主界面深链 /?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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user