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