暂无数据
- ] - } + ] + } }) 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 @@