main.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. * 引入vue.grid-layout
  21. */
  22. import VueGridLayout from 'vue-grid-layout'
  23. /**
  24. * @author chuzhixin 1204505056@qq.com
  25. * @description 正式环境默认使用mock,正式项目记得注释后再打包
  26. */
  27. // if (process.env.NODE_ENV === 'production') {
  28. // const { mockXHR } = require('@/utils/static')
  29. // mockXHR()
  30. // }
  31. var app = createApp(App)
  32. app.config.globalProperties.$echarts = echarts
  33. app.directive("drag", { //指令的名称
  34. inserted: function (el, binding) { //当被绑定的元素插入到 DOM 中时
  35. binding
  36. el.onmousedown = function (e) {
  37. var x = e.clientX - el.offsetLeft;
  38. var y = e.clientY - el.offsetTop;
  39. document.onmousemove = function (eve) {
  40. el.style.left = eve.clientX - x + "px";
  41. el.style.top = eve.clientY - y + "px";
  42. }
  43. document.onmouseup = function () {
  44. document.onmousemove = null;
  45. document.onmouseup = null;
  46. }
  47. }
  48. }
  49. })
  50. app
  51. .component("svg-icon", SvgIcon)
  52. .use(store)
  53. .use(router)
  54. .use(ElementPlus, { locale: zhCn, size: 'small' })
  55. .use(Antd)
  56. .use(VueGridLayout)
  57. .mount('#app')
  58. /**
  59. * @需添加路由拦截 --登录后执行
  60. */
  61. router.beforeEach((to) => {
  62. if (to.path != '/login') {
  63. store.commit("publicSiteList");
  64. store.commit('publicDeviceList')
  65. console.log(to.meta.title)
  66. store.commit('getAuthorities', to.meta.title)
  67. // store.commit('getMiddleConfig')
  68. // console.log('store.state.authorities')
  69. // console.log(store.state.authorities)
  70. // next()
  71. }
  72. // if (to.path == '/home') {
  73. // if (window.location.host.indexOf('localhost') != -1) {
  74. // window.location.href = "http://localhost:8080/#/home";
  75. // // } else if (window.location.host.indexOf('pcdev.ewoogi.com') != -1) {
  76. // // window.location.href = "https://pcdev.ewoogi.com/vuefiv#/home";
  77. // } else {
  78. // window.location.href = "http://101.133.214.75:13201/";
  79. // }
  80. // }
  81. })
  82. router.afterEach((to) => {
  83. to
  84. })