remoteComponentsList.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // 得到用户自定义的远程组件列表
  2. import { dataConfig, settingConfig } from './settingConfig'
  3. // import _ from 'lodash'
  4. import cloneDeep from 'lodash/cloneDeep'
  5. const files = require.context('./innerComponents/', true, /index.vue$/)
  6. const innerRemoteComponents = []
  7. files.keys().forEach(key => {
  8. const title = key.split('/')[1].replace('.vue', '')
  9. const img = require(`./innerComponents/${title}/component.png`)
  10. const config = require(`./innerComponents/${title}/config.js`).default
  11. innerRemoteComponents.push({
  12. title: config.title || title,
  13. vueSysComponentDirName: 'inner_' + title,
  14. vueFile: files(key).default,
  15. ...config,
  16. img
  17. })
  18. })
  19. // 抛出内置系统组件
  20. export default getRemoteComponents(innerRemoteComponents)
  21. // 抛出外部的用户系统组件
  22. export function getRemoteComponents (comList) {
  23. const customList = (comList || window.BS_CONFIG?.remoteComponents) || []
  24. const list = []
  25. customList.forEach((config) => {
  26. list.push({
  27. name: config.name,
  28. title: config.title,
  29. icon: null,
  30. img: config.img,
  31. border: { type: '', titleHeight: 60, fontSize: 16, isTitle: true, padding: [16, 16, 16, 16] },
  32. className:
  33. 'com.gccloud.dataroom.core.module.chart.components.RemoteComponentChart',
  34. w: 450,
  35. h: 320,
  36. x: 0,
  37. y: 0,
  38. rotateX: config.rotateX || 0,
  39. rotateY: config.rotateY || 0,
  40. rotateZ: config.rotateZ || 0,
  41. perspective: config.perspective || 500,
  42. skewX: config.skewX || 0,
  43. skewY: config.skewY || 0,
  44. type: 'remoteComponent',
  45. option: {
  46. ...cloneDeep(settingConfig),
  47. ...config.option
  48. },
  49. // 右侧面板自定义配置
  50. setting: config.setting,
  51. ...cloneDeep(dataConfig),
  52. // 自定义配置
  53. customize: {
  54. ...config.customize,
  55. vueSysComponentDirName: config.vueSysComponentDirName,
  56. vueFile: config.vueFile
  57. }
  58. })
  59. })
  60. return list
  61. }
  62. export function getRemoteComponentConfig (code, name) {
  63. const config = {
  64. name,
  65. title: name,
  66. icon: null,
  67. img: null,
  68. border: { type: '', titleHeight: 60, fontSize: 16, isTitle: true, padding: [16, 16, 16, 16] },
  69. className:
  70. 'com.gccloud.dataroom.core.module.chart.components.RemoteComponentChart',
  71. w: 450,
  72. h: 320,
  73. x: 0,
  74. y: 0,
  75. rotateX: 0,
  76. rotateY: 0,
  77. rotateZ: 0,
  78. perspective: 0,
  79. skewX: 0,
  80. skewY: 0,
  81. type: 'remoteComponent',
  82. option: {
  83. ...cloneDeep(settingConfig)
  84. },
  85. // 右侧面板自定义配置
  86. setting: [],
  87. ...cloneDeep(dataConfig),
  88. // 自定义配置
  89. customize: {
  90. // 文件路径
  91. vueSysComponentDirName: null,
  92. // 用户上传的vue文件编码,根据此编码获取文件内容
  93. vueBizComponentCode: code,
  94. // vue文本内容
  95. vueFileContent: null
  96. }
  97. }
  98. return config
  99. }