From 082817d6cd8146d5ec4a6aa8f4210fbf8fd94147 Mon Sep 17 00:00:00 2001 From: CrescentLeaf Date: Sun, 21 Sep 2025 02:18:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(wip):=20=E6=94=B6=E7=99=BC=E6=B6=88?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/ui/chat/ChatFragment.tsx | 21 ++++++++++++++++++++- server/api/ChatApi.ts | 16 +++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/client/ui/chat/ChatFragment.tsx b/client/ui/chat/ChatFragment.tsx index d074416..98af06a 100644 --- a/client/ui/chat/ChatFragment.tsx +++ b/client/ui/chat/ChatFragment.tsx @@ -37,7 +37,26 @@ export default function ChatFragment({ target, ...props }: Args) { setChatInfo(re.data as Chat) }, [target]) - console.log(tabItemSelected) + let page = 0 + async function loadMore() { + const re = await Client.invoke("Chat.getMessageHistory", { + token: data.access_token, + target, + page, + }) + + if (checkApiSuccessOrSncakbar(re, "拉取歷史記錄失敗")) return + page++ + setMessagesList(messagesList.concat()) + } + + React.useEffect(() => { + + return () => { + + } + }) + return (
{ - if (this.checkArgsMissing(args, ['token', 'target'])) return { + if (this.checkArgsMissing(args, ['token', 'target', 'page'])) return { msg: "參數缺失", code: 400, } @@ -93,9 +94,18 @@ export default class ChatApi extends BaseApi { msg: "令牌無效", } + const chat = Chat.findById(args.target as string) + if (chat == null) return { + code: 404, + msg: "對話不存在", + } + return { - code: 501, - msg: "未實現", + code: 200, + msg: "成功", + data: { + messages: MessagesManager.getInstanceForChat(chat).getMessagesWithPage(), + }, } }) }