main.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { createApp } from 'vue/dist/vue.esm-bundler.js';
  2. import Antd from 'ant-design-vue';
  3. import 'ant-design-vue/dist/antd.css';
  4. import App from './App.vue';
  5. import UCore from './utils/UCore.js';
  6. import './assets/css/index.css';
  7. import router from './router';
  8. import Vuex from 'vuex'
  9. import store from './store/index.js';
  10. import axios from 'axios';
  11. import ElementPlus from 'element-plus';
  12. import 'element-plus/lib/theme-chalk/index.css';
  13. import 'dayjs/locale/zh-cn';
  14. import locale from 'element-plus/lib/locale/lang/zh-cn';
  15. //引入rem字体配置
  16. import '@/assets/js/flexible.js';
  17. // 引入字体样式
  18. import '@/assets/fonts/font.css';
  19. import * as echarts from 'echarts'
  20. import 'echarts/lib/component/tooltip';
  21. import 'echarts/lib/component/title';
  22. import 'echarts/lib/component/legend';
  23. // import { ElMessage } from "element-plus";
  24. import { removeToken } from './utils/auth';
  25. const app = createApp(App);
  26. import Interface from "../public/InterfaceReturn.json"
  27. app.config.globalProperties.$Interface = Interface
  28. app.config.globalProperties.$UCore = UCore;
  29. app.config.globalProperties.$axios = axios;
  30. import ECharts from 'vue-echarts';
  31. app.component('v-chart', ECharts);
  32. app.use(router).use(store).use(ElementPlus, { locale }).use(Vuex).use(echarts).use(Antd).mount('#app');
  33. store.commit("getTimeAll");
  34. /*路由守卫*/
  35. router.beforeEach((to, from, next) => {
  36. /* 路由发生变化修改页面title */
  37. if (to.meta.title) {
  38. document.title = to.meta.title
  39. }
  40. if (to.path !== '/') {
  41. if (localStorage.getItem('accessToken') === null) {
  42. removeToken()//不用管
  43. // if (localStorage.getItem('userInfo') === null) {
  44. // 本地存储的accessToken不存在时,跳转至后台登录页
  45. // alert('本地存储的accessToken不存在')
  46. if (window.location.host.indexOf("localhost") != -1) {
  47. next({ path: '/' })
  48. } else if (window.location.host.indexOf("pcdev.ewoogi.com") != -1) {
  49. window.location.href = 'https://pcdev.ewoogi.com/adminfiv/#/login'
  50. } else {
  51. window.location.href = 'https://wx.ewoogi.com/manage/#/login'
  52. }
  53. document.getElementById('routers').style.display = "none"
  54. // setTimeout(() => {
  55. // ElMessage.warning({
  56. // message: '请登录后重试!',
  57. // type: 'warning'
  58. // })
  59. // }, 100);
  60. } else {
  61. // alert('本地存储的accessToken存在')
  62. next();
  63. }
  64. } else {
  65. document.getElementById('routers').style.display = "block"
  66. //路由的next必须存在,否则无法进入下一页
  67. if (localStorage.getItem('accessToken') != null) {
  68. next({ path: '/home' })
  69. } else {
  70. next()
  71. }
  72. }
  73. })