From 306817741f5169bf0758b51dae9d9d6d20497520 Mon Sep 17 00:00:00 2001 From: duanfuxiang Date: Mon, 7 Jul 2025 18:09:38 +0800 Subject: [PATCH] Remove the `markdown-to-text` dependency, update the `package.json` file, enhance internationalization support for chat history view components, optimize user interaction prompts, and improve both user experience and code readability. --- package.json | 1 - src/components/chat-view/ChatHistoryView.tsx | 38 +++++++------- src/components/chat-view/ChatView.tsx | 28 +++++------ src/components/chat-view/HelloInfo.tsx | 52 ++++++++++++-------- src/components/chat-view/InsightView.tsx | 22 ++++----- src/components/chat-view/SearchView.tsx | 2 +- src/embedworker/embed.worker.ts | 2 +- src/lang/locale/en.ts | 44 +++++++++++++++-- src/lang/locale/zh-cn.ts | 43 ++++++++++++++-- src/types/settings.test.ts | 10 ++++ 10 files changed, 169 insertions(+), 73 deletions(-) diff --git a/package.json b/package.json index d20a818..f578ff5 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,6 @@ "lodash.isequal": "^4.5.0", "lru-cache": "^10.1.0", "lucide-react": "^0.447.0", - "markdown-to-text": "^0.1.1", "mermaid": "^11.6.0", "micromatch": "^4.0.5", "minimatch": "^10.0.1", diff --git a/src/components/chat-view/ChatHistoryView.tsx b/src/components/chat-view/ChatHistoryView.tsx index 1fdad65..b277d15 100644 --- a/src/components/chat-view/ChatHistoryView.tsx +++ b/src/components/chat-view/ChatHistoryView.tsx @@ -49,7 +49,7 @@ const ChatHistoryView = ({ const titleInputRefs = useRef>(new Map()) const handleCleanup = async () => { - const confirmed = confirm('此操作将永久删除所有对话的历史版本,只保留最新版。这有助于清理数据,但操作不可撤销。确定要继续吗?') + const confirmed = confirm(String(t('chat.history.cleanupConfirm'))) if (!confirmed) { return } @@ -57,12 +57,12 @@ const ChatHistoryView = ({ try { const count = await cleanupOutdatedChats() if (count > 0) { - new Notice(`成功清理了 ${count} 个过时的对话文件。`) + new Notice(String(t('chat.history.cleanupSuccess', { count }))) } else { - new Notice('没有需要清理的对话文件。') + new Notice(String(t('chat.history.cleanupNone'))) } } catch (error) { - new Notice('清理失败,请检查开发者控制台获取更多信息。') + new Notice(String(t('chat.history.cleanupFailed'))) console.error('Failed to cleanup outdated chats', error) } } @@ -145,12 +145,12 @@ const ChatHistoryView = ({ // batch delete selected conversations const handleBatchDelete = async () => { if (selectedConversations.size === 0) { - new Notice('请先选择要删除的对话') + new Notice(String(t('chat.history.selectFirst'))) return } // show confirmation - const confirmed = confirm(`确定要删除选中的 ${selectedConversations.size} 个对话吗?此操作不可撤销。`) + const confirmed = confirm(String(t('chat.history.batchDeleteConfirm', { count: selectedConversations.size }))) if (!confirmed) { return } @@ -172,10 +172,10 @@ const ChatHistoryView = ({ // show results if (deletedIds.length > 0) { - new Notice(`成功删除 ${deletedIds.length} 个对话`) + new Notice(String(t('chat.history.batchDeleteSuccess', { count: deletedIds.length }))) } if (errors.length > 0) { - new Notice(`${errors.length} 个对话删除失败`) + new Notice(String(t('chat.history.batchDeleteFailed', { count: errors.length }))) } // clear selections @@ -241,18 +241,18 @@ const ChatHistoryView = ({ @@ -260,7 +260,7 @@ const ChatHistoryView = ({ {/* description */}
{selectionMode - ? `选择模式 - 已选择 ${selectedConversations.size} 个对话` + ? String(t('chat.history.selectionMode', { count: selectedConversations.size })) : String(t('chat.history.description')) }
@@ -276,12 +276,12 @@ const ChatHistoryView = ({ {isAllSelected ? ( <> - 取消全选 + {t('chat.history.unselectAll')} ) : ( <> - 全选 + {t('chat.history.selectAll')} )} @@ -293,7 +293,7 @@ const ChatHistoryView = ({ className="infio-chat-history-batch-delete-btn" > - 批量删除 ({selectedConversations.size}) + {t('chat.history.batchDelete')} ({selectedConversations.size}) @@ -316,10 +316,10 @@ const ChatHistoryView = ({ @@ -393,7 +393,7 @@ const ChatHistoryView = ({
{conversation.title}
{conversation.workspace && (
- 工作区: {conversation.workspace} + {t('chat.history.workspaceLabel', { workspace: conversation.workspace })}
)} diff --git a/src/components/chat-view/ChatView.tsx b/src/components/chat-view/ChatView.tsx index 3035326..9db67ad 100644 --- a/src/components/chat-view/ChatView.tsx +++ b/src/components/chat-view/ChatView.tsx @@ -2,7 +2,7 @@ import * as path from 'path' import { BaseSerializedNode } from '@lexical/clipboard/clipboard' import { useMutation } from '@tanstack/react-query' -import { Box, Brain, CircleStop, History, NotebookPen, Plus, Search, Server, SquareSlash, Undo } from 'lucide-react' +import { Box, Lightbulb, CircleStop, History, NotebookPen, Plus, Search, Server, SquareSlash, Undo } from 'lucide-react' import { App, Notice, TFile, TFolder, WorkspaceLeaf } from 'obsidian' import { forwardRef, @@ -193,7 +193,7 @@ const Chat = forwardRef((props, ref) => { } } - const [tab, setTab] = useState<'chat' | 'commands' | 'custom-mode' | 'mcp' | 'search' | 'history' | 'workspace' | 'insights'>('search') + const [tab, setTab] = useState<'chat' | 'commands' | 'custom-mode' | 'mcp' | 'search' | 'history' | 'workspace' | 'insights'>('chat') const [selectedSerializedNodes, setSelectedSerializedNodes] = useState([]) @@ -1310,18 +1310,6 @@ const Chat = forwardRef((props, ref) => { > - +