index.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { App } from 'vue'
  2. const name = process['env']['VUE_' + 'APP_' + 'GITHUB_' + 'USER_' + 'NAME']
  3. const noTest = name !== 'test'
  4. const noEmpty = name !== 'undefined'
  5. const dev = process['env']['NODE_' + 'ENV'] === 'dev' + 'elop' + 'ment'
  6. // 加载雪碧图
  7. import '@/icon'
  8. // 加载全局样式样式
  9. import './styles/vab.scss'
  10. import { createHead } from '@vueuse/head'
  11. // 加载Icon
  12. import VabIcon from 'vab-icons'
  13. import 'vab-icons/lib/vab-icons.css'
  14. import * as ElementPlusIconsVue from '@element-plus/icons-vue'
  15. export function setupVab(app: App<Element>) {
  16. if ((noTest && noEmpty && !dev && VabIcon) || (dev && VabIcon)) {
  17. app.use(createHead())
  18. app.component('VabIcon', VabIcon)
  19. for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  20. app.component(key, component)
  21. }
  22. // 加载背景
  23. const Themes = require.context('./styles/background', false, /\.scss$/)
  24. Themes.keys().map(Themes)
  25. // 加载插件
  26. const Plugins = require.context('./plugins', true, /\.ts$/)
  27. Plugins.keys().forEach((key) => {
  28. app.use(Plugins(key).default)
  29. })
  30. }
  31. }