Skip to content

Commit

Permalink
fix(resetsetter): mixedsetter逻辑push修改
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiZng committed Jan 11, 2024
1 parent 67dca52 commit 7baa505
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
3 changes: 0 additions & 3 deletions packages/editor-skeleton/src/components/field/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,4 @@
}
}
}
.lc-reseticon {
cursor: pointer;
}
}
36 changes: 25 additions & 11 deletions packages/editor-skeleton/src/components/settings/settings-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,34 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
// supportVariableGlobally 只对标准组件生效,vc 需要单独配置
const supportVariableGlobally = engineConfig.get('supportVariableGlobally', false) && isStandardComponent(componentMeta);
const isUseVariableSetter = shouldUseVariableSetter(supportVariable, supportVariableGlobally);
const shouldAddVariableSetter = isUseVariableSetter && !setterProps.setters?.includes('VariableSetter');
const shouldAddResetSetter = isUseResetSetter && !setterProps.setters?.includes('ResetSetter');

if (shouldAddVariableSetter || shouldAddResetSetter) {
setterType = 'MixedSetter';
setterProps.setters = setterProps.setters || [];
setterProps.setters.push(setter);

const shouldAddVariableSetter = isUseVariableSetter && Array.isArray(setterProps.setters) && !setterProps.setters?.includes('VariableSetter');
const shouldAddResetSetter = isUseResetSetter && Array.isArray(setterProps.setters) && !setterProps.setters?.includes('ResetSetter');
if (!isUseResetSetter && !isUseVariableSetter) {
return {
setterProps,
initialValue,
setterType,
};
}
if (setterType === 'MixedSetter') {
if (shouldAddVariableSetter) {
setterProps.setters.push('VariableSetter');
setterProps.setters?.push('VariableSetter');
}

if (shouldAddResetSetter) {
setterProps.setters.push('ResetSetter');
setterProps.setters?.push('ResetSetter');
}
} else {
setterType = 'MixedSetter';
setterProps = {
setters: [
setter,
],
};
if (isUseVariableSetter) {
setterProps.setters?.push('VariableSetter');
}
if (isUseResetSetter) {
setterProps.setters?.push('ResetSetter');
}
}
return {
Expand Down

0 comments on commit 7baa505

Please sign in to comment.