fix: 自定义主题icons完成度校验

This commit is contained in:
streakingman 2022-10-12 00:13:49 +08:00
parent d070c67d3f
commit 01d85610eb

View File

@ -271,6 +271,15 @@ const ConfigDialog: FC<{
const findIconError = iconErrors.find((i) => !!i); const findIconError = iconErrors.find((i) => !!i);
if (findIconError) if (findIconError)
return Promise.reject(`图标素材有错误:${findIconError}`); return Promise.reject(`图标素材有错误:${findIconError}`);
const findUnfinishedIconIdx = customTheme.icons.findIndex(
(icon) => !icon.content
);
if (findUnfinishedIconIdx !== -1) {
setIconErrors(makeIconErrors(findUnfinishedIconIdx, '请填写链接'));
return Promise.reject(
`${findUnfinishedIconIdx + 1}图标素材未完成`
);
}
return Promise.resolve(''); return Promise.resolve('');
}; };
@ -361,10 +370,8 @@ const ConfigDialog: FC<{
}); });
}) })
.catch((e) => { .catch((e) => {
setTimeout(() => { setConfigError(e);
setConfigError(e); setUploading(false);
setUploading(false);
}, 3000);
}); });
}; };
@ -568,13 +575,14 @@ const ConfigDialog: FC<{
placeholder={'或者输入https外链'} placeholder={'或者输入https外链'}
value={customTheme.icons[idx].content} value={customTheme.icons[idx].content}
onBlur={(e) => { onBlur={(e) => {
if (!linkReg.test(e.target.value)) setIconErrors(
setIconErrors( makeIconErrors(
makeIconErrors( idx,
idx, linkReg.test(e.target.value)
'请输入https外链' ? ''
) : '请输入https外链'
); )
);
}} }}
onChange={(e) => onChange={(e) =>
updateIcons('content', e.target.value, idx) updateIcons('content', e.target.value, idx)