종료 보완: DB 를 닫은 뒤 온 변환 성공 응답도 버림 · 트레이와 갱신 타이머를 TrayShell 로 묶어 종료 · 없어진 트레이 처리 회귀 시험
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import { Finetuner } from './finetune.js';
|
||||
import type { AuthView } from './api-types.js';
|
||||
import { buildState, registerIpc } from './ipc.js';
|
||||
import { brandDir, rendererDir, replayToolPath, resolveDataDir, resourcesDir, workerCommand } from './paths.js';
|
||||
import { TrayShell } from './tray-shell.js';
|
||||
|
||||
// 인증서 검증을 끄는 환경변수(NODE_TLS_REJECT_UNAUTHORIZED=0)는 무시한다. fuses 로 막지 못하는 변수라 가장 먼저 지운다
|
||||
hardenTlsEnv();
|
||||
@@ -33,9 +34,7 @@ let ft: Finetuner | null = null;
|
||||
let settings: SettingsStore | null = null;
|
||||
let auth: AppAuth | null = null;
|
||||
let win: BrowserWindow | null = null;
|
||||
let tray: Tray | null = null;
|
||||
/** 트레이 · 상태 갱신 타이머 (종료할 때 멈춘다) */
|
||||
const timers: NodeJS.Timeout[] = [];
|
||||
const trayShell = new TrayShell<Tray>();
|
||||
let quitting = false;
|
||||
const dataDir = resolveDataDir(opt('data-dir'));
|
||||
|
||||
@@ -150,8 +149,8 @@ function closeSplash(): void {
|
||||
}
|
||||
|
||||
function updateTray(): void {
|
||||
// Windows 로그오프 등으로 Electron 이 트레이를 먼저 없앤 경우에도 오류 창이 뜨지 않게
|
||||
if (!tray || tray.isDestroyed()) return;
|
||||
const tray = trayShell.get();
|
||||
if (!tray) return;
|
||||
if (!core) {
|
||||
tray.setImage(trayImage('off'));
|
||||
tray.setToolTip(`겜녹이\n${auth?.state.status === 'not_registered' ? '등록되지 않은 아이디' : '로그인이 필요합니다'}`);
|
||||
@@ -171,7 +170,8 @@ function updateTray(): void {
|
||||
}
|
||||
|
||||
function buildTrayMenu(): void {
|
||||
if (!tray || tray.isDestroyed()) return;
|
||||
const tray = trayShell.get();
|
||||
if (!tray) return;
|
||||
if (!core) {
|
||||
tray.setContextMenu(
|
||||
Menu.buildFromTemplate([
|
||||
@@ -207,10 +207,7 @@ async function quit(): Promise<void> {
|
||||
log.error('종료 중 오류', e);
|
||||
}
|
||||
// 트레이 갱신 타이머가 app.exit 사이에 한 번 더 돌면 'Tray is destroyed' 오류 창이 뜬다
|
||||
for (const t of timers) clearInterval(t);
|
||||
const tr = tray;
|
||||
tray = null;
|
||||
tr?.destroy();
|
||||
trayShell.dispose();
|
||||
app.exit(0);
|
||||
}
|
||||
|
||||
@@ -383,25 +380,26 @@ app.whenReady().then(async () => {
|
||||
if (starting) await starting;
|
||||
},
|
||||
});
|
||||
tray = new Tray(trayImage('off'));
|
||||
const tray = new Tray(trayImage('off'));
|
||||
tray.on('click', () => openWindow());
|
||||
trayShell.set(tray);
|
||||
refreshShell();
|
||||
a.on('change', onAuthChange);
|
||||
// 시작할 때 확인 → 10분마다 다시 확인 (등록 해제되면 바로 잠김). 서버에 못 붙어 막힌 상태면 1분마다 다시 시도
|
||||
let lastCheck = Date.now();
|
||||
const first = a.check();
|
||||
timers.push(setInterval(() => {
|
||||
trayShell.every(15000, () => {
|
||||
const st = a.state.status;
|
||||
if ((st === 'ok' && Date.now() - lastCheck > 10 * 60000) || (st === 'error' && Date.now() - lastCheck > 60000) || (st === 'ok' && a.state.offline && Date.now() - lastCheck > 60000)) {
|
||||
lastCheck = Date.now();
|
||||
void a.check().then(syncNames);
|
||||
}
|
||||
}, 15000));
|
||||
timers.push(setInterval(() => {
|
||||
});
|
||||
trayShell.every(1500, () => {
|
||||
updateTray();
|
||||
buildTrayMenu();
|
||||
pushState();
|
||||
}, 1500));
|
||||
});
|
||||
splashText('로그인 확인 중…');
|
||||
await first;
|
||||
if (a.ok) splashText('녹음 · 음성 인식 엔진 시작 중…');
|
||||
|
||||
Reference in New Issue
Block a user