fix(hub): show monitor page instead of overlapping market page
page-market id contained substring monitor so setActiveNav kept both pages visible and hid the grid. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -537,13 +537,24 @@
|
|||||||
return "monitor";
|
return "monitor";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pageElementId(page) {
|
||||||
|
if (page === "settings") return "page-settings";
|
||||||
|
if (page === "market") return "page-market";
|
||||||
|
return "page-monitor";
|
||||||
|
}
|
||||||
|
|
||||||
function setActiveNav() {
|
function setActiveNav() {
|
||||||
const page = currentPage();
|
const page = currentPage();
|
||||||
|
const pageId = pageElementId(page);
|
||||||
document.querySelectorAll(".top-nav a").forEach((a) => {
|
document.querySelectorAll(".top-nav a").forEach((a) => {
|
||||||
a.classList.toggle("active", a.getAttribute("href").includes(page));
|
const href = (a.getAttribute("href") || "").split("?")[0];
|
||||||
|
a.classList.toggle(
|
||||||
|
"active",
|
||||||
|
href === "/" + page || (page === "monitor" && (href === "/" || href === "/monitor"))
|
||||||
|
);
|
||||||
});
|
});
|
||||||
document.querySelectorAll(".page").forEach((el) => {
|
document.querySelectorAll(".page").forEach((el) => {
|
||||||
el.classList.toggle("hidden", !el.id.includes(page));
|
el.classList.toggle("hidden", el.id !== pageId);
|
||||||
});
|
});
|
||||||
if (page === "monitor") startMonitorPoll();
|
if (page === "monitor") startMonitorPoll();
|
||||||
else stopMonitorPoll();
|
else stopMonitorPoll();
|
||||||
@@ -1140,10 +1151,15 @@
|
|||||||
const mobileTiles = isMobileLayout() && !expandedExchangeId;
|
const mobileTiles = isMobileLayout() && !expandedExchangeId;
|
||||||
const displayRows = mobileTiles ? sortRowsForMobileDashboard(rows) : rows;
|
const displayRows = mobileTiles ? sortRowsForMobileDashboard(rows) : rows;
|
||||||
box.classList.toggle("grid-monitor-tiles", mobileTiles);
|
box.classList.toggle("grid-monitor-tiles", mobileTiles);
|
||||||
|
try {
|
||||||
box.innerHTML =
|
box.innerHTML =
|
||||||
displayRows
|
displayRows
|
||||||
.map((r) => (mobileTiles ? renderMonitorTile(r) : renderMonitorCard(r)))
|
.map((r) => (mobileTiles ? renderMonitorTile(r) : renderMonitorCard(r)))
|
||||||
.join("") || '<div class="err">无已启用账户</div>';
|
.join("") || '<div class="err">无已启用账户</div>';
|
||||||
|
} catch (err) {
|
||||||
|
console.error("renderMonitorGrid", err);
|
||||||
|
box.innerHTML = `<div class="err">监控区渲染失败:${esc(String(err && err.message ? err.message : err))}</div>`;
|
||||||
|
}
|
||||||
syncMonitorGridColumns(box, displayRows.length);
|
syncMonitorGridColumns(box, displayRows.length);
|
||||||
bindMonitorInteractions(box);
|
bindMonitorInteractions(box);
|
||||||
|
|
||||||
|
|||||||
@@ -250,6 +250,6 @@
|
|||||||
<div id="toast"></div>
|
<div id="toast"></div>
|
||||||
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
|
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
|
||||||
<script src="/assets/chart.js?v=20260604-market-pnl-calc"></script>
|
<script src="/assets/chart.js?v=20260604-market-pnl-calc"></script>
|
||||||
<script src="/assets/app.js?v=20260604-market-pnl-calc"></script>
|
<script src="/assets/app.js?v=20260604-page-nav-fix"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user