From 722b06c018fb1b7c19d656287eec5c24d643b70e Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Thu, 1 Jan 2026 19:23:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=98=BE=E7=A4=BA=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E5=AF=B9=E8=AF=9D=E6=A0=87=E9=A2=98!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/init.ts | 3 --- client/ui/app-state/AppStateContextWrapper.tsx | 8 ++++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client/init.ts b/client/init.ts index 54cfb35..235093a 100644 --- a/client/init.ts +++ b/client/init.ts @@ -36,6 +36,3 @@ const onResize = () => { // deno-lint-ignore no-window no-window-prefix window.addEventListener('resize', onResize) onResize() - -const config = await fetch('/config.json').then((re) => re.json()) -config.title && (document.title = config.title) diff --git a/client/ui/app-state/AppStateContextWrapper.tsx b/client/ui/app-state/AppStateContextWrapper.tsx index 55f9e35..0bbd17c 100644 --- a/client/ui/app-state/AppStateContextWrapper.tsx +++ b/client/ui/app-state/AppStateContextWrapper.tsx @@ -10,6 +10,10 @@ import * as React from 'react' import { useContextSelector } from "use-context-selector" import MainSharedContext, { Shared } from "../MainSharedContext" import ChatFragmentDialog from "./ChatFragmentDialog" +import useAsyncEffect from "../../utils/useAsyncEffect" +import ClientCache from "../../ClientCache" + +const config = await fetch('/config.json').then((re) => re.json()) export default function DialogContextWrapper({ children, useRef }: { children: React.ReactNode, useRef: React.MutableRefObject }) { const [userOrChatInfoDialogState, setUserOrChatInfoDialogState] = React.useState([]) @@ -41,6 +45,10 @@ export default function DialogContextWrapper({ children, useRef }: { children: R const [useChatFragmentDialog, setUseChatFragmentDialog] = React.useState(false) const chatFragmentDialogRef = React.useRef() + useAsyncEffect(async () => { + document.title = (currentSelectedChatId && currentSelectedChatId != '' && await ClientCache.getChat(currentSelectedChatId).then((v) => v?.getTitle()) + ' | ') + (config.title || 'LingChair') + }, [currentSelectedChatId]) + return