| | |
| | | import { Message, Notification } from 'element-ui' |
| | | import store from '@/store' |
| | | import { getCookie, removeCookie } from '@/utils/auth' |
| | | import Vue from 'vue' |
| | | |
| | | const service = axios.create({ |
| | | baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url |
| | |
| | | // do something before request is sent |
| | | config.headers['Token'] = localStorage.getItem('token') |
| | | |
| | | config.headers['ruleCode'] = getCookie('ruleCode') // 编码规则 |
| | | config.headers['Menucode'] = getCookie('ruleCode') // 编码规则 |
| | | |
| | | config.headers['Datacode'] = getCookie('datacode') // 数据权限 |
| | | return config |
| | | }, |
| | | error => { |
| | |
| | | localStorage.removeItem('torg') |
| | | localStorage.removeItem('token') |
| | | sessionStorage.removeItem('tabViews') |
| | | // setTimeout(() => { |
| | | // window.location.reload() |
| | | // }, 1000) |
| | | |
| | | setTimeout(() => { |
| | | window.location.reload() |
| | | }, 1000) |
| | | } |
| | | // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired; |
| | | // if (res.code === 50008 || res.code === 50012 || res.code === 50014) { |
| | |
| | | type: 'error', |
| | | duration: 5 * 1000 |
| | | }) |
| | | store.state.app.buttonIsDisabled = false |
| | | return Promise.reject(error) |
| | | } |
| | | ) |