Files
dukang/apps/mini-user/src/lib/home-splash.ts
T
2026-08-30 15:07:58 +08:00

22 lines
606 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Taro from '@tarojs/taro';
import { HOME_SPLASH_BOTTLE_URL } from '@dukang/shared-types';
/** 冷启动会话内是否已播过首页开场(进程级,切 Tab 不重播) */
let played = false;
export function hasHomeSplashPlayed() {
return played;
}
export function markHomeSplashPlayed() {
played = true;
}
/** 冷启动预拉 OSS 开场图(仅 weappH5 的 getImageInfo 会走 CORS */
export function prefetchHomeSplashAssets() {
if (played) return;
if (process.env.TARO_ENV !== 'weapp') return;
void Taro.getImageInfo({ src: HOME_SPLASH_BOTTLE_URL }).catch(() => {});
}