@chiyou/minigame-framework 1.4.2 → 1.4.4
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
|
@@ -89,6 +89,29 @@ 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
|
+
|
|
110
|
+
/** 判断是否从指定分类启动(兼容原 isLaunchFromRecentUse/isLaunchFromDesktopShortcut/isLaunchFromAdvertisement) */
|
|
111
|
+
public isLaunchFrom(category: LaunchCategory): boolean {
|
|
112
|
+
return this.getLaunchCategory() === category;
|
|
113
|
+
}
|
|
114
|
+
|
|
92
115
|
abstract isNavigateToRecentUseAvailable(callback: Function): void;
|
|
93
116
|
|
|
94
117
|
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,31 @@ 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
|
+
}
|
|
206
|
+
|
|
207
|
+
/** 判断是否从指定分类启动 */
|
|
208
|
+
public isLaunchFrom(category: string): boolean {
|
|
209
|
+
if (this.getPlatformAdapter() === null) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return this.getPlatformAdapter().isLaunchFrom(category as any);
|
|
214
|
+
}
|
|
188
215
|
}
|