clear confirm for chat page

This commit is contained in:
josc146 2023-06-15 22:55:38 +08:00
parent 721653a812
commit 7f85a08508
3 changed files with 19 additions and 10 deletions

View File

@ -145,5 +145,6 @@
"Update completed, please restart the program.": "更新完成, 请重启程序", "Update completed, please restart the program.": "更新完成, 请重启程序",
"Are you sure you want to reset this page? It cannot be undone.": "你确定要重置本页吗?这无法撤销", "Are you sure you want to reset this page? It cannot be undone.": "你确定要重置本页吗?这无法撤销",
"Model file download is not complete": "模型文件下载未完成", "Model file download is not complete": "模型文件下载未完成",
"Error": "错误" "Error": "错误",
"Are you sure you want to clear the conversation? It cannot be undone.": "你确定要清空对话吗?这无法撤销"
} }

View File

@ -19,15 +19,22 @@ export const DialogButton: FC<{
className?: string, className?: string,
title: string, title: string,
contentText: string, contentText: string,
onConfirm: () => void onConfirm: () => void,
}> = ({ text, icon, tooltip, className, title, contentText, onConfirm }) => { size?: 'small' | 'medium' | 'large',
shape?: 'rounded' | 'circular' | 'square',
appearance?: 'secondary' | 'primary' | 'outline' | 'subtle' | 'transparent',
}> = ({
text, icon, tooltip, className, title, contentText,
onConfirm, size, shape, appearance
}) => {
const { t } = useTranslation(); const { t } = useTranslation();
return <Dialog> return <Dialog>
<DialogTrigger disableButtonEnhancement> <DialogTrigger disableButtonEnhancement>
{tooltip ? {tooltip ?
<ToolTipButton className={className} desc={tooltip} text={text} icon={icon} /> : <ToolTipButton className={className} desc={tooltip} text={text} icon={icon} size={size} shape={shape}
<Button className={className} icon={icon}>{text}</Button> appearance={appearance} /> :
<Button className={className} icon={icon} size={size} shape={shape} appearance={appearance}>{text}</Button>
} }
</DialogTrigger> </DialogTrigger>
<DialogSurface> <DialogSurface>

View File

@ -15,6 +15,7 @@ import { CopyButton } from '../components/CopyButton';
import { ReadButton } from '../components/ReadButton'; import { ReadButton } from '../components/ReadButton';
import { toast } from 'react-toastify'; import { toast } from 'react-toastify';
import { WorkHeader } from '../components/WorkHeader'; import { WorkHeader } from '../components/WorkHeader';
import { DialogButton } from '../components/DialogButton';
export const userName = 'M E'; export const userName = 'M E';
export const botName = 'A I'; export const botName = 'A I';
@ -251,16 +252,16 @@ const ChatPanel: FC = observer(() => {
})} })}
</div> </div>
<div className="flex items-end gap-2"> <div className="flex items-end gap-2">
<ToolTipButton desc={t('Clear')} <DialogButton tooltip={t('Clear')}
icon={<Delete28Regular />} icon={<Delete28Regular />}
size="large" shape="circular" appearance="subtle" size="large" shape="circular" appearance="subtle" title={t('Clear')}
onClick={(e) => { contentText={t('Are you sure you want to clear the conversation? It cannot be undone.')}
onConfirm={() => {
if (generating) if (generating)
chatSseController?.abort(); chatSseController?.abort();
commonStore.setConversations({}); commonStore.setConversations({});
commonStore.setConversationsOrder([]); commonStore.setConversationsOrder([]);
}} }} />
/>
<Textarea <Textarea
ref={inputRef} ref={inputRef}
className="grow" className="grow"