fix: home time card fallback when no catalog

This commit is contained in:
2026-08-16 16:47:02 +08:00
parent fdaa8d0516
commit 695df96c24
+9 -3
View File
@@ -10,9 +10,15 @@ window.updateHomeCards = async function () {
try {
catalog = JSON.parse(await bridge.call('fetchCards'));
} catch (e) {
// 桥接不可用(如未接线)时降级为内置时间卡
// Degrade to builtin time card when the bridge is unavailable (e.g. not wired yet)
catalog = [{ id: 'time', priority: 0, enabled: true }];
// 桥接不可用(如未接线)时按空目录处理
// Treat bridge failure as an empty catalog
catalog = [];
}
if (!Array.isArray(catalog)) catalog = [];
// 兜底:无目录或缺失 time 卡时补内置大字时间卡,保证首页始终有时间卡
// Fallback: prepend builtin big time card when the catalog is empty or missing the time card
if (!catalog.some((c) => c.id === 'time')) {
catalog.push({ id: 'time', name: '大字时间', priority: 0 });
}
const cols = cards.layout(catalog);
cols.forEach((ids, i) => {