From 2d532a77e7798b2aef8d79a999b3f08ccace84ee Mon Sep 17 00:00:00 2001 From: zhang Date: Wed, 14 Aug 2024 23:31:31 +0800 Subject: [PATCH] feat: add react router pages - using https://github.com/ArnaudBarre/eslint-plugin-react-refresh/issues/25 fix eslint warn of react-refresh --- src/App.tsx | 4 +-- src/pages/Account/Login/index.tsx | 13 ++++++++++ src/pages/Account/Register/index.tsx | 13 ++++++++++ src/pages/Home/index.tsx | 13 ++++++++++ src/pages/NotFound/index.tsx | 13 ++++++++++ src/pages/Survey/Edit/index.tsx | 13 ++++++++++ src/router/index.tsx | 39 +++++++++++++++++++++++++--- 7 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 src/pages/Account/Login/index.tsx create mode 100644 src/pages/Account/Register/index.tsx create mode 100644 src/pages/Home/index.tsx create mode 100644 src/pages/NotFound/index.tsx create mode 100644 src/pages/Survey/Edit/index.tsx diff --git a/src/App.tsx b/src/App.tsx index f6fdd8b..824f2a7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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 ( <> - + {/*

问卷调查

diff --git a/src/pages/Account/Login/index.tsx b/src/pages/Account/Login/index.tsx new file mode 100644 index 0000000..28debf5 --- /dev/null +++ b/src/pages/Account/Login/index.tsx @@ -0,0 +1,13 @@ +import React, { FC } from 'react' + +type PropTypes = {} + +const Login: FC = () => { + return ( + <> +
Login
+ + ) +} + +export default Login diff --git a/src/pages/Account/Register/index.tsx b/src/pages/Account/Register/index.tsx new file mode 100644 index 0000000..5340daa --- /dev/null +++ b/src/pages/Account/Register/index.tsx @@ -0,0 +1,13 @@ +import React, { FC } from 'react' + +type PropTypes = {} + +const Register: FC = () => { + return ( + <> +
Register
+ + ) +} + +export default Register diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx new file mode 100644 index 0000000..ce1a01e --- /dev/null +++ b/src/pages/Home/index.tsx @@ -0,0 +1,13 @@ +import React, { FC } from 'react' + +type PropTypes = {} + +const Home: FC = () => { + return ( + <> +
Home
+ + ) +} + +export default Home diff --git a/src/pages/NotFound/index.tsx b/src/pages/NotFound/index.tsx new file mode 100644 index 0000000..2181abe --- /dev/null +++ b/src/pages/NotFound/index.tsx @@ -0,0 +1,13 @@ +import React, { FC } from 'react' + +type PropTypes = {} + +const NotFound: FC = () => { + return ( + <> +
NotFound
+ + ) +} + +export default NotFound diff --git a/src/pages/Survey/Edit/index.tsx b/src/pages/Survey/Edit/index.tsx new file mode 100644 index 0000000..64455a7 --- /dev/null +++ b/src/pages/Survey/Edit/index.tsx @@ -0,0 +1,13 @@ +import React, { FC } from 'react' + +type PropTypes = {} + +const Edit: FC = () => { + return ( + <> +
Edit
+ + ) +} + +export default Edit diff --git a/src/router/index.tsx b/src/router/index.tsx index 662c069..283935c 100644 --- a/src/router/index.tsx +++ b/src/router/index.tsx @@ -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: , + }, + { + path: '/login', + element: , + }, + { + path: '/register', + element: , + }, + { + path: '/list', element: , }, -]) + { + path: '/edit', + element: , + }, + { + path: '*', + element: , + }, +] + +const router = createBrowserRouter(routes) + +const Routes: React.FC = () => { + return +} -export default router +export default Routes