import { StrictMode, Suspense, lazy, useEffect } from 'react'; import { createRoot } from 'react-dom/client'; import { BrowserRouter, Route, Routes, useLocation, useNavigate } from 'react-router'; import 'pretendard/dist/web/variable/pretendardvariable-dynamic-subset.css'; import './styles/global.css'; import { ConnectionBanner, Toasts } from './components/ui'; import { useSession } from './store/session'; import { toast } from './store/toast'; import { Home } from './pages/Home'; import { SiteHeader } from './components/SiteHeader'; const JoinPage = lazy(() => import('./pages/JoinPage')); const RoomPage = lazy(() => import('./pages/RoomPage')); const GamePage = lazy(() => import('./pages/GamePage')); const MePage = lazy(() => import('./pages/MePage')); const RulesPage = lazy(() => import('./pages/RulesPage')); const NotFound = lazy(() => import('./pages/NotFound')); const AdminApp = lazy(() => import('./pages/admin/AdminApp')); const GamesPage = lazy(() => import('./pages/GamesPage')); function Announcement() { const text = useSession((s) => s.announcement); const maintenance = useSession((s) => s.maintenance); if (!text && !maintenance) return null; return (
{maintenance && 'πŸ›  점검 쀑 Β· '} {text || 'μƒˆ 방을 μž μ‹œ λ§Œλ“€ 수 μ—†μ–΄μš”.'}
); } function Shell() { const loaded = useSession((s) => s.loaded); const nav = useNavigate(); const loc = useLocation(); useEffect(() => { void useSession.getState().refresh(); const onUnauthorized = () => void useSession.getState().refresh(); window.addEventListener('bg:unauthorized', onUnauthorized); return () => window.removeEventListener('bg:unauthorized', onUnauthorized); }, []); useEffect(() => { const q = new URLSearchParams(loc.search); if (q.get('linked') === '1') toast('λ””μŠ€μ½”λ“œ 계정과 μ—°κ²°ν–ˆμ–΄μš”.'); if (q.get('login') === 'failed') toast('λ””μŠ€μ½”λ“œ λ‘œκ·ΈμΈμ— μ‹€νŒ¨ν–ˆμ–΄μš”. λ‹€μ‹œ μ‹œλ„ν•΄ μ£Όμ„Έμš”.', 'error'); if (q.get('login') === 'banned') toast('이용이 μ œν•œλœ κ³„μ •μ΄μ—μš”.', 'error', 6000); if (q.has('linked') || q.has('login')) { q.delete('linked'); q.delete('login'); nav({ pathname: loc.pathname, search: q.toString() }, { replace: true }); } }, [loc.search]); // eslint-disable-line react-hooks/exhaustive-deps if (!loaded) return
λΆˆλŸ¬μ˜€λŠ” 쀑…
; return ( <> λΆˆλŸ¬μ˜€λŠ” 쀑…}> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); } createRoot(document.getElementById('root')!).render( , );