File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,21 +56,14 @@ const processScriptFavicon = async (script: Script) => {
5656} ;
5757
5858// 在scriptSlice创建后处理favicon加载,以批次方式处理
59- export const loadScriptFavicons = async ( scripts : Script [ ] ) => {
59+ export const loadScriptFavicons = ( scripts : Script [ ] ) => {
6060 const batchSize = 20 ; // 每批处理20个脚本
6161 const scriptChunks = chunkArray ( scripts , batchSize ) ;
62- const results = [ ] ;
63-
6462 // 逐批处理脚本
6563 for ( const chunk of scriptChunks ) {
66- const chunkResults = await Promise . all ( chunk . map ( processScriptFavicon ) ) ;
67-
68- // 每完成一批就更新一次store
69- store . dispatch ( scriptSlice . actions . setScriptFavicon ( chunkResults ) ) ;
70-
71- results . push ( ...chunkResults ) ;
64+ Promise . all ( chunk . map ( processScriptFavicon ) ) . then ( ( chunkResults ) => {
65+ // 每完成一批就更新一次store
66+ store . dispatch ( scriptSlice . actions . setScriptFavicon ( chunkResults ) ) ;
67+ } ) ;
7268 }
73-
74- // 最后再做一次完整更新,确保所有数据都已更新
75- store . dispatch ( scriptSlice . actions . setScriptFavicon ( results ) ) ;
7669} ;
You can’t perform that action at this time.
0 commit comments