refactor(ui): 移除空壳行业资讯 Tab + Provider URL 去重
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
- SimpleSidebar: 移除空壳"行业资讯" Tab 和 Newspaper icon import - ModelsAPI.tsx: AVAILABLE_PROVIDERS 引用 LLM_PROVIDER_URLS 常量 - models.ts: PROVIDER_DEFAULTS 引用 api-urls.ts,消除重复 URL 定义 - 所有 Provider URL 现在统一在 api-urls.ts 维护
This commit is contained in:
@@ -6,6 +6,7 @@ import { useConfigStore } from '../../store/configStore';
|
||||
import { useConversationStore } from '../../store/chat/conversationStore';
|
||||
import { silentErrorHandler } from '../../lib/error-utils';
|
||||
import { secureStorage } from '../../lib/secure-storage';
|
||||
import { LLM_PROVIDER_URLS } from '../../constants/api-urls';
|
||||
import { Plus, Pencil, Trash2, Star, Eye, EyeOff, AlertCircle, X, Zap, Check } from 'lucide-react';
|
||||
|
||||
// 自定义模型数据结构
|
||||
@@ -41,17 +42,17 @@ interface EmbeddingProvider {
|
||||
// P2-21: 外国模型 (OpenAI, Anthropic, Gemini) 暂停支持,标记为 suspended
|
||||
const AVAILABLE_PROVIDERS = [
|
||||
// === Coding Plan 专用端点 (推荐用于编程场景) ===
|
||||
{ id: 'kimi-coding', name: 'Kimi Coding Plan', baseUrl: 'https://api.kimi.com/coding/v1' },
|
||||
{ id: 'qwen-coding', name: '百炼 Coding Plan', baseUrl: 'https://coding.dashscope.aliyuncs.com/v1' },
|
||||
{ id: 'zhipu-coding', name: '智谱 GLM Coding Plan', baseUrl: 'https://open.bigmodel.cn/api/coding/paas/v4' },
|
||||
{ id: 'kimi-coding', name: 'Kimi Coding Plan', baseUrl: LLM_PROVIDER_URLS.KIMI_CODING },
|
||||
{ id: 'qwen-coding', name: '百炼 Coding Plan', baseUrl: LLM_PROVIDER_URLS.QWEN_CODING },
|
||||
{ id: 'zhipu-coding', name: '智谱 GLM Coding Plan', baseUrl: LLM_PROVIDER_URLS.ZHIPU_CODING },
|
||||
// === 标准 API 端点 (国内) ===
|
||||
{ id: 'kimi', name: 'Kimi (标准 API)', baseUrl: 'https://api.moonshot.cn/v1' },
|
||||
{ id: 'zhipu', name: '智谱 (标准 API)', baseUrl: 'https://open.bigmodel.cn/api/paas/v4' },
|
||||
{ id: 'qwen', name: '百炼/通义千问 (标准)', baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1' },
|
||||
{ id: 'deepseek', name: 'DeepSeek', baseUrl: 'https://api.deepseek.com/v1' },
|
||||
{ id: 'kimi', name: 'Kimi (标准 API)', baseUrl: LLM_PROVIDER_URLS.KIMI },
|
||||
{ id: 'zhipu', name: '智谱 (标准 API)', baseUrl: LLM_PROVIDER_URLS.ZHIPU },
|
||||
{ id: 'qwen', name: '百炼/通义千问 (标准)', baseUrl: LLM_PROVIDER_URLS.QWEN },
|
||||
{ id: 'deepseek', name: 'DeepSeek', baseUrl: LLM_PROVIDER_URLS.DEEPSEEK },
|
||||
// === 暂停支持 (P2-21: 前期不使用非国内大模型) ===
|
||||
{ id: 'openai', name: 'OpenAI (暂停支持)', baseUrl: 'https://api.openai.com/v1', suspended: true },
|
||||
{ id: 'anthropic', name: 'Anthropic (暂停支持)', baseUrl: 'https://api.anthropic.com', suspended: true },
|
||||
{ id: 'openai', name: 'OpenAI (暂停支持)', baseUrl: LLM_PROVIDER_URLS.OPENAI, suspended: true },
|
||||
{ id: 'anthropic', name: 'Anthropic (暂停支持)', baseUrl: LLM_PROVIDER_URLS.ANTHROPIC, suspended: true },
|
||||
{ id: 'custom', name: '自定义', baseUrl: '' },
|
||||
];
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* SimpleSidebar - Trae Solo 风格的简洁侧边栏
|
||||
*
|
||||
* 仅显示:对话列表 + 行业资讯
|
||||
* 仅显示:对话列表
|
||||
* 底部:模式切换 + 设置
|
||||
*/
|
||||
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
MessageSquare, Settings, LayoutGrid,
|
||||
Search, X, Newspaper,
|
||||
Settings, LayoutGrid,
|
||||
Search, X,
|
||||
} from 'lucide-react';
|
||||
import { ConversationList } from './ConversationList';
|
||||
|
||||
@@ -17,10 +17,7 @@ interface SimpleSidebarProps {
|
||||
onToggleMode?: () => void;
|
||||
}
|
||||
|
||||
type Tab = 'conversations' | 'news';
|
||||
|
||||
export function SimpleSidebar({ onOpenSettings, onToggleMode }: SimpleSidebarProps) {
|
||||
const [activeTab, setActiveTab] = useState<Tab>('conversations');
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
|
||||
return (
|
||||
@@ -32,68 +29,30 @@ export function SimpleSidebar({ onOpenSettings, onToggleMode }: SimpleSidebarPro
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Tab 切换: 对话 / 行业资讯 */}
|
||||
<div className="flex border-b border-[#e8e6e1]/50 dark:border-gray-800">
|
||||
<button
|
||||
onClick={() => setActiveTab('conversations')}
|
||||
className={`flex-1 flex items-center justify-center gap-1.5 py-2.5 text-xs font-medium transition-colors ${
|
||||
activeTab === 'conversations'
|
||||
? 'text-gray-900 dark:text-gray-100 border-b-2 border-orange-500'
|
||||
: 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300'
|
||||
}`}
|
||||
>
|
||||
<MessageSquare className="w-3.5 h-3.5" />
|
||||
对话
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('news')}
|
||||
className={`flex-1 flex items-center justify-center gap-1.5 py-2.5 text-xs font-medium transition-colors ${
|
||||
activeTab === 'news'
|
||||
? 'text-gray-900 dark:text-gray-100 border-b-2 border-orange-500'
|
||||
: 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300'
|
||||
}`}
|
||||
>
|
||||
<Newspaper className="w-3.5 h-3.5" />
|
||||
行业资讯
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* 内容区域 */}
|
||||
<div className="flex-1 overflow-hidden">
|
||||
{activeTab === 'conversations' && (
|
||||
<div className="p-2 h-full overflow-y-auto">
|
||||
{/* 搜索框 */}
|
||||
<div className="relative mb-2">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 w-4 h-4" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="搜索对话..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="w-full pl-9 pr-8 py-1.5 bg-white/60 dark:bg-gray-800 border border-[#e8e6e1] dark:border-gray-700 rounded-lg text-sm focus:outline-none focus:border-gray-400 transition-all text-gray-700 dark:text-gray-300 placeholder-gray-400"
|
||||
/>
|
||||
{searchQuery && (
|
||||
<button
|
||||
onClick={() => setSearchQuery('')}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded text-gray-400"
|
||||
>
|
||||
<X className="w-3 h-3" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<ConversationList searchQuery={searchQuery} />
|
||||
<div className="p-2 h-full overflow-y-auto">
|
||||
{/* 搜索框 */}
|
||||
<div className="relative mb-2">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 w-4 h-4" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="搜索对话..."
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
className="w-full pl-9 pr-8 py-1.5 bg-white/60 dark:bg-gray-800 border border-[#e8e6e1] dark:border-gray-700 rounded-lg text-sm focus:outline-none focus:border-gray-400 transition-all text-gray-700 dark:text-gray-300 placeholder-gray-400"
|
||||
/>
|
||||
{searchQuery && (
|
||||
<button
|
||||
onClick={() => setSearchQuery('')}
|
||||
className="absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded text-gray-400"
|
||||
>
|
||||
<X className="w-3 h-3" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'news' && (
|
||||
<div className="p-3 h-full overflow-y-auto">
|
||||
<div className="flex flex-col items-center justify-center py-12 text-gray-400 dark:text-gray-500">
|
||||
<Newspaper className="w-10 h-10 mb-3 opacity-50" />
|
||||
<p className="text-sm">行业资讯</p>
|
||||
<p className="text-xs mt-1">开发中,敬请期待</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<ConversationList searchQuery={searchQuery} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 底部操作栏 */}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* Backend (Rust) should use the same values in kernel_commands.rs
|
||||
*/
|
||||
|
||||
import { LLM_PROVIDER_URLS } from './api-urls';
|
||||
|
||||
// === Default Model Configuration ===
|
||||
|
||||
/**
|
||||
@@ -31,58 +33,58 @@ export const DEFAULT_TEMPERATURE = 0.7 as const;
|
||||
/**
|
||||
* Default base URL for OpenAI API
|
||||
*/
|
||||
export const DEFAULT_OPENAI_BASE_URL = 'https://api.openai.com/v1' as const;
|
||||
export const DEFAULT_OPENAI_BASE_URL = LLM_PROVIDER_URLS.OPENAI as string;
|
||||
|
||||
/**
|
||||
* Default base URL for Anthropic API
|
||||
*/
|
||||
export const DEFAULT_ANTHROPIC_BASE_URL = 'https://api.anthropic.com' as const;
|
||||
export const DEFAULT_ANTHROPIC_BASE_URL = LLM_PROVIDER_URLS.ANTHROPIC as string;
|
||||
|
||||
// === Provider-Specific Defaults ===
|
||||
|
||||
export const PROVIDER_DEFAULTS = {
|
||||
openai: {
|
||||
baseUrl: 'https://api.openai.com/v1',
|
||||
baseUrl: LLM_PROVIDER_URLS.OPENAI,
|
||||
defaultModel: 'gpt-4o-mini',
|
||||
},
|
||||
anthropic: {
|
||||
baseUrl: 'https://api.anthropic.com',
|
||||
baseUrl: LLM_PROVIDER_URLS.ANTHROPIC,
|
||||
defaultModel: 'claude-sonnet-4-20250514',
|
||||
},
|
||||
zhipu: {
|
||||
baseUrl: 'https://open.bigmodel.cn/api/paas/v4',
|
||||
baseUrl: LLM_PROVIDER_URLS.ZHIPU,
|
||||
defaultModel: 'glm-4-flash-250414',
|
||||
},
|
||||
zhipu_coding: {
|
||||
baseUrl: 'https://open.bigmodel.cn/api/coding/paas/v4',
|
||||
baseUrl: LLM_PROVIDER_URLS.ZHIPU_CODING,
|
||||
defaultModel: 'glm-4-flash-250414',
|
||||
},
|
||||
kimi: {
|
||||
baseUrl: 'https://api.moonshot.cn/v1',
|
||||
baseUrl: LLM_PROVIDER_URLS.KIMI,
|
||||
defaultModel: 'moonshot-v1-8k',
|
||||
},
|
||||
kimi_coding: {
|
||||
baseUrl: 'https://api.kimi.com/coding/v1',
|
||||
baseUrl: LLM_PROVIDER_URLS.KIMI_CODING,
|
||||
defaultModel: 'kimi-for-coding',
|
||||
},
|
||||
qwen: {
|
||||
baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
||||
baseUrl: LLM_PROVIDER_URLS.QWEN,
|
||||
defaultModel: 'qwen-turbo',
|
||||
},
|
||||
qwen_coding: {
|
||||
baseUrl: 'https://coding.dashscope.aliyuncs.com/v1',
|
||||
baseUrl: LLM_PROVIDER_URLS.QWEN_CODING,
|
||||
defaultModel: 'qwen3-coder-next',
|
||||
},
|
||||
deepseek: {
|
||||
baseUrl: 'https://api.deepseek.com/v1',
|
||||
baseUrl: LLM_PROVIDER_URLS.DEEPSEEK,
|
||||
defaultModel: 'deepseek-chat',
|
||||
},
|
||||
gemini: {
|
||||
baseUrl: 'https://generativelanguage.googleapis.com/v1beta',
|
||||
baseUrl: LLM_PROVIDER_URLS.GEMINI,
|
||||
defaultModel: 'gemini-2.0-flash',
|
||||
},
|
||||
local: {
|
||||
baseUrl: 'http://localhost:11434/v1',
|
||||
baseUrl: LLM_PROVIDER_URLS.OLLAMA,
|
||||
defaultModel: 'llama3',
|
||||
},
|
||||
} as const;
|
||||
|
||||
Reference in New Issue
Block a user