From 84a2cbbc5956e99ddd2dfb808edacd5023f88514 Mon Sep 17 00:00:00 2001 From: cyfung1031 <44498510+cyfung1031@users.noreply.github.com> Date: Sun, 13 Jul 2025 02:22:59 +0900 Subject: [PATCH] =?UTF-8?q?React=E5=85=83=E4=BB=B6key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/components/ScriptMenuList/index.tsx | 7 +++++-- src/pages/options/routes/Logger.tsx | 6 +++--- src/pages/options/routes/SubscribeList.tsx | 14 ++++++++++---- src/pages/options/routes/Tools.tsx | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/pages/components/ScriptMenuList/index.tsx b/src/pages/components/ScriptMenuList/index.tsx index 8b4d1002b..51f69e3ef 100644 --- a/src/pages/components/ScriptMenuList/index.tsx +++ b/src/pages/components/ScriptMenuList/index.tsx @@ -138,8 +138,11 @@ const ScriptMenuList: React.FC<{ scriptClient .enable(item.uuid, checked) .then(() => { - item.enable = checked; - setList([...list]); + setList((prevList) => + prevList.map((item1, _i) => + item1 === item ? { ...item1, enable: checked } : item1 + ) + ); }) .catch((err) => { Message.error(err); diff --git a/src/pages/options/routes/Logger.tsx b/src/pages/options/routes/Logger.tsx index 9038ad974..616825f89 100644 --- a/src/pages/options/routes/Logger.tsx +++ b/src/pages/options/routes/Logger.tsx @@ -197,7 +197,7 @@ function LoggerPage() { {querys.map((query, index) => ( { @@ -305,9 +305,9 @@ function LoggerPage() { }} size="small" dataSource={queryLogs} - render={(item: Logger, index) => ( + render={(item: Logger, _index) => ( { - list[index].loading = true; - setList([...list]); + setList((prevList) => + prevList.map((item, i) => + i === index ? { ...item, loading: true } : item + ) + ); subscribeClient .enable(item.url, checked) .then(() => { @@ -75,8 +78,11 @@ function SubscribeList() { Message.error(err); }) .finally(() => { - list[index].loading = false; - setList([...list]); + setList((prevList) => + prevList.map((item, i) => + i === index ? { ...item, loading: false } : item + ) + ); }); }} /> diff --git a/src/pages/options/routes/Tools.tsx b/src/pages/options/routes/Tools.tsx index e0825f635..394989e90 100644 --- a/src/pages/options/routes/Tools.tsx +++ b/src/pages/options/routes/Tools.tsx @@ -214,7 +214,7 @@ function Tools() { bordered={false} dataSource={backupFileList} render={(item: File) => ( - +