From afa424fc0570a2146379b1b4ca8fab2d390a9ff2 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 29 Aug 2025 11:59:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A4=E6=96=AD=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=94=AF=E6=8C=81=20`requestIdleCallback`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/NewEmail.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/views/NewEmail.jsx b/src/views/NewEmail.jsx index 939cacd..85590c6 100644 --- a/src/views/NewEmail.jsx +++ b/src/views/NewEmail.jsx @@ -576,10 +576,12 @@ const NewEmail = () => { const idleCallbackId = useRef(null) const debouncedSave = useCallback( debounce((data) => { - idleCallbackId.current = window.requestIdleCallback(() => { - console.log('Saving data (idle, debounced):', data) - writeIndexDB([{ ...data, key: editorKey }], 'draft', 'mailbox') - }) + if ('requestIdleCallback' in window) { + idleCallbackId.current = window.requestIdleCallback(() => { + console.log('Saving data (idle, debounced):', data) + writeIndexDB([{ ...data, key: editorKey }], 'draft', 'mailbox') + }) + } }, 1500), // 1.5s [], )