MCPcopy Create free account
hub / github.com/codeHappyDananx/SpecWave / createWindow

Function createWindow

electron/main.js:551–592  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

549}
550
551function createWindow() {
552 loadPreferences()
553
554 const { windowBounds } = userPreferences
555
556 mainWindow = new BrowserWindow({
557 width: windowBounds.width,
558 height: windowBounds.height,
559 x: windowBounds.x,
560 y: windowBounds.y,
561 minWidth: 900,
562 minHeight: 600,
563 webPreferences: {
564 preload: path.join(__dirname, 'preload.js'),
565 contextIsolation: true,
566 nodeIntegration: false
567 },
568 show: false
569 })
570
571 // 开发模式加载 Vite 服务器,生产模式加载打包文件
572 if (process.env.NODE_ENV === 'development' || !app.isPackaged) {
573 mainWindow.loadURL('http://localhost:5173')
574 mainWindow.webContents.openDevTools()
575 } else {
576 // 生产模式:加载打包后的文件
577 mainWindow.loadFile(path.join(__dirname, '../dist/index.html'))
578 }
579
580 mainWindow.once('ready-to-show', () => {
581 mainWindow.show()
582 })
583
584 // 保存窗口位置和大小
585 mainWindow.on('close', () => {
586 const bounds = mainWindow.getBounds()
587 userPreferences.windowBounds = bounds
588 savePreferences()
589 })
590
591 refreshApplicationMenu()
592}
593
594// 验证是否为有效的 OpenSpec 项目
595function isValidOpenSpecProject(dirPath) {

Callers 1

main.jsFile · 0.85

Calls 3

loadPreferencesFunction · 0.85
refreshApplicationMenuFunction · 0.85
savePreferencesFunction · 0.70

Tested by

no test coverage detected