mirror of
https://github.com/un-pany/v3-admin-vite.git
synced 2025-04-21 03:19:19 +08:00
perf: 优化 useFullscreenLoading 代码
This commit is contained in:
parent
e270308f10
commit
f3a62504d6
@ -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<T>(
|
||||
// Promise
|
||||
return result
|
||||
.then((res) => {
|
||||
hideLoading()
|
||||
return res
|
||||
})
|
||||
.catch((err) => {
|
||||
hideLoading()
|
||||
throw err
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoading()
|
||||
})
|
||||
} catch (err) {
|
||||
hideLoading()
|
||||
throw err
|
||||
|
Loading…
x
Reference in New Issue
Block a user