Skip to content

Commit

Permalink
feat: add react router pages
Browse files Browse the repository at this point in the history
- using ArnaudBarre/eslint-plugin-react-refresh#25 fix eslint warn of react-refresh
  • Loading branch information
zhangwh754 committed Aug 14, 2024
1 parent b4d0d99 commit 2d532a7
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { RouterProvider } from 'react-router-dom'
import router from './router'
import Routes from './router'
import './App.scss'
// import List from './pages/Manage/List'

function App() {
return (
<>
<RouterProvider router={router} />
<Routes />
{/* <header>
<h3>问卷调查</h3>
</header>
Expand Down
13 changes: 13 additions & 0 deletions src/pages/Account/Login/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { FC } from 'react'

type PropTypes = {}

const Login: FC<PropTypes> = () => {
return (
<>
<div>Login</div>
</>
)
}

export default Login
13 changes: 13 additions & 0 deletions src/pages/Account/Register/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { FC } from 'react'

type PropTypes = {}

const Register: FC<PropTypes> = () => {
return (
<>
<div>Register</div>
</>
)
}

export default Register
13 changes: 13 additions & 0 deletions src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { FC } from 'react'

type PropTypes = {}

const Home: FC<PropTypes> = () => {
return (
<>
<div>Home</div>
</>
)
}

export default Home
13 changes: 13 additions & 0 deletions src/pages/NotFound/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { FC } from 'react'

type PropTypes = {}

const NotFound: FC<PropTypes> = () => {
return (
<>
<div>NotFound</div>
</>
)
}

export default NotFound
13 changes: 13 additions & 0 deletions src/pages/Survey/Edit/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { FC } from 'react'

type PropTypes = {}

const Edit: FC<PropTypes> = () => {
return (
<>
<div>Edit</div>
</>
)
}

export default Edit
39 changes: 35 additions & 4 deletions src/router/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
import React from 'react'
import { createBrowserRouter } from 'react-router-dom'
import { createBrowserRouter, RouteObject, RouterProvider } from 'react-router-dom'

const Home = React.lazy(() => import('@/pages/Home'))
const Login = React.lazy(() => import('@/pages/Account/Login'))
const Register = React.lazy(() => import('@/pages/Account/Register'))
const List = React.lazy(() => import('@/pages/Manage/List'))
const Edit = React.lazy(() => import('@/pages/Survey/Edit'))
const NotFound = React.lazy(() => import('@/pages/NotFound'))

const router = createBrowserRouter([
const routes: RouteObject[] = [
{
path: '/',
element: <Home />,
},
{
path: '/login',
element: <Login />,
},
{
path: '/register',
element: <Register />,
},
{
path: '/list',
element: <List />,
},
])
{
path: '/edit',
element: <Edit />,
},
{
path: '*',
element: <NotFound />,
},
]

const router = createBrowserRouter(routes)

const Routes: React.FC = () => {
return <RouterProvider router={router} />
}

export default router
export default Routes

0 comments on commit 2d532a7

Please sign in to comment.