crh-jssdk 1.0.24 → 1.0.25

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.
@@ -274,17 +274,24 @@ var Bridge = /** @class */ (function () {
274
274
  // 确保bridge.init存在且是函数,且未初始化过
275
275
  // 在iOS环境下,App原生可能已经调用过bridge.init(),再次调用会报错"init called twice"
276
276
  // 使用全局标记 window._WVJBInitialized 检测App原生的初始化
277
- if (bridge && typeof bridge.init === 'function' && !_this._bridgeInitCalled && !window._WVJBInitialized) {
278
- bridge.init(function () {
279
- console.log('Bridge初始化完成');
277
+ if (bridge && typeof bridge.init === 'function') {
278
+ // 双保险:在调用init前再次检查全局标记,避免并发或多次进入时重复调用
279
+ if (!window._WVJBInitialized && !_this._bridgeInitCalled) {
280
+ window._WVJBInitialized = true;
281
+ bridge.init(function () {
282
+ console.log('Bridge初始化完成');
283
+ _this._bridgeInitCalled = true;
284
+ resolve();
285
+ });
286
+ }
287
+ else {
288
+ console.log('Bridge.init已调用过(全局标记或实例标记),跳过');
280
289
  resolve();
281
- });
282
- _this._bridgeInitCalled = true;
283
- window._WVJBInitialized = true;
290
+ }
284
291
  }
285
292
  else {
286
- // 如果bridge已经初始化过或init不存在,直接resolve
287
- console.log('Bridge已存在或init已调用,跳过初始化');
293
+ // 如果init不存在,直接resolve
294
+ console.log('Bridge.init不存在,跳过');
288
295
  resolve();
289
296
  }
290
297
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crh-jssdk",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "crh-jssdk",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {