fix: home time card fallback when no catalog
This commit is contained in:
@@ -10,9 +10,15 @@ window.updateHomeCards = async function () {
|
|||||||
try {
|
try {
|
||||||
catalog = JSON.parse(await bridge.call('fetchCards'));
|
catalog = JSON.parse(await bridge.call('fetchCards'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// 桥接不可用(如未接线)时降级为内置时间卡
|
// 桥接不可用(如未接线)时按空目录处理
|
||||||
// Degrade to builtin time card when the bridge is unavailable (e.g. not wired yet)
|
// Treat bridge failure as an empty catalog
|
||||||
catalog = [{ id: 'time', priority: 0, enabled: true }];
|
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);
|
const cols = cards.layout(catalog);
|
||||||
cols.forEach((ids, i) => {
|
cols.forEach((ids, i) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user