From f665030ee6c189778ffedb3dbe74b5890e28f07e Mon Sep 17 00:00:00 2001 From: sp mac bookpro 2605 Date: Fri, 29 May 2026 14:11:22 +0800 Subject: [PATCH] refactor(chat): use select model picker in composer --- src/pages/ChatPage.tsx | 102 ++++++++++++----------------------------- src/styles.css | 78 +++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 73 deletions(-) diff --git a/src/pages/ChatPage.tsx b/src/pages/ChatPage.tsx index 4d23e08..d86e8e8 100644 --- a/src/pages/ChatPage.tsx +++ b/src/pages/ChatPage.tsx @@ -1,5 +1,5 @@ import { useEffect, useRef, useState } from 'react'; -import { Button, Input, Space, Tag, App as AntApp, Popconfirm, Empty, Collapse, Switch, Drawer, Slider, InputNumber, Upload, Tooltip, Modal, Image as AntImage, Divider, Dropdown } from 'antd'; +import { Button, Input, Space, Tag, App as AntApp, Popconfirm, Empty, Collapse, Switch, Drawer, Slider, InputNumber, Upload, Tooltip, Modal, Image as AntImage, Divider, Dropdown, Select } from 'antd'; import { SettingOutlined, ApiOutlined, EditOutlined, DeleteOutlined, PaperClipOutlined, BookOutlined, ArrowUpOutlined, CloseOutlined, DownOutlined } from '@ant-design/icons'; import { useNavigate, useParams, useSearchParams } from 'react-router-dom'; import ReactMarkdown from 'react-markdown'; @@ -418,9 +418,15 @@ export default function ChatPage() { label: modelName })); const activeModelValue = overrides.model || ''; - const activeModelOption = modelOptions.find((item) => item.value === activeModelValue); const defaultModelLabel = allowedModels.length > 0 ? allowedModels.join(', ') : agentModel || '默认模型'; - const currentModelName = activeModelOption?.label || activeModelValue || defaultModelLabel; + const selectedModelKey = activeModelValue || '__default__'; + const modelSelectOptions = [ + { + value: '__default__', + label: `跟随默认 · ${defaultModelLabel}` + }, + ...modelOptions + ]; return (
@@ -639,7 +645,7 @@ export default function ChatPage() {
-
+
setInput(e.target.value)} @@ -653,73 +659,23 @@ export default function ChatPage() { }} className="chat-input-textarea" disabled={sending} - style={{ width: '100%' }} /> -
-
- - setOverrides((o) => ({ - ...o, - model: String(key) === '__default__' ? undefined : String(key) - })), - items: [ - { - key: '__default__', - label: `跟随默认 · ${defaultModelLabel}` - }, - ...modelOptions.map((item) => ({ - key: item.value, - label: `${item.label}` - })) - ] - }} - > - - +
+
+