From f3a62504d6d27efc1c213d345da8a394b52dddb3 Mon Sep 17 00:00:00 2001 From: pany <939630029@qq.com> Date: Thu, 2 Feb 2023 11:29:34 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20useFullscreenLoadi?= =?UTF-8?q?ng=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useFullscreenLoading.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hooks/useFullscreenLoading.ts b/src/hooks/useFullscreenLoading.ts index 46d810c..155c481 100644 --- a/src/hooks/useFullscreenLoading.ts +++ b/src/hooks/useFullscreenLoading.ts @@ -15,7 +15,7 @@ interface ILoadingInstance { * 1. fn 如果是同步函数,执行结束后隐藏 loading * 2. fn 如果是 Promise,resolve 或 reject 后隐藏 loading * 3. 报错后隐藏 loading 并抛出错误 - * @param {*} fn 函数 + * @param {*} fn 要执行的函数 * @param options LoadingOptions * @returns Function 一个新的函数,去执行它吧 */ @@ -44,13 +44,14 @@ export function useFullscreenLoading( // Promise return result .then((res) => { - hideLoading() return res }) .catch((err) => { - hideLoading() throw err }) + .finally(() => { + hideLoading() + }) } catch (err) { hideLoading() throw err