修复切换邮箱自动刷新错乱

This commit is contained in:
eoao
2025-11-23 13:25:41 +08:00
parent c61bda1828
commit 70923fee59
4 changed files with 38 additions and 15 deletions

View File

@@ -74,22 +74,31 @@ const existIds = new Set();
async function latest() {
while (true) {
const latestId = scroll.value.latestEmail?.emailId || 0
const latestId = scroll.value.latestEmail?.emailId
if (!scroll.value.firstLoad && settingStore.settings.autoRefreshTime) {
try {
const accountId = accountStore.currentAccountId
const curTimeSort = params.timeSort
const list = await emailLatest(latestId, accountId)
let list = []
//确保发起请求时最后一个邮件是当前账号的,或者
if (accountId === scroll.value.latestEmail?.accountId) {
list = await emailLatest(latestId, accountId);
}
//确保请求回来后,账号没有切换,时间排序没有改变
if (accountId === accountStore.currentAccountId && params.timeSort === curTimeSort) {
if (list.length > 0) {
list.forEach(email => {
for (let email of list) {
setTimeout(() => {
if (!existIds.has(email.emailId)) {
if (!existIds.has(email.emailId) && innerWidth > 1367) {
existIds.add(email.emailId)
scroll.value.addItem(email)
if (innerWidth > 1367) {
ElNotification({
type: 'primary',
message: `<div style="cursor: pointer;"><div style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis; font-weight: bold;font-size: 16px;margin-bottom: 5px;">${email.name}</div><div style="color: teal;">${email.subject}</div></div>`,
@@ -101,12 +110,10 @@ async function latest() {
})
}
existIds.add(email.emailId)
scroll.value.addItem(email)
await sleep(50)
}
},50)
})
}
}