fix(sync): bind sync engine to its user DB, scope instructions/templates per account, harden navigation
This commit is contained in:
parent
1b8fe445f3
commit
9aa7302944
30 changed files with 2614 additions and 386 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// src/main/windows/WindowManager.ts
|
||||
// 설계서 01 WindowManagerService: 메인 윈도우 + 팝업 프리로딩 + 2-phase 리사이즈
|
||||
|
||||
import { BrowserWindow, shell, screen, ipcMain, Menu, clipboard } from 'electron'
|
||||
import { app, BrowserWindow, screen, ipcMain, Menu, clipboard } from 'electron'
|
||||
import { join } from 'path'
|
||||
import { is } from '@electron-toolkit/utils'
|
||||
import { WINDOW_SIZE } from '@d3ro/core/constants'
|
||||
|
|
@ -15,7 +15,8 @@ import {
|
|||
type KeyBindingActionId
|
||||
} from '@d3ro/core/keybinding'
|
||||
import { getLogger } from '../services/LoggerService'
|
||||
import { getIsQuitting } from '../lifecycle'
|
||||
import { getIsQuitting, setIsQuitting } from '../lifecycle'
|
||||
import { hardenWebContents } from './web-contents-hardening'
|
||||
import { configGet, configSet } from '../services/ConfigService'
|
||||
import { buildPopupThemeCss } from '@d3ro/ui/theme-vars'
|
||||
import { getI18n } from '@d3ro/i18n'
|
||||
|
|
@ -269,6 +270,25 @@ export function getMainWindow(): BrowserWindow | null {
|
|||
return mainWindow
|
||||
}
|
||||
|
||||
/** 부트스트랩이 메인 창을 한 번이라도 만들었는지 — 그 전에는 다시 만들지 않는다(중복 창 방지). */
|
||||
let mainWindowCreated = false
|
||||
|
||||
/**
|
||||
* 메인 창을 앞으로 가져온다. 이미 한 번 만들어진 뒤 닫혀 없으면 다시 만든다(트레이 '표시'·두 번째 실행).
|
||||
* 부트스트랩 전이면 null.
|
||||
*/
|
||||
export function showMainWindow(): BrowserWindow | null {
|
||||
let win = mainWindow && !mainWindow.isDestroyed() ? mainWindow : null
|
||||
if (!win) {
|
||||
if (!mainWindowCreated) return null
|
||||
win = createMainWindow()
|
||||
}
|
||||
if (win.isMinimized()) win.restore()
|
||||
win.show()
|
||||
win.focus()
|
||||
return win
|
||||
}
|
||||
|
||||
export function createMainWindow(): BrowserWindow {
|
||||
const primaryDisplay = screen.getPrimaryDisplay()
|
||||
const { width: screenWidth, height: screenHeight } = primaryDisplay.workAreaSize
|
||||
|
|
@ -302,6 +322,7 @@ export function createMainWindow(): BrowserWindow {
|
|||
}
|
||||
})
|
||||
|
||||
mainWindowCreated = true
|
||||
mainWindow.setSkipTaskbar(false)
|
||||
|
||||
// Alt 키로 메뉴 활성화 방지: 메뉴 완전 제거
|
||||
|
|
@ -320,11 +341,18 @@ export function createMainWindow(): BrowserWindow {
|
|||
})
|
||||
|
||||
mainWindow.on('close', (event) => {
|
||||
if (!getIsQuitting() && configGet('closeToTray')) {
|
||||
if (getIsQuitting()) return
|
||||
if (configGet('closeToTray')) {
|
||||
event.preventDefault()
|
||||
mainWindow?.hide()
|
||||
logger.info('Main window hidden to tray')
|
||||
return
|
||||
}
|
||||
// 트레이로 숨기지 않는 설정이면 창 닫기 = 앱 종료. 숨은 팝업이 남아 있어 window-all-closed가
|
||||
// 오지 않으므로, 그대로 두면 다시 열 수 없는 창 없는 프로세스가 남는다.
|
||||
setIsQuitting(true)
|
||||
logger.info('Main window closed with closeToTray=false — quitting')
|
||||
app.quit()
|
||||
})
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
|
|
@ -335,10 +363,8 @@ export function createMainWindow(): BrowserWindow {
|
|||
logger.info(`[Renderer] [${level}] ${message} (${sourceId}:${line})`)
|
||||
})
|
||||
|
||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||
shell.openExternal(details.url)
|
||||
return { action: 'deny' }
|
||||
})
|
||||
// 앱 밖 링크는 창 안에서 열지 않고(원격 페이지가 preload API를 얻지 못하게) 허용 scheme만 브라우저로 넘긴다.
|
||||
hardenWebContents(mainWindow)
|
||||
|
||||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
||||
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'])
|
||||
|
|
@ -384,6 +410,7 @@ function createRecordingTipWindow(): BrowserWindow {
|
|||
backgroundThrottling: false
|
||||
}
|
||||
})
|
||||
hardenWebContents(win)
|
||||
|
||||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
||||
win.loadURL(`${process.env['ELECTRON_RENDERER_URL']}/popups/recording-tip/index.html`)
|
||||
|
|
@ -496,6 +523,7 @@ function createResultPopupWindow(): BrowserWindow {
|
|||
nodeIntegration: false
|
||||
}
|
||||
})
|
||||
hardenWebContents(win)
|
||||
|
||||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
||||
win.loadURL(`${process.env['ELECTRON_RENDERER_URL']}/popups/result-popup/index.html`)
|
||||
|
|
@ -579,6 +607,7 @@ function createHistoryPopupWindow(): BrowserWindow {
|
|||
nodeIntegration: false
|
||||
}
|
||||
})
|
||||
hardenWebContents(win)
|
||||
|
||||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
||||
win.loadURL(`${process.env['ELECTRON_RENDERER_URL']}/popups/history-popup/index.html`)
|
||||
|
|
@ -671,6 +700,7 @@ function createCommandPopupWindow(): BrowserWindow {
|
|||
nodeIntegration: false
|
||||
}
|
||||
})
|
||||
hardenWebContents(win)
|
||||
|
||||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
||||
win.loadURL(`${process.env['ELECTRON_RENDERER_URL']}/popups/command-popup/index.html`)
|
||||
|
|
@ -781,6 +811,7 @@ function createCaptionOverlayWindow(): BrowserWindow {
|
|||
nodeIntegration: false
|
||||
}
|
||||
})
|
||||
hardenWebContents(win)
|
||||
|
||||
// 클릭 통과: 마우스 이벤트를 무시하되, CSS hover 등을 위해 forward 활성화
|
||||
win.setIgnoreMouseEvents(true, { forward: true })
|
||||
|
|
@ -936,6 +967,7 @@ function createSuggestionOverlayWindow(): BrowserWindow {
|
|||
backgroundThrottling: false
|
||||
}
|
||||
})
|
||||
hardenWebContents(win)
|
||||
|
||||
applySuggestionOverlayMouseMode(win)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue