13693261870
2023-06-21 cdf12fc9e88b1af69f5c85165eb9fef4e23bf57a
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
import React, { useEffect } from 'react'; // , useState
//import { PlayCircleOutlined } from '@ant-design/icons';
import setting from './setting';
import styles from './index.less';
import * as UE from "./UE";
 
function Terra ({
  width, height, config = {}, data
}) {
  // const [msg, setMsg] = useState('hello');
  // const {
  //   theme, rectAngle = 30, angle = 45, backgroundColor = '#2949B1'
  // } = config;
 
  // let background = '';
  // if (backgroundColor.indexOf('-') > 0) {
  //   background = `linear-gradient(${angle}deg, ${backgroundColor.replace('-', ',')})`;
  // } else {
  //   background = backgroundColor;
  // }
 
  // const style = {
  //   width,
  //   height,
  //   background,
  //   fontSize: 32
  // };
 
  // if (theme === 'circle') {
  //   style.borderRadius = '50%';
  // }
  // if (theme === 'rect') {
  //   const rectLength = width - Math.floor(height * 0.578);
  //   style.transform = `skew(-${rectAngle}deg)`;
  //   style.marginLeft = Math.floor(height * 0.578 / 2);
  //   style.width = rectLength > 0 ? rectLength : 0;
  // }
 
  // 第一次加载
  useEffect(() => {
    // setTimeout(() => {
    //   setMsg('hello world');
    // }, 3000);
 
    // http://103.25.37.69:92/dist/tumap.js
    // const script = document.createElement('script');
    // script.src = setting.ueUrl + '/dist/tumap.js';
    // document.body.appendChild(script);
 
    // window.onload = function () {
    //   const script = document.createElement('script');
    //   script.src = 'tumap.js';
    //   document.body.appendChild(script);
    // };
 
    //let div = document.getElementById('tMap');
    // var node = div.parentNode;
    // while (true) {
    //   node.style.width = '100%';
    //   node.style.height = '100%';
    //   if (node.id == "root") break;
 
    //   node = node.parentNode;
    // }
 
    const div = document.getElementById('tMap');
    div.parentNode.style.width = '100%';
    div.parentNode.style.height = '100%';
    div.parentNode.parentNode.parentNode.style.width = '100%';
    div.parentNode.parentNode.parentNode.style.height = '100%';
 
    window.UE = UE;
    UE.init('tMap', (map) => {
      window.UE.map = map;
      console.log('UE.init => ', map);
    });
 
  }, []);
 
  return (
    // <div className={styles.box}>
    //   <div style={style}>
    //     {msg}
    //     {data && data.map(i => (
    //       <p key={`${i.name}-${i.value}`}>
    //         <PlayCircleOutlined />
    //         {`${i.name}-${i.value}`}
    //       </p>
    //     ))}
    //     {config.isProd ? 'production' : 'test'}
    //   </div>
    // </div>
    <div id="tMap" className={styles.box}></div>
  );
}
Terra.setting = setting;
 
/**
 * 自定义配置
 *  1. 对于只有当前组件才使用的样式配置,可以集成自定义配置组件
 *  2. 自定义配置组件 props 参数必须实现:  value, onChange
 *
*/
Terra.styleConfig = {
  EnvSwitch: ({ value, onChange }) => (
    <div onClick={() => { onChange(!value); }}>
      {value ? 'production' : 'test'}
    </div>
  )
};
export default Terra;