diff --git a/src/preload/index.d.ts b/src/preload/index.d.ts index 7cf58d6a2..86e87c1c5 100644 --- a/src/preload/index.d.ts +++ b/src/preload/index.d.ts @@ -4,5 +4,6 @@ declare global { interface Window { electron?: ElectronAPI api: unknown + platform: NodeJS.Platform } } diff --git a/src/preload/index.ts b/src/preload/index.ts index 013b57607..2a22d0f35 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -11,6 +11,7 @@ if (process.contextIsolated) { try { contextBridge.exposeInMainWorld("electron", electronAPI) contextBridge.exposeInMainWorld("api", api) + contextBridge.exposeInMainWorld("platform", process.platform) } catch (error) { console.error(error) } @@ -19,4 +20,6 @@ if (process.contextIsolated) { window.electron = electronAPI // @ts-ignore (define in dts) window.api = api + // @ts-ignore (define in dts) + window.platform = process.platform } diff --git a/src/renderer/src/lib/utils.ts b/src/renderer/src/lib/utils.ts index 4463e56dc..ef5d87ba8 100644 --- a/src/renderer/src/lib/utils.ts +++ b/src/renderer/src/lib/utils.ts @@ -40,6 +40,20 @@ export function getEntriesParams({ export type OS = "macOS" | "iOS" | "Windows" | "Android" | "Linux" | "" export const getOS = memoize((): OS => { + if (window.platform) { + switch (window.platform) { + case "darwin": { + return "macOS" + } + case "win32": { + return "Windows" + } + case "linux": { + return "Linux" + } + } + } + const { userAgent } = window.navigator, { platform } = window.navigator, macosPlatforms = ["Macintosh", "MacIntel", "MacPPC", "Mac68K"], diff --git a/src/renderer/src/main.tsx b/src/renderer/src/main.tsx index 0434c26c6..9e5378d60 100644 --- a/src/renderer/src/main.tsx +++ b/src/renderer/src/main.tsx @@ -20,7 +20,6 @@ const $container = document.querySelector("#root") as HTMLElement if (window.electron && getOS() === "Windows") { $container.style.borderRadius = `${ELECTRON_WINDOWS_RADIUS}px` $container.style.overflow = "hidden" - $container.style.paddingTop = `${ElECTRON_CUSTOM_TITLEBAR_HEIGHT}px` $container.style.background = "var(--fo-background)" document.body.style.cssText += `--fo-window-padding-top: ${ElECTRON_CUSTOM_TITLEBAR_HEIGHT}px; --fo-window-radius: ${ELECTRON_WINDOWS_RADIUS}px;` diff --git a/src/renderer/src/modules/app/Titlebar.tsx b/src/renderer/src/modules/app/Titlebar.tsx index 724bd0e94..2a5a3ab8e 100644 --- a/src/renderer/src/modules/app/Titlebar.tsx +++ b/src/renderer/src/modules/app/Titlebar.tsx @@ -10,7 +10,7 @@ export const Titlebar = () => { return (