feat(short-drama-agent-front): 优化项目查询与工作区界面

This commit is contained in:
GJ committed 2026-09-21 19:36:47 +08:00
1 parent 227db5450d
commit e6d02a20a7
33 files changed
+439 -513

No files matched your search

+10 -14
View File
@@ -1,23 +1,19 @@
import { computed, inject, type InjectionKey, type MaybeRefOrGetter } from 'vue'
import { usePolling } from '../../composables/usePolling'
import { computed, inject, type InjectionKey } from 'vue'
import { useQuery } from '../../composables/useQuery'
import { projectsApi } from './api'
import type { ProjectDetail } from './types'
import type { Checkpoint } from '../workflows/types'
import type { Ref } from 'vue'
/** 同一项目的各个 graph 共用一份查询,避免每个面板重复请求。 */
export function useProjectData(id: Ref<string>, interval: MaybeRefOrGetter<number | false> = 6000) {
const query = usePolling(
id,
async (projectId, signal) => {
const [project, checkpoints] = await Promise.all([
projectsApi.detail(projectId, signal),
projectsApi.checkpoints(projectId, signal)
])
return { project, checkpoints }
},
interval
)
export function useProjectData(id: Ref<string>) {
const query = useQuery(id, async (projectId, signal) => {
const [project, checkpoints] = await Promise.all([
projectsApi.detail(projectId, signal),
projectsApi.checkpoints(projectId, signal)
])
return { project, checkpoints }
})
const project = computed<ProjectDetail | null>(() => query.data.value?.project ?? null)
const checkpoints = computed<Checkpoint[]>(() => query.data.value?.checkpoints ?? [])
return { ...query, project, checkpoints }