MCPcopy Create free account
hub / github.com/experdot/pointer / createWindow

Function createWindow

src/main/window.ts:30–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28}
29
30export function createWindow(): void {
31 const mainWindowState = windowStateKeeper({
32 defaultWidth: 960,
33 defaultHeight: 640,
34 fullScreen: false,
35 maximize: false
36 })
37 // Create the browser window.
38 const mainWindow = new BrowserWindow({
39 x: mainWindowState.x,
40 y: mainWindowState.y,
41 width: mainWindowState.width,
42 height: mainWindowState.height,
43 minWidth: 480,
44 minHeight: 320,
45 show: false,
46 autoHideMenuBar: true,
47 // macOS 使用原生窗口控制按钮,其他平台使用自定义
48 ...(process.platform === 'darwin'
49 ? {
50 titleBarStyle: 'hiddenInset', // macOS: 显示原生控制按钮
51 trafficLightPosition: { x: 10, y: 10 } // 调整原生按钮位置
52 }
53 : {
54 frame: false, // Windows/Linux: 完全自定义
55 titleBarStyle: 'hidden'
56 }),
57 ...(process.platform === 'linux' ? { icon } : {}),
58 webPreferences: {
59 preload: join(__dirname, '../preload/index.js'),
60 sandbox: false
61 }
62 })
63
64 mainWindowState.manage(mainWindow)
65 if (mainWindowState.isMaximized) {
66 mainWindow.maximize()
67 }
68
69 mainWindow.on('ready-to-show', () => {
70 mainWindow.show()
71 })
72
73 mainWindow.webContents.setWindowOpenHandler((details) => {
74 shell.openExternal(details.url)
75 return { action: 'deny' }
76 })
77
78 mainWindow.webContents.on('before-input-event', (event, input) => {
79 const action = resolveForwardedShortcutAction(input)
80 if (!action) {
81 return
82 }
83
84 event.preventDefault()
85 mainWindow.webContents.send('shortcut:action', action)
86 })
87

Callers 1

index.tsFile · 0.90

Calls 1

Tested by

no test coverage detected