snowy.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Copyright [2022] [https://www.xiaonuo.vip]
  3. * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
  4. * 1.请不要删除和修改根目录下的LICENSE文件。
  5. * 2.请不要删除和修改Snowy源码头部的版权声明。
  6. * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
  7. * 4.分发源码时候,请注明软件出处 https://xiaonuo.vip
  8. * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
  9. * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
  10. */
  11. import * as antdvIcons from '@ant-design/icons-vue'
  12. import config from './config'
  13. import reSourceConfig from './config/reSource'
  14. import tool from './utils/tool'
  15. import { hasPerm } from './utils/permission/index'
  16. import errorHandler from './utils/errorHandler'
  17. import customIcons from './assets/icons/index.js'
  18. import 'snowy-form-design/dist/style.css'
  19. import SnowyFormDesign from 'snowy-form-design'
  20. import 'highlight.js/styles/atom-one-dark.css'
  21. import hljsCommon from 'highlight.js/lib/common'
  22. import hljsVuePlugin from '@highlightjs/vue-plugin'
  23. import STable from './components/Table/index.vue'
  24. import Ellipsis from './components/Ellipsis/index.vue'
  25. import DragModal from './components/DragModal/index.vue'
  26. import globalFunction from './libs/globalFunction/index.js'
  27. import fileOperationPlugins from './libs/fileOperationPlugins.js'
  28. export default {
  29. install(app) {
  30. // 挂载全局对象
  31. app.config.globalProperties.$CONFIG = config
  32. app.config.globalProperties.$RESOURCE_CONFIG = reSourceConfig
  33. app.config.globalProperties.$TOOL = tool
  34. app.config.globalProperties.hasPerm = hasPerm
  35. app.config.globalProperties.$file = globalFunction.file
  36. for (let key in fileOperationPlugins) {
  37. app.config.globalProperties[`$${key}`] = fileOperationPlugins[key]
  38. }
  39. // 注册常用组件
  40. app.component('STable', STable)
  41. app.component('Ellipsis', Ellipsis)
  42. app.component('DragModal', DragModal)
  43. // 统一注册antdv图标
  44. for (const icon in antdvIcons) {
  45. app.component(icon, antdvIcons[icon])
  46. }
  47. // 统一注册自定义全局图标
  48. app.use(customIcons)
  49. // 注册表单设计器,如果您不需要流程设计相关功能,可以移除以减少体积
  50. app.use(SnowyFormDesign)
  51. // 注册代码高亮组件 (博客:https://blog.csdn.net/weixin_41897680/article/details/124925222)
  52. // 注意:解决Vue使用highlight.js build打包发布后样式消失问题,原因是webpack在打包的时候没有把未被使用的代码打包进去,因此,在此处引用一下,看似无意义实则有用
  53. hljsCommon.highlightAuto('<h1>Highlight.js has been registered successfully!</h1>').value
  54. app.use(hljsVuePlugin)
  55. // 全局代码错误捕捉
  56. app.config.errorHandler = errorHandler
  57. }
  58. }