chore: try to add stop task more info #75

This commit is contained in:
duorameng
2026-04-30 16:08:22 +08:00
parent cfdf186b93
commit 40e37b797c
6 changed files with 91 additions and 22 deletions
+10 -6
View File
@@ -387,12 +387,16 @@ export interface RepoConfig {
}
export interface ExecutionResult {
TaskID: string
Success: boolean
Output: string
Error: string
Start: string
End: string
task_id: string
log_id?: string
success: boolean
status?: string
output?: string
error?: string
duration?: number
exit_code?: number
start_time?: string
end_time?: string
}
export interface TaskListResponse {
+2
View File
@@ -18,6 +18,7 @@ const props = withDefaults(defineProps<{
const emit = defineEmits<{
'update:open': [value: boolean]
'stop': []
}>()
const isFullscreen = ref(false)
@@ -74,6 +75,7 @@ onUnmounted(() => {
:empty-description="emptyDescription"
@close="close"
@maximize="isFullscreen = !isFullscreen"
@stop="$emit('stop')"
/>
</div>
</div>
+26 -6
View File
@@ -205,23 +205,41 @@ async function deleteTask() {
}
const executingTaskId = ref<string | null>(null)
const isStopping = ref(false)
async function runTask(id: string) {
if (executingTaskId.value) return
executingTaskId.value = id
toast.message('正在执行...', { id: 'executing' })
try {
const res = await api.tasks.execute(id)
if (res.Success === false) {
throw new Error(res.Error || '执行失败')
toast.success('执行指令已发送')
if (res.log_id) {
// 开启日志查看器
viewLogs(id)
}
toast.success('触发成功', { id: 'executing' })
} catch (error: any) {
toast.error(error?.message || '执行失败', { id: 'executing' })
toast.error(error.message || '执行失败')
} finally {
executingTaskId.value = null
}
}
async function handleStopTask() {
if (!selectedLog.value || isStopping.value) return
isStopping.value = true
try {
await api.tasks.stop(selectedLog.value.id)
toast.success('停止指令已发送')
} catch (error: any) {
toast.error(error.message || '停止失败')
// 出错时也尝试刷新,因为后端可能已经自动修正了“僵尸”状态
loadTasks()
} finally {
isStopping.value = false
}
}
async function toggleTask(task: Task, enabled: boolean) {
try {
await api.tasks.update(task.id, { ...task, enabled })
@@ -830,8 +848,10 @@ watch(() => route.query.agent_id, (newVal: any) => {
variant="full"
:log="selectedLog"
:content="displayLogContent"
:is-stopping="isStopping"
:empty-title="logEmptyTitle"
:empty-description="logEmptyDesc" />
:empty-description="logEmptyDesc"
@stop="handleStopTask" />
<!-- 删除确认 (批量) -->