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
c67c7699
Commit
c67c7699
authored
Nov 09, 2017
by
WhatAKitty
Committed by
afc163
Nov 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load models on demand
parent
7808f663
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
8 deletions
+68
-8
src/common/nav.js
src/common/nav.js
+61
-1
src/index.js
src/index.js
+2
-5
src/router.js
src/router.js
+5
-2
No files found.
src/common/nav.js
View file @
c67c7699
...
@@ -3,11 +3,14 @@ import dynamic from 'dva/dynamic';
...
@@ -3,11 +3,14 @@ import dynamic from 'dva/dynamic';
const
data
=
[{
const
data
=
[{
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/user
'
),
],
component
:
()
=>
import
(
'
../layouts/BasicLayout
'
),
component
:
()
=>
import
(
'
../layouts/BasicLayout
'
),
}),
}),
layout
:
'
BasicLayout
'
,
layout
:
'
BasicLayout
'
,
name
:
'
ι¦ι‘΅
'
,
// for breadcrumb
name
:
'
ι¦ι‘΅
'
,
// for breadcrumb
path
:
''
,
path
:
'
/
'
,
children
:
[{
children
:
[{
name
:
'
Dashboard
'
,
name
:
'
Dashboard
'
,
icon
:
'
dashboard
'
,
icon
:
'
dashboard
'
,
...
@@ -17,6 +20,9 @@ const data = [{
...
@@ -17,6 +20,9 @@ const data = [{
path
:
'
analysis
'
,
path
:
'
analysis
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/chart
'
),
],
component
:
()
=>
import
(
'
../routes/Dashboard/Analysis
'
),
component
:
()
=>
import
(
'
../routes/Dashboard/Analysis
'
),
}),
}),
},
{
},
{
...
@@ -24,6 +30,9 @@ const data = [{
...
@@ -24,6 +30,9 @@ const data = [{
path
:
'
monitor
'
,
path
:
'
monitor
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/monitor
'
),
],
component
:
()
=>
import
(
'
../routes/Dashboard/Monitor
'
),
component
:
()
=>
import
(
'
../routes/Dashboard/Monitor
'
),
}),
}),
},
{
},
{
...
@@ -31,6 +40,11 @@ const data = [{
...
@@ -31,6 +40,11 @@ const data = [{
path
:
'
workplace
'
,
path
:
'
workplace
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/project
'
),
import
(
'
../models/activities
'
),
import
(
'
../models/chart
'
),
],
component
:
()
=>
import
(
'
../routes/Dashboard/Workplace
'
),
component
:
()
=>
import
(
'
../routes/Dashboard/Workplace
'
),
}),
}),
}],
}],
...
@@ -43,6 +57,9 @@ const data = [{
...
@@ -43,6 +57,9 @@ const data = [{
path
:
'
basic-form
'
,
path
:
'
basic-form
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/form
'
),
],
component
:
()
=>
import
(
'
../routes/Forms/BasicForm
'
),
component
:
()
=>
import
(
'
../routes/Forms/BasicForm
'
),
}),
}),
},
{
},
{
...
@@ -50,18 +67,27 @@ const data = [{
...
@@ -50,18 +67,27 @@ const data = [{
path
:
'
step-form
'
,
path
:
'
step-form
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/form
'
),
],
component
:
()
=>
import
(
'
../routes/Forms/StepForm
'
),
component
:
()
=>
import
(
'
../routes/Forms/StepForm
'
),
}),
}),
children
:
[{
children
:
[{
path
:
'
confirm
'
,
path
:
'
confirm
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/form
'
),
],
component
:
()
=>
import
(
'
../routes/Forms/StepForm/Step2
'
),
component
:
()
=>
import
(
'
../routes/Forms/StepForm/Step2
'
),
}),
}),
},
{
},
{
path
:
'
result
'
,
path
:
'
result
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/form
'
),
],
component
:
()
=>
import
(
'
../routes/Forms/StepForm/Step3
'
),
component
:
()
=>
import
(
'
../routes/Forms/StepForm/Step3
'
),
}),
}),
}],
}],
...
@@ -70,6 +96,9 @@ const data = [{
...
@@ -70,6 +96,9 @@ const data = [{
path
:
'
advanced-form
'
,
path
:
'
advanced-form
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/form
'
),
],
component
:
()
=>
import
(
'
../routes/Profile/AdvancedProfile
'
),
component
:
()
=>
import
(
'
../routes/Profile/AdvancedProfile
'
),
}),
}),
}],
}],
...
@@ -82,6 +111,9 @@ const data = [{
...
@@ -82,6 +111,9 @@ const data = [{
path
:
'
table-list
'
,
path
:
'
table-list
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/rule
'
),
],
component
:
()
=>
import
(
'
../routes/List/TableList
'
),
component
:
()
=>
import
(
'
../routes/List/TableList
'
),
}),
}),
},
{
},
{
...
@@ -89,6 +121,9 @@ const data = [{
...
@@ -89,6 +121,9 @@ const data = [{
path
:
'
basic-list
'
,
path
:
'
basic-list
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/list
'
),
],
component
:
()
=>
import
(
'
../routes/List/BasicList
'
),
component
:
()
=>
import
(
'
../routes/List/BasicList
'
),
}),
}),
},
{
},
{
...
@@ -96,6 +131,9 @@ const data = [{
...
@@ -96,6 +131,9 @@ const data = [{
path
:
'
card-list
'
,
path
:
'
card-list
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/list
'
),
],
component
:
()
=>
import
(
'
../routes/List/CardList
'
),
component
:
()
=>
import
(
'
../routes/List/CardList
'
),
}),
}),
},
{
},
{
...
@@ -103,6 +141,9 @@ const data = [{
...
@@ -103,6 +141,9 @@ const data = [{
path
:
'
cover-card-list
'
,
path
:
'
cover-card-list
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/list
'
),
],
component
:
()
=>
import
(
'
../routes/List/CoverCardList
'
),
component
:
()
=>
import
(
'
../routes/List/CoverCardList
'
),
}),
}),
},
{
},
{
...
@@ -110,6 +151,9 @@ const data = [{
...
@@ -110,6 +151,9 @@ const data = [{
path
:
'
filter-card-list
'
,
path
:
'
filter-card-list
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/list
'
),
],
component
:
()
=>
import
(
'
../routes/List/FilterCardList
'
),
component
:
()
=>
import
(
'
../routes/List/FilterCardList
'
),
}),
}),
},
{
},
{
...
@@ -117,6 +161,9 @@ const data = [{
...
@@ -117,6 +161,9 @@ const data = [{
path
:
'
search
'
,
path
:
'
search
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/list
'
),
],
component
:
()
=>
import
(
'
../routes/List/SearchList
'
),
component
:
()
=>
import
(
'
../routes/List/SearchList
'
),
}),
}),
}],
}],
...
@@ -129,6 +176,9 @@ const data = [{
...
@@ -129,6 +176,9 @@ const data = [{
path
:
'
basic
'
,
path
:
'
basic
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/profile
'
),
],
component
:
()
=>
import
(
'
../routes/Profile/BasicProfile
'
),
component
:
()
=>
import
(
'
../routes/Profile/BasicProfile
'
),
}),
}),
},
{
},
{
...
@@ -136,6 +186,9 @@ const data = [{
...
@@ -136,6 +186,9 @@ const data = [{
path
:
'
advanced
'
,
path
:
'
advanced
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/profile
'
),
],
component
:
()
=>
import
(
'
../routes/Profile/AdvancedProfile
'
),
component
:
()
=>
import
(
'
../routes/Profile/AdvancedProfile
'
),
}),
}),
}],
}],
...
@@ -190,6 +243,7 @@ const data = [{
...
@@ -190,6 +243,7 @@ const data = [{
app
,
app
,
component
:
()
=>
import
(
'
../layouts/UserLayout
'
),
component
:
()
=>
import
(
'
../layouts/UserLayout
'
),
}),
}),
path
:
'
/user
'
,
layout
:
'
UserLayout
'
,
layout
:
'
UserLayout
'
,
children
:
[{
children
:
[{
name
:
'
εΈζ·
'
,
name
:
'
εΈζ·
'
,
...
@@ -200,6 +254,9 @@ const data = [{
...
@@ -200,6 +254,9 @@ const data = [{
path
:
'
login
'
,
path
:
'
login
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/login
'
),
],
component
:
()
=>
import
(
'
../routes/User/Login
'
),
component
:
()
=>
import
(
'
../routes/User/Login
'
),
}),
}),
},
{
},
{
...
@@ -207,6 +264,9 @@ const data = [{
...
@@ -207,6 +264,9 @@ const data = [{
path
:
'
register
'
,
path
:
'
register
'
,
component
:
app
=>
dynamic
({
component
:
app
=>
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
../models/register
'
),
],
component
:
()
=>
import
(
'
../routes/User/Register
'
),
component
:
()
=>
import
(
'
../routes/User/Register
'
),
}),
}),
},
{
},
{
...
...
src/index.js
View file @
c67c7699
import
dva
from
'
dva
'
;
import
dva
from
'
dva
'
;
import
'
moment/locale/zh-cn
'
;
import
'
moment/locale/zh-cn
'
;
import
models
from
'
./models
'
;
import
'
./polyfill
'
;
import
'
./polyfill
'
;
import
'
./g2
'
;
import
'
./g2
'
;
// import { browserHistory } from 'dva/router';
// import { browserHistory } from 'dva/router';
...
@@ -14,10 +13,8 @@ const app = dva({
...
@@ -14,10 +13,8 @@ const app = dva({
// 2. Plugins
// 2. Plugins
// app.use({});
// app.use({});
// 3. Model move to router
// 3. Register global model
models
.
forEach
((
m
)
=>
{
app
.
model
(
require
(
'
./models/global
'
));
app
.
model
(
m
);
});
// 4. Router
// 4. Router
app
.
router
(
require
(
'
./router
'
));
app
.
router
(
require
(
'
./router
'
));
...
...
src/router.js
View file @
c67c7699
...
@@ -7,6 +7,9 @@ import dynamic from 'dva/dynamic';
...
@@ -7,6 +7,9 @@ import dynamic from 'dva/dynamic';
function
RouterConfig
({
history
,
app
})
{
function
RouterConfig
({
history
,
app
})
{
const
BasicLayout
=
dynamic
({
const
BasicLayout
=
dynamic
({
app
,
app
,
models
:
()
=>
[
import
(
'
./models/user
'
),
],
component
:
()
=>
import
(
'
./layouts/BasicLayout
'
),
component
:
()
=>
import
(
'
./layouts/BasicLayout
'
),
});
});
const
UserLayout
=
dynamic
({
const
UserLayout
=
dynamic
({
...
@@ -18,8 +21,8 @@ function RouterConfig({ history, app }) {
...
@@ -18,8 +21,8 @@ function RouterConfig({ history, app }) {
<
LocaleProvider
locale
=
{
zhCN
}
>
<
LocaleProvider
locale
=
{
zhCN
}
>
<
Router
history
=
{
history
}
>
<
Router
history
=
{
history
}
>
<
Switch
>
<
Switch
>
<
Route
path
=
"
/user
"
component
=
{
UserLayout
}
/
>
<
Route
path
=
"
/user
"
render
=
{
props
=>
<
UserLayout
{...
props
}
app
=
{
app
}
/>
} /
>
<
Route
path
=
"
/
"
component
=
{
BasicLayout
}
/
>
<
Route
path
=
"
/
"
render
=
{
props
=>
<
BasicLayout
{...
props
}
app
=
{
app
}
/>
} /
>
<
/Switch
>
<
/Switch
>
<
/Router
>
<
/Router
>
<
/LocaleProvider
>
<
/LocaleProvider
>
...
...
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