// 卡片三栏降级布局纯函数(UMD:Node require / 浏览器挂 window.cards) // Card three-column fallback layout pure function (UMD: Node require / browser window.cards) (function (root, factory) { if (typeof module === 'object' && module.exports) module.exports = factory(); else root.cards = factory(); })(this, function () { // cards: [{id, priority, enabled}],time 卡为内置始终保留 // 返回三栏分配结果,优先级数字小者优先;disabled 的卡不占位 // cards: [{id, priority, enabled}], time card is builtin and always kept // Returns the three-column assignment; smaller priority comes first; disabled cards are skipped function layout(cards) { const columns = [[], [], []]; const active = cards .filter((c) => c.enabled !== false) .sort((a, b) => a.priority - b.priority); active.forEach((c, i) => columns[i % 3].push(c.id)); return columns; } return { layout }; });