feat(V2-4): 데스크톱 ↔ Supabase 동기화 (push only MVP)
CloudSyncService (싱글톤 + EventEmitter): - Supabase 클라이언트 lazy init (configGet으로 url/key) - safeStorage 기반 refresh token 영속화 (cloud-sync.token) - startSignIn(provider): OAuth URL 발급 후 shell.openExternal로 외부 브라우저 - handleAuthCallback(code): code -> session 교환 - pushAll(): history/dictionary/meetings/meeting_memos/meeting_documents 를 last_sync_at 이후 변경분만 upsert (onConflict: id) - 이벤트: auth-changed / sync-progress / sync-complete / sync-error Deep link (d3ro-voice://auth-callback): - main/index.ts에 setAsDefaultProtocolClient - macOS open-url 핸들러 - Windows second-instance argv 검사 - handleDeepLink로 URL 파싱 후 CloudSyncService로 전달 IPC: - @d3ro/core/ipc-channels에 CLOUD_SYNC 채널 추가 - ipc/cloud-sync-handlers.ts (configure/signIn/signOut/pushAll/state) - preload index.ts에 cloudSync 노출 - bootstrap의 cloud-sync 단계 추가 Renderer: - CloudSyncSection 컴포넌트 신규 - 미설정: Supabase URL/Key 입력 폼 - 미로그인: Google/GitHub OAuth 버튼 - 로그인: 사용자 이메일 + Sync Now + 진행 바 + 로그아웃 - d3roPalette/typoSx로 SSOT 준수, useI18n 사용 ConfigService 키 5종 추가: - hfToken, diarizationEnabled (Phase 15.5 누락분 보충) - supabaseUrl, supabaseAnonKey, cloudSyncLastAt (V2-4) - packages/core types.ts AppConfig에도 동일하게 추가 검증: - desktop typecheck OK - desktop build OK - 실제 Supabase 동기화는 사용자가 V2-2 배포 + 설정 입력 후 검증
This commit is contained in:
parent
d0c33ca259
commit
5c0f4a2b98
13 changed files with 1069 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
// src/main/index.ts — 앱 진입점
|
||||
|
||||
import { app } from 'electron'
|
||||
import path from 'path'
|
||||
import { bootstrap } from './bootstrap'
|
||||
import { setupLifecycle } from './lifecycle'
|
||||
import { getMainWindow } from './windows/WindowManager'
|
||||
|
|
@ -14,19 +15,59 @@ process.on('uncaughtException', (err) => {
|
|||
try { require('electron-log').default?.error?.('Uncaught:', err) } catch { /* noop */ }
|
||||
})
|
||||
|
||||
// V2-4: deep link 프로토콜 등록 — d3ro-voice://auth-callback?code=...
|
||||
const PROTOCOL = 'd3ro-voice'
|
||||
if (process.defaultApp) {
|
||||
if (process.argv.length >= 2) {
|
||||
app.setAsDefaultProtocolClient(PROTOCOL, process.execPath, [path.resolve(process.argv[1])])
|
||||
}
|
||||
} else {
|
||||
app.setAsDefaultProtocolClient(PROTOCOL)
|
||||
}
|
||||
|
||||
/**
|
||||
* deep link URL을 파싱해서 CloudSyncService로 전달.
|
||||
* d3ro-voice://auth-callback?code=...
|
||||
*/
|
||||
async function handleDeepLink(url: string): Promise<void> {
|
||||
try {
|
||||
const parsed = new URL(url)
|
||||
if (parsed.host === 'auth-callback') {
|
||||
const code = parsed.searchParams.get('code')
|
||||
if (code) {
|
||||
const { getCloudSyncService } = await import('./services/CloudSyncService')
|
||||
await getCloudSyncService().handleAuthCallback(code)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// 잘못된 URL은 무시
|
||||
}
|
||||
}
|
||||
|
||||
// 단일 인스턴스 잠금
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', () => {
|
||||
app.on('second-instance', (_event, argv) => {
|
||||
// 기존 인스턴스의 메인 윈도우를 활성화
|
||||
const mainWindow = getMainWindow()
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
mainWindow.focus()
|
||||
}
|
||||
// Windows: deep link는 두 번째 인스턴스의 argv 마지막 인자로 들어옴
|
||||
const deepLinkArg = argv.find((a) => a.startsWith(`${PROTOCOL}://`))
|
||||
if (deepLinkArg) {
|
||||
void handleDeepLink(deepLinkArg)
|
||||
}
|
||||
})
|
||||
|
||||
// macOS: open-url 이벤트로 deep link 도착
|
||||
app.on('open-url', (event, url) => {
|
||||
event.preventDefault()
|
||||
void handleDeepLink(url)
|
||||
})
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue