File tree Expand file tree Collapse file tree 8 files changed +61
-8
lines changed Expand file tree Collapse file tree 8 files changed +61
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { useStore } from '@nanostores/solid'
2
2
import { currentConversationId } from '@/stores/conversation'
3
- import { scrollController } from '@/stores/ui'
3
+ import {
4
+ scrollController ,
5
+ showConfirmModal ,
6
+ } from '@/stores/ui'
4
7
import { clearMessagesByConversationId } from '@/stores/messages'
8
+ import { useI18n } from '@/hooks'
9
+ import ConfirmModal from '../ui/ConfirmModal'
5
10
6
11
export default ( ) => {
7
12
const $currentConversationId = useStore ( currentConversationId )
13
+ const { t } = useI18n ( )
8
14
9
15
const handleClearMessage = ( ) => {
10
16
clearMessagesByConversationId ( $currentConversationId ( ) )
11
17
scrollController ( ) . scrollToBottom ( )
18
+ showConfirmModal . set ( false )
12
19
}
13
20
14
21
return (
15
22
< >
16
23
{ $currentConversationId ( ) && (
17
24
< div
18
25
class = "fcc p-2 rounded-md text-xl hv-foreground"
19
- onClick = { handleClearMessage }
26
+ onClick = { ( ) => { showConfirmModal . set ( true ) } }
20
27
>
21
28
< div i-carbon-clean />
22
29
</ div >
23
30
) }
31
+ < ConfirmModal title = { t ( 'conversations.confirm.title' ) } description = { t ( 'conversations.confirm.desc' ) } onConfirm = { handleClearMessage } onCancel = { ( ) => { showConfirmModal . set ( false ) } } />
24
32
</ >
25
33
)
26
34
}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export default () => {
33
33
< Switch
34
34
fallback = { (
35
35
< Welcome />
36
- ) }
36
+ ) }
37
37
>
38
38
< Match when = { $currentConversationId ( ) && ! currentConversationMessages ( ) . length } >
39
39
< ConversationEmpty conversation = { currentConversation ( ) } />
@@ -52,9 +52,8 @@ export default () => {
52
52
</ Match >
53
53
< Match when = { currentBot ( ) ?. type === 'image_generation' } >
54
54
< Image
55
- // conversationId={$currentConversationId()}
55
+ // conversationId={$currentConversationId()}
56
56
messages = { currentConversationMessages }
57
- // fetching={isLoading() || !isStreaming()}
58
57
/>
59
58
</ Match >
60
59
</ Switch >
Original file line number Diff line number Diff line change
1
+ import {
2
+ showConfirmModal ,
3
+ } from '@/stores/ui'
4
+ import { useI18n } from '@/hooks'
5
+ import Modal from './Modal'
6
+
7
+ interface Props {
8
+ title : string
9
+ description : string
10
+ onConfirm : ( ) => void
11
+ onCancel : ( ) => void
12
+ }
13
+
14
+ export default ( props : Props ) => {
15
+ const { t } = useI18n ( )
16
+ return (
17
+ < Modal bindValue = { showConfirmModal } direction = "bottom" closeBtnClass = "top-6 right-6" hiddenCloseIcon >
18
+ < div class = "max-h-[70vh] w-full" >
19
+ < div class = "grid w-full max-w-lg scale-100 gap-4 border-base sm:border bg-white dark:bg-zinc-900/90 dark:backdrop-blur-lg p-6 opacity-100 shadow-lg sm:rounded-lg md:w-full" >
20
+ < div class = "flex flex-col space-y-2 text-center sm:text-left" > < h2 id = "radix-:rl:" class = "text-lg font-semibold" > { props . title } </ h2 > < p id = "radix-:rm:" class = "text-sm text-muted-foreground" > { props . description } </ p > </ div >
21
+ < div class = "flex flex-col-reverse sm:flex-row sm:justify-end gap-2" >
22
+ < button class = "button" onClick = { ( ) => props . onCancel ( ) } > { t ( 'conversations.confirm.cancel' ) } </ button >
23
+ < button class = "emerald-button" onClick = { ( ) => props . onConfirm ( ) } > { t ( 'conversations.confirm.btn' ) } </ button >
24
+ </ div >
25
+ </ div >
26
+ </ div >
27
+ </ Modal >
28
+ )
29
+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ interface Props {
11
11
direction : 'top' | 'bottom' | 'left' | 'right'
12
12
children : JSXElement
13
13
closeBtnClass ?: string
14
+ hiddenCloseIcon ?: boolean
14
15
}
15
16
16
17
export default ( props : Props ) => {
@@ -45,9 +46,9 @@ export default (props: Props) => {
45
46
</ Portal >
46
47
< div { ...api ( ) . containerProps } >
47
48
< div { ...api ( ) . contentProps } class = { `bg-modal transition-transform ease-out max-w-screen max-h-screen overflow-auto border-base shadow-lg ring-0 outline-none ${ containerBaseClass } ` } >
48
- < button { ... api ( ) . closeTriggerProps } class = { `absolute p-1 rounded-md top-4 right-4 hv-base hv-foreground ${ props . closeBtnClass || '' } ` } >
49
- < div i-carbon-close class = "text-xl" />
50
- </ button >
49
+ {
50
+ ! props . hiddenCloseIcon && < button { ... api ( ) . closeTriggerProps } class = { `absolute p-1 rounded-md top-4 right-4 hv-base hv-foreground ${ props . closeBtnClass || '' } ` } > < div i-carbon-close class = "text-xl" /> </ button >
51
+ }
51
52
{ props . children }
52
53
</ div >
53
54
</ div >
Original file line number Diff line number Diff line change @@ -24,6 +24,13 @@ export const en = {
24
24
recent : 'Recents' ,
25
25
noRecent : 'No recents' ,
26
26
untitled : 'Untitled' ,
27
+ confirm : {
28
+ title : 'Delete all messages in this chat' ,
29
+ desc : 'This action cannot be undone.' ,
30
+ message : 'Delete this record' ,
31
+ btn : 'confirm' ,
32
+ cancel : 'cancel' ,
33
+ } ,
27
34
} ,
28
35
send : {
29
36
placeholder : 'Enter Something...' ,
Original file line number Diff line number Diff line change @@ -24,6 +24,13 @@ export const zhCN = {
24
24
recent : '最近对话' ,
25
25
noRecent : '暂无最近对话' ,
26
26
untitled : '未命名对话' ,
27
+ confirm : {
28
+ title : '删除本会话的所有消息' ,
29
+ desc : '这将删除本会话的所有消息,且不可恢复' ,
30
+ message : '删除这条记录' ,
31
+ btn : '确认' ,
32
+ cancel : '取消' ,
33
+ } ,
27
34
} ,
28
35
send : {
29
36
placeholder : '输入内容...' ,
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ export const showConversationSidebar = atom(false)
5
5
export const showSettingsSidebar = atom ( false )
6
6
export const showConversationEditModal = atom ( false )
7
7
export const showEmojiPickerModal = atom ( false )
8
+ export const showConfirmModal = atom ( false )
8
9
9
10
export const isSendBoxFocus = atom ( false )
10
11
export const currentErrorMessage = atom < ErrorMessage | null > ( null )
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ export default defineConfig({
58
58
'hv-foreground' : 'transition-opacity cursor-pointer op-70 hover:op-100' ,
59
59
'input-base' : 'bg-transparent placeholder:op-50 dark:placeholder:op-20 focus:(ring-0 outline-none) resize-none' ,
60
60
'button' : 'mt-4 px-3 py-2 text-xs border border-base rounded-lg hv-base hover:border-base-100' ,
61
+ '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' ,
61
62
'max-w-base' : 'max-w-3xl mx-auto' ,
62
63
'text-error' : 'text-red-700 dark:text-red-400/80' ,
63
64
'border-error' : 'border border-red-700 dark:border-red-400/80' ,
You can’t perform that action at this time.
0 commit comments