@ray-js/robot-map 0.0.5-beta.2 → 0.0.5-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,6 +16,9 @@ const componentOptions = {
|
|
|
16
16
|
mapApi: null
|
|
17
17
|
},
|
|
18
18
|
properties: {
|
|
19
|
+
containerId: {
|
|
20
|
+
type: String
|
|
21
|
+
},
|
|
19
22
|
path: {
|
|
20
23
|
type: String,
|
|
21
24
|
observer: function (newValue, oldValue) {
|
|
@@ -129,8 +132,11 @@ const componentOptions = {
|
|
|
129
132
|
this.mapApi = null;
|
|
130
133
|
},
|
|
131
134
|
async ready() {
|
|
132
|
-
const
|
|
133
|
-
|
|
135
|
+
const {
|
|
136
|
+
config: configProp = {},
|
|
137
|
+
containerId
|
|
138
|
+
} = this.properties;
|
|
139
|
+
await this.render.initialize(configProp || {}, containerId);
|
|
134
140
|
this.setData({
|
|
135
141
|
initialized: true
|
|
136
142
|
});
|
|
@@ -5,16 +5,16 @@ export default Render({
|
|
|
5
5
|
mapInstance: null,
|
|
6
6
|
initialized: false,
|
|
7
7
|
|
|
8
|
-
async initialize(config = {}) {
|
|
8
|
+
async initialize(config = {}, containerId = 'container') {
|
|
9
9
|
const { mapInstance } = this;
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
if (mapInstance) {
|
|
12
12
|
console.warn('Map instance already initialized')
|
|
13
13
|
return
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
this.mapInstance = new MapApplication()
|
|
17
|
-
const containerElement = document.getElementById(
|
|
17
|
+
const containerElement = document.getElementById(containerId)
|
|
18
18
|
|
|
19
19
|
// 定义事件处理器
|
|
20
20
|
const events = {}
|
package/lib/RjsRobotMap.js
CHANGED
|
@@ -9,6 +9,7 @@ import "core-js/modules/esnext.iterator.reduce.js";
|
|
|
9
9
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
10
10
|
import React, { useCallback, useEffect, useRef, useMemo } from 'react';
|
|
11
11
|
import { MAP_CALLBACK_METHODS } from '@ray-js/robot-map-sdk';
|
|
12
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
12
13
|
import RjsComponent from './RjsComponent';
|
|
13
14
|
import { robotMapDefaultProps } from './props';
|
|
14
15
|
|
|
@@ -39,6 +40,8 @@ const RjsRobotMap = _ref => {
|
|
|
39
40
|
callbacks = _objectWithoutProperties(_ref, _excluded);
|
|
40
41
|
const componentRef = useRef(null);
|
|
41
42
|
const callbacksRef = useRef(callbacks);
|
|
43
|
+
// 为每个组件实例生成唯一的 containerId
|
|
44
|
+
const containerId = useRef("robot-map-container-".concat(nanoid())).current;
|
|
42
45
|
|
|
43
46
|
// 更新回调引用
|
|
44
47
|
useEffect(() => {
|
|
@@ -92,7 +95,8 @@ const RjsRobotMap = _ref => {
|
|
|
92
95
|
detectedObjects: detectedObjects,
|
|
93
96
|
customElements: customElements,
|
|
94
97
|
config: config,
|
|
95
|
-
runtime: runtime
|
|
98
|
+
runtime: runtime,
|
|
99
|
+
containerId: containerId
|
|
96
100
|
}, eventBindings));
|
|
97
101
|
};
|
|
98
102
|
RjsRobotMap.defaultProps = robotMapDefaultProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/robot-map",
|
|
3
|
-
"version": "0.0.5-beta.
|
|
3
|
+
"version": "0.0.5-beta.4",
|
|
4
4
|
"description": "机器人地图组件",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@ray-js/ray": "^1.7.39"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@ray-js/robot-map-sdk": "0.0.4-beta.
|
|
36
|
+
"@ray-js/robot-map-sdk": "0.0.4-beta.3",
|
|
37
37
|
"clsx": "^1.2.1",
|
|
38
38
|
"nanoid": "^5.1.6"
|
|
39
39
|
},
|