-
Notifications
You must be signed in to change notification settings - Fork 213
Closed as not planned
Labels
bugSomething isn't workingSomething isn't working
Description
Problem Description
现在是要等5秒
假设我有200 个脚本
其中10个的Icon 已经死掉
所以这10个要等5秒
190个早就载入好(知道网址)
// 在scriptSlice创建后处理favicon加载,以批次方式处理
export const loadScriptFavicons = (scripts: Script[]) => {
const batchSize = 20; // 每批处理20个脚本
const scriptChunks = chunkArray(scripts, batchSize);
// 逐批处理脚本
for (const chunk of scriptChunks) {
Promise.all(chunk.map(processScriptFavicon)).then((chunkResults) => {
// 每完成一批就更新一次store
store.dispatch(scriptSlice.actions.setScriptFavicon(chunkResults));
});
}
};
200 / 20 = 10 对吧
刚好我那10个死掉的各佔1个
Promise.all(chunk.map(processScriptFavicon))
这个就要等5秒了
然后其他10个batch也是等5秒
於是
store.dispatch(scriptSlice.actions.setScriptFavicon(chunkResults));
就10个batch一起在5秒后载入
Reproduction Steps
ScriptCat Version
Operating System and Browser Information
Additional Information (Optional)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working