Parcourir la source

feat: 添加邮件清理调度功能,优化邮件删除流程

QLHazyCoder il y a 4 mois
Parent
commit
28c151d109
1 fichiers modifiés avec 10 ajouts et 4 suppressions
  1. 10 4
      content/mail-163.js

+ 10 - 4
content/mail-163.js

@@ -145,6 +145,14 @@ function getMailTimestamp(item) {
   return null;
 }
 
+function scheduleEmailCleanup(item, step) {
+  setTimeout(() => {
+    Promise.resolve(deleteEmail(item, step)).catch(() => {
+      // Cleanup is best effort only and must never affect the main verification flow.
+    });
+  }, 0);
+}
+
 // ============================================================
 // Email Polling
 // ============================================================
@@ -242,10 +250,8 @@ async function handlePollEmail(step, payload) {
           const timeLabel = mailTimestamp ? `,时间:${new Date(mailTimestamp).toLocaleString('zh-CN', { hour12: false })}` : '';
           log(`步骤 ${step}:已找到验证码:${code}(来源:${source}${timeLabel},主题:${subject.slice(0, 40)})`, 'ok');
 
-          // Delete this email via right-click menu, WAIT for it to finish before returning
-          await deleteEmail(item, step);
-          // Extra wait to ensure deletion is processed
-          await sleep(1000);
+          // Trigger cleanup only as a best-effort side effect.
+          scheduleEmailCleanup(item, step);
 
           return { ok: true, code, emailTimestamp: Date.now(), mailId: id };
         } else if (code && seenCodes.has(code)) {