amis-saas-7927 [Bug] 「外观配置」背景配置项功能异常

Change-Id: Id8bbd155b11ea40fea3c2bfb8d348e2e322b64bf
This commit is contained in:
jiatianqi 2022-11-07 12:21:31 +08:00
parent 6e6202f688
commit 41a74f6b77

View File

@ -361,12 +361,39 @@ const Background: React.FC<BackgroundProps> = props => {
setTabIndex(index); setTabIndex(index);
} }
function handleChange(key: string, keyValue: string) { function handleChange(key: string, keyValue: string | number) {
const {value, onChange} = props; const {value, onChange} = props;
const result = {
...value, let result = {};
[key]: keyValue if (key === 'backgroundColor') {
}; result = {
...omit(value, [
'backgroundImage',
'backgroundPosition',
'backgroundSize',
'backgroundRepeat',
'angle'
]),
[key]: keyValue
};
} else if (key === 'angle') {
keyValue = keyValue || 0;
const linearGradient = value?.backgroundImage;
let backgroundImage = linearGradient?.replace(
/(\d{1,})?deg/,
`${keyValue}deg`
);
result = {
...value,
backgroundImage
};
} else {
result = {
...value,
[key]: keyValue
};
}
onChange(result); onChange(result);
} }