chore: try to add stop task more info --fix pass status #75
This commit is contained in:
@@ -494,7 +494,9 @@ watch(() => route.query, (newQuery) => {
|
||||
<!-- 全屏查看日志 -->
|
||||
<LogViewer v-model:open="showFullscreen"
|
||||
:log="selectedLog"
|
||||
:content="decompressedOutput" />
|
||||
:is-stopping="isStopping"
|
||||
:content="decompressedOutput"
|
||||
@stop="stopTask" />
|
||||
|
||||
<!-- 清空日志确认弹窗 -->
|
||||
<BaihuDialog v-model:open="showClearDialog" title="确认清空日志?">
|
||||
|
||||
@@ -10,10 +10,12 @@ const props = withDefaults(defineProps<{
|
||||
title?: string
|
||||
loading?: boolean
|
||||
variant?: 'full' | 'simple'
|
||||
isStopping?: boolean
|
||||
emptyTitle?: string
|
||||
emptyDescription?: string
|
||||
}>(), {
|
||||
variant: 'simple'
|
||||
variant: 'simple',
|
||||
isStopping: false
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -70,6 +72,7 @@ onUnmounted(() => {
|
||||
:content="content"
|
||||
:title="title"
|
||||
:loading="loading"
|
||||
:is-stopping="isStopping"
|
||||
:variant="isFullscreen ? 'simple' : variant"
|
||||
:empty-title="emptyTitle"
|
||||
:empty-description="emptyDescription"
|
||||
|
||||
@@ -263,6 +263,7 @@ const logContent = ref('')
|
||||
const logEmptyTitle = ref<string | undefined>(undefined)
|
||||
const logEmptyDesc = ref<string | undefined>(undefined)
|
||||
let logSocket: WebSocket | null = null
|
||||
let durationTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
function cleanupLogSocket() {
|
||||
if (logSocket) {
|
||||
@@ -275,15 +276,24 @@ function cleanupLogSocket() {
|
||||
}
|
||||
}
|
||||
|
||||
function cleanupDurationTimer() {
|
||||
if (durationTimer) {
|
||||
clearInterval(durationTimer)
|
||||
durationTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
watch(showLogViewer, (val) => {
|
||||
if (!val) {
|
||||
cleanupLogSocket()
|
||||
cleanupDurationTimer()
|
||||
logContent.value = ''
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
cleanupLogSocket()
|
||||
cleanupDurationTimer()
|
||||
})
|
||||
|
||||
import { decompressFromBase64 } from '@/utils/decompress'
|
||||
@@ -327,6 +337,26 @@ async function viewLogs(taskId: string) {
|
||||
logSocket.onmessage = (event) => {
|
||||
logContent.value += event.data
|
||||
}
|
||||
|
||||
// 启动状态轮询
|
||||
cleanupDurationTimer()
|
||||
const updateLogStatus = async () => {
|
||||
try {
|
||||
const res = await api.logs.get(latestLog.id)
|
||||
if (res && selectedLog.value && selectedLog.value.id === latestLog.id) {
|
||||
selectedLog.value.duration = res.duration
|
||||
selectedLog.value.status = res.status
|
||||
selectedLog.value.end_time = res.end_time
|
||||
|
||||
// 如果任务结束,停止轮询
|
||||
if (res.status !== TASK_STATUS.RUNNING) {
|
||||
cleanupDurationTimer()
|
||||
loadTasks() // 同时刷新列表状态
|
||||
}
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
durationTimer = setInterval(updateLogStatus, 3000)
|
||||
} else {
|
||||
// 如果没有日志,构造一个基础的任务信息对象用于展示弹窗
|
||||
const task = tasks.value.find(t => t.id === taskId)
|
||||
|
||||
Reference in New Issue
Block a user