From 1c44e19e157ef0c19665902e836462f658a881f3 Mon Sep 17 00:00:00 2001 From: JSR Date: Sat, 21 Mar 2026 10:56:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3App.tsx=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E5=86=B2=E7=AA=81=E5=B9=B6=E4=BF=AE=E5=A4=8D=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 88 ----------------------------------------------------- 1 file changed, 88 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index b881a7d..9fd7faf 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -63,7 +63,6 @@ function MainContent(): React.JSX.Element { const syncCheckingRef = useRef(false) const syncApplyLoadingRef = useRef(false) const lastLocalMutationAtRef = useRef(0) - const lastLandscapeSizeRef = useRef<{ width: number; height: number } | null>(null) const activeMenu = useMemo(() => { const p = location.pathname @@ -285,93 +284,6 @@ function MainContent(): React.JSX.Element { if (key === "settings") navigate("/settings") } -<<<<<<< HEAD -======= - const getMaxWindowSize = () => { - const availableWidth = window.screen?.availWidth || window.innerWidth || 1200 - const availableHeight = window.screen?.availHeight || window.innerHeight || 800 - return { - maxWidth: Math.max(360, Math.round(availableWidth - 64)), - maxHeight: Math.max(640, Math.round(availableHeight - 64)), - } - } - - const getFixedPortraitSize = () => { - const { maxWidth, maxHeight } = getMaxWindowSize() - const phonePortraitBase = { width: 430, height: 932 } - let width = Math.max(360, Math.min(phonePortraitBase.width, maxWidth)) - let height = Math.max(640, Math.min(phonePortraitBase.height, maxHeight)) - - // 保证竖屏高于宽,维持手机风格比例。 - if (height <= width) { - height = Math.min(maxHeight, Math.max(640, Math.round(width * 2.0))) - } - if (height <= width) { - width = Math.max(360, Math.min(maxWidth, Math.round(height * 0.5))) - } - - return { width, height } - } - - const getLandscapeRestoreSize = () => { - const { maxWidth, maxHeight } = getMaxWindowSize() - const fallback = { width: 1180, height: 680 } - const source = lastLandscapeSizeRef.current || fallback - - let width = Math.max(800, Math.min(maxWidth, Math.round(source.width))) - let height = Math.max(600, Math.min(maxHeight, Math.round(source.height))) - if (width < height) { - const swappedWidth = Math.max(800, Math.min(maxWidth, height)) - const swappedHeight = Math.max(600, Math.min(maxHeight, width)) - width = swappedWidth - height = swappedHeight - } - - return { width, height } - } - - const toggleOrientationMode = async () => { - const api = (window as any).api - if (!api) return - - const nextPortraitMode = !isPortraitMode - try { - const maximized = await api.windowIsMaximized() - if (maximized) { - await api.windowMaximize() - } - - if (nextPortraitMode) { - lastLandscapeSizeRef.current = { - width: Math.max(1, Math.round(window.innerWidth || 0)), - height: Math.max(1, Math.round(window.innerHeight || 0)), - } - const targetSize = getFixedPortraitSize() - await api.windowSetResizable(false) - await api.windowResize(targetSize.width, targetSize.height) - setSidebarCollapsed(true) - setFloatingSidebarExpanded(false) - } else { - const targetSize = getLandscapeRestoreSize() - await api.windowSetResizable(true) - await api.windowResize(targetSize.width, targetSize.height) - setSidebarCollapsed(false) - setFloatingSidebarExpanded(false) - } - setIsPortraitMode(nextPortraitMode) - } catch (error) { - messageApi.error(t("common.error")) - console.error("Failed to toggle orientation mode:", error) - } - } - - useEffect(() => { - if (!isPortraitMode || !sidebarCollapsed) { - setFloatingSidebarExpanded(false) - } - }, [isPortraitMode, sidebarCollapsed]) - ->>>>>>> 1fe9dbe66a8a3df649fd86fb5ba64f3178057ec1 const toggleSidebar = () => { if (isPortraitMode && sidebarCollapsed) { setFloatingSidebarExpanded((prev) => !prev)