fix: 修复单测问题

This commit is contained in:
fujianchao 2024-10-28 16:39:35 +08:00 committed by lmaomaoz
parent 024efd3a17
commit 7ace846fa7
4 changed files with 11 additions and 5 deletions

View File

@ -61,7 +61,7 @@ export default class TimelineItemControl extends React.Component<
if (source === this.state.source) {
return;
}
this.setState({source: source, api: '', items: []}, this.onChange);
this.setState({source, api: '', items: []}, this.onChange);
}
@autobind

View File

@ -1,3 +1,7 @@
.#{$ns}Timeline {
min-height: #{px2rem(10px)};
}
.#{$ns}Timeline-vertical {
display: flex;
flex-flow: column;

View File

@ -305,9 +305,6 @@ export function withRemoteConfig<P = any>(
ignoreData: true
}).url) &&
this.loadConfig();
} else if (!source) {
//如果source为空则清空配置
this.setConfig(undefined);
}
if (data !== prevProps.data) {

View File

@ -199,7 +199,7 @@ const TimelineWithRemoteConfig = withRemoteConfig({
RemoteOptionsProps & React.ComponentProps<typeof TimelineCmpt>
> {
render() {
const {config, items, deferLoad, loading, updateConfig, ...rest} =
const {config, items, deferLoad, loading, updateConfig, source, ...rest} =
this.props;
let sourceItems: Array<TimelineItemSchema> = config
@ -210,6 +210,11 @@ const TimelineWithRemoteConfig = withRemoteConfig({
title: config[key]
}))
: items || [];
// 如果items有值或者source为空则直接使用items
if (items?.length || !source) {
sourceItems = items || [];
}
return <TimelineCmpt items={sourceItems} {...rest} />;
}
}