Files
NFD2NFC/src/main/index.ts
jung-geun 3dff470044 src/main: 트레이/감시자/저장소/IPC/알림 배치 (Electron 메인)
tray.ts: 트레이 아이콘, 팝오버 BrowserWindow 토글, 컨텍스트 메뉴.
watcher.ts: chokidar 감시, dedup TTL 2s, auto/manual 모드, 글로벌 일시정지.
store.ts: userData/store.json 영속화 (watchedDirs/settings/undoLog).
ipc.ts: 18개 IPC 채널 핸들러.
notifier.ts: interval 기반 알림 배치 처리 (알림 폭주 방지).
settings-window.ts: 설정창 BrowserWindow 라이프사이클.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 15:41:08 +09:00

38 lines
970 B
TypeScript

import { app } from 'electron';
import { createTray, destroyTray } from './tray';
import { openSettingsWindow } from './settings-window';
import { registerIpcHandlers } from './ipc';
import * as store from './store';
import * as watcher from './watcher';
// 단일 인스턴스 강제
const gotLock = app.requestSingleInstanceLock();
if (!gotLock) {
app.quit();
}
app.whenReady().then(async () => {
registerIpcHandlers();
createTray();
// 저장된 디렉토리 감시 복원
const dirs = await store.getDirs();
for (const dir of dirs.filter((d) => d.enabled)) {
watcher.startDir(dir).catch(console.error);
}
// 감시 디렉토리가 없으면 설정창 자동 오픈 (첫 실행 안내)
if (dirs.length === 0) {
openSettingsWindow();
}
});
app.on('window-all-closed', () => {
// 트레이 앱은 윈도우를 모두 닫아도 종료하지 않음
});
app.on('will-quit', async () => {
destroyTray();
await watcher.stopAll();
});