优化自动刷新邮件请求次数

This commit is contained in:
eoao
2026-01-12 22:33:00 +08:00
parent 97b2be8d25
commit 7694278045
10 changed files with 161 additions and 129 deletions

View File

@@ -0,0 +1,4 @@
export const AutoRefreshEnum = {
DISABLED: 0,
ENABLED: 1
}

View File

@@ -9,7 +9,7 @@ export function emailDelete(emailIds) {
}
export function emailLatest(emailId, accountId, allReceive) {
return http.get('/email/latest', {params: {emailId, accountId, allReceive}, noMsg: true })
return http.get('/email/latest', {params: {emailId, accountId, allReceive}, noMsg: true, timeout: 35 * 1000})
}
export function emailRead(emailIds) {

View File

@@ -34,6 +34,7 @@ import {sleep} from "@/utils/time-utils.js";
import router from "@/router/index.js";
import {Icon} from "@iconify/vue";
import {AccountAllReceiveEnum} from "@/enums/account-enum.js";
import {AutoRefreshEnum} from "@/enums/setting-enum.js";
defineOptions({
name: 'email'
@@ -77,7 +78,7 @@ async function latest() {
while (true) {
const latestId = scroll.value.latestEmail?.emailId
if (!scroll.value.firstLoad && settingStore.settings.autoRefreshTime) {
if (!scroll.value.firstLoad && settingStore.settings.autoRefresh === AutoRefreshEnum.ENABLED) {
try {
const accountId = accountStore.currentAccountId
const allReceive = scroll.value.latestEmail?.allReceive
@@ -127,7 +128,7 @@ async function latest() {
console.error(e)
}
}
await sleep(settingStore.settings.autoRefreshTime * 1000)
await sleep(500)
}
}

View File

@@ -145,11 +145,11 @@
<el-select
@change="change"
:style="`width: ${ locale === 'en' ? 100 : 80 }px;`"
v-model="setting.autoRefreshTime"
v-model="setting.autoRefresh"
placeholder="Select"
>
<el-option
v-for="item in options"
v-for="item in authRefreshOptions"
:key="item.value"
:label="item.label"
:value="item.value"
@@ -827,14 +827,9 @@ const regKeyOptions = computed(() => [
{label: t('optional'), value: 2},
])
const options = computed(() => [
const authRefreshOptions = computed(() => [
{label: t('disable'), value: 0},
{label: '3s', value: 3},
{label: '5s', value: 5},
{label: '7s', value: 7},
{label: '10s', value: 10},
{label: '15s', value: 15},
{label: '20s', value: 20}
{label: t('enable'), value: 1},
])
const tgChatId = ref([])