From 59e9a1053ea9a69cefd4b30a3c6617ee65d25af7 Mon Sep 17 00:00:00 2001 From: chencheng Date: Fri, 23 Mar 2018 22:51:41 +0800 Subject: [PATCH 1/8] refact config files and package.json --- .babelrc | 22 +++++++ .gitignore | 5 ++ .roadhogrc.js | 57 ----------------- .roadhogrc.mock.js | 5 -- .umirc.mock.js | 5 ++ .webpackrc.js | 16 +++++ {src/mock => mock}/common.js | 0 {src/mock => mock}/dashboard.js | 0 {src/mock => mock}/menu.js | 0 {src/mock => mock}/post.js | 0 {src/mock => mock}/user.js | 0 package.json | 39 +++--------- {src/public => public}/antd/iconfont.eot | Bin {src/public => public}/antd/iconfont.svg | 0 {src/public => public}/antd/iconfont.ttf | Bin {src/public => public}/antd/iconfont.woff | Bin .../assets/data-1491837999815-H1_44Qtal.jpg | Bin .../assets/data-1493804606544-r1PBU7D1W.jpg | Bin .../assets/data-1493804610896-SJoBIXPkW.jpg | Bin {src/public => public}/iconfont.css | 0 {src/public => public}/iconfont.eot | Bin {src/public => public}/iconfont.js | 0 {src/public => public}/iconfont.svg | 0 {src/public => public}/iconfont.ttf | Bin {src/public => public}/iconfont.woff | Bin {src/public => public}/logo.svg | 0 src/{entry.ejs => document.ejs} | 44 ++++++------- webpack.config.js | 59 ------------------ 28 files changed, 74 insertions(+), 178 deletions(-) create mode 100644 .babelrc delete mode 100644 .roadhogrc.js delete mode 100644 .roadhogrc.mock.js create mode 100644 .umirc.mock.js create mode 100644 .webpackrc.js rename {src/mock => mock}/common.js (100%) rename {src/mock => mock}/dashboard.js (100%) rename {src/mock => mock}/menu.js (100%) rename {src/mock => mock}/post.js (100%) rename {src/mock => mock}/user.js (100%) rename {src/public => public}/antd/iconfont.eot (100%) rename {src/public => public}/antd/iconfont.svg (100%) rename {src/public => public}/antd/iconfont.ttf (100%) rename {src/public => public}/antd/iconfont.woff (100%) rename {src/public => public}/assets/data-1491837999815-H1_44Qtal.jpg (100%) rename {src/public => public}/assets/data-1493804606544-r1PBU7D1W.jpg (100%) rename {src/public => public}/assets/data-1493804610896-SJoBIXPkW.jpg (100%) rename {src/public => public}/iconfont.css (100%) rename {src/public => public}/iconfont.eot (100%) rename {src/public => public}/iconfont.js (100%) rename {src/public => public}/iconfont.svg (100%) rename {src/public => public}/iconfont.ttf (100%) rename {src/public => public}/iconfont.woff (100%) rename {src/public => public}/logo.svg (100%) rename src/{entry.ejs => document.ejs} (71%) delete mode 100644 webpack.config.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..710f153e --- /dev/null +++ b/.babelrc @@ -0,0 +1,22 @@ +{ + "presets": [ + "umi/babel" + ], + "plugins": [ + [ + "babel-plugin-module-resolver", + { + "alias": { + "components": "./src/components", + "utils": "./src/utils", + "config": "./src/utils/config", + "enums": "./src/utils/enums", + "services": "./src/services", + "models": "./src/models", + "routes": "./src/routes", + "themes": "./src/themes" + } + } + ] + ] +} diff --git a/.gitignore b/.gitignore index 46661141..d1c78d12 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ dist node_modules yarn.lock npm-debug.log + # ide .idea @@ -9,3 +10,7 @@ npm-debug.log .DS_Store .AppleDouble .LSOverride + +# umi +.umi +.umi-production diff --git a/.roadhogrc.js b/.roadhogrc.js deleted file mode 100644 index 9b76d6fc..00000000 --- a/.roadhogrc.js +++ /dev/null @@ -1,57 +0,0 @@ -const path = require('path') -const { version } = require('./package.json') - -const svgSpriteDirs = [ - path.resolve(__dirname, 'src/svg/'), - require.resolve('antd').replace(/index\.js$/, '') -] - -export default { - entry: 'src/index.js', - svgSpriteLoaderDirs: svgSpriteDirs, - theme: "./theme.config.js", - publicPath: `/${version}/`, - outputPath: `./dist/${version}`, - // 接口代理示例 - proxy: { - "/api/v1/weather": { - "target": "https://api.seniverse.com/", - "changeOrigin": true, - "pathRewrite": { "^/api/v1/weather": "/v3/weather" } - }, - // "/api/v2": { - // "target": "http://192.168.0.110", - // "changeOrigin": true, - // "pathRewrite": { "^/api/v2" : "/api/v2" } - // } - }, - env: { - development: { - extraBabelPlugins: [ - "dva-hmr", - "transform-runtime", - [ - "import", { - "libraryName": "antd", - "style": true - } - ] - ] - }, - production: { - extraBabelPlugins: [ - "transform-runtime", - [ - "import", { - "libraryName": "antd", - "style": true - } - ] - ] - } - }, - dllPlugin: { - exclude: ["babel-runtime", "roadhog", "cross-env"], - include: ["dva/router", "dva/saga", "dva/fetch"] - } -} diff --git a/.roadhogrc.mock.js b/.roadhogrc.mock.js deleted file mode 100644 index fc068f08..00000000 --- a/.roadhogrc.mock.js +++ /dev/null @@ -1,5 +0,0 @@ -const mock = {} -require('fs').readdirSync(require('path').join(__dirname + '/src/mock')).forEach(function(file) { - Object.assign(mock, require('./src/mock/' + file)) -}) -module.exports = mock diff --git a/.umirc.mock.js b/.umirc.mock.js new file mode 100644 index 00000000..08feb114 --- /dev/null +++ b/.umirc.mock.js @@ -0,0 +1,5 @@ +const mock = {} +require('fs').readdirSync(require('path').join(__dirname + '/mock')).forEach(function(file) { + Object.assign(mock, require('./mock/' + file)) +}) +module.exports = mock diff --git a/.webpackrc.js b/.webpackrc.js new file mode 100644 index 00000000..4249e0a2 --- /dev/null +++ b/.webpackrc.js @@ -0,0 +1,16 @@ +export default { + theme: "./theme.config.js", + // 接口代理示例 + proxy: { + "/api/v1/weather": { + "target": "https://api.seniverse.com/", + "changeOrigin": true, + "pathRewrite": { "^/api/v1/weather": "/v3/weather" } + }, + // "/api/v2": { + // "target": "http://192.168.0.110", + // "changeOrigin": true, + // "pathRewrite": { "^/api/v2" : "/api/v2" } + // } + }, +} diff --git a/src/mock/common.js b/mock/common.js similarity index 100% rename from src/mock/common.js rename to mock/common.js diff --git a/src/mock/dashboard.js b/mock/dashboard.js similarity index 100% rename from src/mock/dashboard.js rename to mock/dashboard.js diff --git a/src/mock/menu.js b/mock/menu.js similarity index 100% rename from src/mock/menu.js rename to mock/menu.js diff --git a/src/mock/post.js b/mock/post.js similarity index 100% rename from src/mock/post.js rename to mock/post.js diff --git a/src/mock/user.js b/mock/user.js similarity index 100% rename from src/mock/user.js rename to mock/user.js diff --git a/package.json b/package.json index 3c274c6e..150a917c 100644 --- a/package.json +++ b/package.json @@ -3,72 +3,47 @@ "name": "antd-admin", "version": "4.3.9", "dependencies": { - "antd": "3.2.2", "axios": "^0.17.1", - "babel-polyfill": "^6.23.0", "classnames": "^2.2.5", - "cross-env": "^5.0.5", "d3-shape": "^1.2.0", "draftjs-to-markdown": "^0.5.0", - "dva": "2.1.0", - "dva-loading": "^1.0.4", + "dva-model-extend": "^0.1.1", "echarts": "^4.0.0", "echarts-for-react": "^2.0.0", "echarts-gl": "^1.0.0-beta.5", "echarts-liquidfill": "^1.1.0", - "ejs-loader": "^0.3.0", "highcharts-exporting": "^0.1.2", "highcharts-more": "^0.1.2", "history": "^4.7.2", "js-beautify": "^1.6.14", "jsonp": "^0.2.1", - "less-vars-to-js": "^1.1.2", "lodash": "^4.17.4", "mockjs": "^1.0.1-beta3", "nprogress": "^0.2.0", "path-to-regexp": "^2.1.0", "prop-types": "^15.5.10", "qs": "^6.5.0", - "query-string": "^5.0.0", "rc-tween-one": "^1.3.1", - "react": "^16.2.0", "react-countup": "^3.0.2", - "react-dom": "^16.2.0", "react-draft-wysiwyg": "^1.10.0", "react-helmet": "^5.1.3", "react-highcharts": "^15.0.0", "recharts": "^1.0.0-beta.0" }, "devDependencies": { - "babel-eslint": "^8.1.0", "babel-plugin-dev-expression": "^0.2.1", - "babel-plugin-dva-hmr": "^0.4.0", - "babel-plugin-import": "^1.1.1", - "babel-plugin-transform-runtime": "^6.9.0", - "babel-runtime": "^6.9.2", - "copy-webpack-plugin": "^4.0.1", + "babel-plugin-module-resolver": "^3.1.0", + "cross-env": "^5.0.5", "draftjs-to-html": "^0.8.1", - "dva-model-extend": "^0.1.1", - "eslint": "^4.1.1", - "eslint-config-airbnb": "^16.1.0", - "eslint-import-resolver-node": "^0.3.1", - "eslint-loader": "^1.9.0", - "eslint-plugin-import": "^2.6.1", - "eslint-plugin-jsx-a11y": "^6.0.2", - "eslint-plugin-react": "^7.1.0", - "html-webpack-plugin": "^2.29.0", - "redbox-react": "^1.2.10", - "roadhog": "1.3.1" + "less-vars-to-js": "^1.1.2" }, "pre-commit": [ "lint" ], "scripts": { - "dev": "cross-env BROWSER=none HOST=0.0.0.0 roadhog server", - "start": "roadhog buildDll && cross-env BROWSER=none HOST=0.0.0.0 roadhog server", + "start": "cross-env BABELRC=1 BROWSER=none HOST=0.0.0.0 umi dev", "lint": "eslint --fix --ext .js src", - "build": "roadhog build", - "build:dll": "roadhog buildDll", - "build:new": "node version && roadhog build" + "build": "umi build", + "test": "umi test" } } diff --git a/src/public/antd/iconfont.eot b/public/antd/iconfont.eot similarity index 100% rename from src/public/antd/iconfont.eot rename to public/antd/iconfont.eot diff --git a/src/public/antd/iconfont.svg b/public/antd/iconfont.svg similarity index 100% rename from src/public/antd/iconfont.svg rename to public/antd/iconfont.svg diff --git a/src/public/antd/iconfont.ttf b/public/antd/iconfont.ttf similarity index 100% rename from src/public/antd/iconfont.ttf rename to public/antd/iconfont.ttf diff --git a/src/public/antd/iconfont.woff b/public/antd/iconfont.woff similarity index 100% rename from src/public/antd/iconfont.woff rename to public/antd/iconfont.woff diff --git a/src/public/assets/data-1491837999815-H1_44Qtal.jpg b/public/assets/data-1491837999815-H1_44Qtal.jpg similarity index 100% rename from src/public/assets/data-1491837999815-H1_44Qtal.jpg rename to public/assets/data-1491837999815-H1_44Qtal.jpg diff --git a/src/public/assets/data-1493804606544-r1PBU7D1W.jpg b/public/assets/data-1493804606544-r1PBU7D1W.jpg similarity index 100% rename from src/public/assets/data-1493804606544-r1PBU7D1W.jpg rename to public/assets/data-1493804606544-r1PBU7D1W.jpg diff --git a/src/public/assets/data-1493804610896-SJoBIXPkW.jpg b/public/assets/data-1493804610896-SJoBIXPkW.jpg similarity index 100% rename from src/public/assets/data-1493804610896-SJoBIXPkW.jpg rename to public/assets/data-1493804610896-SJoBIXPkW.jpg diff --git a/src/public/iconfont.css b/public/iconfont.css similarity index 100% rename from src/public/iconfont.css rename to public/iconfont.css diff --git a/src/public/iconfont.eot b/public/iconfont.eot similarity index 100% rename from src/public/iconfont.eot rename to public/iconfont.eot diff --git a/src/public/iconfont.js b/public/iconfont.js similarity index 100% rename from src/public/iconfont.js rename to public/iconfont.js diff --git a/src/public/iconfont.svg b/public/iconfont.svg similarity index 100% rename from src/public/iconfont.svg rename to public/iconfont.svg diff --git a/src/public/iconfont.ttf b/public/iconfont.ttf similarity index 100% rename from src/public/iconfont.ttf rename to public/iconfont.ttf diff --git a/src/public/iconfont.woff b/public/iconfont.woff similarity index 100% rename from src/public/iconfont.woff rename to public/iconfont.woff diff --git a/src/public/logo.svg b/public/logo.svg similarity index 100% rename from src/public/logo.svg rename to public/logo.svg diff --git a/src/entry.ejs b/src/document.ejs similarity index 71% rename from src/entry.ejs rename to src/document.ejs index 2e149a91..de5e2433 100644 --- a/src/entry.ejs +++ b/src/document.ejs @@ -1,25 +1,19 @@ -<% htmlWebpackPlugin.options.headScripts = htmlWebpackPlugin.options.headScripts || [] %> - - - - - - - - - antd admin - - <% for (item of htmlWebpackPlugin.options.headScripts) { %> - - <% } %> - - - -
- - - - + + + + + + + + antd admin + + + + +
+ + + diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 2abc96f5..00000000 --- a/webpack.config.js +++ /dev/null @@ -1,59 +0,0 @@ -const HtmlWebpackPlugin = require('html-webpack-plugin') -const CopyWebpackPlugin = require('copy-webpack-plugin') -const webpack = require('webpack') - -module.exports = (webpackConfig, env) => { - const production = env === 'production' - // FilenameHash - webpackConfig.output.chunkFilename = '[name].[chunkhash].js' - - if (production) { - if (webpackConfig.module) { - // ClassnameHash - webpackConfig.module.rules.map((item) => { - if (String(item.test) === '/\\.less$/' || String(item.test) === '/\\.css/') { - item.use.filter(iitem => iitem.loader === 'css')[0].options.localIdentName = '[hash:base64:5]' - } - return item - }) - } - webpackConfig.plugins.push( - new webpack.LoaderOptionsPlugin({ - minimize: true, - debug: false, - }) - ) - } - - webpackConfig.plugins = webpackConfig.plugins.concat([ - new CopyWebpackPlugin([ - { - from: 'src/public', - to: production ? '../' : webpackConfig.output.outputPath, - }, - ]), - new HtmlWebpackPlugin({ - template: `${__dirname}/src/entry.ejs`, - filename: production ? '../index.html' : 'index.html', - minify: production ? { - collapseWhitespace: true, - } : null, - hash: true, - headScripts: production ? null : ['/roadhog.dll.js'], - }), - ]) - - // Alias - webpackConfig.resolve.alias = { - components: `${__dirname}/src/components`, - utils: `${__dirname}/src/utils`, - config: `${__dirname}/src/utils/config`, - enums: `${__dirname}/src/utils/enums`, - services: `${__dirname}/src/services`, - models: `${__dirname}/src/models`, - routes: `${__dirname}/src/routes`, - themes: `${__dirname}/src/themes`, - } - - return webpackConfig -} From d4e10ad5c231a486cb993b8f9ff308607e7004af Mon Sep 17 00:00:00 2001 From: chencheng Date: Fri, 23 Mar 2018 23:31:09 +0800 Subject: [PATCH 2/8] refact the directory structure --- .umirc.js | 19 +++++++++++++ package.json | 6 ++++- src/global.js | 1 + src/index.js | 25 ------------------ src/{routes => layouts}/app.js | 2 +- src/{routes => layouts}/app.less | 0 src/layouts/index.js | 14 ++++++++++ src/{routes/error/index.js => pages/404.js} | 2 +- .../error/index.less => pages/404.less} | 0 .../UIElement/dataTable/index.js | 0 .../UIElement/dropOption/index.js | 0 .../UIElement/editor/index.js | 0 .../UIElement/iconfont/emoji.js | 0 .../UIElement/iconfont/index.js | 0 .../UIElement/iconfont/index.less | 0 .../UIElement/layer/index.js | 0 .../UIElement/search/index.js | 0 src/{routes => pages}/chart/Container.js | 0 src/{routes => pages}/chart/Container.less | 0 .../chart/ECharts/AirportCoordComponent.js | 0 .../chart/ECharts/BubbleGradientComponent.js | 0 .../chart/ECharts/CalendarComponent.js | 0 .../chart/ECharts/ChartAPIComponent.js | 0 .../ECharts/ChartShowLoadingComponent.js | 0 .../chart/ECharts/ChartWithEventComponent.js | 0 .../chart/ECharts/DynamicChartComponent.js | 0 .../chart/ECharts/EchartsComponent.js | 0 .../chart/ECharts/GCalendarComponent.js | 0 .../chart/ECharts/GaugeComponent.js | 0 .../chart/ECharts/GraphComponent.js | 0 .../chart/ECharts/LiquidfillComponent.js | 0 .../chart/ECharts/LunarCalendarComponent.js | 0 .../chart/ECharts/MainPageComponent.js | 0 .../chart/ECharts/MapChartComponent.js | 0 .../chart/ECharts/ModuleLoadChartComponent.js | 0 .../chart/ECharts/MoonComponent.js | 0 .../chart/ECharts/SimpleChartComponent.js | 0 .../chart/ECharts/ThemeChartComponent.js | 0 .../ECharts/TransparentBar3DComPonent.js | 0 .../chart/ECharts/TreemapComponent.js | 0 src/{routes => pages}/chart/ECharts/index.js | 0 .../chart/ECharts/index.less | 0 .../chart/ECharts/theme/macarons.js | 0 .../chart/ECharts/theme/shine.js | 0 .../chart/Recharts/AreaChartComponent.js | 0 .../chart/Recharts/BarChartComponent.js | 0 .../chart/Recharts/Container.js | 0 .../chart/Recharts/Container.less | 0 .../chart/Recharts/LineChartComponent.js | 0 .../chart/Recharts/ReChartsComponent.js | 0 src/{routes => pages}/chart/Recharts/index.js | 0 .../chart/Recharts/index.less | 0 .../chart/highCharts/HighChartsComponent.js | 0 .../chart/highCharts/HighMoreComponent.js | 0 .../chart/highCharts/HighmapsComponent.js | 0 .../chart/highCharts/HighstockComponent.js | 0 .../chart/highCharts/index.js | 0 .../chart/highCharts/index.less | 0 .../chart/highCharts/mapdata/europe.js | 0 .../dashboard/components/browser.js | 0 .../dashboard/components/browser.less | 0 .../dashboard/components/comments.js | 0 .../dashboard/components/comments.less | 0 .../dashboard/components/completed.js | 0 .../dashboard/components/completed.less | 0 .../dashboard/components/cpu.js | 0 .../dashboard/components/cpu.less | 0 .../dashboard/components/index.js | 0 .../dashboard/components/numberCard.js | 0 .../dashboard/components/numberCard.less | 0 .../dashboard/components/quote.js | 0 .../dashboard/components/quote.less | 0 .../dashboard/components/recentSales.js | 0 .../dashboard/components/recentSales.less | 0 .../dashboard/components/sales.js | 0 .../dashboard/components/sales.less | 0 .../dashboard/components/user-background.png | Bin .../dashboard/components/user.js | 0 .../dashboard/components/user.less | 0 .../dashboard/components/weather.js | 0 .../dashboard/components/weather.less | 0 src/{routes => pages}/dashboard/index.js | 0 src/{routes => pages}/dashboard/index.less | 0 src/{ => pages/dashboard}/models/dashboard.js | 6 ++--- .../dashboard}/services/dashboard.js | 0 src/{ => pages/dashboard}/services/weather.js | 0 src/{ => pages}/document.ejs | 0 src/pages/index.js | 3 +++ src/{routes => pages}/login/index.js | 0 src/{routes => pages}/login/index.less | 0 src/{ => pages/login}/models/login.js | 2 +- src/{ => pages/login}/services/login.js | 0 .../post => pages/post/components}/List.js | 0 .../post => pages/post/components}/List.less | 0 src/{routes => pages}/post/index.js | 2 +- src/{ => pages/post}/models/post.js | 4 +-- src/{ => pages/post}/services/posts.js | 0 src/{routes => pages}/request/index.js | 0 src/{routes => pages}/request/index.less | 0 .../user/detail => pages/user/$id}/index.js | 0 .../user/detail => pages/user/$id}/index.less | 0 .../user => pages/user/$id/models}/detail.js | 0 .../user => pages/user/components}/Filter.js | 0 .../user => pages/user/components}/List.js | 0 .../user => pages/user/components}/List.less | 0 .../user => pages/user/components}/Modal.js | 0 src/{routes => pages}/user/index.js | 6 ++--- src/{ => pages/user}/models/user.js | 6 ++--- src/{ => pages/user}/services/user.js | 0 src/{ => pages/user}/services/users.js | 0 src/plugins/onError.js | 8 ++++++ src/router.js | 12 --------- src/tests/models/example-test.js | 1 - src/{models/common.js => utils/model.js} | 0 114 files changed, 65 insertions(+), 54 deletions(-) create mode 100644 .umirc.js create mode 100644 src/global.js delete mode 100644 src/index.js rename src/{routes => layouts}/app.js (99%) rename src/{routes => layouts}/app.less (100%) create mode 100644 src/layouts/index.js rename src/{routes/error/index.js => pages/404.js} (88%) rename src/{routes/error/index.less => pages/404.less} (100%) rename src/{routes => pages}/UIElement/dataTable/index.js (100%) rename src/{routes => pages}/UIElement/dropOption/index.js (100%) rename src/{routes => pages}/UIElement/editor/index.js (100%) rename src/{routes => pages}/UIElement/iconfont/emoji.js (100%) rename src/{routes => pages}/UIElement/iconfont/index.js (100%) rename src/{routes => pages}/UIElement/iconfont/index.less (100%) rename src/{routes => pages}/UIElement/layer/index.js (100%) rename src/{routes => pages}/UIElement/search/index.js (100%) rename src/{routes => pages}/chart/Container.js (100%) rename src/{routes => pages}/chart/Container.less (100%) rename src/{routes => pages}/chart/ECharts/AirportCoordComponent.js (100%) rename src/{routes => pages}/chart/ECharts/BubbleGradientComponent.js (100%) rename src/{routes => pages}/chart/ECharts/CalendarComponent.js (100%) rename src/{routes => pages}/chart/ECharts/ChartAPIComponent.js (100%) rename src/{routes => pages}/chart/ECharts/ChartShowLoadingComponent.js (100%) rename src/{routes => pages}/chart/ECharts/ChartWithEventComponent.js (100%) rename src/{routes => pages}/chart/ECharts/DynamicChartComponent.js (100%) rename src/{routes => pages}/chart/ECharts/EchartsComponent.js (100%) rename src/{routes => pages}/chart/ECharts/GCalendarComponent.js (100%) rename src/{routes => pages}/chart/ECharts/GaugeComponent.js (100%) rename src/{routes => pages}/chart/ECharts/GraphComponent.js (100%) rename src/{routes => pages}/chart/ECharts/LiquidfillComponent.js (100%) rename src/{routes => pages}/chart/ECharts/LunarCalendarComponent.js (100%) rename src/{routes => pages}/chart/ECharts/MainPageComponent.js (100%) rename src/{routes => pages}/chart/ECharts/MapChartComponent.js (100%) rename src/{routes => pages}/chart/ECharts/ModuleLoadChartComponent.js (100%) rename src/{routes => pages}/chart/ECharts/MoonComponent.js (100%) rename src/{routes => pages}/chart/ECharts/SimpleChartComponent.js (100%) rename src/{routes => pages}/chart/ECharts/ThemeChartComponent.js (100%) rename src/{routes => pages}/chart/ECharts/TransparentBar3DComPonent.js (100%) rename src/{routes => pages}/chart/ECharts/TreemapComponent.js (100%) rename src/{routes => pages}/chart/ECharts/index.js (100%) rename src/{routes => pages}/chart/ECharts/index.less (100%) rename src/{routes => pages}/chart/ECharts/theme/macarons.js (100%) rename src/{routes => pages}/chart/ECharts/theme/shine.js (100%) rename src/{routes => pages}/chart/Recharts/AreaChartComponent.js (100%) rename src/{routes => pages}/chart/Recharts/BarChartComponent.js (100%) rename src/{routes => pages}/chart/Recharts/Container.js (100%) rename src/{routes => pages}/chart/Recharts/Container.less (100%) rename src/{routes => pages}/chart/Recharts/LineChartComponent.js (100%) rename src/{routes => pages}/chart/Recharts/ReChartsComponent.js (100%) rename src/{routes => pages}/chart/Recharts/index.js (100%) rename src/{routes => pages}/chart/Recharts/index.less (100%) rename src/{routes => pages}/chart/highCharts/HighChartsComponent.js (100%) rename src/{routes => pages}/chart/highCharts/HighMoreComponent.js (100%) rename src/{routes => pages}/chart/highCharts/HighmapsComponent.js (100%) rename src/{routes => pages}/chart/highCharts/HighstockComponent.js (100%) rename src/{routes => pages}/chart/highCharts/index.js (100%) rename src/{routes => pages}/chart/highCharts/index.less (100%) rename src/{routes => pages}/chart/highCharts/mapdata/europe.js (100%) rename src/{routes => pages}/dashboard/components/browser.js (100%) rename src/{routes => pages}/dashboard/components/browser.less (100%) rename src/{routes => pages}/dashboard/components/comments.js (100%) rename src/{routes => pages}/dashboard/components/comments.less (100%) rename src/{routes => pages}/dashboard/components/completed.js (100%) rename src/{routes => pages}/dashboard/components/completed.less (100%) rename src/{routes => pages}/dashboard/components/cpu.js (100%) rename src/{routes => pages}/dashboard/components/cpu.less (100%) rename src/{routes => pages}/dashboard/components/index.js (100%) rename src/{routes => pages}/dashboard/components/numberCard.js (100%) rename src/{routes => pages}/dashboard/components/numberCard.less (100%) rename src/{routes => pages}/dashboard/components/quote.js (100%) rename src/{routes => pages}/dashboard/components/quote.less (100%) rename src/{routes => pages}/dashboard/components/recentSales.js (100%) rename src/{routes => pages}/dashboard/components/recentSales.less (100%) rename src/{routes => pages}/dashboard/components/sales.js (100%) rename src/{routes => pages}/dashboard/components/sales.less (100%) rename src/{routes => pages}/dashboard/components/user-background.png (100%) rename src/{routes => pages}/dashboard/components/user.js (100%) rename src/{routes => pages}/dashboard/components/user.less (100%) rename src/{routes => pages}/dashboard/components/weather.js (100%) rename src/{routes => pages}/dashboard/components/weather.less (100%) rename src/{routes => pages}/dashboard/index.js (100%) rename src/{routes => pages}/dashboard/index.less (100%) rename src/{ => pages/dashboard}/models/dashboard.js (92%) rename src/{ => pages/dashboard}/services/dashboard.js (100%) rename src/{ => pages/dashboard}/services/weather.js (100%) rename src/{ => pages}/document.ejs (100%) create mode 100644 src/pages/index.js rename src/{routes => pages}/login/index.js (100%) rename src/{routes => pages}/login/index.less (100%) rename src/{ => pages/login}/models/login.js (93%) rename src/{ => pages/login}/services/login.js (100%) rename src/{routes/post => pages/post/components}/List.js (100%) rename src/{routes/post => pages/post/components}/List.less (100%) rename src/{routes => pages}/post/index.js (97%) rename src/{ => pages/post}/models/post.js (92%) rename src/{ => pages/post}/services/posts.js (100%) rename src/{routes => pages}/request/index.js (100%) rename src/{routes => pages}/request/index.less (100%) rename src/{routes/user/detail => pages/user/$id}/index.js (100%) rename src/{routes/user/detail => pages/user/$id}/index.less (100%) rename src/{models/user => pages/user/$id/models}/detail.js (100%) rename src/{routes/user => pages/user/components}/Filter.js (100%) rename src/{routes/user => pages/user/components}/List.js (100%) rename src/{routes/user => pages/user/components}/List.less (100%) rename src/{routes/user => pages/user/components}/Modal.js (100%) rename src/{routes => pages}/user/index.js (96%) rename src/{ => pages/user}/models/user.js (94%) rename src/{ => pages/user}/services/user.js (100%) rename src/{ => pages/user}/services/users.js (100%) create mode 100644 src/plugins/onError.js delete mode 100644 src/tests/models/example-test.js rename src/{models/common.js => utils/model.js} (100%) 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 From a3071819c496dfbdc294ea1844e5d482d6d41cee Mon Sep 17 00:00:00 2001 From: chencheng Date: Sat, 24 Mar 2018 09:07:36 +0800 Subject: [PATCH 3/8] eslint --- .eslintrc | 16 ++-------------- package.json | 6 ++++++ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.eslintrc b/.eslintrc index 343890d1..efb25087 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,5 @@ { - "extends": "airbnb", + "extends": "umi", "rules": { "arrow-body-style": [0, "never"], "comma-dangle": [2, "always-multiline"], @@ -44,17 +44,5 @@ "react/no-danger": 0, "react/jsx-first-prop-new-line": 0, "react/jsx-filename-extension": 0 - }, - "parser": "babel-eslint", - "parserOptions": { - "sourceType": "module", - "ecmaVersion": 8, - "ecmaFeatures": { - "jsx": true, - "experimentalObjectRestSpread": true - } - }, - "settings": { - "import/resolver": "node" - } + } } diff --git a/package.json b/package.json index b9cc4af4..9c308b39 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,12 @@ "babel-plugin-module-resolver": "^3.1.0", "cross-env": "^5.0.5", "draftjs-to-html": "^0.8.1", + "eslint": "^4.19.1", + "eslint-config-umi": "^0.1.4", + "eslint-plugin-flowtype": "^2.46.1", + "eslint-plugin-import": "^2.9.0", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-react": "^7.7.0", "less-vars-to-js": "^1.1.2" }, "pre-commit": [ From fb49056c73eeae1a58d9169761c937c676faeb29 Mon Sep 17 00:00:00 2001 From: chencheng Date: Sat, 24 Mar 2018 14:39:54 +0800 Subject: [PATCH 4/8] make login work --- .babelrc | 3 +- .umirc.mock.js | 13 +- .webpackrc.js | 5 + mock/common.js | 2 +- mock/dashboard.js | 4 +- mock/user.js | 2 +- src/components/Layout/Header.less | 184 +++++++-------- src/components/Layout/Layout.less | 376 +++++++++++++++--------------- src/components/Page/Page.less | 32 +-- src/layouts/app.less | 144 ++++++------ src/plugins/onError.js | 6 +- src/themes/index.less | 270 ++++++++++----------- src/themes/vars.less | 4 +- src/utils/index.js | 28 +-- src/utils/model.js | 10 +- 15 files changed, 537 insertions(+), 546 deletions(-) diff --git a/.babelrc b/.babelrc index 710f153e..e391846f 100644 --- a/.babelrc +++ b/.babelrc @@ -13,8 +13,7 @@ "enums": "./src/utils/enums", "services": "./src/services", "models": "./src/models", - "routes": "./src/routes", - "themes": "./src/themes" + "routes": "./src/routes" } } ] diff --git a/.umirc.mock.js b/.umirc.mock.js index 08feb114..fb7e6fb0 100644 --- a/.umirc.mock.js +++ b/.umirc.mock.js @@ -1,5 +1,8 @@ -const mock = {} -require('fs').readdirSync(require('path').join(__dirname + '/mock')).forEach(function(file) { - Object.assign(mock, require('./mock/' + file)) -}) -module.exports = mock + +export default { + ...require('./mock/common'), + ...require('./mock/dashboard'), + ...require('./mock/menu'), + ...require('./mock/post'), + ...require('./mock/user'), +} diff --git a/.webpackrc.js b/.webpackrc.js index 4249e0a2..a96cd180 100644 --- a/.webpackrc.js +++ b/.webpackrc.js @@ -1,3 +1,5 @@ +import { resolve } from 'path'; + export default { theme: "./theme.config.js", // 接口代理示例 @@ -13,4 +15,7 @@ export default { // "pathRewrite": { "^/api/v2" : "/api/v2" } // } }, + alias: { + themes: resolve(__dirname, './src/themes'), + }, } diff --git a/mock/common.js b/mock/common.js index c8b79e9a..1d5436de 100644 --- a/mock/common.js +++ b/mock/common.js @@ -1,5 +1,5 @@ const Mock = require('mockjs') -const config = require('../utils/config') +const config = require('../src/utils/config') const queryArray = (array, key, keyAlias = 'key') => { if (!(array instanceof Array)) { diff --git a/mock/dashboard.js b/mock/dashboard.js index 788bc56a..9f31a4a9 100644 --- a/mock/dashboard.js +++ b/mock/dashboard.js @@ -1,7 +1,7 @@ -import { color } from '../utils/theme' +import { color } from '../src/utils/theme' const Mock = require('mockjs') -const config = require('../utils/config') +const config = require('../src/utils/config') const { apiPrefix } = config diff --git a/mock/user.js b/mock/user.js index 6dd8a8f2..c3ee292c 100644 --- a/mock/user.js +++ b/mock/user.js @@ -1,6 +1,6 @@ const qs = require('qs') const Mock = require('mockjs') -const config = require('../utils/config') +const config = require('../src/utils/config') const { apiPrefix } = config diff --git a/src/components/Layout/Header.less b/src/components/Layout/Header.less index 9312ad2c..9bfde842 100644 --- a/src/components/Layout/Header.less +++ b/src/components/Layout/Header.less @@ -1,92 +1,92 @@ -@import "~themes/vars"; - -.header { - :global { - .ant-menu-submenu-title { - height: 56px; - } - - .ant-menu-horizontal { - line-height: 56px; - - & > .ant-menu-submenu:hover { - color: #1890ff; - background-color: rgba(24, 144, 255, 0.15); - } - } - - .ant-menu { - border-bottom: none; - height: 56px; - } - - .ant-menu-horizontal > .ant-menu-submenu { - top: 0; - margin-top: 0; - } - - .ant-menu-horizontal > .ant-menu-item, - .ant-menu-horizontal > .ant-menu-submenu { - border-bottom: none; - } - - .ant-menu-horizontal > .ant-menu-item-active, - .ant-menu-horizontal > .ant-menu-item-open, - .ant-menu-horizontal > .ant-menu-item-selected, - .ant-menu-horizontal > .ant-menu-item:hover, - .ant-menu-horizontal > .ant-menu-submenu-active, - .ant-menu-horizontal > .ant-menu-submenu-open, - .ant-menu-horizontal > .ant-menu-submenu-selected, - .ant-menu-horizontal > .ant-menu-submenu:hover { - border-bottom: none; - } - } - box-shadow: @shadow-2; - position: relative; - display: flex; - justify-content: space-between; - height: 56px; - z-index: 9; - display: flex; - align-items: center; - background-color: #fff; - - .rightWarpper { - display: flex; - padding-right: 16px; - } - - .button { - width: 56px; - height: 56px; - line-height: 56px; - text-align: center; - font-size: 18px; - cursor: pointer; - transition: @transition-ease-in; - - &:hover { - color: @primary-color; - background-color: fade(@primary-color, 15%); - } - } -} - -.popovermenu { - width: 280px; - margin-left: 6px; - - :global .ant-popover-inner-content { - padding: 0; - - .ant-menu-inline .ant-menu-item, - .ant-menu-vertical .ant-menu-item { - border-right: 0; - } - - .ant-menu-inline .ant-menu-item-selected, - .ant-menu-inline .ant-menu-selected { - border-right: 0; - } - } -} +@import "~themes/vars.less"; + +.header { + :global { + .ant-menu-submenu-title { + height: 56px; + } + + .ant-menu-horizontal { + line-height: 56px; + + & > .ant-menu-submenu:hover { + color: #1890ff; + background-color: rgba(24, 144, 255, 0.15); + } + } + + .ant-menu { + border-bottom: none; + height: 56px; + } + + .ant-menu-horizontal > .ant-menu-submenu { + top: 0; + margin-top: 0; + } + + .ant-menu-horizontal > .ant-menu-item, + .ant-menu-horizontal > .ant-menu-submenu { + border-bottom: none; + } + + .ant-menu-horizontal > .ant-menu-item-active, + .ant-menu-horizontal > .ant-menu-item-open, + .ant-menu-horizontal > .ant-menu-item-selected, + .ant-menu-horizontal > .ant-menu-item:hover, + .ant-menu-horizontal > .ant-menu-submenu-active, + .ant-menu-horizontal > .ant-menu-submenu-open, + .ant-menu-horizontal > .ant-menu-submenu-selected, + .ant-menu-horizontal > .ant-menu-submenu:hover { + border-bottom: none; + } + } + box-shadow: @shadow-2; + position: relative; + display: flex; + justify-content: space-between; + height: 56px; + z-index: 9; + display: flex; + align-items: center; + background-color: #fff; + + .rightWarpper { + display: flex; + padding-right: 16px; + } + + .button { + width: 56px; + height: 56px; + line-height: 56px; + text-align: center; + font-size: 18px; + cursor: pointer; + transition: @transition-ease-in; + + &:hover { + color: @primary-color; + background-color: fade(@primary-color, 15%); + } + } +} + +.popovermenu { + width: 280px; + margin-left: 6px; + + :global .ant-popover-inner-content { + padding: 0; + + .ant-menu-inline .ant-menu-item, + .ant-menu-vertical .ant-menu-item { + border-right: 0; + } + + .ant-menu-inline .ant-menu-item-selected, + .ant-menu-inline .ant-menu-selected { + border-right: 0; + } + } +} diff --git a/src/components/Layout/Layout.less b/src/components/Layout/Layout.less index 0ca53820..7fb56e0b 100644 --- a/src/components/Layout/Layout.less +++ b/src/components/Layout/Layout.less @@ -1,188 +1,188 @@ -@import "~themes/vars"; - -:global { - .ant-layout-header { - padding: 0; - } - - .ant-layout-sider { - transition: all 0.3s; - - .ant-menu-root { - height: ~"calc(100vh - 144px)"; - overflow-x: hidden; - border-right: none; - - &::-webkit-scrollbar-thumb { - background-color: transparent; - } - - &:hover { - &::-webkit-scrollbar-thumb { - background-color: rgba(0, 0, 0, 0.2); - } - } - } - - .ant-menu { - .ant-menu-item, - .ant-menu-submenu-title { - overflow: hidden; - white-space: normal; - } - } - } - - .ant-layout-content { - padding: 24px; - } - - .ant-layout-footer { - text-align: center; - padding: 0 24px; - height: 40px; - font-size: 12px; - line-height: 40px; - } - - .ant-back-top { - right: 50px; - } - - .ant-switch.ant-switch-large { - line-height: 24px; - height: 26px; - - &:after, - &:before { - width: 22px; - height: 22px; - } - - &.ant-switch-checked:after, - &.ant-switch-checked:before { - margin-left: -23px; - } - } - - .flex-vertical-center { - display: flex; - align-items: center; - } - - .ant-form-item { - margin-bottom: 12px; - } -} - - - -.logo { - height: 96px; - display: flex; - align-items: center; - justify-content: center; - - img { - width: 40px; - margin-right: 8px; - } - - span { - vertical-align: text-bottom; - font-size: 16px; - text-transform: uppercase; - display: inline-block; - font-weight: 700; - color: @primary-color; - white-space: nowrap; - :local { - animation: fadeLeftIn 500ms linear; - animation-fill-mode: both; - } - } -} - -.switchtheme { - width: 100%; - position: absolute; - bottom: 0; - height: 48px; - background-color: #fff; - border-top: solid 1px #f8f8f8; - display: flex; - justify-content: space-between; - align-items: center; - padding: 0 16px; - overflow: hidden; - z-index: 9; - transition: all 0.3s; - - span { - white-space: nowrap; - overflow: hidden; - font-size: 12px; - } - - :global { - .anticon { - min-width: 14px; - margin-right: 4px; - font-size: 14px; - } - } -} - -.bread { - margin-bottom: 24px; - - :global { - .ant-breadcrumb { - display: flex; - align-items: center; - } - } -} - -.dark { - .switchtheme { - background-color: #000d18; - border-color: #001629; - } -} - -.light { - :global { - .ant-layout-sider { - background: #fff; - } - } -} -@media (max-width: 767px) { - .bread { - margin-bottom: 12px; - } - - :global { - .ant-layout-content { - padding: 12px; - } - - .ant-back-top { - right: 20px; - bottom: 20px; - } - } -} - -@keyframes fadeLeftIn { - 0% { - transform: translateX(5px); - opacity: 0; - } - - 100% { - transform: translateX(0); - opacity: 1; - } -} +@import "~themes/vars.less"; + +:global { + .ant-layout-header { + padding: 0; + } + + .ant-layout-sider { + transition: all 0.3s; + + .ant-menu-root { + height: ~"calc(100vh - 144px)"; + overflow-x: hidden; + border-right: none; + + &::-webkit-scrollbar-thumb { + background-color: transparent; + } + + &:hover { + &::-webkit-scrollbar-thumb { + background-color: rgba(0, 0, 0, 0.2); + } + } + } + + .ant-menu { + .ant-menu-item, + .ant-menu-submenu-title { + overflow: hidden; + white-space: normal; + } + } + } + + .ant-layout-content { + padding: 24px; + } + + .ant-layout-footer { + text-align: center; + padding: 0 24px; + height: 40px; + font-size: 12px; + line-height: 40px; + } + + .ant-back-top { + right: 50px; + } + + .ant-switch.ant-switch-large { + line-height: 24px; + height: 26px; + + &:after, + &:before { + width: 22px; + height: 22px; + } + + &.ant-switch-checked:after, + &.ant-switch-checked:before { + margin-left: -23px; + } + } + + .flex-vertical-center { + display: flex; + align-items: center; + } + + .ant-form-item { + margin-bottom: 12px; + } +} + + + +.logo { + height: 96px; + display: flex; + align-items: center; + justify-content: center; + + img { + width: 40px; + margin-right: 8px; + } + + span { + vertical-align: text-bottom; + font-size: 16px; + text-transform: uppercase; + display: inline-block; + font-weight: 700; + color: @primary-color; + white-space: nowrap; + :local { + animation: fadeLeftIn 500ms linear; + animation-fill-mode: both; + } + } +} + +.switchtheme { + width: 100%; + position: absolute; + bottom: 0; + height: 48px; + background-color: #fff; + border-top: solid 1px #f8f8f8; + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 16px; + overflow: hidden; + z-index: 9; + transition: all 0.3s; + + span { + white-space: nowrap; + overflow: hidden; + font-size: 12px; + } + + :global { + .anticon { + min-width: 14px; + margin-right: 4px; + font-size: 14px; + } + } +} + +.bread { + margin-bottom: 24px; + + :global { + .ant-breadcrumb { + display: flex; + align-items: center; + } + } +} + +.dark { + .switchtheme { + background-color: #000d18; + border-color: #001629; + } +} + +.light { + :global { + .ant-layout-sider { + background: #fff; + } + } +} +@media (max-width: 767px) { + .bread { + margin-bottom: 12px; + } + + :global { + .ant-layout-content { + padding: 12px; + } + + .ant-back-top { + right: 20px; + bottom: 20px; + } + } +} + +@keyframes fadeLeftIn { + 0% { + transform: translateX(5px); + opacity: 0; + } + + 100% { + transform: translateX(0); + opacity: 1; + } +} diff --git a/src/components/Page/Page.less b/src/components/Page/Page.less index 0a8156f2..8355fb7a 100644 --- a/src/components/Page/Page.less +++ b/src/components/Page/Page.less @@ -1,16 +1,16 @@ -@import "~themes/vars"; - -.contentInner{ - background: #fff; - padding: 24px; - box-shadow: @shadow-1; - min-height: ~"calc(100vh - 198px)"; - position: relative; -} - -@media (max-width: 767px) { - .contentInner { - padding: 12px; - min-height: ~"calc(100vh - 160px)"; - } -} +@import "~themes/vars.less"; + +.contentInner{ + background: #fff; + padding: 24px; + box-shadow: @shadow-1; + min-height: ~"calc(100vh - 198px)"; + position: relative; +} + +@media (max-width: 767px) { + .contentInner { + padding: 12px; + min-height: ~"calc(100vh - 160px)"; + } +} diff --git a/src/layouts/app.less b/src/layouts/app.less index 32023d43..6af0944d 100644 --- a/src/layouts/app.less +++ b/src/layouts/app.less @@ -1,72 +1,72 @@ -@import "~themes/vars"; - -:global { - #nprogress { - pointer-events: none; - - .bar { - background: @primary-color; - position: fixed; - z-index: 1024; - top: 0; - left: 0; - right: 0; - width: 100%; - height: 2px; - } - - .peg { - display: block; - position: absolute; - right: 0; - width: 100px; - height: 100%; - box-shadow: 0 0 10px @primary-color,0 0 5px @primary-color; - opacity: 1.0; - transform: rotate(3deg) translate(0px,-4px); - } - - .spinner { - display: block; - position: fixed; - z-index: 1031; - top: 15px; - right: 15px; - } - - .spinner-icon { - width: 18px; - height: 18px; - box-sizing: border-box; - border: solid 2px transparent; - border-top-color: @primary-color; - border-left-color: @primary-color; - border-radius: 50%; - - :local { - animation: nprogress-spinner 400ms linear infinite; - } - } - } - - .nprogress-custom-parent { - overflow: hidden; - position: relative; - - #nprogress { - .bar, - .spinner { - position: absolute; - } - } - } -} -@keyframes nprogress-spinner { - 0% { - transform: rotate(0deg); - } - - 100% { - transform: rotate(360deg); - } -} +@import "~themes/vars.less"; + +:global { + #nprogress { + pointer-events: none; + + .bar { + background: @primary-color; + position: fixed; + z-index: 1024; + top: 0; + left: 0; + right: 0; + width: 100%; + height: 2px; + } + + .peg { + display: block; + position: absolute; + right: 0; + width: 100px; + height: 100%; + box-shadow: 0 0 10px @primary-color,0 0 5px @primary-color; + opacity: 1.0; + transform: rotate(3deg) translate(0px,-4px); + } + + .spinner { + display: block; + position: fixed; + z-index: 1031; + top: 15px; + right: 15px; + } + + .spinner-icon { + width: 18px; + height: 18px; + box-sizing: border-box; + border: solid 2px transparent; + border-top-color: @primary-color; + border-left-color: @primary-color; + border-radius: 50%; + + :local { + animation: nprogress-spinner 400ms linear infinite; + } + } + } + + .nprogress-custom-parent { + overflow: hidden; + position: relative; + + #nprogress { + .bar, + .spinner { + position: absolute; + } + } + } +} +@keyframes nprogress-spinner { + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } +} diff --git a/src/plugins/onError.js b/src/plugins/onError.js index 9b769852..5661d64c 100644 --- a/src/plugins/onError.js +++ b/src/plugins/onError.js @@ -1,8 +1,8 @@ import { message } from 'antd' export default { - onError(e) { + onError (e) { e.preventDefault() - message.error(error.message) - } + message.error(e.message) + }, } diff --git a/src/themes/index.less b/src/themes/index.less index 74582f7a..a6f29a42 100644 --- a/src/themes/index.less +++ b/src/themes/index.less @@ -1,135 +1,135 @@ -@import "~themes/vars"; - -body { - height: 100%; - overflow-y: hidden; - background-color: #f8f8f8; -} - -::-webkit-scrollbar-thumb { - background-color: #e6e6e6; -} - -::-webkit-scrollbar { - width: 8px; - height: 8px; -} - -:global { - .ant-breadcrumb { - & > span { - &:last-child { - color: #999; - font-weight: normal; - } - } - } - - .ant-breadcrumb-link { - .anticon + span { - margin-left: 4px; - } - } - - .ant-table { - .ant-table-thead > tr > th { - text-align: center; - } - - .ant-table-tbody > tr > td { - text-align: center; - } - - &.ant-table-small { - .ant-table-thead > tr > th { - background: #f7f7f7; - } - - .ant-table-body > table { - padding: 0; - } - } - } - - .ant-table-pagination { - float: none!important; - display: table; - margin: 16px auto !important; - } - - .ant-popover-inner { - border: none; - border-radius: 0; - box-shadow: 0 0 20px rgba(100, 100, 100, 0.2); - } - - .vertical-center-modal { - display: flex; - align-items: center; - justify-content: center; - - .ant-modal { - top: 0; - - .ant-modal-body { - max-height: 80vh; - overflow-y: auto; - } - } - } - - .ant-form-item-control { - vertical-align: middle; - } - - .ant-modal-mask { - background-color: rgba(55, 55, 55, 0.2); - } - - .ant-modal-content { - box-shadow: none; - } - - .ant-select-dropdown-menu-item { - padding: 12px 16px !important; - } - - .margin-right { - margin-right: 16px; - } - - a:focus { - text-decoration: none; - } -} -@media (min-width: 1600px) { - :global { - .ant-col-xl-48 { - width: 20%; - } - - .ant-col-xl-96 { - width: 40%; - } - } -} -@media (max-width: 767px) { - :global { - .ant-pagination-item, - .ant-pagination-next, - .ant-pagination-options, - .ant-pagination-prev { - margin-bottom: 8px; - } - - .ant-card { - .ant-card-head { - padding: 0 12px; - } - - .ant-card-body { - padding: 12px; - } - } - } -} +@import "~themes/vars.less"; + +body { + height: 100%; + overflow-y: hidden; + background-color: #f8f8f8; +} + +::-webkit-scrollbar-thumb { + background-color: #e6e6e6; +} + +::-webkit-scrollbar { + width: 8px; + height: 8px; +} + +:global { + .ant-breadcrumb { + & > span { + &:last-child { + color: #999; + font-weight: normal; + } + } + } + + .ant-breadcrumb-link { + .anticon + span { + margin-left: 4px; + } + } + + .ant-table { + .ant-table-thead > tr > th { + text-align: center; + } + + .ant-table-tbody > tr > td { + text-align: center; + } + + &.ant-table-small { + .ant-table-thead > tr > th { + background: #f7f7f7; + } + + .ant-table-body > table { + padding: 0; + } + } + } + + .ant-table-pagination { + float: none!important; + display: table; + margin: 16px auto !important; + } + + .ant-popover-inner { + border: none; + border-radius: 0; + box-shadow: 0 0 20px rgba(100, 100, 100, 0.2); + } + + .vertical-center-modal { + display: flex; + align-items: center; + justify-content: center; + + .ant-modal { + top: 0; + + .ant-modal-body { + max-height: 80vh; + overflow-y: auto; + } + } + } + + .ant-form-item-control { + vertical-align: middle; + } + + .ant-modal-mask { + background-color: rgba(55, 55, 55, 0.2); + } + + .ant-modal-content { + box-shadow: none; + } + + .ant-select-dropdown-menu-item { + padding: 12px 16px !important; + } + + .margin-right { + margin-right: 16px; + } + + a:focus { + text-decoration: none; + } +} +@media (min-width: 1600px) { + :global { + .ant-col-xl-48 { + width: 20%; + } + + .ant-col-xl-96 { + width: 40%; + } + } +} +@media (max-width: 767px) { + :global { + .ant-pagination-item, + .ant-pagination-next, + .ant-pagination-options, + .ant-pagination-prev { + margin-bottom: 8px; + } + + .ant-card { + .ant-card-head { + padding: 0 12px; + } + + .ant-card-body { + padding: 12px; + } + } + } +} diff --git a/src/themes/vars.less b/src/themes/vars.less index 69f340ed..8b052a40 100644 --- a/src/themes/vars.less +++ b/src/themes/vars.less @@ -1,2 +1,2 @@ -@import "~themes/default"; -@import "~themes/mixin"; +@import "~themes/default.less"; +@import "~themes/mixin.less"; diff --git a/src/utils/index.js b/src/utils/index.js index dad7e5f5..ac4e4cde 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,9 +1,10 @@ /* global window */ -import classnames from 'classnames' import lodash from 'lodash' -import config from './config' -import request from './request' -import { color } from './theme' + +export classnames from 'classnames' +export config from './config' +export request from './request' +export { color } from './theme' // 连字符转驼峰 String.prototype.hyphenToHump = function () { @@ -42,11 +43,10 @@ Date.prototype.format = function (format) { /** - * @param {String} + * @param name {String} * @return {String} */ - -const queryURL = (name) => { +export function queryURL (name) { let reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`, 'i') let r = window.location.search.substr(1).match(reg) if (r != null) return decodeURI(r[2]) @@ -60,7 +60,7 @@ const queryURL = (name) => { * @param {String} keyAlias * @return {Array} */ -const queryArray = (array, key, keyAlias = 'key') => { +export function queryArray (array, key, keyAlias = 'key') { if (!(array instanceof Array)) { return null } @@ -79,7 +79,7 @@ const queryArray = (array, key, keyAlias = 'key') => { * @param {String} children * @return {Array} */ -const arrayToTree = (array, id = 'id', pid = 'pid', children = 'children') => { +export function arrayToTree (array, id = 'id', pid = 'pid', children = 'children') { let data = lodash.cloneDeep(array) let result = [] let hash = {} @@ -98,13 +98,3 @@ const arrayToTree = (array, id = 'id', pid = 'pid', children = 'children') => { }) return result } - -module.exports = { - config, - request, - color, - classnames, - queryURL, - queryArray, - arrayToTree, -} diff --git a/src/utils/model.js b/src/utils/model.js index bcd9e46d..79997277 100644 --- a/src/utils/model.js +++ b/src/utils/model.js @@ -1,6 +1,6 @@ import modelExtend from 'dva-model-extend' -const model = { +export const model = { reducers: { updateState (state, { payload }) { return { @@ -11,7 +11,7 @@ const model = { }, } -const pageModel = modelExtend(model, { +export const pageModel = modelExtend(model, { state: { list: [], @@ -40,9 +40,3 @@ const pageModel = modelExtend(model, { }, }) - - -module.exports = { - model, - pageModel, -} From 89d22451c54902b8656f575185ae8cb2eaf82f52 Mon Sep 17 00:00:00 2001 From: chencheng Date: Sat, 24 Mar 2018 18:08:16 +0800 Subject: [PATCH 5/8] fix: svg don't work --- .webpackrc.js | 3 + package.json | 3 +- src/pages/chart/ECharts/theme/macarons.js | 4 +- src/pages/user/components/Filter.js | 2 +- src/pages/user/components/Modal.js | 2 +- src/router.js | 89 ----------------------- webpack.config.js | 13 ++++ 7 files changed, 22 insertions(+), 94 deletions(-) delete mode 100644 src/router.js create mode 100644 webpack.config.js diff --git a/.webpackrc.js b/.webpackrc.js index a96cd180..552ae202 100644 --- a/.webpackrc.js +++ b/.webpackrc.js @@ -18,4 +18,7 @@ export default { alias: { themes: resolve(__dirname, './src/themes'), }, + urlLoaderExcludes: [ + /\.svg$/, + ], } diff --git a/package.json b/package.json index 9c308b39..82614eb3 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,8 @@ "eslint-plugin-import": "^2.9.0", "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-react": "^7.7.0", - "less-vars-to-js": "^1.1.2" + "less-vars-to-js": "^1.1.2", + "svg-sprite-loader": "^3.7.3" }, "pre-commit": [ "lint" diff --git a/src/pages/chart/ECharts/theme/macarons.js b/src/pages/chart/ECharts/theme/macarons.js index 73fc10d4..64da22d5 100644 --- a/src/pages/chart/ECharts/theme/macarons.js +++ b/src/pages/chart/ECharts/theme/macarons.js @@ -1,7 +1,7 @@ (function (root, factory) { - if (typeof define === 'function' && define.amd) { + if (typeof define === 'function' && define.amd) { // eslint-disable-line // AMD. Register as an anonymous module. - define(['exports', 'echarts'], factory) + define(['exports', 'echarts'], factory) // eslint-disable-line } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') { // CommonJS factory(exports, require('echarts')) diff --git a/src/pages/user/components/Filter.js b/src/pages/user/components/Filter.js index 3a02ff90..9b82badb 100644 --- a/src/pages/user/components/Filter.js +++ b/src/pages/user/components/Filter.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types' import moment from 'moment' import { FilterItem } from 'components' import { Form, Button, Row, Col, DatePicker, Input, Cascader, Switch } from 'antd' -import city from '../../utils/city' +import city from 'utils/city' const { Search } = Input const { RangePicker } = DatePicker diff --git a/src/pages/user/components/Modal.js b/src/pages/user/components/Modal.js index 47141a6c..ab760a24 100644 --- a/src/pages/user/components/Modal.js +++ b/src/pages/user/components/Modal.js @@ -1,7 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import { Form, Input, InputNumber, Radio, Modal, Cascader } from 'antd' -import city from '../../utils/city' +import city from 'utils/city' const FormItem = Form.Item diff --git a/src/router.js b/src/router.js deleted file mode 100644 index 143de891..00000000 --- a/src/router.js +++ /dev/null @@ -1,89 +0,0 @@ -import React from 'react' -import PropTypes from 'prop-types' -import { Switch, Route, Redirect, routerRedux } from 'dva/router' -import dynamic from 'dva/dynamic' - -const { ConnectedRouter } = routerRedux - -const Routers = function ({ history, app }) { - const routes = [ - { - path: '/dashboard', - models: () => [import('./models/dashboard')], - component: () => import('./routes/dashboard/'), - }, { - path: '/user', - models: () => [import('./models/user')], - component: () => import('./routes/user/'), - }, { - path: '/user/:id', - models: () => [import('./models/user/detail')], - component: () => import('./routes/user/detail/'), - }, { - path: '/login', - models: () => [import('./models/login')], - component: () => import('./routes/login/'), - }, { - path: '/request', - component: () => import('./routes/request/'), - }, { - path: '/UIElement/iconfont', - component: () => import('./routes/UIElement/iconfont/'), - }, { - path: '/UIElement/search', - component: () => import('./routes/UIElement/search/'), - }, { - path: '/UIElement/dropOption', - component: () => import('./routes/UIElement/dropOption/'), - }, { - path: '/UIElement/layer', - component: () => import('./routes/UIElement/layer/'), - }, { - path: '/UIElement/dataTable', - component: () => import('./routes/UIElement/dataTable/'), - }, { - path: '/UIElement/editor', - component: () => import('./routes/UIElement/editor/'), - }, { - path: '/chart/ECharts', - component: () => import('./routes/chart/ECharts/'), - }, { - path: '/chart/highCharts', - component: () => import('./routes/chart/highCharts/'), - }, { - path: '/chart/Recharts', - component: () => import('./routes/chart/Recharts/'), - }, { - path: '/post', - models: () => [import('./models/post')], - component: () => import('./routes/post/'), - }, - ] - - return ( - - - ()} /> - { - routes.map(({ path, ...dynamics }, key) => ( - - )) - } - - - ) -} - -Routers.propTypes = { - history: PropTypes.object, - app: PropTypes.object, -} - -export default Routers diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 00000000..ac4f22db --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,13 @@ + +export default function (webpackConfig) { + webpackConfig.module.rules.push({ + test: /\.svg$/i, + use: [ + { + loader: require.resolve('svg-sprite-loader'), + }, + ], + }) + + return webpackConfig +}; From 0fef06e0c6d0c4cecd7ba3e59e9e6e1086e1f9d3 Mon Sep 17 00:00:00 2001 From: chencheng Date: Mon, 26 Mar 2018 17:15:27 +0800 Subject: [PATCH 6/8] use umi-plugin-dll to enable dll --- .umirc.js | 7 ++ package.json | 17 ++-- src/pages/chart/ECharts/{index.js => page.js} | 2 +- .../chart/ECharts/{index.less => page.less} | 0 src/pages/chart/ECharts/theme/shine.js | 4 +- .../chart/Recharts/{index.js => page.js} | 2 +- .../chart/Recharts/{index.less => page.less} | 0 .../chart/highCharts/{index.js => page.js} | 2 +- .../highCharts/{index.less => page.less} | 0 version.js | 82 ------------------- 10 files changed, 21 insertions(+), 95 deletions(-) rename src/pages/chart/ECharts/{index.js => page.js} (98%) rename src/pages/chart/ECharts/{index.less => page.less} (100%) rename src/pages/chart/Recharts/{index.js => page.js} (96%) rename src/pages/chart/Recharts/{index.less => page.less} (100%) rename src/pages/chart/highCharts/{index.js => page.js} (96%) rename src/pages/chart/highCharts/{index.less => page.less} (100%) delete mode 100644 version.js diff --git a/.umirc.js b/.umirc.js index 9ca6633c..5e176d20 100644 --- a/.umirc.js +++ b/.umirc.js @@ -15,5 +15,12 @@ export default { ], }, ], + [ + 'umi-plugin-dll', + { + exclude: [], + include: ["dva", "dva/router", "dva/saga", "dva/fetch", "antd/es"], + }, + ], ], } diff --git a/package.json b/package.json index 82614eb3..d78a1de0 100644 --- a/package.json +++ b/package.json @@ -15,24 +15,20 @@ "echarts-liquidfill": "^1.1.0", "highcharts-exporting": "^0.1.2", "highcharts-more": "^0.1.2", - "history": "^4.7.2", "js-beautify": "^1.6.14", "jsonp": "^0.2.1", "lodash": "^4.17.4", - "mockjs": "^1.0.1-beta3", "nprogress": "^0.2.0", "path-to-regexp": "^2.1.0", "prop-types": "^15.5.10", "qs": "^6.5.0", "rc-tween-one": "^1.3.1", + "react-adsense": "^0.0.5", "react-countup": "^3.0.2", "react-draft-wysiwyg": "^1.10.0", "react-helmet": "^5.1.3", "react-highcharts": "^15.0.0", - "recharts": "^1.0.0-beta.0", - "umi": "^1.1.0", - "umi-plugin-dva": "^0.4.0", - "umi-plugin-routes": "^0.1.2" + "recharts": "^1.0.0-beta.0" }, "devDependencies": { "babel-plugin-dev-expression": "^0.2.1", @@ -46,7 +42,12 @@ "eslint-plugin-jsx-a11y": "^5.1.1", "eslint-plugin-react": "^7.7.0", "less-vars-to-js": "^1.1.2", - "svg-sprite-loader": "^3.7.3" + "mockjs": "^1.0.1-beta3", + "svg-sprite-loader": "^3.7.3", + "umi": "^1.1.2", + "umi-plugin-dll": "^0.1.0", + "umi-plugin-dva": "^0.4.0", + "umi-plugin-routes": "^0.1.2" }, "pre-commit": [ "lint" @@ -54,7 +55,7 @@ "scripts": { "start": "cross-env BABELRC=1 BROWSER=none HOST=0.0.0.0 umi dev", "lint": "eslint --fix --ext .js src", - "build": "umi build", + "build": "cross-env BABELRC=1 umi build", "test": "umi test" } } diff --git a/src/pages/chart/ECharts/index.js b/src/pages/chart/ECharts/page.js similarity index 98% rename from src/pages/chart/ECharts/index.js rename to src/pages/chart/ECharts/page.js index 120260c6..35f29865 100644 --- a/src/pages/chart/ECharts/index.js +++ b/src/pages/chart/ECharts/page.js @@ -2,7 +2,7 @@ import React from 'react' import { Radio } from 'antd' import { Page } from 'components' import EchartsComponent from './EchartsComponent' -import styles from './index.less' +import styles from './page.less' const RadioGroup = Radio.Group diff --git a/src/pages/chart/ECharts/index.less b/src/pages/chart/ECharts/page.less similarity index 100% rename from src/pages/chart/ECharts/index.less rename to src/pages/chart/ECharts/page.less diff --git a/src/pages/chart/ECharts/theme/shine.js b/src/pages/chart/ECharts/theme/shine.js index 027fb4eb..9d342ab4 100644 --- a/src/pages/chart/ECharts/theme/shine.js +++ b/src/pages/chart/ECharts/theme/shine.js @@ -1,7 +1,7 @@ (function (root, factory) { - if (typeof define === 'function' && define.amd) { + if (typeof define === 'function' && define.amd) { // eslint-disable-line // AMD. Register as an anonymous module. - define(['exports', 'echarts'], factory) + define(['exports', 'echarts'], factory) // eslint-disable-line } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') { // CommonJS factory(exports, require('echarts')) diff --git a/src/pages/chart/Recharts/index.js b/src/pages/chart/Recharts/page.js similarity index 96% rename from src/pages/chart/Recharts/index.js rename to src/pages/chart/Recharts/page.js index 32a0990f..0bd0f9fe 100644 --- a/src/pages/chart/Recharts/index.js +++ b/src/pages/chart/Recharts/page.js @@ -2,7 +2,7 @@ import React from 'react' import { Radio } from 'antd' import { Page } from 'components' import ReChartsComponent from './ReChartsComponent' -import styles from './index.less' +import styles from './page.less' const RadioGroup = Radio.Group diff --git a/src/pages/chart/Recharts/index.less b/src/pages/chart/Recharts/page.less similarity index 100% rename from src/pages/chart/Recharts/index.less rename to src/pages/chart/Recharts/page.less diff --git a/src/pages/chart/highCharts/index.js b/src/pages/chart/highCharts/page.js similarity index 96% rename from src/pages/chart/highCharts/index.js rename to src/pages/chart/highCharts/page.js index 7941c2f2..06ea85a4 100644 --- a/src/pages/chart/highCharts/index.js +++ b/src/pages/chart/highCharts/page.js @@ -2,7 +2,7 @@ import React from 'react' import { Radio } from 'antd' import { Page } from 'components' import HighChartsComponent from './HighChartsComponent' -import styles from './index.less' +import styles from './page.less' const RadioGroup = Radio.Group diff --git a/src/pages/chart/highCharts/index.less b/src/pages/chart/highCharts/page.less similarity index 100% rename from src/pages/chart/highCharts/index.less rename to src/pages/chart/highCharts/page.less diff --git a/version.js b/version.js deleted file mode 100644 index f4635755..00000000 --- a/version.js +++ /dev/null @@ -1,82 +0,0 @@ -const fs = require('fs') -const path = require('path') -const beautify = require('js-beautify').js_beautify -const config = require('./package.json') - -const dist = path.join(`${__dirname}/dist`) -const maxVersion = 5 - -const writeVersion = () => new Promise((resolve, reject) => { - const { version } = config - const numbers = version.split('.') - numbers[2] = Number(numbers[2]) + 1 - config.version = numbers.join('.') - - fs.writeFile(path.join(__dirname, 'package.json'), beautify(JSON.stringify(config), { indent_size: 2 }), (err) => { - if (err) { - reject() - } - resolve() - console.log(`version: ${config.version}`) - }) -}) - -const removeFolder = (folderPath) => { - let files = [] - if (fs.existsSync(folderPath)) { - files = fs.readdirSync(folderPath) - files.forEach((file) => { - const curPath = `${folderPath}/${file}` - if (fs.statSync(curPath).isDirectory()) { - removeFolder(curPath) - } else { - fs.unlinkSync(curPath) - } - }) - fs.rmdirSync(folderPath) - } -} - -const start = async () => { - const files = fs.readdirSync(dist) - const promises = files.map(file => new Promise((resolve, reject) => { - fs.stat(`${dist}/${file}`, (err, stats) => { - if (err) { - reject() - } else { - resolve(!stats.isFile() - ? file - : null) - } - }) - })) - - const result = await Promise.all(promises) - - const folders = result.filter((item) => { - if (item) { - return item.split('.').length === 3 - } - return false - }).sort((a, b) => { - const an = a.split('.').map(_ => Number(_)) - const bn = b.split('.').map(_ => Number(_)) - if (an[0] === bn[0]) { - if (an[1] === bn[1]) { - return an[2] < bn[2] - } - return an[1] < bn[1] - } - return an[0] < bn[0] - }).filter((item, index) => { - return index > (maxVersion - 1) - }) - - for (const item of folders) { - await removeFolder(`${dist}/${item}`) - } - - await writeVersion() -} - -start() From 5f04d19d2dbb2a3fb5901037ffe35ab3526cfd31 Mon Sep 17 00:00:00 2001 From: chencheng Date: Mon, 26 Mar 2018 17:18:43 +0800 Subject: [PATCH 7/8] add lost dep query-string --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index d78a1de0..a5f19085 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "path-to-regexp": "^2.1.0", "prop-types": "^15.5.10", "qs": "^6.5.0", + "query-string": "^6.0.0", "rc-tween-one": "^1.3.1", "react-adsense": "^0.0.5", "react-countup": "^3.0.2", From 74895fbb0d3d936528af6b44d84a878708734efe Mon Sep 17 00:00:00 2001 From: chencheng Date: Mon, 26 Mar 2018 17:59:22 +0800 Subject: [PATCH 8/8] fix: uglifyjs problem, use query-string@5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a5f19085..0ee3fd0d 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "path-to-regexp": "^2.1.0", "prop-types": "^15.5.10", "qs": "^6.5.0", - "query-string": "^6.0.0", + "query-string": "^5.1.1", "rc-tween-one": "^1.3.1", "react-adsense": "^0.0.5", "react-countup": "^3.0.2",