From 5418d492aef40160a2db9498e6556753f3ab95b3 Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Sun, 21 Dec 2025 01:32:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=AD=BB=E5=90=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/ui/chat-fragment/ChatFragment.tsx | 9 +++++---- client/ui/routers/RouterDialogsContext.ts | 3 ++- client/ui/routers/RouterDialogsContextWrapper.tsx | 5 ++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/client/ui/chat-fragment/ChatFragment.tsx b/client/ui/chat-fragment/ChatFragment.tsx index 9c8e013..e0d40f0 100644 --- a/client/ui/chat-fragment/ChatFragment.tsx +++ b/client/ui/chat-fragment/ChatFragment.tsx @@ -12,9 +12,10 @@ import SwitchPreference from "../preference/SwitchPreference" import TextFieldPreference from "../preference/TextFieldPreference" import * as React from 'react' import ChatMessageContainer from "./ChatMessageContainer" +import gotoChatInfo from "../routers/gotoChatInfo" -function gotoChatInfo(nav: NavigateFunction, id: string) { - nav('/chat/info?id=' + id) +function gotoChatInfo2(nav: NavigateFunction, id: string, useWithRouterChatFragment?: boolean) { + useWithRouterChatFragment ? nav('/chat/info?id=' + id) : gotoChatInfo(nav, id) } interface MduiTabFitSizeArgs extends React.HTMLAttributes { @@ -100,13 +101,13 @@ export default function ChatFragment({ marginRight: '5px', }}> { - + }} style={{ alignSelf: 'center', marginLeft: '5px', marginRight: '5px', }}> - gotoChatInfo(nav, chatInfo.getId())} style={{ + gotoChatInfo2(nav, chatInfo.getId(), openedWithRouter)} style={{ alignSelf: 'center', marginLeft: '5px', marginRight: '5px', diff --git a/client/ui/routers/RouterDialogsContext.ts b/client/ui/routers/RouterDialogsContext.ts index 6558873..f69d7fd 100644 --- a/client/ui/routers/RouterDialogsContext.ts +++ b/client/ui/routers/RouterDialogsContext.ts @@ -1,5 +1,6 @@ +import { Dialog } from 'mdui' import * as React from 'react' -const RouterDialogsContext = React.createContext(() => {}) +const RouterDialogsContext = React.createContext((ref: React.MutableRefObject) => {}) export default RouterDialogsContext diff --git a/client/ui/routers/RouterDialogsContextWrapper.tsx b/client/ui/routers/RouterDialogsContextWrapper.tsx index 20e4d6f..ca50e2e 100644 --- a/client/ui/routers/RouterDialogsContextWrapper.tsx +++ b/client/ui/routers/RouterDialogsContextWrapper.tsx @@ -4,7 +4,7 @@ import RouterDialogsContext from './RouterDialogsContext' import { BlockerFunction, useBlocker, useNavigate } from "react-router" import sleep from "../../utils/sleep" -const routerDialogsList = [] +const routerDialogsList: React.MutableRefObject[] = [] export default function RouterDialogsContextWrapper({ children }: React.HTMLAttributes) { const proceedRef = React.useRef<() => void>() @@ -41,6 +41,9 @@ export default function RouterDialogsContextWrapper({ children }: React.HTMLAttr // 这个让姐姐来就好啦 routerDialogsList.length != 0 && (routerDialogsList[routerDialogsList.length - 1].current!.open = false) } + return () => { + blocker.reset?.() + } }, [blocker.state]) // 注册