From 77b1ca8f0d4b5d457b4cf4f768e38d584ae1713c Mon Sep 17 00:00:00 2001 From: zer0Black <694429613@qq.com> Date: Tue, 28 Feb 2023 22:43:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=89=8D=E7=AB=AF=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=E7=AC=A6=E5=90=88ESLint=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 5 + .eslintrc.js | 17 + babel.config.js | 6 +- package.json | 10 + src/App.vue | 114 +- src/api/index.js | 42 +- src/api/modules/login.js | 78 +- src/api/modules/menu.js | 81 +- src/api/modules/report.js | 254 ++-- src/api/modules/role.js | 81 +- src/api/modules/user.js | 64 +- src/assets/js/jsencrypt.min.js | 2 +- src/components/Demo.vue | 356 ++--- src/components/ECharts.vue | 550 ++++---- src/components/Header.vue | 112 +- src/components/Menu.vue | 91 +- src/components/MenuItem.vue | 4 +- src/components/QueryCascaterAZ.vue | 291 ++-- src/directives/index.js | 22 +- .../modules/vxe_table_min_height.js | 14 +- src/filters/index.js | 22 +- src/filters/modules/ex.js | 14 +- src/main.js | 62 +- src/router/index.js | 116 +- src/router/modules/default.js | 101 +- src/router/modules/report.js | 74 +- src/router/modules/system.js | 126 +- src/store/index.js | 64 +- src/utils/config.js | 2 +- src/utils/date.js | 54 +- src/utils/downloadFile.js | 20 +- src/utils/fileType.js | 22 +- src/utils/http.js | 20 +- src/utils/lineHeight.js | 14 +- src/utils/request.js | 175 ++- src/utils/waterMark.js | 10 +- src/views/Layout.vue | 212 ++- src/views/Login.vue | 167 +-- src/views/Register.vue | 2 +- src/views/Report/ReportDetail.vue | 80 +- src/views/Report/ReportList.vue | 340 ++--- src/views/Report/ReportManager.vue | 1185 ++++++++--------- src/views/System/401Page.vue | 14 +- src/views/System/MenuManager.vue | 302 +++-- src/views/System/Role.vue | 368 ++--- src/views/System/User.vue | 463 ++++--- src/views/System/urlIndex.vue | 57 +- vue.config.js | 98 +- 48 files changed, 3199 insertions(+), 3179 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintrc.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7053c49 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*.{js,jsx,ts,tsx,vue}] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..715fb3a --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,17 @@ +module.exports = { + root: true, + env: { + node: true + }, + extends: [ + 'plugin:vue/essential', + '@vue/standard' + ], + parserOptions: { + parser: '@babel/eslint-parser' + }, + rules: { + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' + } +} diff --git a/babel.config.js b/babel.config.js index d470020..e955840 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,5 +1,5 @@ module.exports = { - presets: [ - '@vue/cli-plugin-babel/preset' - ], + presets: [ + '@vue/cli-plugin-babel/preset' + ] } diff --git a/package.json b/package.json index 8064407..9fe9a00 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", + "lint": "vue-cli-service lint", "vueui": "vue ui" }, "dependencies": { @@ -33,10 +34,19 @@ "xe-utils": "^3.4.0" }, "devDependencies": { + "@babel/core": "^7.12.16", + "@babel/eslint-parser": "^7.12.16", "@vue/cli-plugin-babel": "~4.5.0", + "@vue/cli-plugin-eslint": "~5.0.0", "@vue/cli-plugin-router": "~4.5.0", "@vue/cli-plugin-vuex": "~4.5.0", "@vue/cli-service": "~4.5.0", + "@vue/eslint-config-standard": "^6.1.0", + "eslint": "^7.32.0", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^5.1.0", + "eslint-plugin-vue": "^8.0.3", "sass": "^1.43.4", "sass-loader": "^8.0.2", "vue-template-compiler": "^2.6.11" diff --git a/src/App.vue b/src/App.vue index a8d74d3..970ffe2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,65 +5,65 @@ \ No newline at end of file + diff --git a/src/directives/index.js b/src/directives/index.js index 92366bd..6d6defd 100644 --- a/src/directives/index.js +++ b/src/directives/index.js @@ -1,17 +1,17 @@ -import Vue from "vue"; +import Vue from 'vue' /** * 获取API * @type {{install(): *|{}}} Vue.use默认执行的方法 */ export default { - install() { - const requireComponents = require.context('./modules', false, /\.js/); - requireComponents.keys().forEach(file => { - const directives = requireComponents(file).default; - for (const directive in directives) { - Vue.directive(directive, directives[directive]); - } - }); - } -}; + install () { + const requireComponents = require.context('./modules', false, /\.js/) + requireComponents.keys().forEach(file => { + const directives = requireComponents(file).default + for (const directive in directives) { + Vue.directive(directive, directives[directive]) + } + }) + } +} diff --git a/src/directives/modules/vxe_table_min_height.js b/src/directives/modules/vxe_table_min_height.js index c4e92ed..e29323c 100644 --- a/src/directives/modules/vxe_table_min_height.js +++ b/src/directives/modules/vxe_table_min_height.js @@ -1,11 +1,11 @@ -import Vue from "vue"; +import Vue from 'vue' export default { - tableMinHeight: { - // 指令的定义 - inserted(el, binding, vnode) { - let dom = el.getElementsByClassName('vxe-table--body-wrapper body--wrapper').item(0); - dom.style.setProperty('min-height', binding.value, 'important') - }, + tableMinHeight: { + // 指令的定义 + inserted (el, binding, vnode) { + const dom = el.getElementsByClassName('vxe-table--body-wrapper body--wrapper').item(0) + dom.style.setProperty('min-height', binding.value, 'important') } + } } diff --git a/src/filters/index.js b/src/filters/index.js index 3a5819e..7f1131d 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -1,17 +1,17 @@ -import Vue from "vue"; +import Vue from 'vue' /** * 获取API * @type {{install(): *|{}}} Vue.use默认执行的方法 */ export default { - install() { - const requireComponents = require.context('./modules', false, /\.js/); - requireComponents.keys().forEach(file => { - const filters = requireComponents(file).default; - for (const filter in filters) { - Vue.filter(filter, filters[filter]); - } - }); - } -}; + install () { + const requireComponents = require.context('./modules', false, /\.js/) + requireComponents.keys().forEach(file => { + const filters = requireComponents(file).default + for (const filter in filters) { + Vue.filter(filter, filters[filter]) + } + }) + } +} diff --git a/src/filters/modules/ex.js b/src/filters/modules/ex.js index 5b123ad..2bd769d 100644 --- a/src/filters/modules/ex.js +++ b/src/filters/modules/ex.js @@ -1,9 +1,9 @@ export default { - formatDate: function (value) { - let date = new Date(value); - let y = date.getFullYear(); - let m = date.getMonth() + 1; - let d = date.getDate(); - return `${y}/${m}/${d}`; - } + formatDate: function (value) { + const date = new Date(value) + const y = date.getFullYear() + const m = date.getMonth() + 1 + const d = date.getDate() + return `${y}/${m}/${d}` + } } diff --git a/src/main.js b/src/main.js index ee5b03a..e116a79 100644 --- a/src/main.js +++ b/src/main.js @@ -3,17 +3,17 @@ import App from './App.vue' import router from './router' import store from './store' -import config from "@/utils/config"; +import config from '@/utils/config' // VXETable import 'xe-utils' import VXETable from 'vxe-table' import 'vxe-table/lib/style.css' // ElementUI -import ElementUI from 'element-ui'; +import ElementUI from 'element-ui' import './assets/css/element-variables.scss' // ECharts import 'echarts' -import ECharts from './components/ECharts'; +import ECharts from './components/ECharts' // Api import Api from './api' @@ -24,52 +24,52 @@ import Filter from './filters' // 自定义水印指令 import '@/utils/waterMark' // 加密函数 -import JSEncrypt from '../src/assets/js/jsencrypt.min.js'; - -VXETable.setup({ - table: { - resizable: true, - } -}) - -Vue.use(VXETable); +import JSEncrypt from '../src/assets/js/jsencrypt.min.js' // 富文本引用 import VueQuillEditor from 'vue-quill-editor' // require styles 引入样式 import 'quill/dist/quill.core.css' import 'quill/dist/quill.snow.css' import 'quill/dist/quill.bubble.css' + +VXETable.setup({ + table: { + resizable: true + } +}) + +Vue.use(VXETable) Vue.use(VueQuillEditor) -Vue.use(ElementUI, {size: 'mini', zIndex: 3000}); -Vue.component('v-chart', ECharts); -Vue.use(Api); -Vue.use(Directive); -Vue.use(Filter); +Vue.use(ElementUI, { size: 'mini', zIndex: 3000 }) +Vue.component('v-chart', ECharts) +Vue.use(Api) +Vue.use(Directive) +Vue.use(Filter) Vue.prototype.$JSEncrypt = (data) => { - if(data === ''){ - return ''; - } - let encryptor = new JSEncrypt(); - encryptor.setPublicKey(config.PUBLIC_KEY); - return encryptor.encrypt(data) || ''; + if (data === '') { + return '' + } + const encryptor = new JSEncrypt() + encryptor.setPublicKey(config.PUBLIC_KEY) + return encryptor.encrypt(data) || '' } VXETable.renderer.add('NotData', { - // 空内容模板 - renderEmpty (h, renderOpts) { - return [ + // 空内容模板 + renderEmpty (h, renderOpts) { + return [

暂无数据

- ] - } + ] + } }) Vue.config.productionTip = false new Vue({ - router, - store, - render: h => h(App) + router, + store, + render: h => h(App) }).$mount('#app') diff --git a/src/router/index.js b/src/router/index.js index d63f32b..97ea6d9 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -2,80 +2,80 @@ import Vue from 'vue' import VueRouter from 'vue-router' import store from '../store' import login from '../api/modules/login' -import {BASE_URL} from "../utils/http" +import { BASE_URL } from '../utils/http' Vue.use(VueRouter) -let routes = []; +let routes = [] -const requireComponents = require.context('./modules', false, /\.js/); -requireComponents.keys().forEach(file => routes = [...routes, ...requireComponents(file).default]); +const requireComponents = require.context('./modules', false, /\.js/) +requireComponents.keys().forEach(file => routes = [...routes, ...requireComponents(file).default]) const router = new VueRouter({ - mode: 'history', - base: process.env.BASE_URL, - routes, - scrollBehavior(to, from, position) { - return position; - }, + mode: 'history', + base: process.env.BASE_URL, + routes, + scrollBehavior (to, from, position) { + return position + } }) // 路由守卫 router.beforeEach((to, from, next) => { - /** + /** * 仅报告价格板块 * 报告板块 http://10.10.1.184:8080/#/report/list?id=XBFBR7UADZ * 价格板块 http://10.10.1.184:8080/#/overall/opricetrend?id=SBME88VTUD */ - // store.commit('saveUserInfo', {}); - // store.commit('saveMenuData', menuTree); - // var url = BASE_URL.BASE_LOCAL + '/login?loginType=1' + // store.commit('saveUserInfo', {}); + // store.commit('saveMenuData', menuTree); + // var url = BASE_URL.BASE_LOCAL + '/login?loginType=1' - // var loginUrl = BASE_URL.BASE_CHANGAN + "/login?service=" + url; - // var logoutUrl = BASE_URL.BASE_CHANGAN + "/logout?service=" + url - if (to.meta.crumb) { - var jumpStr = to.meta.crumb.join('/') - if(jumpStr){ - if (jumpStr == 'urlIndex' && to.path != '/system/401Page') { - login.pageLog(store.state.menuName).then(res => { - }).catch(_ => { - }) - }else{ - login.pageLog(jumpStr).then(res => { - }).catch(_ => { - }) - } - } + // var loginUrl = BASE_URL.BASE_CHANGAN + "/login?service=" + url; + // var logoutUrl = BASE_URL.BASE_CHANGAN + "/logout?service=" + url + if (to.meta.crumb) { + const jumpStr = to.meta.crumb.join('/') + if (jumpStr) { + if (jumpStr == 'urlIndex' && to.path != '/system/401Page') { + login.pageLog(store.state.menuName).then(res => { + }).catch(_ => { + }) + } else { + login.pageLog(jumpStr).then(res => { + }).catch(_ => { + }) + } } - // debugger - // if (to.query.loginType) { - // if (to.query.loginType == 1 && to.query.ticket) { - // var params = { - // service: url, - // ticket: to.query.ticket - // } - // login.loginByTicket(params).then(res => { - // if (res.respCode !== '0') { - // // this.verifyCode(); - // // return this.$message.error(res.data.message); - // } - // // this.$message.success('登录成功'); - // store.commit('saveUserInfo', res.data); - // next('/home'); - // }).catch(_ => { - // window.open(logoutUrl, '_self'); - // }) - // } else { - // window.open(loginUrl, '_self'); - // } - // } else if (to.path.toLowerCase() !== '/login') { - // if (!store.state.userInfo) { - // window.open(logoutUrl, '_self'); - // } - // next(); - // } else { - next(); - // } + } + // debugger + // if (to.query.loginType) { + // if (to.query.loginType == 1 && to.query.ticket) { + // var params = { + // service: url, + // ticket: to.query.ticket + // } + // login.loginByTicket(params).then(res => { + // if (res.respCode !== '0') { + // // this.verifyCode(); + // // return this.$message.error(res.data.message); + // } + // // this.$message.success('登录成功'); + // store.commit('saveUserInfo', res.data); + // next('/home'); + // }).catch(_ => { + // window.open(logoutUrl, '_self'); + // }) + // } else { + // window.open(loginUrl, '_self'); + // } + // } else if (to.path.toLowerCase() !== '/login') { + // if (!store.state.userInfo) { + // window.open(logoutUrl, '_self'); + // } + // next(); + // } else { + next() + // } }) export default router diff --git a/src/router/modules/default.js b/src/router/modules/default.js index 8366b87..10bdfa6 100644 --- a/src/router/modules/default.js +++ b/src/router/modules/default.js @@ -1,53 +1,54 @@ const routes = [ - { - path: '/system', - name: '', - component: () => import('../../views/Layout.vue'), - children: [ - { - path: 'urlIndex', - name: 'urlIndex', - component: () => import('../../views/System/urlIndex.vue'), - meta: { - crumb: ['urlIndex'], - } - }]}, - { - path: '/', - redirect: { - name: 'Login' - // path: '/report/list?id=XBFBR7UADZ' + { + path: '/system', + name: '', + component: () => import('../../views/Layout.vue'), + children: [ + { + path: 'urlIndex', + name: 'urlIndex', + component: () => import('../../views/System/urlIndex.vue'), + meta: { + crumb: ['urlIndex'] } - }, - // 登录 - { - path: '/login', - name: 'Login', - component: () => import('../../views/Login.vue') - }, - // // 注册 - // { - // path: '/register', - // name: 'Register', - // component: () => import('../../views/Register.vue') - // }, - // 首页 - // { - // path: '/home', - // name: 'Home', - // component: () => import('../../views/Home.vue') - // }, - { - path: '/layout', - name: 'LayoutBox', - component: () => import('../../views/Layout.vue') - }, - // // Demo - // { - // path: '/demo', - // name: 'Demo', - // component: () => import('../../components/Demo.vue') - // }, -]; + }] + }, + { + path: '/', + redirect: { + name: 'Login' + // path: '/report/list?id=XBFBR7UADZ' + } + }, + // 登录 + { + path: '/login', + name: 'Login', + component: () => import('../../views/Login.vue') + }, + // // 注册 + // { + // path: '/register', + // name: 'Register', + // component: () => import('../../views/Register.vue') + // }, + // 首页 + // { + // path: '/home', + // name: 'Home', + // component: () => import('../../views/Home.vue') + // }, + { + path: '/layout', + name: 'LayoutBox', + component: () => import('../../views/Layout.vue') + } + // // Demo + // { + // path: '/demo', + // name: 'Demo', + // component: () => import('../../components/Demo.vue') + // }, +] -export default routes; +export default routes diff --git a/src/router/modules/report.js b/src/router/modules/report.js index 110cce7..d6ba60e 100644 --- a/src/router/modules/report.js +++ b/src/router/modules/report.js @@ -1,39 +1,39 @@ const routes = [ - // 报告管理 - { - path: '/report', - name: 'Layout', - component: () => import('../../views/Layout.vue'), - children: [ - // 报告列表 - { - path: 'list', - name: 'ReportList', - component: () => import('../../views/Report/ReportList.vue'), - meta: { - crumb: ['报告列表'], - } - }, - // 报告详情 - { - path: 'detail', - name: 'ReportDetail', - component: () => import('../../views/Report/ReportDetail.vue'), - meta: { - crumb: ['报告详情'], - } - }, - // 报告管理 - { - path: '/report/manager', - name: 'ReportManager', - component: () => import('../../views/Report/ReportManager.vue'), - meta: { - crumb: ['报告管理'], - } - }, - ] - }, -]; + // 报告管理 + { + path: '/report', + name: 'Layout', + component: () => import('../../views/Layout.vue'), + children: [ + // 报告列表 + { + path: 'list', + name: 'ReportList', + component: () => import('../../views/Report/ReportList.vue'), + meta: { + crumb: ['报告列表'] + } + }, + // 报告详情 + { + path: 'detail', + name: 'ReportDetail', + component: () => import('../../views/Report/ReportDetail.vue'), + meta: { + crumb: ['报告详情'] + } + }, + // 报告管理 + { + path: '/report/manager', + name: 'ReportManager', + component: () => import('../../views/Report/ReportManager.vue'), + meta: { + crumb: ['报告管理'] + } + } + ] + } +] -export default routes; +export default routes diff --git a/src/router/modules/system.js b/src/router/modules/system.js index e32c670..bbce1ea 100644 --- a/src/router/modules/system.js +++ b/src/router/modules/system.js @@ -1,65 +1,65 @@ const routes = [ - // 系统管理 - { - path: '/system', - name: '', - component: () => import('../../views/Layout.vue'), - children: [ - // 菜单管理 - { - path: 'menu', - name: 'MenuManager', - component: () => import('../../views/System/MenuManager.vue'), - meta: { - crumb: ['菜单管理'], - } - }, - // 用户管理 - { - path: 'user', - name: 'User', - component: () => import('../../views/System/User.vue'), - meta: { - crumb: ['用户管理'], - } - }, - // 角色管理 - { - path: 'role', - name: 'Role', - component: () => import('../../views/System/Role.vue'), - meta: { - crumb: ['角色管理'], - } - }, - // // 角色管理 - // { - // path: 'mail', - // name: 'Mail', - // component: () => import('../../views/System/mail.vue'), - // meta: { - // crumb: ['邮件管理'], - // } - // }, - // // 角色管理 - // { - // path: 'notification', - // name: 'Notification', - // component: () => import('../../views/System/notification.vue'), - // meta: { - // crumb: ['通知管理'], - // } - // }, - { - path: '401Page', - name: '401Page', - component: () => import('../../views/System/401Page.vue'), - meta: { - crumb: ['暂无权限'], - } - }, - ] - }, -]; + // 系统管理 + { + path: '/system', + name: '', + component: () => import('../../views/Layout.vue'), + children: [ + // 菜单管理 + { + path: 'menu', + name: 'MenuManager', + component: () => import('../../views/System/MenuManager.vue'), + meta: { + crumb: ['菜单管理'] + } + }, + // 用户管理 + { + path: 'user', + name: 'User', + component: () => import('../../views/System/User.vue'), + meta: { + crumb: ['用户管理'] + } + }, + // 角色管理 + { + path: 'role', + name: 'Role', + component: () => import('../../views/System/Role.vue'), + meta: { + crumb: ['角色管理'] + } + }, + // // 角色管理 + // { + // path: 'mail', + // name: 'Mail', + // component: () => import('../../views/System/mail.vue'), + // meta: { + // crumb: ['邮件管理'], + // } + // }, + // // 角色管理 + // { + // path: 'notification', + // name: 'Notification', + // component: () => import('../../views/System/notification.vue'), + // meta: { + // crumb: ['通知管理'], + // } + // }, + { + path: '401Page', + name: '401Page', + component: () => import('../../views/System/401Page.vue'), + meta: { + crumb: ['暂无权限'] + } + } + ] + } +] -export default routes; +export default routes diff --git a/src/store/index.js b/src/store/index.js index fecd6c3..8074c0e 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -5,39 +5,39 @@ import createPersistedState from 'vuex-persistedstate' Vue.use(Vuex) export default new Vuex.Store({ - state: { - userInfo: null, - isLoading: false, - rememberData: null, - menuData: [], - pathUrl: '', - menuName: '', + state: { + userInfo: null, + isLoading: false, + rememberData: null, + menuData: [], + pathUrl: '', + menuName: '' + }, + getters: { + menuData: (state) => state.menuData, + menuName: (state) => state.menuName + }, + mutations: { + saveUserInfo (state, data) { + state.userInfo = data }, - getters: { - menuData: (state) => state.menuData, - menuName: (state) => state.menuName, + saveIsLoading (state, data) { + state.isLoading = data }, - mutations: { - saveUserInfo(state, data) { - state.userInfo = data; - }, - saveIsLoading(state, data){ - state.isLoading = data; - }, - saveRememberData(state, data){ - state.rememberData = data; - }, - saveMenuData(state, data){ - state.menuData = data; - }, - savePathUrl(state, data){ - state.pathUrl = data; - }, - saveMenuName(state, data){ - state.menuName = data; - }, + saveRememberData (state, data) { + state.rememberData = data }, - actions: {}, - modules: {}, - plugins: [createPersistedState()] + saveMenuData (state, data) { + state.menuData = data + }, + savePathUrl (state, data) { + state.pathUrl = data + }, + saveMenuName (state, data) { + state.menuName = data + } + }, + actions: {}, + modules: {}, + plugins: [createPersistedState()] }) diff --git a/src/utils/config.js b/src/utils/config.js index b163a48..52f923e 100644 --- a/src/utils/config.js +++ b/src/utils/config.js @@ -1,3 +1,3 @@ export default { - PUBLIC_KEY: `MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDKwvimHNGEiyV5L73llAeTv8O/3c9KLZLjNDpzNVOvzowk1MJySdSh6BiZPFXGLJ49Rrp/0U1L68ZCvC2Zv07YYTrr7Bd8o8lKB9HlUqcJo/seIHrLCLl2ePuLn+NYtIM4xxbbvAOdy5Ep/QbK4aWz8G7vsx8pctijLksYKNBQyQIDAQAB`, + PUBLIC_KEY: 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDKwvimHNGEiyV5L73llAeTv8O/3c9KLZLjNDpzNVOvzowk1MJySdSh6BiZPFXGLJ49Rrp/0U1L68ZCvC2Zv07YYTrr7Bd8o8lKB9HlUqcJo/seIHrLCLl2ePuLn+NYtIM4xxbbvAOdy5Ep/QbK4aWz8G7vsx8pctijLksYKNBQyQIDAQAB' } diff --git a/src/utils/date.js b/src/utils/date.js index 1cb65a0..463ce10 100644 --- a/src/utils/date.js +++ b/src/utils/date.js @@ -4,31 +4,31 @@ * @param fmt * @returns {*} */ -export function formatDate(value, fmt) { - let regPos = /^\d+(\.\d+)?$/ - if (regPos.test(value)) { - //如果是数字 - let getDate = new Date(value) - let o = { - 'M+': getDate.getMonth() + 1, - 'd+': getDate.getDate(), - 'h+': getDate.getHours(), - 'm+': getDate.getMinutes(), - 's+': getDate.getSeconds(), - 'q+': Math.floor((getDate.getMonth() + 3) / 3), - 'S': getDate.getMilliseconds() - } - if (/(y+)/.test(fmt)) { - fmt = fmt.replace(RegExp.$1, (getDate.getFullYear() + '').substr(4 - RegExp.$1.length)) - } - for (let k in o) { - if (new RegExp('(' + k + ')').test(fmt)) { - fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) - } - } - return fmt - } else { - value = value.trim() - return value.substr(0, fmt.length) - } +export function formatDate (value, fmt) { + const regPos = /^\d+(\.\d+)?$/ + if (regPos.test(value)) { + // 如果是数字 + const getDate = new Date(value) + const o = { + 'M+': getDate.getMonth() + 1, + 'd+': getDate.getDate(), + 'h+': getDate.getHours(), + 'm+': getDate.getMinutes(), + 's+': getDate.getSeconds(), + 'q+': Math.floor((getDate.getMonth() + 3) / 3), + S: getDate.getMilliseconds() + } + if (/(y+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, (getDate.getFullYear() + '').substr(4 - RegExp.$1.length)) + } + for (const k in o) { + if (new RegExp('(' + k + ')').test(fmt)) { + fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) + } + } + return fmt + } else { + value = value.trim() + return value.substr(0, fmt.length) + } } diff --git a/src/utils/downloadFile.js b/src/utils/downloadFile.js index 3a14422..5a8854d 100644 --- a/src/utils/downloadFile.js +++ b/src/utils/downloadFile.js @@ -1,13 +1,13 @@ -import {fileType} from "./fileType"; +import { fileType } from './fileType' export const downloadFile = (res) => { - let file_name = decodeURI(res.headers["content-disposition"]).split('=').pop(); - let file_type = file_name.split('.').pop(); - let blobData = new Blob([res.data], {type: fileType[file_type]}); - let downloadUrl = window.URL.createObjectURL(blobData); - let anchor = document.createElement("a"); - anchor.href = downloadUrl; - anchor.download = file_name; - anchor.click(); - window.URL.revokeObjectURL(blobData); + const file_name = decodeURI(res.headers['content-disposition']).split('=').pop() + const file_type = file_name.split('.').pop() + const blobData = new Blob([res.data], { type: fileType[file_type] }) + const downloadUrl = window.URL.createObjectURL(blobData) + const anchor = document.createElement('a') + anchor.href = downloadUrl + anchor.download = file_name + anchor.click() + window.URL.revokeObjectURL(blobData) } diff --git a/src/utils/fileType.js b/src/utils/fileType.js index 835272d..cee11ed 100644 --- a/src/utils/fileType.js +++ b/src/utils/fileType.js @@ -1,13 +1,13 @@ export const fileType = { - pdf: 'application/pdf', - xls: 'application/vnd.ms-excel', - xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - doc: 'application/msword', - docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - ppt: 'application/vnd.ms-powerpoint', - pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - png: 'image/png', - jpg: 'image/jpeg', - rar: 'application/x-rar', - zip: 'application/zip', + pdf: 'application/pdf', + xls: 'application/vnd.ms-excel', + xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + doc: 'application/msword', + docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + ppt: 'application/vnd.ms-powerpoint', + pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + png: 'image/png', + jpg: 'image/jpeg', + rar: 'application/x-rar', + zip: 'application/zip' } diff --git a/src/utils/http.js b/src/utils/http.js index 650fc56..8dac867 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -1,15 +1,15 @@ export const BASE_URL = { - // LOGIN_URL : "http://192.168.144.29:9090/cas/login?service=http://192.168.144.22:9966/login?loginType=1", - // LOGOUT_URL : "http://192.168.144.29:9090/cas/logout?service=http://192.168.144.22:9966/login?loginType=1", + // LOGIN_URL : "http://192.168.144.29:9090/cas/login?service=http://192.168.144.22:9966/login?loginType=1", + // LOGOUT_URL : "http://192.168.144.29:9090/cas/logout?service=http://192.168.144.22:9966/login?loginType=1", - //内部测试 - // BASE_CHANGAN:'http://192.168.144.29:9090/cas', - BASE_LOCAL:'http://127.0.0.1:8080', - BASE_LOCAL_IMG:'http://127.0.0.1:8080', + // 内部测试 + // BASE_CHANGAN:'http://192.168.144.29:9090/cas', + BASE_LOCAL: 'http://127.0.0.1:8080', + BASE_LOCAL_IMG: 'http://127.0.0.1:8080' - // //企业测试 - // BASE_CHANGAN:'https://caddmuat.changan.com.cn/cas', - // BASE_LOCAL:'https://caddmuat.changan.com.cn/mi', - // BASE_LOCAL_IMG:'https://caddmuat.changan.com.cn', + // //企业测试 + // BASE_CHANGAN:'https://caddmuat.changan.com.cn/cas', + // BASE_LOCAL:'https://caddmuat.changan.com.cn/mi', + // BASE_LOCAL_IMG:'https://caddmuat.changan.com.cn', } diff --git a/src/utils/lineHeight.js b/src/utils/lineHeight.js index f1bc841..b204159 100644 --- a/src/utils/lineHeight.js +++ b/src/utils/lineHeight.js @@ -1,13 +1,13 @@ -import Quill from "quill"; +import Quill from 'quill' -let Parchment = Quill.import("parchment"); +const Parchment = Quill.import('parchment') class lineHeightAttributor extends Parchment.Attributor.Style { } -const lineHeightStyle = new lineHeightAttributor("lineHeight", "line-height", { - scope: Parchment.Scope.INLINE, - whitelist: ["initial", "1", "1.5", "1.75", "2", "3", "4"] -}); +const lineHeightStyle = new lineHeightAttributor('lineHeight', 'line-height', { + scope: Parchment.Scope.INLINE, + whitelist: ['initial', '1', '1.5', '1.75', '2', '3', '4'] +}) -export {lineHeightStyle}; \ No newline at end of file +export { lineHeightStyle } diff --git a/src/utils/request.js b/src/utils/request.js index 628ae35..caf522c 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,104 +1,103 @@ -import axios from 'axios'; -import {Message, Loading} from 'element-ui'; -import store from '../store'; -import router from "../router"; -import {BASE_URL} from "../utils/http"; +import axios from 'axios' +import { Message, Loading } from 'element-ui' +import store from '../store' +import router from '../router' +import { BASE_URL } from '../utils/http' // 记录请求个数、加载 -let count = 0, loading = null; +let count = 0; let loading = null // axios实例化 const instance = axios.create({ - baseURL: '/library', - // timeout: 60000, - headers: { - 'Cache-Control': 'no-cache', - 'Pragma': 'no-cache' - } -}); + baseURL: '/library', + // timeout: 60000, + headers: { + 'Cache-Control': 'no-cache', + Pragma: 'no-cache' + } +}) // 添加请求拦截器 instance.interceptors.request.use(function (config) { - // 在发送请求之前做些什么 - loading = Loading.service(null); - count++; - store.commit('saveIsLoading', true); - return config; + // 在发送请求之前做些什么 + loading = Loading.service(null) + count++ + store.commit('saveIsLoading', true) + return config }, function (error) { - // 对请求错误做些什么 - count--; - if (count < 1) { - loading.close(); - store.commit('saveIsLoading', false); - } - Message.error(error); - return Promise.reject(error); -}); + // 对请求错误做些什么 + count-- + if (count < 1) { + loading.close() + store.commit('saveIsLoading', false) + } + Message.error(error) + return Promise.reject(error) +}) // 添加响应拦截器 instance.interceptors.response.use(function (response) { - // 对响应数据做点什么 - count--; - if (count < 1) { - loading.close(); - store.commit('saveIsLoading', false); - } + // 对响应数据做点什么 + count-- + if (count < 1) { + loading.close() + store.commit('saveIsLoading', false) + } - // 登录超时 - if (response.data.respCode === '401') { - store.commit('saveUserInfo', null); - router.push('/login'); - Message.error('登录超时过期'); - // var url = 'http://192.168.144.22:9966/login?loginType=1' - // // var url = 'http://10.64.23.30:7766/home' - // - // return window.open('http://192.168.144.29:9090/cas/login?service='+url, '_self'); - // return window.open('https://caddmuat.changan.com.cn/cas/login?service='+url, '_self'); - // window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self'); - } + // 登录超时 + if (response.data.respCode === '401') { + store.commit('saveUserInfo', null) + router.push('/login') + Message.error('登录超时过期') + // var url = 'http://192.168.144.22:9966/login?loginType=1' + // // var url = 'http://10.64.23.30:7766/home' + // + // return window.open('http://192.168.144.29:9090/cas/login?service='+url, '_self'); + // return window.open('https://caddmuat.changan.com.cn/cas/login?service='+url, '_self'); + // window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self'); + } - // 请求成功 - if (response.status === 200) { - if (response.data.respCode === "0") { - return response.data; - } else if (response.data.respCode === "-1") { - Message.error(response.data.message); - return Promise.reject(response); - } else { - return response; - } - } else { // 请求失败 - Message.error(response.data.message); - return Promise.reject(response); - } - -}, function (error) { - // 对响应错误做点什么 - count--; - if (count < 1) { - loading.close(); - store.commit('saveIsLoading', false); - } - - // 登录过期 - if (error.response.status === 401) { - store.commit('saveUserInfo', null); - router.push('/login'); - Message.error('登录超时过期'); - // window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self'); - // var url = 'http://192.168.144.22:9966/login?loginType=1' - // // var url = 'http://10.64.23.30:7766/home' - // - // return window.open('http://192.168.144.29:9090/cas/login?service='+url, '_self'); - // // return window.open('https://caddmuat.changan.com.cn/cas/login?service='+url, '_self'); - } - - // 判断超时 - if (error.code === "ECONNABORTED" && error.message.indexOf('timeout') !== -1 && !error.config._retry) { - Message.error(error.message); + // 请求成功 + if (response.status === 200) { + if (response.data.respCode === '0') { + return response.data + } else if (response.data.respCode === '-1') { + Message.error(response.data.message) + return Promise.reject(response) } else { - Message.error(error.message); + return response } - return Promise.reject(error); -}); + } else { // 请求失败 + Message.error(response.data.message) + return Promise.reject(response) + } +}, function (error) { + // 对响应错误做点什么 + count-- + if (count < 1) { + loading.close() + store.commit('saveIsLoading', false) + } -export {instance, loading}; + // 登录过期 + if (error.response.status === 401) { + store.commit('saveUserInfo', null) + router.push('/login') + Message.error('登录超时过期') + // window.open(BASE_URL.BASE_CHANGAN + "/logout?service=" + BASE_URL.BASE_LOCAL + "/login?loginType=1", '_self'); + // var url = 'http://192.168.144.22:9966/login?loginType=1' + // // var url = 'http://10.64.23.30:7766/home' + // + // return window.open('http://192.168.144.29:9090/cas/login?service='+url, '_self'); + // // return window.open('https://caddmuat.changan.com.cn/cas/login?service='+url, '_self'); + } + + // 判断超时 + if (error.code === 'ECONNABORTED' && error.message.indexOf('timeout') !== -1 && !error.config._retry) { + Message.error(error.message) + } else { + Message.error(error.message) + } + return Promise.reject(error) +}) + +export { instance, loading } diff --git a/src/utils/waterMark.js b/src/utils/waterMark.js index a80a55c..6cbe521 100644 --- a/src/utils/waterMark.js +++ b/src/utils/waterMark.js @@ -7,20 +7,20 @@ import Vue from 'vue' * v-watermark="{text: '水印名称', textColor: 'rgba(100, 100, 100, 0.6)'}" */ Vue.directive('watermark', { - bind: function(el, binding){ + bind: function (el, binding) { // 水印文字,父元素,画布宽度,画布高度,字体,文字颜色,画布横坐标,是否铺满全页 - function addWaterMarker(str, parentNode, width, height, font, textColor, fillTextX = '10'){ + function addWaterMarker (str, parentNode, width, height, font, textColor, fillTextX = '10') { // 检查父元素是否包含子元素 const elementContains = (parent, child) => parent !== child && parent.contains(child) const flag = elementContains(parentNode, document.querySelector('canvas')) // 防止重复创建 if (!flag) { - let can = document.createElement('canvas') + const can = document.createElement('canvas') parentNode.appendChild(can) can.width = width || 300 can.height = height || 140 can.style.display = 'none' - let cans = can.getContext('2d') + const cans = can.getContext('2d') cans.rotate(-20 * Math.PI / 180) cans.font = font || '13px Microsoft Yahei' cans.fillStyle = textColor || 'rgba(100, 100, 100, 0.2)' @@ -31,7 +31,7 @@ Vue.directive('watermark', { // parentNode.style.backgroundImage = "url(" + can.toDataURL("image/png") + ")"; // 创建div 定位覆盖(某个元素,如图片添加水印建议使用此方法) - let div = document.createElement('div') + const div = document.createElement('div') div.id = str div.className = 'waterMark' div.style.pointerEvents = 'none' diff --git a/src/views/Layout.vue b/src/views/Layout.vue index e9cc69c..deffd6c 100644 --- a/src/views/Layout.vue +++ b/src/views/Layout.vue @@ -20,115 +20,113 @@