main.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { createApp } from 'vue'
  2. import './style.css'
  3. import './global.scss'
  4. import App from './App.vue'
  5. import { getAssetsFile } from '@/utils/imgResolve'
  6. import router from './router'
  7. import store from './store/index'
  8. import ElementPlus from 'element-plus'
  9. import 'element-plus/dist/index.css'
  10. import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
  11. import 'vant/lib/index.css'
  12. import '@vant/touch-emulator'
  13. import * as ElementPlusIconsVue from '@element-plus/icons-vue'
  14. const setHtmlFontSize = () => {
  15. // store.commit('screenChange');
  16. const htmlDom = document.getElementsByTagName('html')[0]
  17. let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth
  18. console.log(htmlWidth)
  19. if (htmlWidth >= 750) {
  20. htmlWidth = 750
  21. }
  22. if (htmlWidth <= 450) {
  23. htmlWidth = 450 // 12px
  24. }
  25. htmlDom.style.fontSize = `${htmlWidth / 37.5}px`
  26. }
  27. window.onresize = setHtmlFontSize
  28. setHtmlFontSize()
  29. const app = createApp(App)
  30. app.provide('img', getAssetsFile)
  31. app.use(store)
  32. app.use(router)
  33. for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  34. app.component(key, component)
  35. }
  36. app.use(ElementPlus, {
  37. locale: zhCn,
  38. size: 'large', zIndex: 3000
  39. })
  40. app.mount('#app')