diff --git a/.babelrc b/.babelrc index 3a280ba3..6c0b7f27 100644 --- a/.babelrc +++ b/.babelrc @@ -8,5 +8,10 @@ }], "stage-2" ], - "plugins": ["transform-vue-jsx", "transform-runtime"] + "plugins": ["transform-vue-jsx", "transform-runtime"], + "env": { + "development":{ + "plugins": ["dynamic-import-node"] + } + } } diff --git a/.eslintrc.js b/.eslintrc.js index 00d60805..6f55c5a1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,7 @@ module.exports = { root: true, - parser: 'babel-eslint', parserOptions: { + parser: 'babel-eslint', sourceType: 'module' }, env: { @@ -9,22 +9,19 @@ module.exports = { node: true, es6: true, }, - extends: 'eslint:recommended', - // required to lint *.vue files - plugins: [ - 'html' - ], - // check if imports actually resolve - 'settings': { - 'import/resolver': { - 'webpack': { - 'config': 'build/webpack.base.conf.js' - } - } - }, + extends: ['plugin:vue/recommended', 'eslint:recommended'], + // add your custom rules here //it is base on https://github.com/vuejs/eslint-config-vue - 'rules': { + rules: { + "vue/max-attributes-per-line": [2, { + "singleline": 10, + "multiline": { + "max": 1, + "allowFirstLine": false + } + }], + "vue/name-property-casing": ["error", "PascalCase"], 'accessor-pairs': 2, 'arrow-spacing': [2, { 'before': true, @@ -196,4 +193,3 @@ module.exports = { 'array-bracket-spacing': [2, 'never'] } } - diff --git a/.gitignore b/.gitignore index a2069ec8..9322b8a6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ dist/ npm-debug.log* yarn-debug.log* yarn-error.log* +**/*.log test/unit/coverage test/e2e/reports diff --git a/README.md b/README.md index e18e5f51..ed083293 100644 --- a/README.md +++ b/README.md @@ -3,92 +3,134 @@

- - vue - - - element-ui - - - Build Status - - - license - - - GitHub release - + + vue + + + element-ui + + + Build Status + + + license + + + GitHub release + + + gitter + + + donate +

English | [简体中文](./README.zh-CN.md) ## Introduction -`vue-element-admin` is a production-ready solution for admin interfaces. Based on [Vue.js](https://github.com/vuejs/vue) and use the UI Toolkit -- [element](https://github.com/ElemeFE/element). `vue-element-admin` is a magical vue admin, it based on the newest development stack of vue, built-in i18n solution, typical templates for enterprise applications, lots of awesome features. It helps you build a large complex Single-Page Applications. I believe whatever your needs are, this project will help you. +[vue-element-admin](http://panjiachen.github.io/vue-element-admin) is a front-end management background integration solution. It based on [vue](https://github.com/vuejs/vue) and use the UI Toolkit [element](https://github.com/ElemeFE/element). + +It is a magical vue admin based on the newest development stack of vue, built-in i18n solution, typical templates for enterprise applications, lots of awesome features. It helps you build a large complex Single-Page Applications. I believe whatever your needs are, this project will help you. - [Preview](http://panjiachen.github.io/vue-element-admin) -- [Documentation](https://panjiachen.github.io/vue-element-admin-site/#/) +- [Documentation](https://panjiachen.github.io/vue-element-admin-site/) -- [wiki](https://github.com/PanJiaChen/vue-element-admin/wiki) +- [Gitter](https://gitter.im/vue-element-admin/discuss) -- [donate](https://panjiachen.github.io/vue-element-admin-site/#/donate) +- [Wiki](https://github.com/PanJiaChen/vue-element-admin/wiki) -**vue-element-admin is a admin interfaces integration solution, which is not suitable for secondary development as a base template.** +- [Donate](https://panjiachen.github.io/vue-element-admin-site/donate/) - - Base template recommends using: [vueAdmin-template](https://github.com/PanJiaChen/vueAdmin-template)   - - Desktop: [electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin) +- [Gitee](https://panjiachen.gitee.io/vue-element-admin/) 国内用户可访问该地址在线预览 -**Note: This project uses element-ui@2.0.0+ version, so the minimum compatible vue@2.5.0** +**This project is positioned as a background integration solution and is not suitable for secondary development as a basic template.** + +- Base template recommends using: [vue-admin-template](https://github.com/PanJiaChen/vue-admin-template) +- Desktop: [electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin) +- Typescript: [vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) (Credits: [@Armour](https://github.com/Armour)) + +**This project does not support low version browsers (e.g. IE). Please add polyfill yourself if you need them.** + +**Note: This project uses element-ui@2.3.0+ version, so the minimum compatible vue@2.5.0+** + +**Start using `webpack4` from `v3.8.0`. If you still want to continue using `webpack3`, please use this branch [webpack3](https://github.com/PanJiaChen/vue-element-admin/tree/webpack3)** ## Preparation -You need to install [node](http://nodejs.org/) and [git](https://git-scm.com/) locally. The project is based on [ES2015+](http://es6.ruanyifeng.com/)、[vue](https://cn.vuejs.org/index.html)、[vuex](https://vuex.vuejs.org/zh-cn/)、[vue-router](https://router.vuejs.org/zh-cn/) 和 [element-ui](https://github.com/ElemeFE/element). All data requests for this project are simulated using [Mock.js](https://github.com/nuysoft/Mock). It would be helpful if you have pre-existing knowledge on those. +You need to install [node](http://nodejs.org/) and [git](https://git-scm.com/) locally. The project is based on [ES2015+](http://es6.ruanyifeng.com/), [vue](https://cn.vuejs.org/index.html), [vuex](https://vuex.vuejs.org/zh-cn/), [vue-router](https://router.vuejs.org/zh-cn/), [axios](https://github.com/axios/axios) and [element-ui](https://github.com/ElemeFE/element), all request data is simulated using [Mock.js](https://github.com/nuysoft/Mock). +Understanding and learning this knowledge in advance will greatly help the use of this project. - **This project is not a scaffolding and is more of an integrated solution.** - - **This project does not support low version browsers (e.g. IE). Please add polyfill yourself if you need them.** +---

## Features + ``` - Login / Logout -- Permission authentication + +- Permission Authentication + - Page permission + - Directive permission + - Two-step login + - Multi-environment build -- Dynamic sidebar (supports multi-level routing) -- Dynamic breadcrumb -- I18n -- Customizable theme -- Tags-view(Tab page Support right-click operation) -- Rich text editor -- Markdown editor -- JSON editor -- Screenfull -- Drag and drop list -- Svg Sprite + - dev sit stage prod + +- Global Features + - I18n + - Multiple dynamic themes + - Dynamic sidebar (supports multi-level routing) + - Dynamic breadcrumb + - Tags-view(Tab page Support right-click operation) + - Svg Sprite + - Mock data + - Screenfull + - Responsive Sidebar + +- Editor + - Rich Text Editor + - Markdown Editor + - JSON Editor + +- Excel + - Export Excel + - Export zip + - Upload Excel + - Visualization Excel + +- Table + - Dynamic Table + - Drag And Drop Table + - Tree Table + - Inline Edit Table + +- Error Page + - 401 + - 404 + +- Components + - Avatar Upload + - Back To Top + - Drag Dialog + - Drag Kanban + - Drag List + - SplitPane + - Dropzone + - Sticky + - CountTo + +- Advanced Example +- Error Log - Dashboard -- Mock data -- Echarts +- Guide Page +- ECharts - Clipboard -- 401/404 error page -- Error log -- Export excel -- Export zip -- Front-end visualization excel -- Tree Table -- Table example -- Dynamictable example -- Drag and drop table example -- Inline edit table example -- Form example -- Two-step login -- SplitPane -- Dropzone -- Sticky -- CountTo - Markdown to html ``` @@ -108,6 +150,7 @@ npm run dev This will automatically open http://localhost:9527. ## Build + ```bash # build for test environment npm run build:sit @@ -117,10 +160,14 @@ npm run build:prod ``` ## Advanced + ```bash # --report to build with bundle size analytics npm run build:prod --report +# --generate a bundle size analytics. default: bundle-report.html +npm run build:prod --generate_report + # --preview to start a server in local to preview npm run build:prod --preview @@ -131,15 +178,18 @@ npm run lint npm run lint -- --fix ``` -Refer to [Documentation](https://panjiachen.github.io/vue-element-admin-site/#/deploy) for more information +Refer to [Documentation](https://panjiachen.github.io/vue-element-admin-site/guide/essentials/deploy.html) for more information ## Changelog + Detailed changes for each release are documented in the [release notes](https://github.com/PanJiaChen/vue-element-admin/releases). ## Online Demo + [Preview](http://panjiachen.github.io/vue-element-admin) ## Donate + If you find this project useful, you can buy author a glass of juice :tropical_drink: ![donate](https://wpimg.wallstcn.com/bd273f0d-83a0-4ef2-92e1-9ac8ed3746b9.png) diff --git a/README.zh-CN.md b/README.zh-CN.md index 5b45deae..ccd136e7 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -3,137 +3,185 @@

- - vue - - - element-ui - - - Build Status - - - license - - - GitHub release - + + vue + + + element-ui + + + Build Status + + + license + + + GitHub release + + + gitter + + + donate +

简体中文 | [English](./README.md) ## 简介 -`vue-element-admin` 是一个后台集成解决方案,它基于 [Vue.js](https://github.com/vuejs/vue) 和 [element](https://github.com/ElemeFE/element)。它使用了最新的前端技术栈,内置了i18国际化解决方案,动态路由,权限验证等很多功能特性,相信不管你的需求是什么,本项目都能帮助到你。 +[vue-element-admin](http://panjiachen.github.io/vue-element-admin) 是一个后台集成解决方案,它基于 [vue](https://github.com/vuejs/vue) 和 [element](https://github.com/ElemeFE/element)。它使用了最新的前端技术栈,内置了 i18 国际化解决方案,动态路由,权限验证,提炼了典型的业务模型,提供了丰富的功能组件,它可以帮助你快速搭建企业级中后台产品原型。相信不管你的需求是什么,本项目都能帮助到你。 - [在线访问](http://panjiachen.github.io/vue-element-admin) -- [使用文档](https://panjiachen.github.io/vue-element-admin-site/#/zh-cn/) +- [使用文档](https://panjiachen.github.io/vue-element-admin-site/zh/) -- [wiki](https://github.com/PanJiaChen/vue-element-admin/wiki) +- [Gitter 讨论组](https://gitter.im/vue-element-admin/discuss) -- [donate](https://panjiachen.github.io/vue-element-admin-site/#/zh-cn/donate) +- [Wiki](https://github.com/PanJiaChen/vue-element-admin/wiki) + +- [Donate](https://panjiachen.github.io/vue-element-admin-site/zh/donate/) + +- [Gitee](https://panjiachen.gitee.io/vue-element-admin/) 国内用户可访问该地址在线预览 + +- [国内访问文档](https://panjiachen.gitee.io/vue-element-admin-site/zh/) 方便没翻墙的用户查看文档 **本项目的定位是后台集成方案,不适合当基础模板来开发。** - - 模板建议使用: [vueAdmin-template](https://github.com/PanJiaChen/vueAdmin-template)   - - 桌面端: [electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin) -**注意:该项目使用 element-ui@2.0.0+ 版本,所以最低兼容 vue@2.5.0** +- 模板建议使用: [vue-admin-template](https://github.com/PanJiaChen/vue-admin-template) +- 桌面端: [electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin) +- Typescript版: [vue-typescript-admin-template](https://github.com/Armour/vue-typescript-admin-template) (鸣谢: [@Armour](https://github.com/Armour)) + +群主 **[圈子](https://jianshiapp.com/circles/1209)** 楼主会经常分享一些技术相关的东西,或者加入[qq 群](https://github.com/PanJiaChen/vue-element-admin/issues/602) + +**注意:该项目使用 element-ui@2.3.0+ 版本,所以最低兼容 vue@2.5.0+** + +**从`v3.8.0`开始使用`webpack4`。所以若还想使用`webpack3`开发,请使用该分支[webpack3](https://github.com/PanJiaChen/vue-element-admin/tree/webpack3)** + +**该项目不支持低版本浏览器(如 ie),有需求请自行添加 polyfill [详情](https://github.com/PanJiaChen/vue-element-admin/wiki#babel-polyfill)** ## 前序准备 -你的本地环境需要安装 [node](http://nodejs.org/) 和 [git](https://git-scm.com/)。我们的技术栈基于 [ES2015+](http://es6.ruanyifeng.com/)、[vue](https://cn.vuejs.org/index.html)、[vuex](https://vuex.vuejs.org/zh-cn/)、[vue-router](https://router.vuejs.org/zh-cn/) and [element-ui](https://github.com/ElemeFE/element),所有的请求数据都使用[Mock.js](https://github.com/nuysoft/Mock)模拟,提前了解和学习这些知识会对使用本项目有很大的帮助。 +你需要在本地安装 [node](http://nodejs.org/) 和 [git](https://git-scm.com/)。本项目技术栈基于 [ES2015+](http://es6.ruanyifeng.com/)、[vue](https://cn.vuejs.org/index.html)、[vuex](https://vuex.vuejs.org/zh-cn/)、[vue-router](https://router.vuejs.org/zh-cn/) 、[axios](https://github.com/axios/axios) 和 [element-ui](https://github.com/ElemeFE/element),所有的请求数据都使用[Mock.js](https://github.com/nuysoft/Mock)模拟,提前了解和学习这些知识会对使用本项目有很大的帮助。 同时配套一个系列的教程文章,如何从零构建后一个完整的后台项目,建议大家先看完这些文章再来实践本项目 - - [手摸手,带你用 vue 撸后台 系列一(基础篇)](https://juejin.im/post/59097cd7a22b9d0065fb61d2) - - [手摸手,带你用 vue 撸后台 系列二(登录权限篇)](https://juejin.im/post/591aa14f570c35006961acac) - - [手摸手,带你用 vue 撸后台 系列三 (实战篇)](https://juejin.im/post/593121aa0ce4630057f70d35) - - [手摸手,带你用 vue 撸后台 系列四(vueAdmin 一个极简的后台基础模板)](https://juejin.im/post/595b4d776fb9a06bbe7dba56) - - [手摸手,带你封装一个 vue component](https://segmentfault.com/a/1190000009090836) - - [手摸手,带你优雅的使用 icon](https://juejin.im/post/59bb864b5188257e7a427c09) - 响应需求,开了一个qq群 `591724180` 方便大家交流 +- [手摸手,带你用 vue 撸后台 系列一(基础篇)](https://juejin.im/post/59097cd7a22b9d0065fb61d2) +- [手摸手,带你用 vue 撸后台 系列二(登录权限篇)](https://juejin.im/post/591aa14f570c35006961acac) +- [手摸手,带你用 vue 撸后台 系列三 (实战篇)](https://juejin.im/post/593121aa0ce4630057f70d35) +- [手摸手,带你用 vue 撸后台 系列四(vueAdmin 一个极简的后台基础模板)](https://juejin.im/post/595b4d776fb9a06bbe7dba56) +- [手摸手,带你封装一个 vue component](https://segmentfault.com/a/1190000009090836) +- [手摸手,带你优雅的使用 icon](https://juejin.im/post/59bb864b5188257e7a427c09) +- [手摸手,带你用合理的姿势使用 webpack4(上)](https://juejin.im/post/5b56909a518825195f499806) +- [手摸手,带你用合理的姿势使用 webpack4(下)](https://juejin.im/post/5b5d6d6f6fb9a04fea58aabc) - 或者加入该群主 **[圈子](https://jianshiapp.com/circles/1209)** 楼主会经常分享一些技术相关的东西 - - **如有问题请先看上述使用文档和文章,若不能满足,欢迎 issue 和 pr** - - **本项目并不是一个脚手架,更倾向于是一个集成解决方案** - - **该项目不支持低版本浏览器(如ie),有需求请自行添加polyfill [详情](https://github.com/PanJiaChen/vue-element-admin/wiki#babel-polyfill)** +**如有问题请先看上述使用文档和文章,若不能满足,欢迎 issue 和 pr**

## 功能 + ``` -- 登录/注销 +- 登录 / 注销 + - 权限验证 + - 页面权限 + - 指令权限 + - 二步登录 + - 多环境发布 -- 动态侧边栏(支持多级路由) -- 动态面包屑 -- 国际化多语言 -- 多种动态换肤 -- 快捷导航(标签页) -- 富文本编辑器 -- Markdown编辑器 -- JSON编辑器 -- Screenfull全屏 -- 列表拖拽 -- Svg Sprite 图标 -- Dashboard -- 本地mock数据 -- Echarts 图表 -- Clipboard(剪贴复制) -- 401/404错误页面 + - dev sit stage prod + +- 全局功能 + - 国际化多语言 + - 多种动态换肤 + - 动态侧边栏(支持多级路由嵌套) + - 动态面包屑 + - 快捷导航(标签页) + - Svg Sprite 图标 + - 本地mock数据 + - Screenfull全屏 + - 自适应收缩侧边栏 + +- 编辑器 + - 富文本 + - Markdown + - JSON 等多格式 + +- Excel + - 导出excel + - 导出zip + - 导入excel + - 前端可视化excel + +- 表格 + - 动态表格 + - 拖拽表格 + - 树形表格 + - 内联编辑 + +- 错误页面 + - 401 + - 404 + +- 組件 + - 头像上传 + - 返回顶部 + - 拖拽Dialog + - 拖拽看板 + - 列表拖拽 + - SplitPane + - Dropzone + - Sticky + - CountTo + +- 综合实例 - 错误日志 -- 导出excel -- 导出zip -- 前端可视化excel -- 树形table -- Table example -- 动态table example -- 拖拽table example -- 内联编辑table example -- Form example -- 二步登录 -- SplitPane -- Dropzone -- Sticky -- CountTo +- Dashboard +- 引导页 +- ECharts 图表 +- Clipboard(剪贴复制) - Markdown2html ``` ## 开发 + ```bash # 克隆项目 git clone https://github.com/PanJiaChen/vue-element-admin.git # 安装依赖 npm install -    -# 建议不要用cnpm安装 会有各种诡异的bug 可以通过如下操作解决 npm 下载速度慢的问题 + +# 建议不要用 cnpm 安装 会有各种诡异的bug 可以通过如下操作解决 npm 下载速度慢的问题 npm install --registry=https://registry.npm.taobao.org # 启动服务 npm run dev ``` + 浏览器访问 http://localhost:9527 ## 发布 + ```bash # 构建测试环境 npm run build:sit -# 构建生成环境 +# 构建生产环境 npm run build:prod ``` ## 其它 + ```bash # --report to build with bundle size analytics -npm run build:prod --report +npm run build:prod + +# --generate a bundle size analytics. default: bundle-report.html +npm run build:prod --generate_report # --preview to start a server in local to preview npm run build:prod --preview @@ -145,15 +193,18 @@ npm run lint npm run lint -- --fix ``` -更多信息请参考 [使用文档](https://panjiachen.github.io/vue-element-admin-site/#/zh-cn/deploy) +更多信息请参考 [使用文档](https://panjiachen.github.io/vue-element-admin-site/zh/) ## Changelog + Detailed changes for each release are documented in the [release notes](https://github.com/PanJiaChen/vue-element-admin/releases). ## Online Demo + [在线 Demo](http://panjiachen.github.io/vue-element-admin) ## Donate + 如果你觉得这个项目帮助到了你,你可以帮作者买一杯果汁表示鼓励 :tropical_drink: ![donate](https://panjiachen.github.io/donate/donation.png) diff --git a/build/build.js b/build/build.js index fc793972..34c71a55 100644 --- a/build/build.js +++ b/build/build.js @@ -8,9 +8,12 @@ const chalk = require('chalk') const webpack = require('webpack') const config = require('../config') const webpackConfig = require('./webpack.prod.conf') -const server = require('pushstate-server') +var connect = require('connect') +var serveStatic = require('serve-static') -var spinner = ora('building for '+ process.env.env_config+ ' environment...' ) +const spinner = ora( + 'building for ' + process.env.env_config + ' environment...' +) spinner.start() rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { @@ -18,31 +21,47 @@ rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { webpack(webpackConfig, (err, stats) => { spinner.stop() if (err) throw err - process.stdout.write(stats.toString({ - colors: true, - modules: false, - children: false, - chunks: false, - chunkModules: false - }) + '\n\n') + process.stdout.write( + stats.toString({ + colors: true, + modules: false, + children: false, + chunks: false, + chunkModules: false + }) + '\n\n' + ) if (stats.hasErrors()) { - console.log(chalk.red(' Build failed with errors.\n')) + console.log(chalk.red(' Build failed with errors.\n')) process.exit(1) } - console.log(chalk.cyan(' Build complete.\n')) - console.log(chalk.yellow( - ' Tip: built files are meant to be served over an HTTP server.\n' + - ' Opening index.html over file:// won\'t work.\n' - )) - if(process.env.npm_config_preview){ - server.start({ - port: 9526, - directory: './dist', - file: '/index.html' - }); - console.log('> Listening at ' + 'http://localhost:9526' + '\n') + console.log(chalk.cyan(' Build complete.\n')) + console.log( + chalk.yellow( + ' Tip: built files are meant to be served over an HTTP server.\n' + + " Opening index.html over file:// won't work.\n" + ) + ) + + if (process.env.npm_config_preview) { + const port = 9526 + const host = 'http://localhost:' + port + const basePath = config.build.assetsPublicPath + const app = connect() + + app.use( + basePath, + serveStatic('./dist', { + index: ['index.html', '/'] + }) + ) + + app.listen(port, function() { + console.log( + chalk.green(`> Listening at http://localhost:${port}${basePath}`) + ) + }) } }) }) diff --git a/build/check-versions.js b/build/check-versions.js index 3ef972a0..c5c29e90 100644 --- a/build/check-versions.js +++ b/build/check-versions.js @@ -4,8 +4,11 @@ const semver = require('semver') const packageConfig = require('../package.json') const shell = require('shelljs') -function exec (cmd) { - return require('child_process').execSync(cmd).toString().trim() +function exec(cmd) { + return require('child_process') + .execSync(cmd) + .toString() + .trim() } const versionRequirements = [ @@ -24,23 +27,30 @@ if (shell.which('npm')) { }) } -module.exports = function () { +module.exports = function() { const warnings = [] for (let i = 0; i < versionRequirements.length; i++) { const mod = versionRequirements[i] if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { - warnings.push(mod.name + ': ' + - chalk.red(mod.currentVersion) + ' should be ' + - chalk.green(mod.versionRequirement) + warnings.push( + mod.name + + ': ' + + chalk.red(mod.currentVersion) + + ' should be ' + + chalk.green(mod.versionRequirement) ) } } if (warnings.length) { console.log('') - console.log(chalk.yellow('To use this template, you must update following to modules:')) + console.log( + chalk.yellow( + 'To use this template, you must update following to modules:' + ) + ) console.log() for (let i = 0; i < warnings.length; i++) { diff --git a/build/utils.js b/build/utils.js index e534fb0f..c96d0936 100644 --- a/build/utils.js +++ b/build/utils.js @@ -1,18 +1,19 @@ 'use strict' const path = require('path') const config = require('../config') -const ExtractTextPlugin = require('extract-text-webpack-plugin') +const MiniCssExtractPlugin = require('mini-css-extract-plugin') const packageConfig = require('../package.json') -exports.assetsPath = function (_path) { - const assetsSubDirectory = process.env.NODE_ENV === 'production' - ? config.build.assetsSubDirectory - : config.dev.assetsSubDirectory +exports.assetsPath = function(_path) { + const assetsSubDirectory = + process.env.NODE_ENV === 'production' + ? config.build.assetsSubDirectory + : config.dev.assetsSubDirectory return path.posix.join(assetsSubDirectory, _path) } -exports.cssLoaders = function (options) { +exports.cssLoaders = function(options) { options = options || {} const cssLoader = { @@ -30,8 +31,22 @@ exports.cssLoaders = function (options) { } // generate loader string to be used with extract text plugin - function generateLoaders (loader, loaderOptions) { - const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader] + function generateLoaders(loader, loaderOptions) { + const loaders = [] + + // Extract CSS when that option is specified + // (which is the case during production build) + if (options.extract) { + loaders.push(MiniCssExtractPlugin.loader) + } else { + loaders.push('vue-style-loader') + } + + loaders.push(cssLoader) + + if (options.usePostCSS) { + loaders.push(postcssLoader) + } if (loader) { loaders.push({ @@ -42,24 +57,16 @@ exports.cssLoaders = function (options) { }) } - // Extract CSS when that option is specified - // (which is the case during production build) - if (options.extract) { - return ExtractTextPlugin.extract({ - use: loaders, - fallback: 'vue-style-loader' - }) - } else { - return ['vue-style-loader'].concat(loaders) - } + return loaders } - // https://vue-loader.vuejs.org/en/configurations/extract-css.html return { css: generateLoaders(), postcss: generateLoaders(), less: generateLoaders('less'), - sass: generateLoaders('sass', { indentedSyntax: true }), + sass: generateLoaders('sass', { + indentedSyntax: true + }), scss: generateLoaders('sass'), stylus: generateLoaders('stylus'), styl: generateLoaders('stylus') @@ -67,7 +74,7 @@ exports.cssLoaders = function (options) { } // Generate loaders for standalone style files (outside of .vue) -exports.styleLoaders = function (options) { +exports.styleLoaders = function(options) { const output = [] const loaders = exports.cssLoaders(options) diff --git a/build/vue-loader.conf.js b/build/vue-loader.conf.js index 33ed58bc..5496c931 100644 --- a/build/vue-loader.conf.js +++ b/build/vue-loader.conf.js @@ -1,22 +1,5 @@ 'use strict' -const utils = require('./utils') -const config = require('../config') -const isProduction = process.env.NODE_ENV === 'production' -const sourceMapEnabled = isProduction - ? config.build.productionSourceMap - : config.dev.cssSourceMap module.exports = { - loaders: utils.cssLoaders({ - sourceMap: sourceMapEnabled, - extract: isProduction - }), - cssSourceMap: sourceMapEnabled, - cacheBusting: config.dev.cacheBusting, - transformToRequire: { - video: ['src', 'poster'], - source: 'src', - img: 'src', - image: 'xlink:href' - } + //You can set the vue-loader configuration by yourself. } diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index 97bc6e2b..3b946b4b 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -2,9 +2,10 @@ const path = require('path') const utils = require('./utils') const config = require('../config') +const { VueLoaderPlugin } = require('vue-loader') const vueLoaderConfig = require('./vue-loader.conf') -function resolve (dir) { +function resolve(dir) { return path.join(__dirname, '..', dir) } @@ -27,15 +28,15 @@ module.exports = { output: { path: config.build.assetsRoot, filename: '[name].js', - publicPath: process.env.NODE_ENV === 'production' - ? config.build.assetsPublicPath - : config.dev.assetsPublicPath + publicPath: + process.env.NODE_ENV === 'production' + ? config.build.assetsPublicPath + : config.dev.assetsPublicPath }, resolve: { extensions: ['.js', '.vue', '.json'], alias: { - 'vue$': 'vue/dist/vue.esm.js', - '@': resolve('src'), + '@': resolve('src') } }, module: { @@ -49,7 +50,11 @@ module.exports = { { test: /\.js$/, loader: 'babel-loader?cacheDirectory', - include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')] + include: [ + resolve('src'), + resolve('test'), + resolve('node_modules/webpack-dev-server/client') + ] }, { test: /\.svg$/, @@ -86,6 +91,7 @@ module.exports = { } ] }, + plugins: [new VueLoaderPlugin()], node: { // prevent webpack from injecting useless setImmediate polyfill because Vue // source contains it (although only uses it if it's native). diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js index d27d8a04..26a5584a 100644 --- a/build/webpack.dev.conf.js +++ b/build/webpack.dev.conf.js @@ -9,7 +9,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin') const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') const portfinder = require('portfinder') -function resolve (dir) { +function resolve(dir) { return path.join(__dirname, '..', dir) } @@ -17,8 +17,12 @@ const HOST = process.env.HOST const PORT = process.env.PORT && Number(process.env.PORT) const devWebpackConfig = merge(baseWebpackConfig, { + mode: 'development', module: { - rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) + rules: utils.styleLoaders({ + sourceMap: config.dev.cssSourceMap, + usePostCSS: true + }) }, // cheap-module-eval-source-map is faster for development devtool: config.dev.devtool, @@ -39,7 +43,7 @@ const devWebpackConfig = merge(baseWebpackConfig, { proxy: config.dev.proxyTable, quiet: true, // necessary for FriendlyErrorsPlugin watchOptions: { - poll: config.dev.poll, + poll: config.dev.poll } }, plugins: [ @@ -47,8 +51,6 @@ const devWebpackConfig = merge(baseWebpackConfig, { 'process.env': require('../config/dev.env') }), new webpack.HotModuleReplacementPlugin(), - new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update. - new webpack.NoEmitOnErrorsPlugin(), // https://github.com/ampedandwired/html-webpack-plugin new HtmlWebpackPlugin({ filename: 'index.html', @@ -75,14 +77,20 @@ module.exports = new Promise((resolve, reject) => { devWebpackConfig.devServer.port = port // Add FriendlyErrorsPlugin - devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({ - compilationSuccessInfo: { - messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`], - }, - onErrors: config.dev.notifyOnErrors - ? utils.createNotifierCallback() - : undefined - })) + devWebpackConfig.plugins.push( + new FriendlyErrorsPlugin({ + compilationSuccessInfo: { + messages: [ + `Your application is running here: http://${ + devWebpackConfig.devServer.host + }:${port}` + ] + }, + onErrors: config.dev.notifyOnErrors + ? utils.createNotifierCallback() + : undefined + }) + ) resolve(devWebpackConfig) } diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 05cbcf4e..946a134a 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -7,17 +7,23 @@ const merge = require('webpack-merge') const baseWebpackConfig = require('./webpack.base.conf') const CopyWebpackPlugin = require('copy-webpack-plugin') const HtmlWebpackPlugin = require('html-webpack-plugin') -const ExtractTextPlugin = require('extract-text-webpack-plugin') -const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') +const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin') +const MiniCssExtractPlugin = require('mini-css-extract-plugin') +const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') const UglifyJsPlugin = require('uglifyjs-webpack-plugin') -function resolve (dir) { +function resolve(dir) { return path.join(__dirname, '..', dir) } -const env = require('../config/'+process.env.env_config+'.env') +const env = require('../config/' + process.env.env_config + '.env') + +// For NamedChunksPlugin +const seen = new Set() +const nameLength = 4 const webpackConfig = merge(baseWebpackConfig, { + mode: 'production', module: { rules: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, @@ -28,37 +34,18 @@ const webpackConfig = merge(baseWebpackConfig, { devtool: config.build.productionSourceMap ? config.build.devtool : false, output: { path: config.build.assetsRoot, - filename: utils.assetsPath('js/[name].[chunkhash].js'), - chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') + filename: utils.assetsPath('js/[name].[chunkhash:8].js'), + chunkFilename: utils.assetsPath('js/[name].[chunkhash:8].js') }, plugins: [ // http://vuejs.github.io/vue-loader/en/workflow/production.html new webpack.DefinePlugin({ 'process.env': env }), - new UglifyJsPlugin({ - uglifyOptions: { - compress: { - warnings: false - } - }, - sourceMap: config.build.productionSourceMap, - parallel: true - }), // extract css into its own file - new ExtractTextPlugin({ - filename: utils.assetsPath('css/[name].[contenthash].css'), - // Setting the following option to `false` will not extract CSS from codesplit chunks. - // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. - // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 - allChunks: false, - }), - // Compress extracted CSS. We are using this plugin so that possible - // duplicated CSS from different components can be deduped. - new OptimizeCSSPlugin({ - cssProcessorOptions: config.build.productionSourceMap - ? { safe: true, map: { inline: false } } - : { safe: true } + new MiniCssExtractPlugin({ + filename: utils.assetsPath('css/[name].[contenthash:8].css'), + chunkFilename: utils.assetsPath('css/[name].[contenthash:8].css') }), // generate dist index.html with correct asset hash for caching. // you can customize output by editing /index.html @@ -78,68 +65,34 @@ const webpackConfig = merge(baseWebpackConfig, { removeAttributeQuotes: true // more options: // https://github.com/kangax/html-minifier#options-quick-reference - }, - // necessary to consistently work with multiple chunks via CommonsChunkPlugin - chunksSortMode: 'dependency' + } + // default sort mode uses toposort which cannot handle cyclic deps + // in certain cases, and in webpack 4, chunk order in HTML doesn't + // matter anyway + }), + new ScriptExtHtmlWebpackPlugin({ + //`runtime` must same as runtimeChunk name. default is `runtime` + inline: /runtime\..*\.js$/ + }), + // keep chunk.id stable when chunk has no name + new webpack.NamedChunksPlugin(chunk => { + if (chunk.name) { + return chunk.name + } + const modules = Array.from(chunk.modulesIterable) + if (modules.length > 1) { + const hash = require('hash-sum') + const joinedHash = hash(modules.map(m => m.id).join('_')) + let len = nameLength + while (seen.has(joinedHash.substr(0, len))) len++ + seen.add(joinedHash.substr(0, len)) + return `chunk-${joinedHash.substr(0, len)}` + } else { + return modules[0].id + } }), // keep module.id stable when vender modules does not change new webpack.HashedModuleIdsPlugin(), - // enable scope hoisting - new webpack.optimize.ModuleConcatenationPlugin(), - // split vendor js into its own file - new webpack.optimize.CommonsChunkPlugin({ - name: 'vendor', - minChunks (module) { - // any required modules inside node_modules are extracted to vendor - return ( - module.resource && - /\.js$/.test(module.resource) && - module.resource.indexOf( - path.join(__dirname, '../node_modules') - ) === 0 - ) - } - }), - // extract webpack runtime and module manifest to its own file in order to - // prevent vendor hash from being updated whenever app bundle is updated - new webpack.optimize.CommonsChunkPlugin({ - name: 'manifest', - minChunks: Infinity - }), - // This instance extracts shared chunks from code splitted chunks and bundles them - // in a separate chunk, similar to the vendor chunk - // see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk - new webpack.optimize.CommonsChunkPlugin({ - name: 'app', - async: 'vendor-async', - children: true, - minChunks: 3 - }), - // split echarts into its own file - new webpack.optimize.CommonsChunkPlugin({ - async: 'echarts', - minChunks(module) { - var context = module.context; - return context && (context.indexOf('echarts') >= 0 || context.indexOf('zrender') >= 0); - } - }), - // split xlsx into its own file - new webpack.optimize.CommonsChunkPlugin({ - async: 'xlsx', - minChunks(module) { - var context = module.context; - return context && (context.indexOf('xlsx') >= 0); - } - }), - // split codemirror into its own file - new webpack.optimize.CommonsChunkPlugin({ - async: 'codemirror', - minChunks(module) { - var context = module.context; - return context && (context.indexOf('codemirror') >= 0); - } - }), - // copy custom static assets new CopyWebpackPlugin([ { @@ -148,7 +101,48 @@ const webpackConfig = merge(baseWebpackConfig, { ignore: ['.*'] } ]) - ] + ], + optimization: { + splitChunks: { + chunks: 'all', + cacheGroups: { + libs: { + name: 'chunk-libs', + test: /[\\/]node_modules[\\/]/, + priority: 10, + chunks: 'initial' // 只打包初始时依赖的第三方 + }, + elementUI: { + name: 'chunk-elementUI', // 单独将 elementUI 拆包 + priority: 20, // 权重要大于 libs 和 app 不然会被打包进 libs 或者 app + test: /[\\/]node_modules[\\/]element-ui[\\/]/ + }, + commons: { + name: 'chunk-commons', + test: resolve('src/components'), // 可自定义拓展你的规则 + minChunks: 3, // 最小公用次数 + priority: 5, + reuseExistingChunk: true + } + } + }, + runtimeChunk: 'single', + minimizer: [ + new UglifyJsPlugin({ + uglifyOptions: { + mangle: { + safari10: true + } + }, + sourceMap: config.build.productionSourceMap, + cache: true, + parallel: true + }), + // Compress extracted CSS. We are using this plugin so that possible + // duplicated CSS from different components can be deduped. + new OptimizeCSSAssetsPlugin() + ] + } }) if (config.build.productionGzip) { @@ -159,9 +153,7 @@ if (config.build.productionGzip) { asset: '[path].gz[query]', algorithm: 'gzip', test: new RegExp( - '\\.(' + - config.build.productionGzipExtensions.join('|') + - ')$' + '\\.(' + config.build.productionGzipExtensions.join('|') + ')$' ), threshold: 10240, minRatio: 0.8 @@ -169,9 +161,28 @@ if (config.build.productionGzip) { ) } -if (config.build.bundleAnalyzerReport) { - const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin - webpackConfig.plugins.push(new BundleAnalyzerPlugin()) +if (config.build.generateAnalyzerReport || config.build.bundleAnalyzerReport) { + const BundleAnalyzerPlugin = require('webpack-bundle-analyzer') + .BundleAnalyzerPlugin + + if (config.build.bundleAnalyzerReport) { + webpackConfig.plugins.push( + new BundleAnalyzerPlugin({ + analyzerPort: 8080, + generateStatsFile: false + }) + ) + } + + if (config.build.generateAnalyzerReport) { + webpackConfig.plugins.push( + new BundleAnalyzerPlugin({ + analyzerMode: 'static', + reportFilename: 'bundle-report.html', + openAnalyzer: false + }) + ) + } } module.exports = webpackConfig diff --git a/config/dev.env.js b/config/dev.env.js index d1e29d4e..68ddea56 100644 --- a/config/dev.env.js +++ b/config/dev.env.js @@ -1,5 +1,5 @@ module.exports = { - NODE_ENV: '"development"', - ENV_CONFIG: '"dev"', - BASE_API: '"https://api-dev"' + NODE_ENV: '"development"', + ENV_CONFIG: '"dev"', + BASE_API: '"https://api-dev"' } diff --git a/config/index.js b/config/index.js index 92ac0ed1..599e4a63 100644 --- a/config/index.js +++ b/config/index.js @@ -6,14 +6,16 @@ const path = require('path') module.exports = { dev: { - // Paths assetsSubDirectory: 'static', assetsPublicPath: '/', proxyTable: {}, // Various Dev Server settings - host: 'localhost', // can be overwritten by process.env.HOST + + // can be overwritten by process.env.HOST + // if you want dev by ip, please set host: '0.0.0.0' + host: 'localhost', port: 9527, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined autoOpenBrowser: true, errorOverlay: true, @@ -33,19 +35,14 @@ module.exports = { */ // https://webpack.js.org/configuration/devtool/#development - devtool: '#cheap-source-map', - - // If you have problems debugging vue-files in devtools, - // set this to false - it *may* help - // https://vue-loader.vuejs.org/en/options.html#cachebusting - cacheBusting: true, + devtool: 'cheap-source-map', // CSS Sourcemaps off by default because relative paths are "buggy" // with this option, according to the CSS-Loader README // (https://github.com/webpack/css-loader#sourcemaps) // In our experience, they generally work as expected, // just be aware of this issue when enabling this option. - cssSourceMap: false, + cssSourceMap: false }, build: { @@ -56,16 +53,21 @@ module.exports = { assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static', - // you can set by youself according to actual condition - assetsPublicPath: './', + /** + * You can set by youself according to actual condition + * You will need to set this if you plan to deploy your site under a sub path, + * for example GitHub pages. If you plan to deploy your site to https://foo.github.io/bar/, + * then assetsPublicPath should be set to "/bar/". + * In most cases please use '/' !!! + */ + assetsPublicPath: '/', /** * Source Maps */ - productionSourceMap: false, // https://webpack.js.org/configuration/devtool/#production - devtool: '#source-map', + devtool: 'source-map', // Gzip off by default as many popular static hosts such as // Surge or Netlify already gzip all static assets for you. @@ -76,8 +78,11 @@ module.exports = { // Run the build command with an extra argument to // View the bundle analyzer report after build finishes: - // `npm run build --report` + // `npm run build:prod --report` // Set to `true` or `false` to always turn it on or off - bundleAnalyzerReport: process.env.npm_config_report + bundleAnalyzerReport: process.env.npm_config_report || false, + + // `npm run build:prod --generate_report` + generateAnalyzerReport: process.env.npm_config_generate_report || false } } diff --git a/config/prod.env.js b/config/prod.env.js index 0c43ea73..bfcd6d27 100644 --- a/config/prod.env.js +++ b/config/prod.env.js @@ -1,5 +1,5 @@ module.exports = { - NODE_ENV: '"production"', - ENV_CONFIG: '"prod"', - BASE_API: '"https://api-prod"' + NODE_ENV: '"production"', + ENV_CONFIG: '"prod"', + BASE_API: '"https://api-prod"' } diff --git a/config/sit.env.js b/config/sit.env.js index 296a3de6..93178e80 100644 --- a/config/sit.env.js +++ b/config/sit.env.js @@ -1,5 +1,5 @@ module.exports = { - NODE_ENV: '"production"', - ENV_CONFIG: '"sit"', - BASE_API: '"https://api-sit"' + NODE_ENV: '"production"', + ENV_CONFIG: '"sit"', + BASE_API: '"https://api-sit"' } diff --git a/package.json b/package.json index 361c9410..c65b3b22 100644 --- a/package.json +++ b/package.json @@ -1,96 +1,126 @@ { "name": "vue-element-admin", - "version": "3.6.2", + "version": "3.9.0", "description": "A magical vue admin. Typical templates for enterprise applications. Newest development stack of vue. Lots of awesome features", "author": "Pan ", "license": "MIT", - "private": true, "scripts": { - "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", + "dev": "cross-env BABEL_ENV=development webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", "build:prod": "cross-env NODE_ENV=production env_config=prod node build/build.js", "build:sit": "cross-env NODE_ENV=production env_config=sit node build/build.js", "lint": "eslint --ext .js,.vue src", - "test": "npm run lint" + "test": "npm run lint", + "precommit": "lint-staged", + "svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml" + }, + "lint-staged": { + "src/**/*.{js,vue}": [ + "eslint --fix", + "git add" + ] + }, + "keywords": [ + "vue", + "element-ui", + "admin", + "management-system", + "admin-template" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/PanJiaChen/vue-element-admin.git" + }, + "bugs": { + "url": "https://github.com/PanJiaChen/vue-element-admin/issues" }, "dependencies": { - "axios": "0.17.1", + "axios": "0.18.0", "clipboard": "1.7.1", - "codemirror": "5.32.0", + "codemirror": "5.39.2", + "connect": "3.6.6", + "driver.js": "0.5.2", "dropzone": "5.2.0", - "echarts": "3.8.5", - "element-ui": "2.0.8", - "file-saver": "1.3.3", + "echarts": "4.1.0", + "element-ui": "2.4.6", + "file-saver": "1.3.8", "font-awesome": "4.7.0", "js-cookie": "2.2.0", - "jsonlint": "1.6.2", + "jsonlint": "1.6.3", "jszip": "3.1.5", "mockjs": "1.0.1-beta3", "normalize.css": "7.0.0", "nprogress": "0.2.0", - "screenfull": "3.3.2", - "showdown": "1.8.5", + "screenfull": "3.3.3", + "showdown": "1.8.6", "simplemde": "1.11.2", "sortablejs": "1.7.0", - "vue": "2.5.10", + "vue": "2.5.17", "vue-count-to": "1.0.13", "vue-i18n": "7.3.2", - "vue-multiselect": "2.0.8", "vue-router": "3.0.1", "vue-splitpane": "1.0.2", - "vuedraggable": "2.15.0", + "vuedraggable": "^2.16.0", "vuex": "3.0.1", "xlsx": "^0.11.16" }, "devDependencies": { - "autoprefixer": "7.2.3", - "babel-core": "6.26.0", - "babel-eslint": "8.0.3", + "autoprefixer": "8.5.0", + "babel-core": "6.26.3", + "babel-eslint": "8.2.6", "babel-helper-vue-jsx-merge-props": "2.0.3", - "babel-loader": "7.1.2", + "babel-loader": "7.1.5", + "babel-plugin-dynamic-import-node": "2.0.0", "babel-plugin-syntax-jsx": "6.18.0", "babel-plugin-transform-runtime": "6.23.0", - "babel-plugin-transform-vue-jsx": "3.5.0", - "babel-preset-env": "1.6.1", + "babel-plugin-transform-vue-jsx": "3.7.0", + "babel-preset-env": "1.7.0", "babel-preset-stage-2": "6.24.1", - "chalk": "2.3.0", - "copy-webpack-plugin": "4.3.0", - "cross-env": "5.1.1", - "css-loader": "0.28.7", - "eslint": "4.13.1", - "eslint-friendly-formatter": "3.0.0", - "eslint-loader": "1.9.0", - "eslint-plugin-html": "4.0.1", - "extract-text-webpack-plugin": "3.0.2", - "file-loader": "1.1.5", - "friendly-errors-webpack-plugin": "1.6.1", - "html-webpack-plugin": "^3.2.0", - "node-notifier": "5.1.2", + "chalk": "2.4.1", + "copy-webpack-plugin": "4.5.2", + "cross-env": "5.2.0", + "css-loader": "1.0.0", + "eslint": "4.19.1", + "eslint-friendly-formatter": "4.0.1", + "eslint-loader": "2.0.0", + "eslint-plugin-vue": "4.7.1", + "file-loader": "1.1.11", + "friendly-errors-webpack-plugin": "1.7.0", + "hash-sum": "1.0.2", + "html-webpack-plugin": "4.0.0-alpha", + "husky": "0.14.3", + "lint-staged": "7.2.2", + "mini-css-extract-plugin": "0.4.1", + "node-notifier": "5.2.1", "node-sass": "^4.7.2", - "optimize-css-assets-webpack-plugin": "3.2.0", - "ora": "1.3.0", + "optimize-css-assets-webpack-plugin": "5.0.0", + "ora": "3.0.0", + "path-to-regexp": "2.4.0", "portfinder": "1.0.13", - "postcss-import": "11.0.0", - "postcss-loader": "2.0.9", - "postcss-url": "7.3.0", - "pushstate-server": "3.0.1", + "postcss-import": "11.1.0", + "postcss-loader": "2.1.6", + "postcss-url": "7.3.2", "rimraf": "2.6.2", - "sass-loader": "6.0.6", + "sass-loader": "7.0.3", + "script-ext-html-webpack-plugin": "2.0.1", "script-loader": "0.7.2", - "semver": "5.4.1", - "shelljs": "0.7.8", - "svg-sprite-loader": "3.5.2", - "uglifyjs-webpack-plugin": "1.1.3", - "url-loader": "0.6.2", - "vue-loader": "13.5.0", - "vue-style-loader": "3.0.3", - "vue-template-compiler": "2.5.10", - "webpack": "3.10.0", - "webpack-bundle-analyzer": "2.9.1", - "webpack-dev-server": "2.9.7", - "webpack-merge": "4.1.1" + "semver": "5.5.0", + "serve-static": "1.13.2", + "shelljs": "0.8.2", + "svg-sprite-loader": "3.8.0", + "svgo": "1.0.5", + "uglifyjs-webpack-plugin": "1.2.7", + "url-loader": "1.0.1", + "vue-loader": "15.3.0", + "vue-style-loader": "4.1.2", + "vue-template-compiler": "2.5.17", + "webpack": "4.16.5", + "webpack-bundle-analyzer": "2.13.1", + "webpack-cli": "3.1.0", + "webpack-dev-server": "3.1.5", + "webpack-merge": "4.1.4" }, "engines": { - "node": ">= 4.0.0", + "node": ">= 6.0.0", "npm": ">= 3.0.0" }, "browserslist": [ diff --git a/src/App.vue b/src/App.vue index 3761c410..ab408f3e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,11 +1,11 @@ diff --git a/src/api/article.js b/src/api/article.js index 9eacd90d..f54b8af6 100644 --- a/src/api/article.js +++ b/src/api/article.js @@ -8,10 +8,11 @@ export function fetchList(query) { }) } -export function fetchArticle() { +export function fetchArticle(id) { return request({ url: '/article/detail', - method: 'get' + method: 'get', + params: { id } }) } diff --git a/src/assets/echarts-macarons.js b/src/assets/echarts-macarons.js deleted file mode 100644 index 0678ef83..00000000 --- a/src/assets/echarts-macarons.js +++ /dev/null @@ -1,199 +0,0 @@ -/* eslint-disable */ -(function (root, factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['exports', 'echarts'], factory); - } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') { - // CommonJS - factory(exports, require('echarts')); - } else { - // Browser globals - factory({}, root.echarts); - } -}(this, function (exports, echarts) { - var log = function (msg) { - if (typeof console !== 'undefined') { - console && console.error && console.error(msg); - } - }; - if (!echarts) { - log('ECharts is not Loaded'); - return; - } - - var colorPalette = [ - '#2ec7c9','#b6a2de','#5ab1ef','#ffb980','#d87a80', - '#8d98b3','#e5cf0d','#97b552','#95706d','#dc69aa', - '#07a2a4','#9a7fd1','#588dd5','#f5994e','#c05050', - '#59678c','#c9ab00','#7eb00a','#6f5553','#c14089' - ]; - - - var theme = { - color: colorPalette, - - title: { - textStyle: { - fontWeight: 'normal', - color: '#008acd' - } - }, - - visualMap: { - itemWidth: 15, - color: ['#5ab1ef','#e0ffff'] - }, - - toolbox: { - iconStyle: { - normal: { - borderColor: colorPalette[0] - } - } - }, - - tooltip: { - backgroundColor: 'rgba(50,50,50,0.5)', - axisPointer : { - type : 'line', - lineStyle : { - color: '#008acd' - }, - crossStyle: { - color: '#008acd' - }, - shadowStyle : { - color: 'rgba(200,200,200,0.2)' - } - } - }, - - dataZoom: { - dataBackgroundColor: '#efefff', - fillerColor: 'rgba(182,162,222,0.2)', - handleColor: '#008acd' - }, - - grid: { - borderColor: '#eee' - }, - - categoryAxis: { - axisLine: { - lineStyle: { - color: '#008acd' - } - }, - splitLine: { - lineStyle: { - color: ['#eee'] - } - } - }, - - valueAxis: { - axisLine: { - lineStyle: { - color: '#008acd' - } - }, - splitArea : { - show : true, - areaStyle : { - color: ['rgba(250,250,250,0.1)','rgba(200,200,200,0.1)'] - } - }, - splitLine: { - lineStyle: { - color: ['#eee'] - } - } - }, - - timeline : { - lineStyle : { - color : '#008acd' - }, - controlStyle : { - normal : { color : '#008acd'}, - emphasis : { color : '#008acd'} - }, - symbol : 'emptyCircle', - symbolSize : 3 - }, - - line: { - smooth : true, - symbol: 'emptyCircle', - symbolSize: 3 - }, - - candlestick: { - itemStyle: { - normal: { - color: '#d87a80', - color0: '#2ec7c9', - lineStyle: { - color: '#d87a80', - color0: '#2ec7c9' - } - } - } - }, - - scatter: { - symbol: 'circle', - symbolSize: 4 - }, - - map: { - label: { - normal: { - textStyle: { - color: '#d87a80' - } - } - }, - itemStyle: { - normal: { - borderColor: '#eee', - areaColor: '#ddd' - }, - emphasis: { - areaColor: '#fe994e' - } - } - }, - - graph: { - color: colorPalette - }, - - gauge : { - axisLine: { - lineStyle: { - color: [[0.2, '#2ec7c9'],[0.8, '#5ab1ef'],[1, '#d87a80']], - width: 10 - } - }, - axisTick: { - splitNumber: 10, - length :15, - lineStyle: { - color: 'auto' - } - }, - splitLine: { - length :22, - lineStyle: { - color: 'auto' - } - }, - pointer : { - width : 5 - } - } - }; - - echarts.registerTheme('macarons', theme); -})); diff --git a/src/components/BackToTop/index.vue b/src/components/BackToTop/index.vue index cbb1f21d..39977178 100644 --- a/src/components/BackToTop/index.vue +++ b/src/components/BackToTop/index.vue @@ -1,10 +1,10 @@