diff --git a/src/main/tipc/setting.ts b/src/main/tipc/setting.ts index 35eba045f..43ebfab2f 100644 --- a/src/main/tipc/setting.ts +++ b/src/main/tipc/setting.ts @@ -1,5 +1,6 @@ import { createRequire } from "node:module" +import type { BrowserWindow } from "electron" import { app, nativeTheme } from "electron" import { setDockCount } from "../lib/dock" @@ -46,4 +47,16 @@ export const settingRoute = { setDockBadge: t.procedure.input().action(async ({ input }) => { setDockCount(input) }), + getWindowIsMaximized: t.procedure + .input() + .action(async ({ context }) => { + const window: BrowserWindow | null = ( + context.sender as Sender + ).getOwnerBrowserWindow() + return window?.isMaximized() + }), +} + +interface Sender extends Electron.WebContents { + getOwnerBrowserWindow: () => Electron.BrowserWindow | null } diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 9fcae7acb..3e3028d74 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -6,7 +6,7 @@ import { env } from "../../env.js" import { useAppIsReady } from "./atoms/app" import { useUISettingKey } from "./atoms/settings/ui" import { appLog } from "./lib/log" -import { getOS } from "./lib/utils" +import { cn, getOS } from "./lib/utils" import { Titlebar } from "./modules/app/Titlebar.js" import { RootProviders } from "./providers/root-providers" import { handlers } from "./tipc" @@ -44,15 +44,15 @@ function App() { const windowsElectron = window.electron && getOS() === "Windows" return ( <> - {window.electron && ( -
- {windowsElectron && } -
- )} + {window.electron && ( +
+ {windowsElectron && } +
+ )}
diff --git a/src/renderer/src/modules/app/Titlebar.tsx b/src/renderer/src/modules/app/Titlebar.tsx index 567e9b71e..f0c9ba386 100644 --- a/src/renderer/src/modules/app/Titlebar.tsx +++ b/src/renderer/src/modules/app/Titlebar.tsx @@ -1,4 +1,5 @@ import { tipcClient } from "@renderer/lib/client" +import { useQuery } from "@tanstack/react-query" import { useForceUpdate } from "framer-motion" import { useEffect } from "react" import { useLocation } from "react-router-dom" @@ -9,10 +10,15 @@ export const Titlebar = () => { useEffect(() => { update() }, [location]) + const { data: isMaximized, refetch } = useQuery({ + queryFn: () => tipcClient?.getWindowIsMaximized(), + queryKey: ["windowIsMaximized"], + }) + return (
+ +