Ship item nicknames, Tiny fear override, and ensure-match API.

Add 冰眼/蛇矛 aliases, correct Tiny fears to Hydra's Breath, and fix production match detail POST 405.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
voson
2026-08-01 04:05:48 +08:00
co-authored by Cursor
parent cafd0651b1
commit 820c3fb1f1
17 changed files with 656 additions and 53 deletions
+31 -4
View File
@@ -1657,8 +1657,14 @@ function selectInspectItem(key) {
function resolveItemDetail(key) {
if (!key) return null;
const shop = shopItem(key);
if (shop) return shop;
const metaExtra = (state.data.items_meta || {})[key] || null;
const aliases =
(shop?.aliases?.length && shop.aliases) ||
(metaExtra?.aliases?.length && metaExtra.aliases) ||
undefined;
if (shop) {
return aliases && !shop.aliases?.length ? { ...shop, aliases } : shop;
}
const items = state.data.hero_items?.items || {};
for (const row of Object.values(items)) {
if (row && row.key === key) {
@@ -1670,6 +1676,7 @@ function resolveItemDetail(key) {
components: metaExtra?.components || [],
builds_into: metaExtra?.builds_into || [],
desc_loc: metaExtra?.desc_loc || row.desc_loc || "",
...(aliases ? { aliases } : {}),
};
}
}
@@ -1681,6 +1688,7 @@ function resolveItemDetail(key) {
components: metaExtra.components || [],
builds_into: metaExtra.builds_into || [],
desc_loc: metaExtra.desc_loc || "",
...(aliases ? { aliases } : {}),
};
}
return { key, name_loc: key, components: [], builds_into: [] };
@@ -2992,7 +3000,8 @@ function buildFearItemsPanel(heroKey) {
const purchaseRate = hasPurchaseRate
? formatCounterRate(stats.purchase_rate)
: null;
const tipParts = [name, reason].filter(Boolean);
const aliasBit = itemAliasHint(key, (state.data.items_meta || {})[key]);
const tipParts = [`${name}${aliasBit}`, reason].filter(Boolean);
if (hasPurchaseRate) {
tipParts.push(`对阵购买率 ${purchaseRate}`);
if (stats.games) tipParts.push(`样本 ${stats.games}`);
@@ -3177,7 +3186,10 @@ function mountItemInspect(root, meta, { onPickItem, hideIcon = false } = {}) {
nameRow.className = "item-detail-name-row";
const title = document.createElement("h3");
title.className = "item-detail-name";
title.textContent = meta.name_loc || meta.key;
const aliasBit = itemAliasHint(meta.key, meta).replace(/^ \/ /, "");
title.textContent = aliasBit
? `${meta.name_loc || meta.key}${aliasBit}`
: meta.name_loc || meta.key;
nameRow.appendChild(title);
if (meta.cost != null) {
const cost = document.createElement("span");
@@ -3758,9 +3770,24 @@ function matchesItemQuery(key, meta) {
if (name.includes(q)) return true;
if (key.toLowerCase().includes(qLower)) return true;
if ((meta?.name || "").toLowerCase().includes(qLower)) return true;
for (const a of meta?.aliases || []) {
if (String(a).includes(q)) return true;
}
// Fall back to items_meta when shop row has no aliases yet.
const extra = (state.data.items_meta || {})[key];
for (const a of extra?.aliases || []) {
if (String(a).includes(q)) return true;
}
return false;
}
function itemAliasHint(key, meta) {
const fromMeta = meta?.aliases;
const fromIndex = (state.data.items_meta || {})[key]?.aliases;
const aliases = (fromMeta?.length ? fromMeta : fromIndex) || [];
return aliases.length ? " / " + aliases.join("、") : "";
}
function onShopItemClick(key) {
state.selectedItemKey = state.selectedItemKey === key ? null : key;
state.selectedKey = null;
@@ -3774,7 +3801,7 @@ function makeShopItemButton(key) {
btn.type = "button";
btn.className = "shop-item";
const cost = meta.cost != null ? ` ${meta.cost}` : "";
btn.title = `${meta.name_loc || key}${cost}`;
btn.title = `${meta.name_loc || key}${itemAliasHint(key, meta)}${cost}`;
if (key === state.selectedItemKey) btn.classList.add("selected");
if (!matchesItemQuery(key, meta)) btn.style.display = "none";