feat: 对话语言国际化

This commit is contained in:
DEV_DSW
2026-04-21 11:46:45 +08:00
parent 0e10ae9e35
commit 5db3e5714f
2 changed files with 20 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import { memo, useEffect, useRef } from 'react';
import type { ChatMessageItem } from './types';
import { useI18n } from '../../i18n';
type ChatMessageListProps = {
messages: ChatMessageItem[];
@@ -8,6 +9,7 @@ type ChatMessageListProps = {
function ChatMessageList({ messages, loading }: ChatMessageListProps) {
const containerRef = useRef<HTMLDivElement | null>(null);
const { t } = useI18n();
useEffect(() => {
const container = containerRef.current;
@@ -20,12 +22,12 @@ function ChatMessageList({ messages, loading }: ChatMessageListProps) {
<div ref={containerRef} className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pr-1">
{loading ? (
<div className="rounded-[18px] border border-dashed border-[#BEDBFF] bg-[#EFF6FF] px-4 py-3 text-sm text-[#525866] dark:border-[#2a2a2d] dark:bg-[#1f1f22] dark:text-gray-400">
...
{t('conversation.messageList.loading')}
</div>
) : null}
{!loading && messages.length === 0 ? (
<div className="rounded-[18px] border border-dashed border-[#BEDBFF] bg-[#EFF6FF] px-4 py-6 text-sm leading-7 text-[#525866] dark:border-[#2a2a2d] dark:bg-[#1f1f22] dark:text-gray-400">
{t('conversation.messageList.emptyHint')}
</div>
) : null}
{messages.map((message) => (
@@ -81,7 +83,7 @@ function ChatMessageList({ messages, loading }: ChatMessageListProps) {
</div>
) : null}
{message.isStreaming ? (
<div className="mt-3 text-xs text-[#2B7FFF]">...</div>
<div className="mt-3 text-xs text-[#2B7FFF]">{t('conversation.messageList.streaming')}</div>
) : null}
</div>
</article>