diff --git a/manual_trading_hub/static/app.css b/manual_trading_hub/static/app.css index 923844a..d1ab671 100644 --- a/manual_trading_hub/static/app.css +++ b/manual_trading_hub/static/app.css @@ -3884,7 +3884,7 @@ body.hub-page-ai #page-ai { } /* 手机 AI:须在 .ai-layout 双列定义之后,避免被覆盖成半屏 */ -@media (max-width: 720px) { +@media (max-width: 720px), ((display-mode: standalone) and (max-width: 960px)) { html:has(body.hub-page-ai) { height: 100%; overflow: hidden; @@ -3922,19 +3922,35 @@ body.hub-page-ai #page-ai { font-size: 11px; } - body.hub-page-ai.hub-ai-keyboard-open .app-header, - body.hub-page-ai.hub-ai-keyboard-open #page-ai .page-head { + body.hub-page-ai .app-header .brand { display: none; } - body.hub-page-ai.hub-ai-keyboard-open .ai-mobile-tabs, - body.hub-page-ai.hub-ai-keyboard-open .ai-chat-topbar, - body.hub-page-ai.hub-ai-keyboard-open .ai-chat-session-head { + body.hub-page-ai .header-right { + grid-template-columns: 1fr auto auto; + grid-template-rows: auto; + } + + body.hub-page-ai .header-right .top-nav { + grid-column: 1 / -1; + order: 2; + } + + body.hub-page-ai.hub-ai-keyboard-open .app-header .theme-toggle, + body.hub-page-ai.hub-ai-keyboard-open .app-header .sys-pill, + body.hub-page-ai.hub-ai-keyboard-open .app-header #btn-logout { display: none; } - body.hub-page-ai.hub-ai-keyboard-open .ai-mobile-tabs { - margin-bottom: 4px; + body.hub-page-ai.hub-ai-keyboard-open .app-header { + padding: 4px 0; + margin-bottom: 0; + } + + body.hub-page-ai.hub-ai-keyboard-open .top-nav a { + min-height: 30px; + padding: 4px 8px; + font-size: 10px; } body.hub-page-ai #page-ai { @@ -3950,6 +3966,11 @@ body.hub-page-ai #page-ai { margin-bottom: 6px; flex-shrink: 0; width: 100%; + position: sticky; + top: 0; + z-index: 12; + padding: 4px 0 2px; + background: var(--bg); } body.hub-page-ai .ai-mobile-tab { diff --git a/manual_trading_hub/static/app.js b/manual_trading_hub/static/app.js index 6af4cc9..a62c8b7 100644 --- a/manual_trading_hub/static/app.js +++ b/manual_trading_hub/static/app.js @@ -900,7 +900,10 @@ } function isMobileLayout() { - return window.matchMedia("(max-width: 720px)").matches; + if (window.matchMedia("(max-width: 720px)").matches) return true; + if (window.matchMedia("(display-mode: standalone)").matches) return true; + if (window.navigator && window.navigator.standalone === true) return true; + return false; } function positionHasContracts(p) { @@ -1107,7 +1110,6 @@ let syncHubAiMobileViewport = () => {}; function initHubAiMobileViewport() { - const mq = window.matchMedia("(max-width: 720px)"); const shell = document.querySelector(".app-shell"); const chatInput = document.getElementById("ai-chat-input"); if (!shell || !window.visualViewport) { @@ -1115,6 +1117,8 @@ return; } + let baselineInnerH = Math.max(window.innerHeight, window.visualViewport.height || 0); + const scrollChatToEnd = () => { const box = document.getElementById("ai-chat-messages"); if (box) requestAnimationFrame(() => { box.scrollTop = box.scrollHeight; }); @@ -1122,7 +1126,7 @@ syncHubAiMobileViewport = () => { const onAi = document.body.classList.contains("hub-page-ai"); - if (!onAi || !mq.matches) { + if (!onAi || !isMobileLayout()) { shell.style.removeProperty("height"); shell.style.removeProperty("max-height"); shell.style.removeProperty("width"); @@ -1135,14 +1139,18 @@ const h = Math.max(240, Math.round(vv.height)); const top = Math.round(vv.offsetTop || 0); const left = Math.round(vv.offsetLeft || 0); + const inputFocused = !!(chatInput && document.activeElement === chatInput); + if (!inputFocused) { + baselineInnerH = Math.max(baselineInnerH, window.innerHeight, h); + } document.documentElement.style.setProperty("--hub-vvh", `${h}px`); shell.style.height = `${h}px`; shell.style.maxHeight = `${h}px`; shell.style.width = `${Math.round(vv.width)}px`; shell.style.transform = top > 0 || left > 0 ? `translate(${left}px, ${top}px)` : ""; - const keyboardLikely = - top > 0 || h < window.innerHeight * 0.82 || document.activeElement === chatInput; + const viewportShrunk = h < baselineInnerH * 0.72; + const keyboardLikely = inputFocused && (viewportShrunk || top > 48); document.body.classList.toggle("hub-ai-keyboard-open", keyboardLikely); }; diff --git a/manual_trading_hub/static/index.html b/manual_trading_hub/static/index.html index 0cecd2c..f2ec10a 100644 --- a/manual_trading_hub/static/index.html +++ b/manual_trading_hub/static/index.html @@ -15,7 +15,7 @@ - +
@@ -449,7 +449,7 @@ -