perf(short-drama-agent-front): 优化记录加载与工作区体验
This commit is contained in:
1 parent
d0264c08ce
commit
db9aea1694
111 files changed
+1680
-1290
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { request, optionalResource } from '../../lib/http'
|
||||
import type { Checkpoint } from '../workflows/types'
|
||||
import type { Checkpoint, CheckpointSummary } from '../workflows/types'
|
||||
import type { WorkflowExecutionStart } from '../workflows/execution.types'
|
||||
import type {
|
||||
CreateProjectInput,
|
||||
@@ -71,8 +71,57 @@ export const projectsApi = {
|
||||
request<{ id: string; deleted: boolean }>(`/projects/${encodeURIComponent(id)}`, { method: 'DELETE' }),
|
||||
state: (id: string, signal?: AbortSignal) =>
|
||||
optionalResource(request<DramaState>(`/projects/${encodeURIComponent(id)}/state`, { signal })),
|
||||
checkpoints: (id: string, signal?: AbortSignal) =>
|
||||
request<Checkpoint[]>(`/projects/${encodeURIComponent(id)}/checkpoints`, { signal }),
|
||||
/**
|
||||
* 读取每个工作流最新的执行状态,供导航与操作门禁使用。
|
||||
* @param id 当前项目
|
||||
* @param signal 请求取消信号
|
||||
* @returns 最新保存记录摘要
|
||||
*/
|
||||
async checkpointSummaries(id: string, signal?: AbortSignal) {
|
||||
const rows = await request<CheckpointSummary[]>(
|
||||
`/projects/${encodeURIComponent(id)}/checkpoints?view=summary`,
|
||||
{ signal }
|
||||
)
|
||||
if (
|
||||
!Array.isArray(rows) ||
|
||||
rows.some(
|
||||
row =>
|
||||
!row?.workflowName ||
|
||||
!row.checkpointId ||
|
||||
!row.createdAt ||
|
||||
!row.updatedAt ||
|
||||
!row.state ||
|
||||
typeof row.state !== 'object' ||
|
||||
Array.isArray(row.state) ||
|
||||
Object.keys(row.state).some(key => key !== 'workflowExecution') ||
|
||||
(row.state.workflowExecution !== undefined &&
|
||||
typeof row.state.workflowExecution?.status !== 'string')
|
||||
) ||
|
||||
new Set(rows.map(row => row.workflowName)).size !== rows.length
|
||||
)
|
||||
throw new Error('任务摘要无法核对,请刷新后再试。')
|
||||
return rows
|
||||
},
|
||||
/**
|
||||
* 读取完整记录,页面按实际需要指定工作流。
|
||||
* @param id 当前项目
|
||||
* @param signal 请求取消信号
|
||||
* @param workflowName 完整记录所属的工作流
|
||||
* @returns 保留历史顺序及来源信息的完整记录
|
||||
*/
|
||||
async checkpoints(id: string, signal?: AbortSignal, workflowName?: string) {
|
||||
const rows = await request<Checkpoint[]>(
|
||||
`/projects/${encodeURIComponent(id)}/checkpoints` +
|
||||
(workflowName === undefined ? '' : `?${new URLSearchParams({ workflowName })}`),
|
||||
{ signal }
|
||||
)
|
||||
if (
|
||||
!Array.isArray(rows) ||
|
||||
(workflowName !== undefined && rows.some(row => row?.workflowName !== workflowName))
|
||||
)
|
||||
throw new Error('工作流记录无法核对,请刷新后再试。')
|
||||
return rows
|
||||
},
|
||||
/**
|
||||
* 用户确认后恢复创作;改写明确携带服务端要求的确认标记。
|
||||
* @param id 当前项目编号
|
||||
|
||||
Reference in new issue
Block a user