@glodon-ecs/web-bridge-sdk 0.1.1 → 0.2.0

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.
package/README.md CHANGED
@@ -12,8 +12,9 @@ import ECSHubBridge from "@glodon-ecs/web-bridge-sdk";
12
12
  // 使用示例
13
13
  async function main() {
14
14
  // initialize 方法需要先被调用
15
-
16
- await ECSHubBridge.initialize({ env: "sketchup" });
15
+ // await ECSHubBridge.initialize(); // 自动检测初始化,QT、SU、Web环境
16
+ const options = { env: "sketchup", logger: window.console }; // options 可选
17
+ await ECSHubBridge.initialize(options);
17
18
  const bridge = ECSHubBridge.getInstance();
18
19
 
19
20
  // 调用方法
@@ -32,24 +33,24 @@ async function main() {
32
33
  class CADAdapter {
33
34
  // 初始方法
34
35
  async init() {
35
- this._client = window.CADPlugin; // 假设第三方CAD插件
36
+ this.client = window.CADPlugin; // 假设第三方CAD插件
36
37
  }
37
38
 
38
39
  // 调用内部函数
39
40
  call(method, args) {
40
- return this._client.execCommand(method, ...args);
41
+ return this.client.execCommand(method, ...args);
41
42
  }
42
43
 
43
44
  // 注册事件监听
44
45
  onEvent(event, callback) {
45
- this._client.on(event, callback);
46
- return () => this._client.off(event, callback);
46
+ this.client.on(event, callback);
47
+ return () => this.client.off(event, callback);
47
48
  }
48
49
  }
49
50
 
50
51
  // 注入自定义适配器
51
52
  await ECSHubBridge.initialize();
52
- ECSHubBridge.setAdapter(new CADAdapter());
53
+ ECSHubBridge.setAdapter(new CADAdapter(), 'cad');
53
54
 
54
55
  // 设置自定义适配器的client交互对象,如 ecsClient
55
56
  await ECSHubBridge.initialize();