Skip to content

Commit 42d431d

Browse files
committed
feat: remove header ssr
1 parent bb2d370 commit 42d431d

File tree

7 files changed

+57
-4
lines changed

7 files changed

+57
-4
lines changed

src/components/Main.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Conversation from './main/Conversation'
88
---
99

1010
<main class="relative h-full flex-1 flex flex-col overflow-hidden bg-base">
11-
<Header client:load />
11+
<Header client:only />
1212
<main class="flex-1 mt-14 flex flex-col overflow-hidden">
1313
<div class="flex-1 relative overflow-hidden">
1414
<Conversation client:only />
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
11
import { useStore } from '@nanostores/solid'
22
import { currentConversationId } from '@/stores/conversation'
3-
import { scrollController } from '@/stores/ui'
3+
import {
4+
scrollController,
5+
showConfirmModal,
6+
} from '@/stores/ui'
47
import { clearMessagesByConversationId } from '@/stores/messages'
8+
import { useI18n } from '@/hooks'
9+
import ConfirmModal from '../ui/ConfirmModal'
510

611
export default () => {
712
const $currentConversationId = useStore(currentConversationId)
13+
const { t } = useI18n()
814

915
const handleClearMessage = () => {
1016
clearMessagesByConversationId($currentConversationId())
1117
scrollController().scrollToBottom()
18+
showConfirmModal.set(false)
1219
}
1320

1421
return (
1522
<>
16-
{ $currentConversationId() && (
23+
{$currentConversationId() && (
1724
<div
1825
class="fcc p-2 rounded-md text-xl hv-foreground"
19-
onClick={handleClearMessage}
26+
onClick={() => { showConfirmModal.set(true) }}
2027
>
2128
<div i-carbon-clean />
2229
</div>
2330
)}
31+
<ConfirmModal title={t('conversations.confirm.title')} description={t('conversations.confirm.desc')} onConfirm={handleClearMessage} onCancel={() => { showConfirmModal.set(false) }} />
2432
</>
2533
)
2634
}

src/components/ui/ConfirmModal.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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="hidden" >
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+
}

src/locale/lang/en.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export const en = {
2424
recent: 'Recents',
2525
noRecent: 'No recents',
2626
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+
},
2734
},
2835
send: {
2936
placeholder: 'Enter Something...',

src/locale/lang/zh-cn.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export const zhCN = {
2424
recent: '最近对话',
2525
noRecent: '暂无最近对话',
2626
untitled: '未命名对话',
27+
confirm: {
28+
title: '删除本会话的所有消息',
29+
desc: '这将删除本会话的所有消息,且不可恢复',
30+
message: '删除这条记录',
31+
btn: '确认',
32+
cancel: '取消',
33+
},
2734
},
2835
send: {
2936
placeholder: '输入内容...',

src/stores/ui.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const showConversationSidebar = atom(false)
55
export const showSettingsSidebar = atom(false)
66
export const showConversationEditModal = atom(false)
77
export const showEmojiPickerModal = atom(false)
8+
export const showConfirmModal = atom(false)
89

910
export const isSendBoxFocus = atom(false)
1011
export const currentErrorMessage = atom<ErrorMessage | null>(null)

unocss.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default defineConfig({
5858
'hv-foreground': 'transition-opacity cursor-pointer op-70 hover:op-100',
5959
'input-base': 'bg-transparent placeholder:op-50 dark:placeholder:op-20 focus:(ring-0 outline-none) resize-none',
6060
'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',
6162
'max-w-base': 'max-w-3xl mx-auto',
6263
'text-error': 'text-red-700 dark:text-red-400/80',
6364
'border-error': 'border border-red-700 dark:border-red-400/80',

0 commit comments

Comments
 (0)