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"
|
<LogViewer v-model:open="showFullscreen"
|
||||||
:log="selectedLog"
|
:log="selectedLog"
|
||||||
:content="decompressedOutput" />
|
:is-stopping="isStopping"
|
||||||
|
:content="decompressedOutput"
|
||||||
|
@stop="stopTask" />
|
||||||
|
|
||||||
<!-- 清空日志确认弹窗 -->
|
<!-- 清空日志确认弹窗 -->
|
||||||
<BaihuDialog v-model:open="showClearDialog" title="确认清空日志?">
|
<BaihuDialog v-model:open="showClearDialog" title="确认清空日志?">
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ const props = withDefaults(defineProps<{
|
|||||||
title?: string
|
title?: string
|
||||||
loading?: boolean
|
loading?: boolean
|
||||||
variant?: 'full' | 'simple'
|
variant?: 'full' | 'simple'
|
||||||
|
isStopping?: boolean
|
||||||
emptyTitle?: string
|
emptyTitle?: string
|
||||||
emptyDescription?: string
|
emptyDescription?: string
|
||||||
}>(), {
|
}>(), {
|
||||||
variant: 'simple'
|
variant: 'simple',
|
||||||
|
isStopping: false
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -70,6 +72,7 @@ onUnmounted(() => {
|
|||||||
:content="content"
|
:content="content"
|
||||||
:title="title"
|
:title="title"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
|
:is-stopping="isStopping"
|
||||||
:variant="isFullscreen ? 'simple' : variant"
|
:variant="isFullscreen ? 'simple' : variant"
|
||||||
:empty-title="emptyTitle"
|
:empty-title="emptyTitle"
|
||||||
:empty-description="emptyDescription"
|
:empty-description="emptyDescription"
|
||||||
|
|||||||
@@ -263,6 +263,7 @@ const logContent = ref('')
|
|||||||
const logEmptyTitle = ref<string | undefined>(undefined)
|
const logEmptyTitle = ref<string | undefined>(undefined)
|
||||||
const logEmptyDesc = ref<string | undefined>(undefined)
|
const logEmptyDesc = ref<string | undefined>(undefined)
|
||||||
let logSocket: WebSocket | null = null
|
let logSocket: WebSocket | null = null
|
||||||
|
let durationTimer: ReturnType<typeof setInterval> | null = null
|
||||||
|
|
||||||
function cleanupLogSocket() {
|
function cleanupLogSocket() {
|
||||||
if (logSocket) {
|
if (logSocket) {
|
||||||
@@ -275,15 +276,24 @@ function cleanupLogSocket() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cleanupDurationTimer() {
|
||||||
|
if (durationTimer) {
|
||||||
|
clearInterval(durationTimer)
|
||||||
|
durationTimer = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
watch(showLogViewer, (val) => {
|
watch(showLogViewer, (val) => {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
cleanupLogSocket()
|
cleanupLogSocket()
|
||||||
|
cleanupDurationTimer()
|
||||||
logContent.value = ''
|
logContent.value = ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
cleanupLogSocket()
|
cleanupLogSocket()
|
||||||
|
cleanupDurationTimer()
|
||||||
})
|
})
|
||||||
|
|
||||||
import { decompressFromBase64 } from '@/utils/decompress'
|
import { decompressFromBase64 } from '@/utils/decompress'
|
||||||
@@ -327,6 +337,26 @@ async function viewLogs(taskId: string) {
|
|||||||
logSocket.onmessage = (event) => {
|
logSocket.onmessage = (event) => {
|
||||||
logContent.value += event.data
|
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 {
|
} else {
|
||||||
// 如果没有日志,构造一个基础的任务信息对象用于展示弹窗
|
// 如果没有日志,构造一个基础的任务信息对象用于展示弹窗
|
||||||
const task = tasks.value.find(t => t.id === taskId)
|
const task = tasks.value.find(t => t.id === taskId)
|
||||||
|
|||||||
Reference in New Issue
Block a user