import { ISample } from '@glodon-aiot/apis'; interface UseSamplePreloadOptions { /** 内存中已加载的样本列表,预加载只在该范围内取相邻项 */ samples: ISample[]; /** 当前图片在 samples 中的位置 */ currentIndex: number; /** 详情/标注弹窗是否开启,关闭时释放缓存 */ active: boolean; /** * 主图已加载完成的图片地址,作为启动信号,避免与主图争抢带宽。 * 与 samples[currentIndex] 比对而非与 currentSample 比对:翻页时 currentIndex 与 * currentSample 不在同一次提交里更新,用后者会出现“新索引 + 旧已加载地址”的空窗, * 导致预加载抢在主图请求之前发出。 */ loadedImageUrl?: string; } /** * 以当前图片为中心预加载相邻样本的图片:先向后(下一张方向)再向前, * 与用户以“下一张”为主的浏览习惯一致。 * * 只在 samples 已有的范围内取相邻项,不会触发 fetchSamples —— * 那个函数会改写 pagination 并 append 样本,作为预加载的副作用会污染分页状态。 */ declare const useSamplePreload: ({ samples, currentIndex, active, loadedImageUrl, }: UseSamplePreloadOptions) => void; export default useSamplePreload;