main.ts 1.8 KB

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