snowy.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import * as antdvIcons from '@ant-design/icons-vue'
  2. import config from './config'
  3. import tool from './utils/tool'
  4. import util from './utils/util'
  5. import { hasPerm } from './utils/permission/index'
  6. import errorHandler from './utils/errorHandler'
  7. import customIcons from './assets/icons/index.js'
  8. import 'highlight.js/styles/atom-one-dark.css'
  9. import hljsCommon from 'highlight.js/lib/common'
  10. import hljsVuePlugin from '@highlightjs/vue-plugin'
  11. import STable from './components/Table/index.vue'
  12. import Ellipsis from './components/Ellipsis/index.vue'
  13. import DragModal from './components/DragModal/index.vue'
  14. export default {
  15. install(app) {
  16. // 挂载全局对象
  17. app.config.globalProperties.$CONFIG = config
  18. app.config.globalProperties.$TOOL = tool
  19. app.config.globalProperties.$util = util
  20. app.config.globalProperties.hasPerm = hasPerm
  21. // 注册常用组件
  22. app.component('STable', STable)
  23. app.component('Ellipsis', Ellipsis)
  24. app.component('DragModal', DragModal)
  25. // 统一注册antdv图标
  26. for (const icon in antdvIcons) {
  27. app.component(icon, antdvIcons[icon])
  28. }
  29. // 统一注册自定义全局图标
  30. app.use(customIcons)
  31. // 注册代码高亮组件 (博客:https://blog.csdn.net/weixin_41897680/article/details/124925222)
  32. // 注意:解决Vue使用highlight.js build打包发布后样式消失问题,原因是webpack在打包的时候没有把未被使用的代码打包进去,因此,在此处引用一下,看似无意义实则有用
  33. hljsCommon.highlightAuto('<h1>Highlight.js has been registered successfully!</h1>').value
  34. app.use(hljsVuePlugin)
  35. // 全局代码错误捕捉
  36. app.config.errorHandler = errorHandler
  37. }
  38. }