main.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { createApp } from 'vue';
  2. // import Vue from 'vue';
  3. import App from './App.vue';
  4. import router from './router';
  5. import { store, key } from './store';
  6. import { directive } from '/@/utils/directive';
  7. import { i18n } from '/@/i18n/index';
  8. import other from '/@/utils/other';
  9. import ElementPlus from 'element-plus';
  10. import 'element-plus/dist/index.css';
  11. import 'element-plus/theme-chalk/dark/css-vars.css'
  12. import '/@/theme/index.scss';
  13. import mitt from 'mitt';
  14. import VueGridLayout from 'vue-grid-layout';
  15. import { getUpFileUrl, handleTree, selectDictLabel } from "/@/utils/common";
  16. import { useDict } from "/@/api/common/dict/data";
  17. // 分页组件
  18. import pagination from '/@/components/pagination/index.vue'
  19. import copy from '/@/components/copy/index.vue'
  20. //引入json数据展示
  21. import JsonViewer from "vue3-json-viewer"
  22. import VForm3 from 'vform3-builds' //引入VForm3库
  23. import 'vform3-builds/dist/designer.style.css' //引入VForm3样式
  24. const app = createApp(App);
  25. directive(app);
  26. other.elSvg(app);
  27. app.component('pagination', pagination)
  28. app.component('copy', copy)
  29. app.use(router)
  30. .use(store, key)
  31. .use(ElementPlus, { i18n: i18n.global.t })
  32. .use(i18n)
  33. .use(JsonViewer)
  34. .use(VueGridLayout)
  35. .use(VForm3)
  36. // .use(BaiduMap, { ak: 'Kp8XHK81HSF6rfRkYP7OxYKtK8IaG51d', type: 'WebGl', v: '2.0' })
  37. .mount('#app');
  38. // 全局挂载
  39. app.config.globalProperties.getUpFileUrl = getUpFileUrl
  40. app.config.globalProperties.handleTree = handleTree
  41. app.config.globalProperties.useDict = useDict
  42. app.config.globalProperties.selectDictLabel = selectDictLabel
  43. app.config.globalProperties.mittBus = mitt();
  44. const matchMedia = window.matchMedia('(prefers-color-scheme: light)')
  45. matchMedia.addEventListener('change', function () {
  46. // console.log(`当前的主题是:${this.matches ? 'light' : 'dark'}`)
  47. setTheme(this.matches)
  48. })
  49. function setTheme(matches: Boolean) {
  50. const body = document.documentElement as HTMLElement;
  51. body.setAttribute('data-theme', matches ? '' : 'dark');
  52. document.querySelector('html')!.className = matches ? '' : 'dark'
  53. }