Show recent item patch notes under the shop detail panel.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3590,6 +3590,9 @@ function renderItemDetail() {
|
||||
render();
|
||||
},
|
||||
});
|
||||
|
||||
const patchPanel = buildItemPatchChangesPanel(meta.key);
|
||||
if (patchPanel) root.appendChild(patchPanel);
|
||||
}
|
||||
|
||||
// Stat-icon labels for patch hero_notes (icon field). Attr values map to the
|
||||
@@ -3772,6 +3775,62 @@ function buildPatchChangesPanel(heroKey) {
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/** Match shop/item key against a patch items or neutral_items entry via lookup. */
|
||||
function patchItemEntryForKey(entries, itemKey, lookup) {
|
||||
if (!itemKey || !entries?.length) return null;
|
||||
const itemsLookup = (lookup && lookup.items) || {};
|
||||
for (const entry of entries) {
|
||||
if (!entry || entry.is_general_note || entry.ability_id === -1) continue;
|
||||
const meta = itemsLookup[String(entry.ability_id)];
|
||||
if (meta && meta.key === itemKey) return entry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Recent patch notes for one item (shop detail). Null when none in window. */
|
||||
function buildItemPatchChangesPanel(itemKey) {
|
||||
const patches = state.data.patches || [];
|
||||
const details = state.data.patch_details || {};
|
||||
const lookup = state.data.patch_lookup || { items: {}, abilities: {}, heroes: {} };
|
||||
if (!itemKey || !patches.length) return null;
|
||||
|
||||
const blocks = [];
|
||||
for (const p of patches) {
|
||||
const det = details[p.version];
|
||||
if (!det) continue;
|
||||
const entry =
|
||||
patchItemEntryForKey(det.items, itemKey, lookup) ||
|
||||
patchItemEntryForKey(det.neutral_items, itemKey, lookup);
|
||||
if (!entry) continue;
|
||||
const notesHtml = renderNotesList(entry.ability_notes);
|
||||
if (!notesHtml) continue;
|
||||
const patchDate =
|
||||
formatAbsoluteTime(p.date || p.timestamp, { dateOnly: true }) ||
|
||||
p.date ||
|
||||
"";
|
||||
blocks.push(
|
||||
`<div class="patch-change-version">` +
|
||||
`<div class="patch-change-ver">${escapeHtml(p.version)}` +
|
||||
`<span class="patch-change-date">${escapeHtml(patchDate)}</span></div>` +
|
||||
notesHtml +
|
||||
`</div>`
|
||||
);
|
||||
}
|
||||
if (!blocks.length) return null;
|
||||
|
||||
const section = document.createElement("div");
|
||||
section.className = "item-detail-patches";
|
||||
const label = document.createElement("div");
|
||||
label.className = "craft-label";
|
||||
label.textContent = "改动";
|
||||
section.appendChild(label);
|
||||
const wrap = document.createElement("div");
|
||||
wrap.className = "patch-changes item-patch-changes";
|
||||
wrap.innerHTML = blocks.join("");
|
||||
section.appendChild(wrap);
|
||||
return section;
|
||||
}
|
||||
|
||||
function ensureDefaultPatch() {
|
||||
const patches = state.data?.patches || [];
|
||||
if (!patches.length) return;
|
||||
|
||||
Reference in New Issue
Block a user