-
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
1 parent
1659d9f
commit fad6269
Showing
7 changed files
with
134 additions
and
77 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
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,57 +1,64 @@ | ||
import { createBrowserRouter } from 'react-router-dom'; | ||
import { createBrowserRouter, Navigate } from 'react-router-dom'; | ||
import App from '../App'; | ||
import BookList from '../views/BookListView'; | ||
import SearchPage from '../views/SearchView'; | ||
import BookView from '../views/BookView'; | ||
import BookChapter from '../views/BookChapter'; | ||
import Navbar from '../components/Navbar'; | ||
|
||
const router = createBrowserRouter([ | ||
{ | ||
path: '/', | ||
element: ( | ||
<> | ||
<Navbar /> | ||
<App /> | ||
</> | ||
), | ||
}, | ||
{ | ||
path: '/list', | ||
element: ( | ||
<> | ||
<Navbar /> | ||
<BookList /> | ||
</> | ||
), | ||
}, | ||
{ | ||
path: '/search', | ||
element: ( | ||
<> | ||
<Navbar /> | ||
<SearchPage /> | ||
</> | ||
), | ||
}, | ||
{ | ||
path: '/book/:name', | ||
element: ( | ||
<> | ||
<Navbar /> | ||
<BookView /> | ||
</> | ||
), | ||
}, | ||
{ | ||
path: '/chapter/:url', | ||
element: ( | ||
<> | ||
<Navbar /> | ||
<BookChapter /> | ||
</> | ||
), | ||
}, | ||
]); | ||
const router = createBrowserRouter( | ||
[ | ||
{ | ||
path: '/', | ||
element: ( | ||
<> | ||
<Navbar /> | ||
<App /> | ||
</> | ||
), | ||
}, | ||
{ | ||
path: '/list', | ||
element: ( | ||
<> | ||
<Navbar /> | ||
<BookList /> | ||
</> | ||
), | ||
}, | ||
{ | ||
path: '/search', | ||
element: ( | ||
<> | ||
<Navbar /> | ||
<SearchPage /> | ||
</> | ||
), | ||
}, | ||
{ | ||
path: '/book/:name', | ||
element: ( | ||
<> | ||
<Navbar /> | ||
<BookView /> | ||
</> | ||
), | ||
}, | ||
{ | ||
path: '/chapter/:url', | ||
element: ( | ||
<> | ||
<Navbar /> | ||
<BookChapter /> | ||
</> | ||
), | ||
}, | ||
{ | ||
path: '*', // 匹配所有未定义的路径 | ||
element: <Navigate to="/" />, // 重定向到首页 | ||
}, | ||
], | ||
{ basename: process.env.NODE_ENV === 'production' ? '/jianlai' : '' } | ||
); | ||
|
||
export default router; |
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
"paths": { | ||
"@/*": ["src/*"] | ||
}, | ||
"types": [""] | ||
"types": ["node"] | ||
}, | ||
"include": ["./src"] | ||
} |