diff --git b/.gitignore a/.gitignore new file mode 100644 index 0000000..db80b7f --- /dev/null +++ a/.gitignore @@ -0,0 +1,28 @@ +.DS_Store +yarn.lock +node_modules +package-lock +package-lock.json +/dist +dist.zip +/public/font_family + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? +src/views/portrait/test.vue diff --git b/.postcssrc.js a/.postcssrc.js new file mode 100755 index 0000000..eee3e92 --- /dev/null +++ a/.postcssrc.js @@ -0,0 +1,10 @@ +// https://github.com/michael-ciniawsky/postcss-load-config + +module.exports = { + "plugins": { + "postcss-import": {}, + "postcss-url": {}, + // to edit target browsers: use "browserslist" field in package.json + "autoprefixer": {} + } +} diff --git b/README.md a/README.md new file mode 100644 index 0000000..30aa20c --- /dev/null +++ a/README.md @@ -0,0 +1,39 @@ +-开发环境 +- node.js v8.0+ +- git + +-技术栈 +- ES6+ +- vue v2.5+ +- vue-router +- vuex +- axios +- scss +- element-ui v2.4+ + +- 实现功能 + +- 登录、退出 ++ 基于token + - 状态拦截、404页面 + - 动态加载路由 + - 页面、按钮指令权限管理 + - 无限级菜单 +- 封装vue-i18n@8.x国际化组件 +- 系统全屏化 + +# 安装依赖 (如果安装失败就多安装几次,实在不行就换淘宝镜像) +yarn or yarn install +or +npm install + +# 启动项目 (已经配置好启动服务自动打开浏览器,如果没自动打开按照控制台输出的地址自己打开) +# 如果eslint语法检查报错,直接关掉eslint语法检查 +yarn dev +or +npm run dev + +# 启动编译打包 生产环境 +yarn build +or + npm run build \ No newline at end of file diff --git b/babel.config.js a/babel.config.js new file mode 100644 index 0000000..e955840 --- /dev/null +++ a/babel.config.js @@ -0,0 +1,5 @@ +module.exports = { + presets: [ + '@vue/cli-plugin-babel/preset' + ] +} diff --git b/package.json a/package.json new file mode 100755 index 0000000..1cf809c --- /dev/null +++ a/package.json @@ -0,0 +1,44 @@ +{ + "name": "vue-admin", + "version": "1.0.0", + "private": true, + "scripts": { + "serve": "vue-cli-service serve", + "build": "vue-cli-service build", + "lint": "vue-cli-service lint" + }, + "dependencies": { + "core-js": "^3.6.5", + "echarts": "5.3.2", + "element-ui": "^2.15.1", + "js-cookie": "^2.2.0", + "jsencrypt": "^3.2.0", + "nprogress": "^0.2.0", + "font-awesome": "^4.7.0", + "vue": "^2.6.11", + "vue-i18n": "^8.4.0", + "vue-router": "^3.5.1", + "axios": "^0.21.1", + "vuex": "^3.6.2" + }, + "devDependencies": { + "@vue/cli-plugin-babel": "~4.5.0", + "@vue/cli-service": "~4.5.0", + "autoprefixer": "^7.1.2", + "babel-core": "^6.22.1", + "babel-loader": "^7.1.1", + "babel-eslint": "^10.1.0", + "eslint": "^6.7.2", + "eslint-plugin-vue": "^6.2.2", + "extract-text-webpack-plugin": "^3.0.0", + "html-webpack-plugin": "^4.2.0", + "mini-css-extract-plugin": "^0.9.0", + "node-sass": "^4.13.0", + "sass-loader": "^7.1.0", + "postcss-import": "^12.0.1", + "postcss-loader": "^3.0.0", + "postcss-url": "^7.2.1", + "optimize-css-assets-webpack-plugin": "^3.2.0", + "vue-template-compiler": "^2.5.2" + } +} diff --git b/public/index.html a/public/index.html new file mode 100644 index 0000000..aa5038b --- /dev/null +++ a/public/index.html @@ -0,0 +1,23 @@ + + + + + + + + + + <%= htmlWebpackPlugin.options.title %> + + + + + +
+ + + + \ No newline at end of file diff --git b/src/App.vue a/src/App.vue new file mode 100644 index 0000000..900ba22 --- /dev/null +++ a/src/App.vue @@ -0,0 +1,47 @@ + + + + + diff --git b/src/main.js a/src/main.js new file mode 100755 index 0000000..51fd014 --- /dev/null +++ a/src/main.js @@ -0,0 +1,35 @@ +// The Vue build version to load with the `import` command +// (runtime-only or standalone) has been set in webpack.base.conf with an alias. +import Vue from "vue" +import ElementUI from "element-ui" +import App from "./App.vue" +import router from "./router" +import store from "./store" +import i18n from "./i18n/i18n" +import globalPlugin from "./utils/global" +import permission from "./directive/permission/button" +import NProgress from "nprogress" + +import "nprogress/nprogress.css" +import "element-ui/lib/theme-chalk/index.css" +import "font-awesome/css/font-awesome.css" +import "@/router/permission" + +Vue.config.productionTip = false +Vue.use(ElementUI) +Vue.use(globalPlugin) +Vue.use(permission) + +NProgress.inc(0.2) +NProgress.configure({ easing: "ease", speed: 500, showSpinner: false }) + +/* eslint-disable no-new */ +new Vue({ + el: "#app", + router, + store, + i18n, + render: h => h(App), + components: {App}, + template: "" +}) diff --git b/vue.config.js a/vue.config.js new file mode 100644 index 0000000..d3e1888 --- /dev/null +++ a/vue.config.js @@ -0,0 +1,93 @@ +const path = require("path"); +const resolve = (dir) => path.join(__dirname, dir); +const IS_PROD = ["production", "prod"].includes(process.env.NODE_ENV); +const BundleAnalyzerPlugin = require("webpack-bundle-analyzer") + .BundleAnalyzerPlugin; + +module.exports = { + publicPath: "./", // 编译后的地址,可以根据环境进行设置 + outputDir: "dist", // 生产环境构建文件的目录 + assetsDir: "static", // 静态文件目录 + lintOnSave: false, //是否开启编译时是否不符合eslint提示 + productionSourceMap: false, // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。 + devServer: { + hot:true, + port: 8080, // 端口 + open: false, // 启动后打开浏览器 + compress: true, + overlay: { + // 当出现编译器错误或警告时,在浏览器中显示全屏覆盖层 + warnings: false, + errors: true, + }, + proxy: { + "/": { + target:"http://lead.xc.com:32269", + changeOrigin: true, + ws:true, + }, + }, + disableHostCheck: true + }, + css: { + extract: IS_PROD, // 是否将组件中的 CSS 提取至一个独立的 CSS 文件中 (而不是动态注入到 JavaScript 中的 inline 代码)。 + sourceMap: false, + }, + chainWebpack: (config) => { + config.plugin('html').tap(args => { + args[0].title = '云平台'; + return args; + }); + config.resolve.alias + .set("@", resolve("src")) + .set("assets", resolve("src/assets")) + .set("components", resolve("src/components")) + .set("router", resolve("src/router")) + .set("utils", resolve("src/utils")) + .set("store", resolve("src/store")) + .set("views", resolve("src/views")) + .set("api", resolve("src/api")); + if (IS_PROD) { + config.plugin("webpack-report").use(BundleAnalyzerPlugin, [ + { + analyzerMode: "static", + }, + ]); + } + config.when(IS_PROD, (config) => { + config.devtool("cheap-source-map"); + config + .plugin("ScriptExtHtmlWebpackPlugin") + .after("html") + .use("script-ext-html-webpack-plugin") + .end(); + config.optimization.splitChunks({ + chunks: "all", + cacheGroups: { + // cacheGroups 下可以可以配置多个组,每个组根据test设置条件,符合test条件的模块 + commons: { + name: "chunk-commons", + test: resolve("src/components"), + minChunks: 3, // 被至少用三次以上打包分离 + priority: 5, // 优先级 + reuseExistingChunk: true, // 表示是否使用已有的 chunk,如果为 true 则表示如果当前的 chunk 包含的模块已经被抽取出去了,那么将不会重新生成新的。 + }, + node_vendors: { + name: "chunk-libs", + chunks: "initial", // 只打包初始时依赖的第三方 + test: /[\\/]node_modules[\\/]/, + priority: 10, + }, + elementUI: { + name: "chunk-elementUI", // 单独将 elementUI 拆包 + priority: 20, // 数字大权重到,满足多个 cacheGroups 的条件时候分到权重高的 + test: /[\\/]node_modules[\\/]_?element(.*)/, + }, + }, + }); + config.optimization.runtimeChunk("single"); + config.optimization.minimize(true); + }); + }, +}; +