feat:代码优化与Mock数据清理

This commit is contained in:
liailing1026
2026-01-30 15:27:00 +08:00
parent 6e4d8f0b6d
commit 1682a8892d
24 changed files with 1364 additions and 3193 deletions

View File

@@ -96,6 +96,23 @@ export interface IRawPlanResponse {
'Collaboration Process'?: IRawStepTask[]
}
/**
* IApiAgentAction[] → TaskProcess[] 格式转换
* @param actions IApiAgentAction 数组
* @returns TaskProcess 数组
*/
export function convertToTaskProcess(
actions: { id: string; type: string; agent: string; description: string; inputs?: string[] }[]
): TaskProcess[] {
return actions.map(action => ({
ID: action.id,
ActionType: action.type,
AgentName: action.agent,
Description: action.description,
ImportantInput: action.inputs || []
}))
}
const storageKey = '$agents' as const
// 清除所有以 storageKey 开头的 localStorage
@@ -471,9 +488,6 @@ export const useAgentsStore = defineStore('agents', () => {
hasStoppedFilling.value = false
}
// 额外的产物列表
const additionalOutputs = ref<string[]>([])
// 用户在 Assignment 中选择的 agent 组合按任务ID分别存储
const selectedAgentGroupMap = ref<Map<string, string[]>>(new Map())
@@ -498,41 +512,42 @@ export const useAgentsStore = defineStore('agents', () => {
selectedAgentGroupMap.value.clear()
}
// 添加新产物
function addNewOutput(outputObject: string) {
if (!outputObject.trim()) return false
const trimmedOutput = outputObject.trim()
if (!additionalOutputs.value.includes(trimmedOutput)) {
additionalOutputs.value.unshift(trimmedOutput)
return true
}
return false
}
// 删除额外产物
function removeAdditionalOutput(outputObject: string) {
const index = additionalOutputs.value.indexOf(outputObject)
if (index > -1) {
additionalOutputs.value.splice(index, 1)
return true
}
return false
}
// 清除额外产物
function clearAdditionalOutputs() {
additionalOutputs.value = []
}
// 标记是否用户已停止智能体分配过程
const hasStoppedFilling = ref(false)
// 标记是否正在停止中(全局停止状态)
const isStopping = ref(false)
// 设置停止状态
function setHasStoppedFilling(value: boolean) {
hasStoppedFilling.value = value
}
// 设置正在停止状态
function setIsStopping(value: boolean) {
isStopping.value = value
}
/**
* 构建 IApiStepTask 对象(用于 API 调用)
* @param agents 选中的 agent 列表
* @returns IApiStepTask 格式的对象
*/
function createStepTaskForApi(agents: string[]): IApiStepTask {
return {
name: currentTask.value?.StepName || '',
content: currentTask.value?.TaskContent || '',
inputs: currentTask.value?.InputObject_List || [],
output: currentTask.value?.OutputObject || '',
agents,
brief: currentTask.value?.Collaboration_Brief_frontEnd || {
template: '',
data: {}
},
process: []
}
}
return {
agents,
setAgents,
@@ -543,15 +558,12 @@ export const useAgentsStore = defineStore('agents', () => {
setCurrentTaskProcess, // 🆕 设置当前任务的 TaskProcess
updateCurrentAgentSelection, // 🆕 强制更新 AgentSelection用于 AgentAllocation 切换组合)
syncCurrentTaskToMainProcess, // 🆕 同步 currentTask 到主流程
createStepTaskForApi, // 🆕 构建 IApiStepTask 对象
agentRawPlan,
setAgentRawPlan,
executePlan,
setExecutePlan,
resetAgent,
additionalOutputs,
addNewOutput,
removeAdditionalOutput,
clearAdditionalOutputs,
// 用户选择的 agent 组合
selectedAgentGroupMap,
setSelectedAgentGroup,
@@ -593,6 +605,9 @@ export const useAgentsStore = defineStore('agents', () => {
// 停止填充状态
hasStoppedFilling,
setHasStoppedFilling,
// 正在停止状态
isStopping,
setIsStopping,
// 重新执行相关
modifiedSteps,
addModifiedStep,