diff --git a/src/celemod-ui/src/routes/Home.tsx b/src/celemod-ui/src/routes/Home.tsx index 945fb08..b590637 100644 --- a/src/celemod-ui/src/routes/Home.tsx +++ b/src/celemod-ui/src/routes/Home.tsx @@ -21,7 +21,7 @@ import { } from "../states"; import "./Home.scss"; import { useGlobalContext } from "src/App"; -import { detectDesktopPlatform } from "../tauri/window"; +import { detectDesktopPlatform, isMobileLayout } from "../tauri/window"; import { SteamAccount } from "../components/SteamAccount"; export const Home = () => { @@ -367,33 +367,35 @@ export const Home = () => { {detectDesktopPlatform() === "android" && } -
-
- -

{chinese ? "常用功能" : "Quick access"}

-
-
- {shortcuts.map((shortcut) => ( - - ))} -
-
+ {isMobileLayout() && ( +
+
+ +

{chinese ? "常用功能" : "Quick access"}

+
+
+ {shortcuts.map((shortcut) => ( + + ))} +
+
+ )} {profileEnabled && (
diff --git a/src/celemod-ui/src/tauri/window.ts b/src/celemod-ui/src/tauri/window.ts index b551b97..8e568fe 100644 --- a/src/celemod-ui/src/tauri/window.ts +++ b/src/celemod-ui/src/tauri/window.ts @@ -14,15 +14,22 @@ export function detectDesktopPlatform(): DesktopPlatform { return "linux"; } +/** + * Mobile layout is a property of the platform, not of the window width. + * + * The interface scale is applied with WebView zoom (`setZoom`), which shrinks + * the CSS viewport: a 1100px window at 150% reports `innerWidth === 733`, so a + * `(max-width: 760px)` check switched desktop users to the Android layout + * (sidebar hidden, bottom navigation shown). Desktop windows also cannot get + * narrower than `minWidth` (800px), so the width check only ever fired because + * of that zoom. + */ +export function isMobileLayout(): boolean { + return detectDesktopPlatform() === "android"; +} + export function initializeWindowChrome() { - document.documentElement.dataset.platform = detectDesktopPlatform(); - const compact = window.matchMedia("(max-width: 760px)"); - const updateLayout = () => { - document.documentElement.toggleAttribute( - "data-mobile-layout", - detectDesktopPlatform() === "android" || compact.matches, - ); - }; - updateLayout(); - compact.addEventListener("change", updateLayout); + const platform = detectDesktopPlatform(); + document.documentElement.dataset.platform = platform; + document.documentElement.toggleAttribute("data-mobile-layout", isMobileLayout()); }