-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. 添加全部已读、全部未读功能。支持一键将内容标记为已读或未读 已知问题:全部已读、全部未读功能存在性能问题。在阅读清单中项目过多的情况下使用会卡顿2-3s。
- Loading branch information
1 parent
e41b7e4
commit e6cef4e
Showing
4 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
self.onmessage = async function(event) { | ||
const { urls, readStatus, batchSize } = event.data; | ||
|
||
const promises = []; // 存储所有的 Promise | ||
|
||
for (let i = 0; i < urls.length; i += batchSize) { | ||
const batch = urls.slice(i, i + batchSize); | ||
|
||
// 处理每个批次的更新 | ||
const promise = (async () => { | ||
// 通知主线程更新状态 | ||
self.postMessage({ batch, readStatus }); | ||
|
||
// 模拟异步操作 | ||
await new Promise(resolve => setTimeout(resolve, 0)); | ||
})(); | ||
|
||
promises.push(promise); // 将 Promise 添加到数组中 | ||
} | ||
|
||
// 等待所有的 Promise 完成 | ||
await Promise.all(promises); | ||
|
||
// 通知主线程任务完成 | ||
self.postMessage({ done: true }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters