feat: add manual segment completed trigger
This commit is contained in:
@@ -4,7 +4,12 @@ import { useRouter } from "vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
import apiClient, { getApiErrorMessage } from "@/api/client";
|
||||
import { useViewport } from "@/composables/useViewport";
|
||||
import type { RecordArtifactUploadItemResult, RecordPreviewTicket, RecordTaskDetail } from "@/types";
|
||||
import type {
|
||||
ManualSegmentCompletedTriggerResult,
|
||||
RecordArtifactUploadItemResult,
|
||||
RecordPreviewTicket,
|
||||
RecordTaskDetail
|
||||
} from "@/types";
|
||||
import {
|
||||
formatQualityLabel,
|
||||
logLevelLabelMap,
|
||||
@@ -23,6 +28,7 @@ const loading = ref(false);
|
||||
const previewLoading = ref(false);
|
||||
const manualTranscodeLoading = ref(false);
|
||||
const uploadLoading = ref(false);
|
||||
const triggerEventLoading = ref(false);
|
||||
const detail = ref<RecordTaskDetail | null>(null);
|
||||
const loadError = ref("");
|
||||
const previewUrl = ref("");
|
||||
@@ -43,6 +49,14 @@ const canManualTranscode = computed(() => {
|
||||
const errorText = `${task.errorMessage ?? ""} ${result?.errorMessage ?? ""}`.toLowerCase();
|
||||
return resultPath.endsWith(".ts") || errorText.includes("finaliz") || errorText.includes("intermediate ts");
|
||||
});
|
||||
const canTriggerSegmentCompleted = computed(() => {
|
||||
const task = detail.value?.task;
|
||||
if (!task || activeTaskStatuses.has(task.status)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Boolean(detail.value?.result?.filePath || task.outputFilePath);
|
||||
});
|
||||
|
||||
async function loadDetailAndPreview() {
|
||||
loading.value = true;
|
||||
@@ -144,6 +158,22 @@ async function uploadTaskArtifacts() {
|
||||
}
|
||||
}
|
||||
|
||||
async function triggerSegmentCompleted() {
|
||||
triggerEventLoading.value = true;
|
||||
|
||||
try {
|
||||
const { data } = await apiClient.post<ManualSegmentCompletedTriggerResult>(
|
||||
`/record-tasks/${props.id}/trigger-segment-completed`
|
||||
);
|
||||
ElMessage[data.success ? "success" : "warning"](data.message);
|
||||
await loadDetailAndPreview();
|
||||
} catch (error) {
|
||||
ElMessage.error(getApiErrorMessage(error, "手动触发分片完成事件失败,请稍后重试。"));
|
||||
} finally {
|
||||
triggerEventLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function statusTagType(status: number) {
|
||||
if (status === 2) {
|
||||
return "success";
|
||||
@@ -221,6 +251,13 @@ onMounted(loadDetailAndPreview);
|
||||
<el-space class="header-actions">
|
||||
<el-button @click="router.push({ name: 'record-tasks' })">返回列表</el-button>
|
||||
<el-button @click="loadDetailAndPreview">刷新</el-button>
|
||||
<el-button
|
||||
v-if="canTriggerSegmentCompleted"
|
||||
:loading="triggerEventLoading"
|
||||
@click="triggerSegmentCompleted"
|
||||
>
|
||||
触发分片完成事件
|
||||
</el-button>
|
||||
<el-button :loading="uploadLoading" @click="uploadTaskArtifacts">上传文件</el-button>
|
||||
</el-space>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user