diff --git a/src/components/layout/bread.jsx b/src/components/layout/bread.jsx index 513b290..031dae6 100644 --- a/src/components/layout/bread.jsx +++ b/src/components/layout/bread.jsx @@ -20,6 +20,8 @@ const getPathSet = function (menuArray, parentPath) { } getPathSet(menu) +console.log(pathSet) + function Bread({ location }) { let pathNames = [] location.pathname.substr(1).split('/').map((item, key) => { @@ -30,14 +32,20 @@ function Bread({ location }) { } }) const breads = pathNames.map((item, key) => { - return ( - - {pathSet[item].icon - ? - : ''} - {pathSet[item].name} + if (item=='-'){ + return + 无 - ) + }else { + return ( + + {pathSet[item].icon + ? + : ''} + {pathSet[item].name} + + ) + } }) return ( diff --git a/src/index.js b/src/index.js index d562107..10240fc 100644 --- a/src/index.js +++ b/src/index.js @@ -5,9 +5,8 @@ import dva from 'dva' const app = dva() // 2. Model + app.model(require('./models/app')) -app.model(require('./models/users')) -app.model(require('./models/dashboard')) // 3. Router app.router(require('./router')) diff --git a/src/router.js b/src/router.js index 69e1859..5b77f59 100644 --- a/src/router.js +++ b/src/router.js @@ -1,21 +1,56 @@ import React from 'react' -import { Router, Route , IndexRedirect } from 'dva/router' +import {Router} from 'dva/router' import App from './routes/app' import Error from './routes/error' -import Dashboard from './routes/dashboard' -import Users from './routes/users' -import Ico from './routes/ui/ico' -export default function ({ history }) { - return ( - - - - - - - - - - ) +export default function ({history, app}) { + + const routes = [ + { + path: '/', + component: App, + // IndexRoute:{ + // component: Error, + // }, + childRoutes: [ + { + path: 'dashboard', + name: 'dashboard', + getComponent(nextState, cb) { + require.ensure([], require => { + app.model(require('./models/dashboard')) + cb(null, require('./routes/dashboard')) + }) + } + }, { + path: 'users', + name: 'users', + getComponent(nextState, cb) { + require.ensure([], require => { + cb(null, require('./routes/ui/ico')) + }) + } + }, { + path: 'ui/ico', + name: 'ui/ico', + getComponent(nextState, cb) { + require.ensure([], require => { + app.model(require('./models/users')) + cb(null, require('./routes/users')) + }) + } + }, { + path: '*', + name: 'error', + getComponent(nextState, cb) { + require.ensure([], require => { + cb(null, require('./routes/error')) + }) + } + } + ] + } + ] + + return } diff --git a/src/routes/dashboard.js b/src/routes/dashboard.js index e2bdbd7..e6737bd 100644 --- a/src/routes/dashboard.js +++ b/src/routes/dashboard.js @@ -22,7 +22,8 @@ const bodyStyle = { } } -function Dashboard({dashboard}) { +function Dashboard({dashboard,dispatch}) { + console.log({dashboard,dispatch}); const {weather, sales, quote, numbers, recentSales, comments, completed, browser, cpu, user} = dashboard const numberCards = numbers.map((item, key) => @@ -97,11 +98,16 @@ function Dashboard({dashboard}) { } Dashboard.propTypes = { - dashboard: PropTypes.object + weather: PropTypes.object, + sales: PropTypes.array, + quote: PropTypes.object, + numbers: PropTypes.array, + recentSales: PropTypes.array, + comments: PropTypes.array, + completed: PropTypes.array, + browser: PropTypes.array, + cpu: PropTypes.object, + user: PropTypes.object, } -function mapStateToProps({dashboard}) { - return {dashboard} -} - -export default connect(mapStateToProps)(Dashboard) +export default connect(({dashboard}) => ({dashboard}))(Dashboard)