From 3b0683faf9b763a7e2b54af2e04446eb94beb66f Mon Sep 17 00:00:00 2001 From: gaoziman <2942894660@qq.com> Date: Sun, 21 Dec 2025 14:04:08 +0800 Subject: [PATCH] =?UTF-8?q?style(=E7=95=8C=E9=9D=A2):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2=E5=92=8C=20API=20Key=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 聊天页面添加 API Key 未配置提示卡片 - 移除设置页面的 CCH URL 配置项(使用默认值) - 简化保存配置逻辑 --- src/app/chat/[id]/page.tsx | 27 ++++++++++++++++++++++++++- src/app/settings/page.tsx | 19 +------------------ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/app/chat/[id]/page.tsx b/src/app/chat/[id]/page.tsx index 8c98a30..9f47244 100644 --- a/src/app/chat/[id]/page.tsx +++ b/src/app/chat/[id]/page.tsx @@ -2,7 +2,8 @@ import { useState, useRef, useEffect, use } from 'react'; import { useRouter, useSearchParams } from 'next/navigation'; -import { Share2, MoreHorizontal, Loader2, Square, Clock, ChevronDown, Pencil, Trash2, Check, X } from 'lucide-react'; +import Link from 'next/link'; +import { Share2, MoreHorizontal, Loader2, Square, Clock, ChevronDown, Pencil, Trash2, Check, X, AlertTriangle, Settings } from 'lucide-react'; import { Sidebar, SidebarToggle } from '@/components/layout/Sidebar'; import { ChatInput } from '@/components/features/ChatInput'; import { MessageBubble } from '@/components/features/MessageBubble'; @@ -448,6 +449,30 @@ export default function ChatPage({ params }: PageProps) { {/* 消息列表区域 */}
+ {/* API Key 未配置提示 */} + {!settings?.cchApiKeyConfigured && ( +
+
+ +
+

+ 请先配置 API Key +

+

+ 您需要配置自己的 API Key 才能使用 AI 对话功能。请前往设置页面完成配置。 +

+ + + 前往设置 + +
+
+
+ )} + {messages.length === 0 ? (

diff --git a/src/app/settings/page.tsx b/src/app/settings/page.tsx index cff7f51..2dddd50 100644 --- a/src/app/settings/page.tsx +++ b/src/app/settings/page.tsx @@ -50,7 +50,6 @@ export default function SettingsPage() { const { tools, loading: toolsLoading } = useTools(); // CCH 配置状态 - const [cchUrl, setCchUrl] = useState(''); const [cchApiKey, setCchApiKey] = useState(''); const [showApiKey, setShowApiKey] = useState(false); const [saveStatus, setSaveStatus] = useState<'idle' | 'saving' | 'saved' | 'error'>('idle'); @@ -69,7 +68,6 @@ export default function SettingsPage() { // 当设置加载完成后,更新本地状态 useEffect(() => { if (settings) { - setCchUrl(settings.cchUrl || ''); setSystemPrompt(settings.systemPrompt || ''); setTemperature(settings.temperature || '0.7'); } @@ -79,11 +77,9 @@ export default function SettingsPage() { const handleSaveCchConfig = async () => { setSaveStatus('saving'); try { - const updates: Record = { cchUrl }; if (cchApiKey) { - updates.cchApiKey = cchApiKey; + await updateSettings({ cchApiKey }); } - await updateSettings(updates); setSaveStatus('saved'); setCchApiKey(''); // 清除输入的 API Key setTimeout(() => setSaveStatus('idle'), 2000); @@ -317,19 +313,6 @@ export default function SettingsPage() { title="CCH 服务配置" description="配置 Claude Code Hub 服务连接" > - - setCchUrl(e.target.value)} - placeholder="http://localhost:13500" - /> - -