2025-09-29 16:07:19 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 终端模拟数据管理器
|
|
|
|
|
|
* 为12个订单班提供统一的终端模拟数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
import { Agent } from '@/store/demoStore';
|
|
|
|
|
|
import { wenluSimulation } from './wenlu';
|
|
|
|
|
|
import { foodSimulation } from './food';
|
|
|
|
|
|
|
|
|
|
|
|
// 终端行类型定义
|
|
|
|
|
|
export interface TerminalLine {
|
|
|
|
|
|
type: 'info' | 'success' | 'warning' | 'error' | 'system' | 'output' | 'progress' | 'install' | 'file' | 'image';
|
|
|
|
|
|
content: string;
|
|
|
|
|
|
agent?: string;
|
|
|
|
|
|
// 进度条相关
|
|
|
|
|
|
target?: number;
|
|
|
|
|
|
stutters?: number[];
|
|
|
|
|
|
duration?: number; // 添加duration字段
|
|
|
|
|
|
// 图片相关
|
|
|
|
|
|
imageSrc?: string;
|
|
|
|
|
|
imageAlt?: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Agent输出定义
|
|
|
|
|
|
export interface AgentOutput {
|
|
|
|
|
|
agent: () => Agent; // 修改为函数类型
|
|
|
|
|
|
outputs: TerminalLine[];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 完整的模拟数据结构
|
|
|
|
|
|
export interface SimulationData {
|
|
|
|
|
|
orderClassId: string;
|
|
|
|
|
|
orderClassName: string;
|
|
|
|
|
|
projectTitle: string;
|
2025-09-29 20:12:57 +08:00
|
|
|
|
agents: Agent[]; // 添加agents字段
|
2025-09-29 16:07:19 +08:00
|
|
|
|
startupSequence: TerminalLine[];
|
|
|
|
|
|
agentSequence: AgentOutput[];
|
|
|
|
|
|
completionSequence: TerminalLine[];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-29 20:12:57 +08:00
|
|
|
|
// 生成函数类型 - 不再需要传入agents参数
|
|
|
|
|
|
export type SimulationGenerator = () => SimulationData;
|
2025-09-29 16:07:19 +08:00
|
|
|
|
|
|
|
|
|
|
// 订单班模拟数据映射表 - 目前只有文旅和食品
|
|
|
|
|
|
export const simulationMap: Record<string, SimulationGenerator> = {
|
|
|
|
|
|
wenlu: wenluSimulation, // 文旅
|
|
|
|
|
|
food: foodSimulation, // 食品
|
|
|
|
|
|
// 其他订单班暂未实现,缺少agent prompt和头像数据
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 获取指定订单班的模拟数据
|
2025-09-29 20:12:57 +08:00
|
|
|
|
export const getSimulationData = (orderClassId: string): SimulationData | null => {
|
|
|
|
|
|
console.log('[getSimulationData] Called with orderClassId:', orderClassId);
|
|
|
|
|
|
|
2025-09-29 16:07:19 +08:00
|
|
|
|
const generator = simulationMap[orderClassId];
|
|
|
|
|
|
console.log('[getSimulationData] Available keys:', Object.keys(simulationMap));
|
|
|
|
|
|
console.log('[getSimulationData] Generator found:', !!generator);
|
2025-09-29 20:12:57 +08:00
|
|
|
|
|
2025-09-29 16:07:19 +08:00
|
|
|
|
if (!generator) {
|
|
|
|
|
|
console.warn(`No simulation data found for order class: ${orderClassId}`);
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2025-09-29 20:12:57 +08:00
|
|
|
|
|
|
|
|
|
|
const data = generator();
|
2025-09-29 16:07:19 +08:00
|
|
|
|
console.log('[getSimulationData] Data generated:', {
|
|
|
|
|
|
hasData: !!data,
|
|
|
|
|
|
orderClassName: data?.orderClassName,
|
|
|
|
|
|
projectTitle: data?.projectTitle,
|
2025-09-29 20:12:57 +08:00
|
|
|
|
agentsCount: data?.agents?.length,
|
2025-09-29 16:07:19 +08:00
|
|
|
|
startupSequenceLength: data?.startupSequence?.length,
|
|
|
|
|
|
agentSequenceLength: data?.agentSequence?.length,
|
|
|
|
|
|
completionSequenceLength: data?.completionSequence?.length
|
|
|
|
|
|
});
|
2025-09-29 20:12:57 +08:00
|
|
|
|
|
2025-09-29 16:07:19 +08:00
|
|
|
|
return data;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 通用工具函数
|
|
|
|
|
|
export const utils = {
|
|
|
|
|
|
// 生成随机延迟
|
|
|
|
|
|
getRandomDelay: (min: number, max: number) => {
|
|
|
|
|
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 生成进度条字符串
|
|
|
|
|
|
generateProgressBar: (progress: number, width: number = 40) => {
|
|
|
|
|
|
const filled = Math.floor((progress / 100) * width);
|
|
|
|
|
|
const empty = width - filled;
|
|
|
|
|
|
return `[${'█'.repeat(filled)}${'░'.repeat(empty)}] ${progress.toString().padStart(3, ' ')}%`;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 生成文件大小
|
|
|
|
|
|
generateFileSize: () => {
|
|
|
|
|
|
const sizes = ['12.3KB', '456KB', '1.2MB', '3.4MB', '15.7MB', '48.2MB', '126MB'];
|
|
|
|
|
|
return sizes[Math.floor(Math.random() * sizes.length)];
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 重复字符
|
|
|
|
|
|
repeat: (char: string, times: number) => char.repeat(times)
|
|
|
|
|
|
};
|