mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-05-24 10:29:11 +00:00
Moved router to a separate folder for better code readability
This commit is contained in:
parent
2f26d12f6a
commit
6cc2489080
51
src/App.jsx
51
src/App.jsx
@ -1,58 +1,13 @@
|
||||
import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom";
|
||||
import { useLocation, Outlet } from "react-router-dom";
|
||||
import { useLayoutEffect } from "react";
|
||||
import Editor from "./pages/Editor";
|
||||
import Survey from "./pages/Survey";
|
||||
import BugReport from "./pages/BugReport";
|
||||
import Shortcuts from "./pages/Shortcuts";
|
||||
import Templates from "./pages/Templates";
|
||||
import LandingPage from "./pages/LandingPage";
|
||||
import SettingsContextProvider from "./context/SettingsContext";
|
||||
import { useSettings } from "./hooks";
|
||||
import NotFound from "./pages/NotFound";
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<SettingsContextProvider>
|
||||
<BrowserRouter>
|
||||
<RestoreScroll />
|
||||
<Routes>
|
||||
<Route path="/" element={<LandingPage />} />
|
||||
<Route
|
||||
path="/editor"
|
||||
element={
|
||||
<ThemedPage>
|
||||
<Editor />
|
||||
</ThemedPage>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/survey"
|
||||
element={
|
||||
<ThemedPage>
|
||||
<Survey />
|
||||
</ThemedPage>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/shortcuts"
|
||||
element={
|
||||
<ThemedPage>
|
||||
<Shortcuts />
|
||||
</ThemedPage>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path="/bug-report"
|
||||
element={
|
||||
<ThemedPage>
|
||||
<BugReport />
|
||||
</ThemedPage>
|
||||
}
|
||||
/>
|
||||
<Route path="/templates" element={<Templates />} />
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
<RestoreScroll />
|
||||
<Outlet />
|
||||
</SettingsContextProvider>
|
||||
);
|
||||
}
|
||||
|
@ -5,11 +5,12 @@ import App from "./App.jsx";
|
||||
import en_US from "@douyinfe/semi-ui/lib/es/locale/source/en_US";
|
||||
import "./index.css";
|
||||
import "./i18n/i18n.js";
|
||||
|
||||
import { RouterProvider } from "react-router-dom";
|
||||
import router from "./routes";
|
||||
const root = ReactDOM.createRoot(document.getElementById("root"));
|
||||
root.render(
|
||||
<LocaleProvider locale={en_US}>
|
||||
<App />
|
||||
<RouterProvider router={router} />
|
||||
<Analytics />
|
||||
</LocaleProvider>,
|
||||
);
|
||||
|
29
src/routes/index.jsx
Normal file
29
src/routes/index.jsx
Normal file
@ -0,0 +1,29 @@
|
||||
import {
|
||||
createBrowserRouter,
|
||||
createRoutesFromElements,
|
||||
Route,
|
||||
} from "react-router-dom";
|
||||
import LandingPage from "../pages/LandingPage";
|
||||
import Editor from "../pages/Editor";
|
||||
import Survey from "../pages/Survey";
|
||||
import Shortcuts from "../pages/Shortcuts";
|
||||
import BugReport from "../pages/BugReport";
|
||||
import Templates from "../pages/Templates";
|
||||
import NotFound from "../pages/NotFound";
|
||||
import App from "../App";
|
||||
|
||||
const router = createBrowserRouter(
|
||||
createRoutesFromElements(
|
||||
<Route path="/" element={<App />}>
|
||||
<Route path="/" index={true} element={<LandingPage />} />
|
||||
<Route path="/editor" element={<Editor />} />
|
||||
<Route path="/survey" element={<Survey />} />
|
||||
<Route path="/shortcuts" element={<Shortcuts />} />
|
||||
<Route path="/bug-report" element={<BugReport />} />
|
||||
<Route path="/templates" element={<Templates />} />
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Route>
|
||||
)
|
||||
);
|
||||
|
||||
export default router;
|
Loading…
Reference in New Issue
Block a user