22 lines
606 B
TypeScript
22 lines
606 B
TypeScript
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 开场图(仅 weapp;H5 的 getImageInfo 会走 CORS) */
|
||
export function prefetchHomeSplashAssets() {
|
||
if (played) return;
|
||
if (process.env.TARO_ENV !== 'weapp') return;
|
||
void Taro.getImageInfo({ src: HOME_SPLASH_BOTTLE_URL }).catch(() => {});
|
||
}
|