fix(training): 修复安全培训状态问题!
This commit is contained in:
1 parent
11cef575b4
commit
375e4e371d
6 files changed
+192
-73
No files matched your search
@@ -247,6 +247,36 @@ const isMaterialCompleted = (material: any) => {
|
||||
|
||||
const currentPreviewVideoUrl = ref('');
|
||||
|
||||
const videoCountdownSeconds = ref(0);
|
||||
let videoCountdownTimer: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
const startVideoCountdown = () => {
|
||||
if (videoCountdownTimer) {
|
||||
clearInterval(videoCountdownTimer);
|
||||
videoCountdownTimer = null;
|
||||
}
|
||||
const requiredDuration = workspace.currentViewingMaterialRequiredDuration;
|
||||
if (requiredDuration && requiredDuration > 0) {
|
||||
videoCountdownSeconds.value = requiredDuration * 60;
|
||||
videoCountdownTimer = setInterval(() => {
|
||||
if (videoCountdownSeconds.value > 0) {
|
||||
videoCountdownSeconds.value--;
|
||||
} else {
|
||||
if (videoCountdownTimer) clearInterval(videoCountdownTimer);
|
||||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
videoCountdownSeconds.value = 0;
|
||||
}
|
||||
};
|
||||
|
||||
const stopVideoCountdown = () => {
|
||||
if (videoCountdownTimer) {
|
||||
clearInterval(videoCountdownTimer);
|
||||
videoCountdownTimer = null;
|
||||
}
|
||||
};
|
||||
|
||||
const handleMaterialClick = (material: any) => {
|
||||
const url = material.resource?.fileUrl;
|
||||
if (!url) {
|
||||
@@ -255,18 +285,18 @@ const handleMaterialClick = (material: any) => {
|
||||
}
|
||||
|
||||
if (material.resource?.fileType === 'video') {
|
||||
workspace.currentViewingMaterialId = material.id;
|
||||
workspace.showVideoModal = true;
|
||||
currentPreviewVideoUrl.value = url;
|
||||
// 当点击视频资料时,我们应该记录正在观看的资源ID,以便后续更新进度
|
||||
workspace.currentViewingMaterialId = material.id;
|
||||
startVideoCountdown();
|
||||
} else {
|
||||
workspace.currentViewingMaterialId = material.id;
|
||||
previewFile.value = {
|
||||
name: material.title || material.resource?.fileName || '资料预览',
|
||||
url: url,
|
||||
actualExt: material.resource?.fileType,
|
||||
};
|
||||
showFilePreview.value = true;
|
||||
workspace.currentViewingMaterialId = material.id;
|
||||
}
|
||||
workspace.startMaterialTimer(material.id);
|
||||
};
|
||||
@@ -281,6 +311,7 @@ const handlePreviewClose = (val: boolean) => {
|
||||
const handleVideoModalClose = () => {
|
||||
workspace.showVideoModal = false;
|
||||
currentPreviewVideoUrl.value = '';
|
||||
stopVideoCountdown();
|
||||
workspace.stopMaterialTimer();
|
||||
};
|
||||
const jumpToExamQuestion = (index: number) => {
|
||||
@@ -858,10 +889,6 @@ const currentSafetyStageText = computed(() => {
|
||||
{{ $t('chat.training.safety.progressHint') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-2.5 py-1 text-center">
|
||||
<div class="text-xs text-muted">{{ $t('chat.training.progressPercent') }}</div>
|
||||
<div class="text-base font-semibold leading-none text-primary">{{ workspace.safetyProgressPercent }}%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-2 grid grid-cols-2 gap-1 lg:grid-cols-4">
|
||||
@@ -1314,9 +1341,14 @@ const currentSafetyStageText = computed(() => {
|
||||
<Teleport to="body">
|
||||
<div v-if="workspace.showVideoModal" class="fixed inset-0 z-[100] flex items-center justify-center bg-slate-950/80 p-4 backdrop-blur-sm" @click.self="handleVideoModalClose">
|
||||
<div class="relative w-full max-w-4xl overflow-hidden rounded-3xl bg-black shadow-2xl">
|
||||
<button @click="handleVideoModalClose" class="absolute top-4 right-4 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/20 transition backdrop-blur-md">
|
||||
<XCircle class="h-6 w-6" />
|
||||
</button>
|
||||
<div class="absolute top-4 right-4 z-10 flex items-center gap-2">
|
||||
<div v-if="videoCountdownSeconds > 0" class="flex items-center justify-center h-10 w-10 rounded-full border border-red-200 bg-red-50 text-red-500 font-semibold text-xs shadow-sm backdrop-blur-md">
|
||||
{{ videoCountdownSeconds }}s
|
||||
</div>
|
||||
<button @click="handleVideoModalClose" class="h-10 w-10 flex items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/20 transition backdrop-blur-md">
|
||||
<XCircle class="h-6 w-6" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="aspect-video bg-black">
|
||||
<video
|
||||
controls
|
||||
@@ -1346,6 +1378,7 @@ const currentSafetyStageText = computed(() => {
|
||||
:file="previewFile"
|
||||
:agent-id="workspace.currentTrainingAgentId || undefined"
|
||||
:auth-headers="getAuthHeaders()"
|
||||
:required-duration="workspace.currentViewingMaterialRequiredDuration"
|
||||
@update:modelValue="handlePreviewClose"
|
||||
/>
|
||||
</Teleport>
|
||||
|
||||
Reference in new issue
Block a user