Commit 647e5838 authored by AI-甘富林's avatar AI-甘富林

fix(desktop): 优化窗口管理和图标支持

- 添加Menu导入并隐藏默认应用菜单
- 新增窗口图标解析函数,支持Windows打包场景
- 修改窗口背景色为浅蓝白色#f4f8ff
- 启用autoHideMenuBar提升用户体验
Co-Authored-By: 's avatarClaude Opus 4.7 <noreply@anthropic.com>
parent 7da00a3c
import { BrowserWindow, app } from "electron"; import { BrowserWindow, Menu, app } from "electron";
import path from "node:path"; import path from "node:path";
import { pathToFileURL } from "node:url"; import { pathToFileURL } from "node:url";
...@@ -10,14 +10,25 @@ function resolveRendererEntry(): string { ...@@ -10,14 +10,25 @@ function resolveRendererEntry(): string {
return path.join(app.getAppPath(), "dist", "renderer", "index.html"); return path.join(app.getAppPath(), "dist", "renderer", "index.html");
} }
function resolveWindowIcon(): string | undefined {
return process.platform === "win32"
? (app.isPackaged
? path.join(process.resourcesPath, "brand-icon.ico")
: path.join(app.getAppPath(), "build", "icons", "brand-icon.ico"))
: undefined;
}
export function createMainWindow(smokeEnabled = false): BrowserWindow { export function createMainWindow(smokeEnabled = false): BrowserWindow {
Menu.setApplicationMenu(null);
const preloadPath = path.join(__dirname, "..", "preload", "index.js"); const preloadPath = path.join(__dirname, "..", "preload", "index.js");
const window = new BrowserWindow({ const window = new BrowserWindow({
width: 1400, width: 1400,
height: 920, height: 920,
minWidth: 960, minWidth: 960,
minHeight: 640, minHeight: 640,
backgroundColor: "#0f172a", backgroundColor: "#f4f8ff",
autoHideMenuBar: true,
icon: resolveWindowIcon(),
webPreferences: { webPreferences: {
additionalArguments: smokeEnabled ? ["--qjc-smoke"] : [], additionalArguments: smokeEnabled ? ["--qjc-smoke"] : [],
contextIsolation: true, contextIsolation: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment