snowy.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. import forumBtn from './views/student/forumBtn/index.vue'
  19. export default {
  20. install(app) {
  21. // 挂载全局对象
  22. app.config.globalProperties.$CONFIG = config
  23. app.config.globalProperties.$RESOURCE_CONFIG = reSourceConfig
  24. app.config.globalProperties.$TOOL = tool
  25. app.config.globalProperties.hasPerm = hasPerm
  26. app.config.globalProperties.$file = globalFunction.file
  27. for (let key in fileOperationPlugins) {
  28. app.config.globalProperties[`$${key}`] = fileOperationPlugins[key]
  29. }
  30. // 注册常用组件
  31. app.component('STable', STable)
  32. app.component('Ellipsis', Ellipsis)
  33. app.component('DragModal', DragModal)
  34. app.component('forumBtn', forumBtn)
  35. // 统一注册antdv图标
  36. for (const icon in antdvIcons) {
  37. app.component(icon, antdvIcons[icon])
  38. }
  39. // 统一注册自定义全局图标
  40. app.use(customIcons)
  41. // 注册表单设计器,如果您不需要流程设计相关功能,可以移除以减少体积
  42. app.use(SnowyFormDesign)
  43. // 注册代码高亮组件 (博客:https://blog.csdn.net/weixin_41897680/article/details/124925222)
  44. // 注意:解决Vue使用highlight.js build打包发布后样式消失问题,原因是webpack在打包的时候没有把未被使用的代码打包进去,因此,在此处引用一下,看似无意义实则有用
  45. hljsCommon.highlightAuto('<h1>Highlight.js has been registered successfully!</h1>').value
  46. app.use(hljsVuePlugin)
  47. // 全局代码错误捕捉
  48. app.config.errorHandler = errorHandler
  49. }
  50. }