fix(desktop): clean single-instance lock exit and suppress devtools console crash
This commit is contained in:
parent
0dc6a1dc93
commit
eedbe97d02
3 changed files with 18 additions and 13 deletions
|
|
@ -131,15 +131,24 @@ async function handleDeepLink(url: string): Promise<void> {
|
|||
const gotTheLock = process.env.NODE_ENV === 'test' ? true : app.requestSingleInstanceLock()
|
||||
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
console.log('[D3RO Voice] Another instance is already running. Existing window focused.')
|
||||
app.exit(0)
|
||||
} else {
|
||||
app.on('second-instance', (_event, argv) => {
|
||||
// 기존 인스턴스의 메인 윈도우를 활성화
|
||||
// 기존 인스턴스의 메인 윈도우를 최상위로 활성화
|
||||
const mainWindow = getMainWindow()
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
mainWindow.show()
|
||||
mainWindow.focus()
|
||||
mainWindow.setAlwaysOnTop(true)
|
||||
setTimeout(() => {
|
||||
try {
|
||||
mainWindow?.setAlwaysOnTop(false)
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
// Windows: deep link는 두 번째 인스턴스의 argv 마지막 인자로 들어옴
|
||||
const deepLinkArg = argv.find((a) => a.startsWith(`${PROTOCOL}://`))
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ export function createMainWindow(): BrowserWindow {
|
|||
mainWindow?.restore()
|
||||
mainWindow?.focus()
|
||||
mainWindow?.flashFrame(true)
|
||||
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
||||
if (is.dev && process.env['ELECTRON_OPEN_DEVTOOLS'] === '1') {
|
||||
mainWindow?.webContents.openDevTools({ mode: 'right' })
|
||||
}
|
||||
logger.info('Main window shown')
|
||||
|
|
|
|||
|
|
@ -1,19 +1,15 @@
|
|||
@echo off
|
||||
title D3RO Voice Dev Runner
|
||||
title D3RO Voice Launcher
|
||||
echo ==========================================
|
||||
echo [1/2] Cleaning up previous processes...
|
||||
echo ==========================================
|
||||
taskkill /F /IM electron.exe >nul 2>&1
|
||||
taskkill /F /IM "D3RO Voice.exe" /IM electron.exe >nul 2>&1
|
||||
timeout /t 1 /nobreak >nul
|
||||
|
||||
echo ==========================================
|
||||
echo [2/2] Launching D3RO Voice...
|
||||
echo [2/2] Launching D3RO Voice App...
|
||||
echo ==========================================
|
||||
cd /d "%~dp0"
|
||||
call pnpm --filter @d3ro/desktop dev
|
||||
if errorlevel 1 (
|
||||
echo.
|
||||
echo pnpm failed, trying npm...
|
||||
call npm run dev --workspace=@d3ro/desktop
|
||||
)
|
||||
pause
|
||||
start "" "%~dp0node_modules\electron\dist\electron.exe" "%~dp0apps\desktop"
|
||||
echo D3RO Voice window opened.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue