feat(V2-1a): Monorepo 구조 전환 — apps/desktop으로 V1 이동
- npm workspaces 루트 (apps/*, packages/*) 세팅 - V1 전체를 apps/desktop/으로 git mv (src, resources, tests, sidecar, scripts, electron.vite.config.ts, electron-builder.yml, vitest.config.ts, tsconfig.node.json, tsconfig.web.json) - apps/desktop/package.json 신규 (name=@d3ro/desktop) - productName: 'd3ro-voice' 명시 — app.getName()을 고정하여 userData 경로 %APPDATA%\d3ro-voice\ 그대로 유지 (기존 DB/설정 연속성 보장) - 루트 package.json을 workspace 루트로 재구성, 공통 devDep만 유지 (typescript, eslint, prettier) - turbo.json, tsconfig.base.json 추가 (Turborepo 자체 설치는 별도 sub-phase) - memory/project_status.md 생성 (규칙 13) 검증: - npm run typecheck 통과 - npm run build 통과 (electron-vite main+preload+renderer) - npm run dev 실제 실행 → DB/핫키/Ollama 자동 실행 모두 정상
This commit is contained in:
parent
3a160b9032
commit
45a580878a
178 changed files with 214 additions and 0 deletions
54
apps/desktop/src/renderer/hooks/useProFeature.ts
Normal file
54
apps/desktop/src/renderer/hooks/useProFeature.ts
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
// src/renderer/hooks/useProFeature.ts
|
||||
// Pro feature gating hook: checks access, subscribes to tier changes
|
||||
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { Feature } from '@shared/types'
|
||||
import type { FeatureAccess } from '@shared/types'
|
||||
|
||||
interface UseProFeatureResult {
|
||||
/** Feature is unlocked for current tier */
|
||||
unlocked: boolean
|
||||
/** Loading initial access check */
|
||||
loading: boolean
|
||||
/** Full access info (null while loading) */
|
||||
access: FeatureAccess | null
|
||||
/** Opens the license modal (dispatches custom event) */
|
||||
showUpgrade: () => void
|
||||
}
|
||||
|
||||
export function useProFeature(feature: Feature): UseProFeatureResult {
|
||||
const [access, setAccess] = useState<FeatureAccess | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
const checkAccess = useCallback(() => {
|
||||
window.electronAPI.license.checkFeature(feature).then((result) => {
|
||||
if (result.success) {
|
||||
setAccess(result.data)
|
||||
}
|
||||
setLoading(false)
|
||||
})
|
||||
}, [feature])
|
||||
|
||||
useEffect(() => {
|
||||
checkAccess()
|
||||
|
||||
// Re-check when tier changes
|
||||
const unsub = window.electronAPI.license.onTierChanged(() => {
|
||||
checkAccess()
|
||||
})
|
||||
|
||||
return unsub
|
||||
}, [checkAccess])
|
||||
|
||||
const showUpgrade = useCallback(() => {
|
||||
// Dispatch custom event that LicenseModal listens to
|
||||
window.dispatchEvent(new CustomEvent('d3ro:open-license-modal'))
|
||||
}, [])
|
||||
|
||||
return {
|
||||
unlocked: access?.allowed ?? false,
|
||||
loading,
|
||||
access,
|
||||
showUpgrade,
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue