From a928577f2aa1b36d866c26d04d0e39257aa52939 Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Thu, 25 Sep 2025 16:26:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=93=E9=96=8B=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E5=B0=8D=E8=A9=B1=E6=99=82,=20=E4=BD=BF=E7=94=A8=E4=BA=86?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E5=80=8B=20ChatFragment=20*=20=E4=B8=A6?= =?UTF-8?q?=E4=BF=AE=E5=BE=A9=E4=BA=86=E4=BD=BF=E7=94=A8=20key=20=E6=99=82?= =?UTF-8?q?,=20=E5=9B=A0=E7=88=B2=E5=8D=B8=E8=BC=89=E7=B5=84=E4=BB=B6?= =?UTF-8?q?=E5=90=8E=20ref=20=E4=B8=9F=E5=A4=B1=E5=B0=8E=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E9=8C=AF=E8=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/ui/App.tsx | 3 ++- client/ui/AppMobile.tsx | 1 + client/ui/useEventListener.ts | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/ui/App.tsx b/client/ui/App.tsx index 1f1ebb0..5130cb8 100644 --- a/client/ui/App.tsx +++ b/client/ui/App.tsx @@ -173,7 +173,8 @@ export default function App() { } { isShowChatFragment && + target={currentChatId} + key={currentChatId} /> } diff --git a/client/ui/AppMobile.tsx b/client/ui/AppMobile.tsx index 8820ccb..f8f0c71 100644 --- a/client/ui/AppMobile.tsx +++ b/client/ui/AppMobile.tsx @@ -109,6 +109,7 @@ export default function AppMobile() { setIsShowChatFragment(false)} + key={currentChatId} target={currentChatId} /> diff --git a/client/ui/useEventListener.ts b/client/ui/useEventListener.ts index 169f29f..8e92b09 100644 --- a/client/ui/useEventListener.ts +++ b/client/ui/useEventListener.ts @@ -3,6 +3,6 @@ import * as React from 'react' export default function useEventListener(ref: React.MutableRefObject, eventName: string, callback: (event: Event) => void) { React.useEffect(() => { ref.current!.addEventListener(eventName, callback) - return () => ref.current!.removeEventListener(eventName, callback) + return () => ref.current?.removeEventListener(eventName, callback) }, [ref, eventName, callback]) }