Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
b425de85
Commit
b425de85
authored
Jul 29, 2018
by
KJlmfe
Committed by
εε³
Aug 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: reduce code duplication of routerDataCache
parent
c9186043
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
src/common/router.js
src/common/router.js
+9
-8
No files found.
src/common/router.js
View file @
b425de85
...
...
@@ -6,6 +6,13 @@ import { getMenuData } from './menu';
let
routerDataCache
;
const
getRouterDataCache
=
app
=>
{
if
(
!
routerDataCache
)
{
routerDataCache
=
getRouterData
(
app
);
}
return
routerDataCache
;
};
const
modelNotExisted
=
(
app
,
model
)
=>
// eslint-disable-next-line
!
app
.
_models
.
some
(({
namespace
})
=>
{
...
...
@@ -26,27 +33,21 @@ const dynamicWrapper = (app, models, component) => {
// transformed by babel-plugin-dynamic-import-node-sync
if
(
component
.
toString
().
indexOf
(
'
.then(
'
)
<
0
)
{
return
props
=>
{
if
(
!
routerDataCache
)
{
routerDataCache
=
getRouterData
(
app
);
}
return
createElement
(
component
().
default
,
{
...
props
,
routerData
:
routerDataCache
,
routerData
:
getRouterDataCache
(
app
)
,
});
};
}
// () => import('module')
return
Loadable
({
loader
:
()
=>
{
if
(
!
routerDataCache
)
{
routerDataCache
=
getRouterData
(
app
);
}
return
component
().
then
(
raw
=>
{
const
Component
=
raw
.
default
||
raw
;
return
props
=>
createElement
(
Component
,
{
...
props
,
routerData
:
routerDataCache
,
routerData
:
getRouterDataCache
(
app
)
,
});
});
},
...
...
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