import { BrowserRouter, HashRouter, Routes, Route, Navigate } from 'react-router-dom' import { AuthProvider } from './contexts/AuthContext' import { useAuth } from './hooks/useAuth' import { AudioProvider } from './contexts/AudioContext' import BackgroundMusic from './components/BackgroundMusic' import LandingPage from './components/LandingPage' import Login from './components/Login' import Register from './components/Register' import CharacterSelection from './components/CharacterSelection' import CharacterCreation from './components/CharacterCreation' import Game from './components/Game' import Profile from './components/Profile' import Leaderboards from './components/Leaderboards' import GameLayout from './components/GameLayout' import AccountPage from './components/AccountPage' import './App.css' // Use HashRouter for Electron (file:// protocol), BrowserRouter for web const isElectron = window.location.protocol === 'file:' const Router = isElectron ? HashRouter : BrowserRouter function PrivateRoute({ children }: { children: React.ReactNode }) { const { isAuthenticated, loading } = useAuth() if (loading) { return
Loading...
} return isAuthenticated ? <>{children} : } function CharacterRoute({ children }: { children: React.ReactNode }) { const { isAuthenticated, currentCharacter, loading } = useAuth() if (loading) { return
Loading...
} if (!isAuthenticated) { return } if (!currentCharacter) { return } return <>{children} } function App() { return (
} /> } /> } /> } /> } /> } /> }> } /> } /> } />
) } export default App