| | |
| | | //npm i moment --save |
| | | import moment from 'moment'; |
| | | import echarts from 'echarts' |
| | | import VueCookies from 'vue-cookies' |
| | | |
| | | |
| | | Vue.prototype.$echarts = echarts |
| | | Vue.use(ElementUI); |
| | | Vue.prototype.$moment = moment;//赋值使用 |
| | | |
| | | Vue.use(VueCookies); |
| | | |
| | | Vue.config.productionTip = false; |
| | | Vue.prototype.$axios = Axios; |
| | | Axios.defaults.baseURL = '/api'; |
| | |
| | | |
| | | |
| | | Axios.interceptors.request.use(function (config) { |
| | | let userId_ = localStorage.getItem('userId'); |
| | | // let userId_ = localStorage.getItem('userId'); |
| | | if(config.url == "/api/user/login") { |
| | | |
| | | } |
| | | else { |
| | | //let userId_ = Vue.VueCookies.get('userId');//localStorage.getItem('userId'); |
| | | let userId_ = Vue.$cookies.get('userId');//localStorage.getItem('userId'); |
| | | if (!userId_ && config.url != "/api/user/login") { |
| | | router.replace('/login'); |
| | | } |
| | | router.replace('/login'); |
| | | } |
| | | config.headers.common['userId'] = userId_; |
| | | } |
| | | return config; |
| | | }, function (error) { |
| | | // console.info("error: "); |