-
Notifications
You must be signed in to change notification settings - Fork 4
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
157622f
commit d34af87
Showing
14 changed files
with
87 additions
and
163 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
File renamed without changes.
File renamed without changes.
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,45 @@ | ||
import { Card } from "antd"; | ||
import ReactMarkdown from "react-markdown"; | ||
|
||
export function RouterQueryDemo() { | ||
const routerAuthDemo = ` | ||
~~~js | ||
export const mainRoutes: RouteObject = { | ||
path: mainLayoutPath, | ||
element: ( | ||
<ShouldLogon> | ||
<Main /> | ||
</ShouldLogon> | ||
), | ||
children: pagesRoutes, | ||
}; | ||
function ShouldLogon({ children }: { children: ReactNode }) { | ||
const loginInfoStorageStr = globalThis.localStorage.getItem(loginInfoStorageKey); | ||
if (!loginInfoStorageStr) { | ||
return <Navigate to="/login" />; | ||
} | ||
const loginInfo = (JSON.parse(loginInfoStorageStr) as ILoginInfoStorageState).state.loginInfo; | ||
if (!loginInfo || !loginInfo.expireAt || dayjs().isAfter(dayjs(loginInfo.expireAt))) { | ||
return <Navigate to="/login" />; | ||
} | ||
return children; | ||
} | ||
~~~ | ||
`; | ||
|
||
return ( | ||
<div css={{ "& > * + *": { marginTop: 12 } }}> | ||
<Card title="npm包:react-router-toolkit" bordered={false}> | ||
<a onClick={() => window.open("https://www.npmjs.com/package/react-router-toolkit")}>查看文档</a> | ||
</Card> | ||
<Card title="路由守卫" bordered={false}> | ||
<ReactMarkdown>{routerAuthDemo}</ReactMarkdown> | ||
</Card> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
import { RequestDemo } from "./RequestDemo"; | ||
import { RouterQueryDemo } from "./RouterQueryDemo"; | ||
|
||
export const utilListModuleName = "util-list"; | ||
export const utilListModuleNameDefaultPath = "request"; | ||
|
||
export const utilListRoutes = { | ||
path: utilListModuleName, | ||
id: "工具", | ||
children: [ | ||
{ | ||
path: utilListModuleNameDefaultPath, | ||
path: "request", | ||
id: "请求示例", | ||
element: <RequestDemo />, | ||
}, | ||
{ | ||
path: "router-toolkit", | ||
id: "路由工具箱", | ||
element: <RouterQueryDemo />, | ||
}, | ||
], | ||
}; |
File renamed without changes.