This commit is contained in:
archer
2023-07-17 22:05:45 +08:00
parent 509ca92f0a
commit ecce182a20
16 changed files with 1395 additions and 1422 deletions

View File

@@ -30,7 +30,8 @@ const ChatHistorySlider = ({
activeHistoryId,
onChangeChat,
onDelHistory,
onSetHistoryTop
onSetHistoryTop,
onUpdateTitle
}: {
appId?: string;
appName: string;
@@ -40,6 +41,7 @@ const ChatHistorySlider = ({
onChangeChat: (historyId?: string) => void;
onDelHistory: (historyId: string) => void;
onSetHistoryTop?: (e: { historyId: string; top: boolean }) => void;
onUpdateTitle?: (e: { historyId: string; title: string }) => void;
}) => {
const theme = useTheme();
const router = useRouter();
@@ -159,6 +161,20 @@ const ChatHistorySlider = ({
{item.top ? '取消置顶' : '置顶'}
</MenuItem>
)}
{/* {onUpdateTitle && (
<MenuItem
onClick={(e) => {
e.stopPropagation();
onUpdateTitle({
historyId: item.id,
title: '是是是'
});
}}
>
<MyIcon mr={2} name={'customTitle'} w={'16px'}></MyIcon>
自定义标题
</MenuItem>
)} */}
<MenuItem
_hover={{ color: 'red.500' }}
onClick={(e) => {

View File

@@ -24,7 +24,7 @@ const ToolMenu = ({ history }: { history: ChatItemType[] }) => {
},
{ icon: 'pdf', label: 'PDF导出', onClick: () => onExportChat({ type: 'pdf', history }) }
]);
return (
return history.length > 0 ? (
<Menu autoSelect={false} isLazy>
<MenuButton
_hover={{ bg: 'myWhite.600 ' }}
@@ -45,7 +45,7 @@ const ToolMenu = ({ history }: { history: ChatItemType[] }) => {
))}
</MenuList>
</Menu>
);
) : null;
};
export default ToolMenu;

View File

@@ -260,6 +260,20 @@ const Chat = () => {
});
} catch (error) {}
}}
onUpdateTitle={async (e) => {
try {
await putChatHistory({
historyId: e.historyId,
customTitle: e.title
});
const historyItem = history.find((item) => item._id === e.historyId);
if (!historyItem) return;
updateHistory({
...historyItem,
title: e.title
});
} catch (error) {}
}}
/>
)}
{/* chat container */}