From b7348ab43cd174354724d3e6f9d88d105479c4e1 Mon Sep 17 00:00:00 2001 From: Danborad <1948863412@qq.com> Date: Mon, 31 Aug 2026 15:16:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(model-logo):=20=E4=BF=AE=E5=A4=8D=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=20Logo=20=E9=80=89=E6=8B=A9=E6=B5=AE=E7=AA=97?= =?UTF-8?q?=E9=97=AA=E9=80=80=E4=B8=8E=E7=84=A6=E7=82=B9=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E4=B8=8E=E6=BB=9A=E5=8A=A8=E4=BD=93=E9=AA=8C=20(#364)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Danborad --- web/src/components/model-logo.tsx | 120 +++++++++++++++++++++++------- 1 file changed, 93 insertions(+), 27 deletions(-) diff --git a/web/src/components/model-logo.tsx b/web/src/components/model-logo.tsx index d26e3354e..b67ad7542 100644 --- a/web/src/components/model-logo.tsx +++ b/web/src/components/model-logo.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo, useState, type ComponentType, type SVGProps } from "react"; +import { useEffect, useMemo, useRef, useState, type ComponentType, type SVGProps } from "react"; import { Input, Popover } from "antd"; import { Cpu, Search, X } from "lucide-react"; @@ -65,48 +65,114 @@ export function ModelLogo({ icon, size = 18, className }: { icon?: string; size? export function ModelIconPicker({ value, onChange }: { value?: string; onChange?: (value: string) => void }) { const [open, setOpen] = useState(false); const [keyword, setKeyword] = useState(""); + const searchInputRef = useRef(null); + + useEffect(() => { + if (open) { + const timer = setTimeout(() => searchInputRef.current?.focus(), 50); + return () => clearTimeout(timer); + } else { + setKeyword(""); + } + }, [open]); + const filteredIcons = useMemo(() => { const query = keyword.trim().toLowerCase(); return query ? iconOptions.filter((item) => `${item.id} ${item.title}`.toLowerCase().includes(query)) : iconOptions; }, [keyword]); const content = ( -
+
event.stopPropagation()} + onClick={(event) => event.stopPropagation()} + >
- } value={keyword} onChange={(event) => setKeyword(event.target.value)} placeholder="搜索 Logo" allowClear /> + } + value={keyword} + onChange={(event) => setKeyword(event.target.value)} + placeholder="搜索 Logo 名称或品牌..." + allowClear + /> {value ? ( - ) : null}
-
- {filteredIcons.map((item) => { - const selected = value === item.id; - return ( - - ); - })} +
event.stopPropagation()} + > + {filteredIcons.length ? ( + filteredIcons.map((item) => { + const selected = value === item.id; + return ( + + ); + }) + ) : ( +
+ 未找到与 “{keyword}” 相关的 Logo +
+ )} +
+
+ 共 {filteredIcons.length} 个可用 Logo + 点击即选定并应用
); return ( - -