main.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import { createApp } from 'vue'
  2. import App from './App.vue'
  3. import router from './router'
  4. import directives from '@/directives' // 自定义指令集
  5. import '@/services/subscribe' // 全局订阅通知
  6. import '@/mock' // 模拟数据
  7. import layouts from "./components/layouts" // 布局组件
  8. import ElementPlus from 'element-plus'
  9. import * as ElementIcons from '@element-plus/icons-vue'
  10. import 'element-plus/dist/index.css'
  11. import './assets/themes/style.less' // 主题样式
  12. import { timerInterceptor } from '@/utils/timer'
  13. import { themeStore } from '@/stores'
  14. const app = createApp(App)
  15. app.use(router)
  16. app.use(directives)
  17. app.use(ElementPlus)
  18. app.use(layouts)
  19. app.mount('#app')
  20. // 等待 html 加载完成
  21. document.addEventListener('DOMContentLoaded', () => {
  22. // 适配客户端
  23. themeStore.actions.screenAdapter()
  24. // 监听窗口大小变化
  25. window.addEventListener('resize', timerInterceptor.setDebounce(() => themeStore.actions.screenAdapter()))
  26. }, false)
  27. // 注册全局图标
  28. for (const [key, value] of Object.entries(ElementIcons)) {
  29. app.component(key, value)
  30. }