drgame-cc 1.0.67 → 1.0.69

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.
@@ -6,6 +6,9 @@ export class KeyAdapter {
6
6
  private static keyHandler: ((event: { key: KeyCode, action: KeyAction }) => void) | null = null;
7
7
  private static keyboardBound: boolean = false;
8
8
 
9
+ /** 兼容处理:保存原有 onNativeBridgeCallback,避免覆盖 */
10
+ private static originalCallback: ((action, data) => void) | null = null;
11
+
9
12
  /** 虚拟手柄模式:激活时忽略键盘/遥控器/AdSdk 输入 */
10
13
  private static _virtualGamepadActive: boolean = false;
11
14
 
@@ -61,7 +64,16 @@ export class KeyAdapter {
61
64
 
62
65
  cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, KeyAdapter.onKeyboardDown, KeyAdapter);
63
66
  cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, KeyAdapter.onKeyboardUp, KeyAdapter);
64
- window['onNativeBridgeCallback'] = this.onMessage.bind(this);
67
+
68
+ // 兼容处理:保存已有回调,注册包装回调,避免覆盖其他模块
69
+ this.originalCallback = window['onNativeBridgeCallback'] || null;
70
+ const self = KeyAdapter;
71
+ window['onNativeBridgeCallback'] = function (action, data) {
72
+ if (self.originalCallback) {
73
+ self.originalCallback(action, data);
74
+ }
75
+ self.onMessage(action, data);
76
+ };
65
77
  KeyAdapter.keyboardBound = true;
66
78
  }
67
79
 
@@ -76,6 +88,11 @@ export class KeyAdapter {
76
88
  cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, KeyAdapter.onKeyboardUp, KeyAdapter);
77
89
  KeyAdapter.keyboardBound = false;
78
90
  }
91
+ // 兼容处理:销毁时恢复原有回调
92
+ if (KeyAdapter.originalCallback) {
93
+ window['onNativeBridgeCallback'] = KeyAdapter.originalCallback;
94
+ KeyAdapter.originalCallback = null;
95
+ }
79
96
  }
80
97
 
81
98
  private static onMessage(action, data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drgame-cc",
3
- "version": "1.0.67",
3
+ "version": "1.0.69",
4
4
  "description": "道然游戏适配包",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",