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);
|
return (settingsCache?.exchanges || []).filter((x) => x.enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 窄屏布局:仅按视口宽度,监控区/行情等共用 */
|
||||||
function isMobileLayout() {
|
function isMobileLayout() {
|
||||||
if (window.matchMedia("(max-width: 720px)").matches) return true;
|
return window.matchMedia("(max-width: 720px)").matches;
|
||||||
if (window.matchMedia("(display-mode: standalone)").matches) return true;
|
}
|
||||||
|
|
||||||
|
/** 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;
|
if (window.navigator && window.navigator.standalone === true) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1054,7 +1065,7 @@
|
|||||||
const layout = document.querySelector(".ai-layout");
|
const layout = document.querySelector(".ai-layout");
|
||||||
const tabs = document.querySelectorAll(".ai-mobile-tab");
|
const tabs = document.querySelectorAll(".ai-mobile-tab");
|
||||||
if (!layout) return;
|
if (!layout) return;
|
||||||
const mobile = isMobileLayout();
|
const mobile = isMobileAiLayout();
|
||||||
if (!mobile) {
|
if (!mobile) {
|
||||||
delete layout.dataset.aiMobileTab;
|
delete layout.dataset.aiMobileTab;
|
||||||
tabs.forEach((btn) => {
|
tabs.forEach((btn) => {
|
||||||
@@ -1099,7 +1110,7 @@
|
|||||||
applyAiMobileTab(tab);
|
applyAiMobileTab(tab);
|
||||||
if (AI_MOBILE_CHAT_TABS.has(tab)) {
|
if (AI_MOBILE_CHAT_TABS.has(tab)) {
|
||||||
const input = document.getElementById("ai-chat-input");
|
const input = document.getElementById("ai-chat-input");
|
||||||
if (input && isMobileLayout()) input.focus();
|
if (input && isMobileAiLayout()) input.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1126,7 +1137,7 @@
|
|||||||
|
|
||||||
syncHubAiMobileViewport = () => {
|
syncHubAiMobileViewport = () => {
|
||||||
const onAi = document.body.classList.contains("hub-page-ai");
|
const onAi = document.body.classList.contains("hub-page-ai");
|
||||||
if (!onAi || !isMobileLayout()) {
|
if (!onAi || !isMobileAiLayout()) {
|
||||||
shell.style.removeProperty("height");
|
shell.style.removeProperty("height");
|
||||||
shell.style.removeProperty("max-height");
|
shell.style.removeProperty("max-height");
|
||||||
shell.style.removeProperty("width");
|
shell.style.removeProperty("width");
|
||||||
@@ -3350,7 +3361,7 @@
|
|||||||
if (title) {
|
if (title) {
|
||||||
const modeLabel = botMode === "general" ? "普通聊天" : "交易教练";
|
const modeLabel = botMode === "general" ? "普通聊天" : "交易教练";
|
||||||
const sessionTitle = session && session.title ? String(session.title) : "";
|
const sessionTitle = session && session.title ? String(session.title) : "";
|
||||||
if (isMobileLayout()) {
|
if (isMobileAiLayout()) {
|
||||||
title.textContent = sessionTitle && sessionTitle !== "新对话"
|
title.textContent = sessionTitle && sessionTitle !== "新对话"
|
||||||
? sessionTitle
|
? sessionTitle
|
||||||
: modeLabel;
|
: modeLabel;
|
||||||
@@ -3426,7 +3437,7 @@
|
|||||||
const mode =
|
const mode =
|
||||||
(aiChatSessionCache && aiChatSessionCache.bot_mode) === "general" ? "general" : "trading";
|
(aiChatSessionCache && aiChatSessionCache.bot_mode) === "general" ? "general" : "trading";
|
||||||
updateAiBotTabs(mode);
|
updateAiBotTabs(mode);
|
||||||
if (isMobileLayout()) {
|
if (isMobileAiLayout()) {
|
||||||
localStorage.setItem(AI_MOBILE_TAB_KEY, mode);
|
localStorage.setItem(AI_MOBILE_TAB_KEY, mode);
|
||||||
applyAiMobileTab(mode);
|
applyAiMobileTab(mode);
|
||||||
}
|
}
|
||||||
@@ -3462,7 +3473,7 @@
|
|||||||
applyAiMobileTab();
|
applyAiMobileTab();
|
||||||
await loadAiChatSession();
|
await loadAiChatSession();
|
||||||
const mobTab = normalizeAiMobileTab(localStorage.getItem(AI_MOBILE_TAB_KEY) || "trading");
|
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");
|
const input = document.getElementById("ai-chat-input");
|
||||||
if (input && !aiChatLoading) {
|
if (input && !aiChatLoading) {
|
||||||
setTimeout(() => input.focus(), 80);
|
setTimeout(() => input.focus(), 80);
|
||||||
@@ -3484,7 +3495,7 @@
|
|||||||
renderAiChatMessages(aiChatSessionCache);
|
renderAiChatMessages(aiChatSessionCache);
|
||||||
renderAiChatHistory(aiChatSessionsCache);
|
renderAiChatHistory(aiChatSessionsCache);
|
||||||
updateAiBotTabs(mode);
|
updateAiBotTabs(mode);
|
||||||
if (isMobileLayout()) {
|
if (isMobileAiLayout()) {
|
||||||
localStorage.setItem(AI_MOBILE_TAB_KEY, mode);
|
localStorage.setItem(AI_MOBILE_TAB_KEY, mode);
|
||||||
applyAiMobileTab(mode);
|
applyAiMobileTab(mode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -557,6 +557,6 @@
|
|||||||
<script src="/assets/funds.js?v=20260609-hub-funds-fold"></script>
|
<script src="/assets/funds.js?v=20260609-hub-funds-fold"></script>
|
||||||
<script src="/assets/dashboard.js?v=20260612-dash-monitor-count"></script>
|
<script src="/assets/dashboard.js?v=20260612-dash-monitor-count"></script>
|
||||||
<script src="/assets/ai_review_render.js?v=2"></script>
|
<script src="/assets/ai_review_render.js?v=2"></script>
|
||||||
<script src="/assets/app.js?v=20260612-hub-ai-pwa-nav"></script>
|
<script src="/assets/app.js?v=20260612-monitor-desktop-layout"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user