main.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { createApp } from 'vue'
  2. import App from './App.vue'
  3. import router from '@/router'
  4. // element plus
  5. import ElementPlus from 'element-plus'
  6. import 'element-plus/theme-chalk/index.css'
  7. // element dark css
  8. import 'element-plus/theme-chalk/dark/css-vars.css'
  9. // 自定义样式
  10. import '@/styles/index.scss'
  11. // 注册全局组件
  12. import { registerGlobComp } from '@/components/registerGlobComp'
  13. // 注册全局directive
  14. import { setupGlobDirectives } from '@/directive'
  15. import '@/permission'
  16. // 引入svg注册脚本
  17. import 'virtual:svg-icons-register'
  18. // 加载admin-svg icon
  19. ;(function () {
  20. const d = document
  21. // const existIconVersion = [...d.querySelectorAll('.le-icon_svg')].map(v => v.getAttribute('version')).includes(version)
  22. const existIconVersion = false
  23. if (!existIconVersion) {
  24. /** update 最新 le-iconfont(.css && .js) */
  25. const origin_prefix = '//at.alicdn.com/t/c/font_4091949_h5ex5dw89e'
  26. const link = d.createElement('link')
  27. link.rel = 'stylesheet'
  28. link.type = 'text/css'
  29. link.className = 'le-icon_iconfont'
  30. // link.setAttribute('version', version)
  31. // link.setAttribute('origin', location.origin)
  32. link.href = `${origin_prefix}.css`
  33. d.getElementsByTagName('head')[0].appendChild(link)
  34. const s = d.createElement('script')
  35. s.className = 'le-icon_svg'
  36. s.src = `${origin_prefix}.js`
  37. // s.setAttribute('version', version)
  38. // s.setAttribute('origin', location.origin)
  39. d.getElementsByTagName('head')[0].appendChild(s)
  40. }
  41. })()
  42. // 国际化
  43. import i18n from '@/lang/index'
  44. // pinia store
  45. import pinia from '@/store/createPinia'
  46. import { $log } from '@/utils'
  47. const app = createApp(App)
  48. // 注册全局组件
  49. registerGlobComp(app)
  50. // 注册全局自定义指令
  51. setupGlobDirectives(app)
  52. // 全局方法
  53. app.config.globalProperties.$log = $log
  54. // 注册全局组件
  55. app.use(router).use(ElementPlus).use(i18n).use(pinia).mount('#app')