|
@@ -2,6 +2,7 @@ import { useXAgent, XStream } from "@ant-design/x";
|
|
|
import { useEffect, useRef, useState } from "react";
|
|
|
import { useSessionStorageState } from "ahooks";
|
|
|
import { GetSessionList, GetSessionMessageList } from "@/api/ai";
|
|
|
+import { getDateGroupString } from "@/utils";
|
|
|
|
|
|
import type { ConversationsProps } from "@ant-design/x";
|
|
|
import type { ReactNode } from "react";
|
|
@@ -54,6 +55,7 @@ const defaultConversation = {
|
|
|
// 会话id
|
|
|
key: "1",
|
|
|
label: "新的对话",
|
|
|
+ group: '今日'
|
|
|
};
|
|
|
|
|
|
export function useChat({ app_name, onSuccess, onUpdate, onError }: ChatProps) {
|
|
@@ -111,6 +113,7 @@ export function useChat({ app_name, onSuccess, onUpdate, onError }: ChatProps) {
|
|
|
...item,
|
|
|
key: item.sessionId,
|
|
|
label: item.name,
|
|
|
+ group: getDateGroupString(item.updateTime)
|
|
|
})),
|
|
|
]);
|
|
|
} else {
|
|
@@ -120,6 +123,7 @@ export function useChat({ app_name, onSuccess, onUpdate, onError }: ChatProps) {
|
|
|
...item,
|
|
|
key: item.sessionId,
|
|
|
label: item.name,
|
|
|
+ group: getDateGroupString(item.updateTime)
|
|
|
})),
|
|
|
]);
|
|
|
}
|
|
@@ -257,7 +261,7 @@ export function useChat({ app_name, onSuccess, onUpdate, onError }: ChatProps) {
|
|
|
* @param chat_query 对话内容
|
|
|
*/
|
|
|
const onRequest = (chat_query: string) => {
|
|
|
- setConversationList((list) => {
|
|
|
+ activeConversation === '1' && setConversationList((list) => {
|
|
|
return list?.map((item) => {
|
|
|
return {
|
|
|
...item,
|
|
@@ -306,6 +310,7 @@ export function useChat({ app_name, onSuccess, onUpdate, onError }: ChatProps) {
|
|
|
*/
|
|
|
const cancel = () => {
|
|
|
abortController.current?.abort();
|
|
|
+ setLoading(false);
|
|
|
};
|
|
|
|
|
|
/**
|