frontend: FE-027 隐藏式标题栏红绿灯融入顶栏,防启动白闪与顶栏拖拽区

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
fenghp
2026-06-11 17:13:33 +08:00
co-authored by Cursor
parent 5408f27902
commit ee9e052586
6 changed files with 60 additions and 10 deletions
+14 -1
View File
@@ -1,4 +1,4 @@
const { app, BrowserWindow, ipcMain, dialog, shell, nativeImage } = require("electron")
const { app, BrowserWindow, ipcMain, dialog, shell, nativeImage, nativeTheme } = require("electron")
const path = require("node:path")
const fs = require("node:fs")
const os = require("node:os")
@@ -284,7 +284,16 @@ function createWindow() {
const mainWindow = new BrowserWindow({
width: 1280,
height: 840,
minWidth: 980,
minHeight: 640,
title: "MacTFS",
// 预设与主题一致的背景色并延迟显示,避免启动白闪。
show: false,
backgroundColor: nativeTheme.shouldUseDarkColors ? "#1d1d20" : "#fafafa",
// macOS 隐藏系统标题栏,红绿灯融入应用顶栏;其它平台回退系统标题栏。
...(process.platform === "darwin"
? { titleBarStyle: "hiddenInset", trafficLightPosition: { x: 16, y: 16 } }
: {}),
...(iconPath ? { icon: nativeImage.createFromPath(iconPath) } : {}),
webPreferences: {
preload: path.join(__dirname, "preload.cjs"),
@@ -293,6 +302,10 @@ function createWindow() {
},
})
mainWindow.once("ready-to-show", () => {
mainWindow.show()
})
if (process.env.NODE_ENV === "development") {
mainWindow.loadURL("http://localhost:5173")
return