fix(training): 修复安全培训状态问题!
This commit is contained in:
1 parent
11cef575b4
commit
375e4e371d
6 files changed
+191
-72
No files matched your search
@@ -85,7 +85,7 @@ def _normalize_exam_mode(value: Any) -> str:
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def _build_default_safety_progress(safety_stage: str) -> dict[str, str]:
|
def _build_default_safety_progress(safety_stage: str) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
根据安全培训当前阶段推导三级学习进度。
|
根据安全培训当前阶段推导三级学习进度。
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ def _build_default_safety_progress(safety_stage: str) -> dict[str, str]:
|
|||||||
Returns:
|
Returns:
|
||||||
company、department、team 三个级别的状态快照。
|
company、department、team 三个级别的状态快照。
|
||||||
"""
|
"""
|
||||||
progress: dict[str, str] = {key: "pending" for key in SAFETY_LEVEL_KEYS}
|
progress: dict[str, Any] = {key: "pending" for key in SAFETY_LEVEL_KEYS}
|
||||||
if safety_stage == "company":
|
if safety_stage == "company":
|
||||||
progress["company"] = "active"
|
progress["company"] = "active"
|
||||||
return progress
|
return progress
|
||||||
@@ -128,7 +128,7 @@ def _normalize_safety_stage(value: Any) -> str:
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
def _normalize_safety_progress(value: Any, safety_stage: str) -> dict[str, str]:
|
def _normalize_safety_progress(value: Any, safety_stage: str) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
规范安全培训三级进度对象。
|
规范安全培训三级进度对象。
|
||||||
|
|
||||||
|
|||||||
Generated
+11
@@ -26,6 +26,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^24.10.1",
|
"@types/node": "^24.10.1",
|
||||||
|
"@types/pdfjs-dist": "^2.10.377",
|
||||||
"@vitejs/plugin-vue": "^6.0.2",
|
"@vitejs/plugin-vue": "^6.0.2",
|
||||||
"@vue/test-utils": "^2.4.11",
|
"@vue/test-utils": "^2.4.11",
|
||||||
"@vue/tsconfig": "^0.8.1",
|
"@vue/tsconfig": "^0.8.1",
|
||||||
@@ -1152,6 +1153,16 @@
|
|||||||
"undici-types": "~7.18.0"
|
"undici-types": "~7.18.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/pdfjs-dist": {
|
||||||
|
"version": "2.10.377",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/pdfjs-dist/-/pdfjs-dist-2.10.377.tgz",
|
||||||
|
"integrity": "sha512-RNBWpazVTkC5aiUIIo6d7ojlL0hJSoeQP1QCvTsVLW6qkNEpTALiI0DNGCYAGDfhbL0r17c/zNPQ15lk948UXg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"pdfjs-dist": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@vitejs/plugin-vue": {
|
"node_modules/@vitejs/plugin-vue": {
|
||||||
"version": "6.0.8",
|
"version": "6.0.8",
|
||||||
"resolved": "https://registry.npmmirror.com/@vitejs/plugin-vue/-/plugin-vue-6.0.8.tgz",
|
"resolved": "https://registry.npmmirror.com/@vitejs/plugin-vue/-/plugin-vue-6.0.8.tgz",
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^24.10.1",
|
"@types/node": "^24.10.1",
|
||||||
|
"@types/pdfjs-dist": "^2.10.377",
|
||||||
"@vitejs/plugin-vue": "^6.0.2",
|
"@vitejs/plugin-vue": "^6.0.2",
|
||||||
"@vue/test-utils": "^2.4.11",
|
"@vue/test-utils": "^2.4.11",
|
||||||
"@vue/tsconfig": "^0.8.1",
|
"@vue/tsconfig": "^0.8.1",
|
||||||
|
|||||||
@@ -247,6 +247,36 @@ const isMaterialCompleted = (material: any) => {
|
|||||||
|
|
||||||
const currentPreviewVideoUrl = ref('');
|
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 handleMaterialClick = (material: any) => {
|
||||||
const url = material.resource?.fileUrl;
|
const url = material.resource?.fileUrl;
|
||||||
if (!url) {
|
if (!url) {
|
||||||
@@ -255,18 +285,18 @@ const handleMaterialClick = (material: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (material.resource?.fileType === 'video') {
|
if (material.resource?.fileType === 'video') {
|
||||||
|
workspace.currentViewingMaterialId = material.id;
|
||||||
workspace.showVideoModal = true;
|
workspace.showVideoModal = true;
|
||||||
currentPreviewVideoUrl.value = url;
|
currentPreviewVideoUrl.value = url;
|
||||||
// 当点击视频资料时,我们应该记录正在观看的资源ID,以便后续更新进度
|
startVideoCountdown();
|
||||||
workspace.currentViewingMaterialId = material.id;
|
|
||||||
} else {
|
} else {
|
||||||
|
workspace.currentViewingMaterialId = material.id;
|
||||||
previewFile.value = {
|
previewFile.value = {
|
||||||
name: material.title || material.resource?.fileName || '资料预览',
|
name: material.title || material.resource?.fileName || '资料预览',
|
||||||
url: url,
|
url: url,
|
||||||
actualExt: material.resource?.fileType,
|
actualExt: material.resource?.fileType,
|
||||||
};
|
};
|
||||||
showFilePreview.value = true;
|
showFilePreview.value = true;
|
||||||
workspace.currentViewingMaterialId = material.id;
|
|
||||||
}
|
}
|
||||||
workspace.startMaterialTimer(material.id);
|
workspace.startMaterialTimer(material.id);
|
||||||
};
|
};
|
||||||
@@ -281,6 +311,7 @@ const handlePreviewClose = (val: boolean) => {
|
|||||||
const handleVideoModalClose = () => {
|
const handleVideoModalClose = () => {
|
||||||
workspace.showVideoModal = false;
|
workspace.showVideoModal = false;
|
||||||
currentPreviewVideoUrl.value = '';
|
currentPreviewVideoUrl.value = '';
|
||||||
|
stopVideoCountdown();
|
||||||
workspace.stopMaterialTimer();
|
workspace.stopMaterialTimer();
|
||||||
};
|
};
|
||||||
const jumpToExamQuestion = (index: number) => {
|
const jumpToExamQuestion = (index: number) => {
|
||||||
@@ -858,10 +889,6 @@ const currentSafetyStageText = computed(() => {
|
|||||||
{{ $t('chat.training.safety.progressHint') }}
|
{{ $t('chat.training.safety.progressHint') }}
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
|
|
||||||
<div class="mt-2 grid grid-cols-2 gap-1 lg:grid-cols-4">
|
<div class="mt-2 grid grid-cols-2 gap-1 lg:grid-cols-4">
|
||||||
@@ -1314,9 +1341,14 @@ const currentSafetyStageText = computed(() => {
|
|||||||
<Teleport to="body">
|
<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 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">
|
<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">
|
<div class="absolute top-4 right-4 z-10 flex items-center gap-2">
|
||||||
<XCircle class="h-6 w-6" />
|
<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">
|
||||||
</button>
|
{{ 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">
|
<div class="aspect-video bg-black">
|
||||||
<video
|
<video
|
||||||
controls
|
controls
|
||||||
@@ -1346,6 +1378,7 @@ const currentSafetyStageText = computed(() => {
|
|||||||
:file="previewFile"
|
:file="previewFile"
|
||||||
:agent-id="workspace.currentTrainingAgentId || undefined"
|
:agent-id="workspace.currentTrainingAgentId || undefined"
|
||||||
:auth-headers="getAuthHeaders()"
|
:auth-headers="getAuthHeaders()"
|
||||||
|
:required-duration="workspace.currentViewingMaterialRequiredDuration"
|
||||||
@update:modelValue="handlePreviewClose"
|
@update:modelValue="handlePreviewClose"
|
||||||
/>
|
/>
|
||||||
</Teleport>
|
</Teleport>
|
||||||
|
|||||||
@@ -273,12 +273,26 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
));
|
));
|
||||||
const canEnterResultStage = computed(() => stage.value === 'result');
|
const canEnterResultStage = computed(() => stage.value === 'result');
|
||||||
const safetyProgressPercent = computed(() => {
|
const safetyProgressPercent = computed(() => {
|
||||||
if (safetyStage.value === 'company') return 25;
|
|
||||||
if (safetyStage.value === 'department') return 50;
|
|
||||||
if (safetyStage.value === 'team') return 75;
|
|
||||||
if (safetyStage.value === 'exam') return 90;
|
if (safetyStage.value === 'exam') return 90;
|
||||||
return 100;
|
if (safetyStage.value === 'result') return 100;
|
||||||
|
|
||||||
|
let completedCount = 0;
|
||||||
|
if (isStageCompleted('company')) completedCount++;
|
||||||
|
if (isStageCompleted('department')) completedCount++;
|
||||||
|
if (isStageCompleted('team')) completedCount++;
|
||||||
|
|
||||||
|
return Math.round((completedCount / 3) * 75) || 10; // Start at 10% or just based on completed
|
||||||
});
|
});
|
||||||
|
const isStageCompleted = (stageKey: SafetyLearningStage) => {
|
||||||
|
const materials = resolveSafetyStageMaterials(stageKey);
|
||||||
|
if (!materials.length) return true;
|
||||||
|
return materials.every(m => {
|
||||||
|
if (m.id == null) return true;
|
||||||
|
const progress = safetyProgress.value.resource_progress?.[String(m.id)];
|
||||||
|
return progress?.completed;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const safetyStepItems = computed(() => {
|
const safetyStepItems = computed(() => {
|
||||||
const base: Array<{ id: SafetyStage extends infer U ? U : never; labelKey: string }> = [
|
const base: Array<{ id: SafetyStage extends infer U ? U : never; labelKey: string }> = [
|
||||||
{ id: 'company', labelKey: 'chat.training.safety.steps.company' },
|
{ id: 'company', labelKey: 'chat.training.safety.steps.company' },
|
||||||
@@ -288,26 +302,22 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
];
|
];
|
||||||
return base.map((item) => {
|
return base.map((item) => {
|
||||||
let status: 'completed' | 'active' | 'pending' | 'locked' = 'pending';
|
let status: 'completed' | 'active' | 'pending' | 'locked' = 'pending';
|
||||||
if (item.id === 'company') {
|
if (item.id === 'company' || item.id === 'department' || item.id === 'team') {
|
||||||
status = safetyProgress.value.company === 'completed'
|
const completed = isStageCompleted(item.id);
|
||||||
? 'completed'
|
if (safetyViewStage.value === item.id) {
|
||||||
: safetyProgress.value.company === 'active' ? 'active' : 'pending';
|
status = 'active';
|
||||||
} else if (item.id === 'department') {
|
} else if (completed) {
|
||||||
status = safetyProgress.value.department === 'completed'
|
status = 'completed';
|
||||||
? 'completed'
|
} else {
|
||||||
: safetyProgress.value.department === 'active' ? 'active' : 'pending';
|
status = 'pending';
|
||||||
} else if (item.id === 'team') {
|
}
|
||||||
status = safetyProgress.value.team === 'completed'
|
|
||||||
? 'completed'
|
|
||||||
: safetyProgress.value.team === 'active' ? 'active' : 'pending';
|
|
||||||
} else if (item.id === 'exam') {
|
} else if (item.id === 'exam') {
|
||||||
status = ['exam', 'result'].includes(safetyStage.value)
|
const allCompleted = isStageCompleted('company') && isStageCompleted('department') && isStageCompleted('team');
|
||||||
? (safetyStage.value === 'exam' ? 'active' : 'completed')
|
if (['exam', 'result'].includes(safetyStage.value)) {
|
||||||
: (safetyProgress.value.company === 'completed'
|
status = safetyStage.value === 'exam' ? 'active' : 'completed';
|
||||||
&& safetyProgress.value.department === 'completed'
|
} else {
|
||||||
&& safetyProgress.value.team === 'completed'
|
status = allCompleted ? 'pending' : 'locked';
|
||||||
? 'pending'
|
}
|
||||||
: 'locked');
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
@@ -519,8 +529,30 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
examMode.value = record.examMode || 'unified';
|
examMode.value = record.examMode || 'unified';
|
||||||
if (learnerTab.value === 'safety') {
|
if (learnerTab.value === 'safety') {
|
||||||
safetyStage.value = record.safetyStage || 'company';
|
safetyStage.value = record.safetyStage || 'company';
|
||||||
safetyProgress.value = record.safetyProgress;
|
// Ensure resource_progress is preserved when merging from backend
|
||||||
safetyViewStage.value = record.safetyStage || 'company';
|
safetyProgress.value = {
|
||||||
|
...record.safetyProgress,
|
||||||
|
resource_progress: record.safetyProgress?.resource_progress || safetyProgress.value.resource_progress || {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Sync legacy fields with actual resource completion
|
||||||
|
safetyProgress.value.company = isStageCompleted('company') ? 'completed' : 'active';
|
||||||
|
safetyProgress.value.department = isStageCompleted('department') ? 'completed' : 'active';
|
||||||
|
safetyProgress.value.team = isStageCompleted('team') ? 'completed' : 'active';
|
||||||
|
|
||||||
|
if (safetyStage.value !== 'exam' && safetyStage.value !== 'result') {
|
||||||
|
if (!isStageCompleted('company')) {
|
||||||
|
safetyViewStage.value = 'company';
|
||||||
|
} else if (!isStageCompleted('department')) {
|
||||||
|
safetyViewStage.value = 'department';
|
||||||
|
} else if (!isStageCompleted('team')) {
|
||||||
|
safetyViewStage.value = 'team';
|
||||||
|
} else {
|
||||||
|
safetyViewStage.value = 'company';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
safetyViewStage.value = record.safetyStage || 'company';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stage.value = record.stage;
|
stage.value = record.stage;
|
||||||
syncExamQuestionIndex(record.currentQuestionIndex);
|
syncExamQuestionIndex(record.currentQuestionIndex);
|
||||||
@@ -735,15 +767,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
const markVideoCompleted = () => {
|
const markVideoCompleted = () => {
|
||||||
if (!hasPublishedTrainingConfig.value || !videoUrl.value) return;
|
if (!hasPublishedTrainingConfig.value || !videoUrl.value) return;
|
||||||
if (learnerTab.value === 'safety') {
|
if (learnerTab.value === 'safety') {
|
||||||
if (safetyStage.value === 'company') {
|
checkAndAdvanceStage();
|
||||||
resetSafetyProgress('department');
|
|
||||||
} else if (safetyStage.value === 'department') {
|
|
||||||
resetSafetyProgress('team');
|
|
||||||
} else if (safetyStage.value === 'team') {
|
|
||||||
resetSafetyProgress('exam');
|
|
||||||
enterSafetyExam();
|
|
||||||
}
|
|
||||||
void persistProgress();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stage.value = 'summary';
|
stage.value = 'summary';
|
||||||
@@ -861,7 +885,13 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
if (!hasPublishedTrainingConfig.value) return;
|
if (!hasPublishedTrainingConfig.value) return;
|
||||||
const target = safetyStepItems.value.find((item) => item.id === nextStage);
|
const target = safetyStepItems.value.find((item) => item.id === nextStage);
|
||||||
if (!target || target.status === 'locked') return;
|
if (!target || target.status === 'locked') return;
|
||||||
safetyViewStage.value = nextStage;
|
|
||||||
|
if (nextStage === 'exam' && safetyStage.value !== 'exam' && safetyStage.value !== 'result') {
|
||||||
|
enterSafetyExam();
|
||||||
|
void persistProgress();
|
||||||
|
} else {
|
||||||
|
safetyViewStage.value = nextStage;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const exportRecords = async () => {
|
const exportRecords = async () => {
|
||||||
@@ -930,6 +960,12 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
const currentViewingMaterialId = ref<number | null>(null);
|
const currentViewingMaterialId = ref<number | null>(null);
|
||||||
const materialStartTime = ref<number>(0);
|
const materialStartTime = ref<number>(0);
|
||||||
|
|
||||||
|
const currentViewingMaterialRequiredDuration = computed(() => {
|
||||||
|
if (!currentViewingMaterialId.value) return 0;
|
||||||
|
const resource = (publishedConfig.value?.resources || []).find((item) => String(item.id) === String(currentViewingMaterialId.value));
|
||||||
|
return resource?.requiredDuration || 0;
|
||||||
|
});
|
||||||
|
|
||||||
const startMaterialTimer = (materialId: number) => {
|
const startMaterialTimer = (materialId: number) => {
|
||||||
currentViewingMaterialId.value = materialId;
|
currentViewingMaterialId.value = materialId;
|
||||||
materialStartTime.value = Date.now();
|
materialStartTime.value = Date.now();
|
||||||
@@ -963,32 +999,32 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const checkAndAdvanceStage = () => {
|
const checkAndAdvanceStage = () => {
|
||||||
const activeStageMaterials = learnerTab.value === 'safety'
|
// Update legacy string fields to reflect real status based on resources
|
||||||
? resolveSafetyStageMaterials(activeSafetyLearningStage.value)
|
safetyProgress.value.company = isStageCompleted('company') ? 'completed' : 'active';
|
||||||
: publishedTrainingMaterials.value;
|
safetyProgress.value.department = isStageCompleted('department') ? 'completed' : 'active';
|
||||||
if (!activeStageMaterials.length) return;
|
safetyProgress.value.team = isStageCompleted('team') ? 'completed' : 'active';
|
||||||
const allCompleted = activeStageMaterials.every(m => {
|
|
||||||
if (m.id == null) return true;
|
|
||||||
const progress = safetyProgress.value.resource_progress?.[String(m.id)];
|
|
||||||
return progress?.completed;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (allCompleted) {
|
if (learnerTab.value === 'safety') {
|
||||||
if (learnerTab.value === 'safety') {
|
const allSafetyCompleted = isStageCompleted('company') && isStageCompleted('department') && isStageCompleted('team');
|
||||||
if (safetyStage.value === 'company') {
|
|
||||||
resetSafetyProgress('department');
|
if (allSafetyCompleted && safetyStage.value !== 'exam' && safetyStage.value !== 'result') {
|
||||||
} else if (safetyStage.value === 'department') {
|
safetyStage.value = 'exam';
|
||||||
resetSafetyProgress('team');
|
enterSafetyExam();
|
||||||
} else if (safetyStage.value === 'team') {
|
}
|
||||||
resetSafetyProgress('exam');
|
void persistProgress();
|
||||||
enterSafetyExam();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
stage.value = 'summary';
|
|
||||||
}
|
|
||||||
void persistProgress();
|
|
||||||
} else {
|
} else {
|
||||||
void persistProgress();
|
const activeStageMaterials = publishedTrainingMaterials.value;
|
||||||
|
if (!activeStageMaterials.length) return;
|
||||||
|
const allCompleted = activeStageMaterials.every(m => {
|
||||||
|
if (m.id == null) return true;
|
||||||
|
const progress = safetyProgress.value.resource_progress?.[String(m.id)];
|
||||||
|
return progress?.completed;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (allCompleted) {
|
||||||
|
stage.value = 'summary';
|
||||||
|
}
|
||||||
|
void persistProgress();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1084,6 +1120,7 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
|
|||||||
startMaterialTimer,
|
startMaterialTimer,
|
||||||
stopMaterialTimer,
|
stopMaterialTimer,
|
||||||
currentViewingMaterialId,
|
currentViewingMaterialId,
|
||||||
|
currentViewingMaterialRequiredDuration,
|
||||||
currentTrainingAgentId,
|
currentTrainingAgentId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -41,6 +41,7 @@ const props = defineProps<{
|
|||||||
currentIndex?: number;
|
currentIndex?: number;
|
||||||
agentId?: number | null;
|
agentId?: number | null;
|
||||||
authHeaders?: Record<string, string>;
|
authHeaders?: Record<string, string>;
|
||||||
|
requiredDuration?: number;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -49,6 +50,35 @@ const emit = defineEmits<{
|
|||||||
}>();
|
}>();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
const countdownSeconds = ref(0);
|
||||||
|
let countdownTimer: ReturnType<typeof setInterval> | null = null;
|
||||||
|
|
||||||
|
const startCountdown = () => {
|
||||||
|
if (countdownTimer) {
|
||||||
|
clearInterval(countdownTimer);
|
||||||
|
countdownTimer = null;
|
||||||
|
}
|
||||||
|
if (props.requiredDuration && props.requiredDuration > 0) {
|
||||||
|
countdownSeconds.value = props.requiredDuration * 60;
|
||||||
|
countdownTimer = setInterval(() => {
|
||||||
|
if (countdownSeconds.value > 0) {
|
||||||
|
countdownSeconds.value--;
|
||||||
|
} else {
|
||||||
|
if (countdownTimer) clearInterval(countdownTimer);
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
countdownSeconds.value = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopCountdown = () => {
|
||||||
|
if (countdownTimer) {
|
||||||
|
clearInterval(countdownTimer);
|
||||||
|
countdownTimer = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
const error = ref('');
|
const error = ref('');
|
||||||
const markdownHtml = ref('');
|
const markdownHtml = ref('');
|
||||||
@@ -647,6 +677,9 @@ const loadContent = async () => {
|
|||||||
watch(
|
watch(
|
||||||
() => [props.modelValue, activeFile.value?.url, activeFile.value?.name, activeIndex.value, activeFiles.value.length],
|
() => [props.modelValue, activeFile.value?.url, activeFile.value?.name, activeIndex.value, activeFiles.value.length],
|
||||||
() => {
|
() => {
|
||||||
|
if (props.modelValue) {
|
||||||
|
startCountdown();
|
||||||
|
}
|
||||||
loadContent();
|
loadContent();
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
@@ -657,6 +690,7 @@ watch(
|
|||||||
(v) => {
|
(v) => {
|
||||||
if (!v) {
|
if (!v) {
|
||||||
clearOfficeObjectUrl();
|
clearOfficeObjectUrl();
|
||||||
|
stopCountdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -674,6 +708,9 @@ watch(
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex shrink-0 items-center gap-2">
|
<div class="flex shrink-0 items-center gap-2">
|
||||||
|
<div v-if="countdownSeconds > 0" class="flex items-center justify-center h-8 w-8 rounded-full border border-red-200 bg-red-50 text-red-500 font-semibold text-xs shadow-sm">
|
||||||
|
{{ countdownSeconds }}s
|
||||||
|
</div>
|
||||||
<div v-if="isExcelPreviewFile" class="flex items-center gap-2 rounded-full border border-default bg-surface px-2 py-1">
|
<div v-if="isExcelPreviewFile" class="flex items-center gap-2 rounded-full border border-default bg-surface px-2 py-1">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
Reference in new issue
Block a user