feat(store): cache official media and autoplay pack demos
Cache allowlisted official media so the in-game browser can load it locally. Match the official catalog snapshot and start pack demos muted and looping on entry.
This commit is contained in:
1 parent
e4227bb8ba
commit
5c9204c031
14 files changed
+645
-140
No files matched your search
@@ -7,15 +7,15 @@ const T = {
|
||||
premiumOff: '未开通', premiumLeft: '剩余 {days} 天',
|
||||
tabPacks: '高级载具', tabEagles: '金鹰', tabPremium: '高级账户', tabRedeem: '兑换码',
|
||||
search: '搜索礼包或载具', allCountries: '所有国家', allRanks: '所有等级', rank: '{rank} 级',
|
||||
sort: '商品排序', sortBest: '默认排序', sortPriceAsc: '价格从低到高', sortPriceDesc: '价格从高到低',
|
||||
sort: '商品排序', sortBest: '最畅销', sortNewest: '最新上架', sortPriceAsc: '价格从低到高', sortPriceDesc: '价格从高到低',
|
||||
containsEagles: '{n} 金鹰', containsSilver: '{n} 银狮', containsPremium: '{days} 天高级账户',
|
||||
buy: '购买', freeBuy: '老福爷付过了', owned: '已拥有', pickAccount: '请先选择账号',
|
||||
redeem: '兑换', codePlaceholder: '输入兑换码', empty: '没有符合条件的商品',
|
||||
featured: '推荐礼包', viewPack: '查看礼包', related: '更多推荐', packPrice: '礼包价格',
|
||||
featured: '推荐礼包', bestSeller: '畅销', viewPack: '查看礼包', related: '更多推荐', packPrice: '礼包价格',
|
||||
includes: '礼包内容', back: '返回目录', bonusTitle: '高级载具权益',
|
||||
bonusText: '驾驶高级载具可在战斗中获得额外的研发点和银狮。',
|
||||
footer: '购买后关闭商城窗口,机库会自动刷新。',
|
||||
gallery: '礼包媒体', cover: '封面', screenshot: '截图 {index}', screenshotPending: '官方截图尚未加载', previousMedia: '上一项', nextMedia: '下一项',
|
||||
gallery: '礼包媒体', cover: '封面', screenshot: '截图 {index}', screenshotLoading: '正在加载官方截图…', screenshotUnavailable: '官方截图暂不可用,当前显示游戏载具图。', previousMedia: '上一项', nextMedia: '下一项',
|
||||
video: '演示视频', videoNumber: '演示视频 {index}', playVideo: '播放演示',
|
||||
videoLoading: '正在加载演示视频…', videoUnavailable: '暂时无法播放官方视频,可以继续浏览其他素材。',
|
||||
cart: '购物车', addCart: '加入购物车', inCart: '已在购物车', confirmPurchase: '确认购买',
|
||||
@@ -29,15 +29,15 @@ const T = {
|
||||
premiumOff: 'Inactive', premiumLeft: '{days} days left',
|
||||
tabPacks: 'Premium vehicles', tabEagles: 'Golden Eagles', tabPremium: 'Premium account', tabRedeem: 'Redeem code',
|
||||
search: 'Search packs or vehicles', allCountries: 'All nations', allRanks: 'All ranks', rank: 'Rank {rank}',
|
||||
sort: 'Sort products', sortBest: 'Default order', sortPriceAsc: 'Price: low to high', sortPriceDesc: 'Price: high to low',
|
||||
sort: 'Sort products', sortBest: 'Top sellers', sortNewest: 'Newest', sortPriceAsc: 'Price: low to high', sortPriceDesc: 'Price: high to low',
|
||||
containsEagles: '{n} Golden Eagles', containsSilver: '{n} Silver Lions', containsPremium: '{days} days of Premium Account',
|
||||
buy: 'Buy', freeBuy: '老福爷付过了', owned: 'Owned', pickAccount: 'Pick an account first',
|
||||
redeem: 'Redeem', codePlaceholder: 'Enter a code', empty: 'Nothing matches the filters',
|
||||
featured: 'Featured packs', viewPack: 'View pack', related: 'Explore other packs', packPrice: 'Pack price',
|
||||
featured: 'Featured packs', bestSeller: 'Top seller', viewPack: 'View pack', related: 'Explore other packs', packPrice: 'Pack price',
|
||||
includes: 'Pack contents', back: 'Back to catalog', bonusTitle: 'Premium bonuses',
|
||||
bonusText: 'Premium vehicles earn extra research points and Silver Lions in battle.',
|
||||
footer: 'Close the store window after buying to refresh the hangar.',
|
||||
gallery: 'Pack media', cover: 'Cover', screenshot: 'Screenshot {index}', screenshotPending: 'Official screenshot has not loaded', previousMedia: 'Previous item', nextMedia: 'Next item',
|
||||
gallery: 'Pack media', cover: 'Cover', screenshot: 'Screenshot {index}', screenshotLoading: 'Loading official screenshot…', screenshotUnavailable: 'The official screenshot is unavailable. Showing game artwork.', previousMedia: 'Previous item', nextMedia: 'Next item',
|
||||
video: 'Demo video', videoNumber: 'Demo video {index}', playVideo: 'Play demo',
|
||||
videoLoading: 'Loading demo video…', videoUnavailable: 'The official video is unavailable. You can still browse the other media.',
|
||||
cart: 'Cart', addCart: 'Add to cart', inCart: 'In cart', confirmPurchase: 'Confirm purchase',
|
||||
@@ -156,14 +156,24 @@ function renderCatalog() {
|
||||
$('packFilters').hidden = !isPacks;
|
||||
const sort = $('sortSelect').value;
|
||||
const filtered = $('countryFilter').value || $('rankFilter').value || $('searchInput').value.trim();
|
||||
renderFeatured($('featured'), isPacks && !filtered && sort === 'best' ? state.products : [], openProduct);
|
||||
|
||||
const items = state.products.filter((p) => p.kind === currentTab && (!isPacks || matchesPack(p)));
|
||||
if (isPacks && sort === 'priceAsc') items.sort((a, b) => a.gjnCostCents - b.gjnCostCents);
|
||||
if (isPacks && sort === 'priceDesc') items.sort((a, b) => b.gjnCostCents - a.gjnCostCents);
|
||||
const grid = $('grid');
|
||||
grid.replaceChildren(...items.map((item) => productCard(item, checkout, openProduct)));
|
||||
if (!items.length) grid.append(makeElement('p', 'empty', t('empty')));
|
||||
if (isPacks) sortPacks(items, sort);
|
||||
|
||||
const cards = items.map((item) => productCard(item, checkout, openProduct));
|
||||
if (isPacks && !filtered && sort === 'best' && items.length) {
|
||||
const featured = items.find((item) => item.id === 'wto_pack_f-4s') || items[0];
|
||||
cards.unshift(featuredBanner(featured, openProduct));
|
||||
}
|
||||
if (!cards.length) cards.push(makeElement('p', 'empty', t('empty')));
|
||||
$('grid').replaceChildren(...cards);
|
||||
}
|
||||
|
||||
function sortPacks(items, mode) {
|
||||
const ids = WtoUi.storeOrder(mode === 'newest' ? 'newest' : 'best');
|
||||
const positions = new Map(ids.map((id, index) => [id, index]));
|
||||
items.sort((a, b) => (positions.get(a.id) ?? ids.length) - (positions.get(b.id) ?? ids.length));
|
||||
if (mode === 'priceAsc') items.sort((a, b) => a.gjnCostCents - b.gjnCostCents);
|
||||
if (mode === 'priceDesc') items.sort((a, b) => b.gjnCostCents - a.gjnCostCents);
|
||||
}
|
||||
|
||||
function openProduct(product) {
|
||||
|
||||
Reference in new issue
Block a user