v0.6.2: hero page site foot, dismiss detail on empty click, drop patches version footer.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -56,7 +56,7 @@ from shared.paths import (
|
||||
from seo_prerender import DEFAULT_SITE_ORIGIN, write_seo_bundle
|
||||
from serve_relations import WEB_DIR, build_payload
|
||||
|
||||
SITE_VERSION = "0.6.1"
|
||||
SITE_VERSION = "0.6.2"
|
||||
DEFAULT_OSS_BASE = "https://climperor.oss-cn-shanghai.aliyuncs.com"
|
||||
|
||||
|
||||
|
||||
+78
-17
@@ -76,6 +76,52 @@ function siteVersionLabel() {
|
||||
return v ? `v${v}` : "";
|
||||
}
|
||||
|
||||
/** Latest fetched_at among volatile site datasets (for hero detail footer). */
|
||||
function siteDataFetchedAt() {
|
||||
if (!state.data) return null;
|
||||
const candidates = [];
|
||||
const push = (v) => {
|
||||
const ms = parseTimeMs(v);
|
||||
if (Number.isFinite(ms)) candidates.push(ms);
|
||||
};
|
||||
push(state.data.hero_stats?.fetched_at);
|
||||
push(state.data.leaderboards?.fetched_at);
|
||||
push(state.data.hero_matches?.meta?.fetched_at);
|
||||
push(state.data.pro_matches?.meta?.fetched_at);
|
||||
push(state.data.streamers?.fetched_at);
|
||||
push(state.data.stratz_hero_meta?.fetched_at);
|
||||
push(state.data.stratz_matchup_tops?.fetched_at);
|
||||
push(state.data.hero_items?.meta?.fetched_at);
|
||||
if (!candidates.length) return null;
|
||||
return new Date(Math.max(...candidates)).toISOString();
|
||||
}
|
||||
|
||||
function renderHeroesSiteFoot() {
|
||||
const el = $("#heroes-site-foot");
|
||||
if (!el) return;
|
||||
// Hide under the detail panel when a hero is selected.
|
||||
const show = state.page === "heroes" && !state.selectedKey;
|
||||
el.classList.toggle("hidden", !show);
|
||||
if (!show) {
|
||||
el.textContent = "";
|
||||
el.removeAttribute("title");
|
||||
el.setAttribute("aria-hidden", "true");
|
||||
return;
|
||||
}
|
||||
const parts = [];
|
||||
const ver = siteVersionLabel();
|
||||
if (ver) parts.push(ver);
|
||||
const fetchedAt = siteDataFetchedAt();
|
||||
const fetchedInfo = fetchedAt
|
||||
? formatFriendlyTime(fetchedAt)
|
||||
: { text: "", title: "" };
|
||||
if (fetchedInfo.text) parts.push(`更新于 ${fetchedInfo.text}`);
|
||||
el.textContent = parts.join(" · ");
|
||||
if (fetchedInfo.title) el.title = fetchedInfo.title;
|
||||
else el.removeAttribute("title");
|
||||
el.setAttribute("aria-hidden", parts.length ? "false" : "true");
|
||||
}
|
||||
|
||||
function siteOrigin() {
|
||||
const configured = typeof SITE_ORIGIN === "string" ? SITE_ORIGIN.trim().replace(/\/+$/, "") : "";
|
||||
if (configured) return configured;
|
||||
@@ -208,14 +254,6 @@ function clearSeoPrerender() {
|
||||
if (el) el.remove();
|
||||
}
|
||||
|
||||
function renderPatchesSiteVersion() {
|
||||
const el = $("#patches-site-version");
|
||||
if (!el) return;
|
||||
const label = siteVersionLabel();
|
||||
el.textContent = label;
|
||||
el.setAttribute("aria-hidden", label ? "false" : "true");
|
||||
}
|
||||
|
||||
const state = {
|
||||
data: null,
|
||||
page: "heroes", // heroes | rankings | matches | streamers | trends | mechanics | items | patches
|
||||
@@ -385,6 +423,15 @@ function onHeroClick(key) {
|
||||
render();
|
||||
}
|
||||
|
||||
function clearHeroDetail() {
|
||||
if (!state.selectedKey) return false;
|
||||
state.selectedKey = null;
|
||||
state.inspect = null;
|
||||
syncStateToUrl();
|
||||
render();
|
||||
return true;
|
||||
}
|
||||
|
||||
function renderTagbar() {
|
||||
const bar = $("#tagbar");
|
||||
if (!bar) return;
|
||||
@@ -3471,7 +3518,6 @@ function renderPatches() {
|
||||
if (select) select.innerHTML = "";
|
||||
if (verEl) verEl.textContent = "";
|
||||
root.innerHTML = '<div class="patches-empty">暂无版本数据</div>';
|
||||
renderPatchesSiteVersion();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3506,7 +3552,6 @@ function renderPatches() {
|
||||
const det = details[state.selectedPatch];
|
||||
if (!det) {
|
||||
root.innerHTML = '<div class="patches-empty">该版本详情暂未收录</div>';
|
||||
renderPatchesSiteVersion();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3539,7 +3584,6 @@ function renderPatches() {
|
||||
.map((h) => renderHeroEntry(h, lookup))
|
||||
.join("");
|
||||
renderPatchSection(root, "英雄改动", heroesHtml);
|
||||
renderPatchesSiteVersion();
|
||||
}
|
||||
|
||||
function escapeHtml(s) {
|
||||
@@ -5612,6 +5656,7 @@ function render() {
|
||||
} else {
|
||||
renderPatches();
|
||||
}
|
||||
renderHeroesSiteFoot();
|
||||
updateDocumentMeta();
|
||||
}
|
||||
|
||||
@@ -5779,6 +5824,26 @@ function bindPageChrome() {
|
||||
});
|
||||
}
|
||||
|
||||
/** Click empty area above role tags (board remainder / toolbar chrome) to dismiss detail. */
|
||||
function bindHeroesDismiss() {
|
||||
const view = $("#heroes-view");
|
||||
if (view) {
|
||||
view.addEventListener("click", (e) => {
|
||||
if (state.page !== "heroes" || !state.selectedKey) return;
|
||||
if (e.target.closest(".hero")) return;
|
||||
clearHeroDetail();
|
||||
});
|
||||
}
|
||||
const toolbar = $("#heroes-toolbar");
|
||||
if (toolbar) {
|
||||
toolbar.addEventListener("click", (e) => {
|
||||
if (state.page !== "heroes" || !state.selectedKey) return;
|
||||
if (e.target.closest("button, a, input, select, textarea, label")) return;
|
||||
clearHeroDetail();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// mobile-gate.js sets this before paint; skip desktop data boot on phones/tablets.
|
||||
if (typeof window !== "undefined" && window.__CLIMPEROR_MOBILE__) return;
|
||||
@@ -5796,12 +5861,7 @@ async function main() {
|
||||
renderBoard();
|
||||
return;
|
||||
}
|
||||
if (state.selectedKey) {
|
||||
state.selectedKey = null;
|
||||
state.inspect = null;
|
||||
syncStateToUrl();
|
||||
render();
|
||||
}
|
||||
clearHeroDetail();
|
||||
return;
|
||||
}
|
||||
if (state.itemQuery && document.activeElement === $("#q-item")) {
|
||||
@@ -5839,6 +5899,7 @@ async function main() {
|
||||
);
|
||||
bindSearch();
|
||||
bindPageChrome();
|
||||
bindHeroesDismiss();
|
||||
const brandLogo = document.querySelector(".brand-logo");
|
||||
if (brandLogo) brandLogo.src = assetUrl("/ui-icon/dota2_logo_wordmark.png");
|
||||
const favicon = document.querySelector('link[rel="icon"]');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Local defaults; production export overwrites via export_relations_site.py. */
|
||||
var SITE_VERSION = "0.6.1";
|
||||
var SITE_VERSION = "0.6.2";
|
||||
var SITE_ORIGIN = "";
|
||||
var ABILITY_VIDEO_BASE = "";
|
||||
var STATIC_ASSET_BASE = "";
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
}
|
||||
</script>
|
||||
<link rel="icon" href="/ui-icon/dota2_logo.png" type="image/png" />
|
||||
<link rel="stylesheet" href="/style.css?v=0.6.1" />
|
||||
<script src="/mobile-gate.js?v=0.6.1"></script>
|
||||
<link rel="stylesheet" href="/style.css?v=0.6.2" />
|
||||
<script src="/mobile-gate.js?v=0.6.2"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 class="sr-only">DOTA2 上分帝</h1>
|
||||
@@ -227,13 +227,13 @@
|
||||
<select id="patch-select" aria-label="选择版本"></select>
|
||||
</div>
|
||||
<div class="patches-detail" id="patches-detail"></div>
|
||||
<footer class="patches-site-version" id="patches-site-version" aria-hidden="true"></footer>
|
||||
</main>
|
||||
|
||||
<section class="detail" id="detail" aria-live="polite"></section>
|
||||
<footer class="heroes-site-foot" id="heroes-site-foot" aria-hidden="true"></footer>
|
||||
|
||||
<script src="/config.js?v=0.6.1"></script>
|
||||
<script src="/router.js?v=0.6.1"></script>
|
||||
<script src="/app.js?v=0.6.1"></script>
|
||||
<script src="/config.js?v=0.6.2"></script>
|
||||
<script src="/router.js?v=0.6.2"></script>
|
||||
<script src="/app.js?v=0.6.2"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+12
-12
@@ -493,6 +493,18 @@ body {
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.heroes-site-foot {
|
||||
flex: 0 0 auto;
|
||||
width: 100%;
|
||||
padding: 6px 14px 10px;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
font-weight: var(--fw-medium);
|
||||
color: var(--muted);
|
||||
letter-spacing: 0.08em;
|
||||
opacity: 0.55;
|
||||
user-select: none;
|
||||
}
|
||||
.detail:not(.empty) {
|
||||
height: var(--detail-fixed-h);
|
||||
min-height: var(--detail-fixed-h);
|
||||
@@ -2808,18 +2820,6 @@ body:has(#items-view:not(.hidden)) {
|
||||
font-size: var(--fs-body);
|
||||
line-height: var(--lh-body);
|
||||
}
|
||||
.patches-site-version {
|
||||
width: min(var(--content-read), 92%);
|
||||
padding: 4px 0 28px;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
font-weight: var(--fw-medium);
|
||||
color: var(--muted);
|
||||
letter-spacing: 0.08em;
|
||||
opacity: 0.55;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.rankings-board {
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
|
||||
Reference in New Issue
Block a user