From 6996326d6bc52e7382eb97c83a66d9db5e185a37 Mon Sep 17 00:00:00 2001 From: wangzeyan <258785420@qq.com> Date: Mon, 16 Jun 2025 20:35:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/axios.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/common/axios.js b/common/axios.js index b28d7be..4f07913 100644 --- a/common/axios.js +++ b/common/axios.js @@ -8,10 +8,17 @@ import { const debounce = (fn, delay = 1000) => { let timer = null; return function (...args) { - if (timer) clearTimeout(timer); - timer = setTimeout(() => { - fn.apply(this, args); - }, delay); + return new Promise((resolve, reject) => { + if (timer) clearTimeout(timer); + timer = setTimeout(() => { + try { + const result = fn.apply(this, args); + resolve(result); + } catch (error) { + reject(error); + } + }, delay); + }); } }