main.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // The Vue build version to load with the `import` command
  2. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
  3. import Vue from "vue";
  4. import App from "./App";
  5. import router from "./router";
  6. import axios from "axios";
  7. import Cube from "./index";
  8. import "lib-flexible";
  9. import "./filters";
  10. // import VConsole from "vconsole";
  11. // import host from '../src/request/host'
  12. // import {get,post} from './service/http'
  13. // new VConsole();
  14. Vue.use(Cube);
  15. console.info('v1.0.2');
  16. // 修改请求接口(删掉地址栏中的app2)
  17. let domainName = document.domain; //域名
  18. let protocolName = document.location.protocol; //http协议
  19. axios.defaults.baseURL = protocolName + "//" + domainName;
  20. // axios.defaults.timeout = 5000;
  21. axios.interceptors.response.use(function (response) {
  22. return response;
  23. }, function (error) {
  24. if(error && error.response && error.response.status == 444){
  25. window.location.href = location.origin + '/user.jsp';
  26. }
  27. return Promise.reject(error);
  28. });
  29. Vue.prototype.$http = axios;
  30. Vue.config.productionTip = false;
  31. Vue.prototype.$host = protocolName + "//" + domainName;
  32. //因项目众多,前端为了加以区分,所以用域名加以判断,后期有更好的方式可以自行修改
  33. // 中南财大
  34. Vue.prototype.isZncd = document.domain === 'itsm.zuel.edu.cn';
  35. /* eslint-disable no-new */
  36. new Vue({
  37. el: "#app",
  38. router,
  39. components: { App },
  40. template: "<App/>"
  41. });