## React SPA Dashboard - React 19 + Vite 7 + Tailwind CSS 4 + Recharts 2 SPA 구축 - Dashboard (배치현황/시스템메트릭/캐시/처리량) + JobMonitor (이력조회/Step상세) - i18n 다국어(ko/en) 시스템, Light/Dark 테마 CSS 토큰 전환 - frontend-maven-plugin 1.15.1 (mvn package 시 자동 빌드) - WebViewController SPA forward + context-path /signal-batch - 레거시 HTML 48개 파일 전체 삭제 ## 안전 배포 - VesselBatchScheduler @PreDestroy: 신규 Job 차단 + 실행 중 Job 완료 대기 - server.shutdown=graceful, timeout-per-shutdown-phase=3m - deploy.yml: 활성 Job 3초 연속 확인 후 stop → 교체 → start - signal-batch.service TimeoutStopSec 60→180 - scripts/deploy.sh: 수동 배포용 안전 스크립트 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import { createContext, useCallback, useEffect, useState, type ReactNode } from 'react'
|
|
|
|
type Theme = 'light' | 'dark'
|
|
|
|
interface ThemeContextValue {
|
|
theme: Theme
|
|
toggleTheme: () => void
|
|
}
|
|
|
|
export const ThemeContext = createContext<ThemeContextValue>({
|
|
theme: 'light',
|
|
toggleTheme: () => {},
|
|
})
|
|
|
|
const STORAGE_KEY = 'sb-theme'
|
|
|
|
function getInitialTheme(): Theme {
|
|
const stored = localStorage.getItem(STORAGE_KEY)
|
|
if (stored === 'dark' || stored === 'light') return stored
|
|
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
}
|
|
|
|
export function ThemeProvider({ children }: { children: ReactNode }) {
|
|
const [theme, setTheme] = useState<Theme>(getInitialTheme)
|
|
|
|
useEffect(() => {
|
|
document.documentElement.dataset.theme = theme
|
|
localStorage.setItem(STORAGE_KEY, theme)
|
|
}, [theme])
|
|
|
|
const toggleTheme = useCallback(() => {
|
|
setTheme(prev => (prev === 'light' ? 'dark' : 'light'))
|
|
}, [])
|
|
|
|
return (
|
|
<ThemeContext value={{ theme, toggleTheme }}>
|
|
{children}
|
|
</ThemeContext>
|
|
)
|
|
}
|