From 35e59d5052987665dc3d658c739fe2007e462f9f Mon Sep 17 00:00:00 2001 From: sw3205933776 <3205933776@qq.com> Date: Fri, 31 Oct 2025 18:01:58 +0800 Subject: [PATCH 1/2] enhance: add close button to login page --- electron/main/index.ts | 1 + src/components/TopBar/index.tsx | 4 +- src/components/WindowControls/index.css | 25 ++++++ src/components/WindowControls/index.tsx | 60 ++++++++++++++ src/pages/Login.tsx | 74 ++++++++++++++++-- utils/__pycache__/__init__.cpython-310.pyc | Bin 155 -> 129 bytes .../traceroot_wrapper.cpython-310.pyc | Bin 2359 -> 2341 bytes 7 files changed, 157 insertions(+), 7 deletions(-) create mode 100644 src/components/WindowControls/index.css create mode 100644 src/components/WindowControls/index.tsx diff --git a/electron/main/index.ts b/electron/main/index.ts index 7c87795a2..911e0794b 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -582,6 +582,7 @@ function registerIpcHandlers() { // ==================== window control handler ==================== ipcMain.on('window-close', (_, data) => { + console.log('window-close', data); if(data.isForceQuit) { return app?.quit() } diff --git a/src/components/TopBar/index.tsx b/src/components/TopBar/index.tsx index 0e6c4c89f..293a63a56 100644 --- a/src/components/TopBar/index.tsx +++ b/src/components/TopBar/index.tsx @@ -12,7 +12,7 @@ import { Power, ChevronDown, ChevronLeft, - House, + LayoutGrid, Share, } from "lucide-react"; import "./index.css"; @@ -246,7 +246,7 @@ function HeaderWin() { className="no-drag" onClick={() => navigate("/history")} > - + (null); + const [platform, setPlatform] = useState(""); + + useEffect(() => { + const p = window.electronAPI.getPlatform(); + setPlatform(p); + + if (p === "darwin") { + if (controlsRef.current) { + controlsRef.current.style.display = "none"; + } + } + }, []); + + if (platform === "darwin") { + return null; + } + + return ( + + window.electronAPI.minimizeWindow()} + > + + + window.electronAPI.toggleMaximizeWindow()} + > + + + { + e.stopPropagation(); + e.preventDefault(); + // Use forceQuit=true to bypass before-close handler + window.electronAPI.closeWindow(true); + }} + onMouseDown={(e) => { + e.stopPropagation(); + }} + > + + + + ); +} + diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx index aa2c79f7c..3bd0e87f1 100644 --- a/src/pages/Login.tsx +++ b/src/pages/Login.tsx @@ -1,6 +1,6 @@ import { useAuthStore } from "@/store/authStore"; import { useNavigate, useLocation } from "react-router-dom"; -import { useCallback, useEffect, useState } from "react"; +import { useCallback, useEffect, useState, useRef } from "react"; import { useStackApp } from "@stackframe/react"; import loginGif from "@/assets/login.gif"; import { Button } from "@/components/ui/button"; @@ -14,6 +14,7 @@ import eyeOff from "@/assets/eye-off.svg"; import { proxyFetchPost } from "@/api/http"; import { hasStackKeys } from "@/lib"; import { useTranslation } from "react-i18next"; +import WindowControls from "@/components/WindowControls"; const HAS_STACK_KEYS = hasStackKeys(); let lock = false; @@ -34,6 +35,8 @@ export default function Login() { }); const [isLoading, setIsLoading] = useState(false); const [generalError, setGeneralError] = useState(""); + const titlebarRef = useRef(null); + const [platform, setPlatform] = useState(""); const validateEmail = (email: string) => { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; @@ -211,12 +214,72 @@ export default function Login() { }; }, []); + useEffect(() => { + const p = window.electronAPI.getPlatform(); + setPlatform(p); + + if (platform === "darwin") { + titlebarRef.current?.classList.add("mac"); + } + }, [platform]); + + // Handle before-close event for login page + useEffect(() => { + const handleBeforeClose = () => { + // On login page, always close directly without confirmation + window.electronAPI.closeWindow(true); + }; + + window.ipcRenderer?.on("before-close", handleBeforeClose); + + return () => { + window.ipcRenderer?.off("before-close", handleBeforeClose); + }; + }, []); + return ( - - - + + {/* Titlebar with drag region and window controls */} + + {/* Left spacer for macOS */} + + {platform === "darwin" && Eigent} + + + {/* Center drag region */} + + + + + {/* Right window controls */} + e.stopPropagation()} + onClick={(e) => e.stopPropagation()} + > + + - + + {/* Main content - image extends to top, form has padding */} + + + + + @@ -319,6 +382,7 @@ export default function Login() { > {t("layout.privacy-policy")} + ); diff --git a/utils/__pycache__/__init__.cpython-310.pyc b/utils/__pycache__/__init__.cpython-310.pyc index 664fc47bd9826a3e449c88dcd75e10bb0081579c..744ca18d8babafde0e9abf569fd73ab4db33e075 100644 GIT binary patch delta 49 zcmbQu*vQD8&&$ij00h#{zD?w|ky3HCig7F`%FjwoE{RFaOi#@#i773~%qfnUSgim6 DQFRZ< delta 75 zcmZoe)=$kVO3l=FNiEJU$uH0^N-f9-ie;v! W=9L&47#TsC`lThAImP-D6BPhss~E8W diff --git a/utils/__pycache__/traceroot_wrapper.cpython-310.pyc b/utils/__pycache__/traceroot_wrapper.cpython-310.pyc index 6d17bd26bce46b7f7dbc33d7dcbc1718ea513c11..b86cd68b6fed6395ca926dffc117d349820efd12 100644 GIT binary patch delta 112 zcmdlkv{Z;UpO=@50SF$|vSdEn$h(e7O4r#c#<8F%KPxr4BqlX8JvFZ+rnDq8r#NQw zd!`GFTv2?*sYPX($*J*^53)>URG1vj8o{VIc>}9DqsrzRtddNODw994Ycr}&mg9&6 PvTHf)8Pz85<){Jx6#FC9 delta 130 zcmZ1~v|WfdpO=@50SIEYf6utLk#`-FiMxJiacWVqerjG(YNozRYH@Z+et~{bYC%3w zEHgbduf)*6$Oy{RFD=Q;Dc0Y7mFWT_(=E2i>sh8UDo%D~jbK!oJdahKQFZe%R!JsC b)yWUowHehW^Kirg+1VWSjOvqDb5sEUB+n_} From 4a62c974e35509c59af8f4fe2bdd74704f9ff09c Mon Sep 17 00:00:00 2001 From: puzhen <1303385763@qq.com> Date: Thu, 6 Nov 2025 22:36:24 +0100 Subject: [PATCH 2/2] update --- electron/main/index.ts | 1 - src/components/WindowControls/index.tsx | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index 911e0794b..7c87795a2 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -582,7 +582,6 @@ function registerIpcHandlers() { // ==================== window control handler ==================== ipcMain.on('window-close', (_, data) => { - console.log('window-close', data); if(data.isForceQuit) { return app?.quit() } diff --git a/src/components/WindowControls/index.tsx b/src/components/WindowControls/index.tsx index 59416d6b1..245175101 100644 --- a/src/components/WindowControls/index.tsx +++ b/src/components/WindowControls/index.tsx @@ -45,8 +45,9 @@ export default function WindowControls() { onClick={(e) => { e.stopPropagation(); e.preventDefault(); - // Use forceQuit=true to bypass before-close handler - window.electronAPI.closeWindow(true); + // Trigger window close - this will go through the before-close handler + // which checks if tasks are running and shows confirmation if needed + window.electronAPI.closeWindow(false); }} onMouseDown={(e) => { e.stopPropagation();