import React, { useEffect, useState } from 'react'; import { BrowserRouter, Routes, Route, Navigate, useLocation } from 'react-router-dom'; import Login from './components/Login'; import './App.css'; import { apiFetch } from './utils'; // Protected Route wrapper function RequireAuth({ children }: { children: React.ReactElement }) { const [auth, setAuth] = useState(null); const location = useLocation(); useEffect(() => { apiFetch('/api/auth') .then((res) => { if (res.ok) { setAuth(true); } else { setAuth(false); } }) .catch(() => setAuth(false)); }, []); if (auth === null) { return
Loading...
; } if (!auth) { return ; } return children; } import FeedList from './components/FeedList'; import FeedItems from './components/FeedItems'; import Settings from './components/Settings'; function Dashboard({ theme, setTheme }: { theme: string; setTheme: (t: string) => void }) { const [sidebarVisible, setSidebarVisible] = useState(true); return (
{!sidebarVisible && ( )}
} /> } /> } /> } />
); } function App() { const [theme, setTheme] = useState(localStorage.getItem('neko-theme') || 'light'); const handleSetTheme = (newTheme: string) => { setTheme(newTheme); localStorage.setItem('neko-theme', newTheme); }; const basename = window.location.pathname.startsWith('/v2') ? '/v2' : '/'; return ( } /> } /> ); } export default App;