// Slim Budget 데스크톱(Electron) 메인 프로세스. // dist(웹 빌드, --mode electron)를 창에 로드한다. 백엔드는 https://app.sblog.kr/api 사용. const { app, BrowserWindow, shell } = require('electron') const path = require('path') function createWindow() { const win = new BrowserWindow({ width: 1200, height: 820, minWidth: 360, minHeight: 560, backgroundColor: '#1a1a1a', title: 'Slim Budget', webPreferences: { contextIsolation: true, nodeIntegration: false, // file:// 출처에서 자기 백엔드(https://app.sblog.kr/api) 호출 시 CORS 차단을 피한다. // 신뢰된 로컬 dist + 자체 API 만 로드하는 데스크톱 클라이언트라 허용 가능한 완화. webSecurity: false, }, }) // 기본 메뉴바 제거(앱 자체 내비게이션 사용) win.removeMenu() win.loadFile(path.join(__dirname, '..', 'dist', 'index.html')) // 외부 링크(target=_blank 등)는 기본 브라우저로 열기 win.webContents.setWindowOpenHandler(({ url }) => { if (/^https?:\/\//i.test(url)) shell.openExternal(url) return { action: 'deny' } }) } app.whenReady().then(() => { createWindow() app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow() }) }) app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit() })