From 9a45fb64c2dfbd56636a5b545cdcf193e9a10eb6 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Thu, 6 Apr 2023 16:12:36 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=9C=AA=E6=9B=B4=E6=96=B0=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=97=B6=E4=B9=9F=E8=83=BD=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/detail/components/InputDataModal.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pages/model/detail/components/InputDataModal.tsx b/src/pages/model/detail/components/InputDataModal.tsx index ca7ff155a..95352234f 100644 --- a/src/pages/model/detail/components/InputDataModal.tsx +++ b/src/pages/model/detail/components/InputDataModal.tsx @@ -80,19 +80,21 @@ const InputDataModal = ({ const updateData = useCallback( async (e: FormData) => { if (!e.dataId) return; - if (e.text === defaultValues.text && e.q === defaultValues.q) return; - await putModelDataById({ - dataId: e.dataId, - text: e.text, - q: e.q === defaultValues.q ? '' : e.q - }); + if (e.text !== defaultValues.text || e.q !== defaultValues.q) { + await putModelDataById({ + dataId: e.dataId, + text: e.text, + q: e.q === defaultValues.q ? '' : e.q + }); + onSuccess(); + } + toast({ title: '修改回答成功', status: 'success' }); onClose(); - onSuccess(); }, [defaultValues, onClose, onSuccess, toast] );