diff --git a/frontend-web/src/components/workspace/agent-icon-color.ts b/frontend-web/src/components/workspace/agent-icon-color.ts new file mode 100644 index 00000000..5f78c7e6 --- /dev/null +++ b/frontend-web/src/components/workspace/agent-icon-color.ts @@ -0,0 +1,35 @@ +/** + * 智能体图标底色 —— 按 id 稳定散列到一组主题色,复刻参考图的彩色方块。 + * + * 浅色模式沿用原高彩度彩色(不改);深蓝主题改用《深蓝 UI 规范》§1.1.7/§1.1.8 的蓝-青系 + * (docs/ui规范-深蓝,克制、不刺眼),仅深蓝主题下生效,互不影响。 + * + * 全量版通用问答左栏(GeneralQaSidebar)与 zzJC/zzXD 模块左栏(AgentModuleSidebar)共用, + * 保证彩色卡片配色完全一致。 + */ + +const AGENT_COLORS_LIGHT = [ + { from: "#fb7185", to: "#ef4444" }, + { from: "#60a5fa", to: "#3b82f6" }, + { from: "#fbbf24", to: "#f59e0b" }, + { from: "#34d399", to: "#10b981" }, + { from: "#a78bfa", to: "#8b5cf6" }, +] as const; + +const AGENT_COLORS_DARK = [ + { from: "#4096FF", to: "#1677FF" }, // 蓝(链接蓝 → 主色) + { from: "#36CFC9", to: "#13C2C2" }, // 青(辅色) + { from: "#6388FF", to: "#0958D9" }, // 紫蓝(装饰紫 → 主色深一档) + { from: "#5CDBD3", to: "#08979C" }, // 浅青 → 深青 + { from: "#69B1FF", to: "#003EB3" }, // 浅蓝 → 主色按下 +] as const; + +/** 按 agent id 稳定散列出一对渐变色(from → to)。`isDark` 切换深蓝/浅色调色板。 */ +export function agentColor(id: string, isDark: boolean) { + let hash = 0; + for (let i = 0; i < id.length; i++) { + hash = (hash * 31 + id.charCodeAt(i)) >>> 0; + } + const palette = isDark ? AGENT_COLORS_DARK : AGENT_COLORS_LIGHT; + return palette[hash % palette.length]!; +} diff --git a/frontend-web/src/components/workspace/agents/agent-module-sidebar.tsx b/frontend-web/src/components/workspace/agents/agent-module-sidebar.tsx index 2266b48d..a30f74af 100644 --- a/frontend-web/src/components/workspace/agents/agent-module-sidebar.tsx +++ b/frontend-web/src/components/workspace/agents/agent-module-sidebar.tsx @@ -5,6 +5,8 @@ import Link from "next/link"; import { usePathname } from "next/navigation"; import { useMemo, useState } from "react"; +import { agentColor } from "@/components/workspace/agent-icon-color"; +import { useTheme } from "@/contexts/ThemeContext"; import { useAgents } from "@/core/agents"; import type { Agent } from "@/core/agents"; import { useAgentModuleConfig } from "@/core/system-settings/hooks"; @@ -125,6 +127,9 @@ export function AgentModuleSidebar({ }) { const routeBase = useRouteBase(); const pathname = usePathname(); + // 智能体图标配色分主题:深蓝主题用规范蓝-青系,其它(浅色)保持原高彩度色,互不影响。 + const { theme } = useTheme(); + const isDark = theme === "dark"; const { agents } = useAgents(); const { data: threads = [] } = useThreads(); const { data: moduleConfig } = useAgentModuleConfig(moduleKey); @@ -165,7 +170,8 @@ export function AgentModuleSidebar({ }); return ( -