主要修复: - 恢复Agent真实头像显示(替换emoji为实际图片) - 删除自动跳转到ResultPageV2的逻辑 - 修改ResultModal支持动态内容显示 - 根据不同订单班显示对应的方案信息 优化内容: - 重构Agent系统,每个订单班独立管理Agent配置 - 删除不需要的ResultPageV2组件 - handleViewDetails改为在新标签页打开 影响模块: - web_frontend/exhibition-demo/src/components/ResultModal.tsx - web_frontend/exhibition-demo/src/pages/WorkflowPageV4.tsx - web_frontend/exhibition-demo/src/App.tsx - web_frontend/exhibition-demo/src/data/terminalSimulations/*.ts 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
160 lines
4.0 KiB
TypeScript
160 lines
4.0 KiB
TypeScript
import { create } from 'zustand';
|
|
import { foodAgents } from '../data/agents/foodAgents';
|
|
import { wenluAgents } from '../data/agents/wenluAgents';
|
|
|
|
export interface Agent {
|
|
id: string;
|
|
name: string;
|
|
icon: string;
|
|
avatar?: string;
|
|
model: string;
|
|
role: string;
|
|
status: 'waiting' | 'thinking' | 'generating' | 'done';
|
|
input?: string;
|
|
output?: string;
|
|
prompt?: string;
|
|
}
|
|
|
|
export interface DemoState {
|
|
// 演示状态
|
|
status: 'idle' | 'running' | 'paused' | 'completed';
|
|
currentPhase: number;
|
|
currentAgent: string | null;
|
|
progress: number;
|
|
selectedOrderClass: string | null;
|
|
|
|
// Agent配置
|
|
agents: Agent[];
|
|
|
|
// 生成的内容
|
|
generatedContent: {
|
|
[key: string]: {
|
|
title: string;
|
|
content: string;
|
|
images: string[];
|
|
isComplete: boolean;
|
|
};
|
|
};
|
|
|
|
// 控制选项
|
|
controls: {
|
|
speed: number; // 1-5倍速
|
|
autoAdvance: boolean;
|
|
showDetails: boolean;
|
|
};
|
|
|
|
// Actions
|
|
startDemo: () => void;
|
|
pauseDemo: () => void;
|
|
resumeDemo: () => void;
|
|
setCurrentAgent: (agentId: string) => void;
|
|
setSelectedOrderClass: (orderClass: string) => void;
|
|
loadOrderClassAgents: (orderClass: string) => void;
|
|
updateAgentStatus: (agentId: string, status: Agent['status']) => void;
|
|
updateAgentOutput: (agentId: string, output: string) => void;
|
|
addGeneratedContent: (section: string, content: any) => void;
|
|
setProgress: (progress: number) => void;
|
|
completeDemo: () => void;
|
|
reset: () => void;
|
|
}
|
|
|
|
// 默认agents已移除 - 每个订单班有自己的Agent配置
|
|
// 参见 src/data/terminalSimulations/[orderClass].ts
|
|
const initialAgents: Agent[] = [];
|
|
|
|
export const useDemoStore = create<DemoState>((set) => ({
|
|
status: 'idle',
|
|
currentPhase: 0,
|
|
currentAgent: null,
|
|
progress: 0,
|
|
selectedOrderClass: null,
|
|
agents: initialAgents,
|
|
generatedContent: {},
|
|
controls: {
|
|
speed: 1,
|
|
autoAdvance: true,
|
|
showDetails: true,
|
|
},
|
|
|
|
startDemo: () => set({ status: 'running', progress: 0 }),
|
|
pauseDemo: () => set({ status: 'paused' }),
|
|
resumeDemo: () => set({ status: 'running' }),
|
|
|
|
setCurrentAgent: (agentId) => set({ currentAgent: agentId }),
|
|
|
|
setSelectedOrderClass: (orderClass) => set({ selectedOrderClass: orderClass }),
|
|
|
|
loadOrderClassAgents: (orderClass) => {
|
|
let newAgents: Agent[] = [];
|
|
|
|
switch(orderClass) {
|
|
case 'food':
|
|
newAgents = foodAgents.map(agent => ({
|
|
id: agent.id,
|
|
name: agent.name,
|
|
icon: agent.icon,
|
|
avatar: agent.avatar,
|
|
model: `DeepSeek Chat Model${Math.floor(Math.random() * 5) + 1}`,
|
|
role: agent.role,
|
|
status: 'waiting' as const,
|
|
}));
|
|
break;
|
|
|
|
case 'wenlu':
|
|
newAgents = wenluAgents.map(agent => ({
|
|
id: agent.id,
|
|
name: agent.name,
|
|
icon: agent.icon,
|
|
avatar: agent.avatar,
|
|
model: `DeepSeek Chat Model${Math.floor(Math.random() * 5) + 1}`,
|
|
role: agent.role,
|
|
status: 'waiting' as const,
|
|
}));
|
|
break;
|
|
|
|
default:
|
|
// 使用默认的 initialAgents
|
|
newAgents = initialAgents;
|
|
break;
|
|
}
|
|
|
|
set({ agents: newAgents });
|
|
},
|
|
|
|
updateAgentStatus: (agentId, status) =>
|
|
set((state) => ({
|
|
agents: state.agents.map((agent) =>
|
|
agent.id === agentId ? { ...agent, status } : agent
|
|
),
|
|
})),
|
|
|
|
updateAgentOutput: (agentId, output) =>
|
|
set((state) => ({
|
|
agents: state.agents.map((agent) =>
|
|
agent.id === agentId ? { ...agent, output } : agent
|
|
),
|
|
})),
|
|
|
|
addGeneratedContent: (section, content) =>
|
|
set((state) => ({
|
|
generatedContent: {
|
|
...state.generatedContent,
|
|
[section]: content,
|
|
},
|
|
})),
|
|
|
|
setProgress: (progress) => set({ progress }),
|
|
|
|
completeDemo: () => set({ status: 'completed' }),
|
|
|
|
reset: () =>
|
|
set({
|
|
status: 'idle',
|
|
currentPhase: 0,
|
|
currentAgent: null,
|
|
progress: 0,
|
|
selectedOrderClass: null,
|
|
agents: initialAgents,
|
|
generatedContent: {},
|
|
}),
|
|
})); |