You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
AdLike2048/assets/mx/module/res/PreloadRules.ts

27 lines
1.0 KiB

import { LoadPriority } from './LoadPolicy';
/** 预加载规则:when 信号 → load 资源包/bundle */
export interface PreloadRule {
when: string;
load: string[];
priority: LoadPriority;
}
export const PRELOAD_RULES: PreloadRule[] = [
{ when: 'tabIntent:Home', load: ['bundle:home', 'ui:101'], priority: 'silent' },
{ when: 'tabIntent:Weapon', load: ['bundle:gemstone', 'bundle:icons'], priority: 'silent' },
{ when: 'panelOpen:Weapon', load: ['bundle:icons'], priority: 'silent' },
{ when: 'idleOnHome:5s', load: ['bundle:rank', 'bundle:gemstone', 'bundle:popBattle'], priority: 'silent' },
];
export function parseBattleScopedToken(token: string): { levelId?: number } {
if (token === 'currentChapter') {
return { levelId: gg.game?.CurentSelectLevelId ?? gg.data?.doc?.rankId ?? 1 };
}
if (token === 'selectedChapter') {
return { levelId: gg.game?.CurentSelectLevelId ?? 1 };
}
const m = /^chapter:(\d+)$/.exec(token);
if (m) return { levelId: Number(m[1]) };
return {};
}