fix: media card survives page switch, cards fill column height

This commit is contained in:
2026-08-16 18:47:29 +08:00
parent 6915c54832
commit 1a79b4ed55
2 changed files with 25 additions and 0 deletions
+15
View File
@@ -28,6 +28,16 @@ window.updateHomeCards = async function () {
else col.appendChild(renderGenericCard(id));
});
});
// 若有当前媒体,覆盖中间栏为媒体卡(切页回来后恢复媒体卡)
// If there is active media, replace the middle column with the media card
// (restores the media card when navigating back to home)
if (currentMedia) {
const mediaCol = document.getElementById('col-1');
if (mediaCol) {
mediaCol.innerHTML = '';
mediaCol.appendChild(renderMediaCard(currentMedia));
}
}
startTimeCardTicker();
};
@@ -80,11 +90,16 @@ function startTimeCardTicker() {
}, 1000);
}
// 当前媒体信息(null 表示无媒体);切页后 updateHomeCards 据此恢复媒体卡
// Current media info (null = none); updateHomeCards restores the media card from it
let currentMedia = null;
// 原生媒体会话事件:有媒体时在中间栏渲染媒体卡,无媒体时降级重新布局
// Native media session event: render media card in middle column when present,
// otherwise fall back to re-layout (calendar/weather fill the media card slot)
window.HearthEvents = window.HearthEvents || {};
window.HearthEvents.mediaSessionChanged = function (info) {
currentMedia = info;
const mediaCol = document.getElementById('col-1');
if (!mediaCol) return;
if (info) {