-
Notifications
You must be signed in to change notification settings - Fork 0
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
master1lan
committed
Jan 1, 2023
1 parent
46d8227
commit 3f3288c
Showing
13 changed files
with
199 additions
and
30 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,18 @@ | ||
| import Masonry from "@components/masonry"; | ||
|
|
||
| import { Link, Outlet } from "react-router-dom"; | ||
| import Image from "@components/image"; | ||
| export default function App() { | ||
| // return <Masonry />; | ||
| const url = `https://images.pexels.com/photos/5702958/pexels-photo-5702958.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1`; | ||
|
|
||
| return ( | ||
| <div> | ||
| <Masonry /> | ||
| {/* <Masonry /> */} | ||
| {/* <Image url={url} /> */} | ||
| <Link to='/photo'>测试第一个跳转</Link> | ||
| <Link to='/video'>test to video</Link> | ||
| <Link to='/read'>test to read</Link> | ||
| <Outlet /> | ||
| </div> | ||
| ); | ||
| } |
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
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,10 +1,59 @@ | ||
| import React from "react"; | ||
| import ReactDOM from "react-dom/client"; | ||
| import { | ||
| BrowserRouter, | ||
| Routes, | ||
| Route, | ||
| createBrowserRouter, | ||
| RouterProvider, | ||
| } from "react-router-dom"; | ||
| import App from "./App"; | ||
| import VideoPage from "./routers/video"; | ||
| import "./index.less"; | ||
| import ReadPage from "./routers/read"; | ||
| import Layout from "./routers/layout"; | ||
| import PhotoPage from "./routers/photo"; | ||
| import ErrorPage from "./routers/error"; | ||
|
|
||
| const router = createBrowserRouter([ | ||
| { | ||
| path: "/", | ||
| element: <Layout />, | ||
| // loader: | ||
| // action: | ||
| // error组件 | ||
| errorElement: <ErrorPage />, | ||
| children: [ | ||
| { | ||
| // error组件 | ||
| errorElement: <ErrorPage />, | ||
| children: [ | ||
| { | ||
| //默认页面 | ||
| index: true, | ||
| element: <PhotoPage />, | ||
| }, | ||
| { | ||
| path: "video", | ||
| element: <VideoPage />, | ||
| }, | ||
| { | ||
| path: "read", | ||
| element: <ReadPage />, | ||
| }, | ||
| { | ||
| path: "photo", | ||
| element: <PhotoPage />, | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }, | ||
| ]); | ||
|
|
||
| ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( | ||
| // <React.StrictMode> | ||
| <App /> | ||
| <RouterProvider router={router} /> | ||
|
|
||
| // </React.StrictMode> | ||
| ); |
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,3 @@ | ||
| export default function ErrorPage() { | ||
| return <h1>这里是error页</h1>; | ||
| } |
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,3 @@ | ||
| export default function Index() { | ||
| return <h1>这里是首页</h1>; | ||
| } |
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,54 @@ | ||
| import { | ||
| Outlet, | ||
| NavLink, | ||
| useLoaderData, | ||
| Form, | ||
| redirect, | ||
| useNavigation, | ||
| useSubmit, | ||
| } from "react-router-dom"; | ||
| export default function Layout() { | ||
| const nav_lists = [ | ||
| { | ||
| id: 1, | ||
| pathname: "photo", | ||
| }, | ||
| { | ||
| id: 2, | ||
| pathname: "read", | ||
| }, | ||
| { | ||
| id: 3, | ||
| pathname: "video", | ||
| }, | ||
| ]; | ||
| return ( | ||
| <> | ||
| <header>首部</header> | ||
| <main> | ||
| <nav> | ||
| <ul> | ||
| {nav_lists.map((nav) => ( | ||
| <li key={nav.id}> | ||
| <NavLink | ||
| to={nav.pathname} | ||
| className={({ isActive, isPending }) => | ||
| isActive ? "active" : isPending ? "pending" : "" | ||
| } | ||
| > | ||
| {nav.pathname} | ||
| </NavLink> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </nav> | ||
| <section | ||
| // className= | ||
| > | ||
| <Outlet /> | ||
| </section> | ||
| </main> | ||
| <footer>尾部</footer> | ||
| </> | ||
| ); | ||
| } |
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,3 @@ | ||
| export default function PhotoPage() { | ||
| return <h1>这里是photographs页面</h1>; | ||
| } |
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,3 @@ | ||
| export default function ReadPage() { | ||
| return <h1>这里是read路由页面</h1>; | ||
| } |
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,3 @@ | ||
| export default function VideoPage() { | ||
| return <h1>这里是video页面</h1>; | ||
| } |