feat(directory): update routers
This commit is contained in:
@@ -8,27 +8,12 @@ import {
|
||||
} from "react-router-dom";
|
||||
import Root from "@/routes/root";
|
||||
import ErrorPage from "@/routes/error-page";
|
||||
import Index from "@/routes/index";
|
||||
import Operator from "@/routes/operator";
|
||||
import routes from "@/routes";
|
||||
import '@/App.css';
|
||||
import 'reset-css';
|
||||
|
||||
document.title = import.meta.env.VITE_APP_TITLE;
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
name: "Home",
|
||||
element: <Index />
|
||||
}, {
|
||||
path: "operator/:key",
|
||||
index: false,
|
||||
name: "Operator",
|
||||
element: <Operator />
|
||||
}
|
||||
]
|
||||
|
||||
const router = createBrowserRouter(
|
||||
createRoutesFromElements(
|
||||
<Route
|
||||
|
||||
@@ -1,24 +1,16 @@
|
||||
import {
|
||||
useState,
|
||||
useEffect
|
||||
} from 'react'
|
||||
import './index.css'
|
||||
import Home from "@/routes/path/home";
|
||||
import Operator from "@/routes/path/operator";
|
||||
|
||||
export default function Index(props) {
|
||||
useEffect(() => {
|
||||
fetch("/_assets/directory.json").then(res => res.json()).then(data => {
|
||||
console.log(data)
|
||||
})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<section>
|
||||
<section>
|
||||
1233
|
||||
</section>
|
||||
<section>
|
||||
22s
|
||||
</section>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
export default [
|
||||
{
|
||||
path: "",
|
||||
index: true,
|
||||
name: "Home",
|
||||
element: <Home />
|
||||
}, {
|
||||
path: "operator/:key",
|
||||
index: false,
|
||||
name: "Operator",
|
||||
element: <Operator />
|
||||
}
|
||||
]
|
||||
24
directory/src/routes/path/home.jsx
Normal file
24
directory/src/routes/path/home.jsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import {
|
||||
useState,
|
||||
useEffect
|
||||
} from 'react'
|
||||
import './home.css'
|
||||
|
||||
export default function Home(props) {
|
||||
useEffect(() => {
|
||||
fetch("/_assets/directory.json").then(res => res.json()).then(data => {
|
||||
console.log(data)
|
||||
})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<section>
|
||||
<section>
|
||||
1233
|
||||
</section>
|
||||
<section>
|
||||
22s
|
||||
</section>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user