content: import React from 'react'
  import PropTypes from 'prop-types'
  import { Router } from 'dva/router'
  import App from './routes/app'
  
  const registerModel = (app, model) => {
    if (!(app._models.filter(m => m.namespace === model.namespace).length === 1)) {
      app.model(model)
    }
  }
  
  const Routers = function ({ history, app }) {
    const routes = [
      {
        path: '/',
        component: App,
        getIndexRoute (nextState, cb) {
          require.ensure([], require => {
            registerModel(app, require('./models/article'))
            cb(null, { component: require('./routes/article/list') })
          }, 'article-list')
        },
        childRoutes: [
          {
            path:'/article',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/article'))
                cb(null, require('./routes/article/'))
              }, 'article')
            }
          },
          {
            path:'/articleList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/article'))
                cb(null, require('./routes/article/list'))
              }, 'article')
            }
          },
          {
            path:'/video',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/video'))
                cb(null, require('./routes/video/'))
              }, 'video')
            }
          },
          {
            path:'/videoList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/video'))
                cb(null, require('./routes/video/list'))
              }, 'video')
            }
          },
          {
            path:'/bannerList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/banner'))
                cb(null, require('./routes/banner/list'))
              }, 'banner')
            }
          },
          {
            path:'/banner',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/banner'))
                cb(null, require('./routes/banner'))
              }, 'banner')
            }
          },
          {
            path:'/subjectList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/subject'))
                cb(null, require('./routes/subject/list'))
              }, 'subject')
            }
          },
          {
            path:'/subject',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/subject'))
                cb(null, require('./routes/subject'))
              }, 'subject')
            }
          },
          {
            path:'/broadcastList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/broadcast'))
                cb(null, require('./routes/broadcast/list'))
              }, 'broadcast')
            }
          },
          {
            path:'/broadcast',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/broadcast'))
                cb(null, require('./routes/broadcast'))
              }, 'broadcast')
            }
          }, 
          {
            path:'/saleList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/sale'))
                cb(null, require('./routes/sale/list'))
              }, 'sale')
            }
          },
          {
            path:'/sale',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/sale'))
                cb(null, require('./routes/sale'))
              }, 'sale')
            }
          },
          {
            path:'/linkList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/link'))
                cb(null, require('./routes/link/list'))
              }, 'link')
            }
          },
          {
            path:'/link',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/link'))
                cb(null, require('./routes/link'))
              }, 'link')
            }
          },
          {
            path:'/qrcodeList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/qrcode'))
                cb(null, require('./routes/qrcode/list'))
              }, 'qrcode')
            }
          },
          {
            path:'/academiaLinkList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/academia'))
                cb(null, require('./routes/academia/academiaLinkList/'))
              }, 'academia-link-list')
            },
          },
          {
            path:'/questions',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/questions'))
                cb(null, require('./routes/questions/'))
              }, 'questions')
            }
          },
          {
            path:'/academiaVideoList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/academia'))
                cb(null, require('./routes/academia/academiaVideoList/'))
              }, 'academia-video-list')
            },
          },
          {
            path:'/newsList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/news'))
                cb(null, require('./routes/news/newsList/'))
              }, 'news-list')
            },
          },
          {
            path:'/lectureList',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/lecture'))
                cb(null, require('./routes/lecture/lectureList'))
              }, 'lecture-list')
            },
          },
          {
            path: '/login',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/login'))
                cb(null, require('./routes/login/'))
              }, 'login')
            },
          },
          {
            path: '/push',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/push'))
                cb(null, require('./routes/push/'))
              }, 'push')
            },
          },
          {
            path: '/quesType',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/quesType'))
                cb(null, require('./routes/quesType/'))
              }, 'quesType')
            },
          },
          {
            path: '/tags',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                registerModel(app, require('./models/tags'))
                cb(null, require('./routes/tags/'))
              }, 'tags')
            },
          },
          {
            path: '*',
            getComponent (nextState, cb) {
              require.ensure([], require => {
                cb(null, require('./routes/error/'))
              }, 'error')
            },
          },
        ],
      },
    ]
  
    return <Router history={history} routes={routes} />
  }
  
  Routers.propTypes = {
    history: PropTypes.object,
    app: PropTypes.object,
  }
  
  export default Routers
  