snowy.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import * as antdvIcons from '@ant-design/icons-vue'
  2. import config from './config'
  3. import reSourceConfig from './config/reSource'
  4. import tool from './utils/tool'
  5. import { hasPerm } from './utils/permission/index'
  6. import errorHandler from './utils/errorHandler'
  7. import customIcons from './assets/icons/index.js'
  8. import 'snowy-form-design/dist/style.css'
  9. import SnowyFormDesign from 'snowy-form-design'
  10. import 'highlight.js/styles/atom-one-dark.css'
  11. import hljsCommon from 'highlight.js/lib/common'
  12. import hljsVuePlugin from '@highlightjs/vue-plugin'
  13. import STable from './components/Table/index.vue'
  14. import Ellipsis from './components/Ellipsis/index.vue'
  15. import DragModal from './components/DragModal/index.vue'
  16. import globalFunction from './libs/globalFunction/index.js'
  17. import fileOperationPlugins from './libs/fileOperationPlugins.js'
  18. export default {
  19. install(app) {
  20. // 挂载全局对象
  21. app.config.globalProperties.$CONFIG = config
  22. app.config.globalProperties.$RESOURCE_CONFIG = reSourceConfig
  23. app.config.globalProperties.$TOOL = tool
  24. app.config.globalProperties.hasPerm = hasPerm
  25. app.config.globalProperties.$file = globalFunction.file
  26. for (let key in fileOperationPlugins) {
  27. app.config.globalProperties[`$${key}`] = fileOperationPlugins[key]
  28. }
  29. // 注册常用组件
  30. app.component('STable', STable)
  31. app.component('Ellipsis', Ellipsis)
  32. app.component('DragModal', DragModal)
  33. // 统一注册antdv图标
  34. for (const icon in antdvIcons) {
  35. app.component(icon, antdvIcons[icon])
  36. }
  37. // 统一注册自定义全局图标
  38. app.use(customIcons)
  39. // 注册表单设计器,如果您不需要流程设计相关功能,可以移除以减少体积
  40. app.use(SnowyFormDesign)
  41. // 注册代码高亮组件 (博客:https://blog.csdn.net/weixin_41897680/article/details/124925222)
  42. // 注意:解决Vue使用highlight.js build打包发布后样式消失问题,原因是webpack在打包的时候没有把未被使用的代码打包进去,因此,在此处引用一下,看似无意义实则有用
  43. hljsCommon.highlightAuto('<h1>Highlight.js has been registered successfully!</h1>').value
  44. app.use(hljsVuePlugin)
  45. // 全局代码错误捕捉
  46. app.config.errorHandler = errorHandler
  47. }
  48. }