-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
298 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React, {Suspense, lazy} from 'react'; | ||
|
||
const Suspenselazy = (props: any) => { | ||
return <Suspense fallback={<>...</>}>{React.createElement(lazy(props))}</Suspense>; | ||
}; | ||
|
||
export default Suspenselazy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import {BrowserRouter} from 'react-router-dom'; | ||
import App from './App'; | ||
|
||
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLDivElement); | ||
|
||
root.render(<App />); | ||
root.render( | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
<BrowserRouter> | ||
<App /> | ||
</BrowserRouter> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* react-router-dom v6 官方文档 | ||
* https://reactrouter.com/en/v6.3.0/getting-started/installation | ||
*/ | ||
import React from 'react'; | ||
import Suspenselazy from '@/components/Suspenselazy'; | ||
import {Navigate, RouteObject} from 'react-router-dom'; | ||
|
||
const Home = Suspenselazy(() => import(/* webpackChunkName:"" */ '@/view/Home')); | ||
const HomeOne = Suspenselazy(() => import(/* webpackChunkName:"homeOne" */ '@/view/Home/HomeOne')); | ||
const HomeTwo = Suspenselazy(() => import(/* webpackChunkName:"homeTwo" */ '@/view/Home/HomeTwo')); | ||
const Dashboard = Suspenselazy(() => import(/* webpackChunkName:"dashboard" */ '@/view/Dashboard')); | ||
const About = Suspenselazy(() => import(/* webpackChunkName:"about" */ '@/view/About')); | ||
|
||
const routes: RouteObject[] = [ | ||
{ | ||
path: '/', | ||
element: <Navigate to='/home/one' /> // 重定向 | ||
}, | ||
{ | ||
path: '/home', | ||
element: Home, | ||
children: [ | ||
// 嵌套路由 | ||
{ | ||
path: '/home/one', | ||
element: HomeOne | ||
}, | ||
{ | ||
path: '/home/two', | ||
element: HomeTwo | ||
} | ||
] | ||
}, | ||
{ | ||
path: '/dashboard', | ||
element: Dashboard | ||
}, | ||
{ | ||
path: '/about', | ||
element: About | ||
} | ||
]; | ||
|
||
export default routes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#root { | ||
.app { | ||
height: 100vh; | ||
background: #cccccc; | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
background: #e2e7e033; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.about-root { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100vw; | ||
height: 100vh; | ||
padding-top: 70px; | ||
font-size: 50px; | ||
background: #30afe0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import './index.scss'; | ||
|
||
const About = () => { | ||
return ( | ||
<div className='about-root'> | ||
<p>Hello About</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default About; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.dashboard-root { | ||
& > span { | ||
display: block; | ||
width: 100%; | ||
font-weight: 800; | ||
font-size: 110px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import './index.scss'; | ||
|
||
const Dashboard = () => { | ||
return ( | ||
<div className='dashboard-root'> | ||
<span>hello world Dashboard </span> | ||
<span>hello world Dashboard </span> | ||
<span>hello world Dashboard </span> | ||
<span>hello world Dashboard </span> | ||
<span>hello world Dashboard </span> | ||
<span>hello world Dashboard </span> | ||
<span>hello world Dashboard </span> | ||
<span>hello world Dashboard </span> | ||
<span>hello world Dashboard </span> | ||
<span>hello world Dashboard </span> | ||
<span>hello world Dashboard </span> | ||
<span>hello world Dashboard </span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Dashboard; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.home-one-root { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
box-sizing: border-box; | ||
width: 1000px; | ||
height: 800px; | ||
font-size: 50px; | ||
background: #c6e2ff; | ||
border-radius: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
import './index.scss'; | ||
|
||
const HomeOne = () => { | ||
return <div className='home-one-root'>HomeOne</div>; | ||
}; | ||
|
||
export default HomeOne; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.home-two-root { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
box-sizing: border-box; | ||
width: 1000px; | ||
height: 800px; | ||
font-size: 50px; | ||
background: #ffe7ba; | ||
border-radius: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
import './index.scss'; | ||
|
||
const HomeTwo = () => { | ||
return <div className='home-two-root'>HomeTwo</div>; | ||
}; | ||
|
||
export default HomeTwo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.home-root { | ||
display: flex; | ||
width: 100vw; | ||
height: 100vh; | ||
padding-top: 70px; | ||
|
||
.home-tab { | ||
display: flex; | ||
flex-direction: column; | ||
box-sizing: border-box; | ||
width: 300px; | ||
height: 800px; | ||
padding: 10px; | ||
font-size: 25px; | ||
background: #00bfff; | ||
border-radius: 10px; | ||
} | ||
} |
Oops, something went wrong.
上下文在这里:
Provider 可以包在这里