From 8dbf3ce52fc0226bedfced67ae92992597b49f74 Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Thu, 28 Nov 2024 03:00:18 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style:=20add=20switch=20portal?= =?UTF-8?q?=20thread=20(#4819)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 💄 style: improve i18n * 💄 style: add switch portal thread * style: improve i18n --- locales/ar/chat.json | 1 + locales/bg-BG/chat.json | 1 + locales/de-DE/chat.json | 1 + locales/en-US/chat.json | 1 + locales/es-ES/chat.json | 1 + locales/fa-IR/chat.json | 1 + locales/fr-FR/chat.json | 1 + locales/it-IT/chat.json | 1 + locales/ja-JP/chat.json | 1 + locales/ko-KR/chat.json | 1 + locales/nl-NL/chat.json | 1 + locales/pl-PL/chat.json | 1 + locales/pt-BR/chat.json | 1 + locales/ru-RU/chat.json | 1 + locales/tr-TR/chat.json | 1 + locales/vi-VN/chat.json | 1 + locales/zh-CN/chat.json | 1 + locales/zh-TW/chat.json | 1 + .../Conversation/components/History/index.tsx | 5 +-- src/features/Portal/Thread/Header/index.tsx | 33 ++++++++++++++++--- src/locales/default/chat.ts | 1 + 21 files changed, 50 insertions(+), 7 deletions(-) diff --git a/locales/ar/chat.json b/locales/ar/chat.json index 8261433bf3d6..c5c0a7c369be 100644 --- a/locales/ar/chat.json +++ b/locales/ar/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} نسخة", "emptyAgent": "لا يوجد مساعد", "historyRange": "نطاق التاريخ", + "historySummary": "ملخص الرسائل التاريخية", "inbox": { "desc": "قم بتشغيل مجموعة الدماغ وأشعل شرارة التفكير. مساعدك الذكي، هنا حيث يمكنك التواصل بكل شيء", "title": "دردشة عشوائية" diff --git a/locales/bg-BG/chat.json b/locales/bg-BG/chat.json index b20a5c765b06..4e58a43c70d1 100644 --- a/locales/bg-BG/chat.json +++ b/locales/bg-BG/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} Копие", "emptyAgent": "Няма наличен асистент", "historyRange": "Диапазон на историята", + "historySummary": "Исторически обобщение на съобщения", "inbox": { "desc": "Активирай мозъчния клъстер и събуди креативното мислене. Твоят виртуален агент е тук, за да общува с теб за всичко.", "title": "Просто чати" diff --git a/locales/de-DE/chat.json b/locales/de-DE/chat.json index 3e6085a3c7d0..ec75cbce915e 100644 --- a/locales/de-DE/chat.json +++ b/locales/de-DE/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} Kopie", "emptyAgent": "Kein Assistent verfügbar", "historyRange": "Verlaufsbereich", + "historySummary": "Zusammenfassung historischer Nachrichten", "inbox": { "desc": "Aktiviere das Gehirncluster und entfache den Funken des Denkens. Dein intelligenter Assistent, der mit dir über alles kommuniziert.", "title": "Lass uns plaudern" diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json index b839dd14b0c9..f2fade0c1819 100644 --- a/locales/en-US/chat.json +++ b/locales/en-US/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} Copy", "emptyAgent": "No assistant available", "historyRange": "History Range", + "historySummary": "Historical Message Summary", "inbox": { "desc": "Activate the brain cluster and spark creative thinking. Your virtual assistant is here to communicate with you about everything.", "title": "Just Chat" diff --git a/locales/es-ES/chat.json b/locales/es-ES/chat.json index 30e4dfe1dd31..5b4ade1727e5 100644 --- a/locales/es-ES/chat.json +++ b/locales/es-ES/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} Copia", "emptyAgent": "No hay asistente disponible", "historyRange": "Rango de historial", + "historySummary": "Resumen de mensajes históricos", "inbox": { "desc": "Despierta la mente con el poder del cerebro colectivo. Tu asistente inteligente está aquí para conversar contigo sobre cualquier cosa.", "title": "Charla casual" diff --git a/locales/fa-IR/chat.json b/locales/fa-IR/chat.json index 65ef4d4b2ff2..13f0337069ce 100644 --- a/locales/fa-IR/chat.json +++ b/locales/fa-IR/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "نسخه‌ای از {{title}}", "emptyAgent": "دستیار موجود نیست", "historyRange": "محدوده تاریخی", + "historySummary": "خلاصه پیام‌های تاریخی", "inbox": { "desc": "خوشه‌های مغزی را فعال کنید و جرقه‌های تفکر را برانگیزید. دستیار هوشمند شما اینجاست تا با شما در مورد هر چیزی صحبت کند.", "title": "گپ دوستانه" diff --git a/locales/fr-FR/chat.json b/locales/fr-FR/chat.json index c7c9431df9a3..960f2b32b4b3 100644 --- a/locales/fr-FR/chat.json +++ b/locales/fr-FR/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} Copie", "emptyAgent": "Aucun assistant disponible", "historyRange": "Plage d'historique", + "historySummary": "Résumé des messages historiques", "inbox": { "desc": "Débloquez le potentiel de votre esprit. Votre agent intelligent est là pour discuter avec vous de tout et de rien.", "title": "Discutons un peu" diff --git a/locales/it-IT/chat.json b/locales/it-IT/chat.json index 57a80b3c9ffa..4bc341a35369 100644 --- a/locales/it-IT/chat.json +++ b/locales/it-IT/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} Copia", "emptyAgent": "Nessun assistente disponibile", "historyRange": "Intervallo cronologico", + "historySummary": "Riepilogo della storia", "inbox": { "desc": "Attiva il cluster cerebrale, accendi la scintilla del pensiero. Il tuo assistente intelligente, qui per comunicare con te su tutto.", "title": "Chiacchierata casuale" diff --git a/locales/ja-JP/chat.json b/locales/ja-JP/chat.json index ace45b4ece04..50897c0ba489 100644 --- a/locales/ja-JP/chat.json +++ b/locales/ja-JP/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} のコピー", "emptyAgent": "エージェントがいません", "historyRange": "履歴範囲", + "historySummary": "履歴メッセージの要約", "inbox": { "desc": "脳のクラスターを起動し、創造性を引き出しましょう。あなたのスマートアシスタントは、あなたとすべてのことについてここでコミュニケーションします。", "title": "気軽におしゃべり" diff --git a/locales/ko-KR/chat.json b/locales/ko-KR/chat.json index 22bf93439610..439af05c28b7 100644 --- a/locales/ko-KR/chat.json +++ b/locales/ko-KR/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} 복사본", "emptyAgent": "도우미가 없습니다", "historyRange": "대화 기록 범위", + "historySummary": "역사 메시지 요약", "inbox": { "desc": "뇌 클러스터를 활성화하여 창의적인 아이디어를 끌어내는 인공지능 비서입니다. 여기서 모든 것에 대해 대화합니다.", "title": "무작위 대화" diff --git a/locales/nl-NL/chat.json b/locales/nl-NL/chat.json index 5b3935ca09f1..a6116797935e 100644 --- a/locales/nl-NL/chat.json +++ b/locales/nl-NL/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} Kopie", "emptyAgent": "Geen assistent beschikbaar", "historyRange": "Geschiedenisbereik", + "historySummary": "Geschiedenis samenvatting", "inbox": { "desc": "Activeer de hersencluster en laat de vonken van gedachten overslaan. Je slimme assistent, hier om met je over alles te praten.", "title": "Praat maar raak" diff --git a/locales/pl-PL/chat.json b/locales/pl-PL/chat.json index c13b847e5e3d..bf18d25f4d4e 100644 --- a/locales/pl-PL/chat.json +++ b/locales/pl-PL/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} kopia", "emptyAgent": "Brak asystenta", "historyRange": "Zakres historii", + "historySummary": "Podsumowanie wiadomości historycznych", "inbox": { "desc": "Włącz klastry mózgów, rozpal iskrę myślenia. Twój inteligentny asystent, gotowy do rozmowy o wszystkim.", "title": "Pogadajmy sobie" diff --git a/locales/pt-BR/chat.json b/locales/pt-BR/chat.json index d3268a3eefc7..e5e29442a4a1 100644 --- a/locales/pt-BR/chat.json +++ b/locales/pt-BR/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} Cópia", "emptyAgent": "Sem assistente disponível", "historyRange": "Intervalo de Histórico", + "historySummary": "Resumo das mensagens históricas", "inbox": { "desc": "Ative o cluster cerebral, inspire faíscas de pensamento. Seu assistente inteligente, aqui para conversar sobre tudo.", "title": "Conversa Aleatória" diff --git a/locales/ru-RU/chat.json b/locales/ru-RU/chat.json index f1880154853d..12d326aeda5c 100644 --- a/locales/ru-RU/chat.json +++ b/locales/ru-RU/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} Копия", "emptyAgent": "Нет ассистента", "historyRange": "История сообщений", + "historySummary": "Сводка исторических сообщений", "inbox": { "desc": "Зажги искру мысли, открой кластер мозгов. Твой виртуальный ассистент, готовый обсудить все с тобой.", "title": "Просто поболтаем" diff --git a/locales/tr-TR/chat.json b/locales/tr-TR/chat.json index 0f61de77a3f7..9d44c8314b04 100644 --- a/locales/tr-TR/chat.json +++ b/locales/tr-TR/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} Kopya", "emptyAgent": "Asistan yok", "historyRange": "Geçmiş Aralığı", + "historySummary": "Tarihsel haber özeti", "inbox": { "desc": "Beyin fırtınasını başlatın ve yaratıcı düşünmeye başlayın. Sanal asistanınız burada, her konuda sizinle iletişim kurmak için hazır.", "title": "Sohbet Et" diff --git a/locales/vi-VN/chat.json b/locales/vi-VN/chat.json index 95584968ec22..0e349fbafd5a 100644 --- a/locales/vi-VN/chat.json +++ b/locales/vi-VN/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} Bản sao", "emptyAgent": "Không có trợ lý", "historyRange": "Phạm vi lịch sử", + "historySummary": "Tóm tắt tin tức lịch sử", "inbox": { "desc": "Kích hoạt cụm não, khơi dậy tia lửa tư duy. Trợ lý thông minh của bạn, ở đây để trò chuyện với bạn về mọi thứ.", "title": "Chuyện phiếm" diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json index beb82fe02dd6..9bd8da7119fe 100644 --- a/locales/zh-CN/chat.json +++ b/locales/zh-CN/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} 副本", "emptyAgent": "暂无助手", "historyRange": "历史范围", + "historySummary": "历史消息总结", "inbox": { "desc": "开启大脑集群,激发思维火花。你的智能助理,在这里与你交流一切", "title": "随便聊聊" diff --git a/locales/zh-TW/chat.json b/locales/zh-TW/chat.json index 0420f783f286..6328062adc38 100644 --- a/locales/zh-TW/chat.json +++ b/locales/zh-TW/chat.json @@ -32,6 +32,7 @@ "duplicateTitle": "{{title}} 副本", "emptyAgent": "暫無助手", "historyRange": "歷史範圍", + "historySummary": "歷史消息總結", "inbox": { "desc": "開啟大腦集群,激發思維火花。你的智能助理,在這裡與你交流一切", "title": "隨便聊聊" diff --git a/src/features/Conversation/components/History/index.tsx b/src/features/Conversation/components/History/index.tsx index c834371adf31..3c90965c43fd 100644 --- a/src/features/Conversation/components/History/index.tsx +++ b/src/features/Conversation/components/History/index.tsx @@ -4,6 +4,7 @@ import { Typography } from 'antd'; import { createStyles } from 'antd-style'; import { ScrollText } from 'lucide-react'; import { memo } from 'react'; +import { useTranslation } from 'react-i18next'; import { Center, Flexbox } from 'react-layout-kit'; import { useChatStore } from '@/store/chat'; @@ -28,6 +29,7 @@ const useStyles = createStyles(({ css, token }) => ({ const History = memo(() => { const { styles, theme } = useStyles(); + const { t } = useTranslation('chat'); const [content, model] = useChatStore((s) => { const history = topicSelectors.currentActiveTopicSummary(s); return [history?.content, history?.model]; @@ -46,8 +48,7 @@ const History = memo(() => { style={{ color: theme.colorTextDescription }} /> - 历史消息总结 - + {t('historySummary')} {model && (
diff --git a/src/features/Portal/Thread/Header/index.tsx b/src/features/Portal/Thread/Header/index.tsx index 7c46ae22d3ce..92393ce928ad 100644 --- a/src/features/Portal/Thread/Header/index.tsx +++ b/src/features/Portal/Thread/Header/index.tsx @@ -1,20 +1,43 @@ import { ActionIcon } from '@lobehub/ui'; -import { XIcon } from 'lucide-react'; +import { ArrowLeftRight, XIcon } from 'lucide-react'; +import { memo } from 'react'; +import { Flexbox } from 'react-layout-kit'; import SidebarHeader from '@/components/SidebarHeader'; import { useChatStore } from '@/store/chat'; import Title from './Title'; -const Header = () => { - const closeThreadPortal = useChatStore((s) => s.closeThreadPortal); +const Header = memo(() => { + const [hasPortal, portalThreadId, closeThreadPortal, switchThread] = useChatStore((s) => [ + !!s.portalThreadId, + s.portalThreadId, + s.closeThreadPortal, + s.switchThread, + ]); + return ( } + actions={ + + {hasPortal && ( + { + if (!portalThreadId) return; + + switchThread(portalThreadId); + closeThreadPortal(); + }} + /> + )} + + + } style={{ paddingBlock: 8, paddingInline: 8 }} title={} /> ); -}; +}); export default Header; diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.ts index b09a545e0599..29087c9260e3 100644 --- a/src/locales/default/chat.ts +++ b/src/locales/default/chat.ts @@ -33,6 +33,7 @@ export default { duplicateTitle: '{{title}} 副本', emptyAgent: '暂无助手', historyRange: '历史范围', + historySummary: '历史消息总结', inbox: { desc: '开启大脑集群,激发思维火花。你的智能助理,在这里与你交流一切', title: '随便聊聊',