fix(hub): restore desktop monitor layout in PWA
Split mobile AI layout from viewport-only mobile detection so standalone desktop app uses full monitor cards again.
This commit is contained in:
@@ -899,9 +899,20 @@
|
||||
return (settingsCache?.exchanges || []).filter((x) => x.enabled);
|
||||
}
|
||||
|
||||
/** 窄屏布局:仅按视口宽度,监控区/行情等共用 */
|
||||
function isMobileLayout() {
|
||||
if (window.matchMedia("(max-width: 720px)").matches) return true;
|
||||
if (window.matchMedia("(display-mode: standalone)").matches) return true;
|
||||
return window.matchMedia("(max-width: 720px)").matches;
|
||||
}
|
||||
|
||||
/** AI 教练手机布局:窄屏或手机 PWA(桌面安装的 App 仍走桌面布局) */
|
||||
function isMobileAiLayout() {
|
||||
if (isMobileLayout()) return true;
|
||||
if (
|
||||
window.matchMedia("(display-mode: standalone)").matches &&
|
||||
window.matchMedia("(max-width: 960px)").matches
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (window.navigator && window.navigator.standalone === true) return true;
|
||||
return false;
|
||||
}
|
||||
@@ -1054,7 +1065,7 @@
|
||||
const layout = document.querySelector(".ai-layout");
|
||||
const tabs = document.querySelectorAll(".ai-mobile-tab");
|
||||
if (!layout) return;
|
||||
const mobile = isMobileLayout();
|
||||
const mobile = isMobileAiLayout();
|
||||
if (!mobile) {
|
||||
delete layout.dataset.aiMobileTab;
|
||||
tabs.forEach((btn) => {
|
||||
@@ -1099,7 +1110,7 @@
|
||||
applyAiMobileTab(tab);
|
||||
if (AI_MOBILE_CHAT_TABS.has(tab)) {
|
||||
const input = document.getElementById("ai-chat-input");
|
||||
if (input && isMobileLayout()) input.focus();
|
||||
if (input && isMobileAiLayout()) input.focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1126,7 +1137,7 @@
|
||||
|
||||
syncHubAiMobileViewport = () => {
|
||||
const onAi = document.body.classList.contains("hub-page-ai");
|
||||
if (!onAi || !isMobileLayout()) {
|
||||
if (!onAi || !isMobileAiLayout()) {
|
||||
shell.style.removeProperty("height");
|
||||
shell.style.removeProperty("max-height");
|
||||
shell.style.removeProperty("width");
|
||||
@@ -3350,7 +3361,7 @@
|
||||
if (title) {
|
||||
const modeLabel = botMode === "general" ? "普通聊天" : "交易教练";
|
||||
const sessionTitle = session && session.title ? String(session.title) : "";
|
||||
if (isMobileLayout()) {
|
||||
if (isMobileAiLayout()) {
|
||||
title.textContent = sessionTitle && sessionTitle !== "新对话"
|
||||
? sessionTitle
|
||||
: modeLabel;
|
||||
@@ -3426,7 +3437,7 @@
|
||||
const mode =
|
||||
(aiChatSessionCache && aiChatSessionCache.bot_mode) === "general" ? "general" : "trading";
|
||||
updateAiBotTabs(mode);
|
||||
if (isMobileLayout()) {
|
||||
if (isMobileAiLayout()) {
|
||||
localStorage.setItem(AI_MOBILE_TAB_KEY, mode);
|
||||
applyAiMobileTab(mode);
|
||||
}
|
||||
@@ -3462,7 +3473,7 @@
|
||||
applyAiMobileTab();
|
||||
await loadAiChatSession();
|
||||
const mobTab = normalizeAiMobileTab(localStorage.getItem(AI_MOBILE_TAB_KEY) || "trading");
|
||||
if (isMobileLayout() && AI_MOBILE_CHAT_TABS.has(mobTab)) {
|
||||
if (isMobileAiLayout() && AI_MOBILE_CHAT_TABS.has(mobTab)) {
|
||||
const input = document.getElementById("ai-chat-input");
|
||||
if (input && !aiChatLoading) {
|
||||
setTimeout(() => input.focus(), 80);
|
||||
@@ -3484,7 +3495,7 @@
|
||||
renderAiChatMessages(aiChatSessionCache);
|
||||
renderAiChatHistory(aiChatSessionsCache);
|
||||
updateAiBotTabs(mode);
|
||||
if (isMobileLayout()) {
|
||||
if (isMobileAiLayout()) {
|
||||
localStorage.setItem(AI_MOBILE_TAB_KEY, mode);
|
||||
applyAiMobileTab(mode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user