main.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. import Vue from 'vue'
  2. import App from './App.vue'
  3. import _ from 'lodash'
  4. import router from './router'
  5. import store from './store'
  6. console.log(router);
  7. //引入element
  8. import ElementUI from 'element-ui';
  9. import {Message} from 'element-ui';
  10. import 'element-ui/lib/theme-chalk/index.css';
  11. Vue.use(ElementUI);
  12. //引入Fastboot UI库
  13. import FastbootUI from 'fastboot-ui/src/components';
  14. import 'fastboot-ui/src/scss/element-theme.scss'
  15. Vue.use(FastbootUI);
  16. // import FastbootAdmin from 'fastboot-admin';
  17. // import DictSelect from "fastboot-admin/src/components/DictSelect.vue";
  18. // import OrgCascader from "fastboot-admin/src/components/OrgCascader.vue";
  19. // import DictText from "fastboot-admin/src/components/DictText.vue";
  20. // import AreaCascader from "fastboot-admin/src/components/AreaCascader.vue";
  21. // import RoleSelect from "fastboot-admin/src/components/RoleSelect.vue";
  22. // Vue.component(DictSelect.name,DictSelect);
  23. // Vue.component(OrgCascader.name,OrgCascader);
  24. // Vue.component(AreaCascader.name,AreaCascader);
  25. // Vue.component(DictText.name,DictText);
  26. // Vue.component(RoleSelect.name,RoleSelect);
  27. //引入全局工具和配置
  28. import qs from 'qs'
  29. import axios from 'axios'
  30. //引入接口
  31. import baseApi from './config/api'
  32. let api = _.defaultsDeep(baseApi);
  33. // router.addRoutes(FastbootAdmin.routes)
  34. import moment from 'moment'
  35. import utils from './util/utils'
  36. Vue.prototype.$moment = moment;
  37. Vue.prototype.$api = api ;
  38. Vue.prototype.$http = axios;
  39. Vue.prototype.$qs = qs;
  40. Vue.prototype.$utils = utils;
  41. axios.defaults.withCredentials = true;
  42. Vue.config.productionTip = false
  43. //http响应拦截器
  44. Vue.prototype.$http.interceptors.response.use(resp => {
  45. //如果未授权,则跳转至授权页面
  46. if(resp.data.status === 401){
  47. if(sessionStorage.getItem("login-user-info") != null){
  48. Message.warning("30分钟未操作自动退出登录");
  49. }
  50. sessionStorage.removeItem("login-user-info");
  51. router.push("/login");
  52. }
  53. //如果未授权,则跳转至授权页面
  54. if(resp.data.status === 403){
  55. router.push("/no-permission");
  56. }
  57. return resp;
  58. }, error => {
  59. console.log(error);
  60. return Promise.reject(error)
  61. });
  62. //加载系统信息
  63. // axios.post(api.app.appInfo).then((resp)=>{
  64. //
  65. // window.appInfo = resp.data.data.appInfo;
  66. // try {
  67. // window.appSetting = JSON.parse(resp.data.data.appInfo.setting);
  68. // }catch (e) {
  69. // window.appSetting = {};
  70. // }
  71. //
  72. // if(!window.appSetting){
  73. // window.appSetting={};
  74. // }
  75. //
  76. // if(window.appInfo.logo){
  77. // window.appInfo.logoUrl = `${api.commonFile.download}?code=${window.appInfo.logo}`;
  78. // }
  79. //
  80. //
  81. // if(window.appInfo.name){
  82. // document.title=window.appInfo.name;
  83. // }else{
  84. // document.title="未配置系统名称";
  85. // }
  86. //
  87. //
  88. // //路由拦截器
  89. // router.beforeEach((to,form,next)=>{
  90. //
  91. //
  92. //
  93. //
  94. // if(to.path.startsWith('/update-user-password')){
  95. // next();
  96. // if(window.updatePassword){
  97. // Message.warning("请修改密码再进行操作!");
  98. // }
  99. // return;
  100. // }
  101. //
  102. //
  103. // if(sessionStorage.getItem("login-user-info") != null){
  104. //
  105. //
  106. // let userInfo = JSON.parse(sessionStorage.getItem("login-user-info"));
  107. //
  108. //
  109. //
  110. //
  111. // if(window.appSetting["UPDATE_PWD_INTERVAL"] && window.appSetting["UPDATE_PWD_INTERVAL"].value !== "0"){
  112. //
  113. // if(!userInfo.lastUpdatePwdTime){
  114. // window.updatePassword = true;
  115. //
  116. // next('/update-user-password')
  117. // return ;
  118. // }
  119. //
  120. // if(userInfo.lastUpdatePwdTime <= parseInt(window.appSetting["UPDATE_PWD_INTERVAL"]) * 24 * 60 * 60 * 1000){
  121. // next('/update-user-password');
  122. // return;
  123. // }
  124. //
  125. // next();
  126. //
  127. //
  128. //
  129. // }else{
  130. // next();
  131. // }
  132. //
  133. // }else{
  134. // next();
  135. // }
  136. //
  137. // });
  138. //
  139. // window.routeViewType = 'route';
  140. //
  141. // new Vue({
  142. // router,
  143. // store,
  144. // render: h => h(App)
  145. // }).$mount('#app');
  146. //
  147. // });