| | |
| | | import Vue from 'vue'; |
| | | import App from './App.vue'; |
| | | |
| | | Vue.config.productionTip = false; |
| | | import ElementUI from 'element-ui'; |
| | | import 'element-ui/lib/theme-chalk/index.css'; |
| | |
| | | import Fingerprint2 from 'fingerprintjs2'; |
| | | import VueClipboards from 'vue-clipboards'; |
| | | import Contextmenu from "vue-contextmenujs" |
| | | import userService from "./components/service/UserService" |
| | | |
| | | |
| | | // 生成唯一ID |
| | |
| | | axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : (window.baseUrl?window.baseUrl:""); |
| | | axios.defaults.withCredentials = true; |
| | | // api 返回401自动回登陆页面 |
| | | axios.interceptors.response.use(function (response) { |
| | | axios.interceptors.response.use((response) => { |
| | | // 对响应数据做点什么 |
| | | let token = response.headers["access-token"]; |
| | | if (token) { |
| | | userService.setToken(token) |
| | | } |
| | | return response; |
| | | }, function (error) { |
| | | }, (error) => { |
| | | // 对响应错误做点什么 |
| | | if (error.response.status === 401) { |
| | | console.log("Received 401 Response") |
| | |
| | | } |
| | | return Promise.reject(error); |
| | | }); |
| | | axios.interceptors.request.use( |
| | | config => { |
| | | if (userService.getToken() != null && config.url !== "/api/user/login") { |
| | | config.headers['access-token'] = `${userService.getToken()}`; |
| | | } |
| | | return config; |
| | | }, |
| | | error => { |
| | | return Promise.reject(error); |
| | | } |
| | | ); |
| | | |
| | | Vue.prototype.$axios = axios; |
| | | Vue.prototype.$cookies.config(60*30); |
| | | |