perf: 优化 useFullscreenLoading 代码
This commit is contained in:
parent
e270308f10
commit
f3a62504d6
@ -15,7 +15,7 @@ interface ILoadingInstance {
|
|||||||
* 1. fn 如果是同步函数,执行结束后隐藏 loading
|
* 1. fn 如果是同步函数,执行结束后隐藏 loading
|
||||||
* 2. fn 如果是 Promise,resolve 或 reject 后隐藏 loading
|
* 2. fn 如果是 Promise,resolve 或 reject 后隐藏 loading
|
||||||
* 3. 报错后隐藏 loading 并抛出错误
|
* 3. 报错后隐藏 loading 并抛出错误
|
||||||
* @param {*} fn 函数
|
* @param {*} fn 要执行的函数
|
||||||
* @param options LoadingOptions
|
* @param options LoadingOptions
|
||||||
* @returns Function 一个新的函数,去执行它吧
|
* @returns Function 一个新的函数,去执行它吧
|
||||||
*/
|
*/
|
||||||
@ -44,13 +44,14 @@ export function useFullscreenLoading<T>(
|
|||||||
// Promise
|
// Promise
|
||||||
return result
|
return result
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
hideLoading()
|
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
hideLoading()
|
|
||||||
throw err
|
throw err
|
||||||
})
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoading()
|
||||||
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
hideLoading()
|
hideLoading()
|
||||||
throw err
|
throw err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user