Revert to browser router

This commit is contained in:
keannu125 2023-03-10 19:36:40 +08:00
parent 8af4b9b3ac
commit 5d8610056b
3 changed files with 85 additions and 84 deletions

View file

@ -1,7 +1,7 @@
{
"name": "ivy-inventorymanager",
"version": "0.1.0",
"homepage": "https://lemeow125.github.io/Ivy",
"homepage": "https://lemeow125.github.io/Ivy/#",
"private": true,
"dependencies": {
"@emotion/react": "^11.10.5",

View file

@ -7,7 +7,11 @@ import Container from "./Components/Container/Container";
import {
createBrowserRouter,
createHashRouter,
HashRouter,
Navigate,
Route,
RouterProvider,
Routes,
} from "react-router-dom";
import Store from "./Plugins/Redux/Store/Store";
import { Provider } from "react-redux";
@ -21,88 +25,85 @@ import Register from "./Routes/Register/Register";
const queryClient = new QueryClient();
const router = createHashRouter(
[
{
path: "/",
element: (
<Container>
<Dashboard />
</Container>
),
errorElement: (
<Container>
<Error />
</Container>
),
},
{
path: "/Products",
element: (
<Container>
<Products />
</Container>
),
},
{
path: "/Inventory",
element: (
<Container>
<Inventory />
</Container>
),
},
{
path: "/Logs",
element: (
<Container>
<Logs />
</Container>
),
},
{
path: "/Login",
element: (
<Container>
<Login />
</Container>
),
},
{
path: "/Product/:id",
element: (
<Container>
<Product />
</Container>
),
},
{
path: "/Activation/:uid/:token",
element: (
<Container>
<Activation />
</Container>
),
},
{
path: "/NewProduct",
element: (
<Container>
<NewProduct />
</Container>
),
},
{
path: "/Register",
element: (
<Container>
<Register />
</Container>
),
},
],
{ basename: "/Ivy" }
);
const router = createBrowserRouter([
{
path: "/",
element: (
<Container>
<Dashboard />
</Container>
),
errorElement: (
<Container>
<Error />
</Container>
),
},
{
path: "/Products",
element: (
<Container>
<Products />
</Container>
),
},
{
path: "/Inventory",
element: (
<Container>
<Inventory />
</Container>
),
},
{
path: "/Logs",
element: (
<Container>
<Logs />
</Container>
),
},
{
path: "/Login",
element: (
<Container>
<Login />
</Container>
),
},
{
path: "/Product/:id",
element: (
<Container>
<Product />
</Container>
),
},
{
path: "/Activation/:uid/:token",
element: (
<Container>
<Activation />
</Container>
),
},
{
path: "/NewProduct",
element: (
<Container>
<NewProduct />
</Container>
),
},
{
path: "/Register",
element: (
<Container>
<Register />
</Container>
),
},
]);
export default function App() {
return (

View file

@ -14,7 +14,7 @@ export default function LoginChecker() {
if (!logged_in && !old_session_checked) {
} else if (!logged_in && old_session_checked) {
console.log("Not logged in. Redirecting to login page");
return <Navigate to="/Login" replace />;
return <Navigate to="Ivy/Login" replace />;
}
return <div />;
}