From 01d85610ebb2f3dcc7da7b2fa038c168414fc49a Mon Sep 17 00:00:00 2001 From: streakingman Date: Wed, 12 Oct 2022 00:13:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=87=AA=E5=AE=9A=E4=B9=89=E4=B8=BB?= =?UTF-8?q?=E9=A2=98icons=E5=AE=8C=E6=88=90=E5=BA=A6=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ConfigDialog.tsx | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/components/ConfigDialog.tsx b/src/components/ConfigDialog.tsx index f365208..e1170b1 100644 --- a/src/components/ConfigDialog.tsx +++ b/src/components/ConfigDialog.tsx @@ -271,6 +271,15 @@ const ConfigDialog: FC<{ const findIconError = iconErrors.find((i) => !!i); if (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(''); }; @@ -361,10 +370,8 @@ const ConfigDialog: FC<{ }); }) .catch((e) => { - setTimeout(() => { - setConfigError(e); - setUploading(false); - }, 3000); + setConfigError(e); + setUploading(false); }); }; @@ -568,13 +575,14 @@ const ConfigDialog: FC<{ placeholder={'或者输入https外链'} value={customTheme.icons[idx].content} onBlur={(e) => { - if (!linkReg.test(e.target.value)) - setIconErrors( - makeIconErrors( - idx, - '请输入https外链' - ) - ); + setIconErrors( + makeIconErrors( + idx, + linkReg.test(e.target.value) + ? '' + : '请输入https外链' + ) + ); }} onChange={(e) => updateIcons('content', e.target.value, idx)