main.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { createApp } from 'vue'
  2. import Antd from 'ant-design-vue'
  3. import App from './App'
  4. import router from './router'
  5. import store from './store'
  6. import 'ant-design-vue/dist/antd.css'
  7. import '@/vab'
  8. import 'default-passive-events'
  9. // 引入 ElementUI
  10. import ElementPlus from 'element-plus'
  11. import 'element-plus/dist/index.css'
  12. import zhCn from 'element-plus/lib/locale/lang/zh-cn' // 中文
  13. import '@/assets/css/index.scss'
  14. import '@/assets/css/global.scss'
  15. import * as echarts from 'echarts';
  16. import '@/icons'
  17. import SvgIcon from "@/components/SvgIcon"
  18. import 'video.js/dist/video-js.css'
  19. /**
  20. * @author chuzhixin 1204505056@qq.com
  21. * @description 正式环境默认使用mock,正式项目记得注释后再打包
  22. */
  23. // if (process.env.NODE_ENV === 'production') {
  24. // const { mockXHR } = require('@/utils/static')
  25. // mockXHR()
  26. // }
  27. var app = createApp(App)
  28. app.config.globalProperties.$echarts = echarts
  29. app
  30. .component("svg-icon", SvgIcon)
  31. .use(store)
  32. .use(router)
  33. .use(ElementPlus, { locale: zhCn, size: 'small' })
  34. .use(Antd)
  35. .mount('#app')
  36. /**
  37. * @需添加路由拦截 --登录后执行
  38. */
  39. router.beforeEach((to) => {
  40. console.log(to.meta.title)
  41. store.commit('getAuthorities', to.meta.title)
  42. console.log('store.state.authorities')
  43. console.log(store.state.authorities)
  44. if (to.path != '/login') {
  45. store.commit("publicSiteList");
  46. store.commit('publicDeviceList')
  47. }
  48. if (to.path == '/home') {
  49. if (window.location.host.indexOf('localhost') != -1) {
  50. window.location.href = "http://localhost:8081/vuefiv#/home";
  51. } else if (window.location.host.indexOf('pcdev.ewoogi.com') != -1) {
  52. window.location.href = "https://pcdev.ewoogi.com/vuefiv#/home";
  53. } else {
  54. window.location.href = "https://wx.ewoogi.com/panel/#/home";
  55. }
  56. }
  57. })
  58. router.afterEach((to) => {
  59. to
  60. })