@chiyou/minigame-framework 1.4.1 → 1.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chiyou/minigame-framework",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "基于 Cocos Creator 3.x 的小游戏开发框架,支持多平台发布",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -1,15 +1,19 @@
1
1
  import { Component } from "cc";
2
2
  import { ScreenInfo } from "../../Definition/SystemDefinition";
3
3
  import { SystemMgr } from "../../Manager/SystemMgr";
4
+ import { LaunchCategory, LaunchSceneInfo } from "../../Definition/AnalyticsDefinition";
4
5
 
5
6
  export abstract class AbsPlatformAdapter extends Component{
6
7
 
7
8
  protected coldStartOptions: any = null;
8
9
  protected warmStartOptions: any = null;
9
10
 
10
- protected coldStartScene: string = "";
11
+ protected _coldStartScene: string = "";
11
12
  protected warmStartScene: string = "";
12
13
 
14
+ /** 启动场景分类表(子类在构造函数中初始化) */
15
+ protected launchSceneCategoryMap: Map<LaunchCategory, Set<string>> = new Map();
16
+
13
17
  protected isShareActive: boolean = false;
14
18
 
15
19
  protected systemMgr: SystemMgr = null;
@@ -74,15 +78,40 @@ export abstract class AbsPlatformAdapter extends Component{
74
78
 
75
79
  abstract offHide(fn: Function): void;
76
80
 
81
+ /** 获取冷启动场景信息 */
82
+ public getColdStartSceneInfo(): LaunchSceneInfo {
83
+ for (const [category, sceneSet] of this.launchSceneCategoryMap) {
84
+ if (category === LaunchCategory.Other) continue;
85
+ if (sceneSet.has(this._coldStartScene)) {
86
+ return { scene: this._coldStartScene, category };
87
+ }
88
+ }
89
+ return { scene: this._coldStartScene, category: LaunchCategory.Other };
90
+ }
91
+
92
+ /** 获取热启动场景信息 */
93
+ public getWarmStartSceneInfo(): LaunchSceneInfo {
94
+ for (const [category, sceneSet] of this.launchSceneCategoryMap) {
95
+ if (category === LaunchCategory.Other) continue;
96
+ if (sceneSet.has(this.warmStartScene)) {
97
+ return { scene: this.warmStartScene, category };
98
+ }
99
+ }
100
+ return { scene: this.warmStartScene, category: LaunchCategory.Other };
101
+ }
102
+
103
+ /** 获取当前启动场景分类(兼容原 isLaunchFromXxx 逻辑:冷启动优先,未命中再查热启动) */
104
+ public getLaunchCategory(): LaunchCategory {
105
+ const cold = this.getColdStartSceneInfo();
106
+ if (cold.category !== LaunchCategory.Other) return cold.category;
107
+ return this.getWarmStartSceneInfo().category;
108
+ }
109
+
77
110
  abstract isNavigateToRecentUseAvailable(callback: Function): void;
78
111
 
79
112
  abstract navigateToRecentUse(): void;
80
113
 
81
- abstract isLaunchFromRecentUse(): boolean;
82
-
83
- abstract isLaunchFromDesktopShortcut(): boolean;
84
114
 
85
- abstract isLaunchFromAdvertisement(): boolean;
86
115
 
87
116
  abstract checkSession(callback: (isValid: boolean) => void): void;
88
117
 
@@ -1,4 +1,5 @@
1
1
  import { AbsPlatformAdapter } from './AbsPlatformAdapter';
2
+ import { LaunchCategory } from "../../Definition/AnalyticsDefinition";
2
3
  import { LogUtils } from '../../Utils/LogUtils';
3
4
  import { FwkErrorCode } from '../../Definition/FwkErrorDefinition';
4
5
  import { AuthorizeResult, GetSettingResult } from '../../Definition/PrivacyDefinition';
@@ -7,6 +8,15 @@ import { ScreenInfo } from '../../Definition/SystemDefinition';
7
8
  export class PlatformAdapterBilibili extends AbsPlatformAdapter {
8
9
 
9
10
  static TAG: string = "PlatformAdapterBilibili";
11
+ protected launchSceneCategoryMap: Map<LaunchCategory, Set<string>> = new Map([
12
+ [LaunchCategory.RecentUse, new Set(["10001", "021036"])],
13
+ [LaunchCategory.Desktop, new Set(["10002"])],
14
+ [LaunchCategory.Search, new Set([])],
15
+ [LaunchCategory.Chat, new Set([])],
16
+ [LaunchCategory.Share, new Set([])],
17
+ [LaunchCategory.Ad, new Set([])],
18
+ [LaunchCategory.Other, new Set([])],
19
+ ]);
10
20
 
11
21
  // Common
12
22
  public init(): void {
@@ -391,18 +401,18 @@ export class PlatformAdapterBilibili extends AbsPlatformAdapter {
391
401
 
392
402
  public onGameColdStart(): void {
393
403
  this.coldStartOptions = null;
394
- this.coldStartScene = "";
404
+ this._coldStartScene = "";
395
405
 
396
406
  if (window["bl"] && window["bl"].getLaunchOptionsSync) {
397
407
  this.coldStartOptions = window["bl"].getLaunchOptionsSync();
398
408
  if (this.coldStartOptions !== null && this.coldStartOptions["scene"]) {
399
- this.coldStartScene = this.coldStartOptions["scene"];
409
+ this._coldStartScene = this.coldStartOptions["scene"];
400
410
  }
401
411
  }
402
412
 
403
413
  LogUtils.Instance.info(PlatformAdapterBilibili.TAG, "冷启动场景更新", {
404
414
  operation: "updateColdStartScene",
405
- scene: this.coldStartScene
415
+ scene: this._coldStartScene
406
416
  });
407
417
  }
408
418
 
@@ -508,38 +518,8 @@ export class PlatformAdapterBilibili extends AbsPlatformAdapter {
508
518
  });
509
519
  }
510
520
 
511
- public isLaunchFromRecentUse(): boolean {
512
- let recentUseSceneSet: Set<string> = new Set<string>([
513
- "10001",
514
- "021036",
515
- ]);
516
521
 
517
- let isLaunchFromRecentUse: boolean = recentUseSceneSet.has(this.coldStartScene) || recentUseSceneSet.has(this.warmStartScene);
518
- LogUtils.Instance.info(PlatformAdapterBilibili.TAG, "判断是否最近使用启动", {
519
- operation: "isLaunchFromRecentUse",
520
- result: isLaunchFromRecentUse
521
- });
522
-
523
- return isLaunchFromRecentUse;
524
- }
525
522
 
526
- public isLaunchFromDesktopShortcut(): boolean {
527
- let desktopShortcutSceneSet: Set<string> = new Set<string>([
528
- "10002",
529
- ]);
530
-
531
- let isLaunchFromDesktopShortcut: boolean = desktopShortcutSceneSet.has(this.coldStartScene) || desktopShortcutSceneSet.has(this.warmStartScene);
532
- LogUtils.Instance.info(PlatformAdapterBilibili.TAG, "判断是否桌面快捷方式启动", {
533
- operation: "isLaunchFromDesktopShortcut",
534
- result: isLaunchFromDesktopShortcut
535
- });
536
-
537
- return isLaunchFromDesktopShortcut;
538
- }
539
-
540
- public isLaunchFromAdvertisement(): boolean {
541
- return false;
542
- }
543
523
 
544
524
  public checkSession(callback: (isValid: boolean) => void): void {
545
525
  if (window["bl"] && window["bl"].checkSession) {
@@ -1,4 +1,5 @@
1
1
  import { game } from 'cc';
2
+ import { LaunchCategory } from "../../Definition/AnalyticsDefinition";
2
3
  import { AbsPlatformAdapter } from './AbsPlatformAdapter';
3
4
  import { LogUtils } from '../../Utils/LogUtils';
4
5
  import { FwkErrorCode } from '../../Definition/FwkErrorDefinition';
@@ -9,6 +10,16 @@ export class PlatformAdapterDesktopBrowser extends AbsPlatformAdapter {
9
10
 
10
11
  static TAG: string = "PlatformAdapterDesktopBrowser";
11
12
 
13
+ protected launchSceneCategoryMap: Map<LaunchCategory, Set<string>> = new Map([
14
+ [LaunchCategory.RecentUse, new Set()],
15
+ [LaunchCategory.Desktop, new Set()],
16
+ [LaunchCategory.Search, new Set()],
17
+ [LaunchCategory.Chat, new Set()],
18
+ [LaunchCategory.Share, new Set()],
19
+ [LaunchCategory.Ad, new Set()],
20
+ [LaunchCategory.Other, new Set()],
21
+ ]);
22
+
12
23
  // Common
13
24
  public init(): void {
14
25
 
@@ -156,11 +167,11 @@ export class PlatformAdapterDesktopBrowser extends AbsPlatformAdapter {
156
167
 
157
168
  public onGameColdStart(): void {
158
169
  this.coldStartOptions = null;
159
- this.coldStartScene = "";
170
+ this._coldStartScene = "";
160
171
 
161
172
  LogUtils.Instance.info(PlatformAdapterDesktopBrowser.TAG, "冷启动场景更新", {
162
173
  operation: "updateColdStartScene",
163
- scene: this.coldStartScene
174
+ scene: this._coldStartScene
164
175
  });
165
176
  }
166
177
 
@@ -210,17 +221,8 @@ export class PlatformAdapterDesktopBrowser extends AbsPlatformAdapter {
210
221
 
211
222
  }
212
223
 
213
- public isLaunchFromRecentUse(): boolean {
214
- return false;
215
- }
216
224
 
217
- public isLaunchFromDesktopShortcut(): boolean {
218
- return false;
219
- }
220
225
 
221
- public isLaunchFromAdvertisement(): boolean {
222
- return false;
223
- }
224
226
 
225
227
  public checkSession(callback: (isValid: boolean) => void): void {
226
228
  // Browser不支持这个方法,直接返回true
@@ -1,4 +1,5 @@
1
1
  import { AbsPlatformAdapter } from './AbsPlatformAdapter';
2
+ import { LaunchCategory } from "../../Definition/AnalyticsDefinition";
2
3
  import { LogUtils } from '../../Utils/LogUtils';
3
4
  import { FwkErrorCode } from '../../Definition/FwkErrorDefinition';
4
5
  import { AuthorizeResult, GetSettingResult } from '../../Definition/PrivacyDefinition';
@@ -11,6 +12,15 @@ class DouYinPlatformBusiness {
11
12
  export class PlatformAdapterDouYin extends AbsPlatformAdapter {
12
13
 
13
14
  static TAG: string = "PlatformAdapterDouYin";
15
+ protected launchSceneCategoryMap: Map<LaunchCategory, Set<string>> = new Map([
16
+ [LaunchCategory.RecentUse, new Set(["021036", "021012", "101036", "011004", "181003", "061004"])],
17
+ [LaunchCategory.Desktop, new Set(["021020", "101020", "181020", "141020", "991020"])],
18
+ [LaunchCategory.Search, new Set([])],
19
+ [LaunchCategory.Chat, new Set([])],
20
+ [LaunchCategory.Share, new Set([])],
21
+ [LaunchCategory.Ad, new Set(["025001", "235001", "016001", "016002", "016003", "105001"])],
22
+ [LaunchCategory.Other, new Set([])],
23
+ ]);
14
24
 
15
25
  private portalGame: any = null;
16
26
 
@@ -408,18 +418,18 @@ export class PlatformAdapterDouYin extends AbsPlatformAdapter {
408
418
 
409
419
  public onGameColdStart(): void {
410
420
  this.coldStartOptions = null;
411
- this.coldStartScene = "";
421
+ this._coldStartScene = "";
412
422
 
413
423
  if (window["tt"] && window["tt"].getLaunchOptionsSync) {
414
424
  this.coldStartOptions = window["tt"].getLaunchOptionsSync();
415
425
  if (this.coldStartOptions !== null && this.coldStartOptions["scene"]) {
416
- this.coldStartScene = this.coldStartOptions["scene"];
426
+ this._coldStartScene = this.coldStartOptions["scene"];
417
427
  }
418
428
  }
419
429
 
420
430
  LogUtils.Instance.info(PlatformAdapterDouYin.TAG, "冷启动场景更新", {
421
431
  operation: "updateColdStartScene",
422
- scene: this.coldStartScene
432
+ scene: this._coldStartScene
423
433
  });
424
434
  }
425
435
 
@@ -524,54 +534,8 @@ export class PlatformAdapterDouYin extends AbsPlatformAdapter {
524
534
  });
525
535
  }
526
536
 
527
- public isLaunchFromRecentUse(): boolean {
528
- let recentUseSceneSet: Set<string> = new Set<string>([
529
- "021036",
530
- "021012",
531
- "101036",
532
- "011004",
533
- "181003",
534
- "061004",
535
- ]);
536
-
537
- let isLaunchFromRecentUse: boolean = recentUseSceneSet.has(this.coldStartScene) || recentUseSceneSet.has(this.warmStartScene);
538
- LogUtils.Instance.info(PlatformAdapterDouYin.TAG, "判断是否最近使用启动", {
539
- operation: "isLaunchFromRecentUse",
540
- result: isLaunchFromRecentUse
541
- });
542
- return isLaunchFromRecentUse;
543
- }
544
-
545
- public isLaunchFromDesktopShortcut(): boolean {
546
- let desktopShortcutSceneSet: Set<string> = new Set<string>([
547
- "021020",
548
- "101020",
549
- "181020",
550
- "141020",
551
- "991020",
552
- ]);
553
-
554
- let isLaunchFromDesktopShortcut: boolean = desktopShortcutSceneSet.has(this.coldStartScene) || desktopShortcutSceneSet.has(this.warmStartScene);
555
- LogUtils.Instance.info(PlatformAdapterDouYin.TAG, "判断是否桌面快捷方式启动", {
556
- operation: "isLaunchFromDesktopShortcut",
557
- result: isLaunchFromDesktopShortcut
558
- });
559
- return isLaunchFromDesktopShortcut;
560
- }
561
537
 
562
- public isLaunchFromAdvertisement(): boolean {
563
- let advertisementSceneSet: Set<string> = new Set<string>([
564
- "025001", "235001", "016001",
565
- "016002", "016003", "105001",
566
- ]);
567
538
 
568
- let isLaunchFromAdvertisement: boolean = advertisementSceneSet.has(this.coldStartScene);
569
- LogUtils.Instance.info(PlatformAdapterDouYin.TAG, "判断是否广告启动", {
570
- operation: "isLaunchFromAdvertisement",
571
- result: isLaunchFromAdvertisement
572
- });
573
- return isLaunchFromAdvertisement;
574
- }
575
539
 
576
540
  public checkSession(callback: (isValid: boolean) => void): void {
577
541
  if (window["tt"] && window["tt"].checkSession) {
@@ -1,4 +1,5 @@
1
1
  import { AbsPlatformAdapter } from './AbsPlatformAdapter';
2
+ import { LaunchCategory } from "../../Definition/AnalyticsDefinition";
2
3
  import { LogUtils } from '../../Utils/LogUtils';
3
4
  import { FwkErrorCode } from '../../Definition/FwkErrorDefinition';
4
5
  import { AuthorizeResult, GetSettingResult } from '../../Definition/PrivacyDefinition';
@@ -6,6 +7,15 @@ import { ScreenInfo } from '../../Definition/SystemDefinition';
6
7
 
7
8
  export class PlatformAdapterHonor extends AbsPlatformAdapter {
8
9
  static TAG: string = "PlatformAdapterHonor";
10
+ protected launchSceneCategoryMap: Map<LaunchCategory, Set<string>> = new Map([
11
+ [LaunchCategory.RecentUse, new Set([])],
12
+ [LaunchCategory.Desktop, new Set([])],
13
+ [LaunchCategory.Search, new Set([])],
14
+ [LaunchCategory.Chat, new Set([])],
15
+ [LaunchCategory.Share, new Set([])],
16
+ [LaunchCategory.Ad, new Set([])],
17
+ [LaunchCategory.Other, new Set([])],
18
+ ]);
9
19
 
10
20
  // Common
11
21
  public init(): void {
@@ -289,7 +299,7 @@ export class PlatformAdapterHonor extends AbsPlatformAdapter {
289
299
 
290
300
  public onGameColdStart(): void {
291
301
  this.coldStartOptions = null;
292
- this.coldStartScene = "";
302
+ this._coldStartScene = "";
293
303
  }
294
304
 
295
305
  public onGameShowCallback(warmStartOptions: any): void {
@@ -341,17 +351,8 @@ export class PlatformAdapterHonor extends AbsPlatformAdapter {
341
351
 
342
352
  }
343
353
 
344
- public isLaunchFromRecentUse(): boolean {
345
- return false;
346
- }
347
354
 
348
- public isLaunchFromDesktopShortcut(): boolean {
349
- return false;
350
- }
351
355
 
352
- public isLaunchFromAdvertisement(): boolean {
353
- return false;
354
- }
355
356
 
356
357
  public checkSession(callback: (isValid: boolean) => void): void {
357
358
  // Honor不支持这个方法,直接返回true
@@ -1,4 +1,5 @@
1
1
  import { AbsPlatformAdapter } from './AbsPlatformAdapter';
2
+ import { LaunchCategory } from "../../Definition/AnalyticsDefinition";
2
3
  import { LogUtils } from '../../Utils/LogUtils';
3
4
  import { AuthorizeResult, GetSettingResult } from '../../Definition/PrivacyDefinition';
4
5
  import { PlatformID, ScreenInfo } from '../../Definition/SystemDefinition';
@@ -6,6 +7,15 @@ import { FwkErrorCode } from '../../Definition/FwkErrorDefinition';
6
7
 
7
8
  export class PlatformAdapterHuaWei extends AbsPlatformAdapter {
8
9
  static TAG: string = "PlatformAdapterHuaWei";
10
+ protected launchSceneCategoryMap: Map<LaunchCategory, Set<string>> = new Map([
11
+ [LaunchCategory.RecentUse, new Set([])],
12
+ [LaunchCategory.Desktop, new Set([])],
13
+ [LaunchCategory.Search, new Set([])],
14
+ [LaunchCategory.Chat, new Set([])],
15
+ [LaunchCategory.Share, new Set([])],
16
+ [LaunchCategory.Ad, new Set([])],
17
+ [LaunchCategory.Other, new Set([])],
18
+ ]);
9
19
 
10
20
  // Common
11
21
  public init(): void {
@@ -287,7 +297,7 @@ export class PlatformAdapterHuaWei extends AbsPlatformAdapter {
287
297
 
288
298
  public onGameColdStart(): void {
289
299
  this.coldStartOptions = null;
290
- this.coldStartScene = "";
300
+ this._coldStartScene = "";
291
301
  }
292
302
 
293
303
  public onGameShowCallback(warmStartOptions: any): void {
@@ -339,17 +349,8 @@ export class PlatformAdapterHuaWei extends AbsPlatformAdapter {
339
349
 
340
350
  }
341
351
 
342
- public isLaunchFromRecentUse(): boolean {
343
- return false;
344
- }
345
352
 
346
- public isLaunchFromDesktopShortcut(): boolean {
347
- return false;
348
- }
349
353
 
350
- public isLaunchFromAdvertisement(): boolean {
351
- return false;
352
- }
353
354
 
354
355
  public checkSession(callback: (isValid: boolean) => void): void {
355
356
  // HuaWei不支持这个方法,直接返回true
@@ -1,4 +1,5 @@
1
1
  import { AbsPlatformAdapter } from './AbsPlatformAdapter';
2
+ import { LaunchCategory } from "../../Definition/AnalyticsDefinition";
2
3
  import { LogUtils } from '../../Utils/LogUtils';
3
4
  import { FwkErrorCode } from '../../Definition/FwkErrorDefinition';
4
5
  import { AuthorizeResult, GetSettingResult } from '../../Definition/PrivacyDefinition';
@@ -8,6 +9,16 @@ export class PlatformAdapterKuaiShou extends AbsPlatformAdapter {
8
9
 
9
10
  static TAG: string = "PlatformAdapterKuaiShou";
10
11
 
12
+ protected launchSceneCategoryMap: Map<LaunchCategory, Set<string>> = new Map([
13
+ [LaunchCategory.RecentUse, new Set(["sidebar_new", "sidebar_miniprogram", "profile"])],
14
+ [LaunchCategory.Desktop, new Set()],
15
+ [LaunchCategory.Search, new Set()],
16
+ [LaunchCategory.Chat, new Set()],
17
+ [LaunchCategory.Share, new Set()],
18
+ [LaunchCategory.Ad, new Set(["dsp"])],
19
+ [LaunchCategory.Other, new Set()],
20
+ ]);
21
+
11
22
  // Common
12
23
  public init(): void {
13
24
 
@@ -292,18 +303,18 @@ export class PlatformAdapterKuaiShou extends AbsPlatformAdapter {
292
303
 
293
304
  public onGameColdStart(): void {
294
305
  this.coldStartOptions = null;
295
- this.coldStartScene = "";
306
+ this._coldStartScene = "";
296
307
 
297
308
  if (window["ks"] && window["ks"].getLaunchOptionsSync) {
298
309
  this.coldStartOptions = window["ks"].getLaunchOptionsSync();
299
310
  if (this.coldStartOptions !== null && this.coldStartOptions["from"]) {
300
- this.coldStartScene = this.coldStartOptions["from"];
311
+ this._coldStartScene = this.coldStartOptions["from"];
301
312
  }
302
313
  }
303
314
 
304
315
  LogUtils.Instance.info(PlatformAdapterKuaiShou.TAG, "冷启动场景更新", {
305
316
  operation: "updateColdStartScene",
306
- scene: this.coldStartScene
317
+ scene: this._coldStartScene
307
318
  });
308
319
  }
309
320
 
@@ -361,44 +372,45 @@ export class PlatformAdapterKuaiShou extends AbsPlatformAdapter {
361
372
 
362
373
  }
363
374
 
364
- public isLaunchFromRecentUse(): boolean {
365
- let recentUseSceneSet: Set<string> = new Set<string>([
366
- "sidebar_new",
367
- "sidebar_miniprogram",
368
- "profile",
369
- ]);
370
- let isLaunchFromRecentUse: boolean = recentUseSceneSet.has(this.coldStartScene) || recentUseSceneSet.has(this.warmStartScene);
371
- LogUtils.Instance.info(PlatformAdapterKuaiShou.TAG, "判断是否最近使用启动", {
372
- operation: "isLaunchFromRecentUse",
373
- result: isLaunchFromRecentUse
374
- });
375
- return isLaunchFromRecentUse;
375
+ /** 重写:快手桌面判断需调用 API */
376
+ public getColdStartSceneInfo(): { scene: string; category: LaunchCategory } {
377
+ // 先用 API 检查是否从桌面启动
378
+ if (window["ks"] && window["ks"].isLaunchFromShortcut) {
379
+ if (window["ks"].isLaunchFromShortcut()) {
380
+ return { scene: this._coldStartScene, category: LaunchCategory.Desktop };
381
+ }
382
+ }
383
+
384
+ // 否则走通用逻辑(Map 查找)
385
+ for (const [category, sceneSet] of this.launchSceneCategoryMap) {
386
+ if (category === LaunchCategory.Other) continue;
387
+ if (sceneSet.has(this._coldStartScene)) {
388
+ return { scene: this._coldStartScene, category };
389
+ }
390
+ }
391
+ return { scene: this._coldStartScene, category: LaunchCategory.Other };
376
392
  }
377
393
 
378
- public isLaunchFromDesktopShortcut(): boolean {
379
- let isLaunchFromDesktopShortcut: boolean = false;
394
+ /** 重写:快手热启动桌面判断也需调用 API */
395
+ public getWarmStartSceneInfo(): { scene: string; category: LaunchCategory } {
380
396
  if (window["ks"] && window["ks"].isLaunchFromShortcut) {
381
- isLaunchFromDesktopShortcut = window["ks"].isLaunchFromShortcut();
397
+ if (window["ks"].isLaunchFromShortcut()) {
398
+ return { scene: this.warmStartScene, category: LaunchCategory.Desktop };
399
+ }
382
400
  }
383
- LogUtils.Instance.info(PlatformAdapterKuaiShou.TAG, "判断是否桌面快捷方式启动", {
384
- operation: "isLaunchFromDesktopShortcut",
385
- result: isLaunchFromDesktopShortcut
386
- });
387
- return isLaunchFromDesktopShortcut;
388
- }
389
401
 
390
- public isLaunchFromAdvertisement(): boolean {
391
- let advertisementSceneSet: Set<string> = new Set<string>([
392
- "dsp",
393
- ]);
394
- let isLaunchFromAdvertisement: boolean = advertisementSceneSet.has(this.coldStartScene);
395
- LogUtils.Instance.info(PlatformAdapterKuaiShou.TAG, "判断是否广告启动", {
396
- operation: "isLaunchFromAdvertisement",
397
- result: isLaunchFromAdvertisement
398
- });
399
- return isLaunchFromAdvertisement;
402
+ for (const [category, sceneSet] of this.launchSceneCategoryMap) {
403
+ if (category === LaunchCategory.Other) continue;
404
+ if (sceneSet.has(this.warmStartScene)) {
405
+ return { scene: this.warmStartScene, category };
406
+ }
407
+ }
408
+ return { scene: this.warmStartScene, category: LaunchCategory.Other };
400
409
  }
401
410
 
411
+
412
+
413
+
402
414
  public checkSession(callback: (isValid: boolean) => void): void {
403
415
  if (window["ks"] && window["ks"].checkSession) {
404
416
  window["ks"].checkSession({
@@ -1,4 +1,5 @@
1
1
  import { AbsPlatformAdapter } from './AbsPlatformAdapter';
2
+ import { LaunchCategory } from "../../Definition/AnalyticsDefinition";
2
3
  import { LogUtils } from '../../Utils/LogUtils';
3
4
  import { FwkErrorCode } from '../../Definition/FwkErrorDefinition';
4
5
  import { AuthorizeResult, GetSettingResult } from '../../Definition/PrivacyDefinition';
@@ -6,6 +7,15 @@ import { ScreenInfo } from '../../Definition/SystemDefinition';
6
7
 
7
8
  export class PlatformAdapterOppo extends AbsPlatformAdapter {
8
9
  static TAG: string = "PlatformAdapterOppo";
10
+ protected launchSceneCategoryMap: Map<LaunchCategory, Set<string>> = new Map([
11
+ [LaunchCategory.RecentUse, new Set([])],
12
+ [LaunchCategory.Desktop, new Set([])],
13
+ [LaunchCategory.Search, new Set([])],
14
+ [LaunchCategory.Chat, new Set([])],
15
+ [LaunchCategory.Share, new Set([])],
16
+ [LaunchCategory.Ad, new Set([])],
17
+ [LaunchCategory.Other, new Set([])],
18
+ ]);
9
19
 
10
20
  // Common
11
21
  public init(): void {
@@ -278,7 +288,7 @@ export class PlatformAdapterOppo extends AbsPlatformAdapter {
278
288
 
279
289
  public onGameColdStart(): void {
280
290
  this.coldStartOptions = null;
281
- this.coldStartScene = "";
291
+ this._coldStartScene = "";
282
292
 
283
293
  if (window["qg"] && window["qg"].getLaunchOptionsSync) {
284
294
  this.coldStartOptions = window["qg"].getLaunchOptionsSync();
@@ -326,17 +336,8 @@ export class PlatformAdapterOppo extends AbsPlatformAdapter {
326
336
 
327
337
  }
328
338
 
329
- public isLaunchFromRecentUse(): boolean {
330
- return false;
331
- }
332
339
 
333
- public isLaunchFromDesktopShortcut(): boolean {
334
- return false;
335
- }
336
340
 
337
- public isLaunchFromAdvertisement(): boolean {
338
- return false;
339
- }
340
341
 
341
342
  public checkSession(callback: (isValid: boolean) => void): void {
342
343
  // Oppo不支持这个方法,直接返回true
@@ -1,4 +1,5 @@
1
1
  import { AbsPlatformAdapter } from './AbsPlatformAdapter';
2
+ import { LaunchCategory } from "../../Definition/AnalyticsDefinition";
2
3
  import { LogUtils } from '../../Utils/LogUtils';
3
4
  import { FwkErrorCode } from '../../Definition/FwkErrorDefinition';
4
5
  import { AuthorizeResult, GetSettingResult } from '../../Definition/PrivacyDefinition';
@@ -7,6 +8,15 @@ import { ScreenInfo } from '../../Definition/SystemDefinition';
7
8
  export class PlatformAdapterTapTap extends AbsPlatformAdapter {
8
9
 
9
10
  static TAG: string = "PlatformAdapterTapTap";
11
+ protected launchSceneCategoryMap: Map<LaunchCategory, Set<string>> = new Map([
12
+ [LaunchCategory.RecentUse, new Set([])],
13
+ [LaunchCategory.Desktop, new Set([])],
14
+ [LaunchCategory.Search, new Set([])],
15
+ [LaunchCategory.Chat, new Set([])],
16
+ [LaunchCategory.Share, new Set([])],
17
+ [LaunchCategory.Ad, new Set([])],
18
+ [LaunchCategory.Other, new Set([])],
19
+ ]);
10
20
 
11
21
  // Common
12
22
  public init(): void {
@@ -316,18 +326,18 @@ export class PlatformAdapterTapTap extends AbsPlatformAdapter {
316
326
 
317
327
  public onGameColdStart(): void {
318
328
  this.coldStartOptions = null;
319
- this.coldStartScene = "";
329
+ this._coldStartScene = "";
320
330
 
321
331
  if (window["tap"] && window["tap"].getLaunchOptionsSync) {
322
332
  this.coldStartOptions = window["tap"].getLaunchOptionsSync();
323
333
  if (this.coldStartOptions !== null && this.coldStartOptions["scene"]) {
324
- this.coldStartScene = this.coldStartOptions["scene"].toString();
334
+ this._coldStartScene = this.coldStartOptions["scene"].toString();
325
335
  }
326
336
  }
327
337
 
328
338
  LogUtils.Instance.info(PlatformAdapterTapTap.TAG, "冷启动场景更新", {
329
339
  operation: "updateColdStartScene",
330
- scene: this.coldStartScene
340
+ scene: this._coldStartScene
331
341
  });
332
342
  }
333
343
 
@@ -389,17 +399,8 @@ export class PlatformAdapterTapTap extends AbsPlatformAdapter {
389
399
 
390
400
  }
391
401
 
392
- public isLaunchFromRecentUse(): boolean {
393
- return false;
394
- }
395
402
 
396
- public isLaunchFromDesktopShortcut(): boolean {
397
- return false;
398
- }
399
403
 
400
- public isLaunchFromAdvertisement(): boolean {
401
- return false;
402
- }
403
404
 
404
405
  public checkSession(callback: (isValid: boolean) => void): void {
405
406
  if (window["tap"] && window["tap"].checkSession) {