diff --git a/.umirc.js b/.umirc.js new file mode 100644 index 00000000..9ca6633c --- /dev/null +++ b/.umirc.js @@ -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$/, + ], + }, + ], + ], +} diff --git a/package.json b/package.json index 150a917c..b9cc4af4 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/src/global.js b/src/global.js new file mode 100644 index 00000000..33b7c42c --- /dev/null +++ b/src/global.js @@ -0,0 +1 @@ +import '@babel/polyfill' diff --git a/src/index.js b/src/index.js deleted file mode 100644 index e880e176..00000000 --- a/src/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import { message } from 'antd' -import dva from 'dva' -import createLoading from 'dva-loading' -import createHistory from 'history/createBrowserHistory' -import 'babel-polyfill' - -// 1. Initialize -const app = dva({ - ...createLoading({ - effects: true, - }), - history: createHistory(), - onError (error) { - message.error(error.message) - }, -}) - -// 2. Model -app.model(require('./models/app')) - -// 3. Router -app.router(require('./router')) - -// 4. Start -app.start('#root') diff --git a/src/routes/app.js b/src/layouts/app.js similarity index 99% rename from src/routes/app.js rename to src/layouts/app.js index 91bd1a8b..adef0b78 100644 --- a/src/routes/app.js +++ b/src/layouts/app.js @@ -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' diff --git a/src/routes/app.less b/src/layouts/app.less similarity index 100% rename from src/routes/app.less rename to src/layouts/app.less diff --git a/src/layouts/index.js b/src/layouts/index.js new file mode 100644 index 00000000..bcb73105 --- /dev/null +++ b/src/layouts/index.js @@ -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 ( + + + { props.children } + + + ) +}) diff --git a/src/routes/error/index.js b/src/pages/404.js similarity index 88% rename from src/routes/error/index.js rename to src/pages/404.js index caa83ee0..8b8f8707 100644 --- a/src/routes/error/index.js +++ b/src/pages/404.js @@ -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 = () => (
diff --git a/src/routes/error/index.less b/src/pages/404.less similarity index 100% rename from src/routes/error/index.less rename to src/pages/404.less diff --git a/src/routes/UIElement/dataTable/index.js b/src/pages/UIElement/dataTable/index.js similarity index 100% rename from src/routes/UIElement/dataTable/index.js rename to src/pages/UIElement/dataTable/index.js diff --git a/src/routes/UIElement/dropOption/index.js b/src/pages/UIElement/dropOption/index.js similarity index 100% rename from src/routes/UIElement/dropOption/index.js rename to src/pages/UIElement/dropOption/index.js diff --git a/src/routes/UIElement/editor/index.js b/src/pages/UIElement/editor/index.js similarity index 100% rename from src/routes/UIElement/editor/index.js rename to src/pages/UIElement/editor/index.js diff --git a/src/routes/UIElement/iconfont/emoji.js b/src/pages/UIElement/iconfont/emoji.js similarity index 100% rename from src/routes/UIElement/iconfont/emoji.js rename to src/pages/UIElement/iconfont/emoji.js diff --git a/src/routes/UIElement/iconfont/index.js b/src/pages/UIElement/iconfont/index.js similarity index 100% rename from src/routes/UIElement/iconfont/index.js rename to src/pages/UIElement/iconfont/index.js diff --git a/src/routes/UIElement/iconfont/index.less b/src/pages/UIElement/iconfont/index.less similarity index 100% rename from src/routes/UIElement/iconfont/index.less rename to src/pages/UIElement/iconfont/index.less diff --git a/src/routes/UIElement/layer/index.js b/src/pages/UIElement/layer/index.js similarity index 100% rename from src/routes/UIElement/layer/index.js rename to src/pages/UIElement/layer/index.js diff --git a/src/routes/UIElement/search/index.js b/src/pages/UIElement/search/index.js similarity index 100% rename from src/routes/UIElement/search/index.js rename to src/pages/UIElement/search/index.js diff --git a/src/routes/chart/Container.js b/src/pages/chart/Container.js similarity index 100% rename from src/routes/chart/Container.js rename to src/pages/chart/Container.js diff --git a/src/routes/chart/Container.less b/src/pages/chart/Container.less similarity index 100% rename from src/routes/chart/Container.less rename to src/pages/chart/Container.less diff --git a/src/routes/chart/ECharts/AirportCoordComponent.js b/src/pages/chart/ECharts/AirportCoordComponent.js similarity index 100% rename from src/routes/chart/ECharts/AirportCoordComponent.js rename to src/pages/chart/ECharts/AirportCoordComponent.js diff --git a/src/routes/chart/ECharts/BubbleGradientComponent.js b/src/pages/chart/ECharts/BubbleGradientComponent.js similarity index 100% rename from src/routes/chart/ECharts/BubbleGradientComponent.js rename to src/pages/chart/ECharts/BubbleGradientComponent.js diff --git a/src/routes/chart/ECharts/CalendarComponent.js b/src/pages/chart/ECharts/CalendarComponent.js similarity index 100% rename from src/routes/chart/ECharts/CalendarComponent.js rename to src/pages/chart/ECharts/CalendarComponent.js diff --git a/src/routes/chart/ECharts/ChartAPIComponent.js b/src/pages/chart/ECharts/ChartAPIComponent.js similarity index 100% rename from src/routes/chart/ECharts/ChartAPIComponent.js rename to src/pages/chart/ECharts/ChartAPIComponent.js diff --git a/src/routes/chart/ECharts/ChartShowLoadingComponent.js b/src/pages/chart/ECharts/ChartShowLoadingComponent.js similarity index 100% rename from src/routes/chart/ECharts/ChartShowLoadingComponent.js rename to src/pages/chart/ECharts/ChartShowLoadingComponent.js diff --git a/src/routes/chart/ECharts/ChartWithEventComponent.js b/src/pages/chart/ECharts/ChartWithEventComponent.js similarity index 100% rename from src/routes/chart/ECharts/ChartWithEventComponent.js rename to src/pages/chart/ECharts/ChartWithEventComponent.js diff --git a/src/routes/chart/ECharts/DynamicChartComponent.js b/src/pages/chart/ECharts/DynamicChartComponent.js similarity index 100% rename from src/routes/chart/ECharts/DynamicChartComponent.js rename to src/pages/chart/ECharts/DynamicChartComponent.js diff --git a/src/routes/chart/ECharts/EchartsComponent.js b/src/pages/chart/ECharts/EchartsComponent.js similarity index 100% rename from src/routes/chart/ECharts/EchartsComponent.js rename to src/pages/chart/ECharts/EchartsComponent.js diff --git a/src/routes/chart/ECharts/GCalendarComponent.js b/src/pages/chart/ECharts/GCalendarComponent.js similarity index 100% rename from src/routes/chart/ECharts/GCalendarComponent.js rename to src/pages/chart/ECharts/GCalendarComponent.js diff --git a/src/routes/chart/ECharts/GaugeComponent.js b/src/pages/chart/ECharts/GaugeComponent.js similarity index 100% rename from src/routes/chart/ECharts/GaugeComponent.js rename to src/pages/chart/ECharts/GaugeComponent.js diff --git a/src/routes/chart/ECharts/GraphComponent.js b/src/pages/chart/ECharts/GraphComponent.js similarity index 100% rename from src/routes/chart/ECharts/GraphComponent.js rename to src/pages/chart/ECharts/GraphComponent.js diff --git a/src/routes/chart/ECharts/LiquidfillComponent.js b/src/pages/chart/ECharts/LiquidfillComponent.js similarity index 100% rename from src/routes/chart/ECharts/LiquidfillComponent.js rename to src/pages/chart/ECharts/LiquidfillComponent.js diff --git a/src/routes/chart/ECharts/LunarCalendarComponent.js b/src/pages/chart/ECharts/LunarCalendarComponent.js similarity index 100% rename from src/routes/chart/ECharts/LunarCalendarComponent.js rename to src/pages/chart/ECharts/LunarCalendarComponent.js diff --git a/src/routes/chart/ECharts/MainPageComponent.js b/src/pages/chart/ECharts/MainPageComponent.js similarity index 100% rename from src/routes/chart/ECharts/MainPageComponent.js rename to src/pages/chart/ECharts/MainPageComponent.js diff --git a/src/routes/chart/ECharts/MapChartComponent.js b/src/pages/chart/ECharts/MapChartComponent.js similarity index 100% rename from src/routes/chart/ECharts/MapChartComponent.js rename to src/pages/chart/ECharts/MapChartComponent.js diff --git a/src/routes/chart/ECharts/ModuleLoadChartComponent.js b/src/pages/chart/ECharts/ModuleLoadChartComponent.js similarity index 100% rename from src/routes/chart/ECharts/ModuleLoadChartComponent.js rename to src/pages/chart/ECharts/ModuleLoadChartComponent.js diff --git a/src/routes/chart/ECharts/MoonComponent.js b/src/pages/chart/ECharts/MoonComponent.js similarity index 100% rename from src/routes/chart/ECharts/MoonComponent.js rename to src/pages/chart/ECharts/MoonComponent.js diff --git a/src/routes/chart/ECharts/SimpleChartComponent.js b/src/pages/chart/ECharts/SimpleChartComponent.js similarity index 100% rename from src/routes/chart/ECharts/SimpleChartComponent.js rename to src/pages/chart/ECharts/SimpleChartComponent.js diff --git a/src/routes/chart/ECharts/ThemeChartComponent.js b/src/pages/chart/ECharts/ThemeChartComponent.js similarity index 100% rename from src/routes/chart/ECharts/ThemeChartComponent.js rename to src/pages/chart/ECharts/ThemeChartComponent.js diff --git a/src/routes/chart/ECharts/TransparentBar3DComPonent.js b/src/pages/chart/ECharts/TransparentBar3DComPonent.js similarity index 100% rename from src/routes/chart/ECharts/TransparentBar3DComPonent.js rename to src/pages/chart/ECharts/TransparentBar3DComPonent.js diff --git a/src/routes/chart/ECharts/TreemapComponent.js b/src/pages/chart/ECharts/TreemapComponent.js similarity index 100% rename from src/routes/chart/ECharts/TreemapComponent.js rename to src/pages/chart/ECharts/TreemapComponent.js diff --git a/src/routes/chart/ECharts/index.js b/src/pages/chart/ECharts/index.js similarity index 100% rename from src/routes/chart/ECharts/index.js rename to src/pages/chart/ECharts/index.js diff --git a/src/routes/chart/ECharts/index.less b/src/pages/chart/ECharts/index.less similarity index 100% rename from src/routes/chart/ECharts/index.less rename to src/pages/chart/ECharts/index.less diff --git a/src/routes/chart/ECharts/theme/macarons.js b/src/pages/chart/ECharts/theme/macarons.js similarity index 100% rename from src/routes/chart/ECharts/theme/macarons.js rename to src/pages/chart/ECharts/theme/macarons.js diff --git a/src/routes/chart/ECharts/theme/shine.js b/src/pages/chart/ECharts/theme/shine.js similarity index 100% rename from src/routes/chart/ECharts/theme/shine.js rename to src/pages/chart/ECharts/theme/shine.js diff --git a/src/routes/chart/Recharts/AreaChartComponent.js b/src/pages/chart/Recharts/AreaChartComponent.js similarity index 100% rename from src/routes/chart/Recharts/AreaChartComponent.js rename to src/pages/chart/Recharts/AreaChartComponent.js diff --git a/src/routes/chart/Recharts/BarChartComponent.js b/src/pages/chart/Recharts/BarChartComponent.js similarity index 100% rename from src/routes/chart/Recharts/BarChartComponent.js rename to src/pages/chart/Recharts/BarChartComponent.js diff --git a/src/routes/chart/Recharts/Container.js b/src/pages/chart/Recharts/Container.js similarity index 100% rename from src/routes/chart/Recharts/Container.js rename to src/pages/chart/Recharts/Container.js diff --git a/src/routes/chart/Recharts/Container.less b/src/pages/chart/Recharts/Container.less similarity index 100% rename from src/routes/chart/Recharts/Container.less rename to src/pages/chart/Recharts/Container.less diff --git a/src/routes/chart/Recharts/LineChartComponent.js b/src/pages/chart/Recharts/LineChartComponent.js similarity index 100% rename from src/routes/chart/Recharts/LineChartComponent.js rename to src/pages/chart/Recharts/LineChartComponent.js diff --git a/src/routes/chart/Recharts/ReChartsComponent.js b/src/pages/chart/Recharts/ReChartsComponent.js similarity index 100% rename from src/routes/chart/Recharts/ReChartsComponent.js rename to src/pages/chart/Recharts/ReChartsComponent.js diff --git a/src/routes/chart/Recharts/index.js b/src/pages/chart/Recharts/index.js similarity index 100% rename from src/routes/chart/Recharts/index.js rename to src/pages/chart/Recharts/index.js diff --git a/src/routes/chart/Recharts/index.less b/src/pages/chart/Recharts/index.less similarity index 100% rename from src/routes/chart/Recharts/index.less rename to src/pages/chart/Recharts/index.less diff --git a/src/routes/chart/highCharts/HighChartsComponent.js b/src/pages/chart/highCharts/HighChartsComponent.js similarity index 100% rename from src/routes/chart/highCharts/HighChartsComponent.js rename to src/pages/chart/highCharts/HighChartsComponent.js diff --git a/src/routes/chart/highCharts/HighMoreComponent.js b/src/pages/chart/highCharts/HighMoreComponent.js similarity index 100% rename from src/routes/chart/highCharts/HighMoreComponent.js rename to src/pages/chart/highCharts/HighMoreComponent.js diff --git a/src/routes/chart/highCharts/HighmapsComponent.js b/src/pages/chart/highCharts/HighmapsComponent.js similarity index 100% rename from src/routes/chart/highCharts/HighmapsComponent.js rename to src/pages/chart/highCharts/HighmapsComponent.js diff --git a/src/routes/chart/highCharts/HighstockComponent.js b/src/pages/chart/highCharts/HighstockComponent.js similarity index 100% rename from src/routes/chart/highCharts/HighstockComponent.js rename to src/pages/chart/highCharts/HighstockComponent.js diff --git a/src/routes/chart/highCharts/index.js b/src/pages/chart/highCharts/index.js similarity index 100% rename from src/routes/chart/highCharts/index.js rename to src/pages/chart/highCharts/index.js diff --git a/src/routes/chart/highCharts/index.less b/src/pages/chart/highCharts/index.less similarity index 100% rename from src/routes/chart/highCharts/index.less rename to src/pages/chart/highCharts/index.less diff --git a/src/routes/chart/highCharts/mapdata/europe.js b/src/pages/chart/highCharts/mapdata/europe.js similarity index 100% rename from src/routes/chart/highCharts/mapdata/europe.js rename to src/pages/chart/highCharts/mapdata/europe.js diff --git a/src/routes/dashboard/components/browser.js b/src/pages/dashboard/components/browser.js similarity index 100% rename from src/routes/dashboard/components/browser.js rename to src/pages/dashboard/components/browser.js diff --git a/src/routes/dashboard/components/browser.less b/src/pages/dashboard/components/browser.less similarity index 100% rename from src/routes/dashboard/components/browser.less rename to src/pages/dashboard/components/browser.less diff --git a/src/routes/dashboard/components/comments.js b/src/pages/dashboard/components/comments.js similarity index 100% rename from src/routes/dashboard/components/comments.js rename to src/pages/dashboard/components/comments.js diff --git a/src/routes/dashboard/components/comments.less b/src/pages/dashboard/components/comments.less similarity index 100% rename from src/routes/dashboard/components/comments.less rename to src/pages/dashboard/components/comments.less diff --git a/src/routes/dashboard/components/completed.js b/src/pages/dashboard/components/completed.js similarity index 100% rename from src/routes/dashboard/components/completed.js rename to src/pages/dashboard/components/completed.js diff --git a/src/routes/dashboard/components/completed.less b/src/pages/dashboard/components/completed.less similarity index 100% rename from src/routes/dashboard/components/completed.less rename to src/pages/dashboard/components/completed.less diff --git a/src/routes/dashboard/components/cpu.js b/src/pages/dashboard/components/cpu.js similarity index 100% rename from src/routes/dashboard/components/cpu.js rename to src/pages/dashboard/components/cpu.js diff --git a/src/routes/dashboard/components/cpu.less b/src/pages/dashboard/components/cpu.less similarity index 100% rename from src/routes/dashboard/components/cpu.less rename to src/pages/dashboard/components/cpu.less diff --git a/src/routes/dashboard/components/index.js b/src/pages/dashboard/components/index.js similarity index 100% rename from src/routes/dashboard/components/index.js rename to src/pages/dashboard/components/index.js diff --git a/src/routes/dashboard/components/numberCard.js b/src/pages/dashboard/components/numberCard.js similarity index 100% rename from src/routes/dashboard/components/numberCard.js rename to src/pages/dashboard/components/numberCard.js diff --git a/src/routes/dashboard/components/numberCard.less b/src/pages/dashboard/components/numberCard.less similarity index 100% rename from src/routes/dashboard/components/numberCard.less rename to src/pages/dashboard/components/numberCard.less diff --git a/src/routes/dashboard/components/quote.js b/src/pages/dashboard/components/quote.js similarity index 100% rename from src/routes/dashboard/components/quote.js rename to src/pages/dashboard/components/quote.js diff --git a/src/routes/dashboard/components/quote.less b/src/pages/dashboard/components/quote.less similarity index 100% rename from src/routes/dashboard/components/quote.less rename to src/pages/dashboard/components/quote.less diff --git a/src/routes/dashboard/components/recentSales.js b/src/pages/dashboard/components/recentSales.js similarity index 100% rename from src/routes/dashboard/components/recentSales.js rename to src/pages/dashboard/components/recentSales.js diff --git a/src/routes/dashboard/components/recentSales.less b/src/pages/dashboard/components/recentSales.less similarity index 100% rename from src/routes/dashboard/components/recentSales.less rename to src/pages/dashboard/components/recentSales.less diff --git a/src/routes/dashboard/components/sales.js b/src/pages/dashboard/components/sales.js similarity index 100% rename from src/routes/dashboard/components/sales.js rename to src/pages/dashboard/components/sales.js diff --git a/src/routes/dashboard/components/sales.less b/src/pages/dashboard/components/sales.less similarity index 100% rename from src/routes/dashboard/components/sales.less rename to src/pages/dashboard/components/sales.less diff --git a/src/routes/dashboard/components/user-background.png b/src/pages/dashboard/components/user-background.png similarity index 100% rename from src/routes/dashboard/components/user-background.png rename to src/pages/dashboard/components/user-background.png diff --git a/src/routes/dashboard/components/user.js b/src/pages/dashboard/components/user.js similarity index 100% rename from src/routes/dashboard/components/user.js rename to src/pages/dashboard/components/user.js diff --git a/src/routes/dashboard/components/user.less b/src/pages/dashboard/components/user.less similarity index 100% rename from src/routes/dashboard/components/user.less rename to src/pages/dashboard/components/user.less diff --git a/src/routes/dashboard/components/weather.js b/src/pages/dashboard/components/weather.js similarity index 100% rename from src/routes/dashboard/components/weather.js rename to src/pages/dashboard/components/weather.js diff --git a/src/routes/dashboard/components/weather.less b/src/pages/dashboard/components/weather.less similarity index 100% rename from src/routes/dashboard/components/weather.less rename to src/pages/dashboard/components/weather.less diff --git a/src/routes/dashboard/index.js b/src/pages/dashboard/index.js similarity index 100% rename from src/routes/dashboard/index.js rename to src/pages/dashboard/index.js diff --git a/src/routes/dashboard/index.less b/src/pages/dashboard/index.less similarity index 100% rename from src/routes/dashboard/index.less rename to src/pages/dashboard/index.less diff --git a/src/models/dashboard.js b/src/pages/dashboard/models/dashboard.js similarity index 92% rename from src/models/dashboard.js rename to src/pages/dashboard/models/dashboard.js index 798377aa..26ef4fe7 100644 --- a/src/models/dashboard.js +++ b/src/pages/dashboard/models/dashboard.js @@ -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', diff --git a/src/services/dashboard.js b/src/pages/dashboard/services/dashboard.js similarity index 100% rename from src/services/dashboard.js rename to src/pages/dashboard/services/dashboard.js diff --git a/src/services/weather.js b/src/pages/dashboard/services/weather.js similarity index 100% rename from src/services/weather.js rename to src/pages/dashboard/services/weather.js diff --git a/src/document.ejs b/src/pages/document.ejs similarity index 100% rename from src/document.ejs rename to src/pages/document.ejs diff --git a/src/pages/index.js b/src/pages/index.js new file mode 100644 index 00000000..30f08c20 --- /dev/null +++ b/src/pages/index.js @@ -0,0 +1,3 @@ +import Redirect from 'umi/redirect' + +export default () => diff --git a/src/routes/login/index.js b/src/pages/login/index.js similarity index 100% rename from src/routes/login/index.js rename to src/pages/login/index.js diff --git a/src/routes/login/index.less b/src/pages/login/index.less similarity index 100% rename from src/routes/login/index.less rename to src/pages/login/index.less diff --git a/src/models/login.js b/src/pages/login/models/login.js similarity index 93% rename from src/models/login.js rename to src/pages/login/models/login.js index a40576f9..43ff59d9 100644 --- a/src/models/login.js +++ b/src/pages/login/models/login.js @@ -1,5 +1,5 @@ import { routerRedux } from 'dva/router' -import { login } from 'services/login' +import { login } from '../services/login' export default { namespace: 'login', diff --git a/src/services/login.js b/src/pages/login/services/login.js similarity index 100% rename from src/services/login.js rename to src/pages/login/services/login.js diff --git a/src/routes/post/List.js b/src/pages/post/components/List.js similarity index 100% rename from src/routes/post/List.js rename to src/pages/post/components/List.js diff --git a/src/routes/post/List.less b/src/pages/post/components/List.less similarity index 100% rename from src/routes/post/List.less rename to src/pages/post/components/List.less diff --git a/src/routes/post/index.js b/src/pages/post/index.js similarity index 97% rename from src/routes/post/index.js rename to src/pages/post/index.js index 87e39ed8..21e09c09 100644 --- a/src/routes/post/index.js +++ b/src/pages/post/index.js @@ -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 diff --git a/src/models/post.js b/src/pages/post/models/post.js similarity index 92% rename from src/models/post.js rename to src/pages/post/models/post.js index 797dcf53..c6929b98 100644 --- a/src/models/post.js +++ b/src/pages/post/models/post.js @@ -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, { diff --git a/src/services/posts.js b/src/pages/post/services/posts.js similarity index 100% rename from src/services/posts.js rename to src/pages/post/services/posts.js diff --git a/src/routes/request/index.js b/src/pages/request/index.js similarity index 100% rename from src/routes/request/index.js rename to src/pages/request/index.js diff --git a/src/routes/request/index.less b/src/pages/request/index.less similarity index 100% rename from src/routes/request/index.less rename to src/pages/request/index.less diff --git a/src/routes/user/detail/index.js b/src/pages/user/$id/index.js similarity index 100% rename from src/routes/user/detail/index.js rename to src/pages/user/$id/index.js diff --git a/src/routes/user/detail/index.less b/src/pages/user/$id/index.less similarity index 100% rename from src/routes/user/detail/index.less rename to src/pages/user/$id/index.less diff --git a/src/models/user/detail.js b/src/pages/user/$id/models/detail.js similarity index 100% rename from src/models/user/detail.js rename to src/pages/user/$id/models/detail.js diff --git a/src/routes/user/Filter.js b/src/pages/user/components/Filter.js similarity index 100% rename from src/routes/user/Filter.js rename to src/pages/user/components/Filter.js diff --git a/src/routes/user/List.js b/src/pages/user/components/List.js similarity index 100% rename from src/routes/user/List.js rename to src/pages/user/components/List.js diff --git a/src/routes/user/List.less b/src/pages/user/components/List.less similarity index 100% rename from src/routes/user/List.less rename to src/pages/user/components/List.less diff --git a/src/routes/user/Modal.js b/src/pages/user/components/Modal.js similarity index 100% rename from src/routes/user/Modal.js rename to src/pages/user/components/Modal.js diff --git a/src/routes/user/index.js b/src/pages/user/index.js similarity index 96% rename from src/routes/user/index.js rename to src/pages/user/index.js index 088c29d3..814eea65 100644 --- a/src/routes/user/index.js +++ b/src/pages/user/index.js @@ -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 = ({ diff --git a/src/models/user.js b/src/pages/user/models/user.js similarity index 94% rename from src/models/user.js rename to src/pages/user/models/user.js index bcf84686..206752f5 100644 --- a/src/models/user.js +++ b/src/pages/user/models/user.js @@ -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 diff --git a/src/services/user.js b/src/pages/user/services/user.js similarity index 100% rename from src/services/user.js rename to src/pages/user/services/user.js diff --git a/src/services/users.js b/src/pages/user/services/users.js similarity index 100% rename from src/services/users.js rename to src/pages/user/services/users.js diff --git a/src/plugins/onError.js b/src/plugins/onError.js new file mode 100644 index 00000000..9b769852 --- /dev/null +++ b/src/plugins/onError.js @@ -0,0 +1,8 @@ +import { message } from 'antd' + +export default { + onError(e) { + e.preventDefault() + message.error(error.message) + } +} diff --git a/src/router.js b/src/router.js index 1a8b9206..143de891 100644 --- a/src/router.js +++ b/src/router.js @@ -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', @@ -69,8 +62,6 @@ const Routers = function ({ history, app }) { return ( - - ()} /> { @@ -85,10 +76,7 @@ const Routers = function ({ history, app }) { /> )) } - - - ) } diff --git a/src/tests/models/example-test.js b/src/tests/models/example-test.js deleted file mode 100644 index 8b137891..00000000 --- a/src/tests/models/example-test.js +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/models/common.js b/src/utils/model.js similarity index 100% rename from src/models/common.js rename to src/utils/model.js