Skip to content

Commit

Permalink
fix: 修复背景图选择参数错误问题
Browse files Browse the repository at this point in the history
  • Loading branch information
qkiroc committed Nov 27, 2024
1 parent 8175a4c commit 08eec90
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -671,12 +671,15 @@ function ImageInput(props: ThemeColorProps) {
if (imgRes) {
let img = imgRes[1];
setImage(img);
let res = value.replace(imgRes[0] + ' ', '');
let res = value;
!res.endsWith(' ') && (res += ' ');
res = value.replace(imgRes[0] + ' ', '');
let list = res.split(' ');
// 解析position
let position = list[0] + ' ' + list[1];
const index = POSITION_MAP.findIndex(n => n === position);
setPosition(index);
!res.endsWith(' ') && (res += ' ');
res = res.replace(position + ' / ', '');
list = res.split(' ');
// 解析mode
Expand All @@ -688,6 +691,7 @@ function ImageInput(props: ThemeColorProps) {
mode = '100% 100% no-repeat';
}
setMode(mode);
!res.endsWith(' ') && (res += ' ');
// 解析color
const color = res.replace(mode + ' ', '');
setColor(color);
Expand Down Expand Up @@ -770,7 +774,7 @@ function ImageInput(props: ThemeColorProps) {
value={color}
onChange={(value: string) => {
onChange(
`url(${image}) ${POSITION_MAP[position]} / ${mode} ${value}`
`url(${image}) ${POSITION_MAP[position]} / ${mode} ${value || ''}`
);
}}
/>
Expand Down

0 comments on commit 08eec90

Please sign in to comment.