修复切换邮箱自动刷新错乱
This commit is contained in:
@@ -447,14 +447,17 @@ function addItem(email) {
|
|||||||
if (props.timeSort) {
|
if (props.timeSort) {
|
||||||
if (noLoading.value) {
|
if (noLoading.value) {
|
||||||
emailList.push(email)
|
emailList.push(email)
|
||||||
latestEmail.value = email
|
|
||||||
total.value++
|
|
||||||
} else {
|
|
||||||
total.value++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (email.emailId > latestEmail.value.emailId) {
|
||||||
|
latestEmail.value = email
|
||||||
|
}
|
||||||
|
|
||||||
|
total.value++
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const index = emailList.findIndex(item => item.emailId < email.emailId)
|
const index = emailList.findIndex(item => item.emailId < email.emailId)
|
||||||
|
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
@@ -465,6 +468,10 @@ function addItem(email) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (email.emailId > latestEmail.value.emailId) {
|
||||||
|
latestEmail.value = email
|
||||||
|
}
|
||||||
|
|
||||||
total.value++
|
total.value++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,22 +74,31 @@ const existIds = new Set();
|
|||||||
|
|
||||||
async function latest() {
|
async function latest() {
|
||||||
while (true) {
|
while (true) {
|
||||||
const latestId = scroll.value.latestEmail?.emailId || 0
|
const latestId = scroll.value.latestEmail?.emailId
|
||||||
|
|
||||||
if (!scroll.value.firstLoad && settingStore.settings.autoRefreshTime) {
|
if (!scroll.value.firstLoad && settingStore.settings.autoRefreshTime) {
|
||||||
try {
|
try {
|
||||||
const accountId = accountStore.currentAccountId
|
const accountId = accountStore.currentAccountId
|
||||||
const curTimeSort = params.timeSort
|
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 (accountId === accountStore.currentAccountId && params.timeSort === curTimeSort) {
|
||||||
if (list.length > 0) {
|
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({
|
ElNotification({
|
||||||
type: 'primary',
|
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>`,
|
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)
|
await sleep(50)
|
||||||
scroll.value.addItem(email)
|
}
|
||||||
|
|
||||||
},50)
|
}
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -754,7 +754,7 @@ defineOptions({
|
|||||||
name: 'sys-setting'
|
name: 'sys-setting'
|
||||||
})
|
})
|
||||||
|
|
||||||
const currentVersion = 'v2.4.0'
|
const currentVersion = 'v2.5.0'
|
||||||
const hasUpdate = ref(false)
|
const hasUpdate = ref(false)
|
||||||
let getUpdateErrorCount = 1;
|
let getUpdateErrorCount = 1;
|
||||||
const {t, locale} = useI18n();
|
const {t, locale} = useI18n();
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ const emailService = {
|
|||||||
size = Number(size);
|
size = Number(size);
|
||||||
emailId = Number(emailId);
|
emailId = Number(emailId);
|
||||||
timeSort = Number(timeSort);
|
timeSort = Number(timeSort);
|
||||||
|
accountId = Number(accountId);
|
||||||
|
|
||||||
if (size > 30) {
|
if (size > 30) {
|
||||||
size = 30;
|
size = 30;
|
||||||
@@ -110,6 +111,14 @@ const emailService = {
|
|||||||
emailRow.attList = atts;
|
emailRow.attList = atts;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!latestEmail) {
|
||||||
|
latestEmail = {
|
||||||
|
emailId: 0,
|
||||||
|
accountId: accountId,
|
||||||
|
userId: userId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { list, total: totalRow.total, latestEmail };
|
return { list, total: totalRow.total, latestEmail };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user