Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit86183fd

Browse files
show loading based on showDataLoadingIndicator flag
1 parent07538e2 commit86183fd

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

‎client/packages/lowcoder/src/comps/generators/withIsLoading.tsx

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import {
1111
importstyledfrom"styled-components";
1212
import{codeControl}from"comps/controls/codeControl";
1313
import{setFieldsNoTypeCheck}from"util/objectUtils";
14+
importSkeletonfrom"antd/es/skeleton";
15+
import{ReactNode,useContext,useMemo}from"react";
16+
import{CompContext}from"../utils/compContext";
17+
importLoadingOutlinedfrom"@ant-design/icons/LoadingOutlined";
18+
import{ThemeContext}from"../utils/themeContext";
1419

1520
constWrapper=styled.div`
1621
&,
@@ -23,6 +28,50 @@ const Wrapper = styled.div`
2328

2429
const__WITH_IS_LOADING="__WITH_IS_LOADING";
2530

31+
constLoadingWrapper=({
32+
isLoading,
33+
children,
34+
}:{
35+
isLoading:boolean,
36+
children:ReactNode,
37+
})=>{
38+
constcompState=useContext(CompContext);
39+
constcurrentTheme=useContext(ThemeContext)?.theme;
40+
41+
constshowLoading=useMemo(()=>{
42+
constthemeDataIndicator=currentTheme?.showDataLoadingIndicators;
43+
constcompDataIndicator=compState.comp?.comp.showDataLoadingIndicators;
44+
45+
returnisLoading ?(
46+
compDataIndicator!=='undefined' ?compDataIndicator :Boolean(themeDataIndicator)
47+
) :false;
48+
},[
49+
isLoading,
50+
currentTheme?.showDataLoadingIndicators,
51+
compState.comp?.comp.showDataLoadingIndicators,
52+
]);
53+
54+
if(currentTheme?.dataLoadingIndicator==='skeleton'){
55+
return(
56+
<Wrapper>
57+
<Skeletonactiveloading={showLoading}>
58+
{children}
59+
</Skeleton>
60+
</Wrapper>
61+
);
62+
}
63+
64+
return(
65+
<Wrapper>
66+
<Spin
67+
spinning={showLoading}
68+
indicator={<LoadingOutlinedstyle={{fontSize:15}}spin/>}
69+
>
70+
{children}
71+
</Spin>
72+
</Wrapper>
73+
)
74+
}
2675
/**
2776
* Unified increase isLoading effect
2877
*/
@@ -38,16 +87,16 @@ export function withIsLoading<T extends MultiCompConstructor>(VariantComp: T): T
3887
},
3988
updateNodeFields:(value:any)=>{
4089
constfetchInfo=value[__WITH_IS_LOADING]asFetchInfo;
41-
return{isLoading:fetchInfo.isFetching};
90+
return{isLoading:fetchInfo?.isFetching};
4291
},
4392
});
4493
}
4594

4695
overridegetView(){
4796
return(
48-
<Wrapper>
49-
<Spinspinning={this.isLoading}>{super.getView()}</Spin>
50-
</Wrapper>
97+
<LoadingWrapperisLoading={this.isLoading}>
98+
{super.getView()}
99+
</LoadingWrapper>
51100
);
52101
}
53102
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp