snowy.js 1.6 KB

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