Skip to content

Commit

Permalink
refact the directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Mar 23, 2018
1 parent 59e9a10 commit d4e10ad
Show file tree
Hide file tree
Showing 114 changed files with 65 additions and 54 deletions.
19 changes: 19 additions & 0 deletions .umirc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

export default {
plugins: [
'umi-plugin-dva',
[
'umi-plugin-routes',
{
exclude: [
/model\.(j|t)sx?$/,
/service\.(j|t)sx?$/,
/models\//,
/components\//,
/services\//,
/chart\/Container\.js$/,
],
},
],
],
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"name": "antd-admin",
"version": "4.3.9",
"dependencies": {
"@babel/polyfill": "^7.0.0-beta.42",
"axios": "^0.17.1",
"classnames": "^2.2.5",
"d3-shape": "^1.2.0",
Expand All @@ -28,7 +29,10 @@
"react-draft-wysiwyg": "^1.10.0",
"react-helmet": "^5.1.3",
"react-highcharts": "^15.0.0",
"recharts": "^1.0.0-beta.0"
"recharts": "^1.0.0-beta.0",
"umi": "^1.1.0",
"umi-plugin-dva": "^0.4.0",
"umi-plugin-routes": "^0.1.2"
},
"devDependencies": {
"babel-plugin-dev-expression": "^0.2.1",
Expand Down
1 change: 1 addition & 0 deletions src/global.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@babel/polyfill'
25 changes: 0 additions & 25 deletions src/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/routes/app.js → src/layouts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { BackTop, Layout } from 'antd'
import { classnames, config } from 'utils'
import { Helmet } from 'react-helmet'
import { withRouter } from 'dva/router'
import Error from './error'
import Error from '../pages/404'
import '../themes/index.less'
import './app.less'

Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions src/layouts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { LocaleProvider } from 'antd'
import enUS from 'antd/lib/locale-provider/en_US'
import withRouter from 'umi/withRouter'
import App from './app'

export default withRouter((props) => {
return (
<LocaleProvider locale={enUS}>
<App>
{ props.children }
</App>
</LocaleProvider>
)
})
2 changes: 1 addition & 1 deletion src/routes/error/index.js → src/pages/404.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { Icon } from 'antd'
import { Page } from 'components'
import styles from './index.less'
import styles from './404.less'

const Error = () => (<Page inner>
<div className={styles.error}>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { parse } from 'qs'
import modelExtend from 'dva-model-extend'
import { query } from 'services/dashboard'
import { model } from 'models/common'
import * as weatherService from 'services/weather'
import { query } from '../services/dashboard'
import { model } from 'utils/model'
import * as weatherService from '../services/weather'

export default modelExtend(model, {
namespace: 'dashboard',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Redirect from 'umi/redirect'

export default () => <Redirect to="/dashboard" />
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/models/login.js → src/pages/login/models/login.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { routerRedux } from 'dva/router'
import { login } from 'services/login'
import { login } from '../services/login'

export default {
namespace: 'login',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/routes/post/index.js → src/pages/post/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Tabs } from 'antd'
import { routerRedux } from 'dva/router'
import queryString from 'query-string'
import { Page } from 'components'
import List from './List'
import List from './components/List'

const { TabPane } = Tabs

Expand Down
4 changes: 2 additions & 2 deletions src/models/post.js → src/pages/post/models/post.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import modelExtend from 'dva-model-extend'
import { query } from 'services/posts'
import { pageModel } from 'models/common'
import { query } from '../services/posts'
import { pageModel } from 'utils/model'
import queryString from 'query-string'

export default modelExtend(pageModel, {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/routes/user/index.js → src/pages/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { connect } from 'dva'
import { Row, Col, Button, Popconfirm } from 'antd'
import { Page } from 'components'
import queryString from 'query-string'
import List from './List'
import Filter from './Filter'
import Modal from './Modal'
import List from './components/List'
import Filter from './components/Filter'
import Modal from './components/Modal'


const User = ({
Expand Down
6 changes: 3 additions & 3 deletions src/models/user.js → src/pages/user/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import modelExtend from 'dva-model-extend'
import queryString from 'query-string'
import { config } from 'utils'
import { create, remove, update } from 'services/user'
import * as usersService from 'services/users'
import { pageModel } from './common'
import { create, remove, update } from '../services/user'
import * as usersService from '../services/users'
import { pageModel } from 'utils/model'

const { query } = usersService
const { prefix } = config
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions src/plugins/onError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { message } from 'antd'

export default {
onError(e) {
e.preventDefault()
message.error(error.message)
}
}
12 changes: 0 additions & 12 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@ import React from 'react'
import PropTypes from 'prop-types'
import { Switch, Route, Redirect, routerRedux } from 'dva/router'
import dynamic from 'dva/dynamic'
import App from 'routes/app'
import { LocaleProvider } from 'antd'
import enUS from 'antd/lib/locale-provider/en_US'

const { ConnectedRouter } = routerRedux

const Routers = function ({ history, app }) {
const error = dynamic({
app,
component: () => import('./routes/error'),
})
const routes = [
{
path: '/dashboard',
Expand Down Expand Up @@ -69,8 +62,6 @@ const Routers = function ({ history, app }) {

return (
<ConnectedRouter history={history}>
<LocaleProvider locale={enUS}>
<App>
<Switch>
<Route exact path="/" render={() => (<Redirect to="/dashboard" />)} />
{
Expand All @@ -85,10 +76,7 @@ const Routers = function ({ history, app }) {
/>
))
}
<Route component={error} />
</Switch>
</App>
</LocaleProvider>
</ConnectedRouter>
)
}
Expand Down
1 change: 0 additions & 1 deletion src/tests/models/example-test.js

This file was deleted.

File renamed without changes.

0 comments on commit d4e10ad

Please sign in to comment.