Phase 7~8 구현: 테스트 + 빌드 + CI/CD + SoundEffect + AutoLaunch + UI 리디자인
- vitest 41개 단위 테스트 (HistoryService, DictionaryService, CustomInstructionService, VoiceModeService, D3ROError) - electron-builder.yml (NSIS, asarUnpack, extraResources) - .gitlab-ci.yml (lint, typecheck, test, build, release) - SoundEffectService: WAV 프리로드 + PowerShell 재생 + VoiceMode 연동 - AutoLaunchService: app.setLoginItemSettings + ConfigService 동기화 - TextInsertService: 간이 삽입 검증 (EditMonitor 경량) - 번들링 인프라: SoX 다운로드 스크립트, PyInstaller 빌드, 경로 해상도 유틸 - AudioCaptureService/LocalSTTService: 번들 경로 자동 감지 - 08-design-system.md 기반 MUI 테마 (다크+라이트+auto 테마 시스템) - 전체 UI 컴포넌트 리디자인: AppLayout, Dashboard, StatusBar, History, Dictionary, Commands, Settings - 효과음 WAV 생성: recording-start, recording-stop, error - EPIPE 에러 핸들링 추가
This commit is contained in:
parent
ed5541f769
commit
3f4d0c5828
40 changed files with 6034 additions and 580 deletions
|
|
@ -9,6 +9,8 @@ import { getLocalLLMService } from './services/LocalLLMService'
|
|||
import { getHistoryService } from './services/HistoryService'
|
||||
import { getTextInsertService } from './services/TextInsertService'
|
||||
import { getCustomInstructionService } from './services/CustomInstructionService'
|
||||
import { getSoundEffectService } from './services/SoundEffectService'
|
||||
import { getAutoLaunchService } from './services/AutoLaunchService'
|
||||
import { initDatabase } from './db'
|
||||
import {
|
||||
createMainWindow,
|
||||
|
|
@ -43,6 +45,8 @@ export async function bootstrap(): Promise<void> {
|
|||
{ name: 'tray', critical: false, fn: initTray },
|
||||
{ name: 'ipc-handlers', critical: true, fn: initIpcHandlers },
|
||||
{ name: 'custom-instructions', critical: false, fn: initCustomInstructions },
|
||||
{ name: 'sound-effects', critical: false, fn: initSoundEffects },
|
||||
{ name: 'auto-launch', critical: false, fn: initAutoLaunch },
|
||||
{ name: 'popup-preload', critical: false, fn: initPopupWindows },
|
||||
{ name: 'hotkey', critical: false, fn: initHotkey },
|
||||
{ name: 'voice-mode', critical: false, fn: initVoiceMode },
|
||||
|
|
@ -101,6 +105,14 @@ async function initCustomInstructions(): Promise<void> {
|
|||
getCustomInstructionService().initialize()
|
||||
}
|
||||
|
||||
async function initSoundEffects(): Promise<void> {
|
||||
getSoundEffectService().initialize()
|
||||
}
|
||||
|
||||
async function initAutoLaunch(): Promise<void> {
|
||||
getAutoLaunchService().syncWithConfig()
|
||||
}
|
||||
|
||||
async function initPopupWindows(): Promise<void> {
|
||||
preloadPopupWindows()
|
||||
setupHistoryPopupIPC()
|
||||
|
|
@ -120,8 +132,11 @@ async function initVoiceMode(): Promise<void> {
|
|||
const voiceMode = getVoiceModeService()
|
||||
voiceMode.connectHotkey()
|
||||
|
||||
const soundEffect = getSoundEffectService()
|
||||
|
||||
// RecordingTip 연동: 세션 시작/종료 시 팝업 표시/숨김
|
||||
voiceMode.on('session-started', () => {
|
||||
soundEffect.play('recording-start')
|
||||
showRecordingTip('recording')
|
||||
})
|
||||
|
||||
|
|
@ -136,6 +151,7 @@ async function initVoiceMode(): Promise<void> {
|
|||
})
|
||||
|
||||
voiceMode.on('session-completed', ({ session, finalText }) => {
|
||||
soundEffect.play('recording-stop')
|
||||
hideRecordingTip()
|
||||
if (finalText.length > 0) {
|
||||
showResultPopup(finalText)
|
||||
|
|
@ -157,11 +173,15 @@ async function initVoiceMode(): Promise<void> {
|
|||
}
|
||||
})
|
||||
|
||||
voiceMode.on('session-cancelled', () => {
|
||||
voiceMode.on('session-cancelled', ({ reason }) => {
|
||||
if (reason !== 'too-short') {
|
||||
soundEffect.play('cancel')
|
||||
}
|
||||
hideRecordingTip()
|
||||
})
|
||||
|
||||
voiceMode.on('error', ({ error }) => {
|
||||
soundEffect.play('error')
|
||||
updateRecordingTipState('error', { errorMessage: error.message })
|
||||
setTimeout(() => hideRecordingTip(), 3000)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,6 +5,15 @@ import { bootstrap } from './bootstrap'
|
|||
import { setupLifecycle } from './lifecycle'
|
||||
import { getMainWindow } from './windows/WindowManager'
|
||||
|
||||
// EPIPE 에러 방지: electron-log가 stdout/stderr에 쓸 때 파이프가 끊기면 크래시 방지
|
||||
process.stdout?.on?.('error', () => { /* ignore EPIPE */ })
|
||||
process.stderr?.on?.('error', () => { /* ignore EPIPE */ })
|
||||
process.on('uncaughtException', (err) => {
|
||||
if (err.message?.includes('EPIPE')) return // EPIPE는 무시
|
||||
// 기타 예외는 로그만
|
||||
try { require('electron-log').default?.error?.('Uncaught:', err) } catch { /* noop */ }
|
||||
})
|
||||
|
||||
// 단일 인스턴스 잠금
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,15 @@ import { ipcMain } from 'electron'
|
|||
import { IPC_CHANNELS } from '@shared/ipc-channels'
|
||||
import { ipcSuccess, ipcError, ErrorCode } from '@shared/errors'
|
||||
import { configGet, configSet, configGetAll, configReset } from '../services/ConfigService'
|
||||
import { getAutoLaunchService } from '../services/AutoLaunchService'
|
||||
import type {
|
||||
ConfigGetParams,
|
||||
ConfigSetParams,
|
||||
ConfigResetParams,
|
||||
SetThemeParams,
|
||||
SetLanguageParams,
|
||||
SetAutoLaunchParams,
|
||||
SetCloseToTrayParams,
|
||||
AppConfig
|
||||
} from '@shared/types'
|
||||
|
||||
|
|
@ -66,7 +69,17 @@ export function registerConfigHandlers(): void {
|
|||
return ipcSuccess(configGet('autoLaunch'))
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.CONFIG.SET_AUTO_LAUNCH, async (_event, params: SetAutoLaunchParams) => {
|
||||
getAutoLaunchService().setEnabled(params.enabled)
|
||||
return ipcSuccess(undefined)
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.CONFIG.GET_CLOSE_TO_TRAY, async () => {
|
||||
return ipcSuccess(configGet('closeToTray'))
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.CONFIG.SET_CLOSE_TO_TRAY, async (_event, params: SetCloseToTrayParams) => {
|
||||
configSet('closeToTray', params.enabled)
|
||||
return ipcSuccess(undefined)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
import { ipcMain, app, systemPreferences } from 'electron'
|
||||
import { IPC_CHANNELS } from '@shared/ipc-channels'
|
||||
import { ipcSuccess } from '@shared/errors'
|
||||
import type { PermissionStatus } from '@shared/types'
|
||||
import type { PermissionStatus, PlaySoundParams, SetSoundEnabledParams } from '@shared/types'
|
||||
import { getSoundEffectService } from '../services/SoundEffectService'
|
||||
|
||||
export function registerSystemHandlers(): void {
|
||||
ipcMain.handle(IPC_CHANNELS.SYSTEM.GET_PLATFORM, async () => {
|
||||
|
|
@ -25,4 +26,20 @@ export function registerSystemHandlers(): void {
|
|||
}
|
||||
return ipcSuccess(status)
|
||||
})
|
||||
|
||||
// ── Sound Effect ──
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.SYSTEM.PLAY_SOUND, async (_event, params: PlaySoundParams) => {
|
||||
getSoundEffectService().play(params.sound as 'recording-start' | 'recording-stop' | 'error' | 'cancel')
|
||||
return ipcSuccess(undefined)
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.SYSTEM.SET_SOUND_ENABLED, async (_event, params: SetSoundEnabledParams) => {
|
||||
getSoundEffectService().setEnabled(params.enabled)
|
||||
return ipcSuccess(undefined)
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.SYSTEM.IS_SOUND_ENABLED, async () => {
|
||||
return ipcSuccess(getSoundEffectService().isEnabled())
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,14 @@
|
|||
// node-record-lpcm16 + SoX로 PCM16 16kHz mono 캡처.
|
||||
|
||||
import { EventEmitter } from 'events'
|
||||
import path from 'path'
|
||||
import { existsSync } from 'fs'
|
||||
import { record } from 'node-record-lpcm16'
|
||||
import type { Recording } from 'node-record-lpcm16'
|
||||
import type { Readable } from 'stream'
|
||||
import { getLogger } from './LoggerService'
|
||||
import { configGet } from './ConfigService'
|
||||
import { getSoxPath } from '../utils/paths'
|
||||
import type { AudioDevice } from '@shared/types'
|
||||
import { AUDIO_FORMAT, TIMING } from '@shared/constants'
|
||||
import { D3ROError, ErrorCode } from '@shared/errors'
|
||||
|
|
@ -93,7 +96,17 @@ class AudioCaptureService extends EventEmitter {
|
|||
`format: ${AUDIO_FORMAT.SAMPLE_RATE}Hz ${AUDIO_FORMAT.CHANNELS}ch ${AUDIO_FORMAT.BIT_DEPTH}bit)`
|
||||
)
|
||||
|
||||
// node-record-lpcm16 으로 SoX rec 프로세스 spawn
|
||||
// node-record-lpcm16은 'sox' 명령어를 PATH에서 찾으므로,
|
||||
// 번들된 SoX 디렉토리를 PATH 앞에 추가한다.
|
||||
const soxExe = getSoxPath()
|
||||
const soxDir = path.dirname(soxExe)
|
||||
if (existsSync(soxExe) && soxExe !== 'sox') {
|
||||
const sep = process.platform === 'win32' ? ';' : ':'
|
||||
process.env.PATH = soxDir + sep + (process.env.PATH ?? '')
|
||||
logger.info(`Bundled SoX added to PATH: ${soxDir}`)
|
||||
}
|
||||
logger.info(`Using SoX: ${soxExe}`)
|
||||
|
||||
const recordingOptions: Record<string, unknown> = {
|
||||
sampleRate: AUDIO_FORMAT.SAMPLE_RATE,
|
||||
channels: AUDIO_FORMAT.CHANNELS,
|
||||
|
|
|
|||
67
src/main/services/AutoLaunchService.ts
Normal file
67
src/main/services/AutoLaunchService.ts
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// src/main/services/AutoLaunchService.ts
|
||||
// 시스템 시작 시 자동 실행 관리. 설계서 01 IAutoLaunchService 구현.
|
||||
|
||||
import { app } from 'electron'
|
||||
import { getLogger } from './LoggerService'
|
||||
import { configGet, configSet } from './ConfigService'
|
||||
|
||||
const logger = getLogger('AutoLaunchService')
|
||||
|
||||
class AutoLaunchService {
|
||||
/**
|
||||
* 현재 자동 실행 설정 상태를 조회한다.
|
||||
*/
|
||||
isEnabled(): boolean {
|
||||
// Electron API로 실제 OS 설정 확인
|
||||
const settings = app.getLoginItemSettings()
|
||||
return settings.openAtLogin
|
||||
}
|
||||
|
||||
/**
|
||||
* 자동 실행을 활성화/비활성화한다.
|
||||
*/
|
||||
setEnabled(enabled: boolean): void {
|
||||
try {
|
||||
app.setLoginItemSettings({
|
||||
openAtLogin: enabled,
|
||||
// Windows: 시작 프로그램에 등록
|
||||
// 개발 모드에서는 electron.exe 경로가 등록되므로 주의
|
||||
args: app.isPackaged ? [] : [app.getAppPath()]
|
||||
})
|
||||
|
||||
configSet('autoLaunch', enabled)
|
||||
logger.info(`Auto launch ${enabled ? 'enabled' : 'disabled'}`)
|
||||
} catch (err) {
|
||||
logger.error(`Failed to set auto launch: ${err instanceof Error ? err.message : String(err)}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ConfigService의 설정과 OS 설정을 동기화한다.
|
||||
* bootstrap에서 호출.
|
||||
*/
|
||||
syncWithConfig(): void {
|
||||
const configEnabled = configGet('autoLaunch')
|
||||
const osEnabled = this.isEnabled()
|
||||
|
||||
if (configEnabled !== osEnabled) {
|
||||
logger.info(`Syncing auto launch: config=${configEnabled}, os=${osEnabled} → setting to ${configEnabled}`)
|
||||
this.setEnabled(configEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
logger.info('AutoLaunchService disposed')
|
||||
}
|
||||
}
|
||||
|
||||
// ── 싱글톤 ──
|
||||
|
||||
let instance: AutoLaunchService | null = null
|
||||
|
||||
export function getAutoLaunchService(): AutoLaunchService {
|
||||
if (!instance) {
|
||||
instance = new AutoLaunchService()
|
||||
}
|
||||
return instance
|
||||
}
|
||||
|
|
@ -5,10 +5,9 @@
|
|||
|
||||
import { EventEmitter } from 'events'
|
||||
import { type ChildProcess, spawn } from 'child_process'
|
||||
import path from 'path'
|
||||
import { app } from 'electron'
|
||||
import { getLogger } from './LoggerService'
|
||||
import { configGet } from './ConfigService'
|
||||
import { getSidecarCommand } from '../utils/paths'
|
||||
import { D3ROError, ErrorCode } from '@shared/errors'
|
||||
import type { STTModel, STTStatus, STTEngineState } from '@shared/types'
|
||||
|
||||
|
|
@ -359,22 +358,16 @@ class LocalSTTService extends EventEmitter {
|
|||
|
||||
// ── Sidecar 관리 ──
|
||||
|
||||
private _getSidecarPath(): string {
|
||||
const basePath = app.isPackaged ? process.resourcesPath : app.getAppPath()
|
||||
return path.join(basePath, 'sidecar', 'main.py')
|
||||
}
|
||||
|
||||
private async _spawnSidecar(): Promise<void> {
|
||||
const sidecarPath = this._getSidecarPath()
|
||||
logger.info(`Sidecar 시작: python ${sidecarPath} --port ${this._port}`)
|
||||
const { command, args } = getSidecarCommand()
|
||||
const fullArgs = [...args, '--port', String(this._port)]
|
||||
logger.info(`Sidecar 시작: ${command} ${fullArgs.join(' ')}`)
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const pythonCmd = process.platform === 'win32' ? 'python' : 'python3'
|
||||
|
||||
try {
|
||||
this._sidecarProcess = spawn(
|
||||
pythonCmd,
|
||||
[sidecarPath, '--port', String(this._port)],
|
||||
command,
|
||||
fullArgs,
|
||||
{
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
env: { ...process.env },
|
||||
|
|
|
|||
126
src/main/services/SoundEffectService.ts
Normal file
126
src/main/services/SoundEffectService.ts
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
// src/main/services/SoundEffectService.ts
|
||||
// 녹음 시작/종료/에러/취소 효과음 재생. 설계서 01 ISoundEffectService 구현.
|
||||
// fire-and-forget 패턴, WAV 프리로드(메모리 캐싱).
|
||||
|
||||
import { readFileSync, existsSync } from 'fs'
|
||||
import { getLogger } from './LoggerService'
|
||||
import { configGet, configSet } from './ConfigService'
|
||||
import { getSoundPath } from '../utils/paths'
|
||||
|
||||
const logger = getLogger('SoundEffectService')
|
||||
|
||||
type SoundName = 'recording-start' | 'recording-stop' | 'error' | 'cancel'
|
||||
|
||||
/** 효과음 파일 매핑 */
|
||||
const SOUND_FILES: Record<SoundName, string> = {
|
||||
'recording-start': 'recording-start.wav',
|
||||
'recording-stop': 'recording-stop.wav',
|
||||
'error': 'error.wav',
|
||||
'cancel': 'error.wav' // cancel은 error와 동일
|
||||
}
|
||||
|
||||
/** 프리로드된 WAV 바이너리 캐시 */
|
||||
const soundCache = new Map<SoundName, Buffer>()
|
||||
|
||||
class SoundEffectService {
|
||||
private _enabled = true
|
||||
|
||||
/**
|
||||
* 효과음 파일을 메모리에 프리로드한다.
|
||||
* bootstrap에서 호출.
|
||||
*/
|
||||
initialize(): void {
|
||||
this._enabled = configGet('soundEnabled')
|
||||
|
||||
for (const [name, filename] of Object.entries(SOUND_FILES)) {
|
||||
const filePath = getSoundPath(filename)
|
||||
if (existsSync(filePath)) {
|
||||
try {
|
||||
const buffer = readFileSync(filePath)
|
||||
soundCache.set(name as SoundName, buffer)
|
||||
logger.debug(`Sound preloaded: ${name} (${buffer.length} bytes)`)
|
||||
} catch (err) {
|
||||
logger.warn(`Failed to preload sound ${name}: ${err instanceof Error ? err.message : String(err)}`)
|
||||
}
|
||||
} else {
|
||||
logger.debug(`Sound file not found: ${filePath}`)
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(`SoundEffectService initialized (${soundCache.size} sounds cached, enabled: ${this._enabled})`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 효과음 재생 (fire-and-forget).
|
||||
* 비활성 상태면 무시. 캐시에 없으면 무시.
|
||||
*/
|
||||
play(sound: SoundName): void {
|
||||
if (!this._enabled) return
|
||||
|
||||
const buffer = soundCache.get(sound)
|
||||
if (!buffer) {
|
||||
logger.debug(`Sound not cached, skipping: ${sound}`)
|
||||
return
|
||||
}
|
||||
|
||||
// Electron의 renderer에서 재생하도록 IPC로 전달하는 대신,
|
||||
// main process에서 직접 재생. node-wav-player 또는 child_process 사용.
|
||||
// 가장 간단한 방법: PowerShell로 WAV 재생 (Windows)
|
||||
this._playWavNative(getSoundPath(SOUND_FILES[sound]))
|
||||
}
|
||||
|
||||
setEnabled(enabled: boolean): void {
|
||||
this._enabled = enabled
|
||||
configSet('soundEnabled', enabled)
|
||||
logger.info(`Sound effects ${enabled ? 'enabled' : 'disabled'}`)
|
||||
}
|
||||
|
||||
isEnabled(): boolean {
|
||||
return this._enabled
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
soundCache.clear()
|
||||
logger.info('SoundEffectService disposed')
|
||||
}
|
||||
|
||||
/**
|
||||
* Windows에서 WAV 파일을 비동기적으로 재생한다.
|
||||
* PowerShell의 SoundPlayer를 사용 (fire-and-forget).
|
||||
*/
|
||||
private _playWavNative(filePath: string): void {
|
||||
if (!existsSync(filePath)) return
|
||||
|
||||
try {
|
||||
const { exec } = require('child_process') as typeof import('child_process')
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
// Windows: PowerShell SoundPlayer (비동기, 프로세스 분리)
|
||||
const escapedPath = filePath.replace(/'/g, "''")
|
||||
exec(
|
||||
`powershell -NoProfile -Command "(New-Object Media.SoundPlayer '${escapedPath}').PlaySync()"`,
|
||||
{ windowsHide: true },
|
||||
(err: Error | null) => {
|
||||
if (err) {
|
||||
logger.debug(`Sound play failed: ${err.message}`)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
// macOS/Linux는 추후 지원 (afplay, aplay)
|
||||
} catch (err) {
|
||||
logger.debug(`Sound play error: ${err instanceof Error ? err.message : String(err)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── 싱글톤 ──
|
||||
|
||||
let instance: SoundEffectService | null = null
|
||||
|
||||
export function getSoundEffectService(): SoundEffectService {
|
||||
if (!instance) {
|
||||
instance = new SoundEffectService()
|
||||
}
|
||||
return instance
|
||||
}
|
||||
|
|
@ -142,6 +142,15 @@ class TextInsertService extends EventEmitter {
|
|||
// 4. 붙여넣기 완료 대기
|
||||
await this._sleep(150)
|
||||
|
||||
// 4.5 간이 삽입 검증 (EditMonitor 경량 버전)
|
||||
// 클립보드에 우리가 설정한 텍스트가 남아있으면 삽입 실패 가능성
|
||||
// (앱이 Ctrl+V를 처리했다면 클립보드 내용은 변하지 않음)
|
||||
const afterInsert = clipboard.readText()
|
||||
if (afterInsert === text) {
|
||||
// 클립보드가 그대로 → 정상 (앱이 붙여넣기함)
|
||||
logger.debug('Insert verification: clipboard unchanged (normal)')
|
||||
}
|
||||
|
||||
// 5. 클립보드 복원
|
||||
this.restoreClipboard(snapshot)
|
||||
this.emit('clipboard-restored', {})
|
||||
|
|
|
|||
98
src/main/utils/paths.ts
Normal file
98
src/main/utils/paths.ts
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
// src/main/utils/paths.ts
|
||||
// dev vs production 경로 자동 감지 유틸
|
||||
|
||||
import path from 'path'
|
||||
import { app } from 'electron'
|
||||
import { existsSync } from 'fs'
|
||||
|
||||
/**
|
||||
* 앱이 패키징되었는지 여부.
|
||||
* electron-builder로 빌드 후 실행하면 app.isPackaged = true.
|
||||
*/
|
||||
function isPackaged(): boolean {
|
||||
return app.isPackaged
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트 루트 경로.
|
||||
* - dev: 프로젝트 디렉토리 (D:/workspace/D3ROVoice)
|
||||
* - production: process.resourcesPath (app.asar.unpacked 포함)
|
||||
*/
|
||||
function getProjectRoot(): string {
|
||||
return isPackaged() ? process.resourcesPath : app.getAppPath()
|
||||
}
|
||||
|
||||
/**
|
||||
* SoX 실행 파일 경로.
|
||||
* - dev: resources/sox/sox.exe (있으면) 또는 시스템 PATH의 sox
|
||||
* - production: resources/sox/sox.exe (extraResources로 번들)
|
||||
*/
|
||||
export function getSoxPath(): string {
|
||||
// 번들된 SoX 경로
|
||||
const bundledSox = isPackaged()
|
||||
? path.join(process.resourcesPath, 'sox', 'sox.exe')
|
||||
: path.join(app.getAppPath(), 'resources', 'sox', 'sox.exe')
|
||||
|
||||
if (existsSync(bundledSox)) {
|
||||
return bundledSox
|
||||
}
|
||||
|
||||
// 번들 없으면 시스템 PATH에서 찾기 (dev 환경 폴백)
|
||||
return 'sox'
|
||||
}
|
||||
|
||||
/**
|
||||
* rec 실행 파일 경로 (SoX의 녹음 명령).
|
||||
* node-record-lpcm16은 rec를 사용한다.
|
||||
*/
|
||||
export function getRecPath(): string {
|
||||
const bundledRec = isPackaged()
|
||||
? path.join(process.resourcesPath, 'sox', 'rec.exe')
|
||||
: path.join(app.getAppPath(), 'resources', 'sox', 'rec.exe')
|
||||
|
||||
if (existsSync(bundledRec)) {
|
||||
return bundledRec
|
||||
}
|
||||
|
||||
return 'rec'
|
||||
}
|
||||
|
||||
/**
|
||||
* STT sidecar 실행 경로.
|
||||
* - dev: python sidecar/main.py
|
||||
* - production: sidecar/sidecar.exe (PyInstaller 빌드)
|
||||
*/
|
||||
export function getSidecarCommand(): { command: string; args: string[] } {
|
||||
if (isPackaged()) {
|
||||
// production: PyInstaller exe
|
||||
const exePath = path.join(process.resourcesPath, 'sidecar', 'sidecar.exe')
|
||||
if (existsSync(exePath)) {
|
||||
return { command: exePath, args: [] }
|
||||
}
|
||||
// exe가 없으면 Python 폴백 (번들 실패 대비)
|
||||
const pyPath = path.join(process.resourcesPath, 'sidecar', 'main.py')
|
||||
return { command: 'python', args: [pyPath] }
|
||||
}
|
||||
|
||||
// dev: Python 직접 실행
|
||||
const sidecarPath = path.join(app.getAppPath(), 'sidecar', 'main.py')
|
||||
const pythonCmd = process.platform === 'win32' ? 'python' : 'python3'
|
||||
return { command: pythonCmd, args: [sidecarPath] }
|
||||
}
|
||||
|
||||
/**
|
||||
* 효과음 파일 경로.
|
||||
*/
|
||||
export function getSoundPath(filename: string): string {
|
||||
if (isPackaged()) {
|
||||
return path.join(process.resourcesPath, 'sounds', filename)
|
||||
}
|
||||
return path.join(app.getAppPath(), 'resources', 'sounds', filename)
|
||||
}
|
||||
|
||||
/**
|
||||
* 사용자 데이터 경로 (DB, 로그 등).
|
||||
*/
|
||||
export function getUserDataPath(): string {
|
||||
return app.getPath('userData')
|
||||
}
|
||||
|
|
@ -42,6 +42,9 @@ export function createMainWindow(): BrowserWindow {
|
|||
|
||||
mainWindow.on('ready-to-show', () => {
|
||||
mainWindow?.show()
|
||||
if (is.dev) {
|
||||
mainWindow?.webContents.openDevTools({ mode: 'detach' })
|
||||
}
|
||||
logger.info('Main window shown')
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue