Port modular price, product, and PWA fixes into boursecu
Sync live quote handling, SSE product images, store hours, file URL normalization, PWA icon cache, TV monitor, about software, SuperAdmin menu gates, price alerts, and related UX from modular while preserving boursecu branding and config constraints. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/** Lottieهای لوکال (`public/lottie`) — پیشدانلود تا مودال/لیست خالی نماند */
|
||||
|
||||
const LOTTIE_FILES = {
|
||||
logoutConfirm: 'lottie/logoutConfirm.json',
|
||||
emptyList: 'lottie/emptyList.json',
|
||||
goldBars: 'lottie/goldBars.json',
|
||||
} as const
|
||||
|
||||
export type LottieAssetKey = keyof typeof LOTTIE_FILES
|
||||
|
||||
const cache = new Map<LottieAssetKey, string>()
|
||||
|
||||
export function lottieSrc(key: LottieAssetKey): string {
|
||||
const base = import.meta.env.BASE_URL || '/'
|
||||
const path = `${base}${LOTTIE_FILES[key]}`
|
||||
return path.replace(/([^:]\/)\/+/g, '$1')
|
||||
}
|
||||
|
||||
export function getLottieData(key: LottieAssetKey): string | undefined {
|
||||
return cache.get(key)
|
||||
}
|
||||
|
||||
export async function preloadLottieAssets(): Promise<void> {
|
||||
const keys = Object.keys(LOTTIE_FILES) as LottieAssetKey[]
|
||||
await Promise.all(
|
||||
keys.map(async (key) => {
|
||||
if (cache.has(key)) return
|
||||
try {
|
||||
const res = await fetch(lottieSrc(key))
|
||||
if (!res.ok) return
|
||||
cache.set(key, await res.text())
|
||||
} catch {
|
||||
/* شبکه/آفلاین — بعداً از src لوکال میخواند */
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user