diff --git a/src/components/header/ConversationMessageClearButton.tsx b/src/components/header/ConversationMessageClearButton.tsx index 48a9be6c..faf7ef02 100644 --- a/src/components/header/ConversationMessageClearButton.tsx +++ b/src/components/header/ConversationMessageClearButton.tsx @@ -1,14 +1,21 @@ import { useStore } from '@nanostores/solid' import { currentConversationId } from '@/stores/conversation' -import { scrollController } from '@/stores/ui' +import { + scrollController, + showConfirmModal, +} from '@/stores/ui' import { clearMessagesByConversationId } from '@/stores/messages' +import { useI18n } from '@/hooks' +import ConfirmModal from '../ui/ConfirmModal' export default () => { const $currentConversationId = useStore(currentConversationId) + const { t } = useI18n() const handleClearMessage = () => { clearMessagesByConversationId($currentConversationId()) scrollController().scrollToBottom() + showConfirmModal.set(false) } return ( @@ -16,11 +23,12 @@ export default () => { { $currentConversationId() && (
{ showConfirmModal.set(true) }} >
)} + { showConfirmModal.set(false) }} /> ) } diff --git a/src/components/main/Conversation.tsx b/src/components/main/Conversation.tsx index f84c4150..d17524e1 100644 --- a/src/components/main/Conversation.tsx +++ b/src/components/main/Conversation.tsx @@ -33,7 +33,7 @@ export default () => { - )} + )} > @@ -52,9 +52,8 @@ export default () => { diff --git a/src/components/ui/ConfirmModal.tsx b/src/components/ui/ConfirmModal.tsx new file mode 100644 index 00000000..b75c6df0 --- /dev/null +++ b/src/components/ui/ConfirmModal.tsx @@ -0,0 +1,29 @@ +import { + showConfirmModal, +} from '@/stores/ui' +import { useI18n } from '@/hooks' +import Modal from './Modal' + +interface Props { + title: string + description: string + onConfirm: () => void + onCancel: () => void +} + +export default (props: Props) => { + const { t } = useI18n() + return ( + +
+
+

{props.title}

{props.description}

+
+ + +
+
+
+
+ ) +} diff --git a/src/components/ui/Modal.tsx b/src/components/ui/Modal.tsx index 4c201ef6..6763acf6 100644 --- a/src/components/ui/Modal.tsx +++ b/src/components/ui/Modal.tsx @@ -11,6 +11,7 @@ interface Props { direction: 'top' | 'bottom' | 'left' | 'right' children: JSXElement closeBtnClass?: string + hiddenCloseIcon?: boolean } export default (props: Props) => { @@ -45,9 +46,9 @@ export default (props: Props) => {
- + { + !props.hiddenCloseIcon && + } { props.children }
diff --git a/src/locale/lang/en.ts b/src/locale/lang/en.ts index 2cd7ee7b..84f19d3c 100644 --- a/src/locale/lang/en.ts +++ b/src/locale/lang/en.ts @@ -24,6 +24,13 @@ export const en = { recent: 'Recents', noRecent: 'No recents', untitled: 'Untitled', + confirm: { + title: 'Delete all messages in this chat', + desc: 'This action cannot be undone.', + message: 'Delete this record', + btn: 'confirm', + cancel: 'cancel', + }, }, send: { placeholder: 'Enter Something...', diff --git a/src/locale/lang/zh-cn.ts b/src/locale/lang/zh-cn.ts index 66c3cd64..9dbc92c5 100644 --- a/src/locale/lang/zh-cn.ts +++ b/src/locale/lang/zh-cn.ts @@ -24,6 +24,13 @@ export const zhCN = { recent: '最近对话', noRecent: '暂无最近对话', untitled: '未命名对话', + confirm: { + title: '删除本会话的所有消息', + desc: '这将删除本会话的所有消息,且不可恢复', + message: '删除这条记录', + btn: '确认', + cancel: '取消', + }, }, send: { placeholder: '输入内容...', diff --git a/src/stores/ui.ts b/src/stores/ui.ts index e733dd3d..7990c17d 100644 --- a/src/stores/ui.ts +++ b/src/stores/ui.ts @@ -5,6 +5,7 @@ export const showConversationSidebar = atom(false) export const showSettingsSidebar = atom(false) export const showConversationEditModal = atom(false) export const showEmojiPickerModal = atom(false) +export const showConfirmModal = atom(false) export const isSendBoxFocus = atom(false) export const currentErrorMessage = atom(null) diff --git a/unocss.config.ts b/unocss.config.ts index db08cef1..83741e01 100644 --- a/unocss.config.ts +++ b/unocss.config.ts @@ -58,6 +58,7 @@ export default defineConfig({ 'hv-foreground': 'transition-opacity cursor-pointer op-70 hover:op-100', 'input-base': 'bg-transparent placeholder:op-50 dark:placeholder:op-20 focus:(ring-0 outline-none) resize-none', 'button': 'mt-4 px-3 py-2 text-xs border border-base rounded-lg hv-base hover:border-base-100', + 'emerald-button': 'mt-4 px-3 py-2 text-xs border rounded-lg text-light-400 border-emerald-600 bg-emerald-600 hover-bg-emerald-700 hover-border-emerald-700', 'max-w-base': 'max-w-3xl mx-auto', 'text-error': 'text-red-700 dark:text-red-400/80', 'border-error': 'border border-red-700 dark:border-red-400/80',