/** * 历史任务抽屉的渲染截断(2026-09 全维度审查 F6)。 * * 历史条目由页面从后端/本地缓存整批传入,抽屉此前全量渲染:条目多时(每卡 8+ 节点) * 打开即产生大量 DOM,关闭后虽然 destroy-on-close 会销毁,但打开期间的首屏渲染成本 * 与内存占用仍随条数线性增长。这里统一按上限截断渲染,由 UI 提供「显示全部」入口。 */ /** 首屏渲染条数上限 */ export const HISTORY_VISIBLE_LIMIT = 50 export interface HistorySlice { /** 实际渲染的条目 */ visible: T[] /** 被截断的条数(0 表示未截断) */ hiddenCount: number /** 是否处于截断状态 */ capped: boolean } export function sliceHistoryItems( items: T[] | null | undefined, showAll: boolean, limit: number = HISTORY_VISIBLE_LIMIT, ): HistorySlice { const list = Array.isArray(items) ? items : [] const safeLimit = Number.isFinite(limit) && limit > 0 ? Math.floor(limit) : HISTORY_VISIBLE_LIMIT if (showAll || list.length <= safeLimit) { return { visible: list, hiddenCount: 0, capped: false } } return { visible: list.slice(0, safeLimit), hiddenCount: list.length - safeLimit, capped: true } }