feat:三个窗口接口联调版本
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import request from '@/utils/request'
|
||||
import type { Agent, IApiStepTask, IRawPlanResponse } from '@/stores'
|
||||
import type { Agent, IApiStepTask, IRawPlanResponse, IRawStepTask } from '@/stores'
|
||||
import {
|
||||
mockBackendAgentSelectModifyInit,
|
||||
mockBackendAgentSelectModifyAddAspect,
|
||||
@@ -9,6 +9,12 @@ import {
|
||||
mockBackendFillAgentTaskProcess,
|
||||
type RawAgentTaskProcessResponse,
|
||||
} from '@/layout/components/Main/TaskTemplate/TaskProcess/components/mock/AgentTaskProcessBackendMock'
|
||||
import { mockBranchPlanOutlineAPI } from '@/layout/components/Main/TaskTemplate/TaskSyllabus/Branch/mock/branchPlanOutlineMock'
|
||||
import { mockFillStepTaskAPI } from '@/layout/components/Main/TaskTemplate/TaskSyllabus/Branch/mock/fill-step-task-mock'
|
||||
import {
|
||||
mockBranchTaskProcessAPI,
|
||||
type BranchAction,
|
||||
} from '@/layout/components/Main/TaskTemplate/TaskSyllabus/Branch/mock/branchTaskProcessMock'
|
||||
|
||||
export interface ActionHistory {
|
||||
ID: string
|
||||
@@ -116,7 +122,7 @@ class Api {
|
||||
})
|
||||
}
|
||||
|
||||
// 分支任务流程(任务节点级别)
|
||||
// 分支任务流程
|
||||
branchTaskProcess = (data: {
|
||||
branch_Number: number
|
||||
Modification_Requirement: string
|
||||
@@ -125,7 +131,7 @@ class Api {
|
||||
stepTaskExisting: any
|
||||
goal: string
|
||||
}) => {
|
||||
return request<unknown, IRawPlanResponse>({
|
||||
return request<unknown, BranchAction[][]>({
|
||||
url: '/branch_TaskProcess',
|
||||
method: 'POST',
|
||||
data: {
|
||||
@@ -139,8 +145,32 @@ class Api {
|
||||
})
|
||||
}
|
||||
|
||||
fillStepTask = (data: { goal: string; stepTask: any }) => {
|
||||
return request<unknown, any>({
|
||||
fillStepTask = async (data: { goal: string; stepTask: any }): Promise<IRawStepTask> => {
|
||||
// 后端返回格式:包含 Collaboration_Brief_FrontEnd(大写 FrontEnd)
|
||||
const response = await request<
|
||||
{
|
||||
'General Goal': string
|
||||
stepTask: any
|
||||
},
|
||||
{
|
||||
AgentSelection?: string[]
|
||||
Collaboration_Brief_FrontEnd?: {
|
||||
template: string
|
||||
data: Record<string, { text: string; color: number[] }>
|
||||
}
|
||||
InputObject_List?: string[]
|
||||
OutputObject?: string
|
||||
StepName?: string
|
||||
TaskContent?: string
|
||||
TaskProcess?: Array<{
|
||||
ID: string
|
||||
ActionType: string
|
||||
AgentName: string
|
||||
Description: string
|
||||
ImportantInput: string[]
|
||||
}>
|
||||
}
|
||||
>({
|
||||
url: '/fill_stepTask',
|
||||
method: 'POST',
|
||||
data: {
|
||||
@@ -148,6 +178,40 @@ class Api {
|
||||
stepTask: data.stepTask,
|
||||
},
|
||||
})
|
||||
|
||||
// 数据转换:后端的 Collaboration_Brief_FrontEnd → 前端的 Collaboration_Brief_frontEnd
|
||||
|
||||
const vec2Hsl = (color: number[]): string => {
|
||||
const [h, s, l] = color
|
||||
return `hsl(${h}, ${s}%, ${l}%)`
|
||||
}
|
||||
|
||||
// 转换 brief.data:后端格式 { "0": { text, color: [h,s,l] } } → 前端格式 { "0": { text, style: { background } } }
|
||||
const briefData: Record<string, { text: string; style?: Record<string, string> }> = {}
|
||||
if (response.Collaboration_Brief_FrontEnd?.data) {
|
||||
for (const [key, value] of Object.entries(response.Collaboration_Brief_FrontEnd.data)) {
|
||||
briefData[key] = {
|
||||
text: value.text,
|
||||
style: {
|
||||
background: vec2Hsl(value.color),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 构建前端格式的 IRawStepTask
|
||||
return {
|
||||
StepName: response.StepName || '',
|
||||
TaskContent: response.TaskContent || '',
|
||||
InputObject_List: response.InputObject_List || [],
|
||||
OutputObject: response.OutputObject || '',
|
||||
AgentSelection: response.AgentSelection || [],
|
||||
Collaboration_Brief_frontEnd: {
|
||||
template: response.Collaboration_Brief_FrontEnd?.template || '',
|
||||
data: briefData,
|
||||
},
|
||||
TaskProcess: response.TaskProcess || [],
|
||||
}
|
||||
}
|
||||
|
||||
fillStepTaskTaskProcess = async (data: {
|
||||
@@ -464,6 +528,61 @@ class Api {
|
||||
process,
|
||||
}
|
||||
}
|
||||
|
||||
// Mock: 分支任务大纲
|
||||
mockBranchPlanOutline = async (data: {
|
||||
branch_Number: number
|
||||
Modification_Requirement: string
|
||||
Existing_Steps: string[]
|
||||
Baseline_Completion: number
|
||||
initialInputs: string[]
|
||||
goal: string
|
||||
}): Promise<IRawPlanResponse> => {
|
||||
// 直接调用 Mock API(已经返回 IRawPlanResponse 格式)
|
||||
const response = await mockBranchPlanOutlineAPI({
|
||||
branch_Number: data.branch_Number,
|
||||
Modification_Requirement: data.Modification_Requirement,
|
||||
Existing_Steps: data.Existing_Steps,
|
||||
Baseline_Completion: data.Baseline_Completion,
|
||||
InitialObject_List: data.initialInputs,
|
||||
General_Goal: data.goal,
|
||||
})
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
// Mock: 填充任务流程
|
||||
mockFillStepTask = async (data: { goal: string; stepTask: any }): Promise<any> => {
|
||||
// 直接调用 Mock API(已经返回 IRawStepTask 格式)
|
||||
const response = await mockFillStepTaskAPI({
|
||||
General_Goal: data.goal,
|
||||
stepTask: data.stepTask,
|
||||
})
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
// Mock: 分支任务流程
|
||||
mockBranchTaskProcess = async (data: {
|
||||
branch_Number: number
|
||||
Modification_Requirement: string
|
||||
Existing_Steps: string[]
|
||||
Baseline_Completion: number
|
||||
stepTaskExisting: any
|
||||
goal: string
|
||||
}): Promise<BranchAction[][]> => {
|
||||
// 直接调用 Mock API(已经返回 BranchAction[][] 格式,与后端完全一致)
|
||||
const response = await mockBranchTaskProcessAPI({
|
||||
branch_Number: data.branch_Number,
|
||||
Modification_Requirement: data.Modification_Requirement,
|
||||
Existing_Steps: data.Existing_Steps,
|
||||
Baseline_Completion: data.Baseline_Completion,
|
||||
stepTaskExisting: data.stepTaskExisting,
|
||||
General_Goal: data.goal,
|
||||
})
|
||||
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
export default new Api()
|
||||
|
||||
Reference in New Issue
Block a user