Skip to content

Commit

Permalink
fix: 修复重复请求拦截失败问题
Browse files Browse the repository at this point in the history
  • Loading branch information
三少 committed Apr 15, 2022
1 parent e20fb8b commit 85174f4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/vantui/src/unite/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ function useContainer(config: any, props: any) {
const _defined = function (this: any, ...args: any[]): any {
let res: any
try {
if (insRef.current.loading[item]) {
return new Promise(() => {})
}
res = copyFunc!.call(this, ...args)
if (typeof res?.then !== 'function') {
return res
Expand All @@ -74,13 +77,16 @@ function useContainer(config: any, props: any) {
[item]: false,
} as any
return new Promise(function (resolve) {
insRef.current.loading[item] = true
_setLoading(loadingTrue)
res
.then(function (result: any) {
insRef.current.loading[item] = false
_setLoading(loadingFalse)
resolve(result)
})
.catch(function (err: any) {
insRef.current.loading[item] = false
_setLoading(loadingFalse)
setError({
code: err.code || 'JSError',
Expand Down

0 comments on commit 85174f4

Please sign in to comment.