@chiyou/minigame-framework 1.4.2 → 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.2",
3
+ "version": "1.4.3",
4
4
  "description": "基于 Cocos Creator 3.x 的小游戏开发框架,支持多平台发布",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -89,6 +89,24 @@ export abstract class AbsPlatformAdapter extends Component{
89
89
  return { scene: this._coldStartScene, category: LaunchCategory.Other };
90
90
  }
91
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
+
92
110
  abstract isNavigateToRecentUseAvailable(callback: Function): void;
93
111
 
94
112
  abstract navigateToRecentUse(): void;
@@ -391,6 +391,23 @@ export class PlatformAdapterKuaiShou extends AbsPlatformAdapter {
391
391
  return { scene: this._coldStartScene, category: LaunchCategory.Other };
392
392
  }
393
393
 
394
+ /** 重写:快手热启动桌面判断也需调用 API */
395
+ public getWarmStartSceneInfo(): { scene: string; category: LaunchCategory } {
396
+ if (window["ks"] && window["ks"].isLaunchFromShortcut) {
397
+ if (window["ks"].isLaunchFromShortcut()) {
398
+ return { scene: this.warmStartScene, category: LaunchCategory.Desktop };
399
+ }
400
+ }
401
+
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 };
409
+ }
410
+
394
411
 
395
412
 
396
413
 
@@ -185,4 +185,22 @@ export class LifeCycleMgr extends BaseMgr {
185
185
 
186
186
  return this.getPlatformAdapter().getColdStartSceneInfo();
187
187
  }
188
+
189
+ /** 获取热启动场景信息 */
190
+ public getWarmStartSceneInfo(): { scene: string; category: string } | null {
191
+ if (this.getPlatformAdapter() === null) {
192
+ return null;
193
+ }
194
+
195
+ return this.getPlatformAdapter().getWarmStartSceneInfo();
196
+ }
197
+
198
+ /** 获取当前启动场景分类(兼容原 isLaunchFromXxx 逻辑) */
199
+ public getLaunchCategory(): string | null {
200
+ if (this.getPlatformAdapter() === null) {
201
+ return null;
202
+ }
203
+
204
+ return this.getPlatformAdapter().getLaunchCategory();
205
+ }
188
206
  }