Skip to content

[BUG] scriptlist 的图片显示不出来是这样啦 (显示很慢) #546

@cyfung1031

Description

@cyfung1031

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

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions