| > 1% | |||||
| last 2 versions | |||||
| last 10 Chrome versions | |||||
| last 5 Firefox versions | |||||
| Safari >= 6 | |||||
| ie > 8 |
| NODE_ENV = 'development' | |||||
| VUE_APP_BASE_API = '/domain' | |||||
| VUE_APP_PARK_DOMAIN = 'http://localhost' |
| NODE_ENV = 'production' | |||||
| VUE_APP_BASE_API = '/' | |||||
| VUE_APP_PARK_DOMAIN = '' |
| module.exports = { | |||||
| root: true, | |||||
| env: { | |||||
| node: true | |||||
| }, | |||||
| extends: ['plugin:vue/essential', 'eslint:recommended'], | |||||
| parserOptions: { | |||||
| parser: 'babel-eslint' | |||||
| }, | |||||
| rules: { | |||||
| 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', | |||||
| 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', | |||||
| }, | |||||
| //过滤掉layui检测 | |||||
| globals: { | |||||
| layui: true | |||||
| }, | |||||
| }; |
| .DS_Store | |||||
| node_modules | |||||
| /dist | |||||
| # local env files | |||||
| .env.local | |||||
| .env.*.local | |||||
| # Log files | |||||
| npm-debug.log* | |||||
| yarn-debug.log* | |||||
| yarn-error.log* | |||||
| # Editor directories and files | |||||
| .idea | |||||
| .vscode | |||||
| *.suo | |||||
| *.ntvs* | |||||
| *.njsproj | |||||
| *.sln | |||||
| *.sw? | |||||
| *.md | |||||
| *.history |
| module.exports = { | |||||
| presets: ['@vue/cli-plugin-babel/preset'] | |||||
| }; |
| { | |||||
| "name": "hhr", | |||||
| "version": "0.1.0", | |||||
| "private": true, | |||||
| "scripts": { | |||||
| "serve": "vue-cli-service serve", | |||||
| "build": "vue-cli-service build", | |||||
| "lint": "vue-cli-service lint", | |||||
| "test": "vue-cli-service build --mode prod --report" | |||||
| }, | |||||
| "dependencies": { | |||||
| "@tinymce/tinymce-vue": "^3.2.2", | |||||
| "axios": "^0.19.2", | |||||
| "core-js": "^3.6.4", | |||||
| "crypto-js": "^4.0.0", | |||||
| "dayjs": "^1.10.4", | |||||
| "echarts": "^4.9.0", | |||||
| "element-ui": "^2.13.0", | |||||
| "fundebug-javascript": "^2.4.2", | |||||
| "fundebug-revideo": "^0.6.2", | |||||
| "fundebug-vue": "0.0.1", | |||||
| "html2canvas": "^1.0.0-rc.7", | |||||
| "js-base64": "^3.6.0", | |||||
| "prerender-spa-plugin": "^3.4.0", | |||||
| "qs": "^6.9.4", | |||||
| "tinymce": "^5.4.1", | |||||
| "vue": "^2.6.11", | |||||
| "vue-clipboard2": "^0.3.1", | |||||
| "vue-lazyload": "^1.3.3", | |||||
| "vue-meta-info": "^0.1.7", | |||||
| "vue-router": "^3.1.6", | |||||
| "vue-seamless-scroll": "^1.1.21", | |||||
| "vue-wxlogin": "^1.0.2", | |||||
| "vuedraggable": "^2.24.0", | |||||
| "vuex": "^3.1.3", | |||||
| "webpack-spritesmith": "^1.1.0" | |||||
| }, | |||||
| "devDependencies": { | |||||
| "@vue/cli-plugin-babel": "^4.3.0", | |||||
| "@vue/cli-plugin-eslint": "^4.3.0", | |||||
| "@vue/cli-service": "^4.3.0", | |||||
| "@vue/eslint-config-prettier": "^6.0.0", | |||||
| "babel-eslint": "^10.1.0", | |||||
| "compression-webpack-plugin": "^3.1.0", | |||||
| "eslint": "^6.7.2", | |||||
| "eslint-plugin-prettier": "^3.1.1", | |||||
| "eslint-plugin-vue": "^6.2.2", | |||||
| "node-sass": "^4.14.1", | |||||
| "prettier": "^1.19.1", | |||||
| "sass-loader": "^8.0.2", | |||||
| "swiper": "^3.4.2", | |||||
| "useless-files-webpack-plugin": "^1.0.1", | |||||
| "vue-awesome-swiper": "^4.1.0", | |||||
| "vue-template-compiler": "^2.6.11" | |||||
| } | |||||
| } |
| <!DOCTYPE html> | |||||
| <html lang="zh"> | |||||
| <head> | |||||
| <meta charset="utf-8" /> | |||||
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |||||
| <meta name="renderer" content="webkit" /> | |||||
| <meta name="viewport" content="width=device-width,initial-scale=1.0" /> | |||||
| <title>园区数字化系统</title> | |||||
| <link rel="icon" href="/web/<%= BASE_URL %>hhr.ico" /> | |||||
| </head> | |||||
| <body> | |||||
| <noscript> | |||||
| <strong> | |||||
| We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without | |||||
| JavaScript enabled. Please enable it to continue. | |||||
| </strong> | |||||
| </noscript> | |||||
| <div id="app"></div> | |||||
| <!-- built files will be auto injected --> | |||||
| <script></script> | |||||
| </body> | |||||
| </html> |
| <template> | |||||
| <div id="app"> | |||||
| <router-view></router-view> | |||||
| </div> | |||||
| </template> | |||||
| <script> | |||||
| export default { | |||||
| name: "Home", | |||||
| components: {}, | |||||
| computed: {}, | |||||
| watch: {}, | |||||
| data() { | |||||
| return {}; | |||||
| }, | |||||
| created() {}, | |||||
| methods: {}, | |||||
| }; | |||||
| </script> | |||||
| <style lang="scss" scoped></style> |
| import Vue from "vue"; | |||||
| import App from "./App.vue"; | |||||
| import router from "./router"; | |||||
| import store from "./store"; | |||||
| import ElementUI from "element-ui"; | |||||
| import "element-ui/lib/theme-chalk/index.css"; | |||||
| import VueLazyload from "vue-lazyload"; | |||||
| import MetaInfo from "vue-meta-info"; | |||||
| Vue.use(VueLazyload, { | |||||
| preLoad: 1.3, | |||||
| attempt: 1, | |||||
| }); | |||||
| Vue.use(scroll); | |||||
| Vue.use(MetaInfo); | |||||
| Vue.config.productionTip = false; | |||||
| Vue.use(ElementUI); | |||||
| // 克隆对象 方便克隆以及调试 | |||||
| Vue.prototype.$cloneDeep = data => JSON.parse(JSON.stringify(data)); | |||||
| new Vue({ | |||||
| router, | |||||
| store, | |||||
| render: h => h(App), | |||||
| mounted() { | |||||
| document.dispatchEvent(new Event("render-event")); | |||||
| }, | |||||
| }).$mount("#app"); |
| export default [{ | |||||
| path: "*", | |||||
| redirect: "/index", // 重定向 | |||||
| }, ]; |
| import Vue from "vue"; | |||||
| import VueRouter from "vue-router"; | |||||
| import store from "../store/index"; | |||||
| import hhr from "./hhr"; | |||||
| Vue.use(VueRouter); | |||||
| const routes = [ | |||||
| ...hhr, // 禾获仁官网 | |||||
| ]; | |||||
| const router = new VueRouter({ | |||||
| mode: "history", | |||||
| base: "web", | |||||
| routes, | |||||
| }); | |||||
| router.beforeEach((to, from, next) => { | |||||
| /* 路由发生变化修改页面title */ | |||||
| if (to.meta.title) { | |||||
| document.title = to.meta.title; | |||||
| } | |||||
| }); | |||||
| const originalPush = VueRouter.prototype.push; | |||||
| VueRouter.prototype.push = function push(location) { | |||||
| return originalPush.call(this, location).catch(err => err); | |||||
| }; | |||||
| export default router; |
| export default {}; |
| const getters = {}; | |||||
| export default getters; |
| import Vue from "vue"; | |||||
| import Vuex from "vuex"; | |||||
| import getters from "./getters"; | |||||
| import state from "./state"; | |||||
| import mutations from "./mutations"; | |||||
| import actions from "./actions"; | |||||
| Vue.use(Vuex); | |||||
| // export default new Vuex.Store({ | |||||
| // state, | |||||
| // actions, | |||||
| // bottomNav, | |||||
| // }); | |||||
| export default new Vuex.Store({ | |||||
| modules: {}, | |||||
| state, | |||||
| mutations, | |||||
| actions, | |||||
| getters, | |||||
| }); |
| import {} from "./mutation-types"; | |||||
| export default {}; |
| // 状态对象 | |||||
| export default {}; |
| /**axios封装 | |||||
| * 请求拦截、相应拦截、错误统一处理 | |||||
| */ | |||||
| import axios from "axios"; | |||||
| import { Message } from "element-ui"; | |||||
| // import QS from "qs"; | |||||
| // 环境的切换 | |||||
| axios.defaults.baseURL = process.env.VUE_APP_BASE_API; | |||||
| // 请求超时时间 | |||||
| axios.defaults.timeout = 300000; | |||||
| // post请求头 | |||||
| axios.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8"; | |||||
| // delete请求头 | |||||
| axios.defaults.headers.delete["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8"; | |||||
| let pending = []; //声明一个数组用于存储每个请求的取消函数和axios标识 | |||||
| let cancelRepeatUrl = [ | |||||
| "/mall/registry/registrationHall.action", | |||||
| "/rentalProduct/getAreaRentalProductListAll.action", | |||||
| ]; // 园区服务、物业租售 | |||||
| let cancelToken = axios.CancelToken; | |||||
| let removePending = config => { | |||||
| // console.log(config); | |||||
| for (let i in pending) { | |||||
| if (pending[i].url === axios.defaults.baseURL + config.url) { | |||||
| //在当前请求在数组中存在时执行取消函数 | |||||
| pending[i].f(); //执行取消操作 | |||||
| // pending.splice(i, 1); // 根据具体情况决定是否在这里就把pending去掉 | |||||
| // console.log("重复的:" + pending[i].url); | |||||
| } | |||||
| } | |||||
| }; | |||||
| // 请求拦截器 | |||||
| axios.interceptors.request.use( | |||||
| config => { | |||||
| // 每次发送请求之前判断是否存在token,如果存在,则统一在http请求的header都加上token,不用每次请求都手动添加了 | |||||
| // 即使本地存在token,也有可能token是过期的,所以在响应拦截器中要对返回状态进行判断 | |||||
| // const token = store.state.token; | |||||
| // token && (config.headers.Authorization = token); | |||||
| // return config; | |||||
| removePending(config); //在一个axios发送前执行一下判定操作,在removePending中执行取消操作 | |||||
| // console.log(config.url); | |||||
| config.cancelToken = new cancelToken(function executor(c) { | |||||
| //本次axios请求的配置添加cancelToken | |||||
| if (cancelRepeatUrl.indexOf(config.url) > -1) { | |||||
| pending.push({ | |||||
| // url: config.url, | |||||
| url: axios.defaults.baseURL + config.url, | |||||
| f: c, | |||||
| }); | |||||
| // console.log(axios.defaults.baseURL + config.url); | |||||
| //将本次的url添加到pending中,因此对于某个url第一次发起的请求不会被取消,因为还没有配置取消函数 | |||||
| } | |||||
| }); | |||||
| return Promise.resolve(config); | |||||
| }, | |||||
| error => { | |||||
| return Promise.error(error); | |||||
| } | |||||
| ); | |||||
| // 响应拦截器 | |||||
| axios.interceptors.response.use( | |||||
| response => { | |||||
| if (response.status === 200) { | |||||
| // removePending(response.config); //在一个axios响应后再执行一下取消操作,把已经完成的请求从pending中移除 | |||||
| return Promise.resolve(response); | |||||
| } else { | |||||
| return Promise.reject(response); | |||||
| } | |||||
| }, | |||||
| // 服务器状态码不是200的情况 | |||||
| error => { | |||||
| if (error.response.status) { | |||||
| return Promise.reject(error.response); | |||||
| } | |||||
| } | |||||
| ); | |||||
| /** | |||||
| * get方法,对应get请求 | |||||
| * @param {String} url [请求的url地址] | |||||
| * @param {Object} params [请求时携带的参数] | |||||
| */ | |||||
| export function get(url, params) { | |||||
| return new Promise((resolve, reject) => { | |||||
| axios | |||||
| .get(url, { | |||||
| params: params, | |||||
| }) | |||||
| .then(res => { | |||||
| if (res.data.status === 1) { | |||||
| Message.error("意外错误!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 101) { | |||||
| Message.error("非法请求!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 103) { | |||||
| Message.error("权限不足!"); | |||||
| if (location.pathname.indexOf("independent-product") > -1) { | |||||
| location.href = "/page/managerIndex.action"; | |||||
| } | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 110) { | |||||
| Message.error("CRM系统异常!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 113) { | |||||
| Message.error("请求过于频繁!"); | |||||
| return; | |||||
| } | |||||
| resolve(res); | |||||
| }) | |||||
| .catch(err => { | |||||
| reject(err); | |||||
| }); | |||||
| }); | |||||
| } | |||||
| /** | |||||
| * post方法,对应post请求 | |||||
| * @param {String} url [请求的url地址] | |||||
| * @param {Object} params [请求时携带的参数] | |||||
| */ | |||||
| export function post(url, params) { | |||||
| return new Promise((resolve, reject) => { | |||||
| axios | |||||
| .post(url, params) | |||||
| .then(res => { | |||||
| if (res.data.status === 1) { | |||||
| Message.error("意外错误!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 101) { | |||||
| Message.error("非法请求!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 103) { | |||||
| Message.error("权限不足!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 110) { | |||||
| Message.error("CRM系统异常!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 113) { | |||||
| Message.error("请求过于频繁!"); | |||||
| return; | |||||
| } | |||||
| resolve(res); | |||||
| }) | |||||
| .catch(err => { | |||||
| reject(err); | |||||
| }); | |||||
| }); | |||||
| } | |||||
| /** | |||||
| * put方法,对应put请求 | |||||
| * @param {String} url [请求的url地址] | |||||
| * @param {Object} params [请求时携带的参数] | |||||
| */ | |||||
| export function put(url, params) { | |||||
| return new Promise((resolve, reject) => { | |||||
| axios | |||||
| .put(url, params) | |||||
| .then(res => { | |||||
| if (res.data.status === 1) { | |||||
| Message.error("意外错误!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 101) { | |||||
| Message.error("非法请求!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 103) { | |||||
| Message.error("权限不足!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 110) { | |||||
| Message.error("CRM系统异常!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 113) { | |||||
| Message.error("请求过于频繁!"); | |||||
| return; | |||||
| } | |||||
| resolve(res); | |||||
| }) | |||||
| .catch(err => { | |||||
| reject(err); | |||||
| }); | |||||
| }); | |||||
| } | |||||
| /** | |||||
| * delete方法,对应delete请求,delete是保留字,使用del代替 | |||||
| * @param {String} url [请求的url地址] | |||||
| * @param {Object} params [请求时携带的参数] | |||||
| */ | |||||
| export function del(url, params) { | |||||
| return new Promise((resolve, reject) => { | |||||
| axios | |||||
| .delete(url, { | |||||
| params: params, | |||||
| }) | |||||
| .then(res => { | |||||
| if (res.data.status === 1) { | |||||
| Message.error("意外错误!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 101) { | |||||
| Message.error("非法请求!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 103) { | |||||
| Message.error("权限不足!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 110) { | |||||
| Message.error("CRM系统异常!"); | |||||
| return; | |||||
| } | |||||
| if (res.data.status === 113) { | |||||
| Message.error("请求过于频繁!"); | |||||
| return; | |||||
| } | |||||
| resolve(res); | |||||
| }) | |||||
| .catch(err => { | |||||
| reject(err); | |||||
| }); | |||||
| }); | |||||
| } |
| const path = require("path"); | |||||
| const resolve = dir => path.join(__dirname, dir); | |||||
| const IS_PROD = ["production", "prod"].includes(process.env.NODE_ENV); | |||||
| const CompressionWebpackPlugin = require("compression-webpack-plugin"); | |||||
| const productionGzipExtensions = /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i; | |||||
| module.exports = { | |||||
| publicPath: "/", // 默认'/',部署应用包时的基本 URL | |||||
| outputDir: "dist", // 'dist', 生产环境构建文件的目录 | |||||
| assetsDir: "pc", // 相对于outputDir的静态资源(js、css、img、fonts)目录 | |||||
| lintOnSave: false, | |||||
| indexPath: "pc.html", | |||||
| runtimeCompiler: true, // 是否使用包含运行时编译器的 Vue 构建版本 | |||||
| productionSourceMap: false, // 生产环境的 source map | |||||
| devServer: { | |||||
| open: true, | |||||
| index: "index.html", //默认启动serve 打开index页面 | |||||
| port: 8088, | |||||
| https: false, | |||||
| hotOnly: false, | |||||
| disableHostCheck: true, | |||||
| proxy: { | |||||
| "/domain": { | |||||
| // target: "http://192.168.18.138:80", | |||||
| target: "http://localhost:80", | |||||
| changeOrigin: true, | |||||
| pathRewrite: { | |||||
| "^/domain": "", | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| }, | |||||
| chainWebpack: config => { | |||||
| // 修复热更新 | |||||
| config.resolve.symlinks(true); | |||||
| // 添加别名 | |||||
| config.resolve.alias | |||||
| .set("@", resolve("./src")) | |||||
| .set("@assets", resolve("./src/assets")) | |||||
| .set("@api", resolve("./src/api")) | |||||
| .set("@utils", resolve("./src/utils")) | |||||
| .set("@components", resolve("./src/components")) | |||||
| .set("@views", resolve("./src/views")); | |||||
| }, | |||||
| configureWebpack: config => { | |||||
| config.optimization = { | |||||
| runtimeChunk: true, | |||||
| }; | |||||
| const plugins = []; | |||||
| if (IS_PROD) { | |||||
| plugins.push( | |||||
| // 开启gzip | |||||
| new CompressionWebpackPlugin({ | |||||
| filename: "[path].gz[query]", | |||||
| algorithm: "gzip", | |||||
| test: productionGzipExtensions, | |||||
| threshold: 10240, | |||||
| minRatio: 0.8, | |||||
| }) | |||||
| ); | |||||
| } | |||||
| config.plugins = [...config.plugins, ...plugins]; | |||||
| }, | |||||
| }; |