From 1a38ce8c77126884d4aa609c8633f22395ef5b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=93=E9=BC=A0?= <71394853+hamster1963@users.noreply.github.com> Date: Wed, 12 Mar 2025 09:18:31 +0800 Subject: [PATCH] feat: improve inline settings handling for mobile responsiveness (#34) * feat: improve inline settings handling for mobile responsiveness * chore: auto-fix linting and formatting issues --- src/pages/Server.tsx | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/pages/Server.tsx b/src/pages/Server.tsx index cc77b93..9da1650 100644 --- a/src/pages/Server.tsx +++ b/src/pages/Server.tsx @@ -62,11 +62,25 @@ export default function Servers() { }, []) useEffect(() => { - const inlineState = localStorage.getItem("inline") - if (window.ForceCardInline) { - setInline("1") - } else if (inlineState !== null) { - setInline(inlineState) + const checkInlineSettings = () => { + const isMobile = window.innerWidth < 768 + + if (!isMobile) { + const inlineState = localStorage.getItem("inline") + if (window.ForceCardInline) { + setInline("1") + } else if (inlineState !== null) { + setInline(inlineState) + } + } + } + + checkInlineSettings() + + window.addEventListener("resize", checkInlineSettings) + + return () => { + window.removeEventListener("resize", checkInlineSettings) } }, [])