Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sunyihao
bkunyun
Commits
fd875ced
Commit
fd875ced
authored
May 16, 2022
by
sunyihao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化03
parent
c75f0f38
Pipeline
#159
failed with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
MyRouter.tsx
src/components/MyRouter/MyRouter.tsx
+4
-7
useMyRouter.ts
src/components/MyRouter/useMyRouter.ts
+2
-0
No files found.
src/components/MyRouter/MyRouter.tsx
View file @
fd875ced
import
React
,
{
ReactNode
,
useCallback
,
Suspense
}
from
"react"
;
import
{
ReactNode
,
useCallback
,
Suspense
}
from
"react"
;
import
{
BrowserRouter
,
Routes
,
Route
,
Navigate
}
from
"react-router-dom"
;
import
{
route
,
navigate
,
operation
}
from
"@/router"
;
import
{
observer
}
from
"mobx-react-lite"
;
import
{
useStores
}
from
"@/store/index"
;
import
Loading
from
"@/views/Loading"
;
import
useMyRouter
from
"./useMyRouter"
;
const
MyRouter
:
React
.
FC
<
{}
>
=
observer
(()
=>
{
const
{
permissionStore
}
=
useStores
();
useMyRouter
();
const
MyRouter
=
observer
(()
=>
{
const
routes
=
useMyRouter
();
const
setRoutes
=
useCallback
(
(
routes
:
Array
<
route
|
navigate
|
operation
>
):
ReactNode
=>
{
...
...
@@ -60,7 +57,7 @@ const MyRouter: React.FC<{}> = observer(() => {
return
(
<
BrowserRouter
>
<
Routes
>
{
setRoutes
(
permissionStore
.
allR
outes
)
}
</
Routes
>
<
Routes
>
{
setRoutes
(
r
outes
)
}
</
Routes
>
</
BrowserRouter
>
);
});
...
...
src/components/MyRouter/useMyRouter.ts
View file @
fd875ced
...
...
@@ -34,6 +34,8 @@ const useMyRouter = () => {
}
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
userInfo
.
data
,
menuInfo
.
data
]);
return
permissionStore
.
allRoutes
;
};
export
default
useMyRouter
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment