From 77f75b0d99ef8044486e923f27e85d8f3237e0ee Mon Sep 17 00:00:00 2001 From: Aska Date: Sun, 6 Sep 2026 14:04:46 +0800 Subject: [PATCH] =?UTF-8?q?refactor(web):=20=E5=89=8D=E7=AB=AF=E5=8D=95?= =?UTF-8?q?=E9=A1=B5=E6=94=B6=E6=95=9B=E4=BF=AE=E6=AD=A3=E2=80=94=E2=80=94?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E5=BC=8F=E4=BE=A7=E8=BE=B9=E6=A0=8F=20+=20?= =?UTF-8?q?=E5=8E=BB=E8=BE=93=E5=85=A5=E6=A8=A1=E5=BC=8F=20chip=EF=BC=8Cmo?= =?UTF-8?q?de=20=E7=94=B1=E5=90=8E=E7=AB=AF=E8=87=AA=E5=88=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 按设计/01 §3 + 主人要求:行为模式切换由后端/agent 自切(热切换),前端不再提供 手动切换的行为模式按钮列表。 - 侧边栏改为导航式(连接状态 / 设置 / 管理面板 / 主题),不再列行为模式按钮; App.tsx 还原 布局。 - ChatInput 去掉行为模式 chip 切换条(模式不由用户手选)。 - useChat.send/chatStream 不再传 mode;消息 mode 由后端在回复时决定, MessageBubble 仍按 message.mode 渲染。 - ChatShell onVoice 为占位(语音处理在 agent)。 --- frontend/web/src/App.tsx | 5 +- frontend/web/src/components/ChatInput.tsx | 38 +----- frontend/web/src/components/Nav.tsx | 159 ++++++++++++---------- frontend/web/src/lib/api.ts | 4 +- frontend/web/src/lib/useChat.ts | 18 ++- frontend/web/src/modes/ChatShell.tsx | 10 +- 6 files changed, 105 insertions(+), 129 deletions(-) diff --git a/frontend/web/src/App.tsx b/frontend/web/src/App.tsx index 2013642..fbedf70 100644 --- a/frontend/web/src/App.tsx +++ b/frontend/web/src/App.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { TopBar } from "./components/TopBar"; -import { Sidebar, BottomNav } from "./components/Nav"; +import { Sidebar } from "./components/Nav"; import { ModeRouter } from "./modes/ModeRouter"; import { AdminApp } from "./admin/AdminApp"; import { parseAdminHash } from "./admin/router"; @@ -34,11 +34,10 @@ export default function App(): React.ReactNode {
-
+
- ); } diff --git a/frontend/web/src/components/ChatInput.tsx b/frontend/web/src/components/ChatInput.tsx index b395af9..62ebefe 100644 --- a/frontend/web/src/components/ChatInput.tsx +++ b/frontend/web/src/components/ChatInput.tsx @@ -1,25 +1,14 @@ import { useEffect, useRef, useState } from "react"; import { Button } from "./primitives"; -import { Icon, type IconName } from "./Icon"; -import { useModeStore } from "../store/useModeStore"; -import type { Mode } from "../lib/types"; +import { Icon } from "./Icon"; export interface ChatInputProps { - onSend: (text: string, mode: Mode) => void; + onSend: (text: string) => void; sending: boolean; onVoice: () => void; placeholder?: string; } -const INPUT_MODES: ReadonlyArray<{ mode: Mode; label: string; icon: IconName }> = [ - { mode: "chat", label: "对话", icon: "chat" }, - { mode: "code", label: "代码", icon: "terminal" }, - { mode: "home", label: "家居", icon: "home" }, - { mode: "work", label: "工作", icon: "folder" }, - { mode: "docs", label: "知识库", icon: "docs" }, - { mode: "vision", label: "视觉", icon: "vision" }, -]; - export function ChatInput({ onSend, sending, @@ -28,8 +17,6 @@ export function ChatInput({ }: ChatInputProps): React.ReactNode { const [value, setValue] = useState(""); const taRef = useRef(null); - const mode = useModeStore((s) => s.mode); - const setMode = useModeStore((s) => s.setMode); // auto-grow the textarea up to a max height useEffect(() => { @@ -42,31 +29,12 @@ export function ChatInput({ const submit = () => { const t = value.trim(); if (!t || sending) return; - onSend(t, mode); + onSend(t); setValue(""); }; return (
- {/* input-mode switcher: sets the mode for the NEXT message (design/07 §1). */} -
- 行为模式 - {INPUT_MODES.map(({ mode: m, label, icon }) => ( - - ))} -
-