fix(培训): 完善培训相关细节!

This commit is contained in:
runny committed 2026-09-22 19:42:15 +08:00
1 parent 453d910364
commit ae882d5d04
8 files changed
+96 -16

No files matched your search

@@ -431,7 +431,13 @@ const compactSummary = computed(() => {
total: workspace.totalQuestionCount,
});
}
return workspace.isPassed ? t('chat.training.result.passTitle') : t('chat.training.result.failTitle');
// 通过标题按培训类型区分:出国规章培训为纯视频学习,通过文案不使用"新人培训考试"表述
if (workspace.isPassed) {
return workspace.isOverseasRegulationsTraining
? t('chat.training.result.overseasPassTitle')
: t('chat.training.result.passTitle');
}
return t('chat.training.result.failTitle');
});
const ruleItems = computed(() => ([
@@ -1189,14 +1195,15 @@ const currentSafetyStageText = computed(() => {
{{ workspace.isPassed ? $t('chat.training.result.passedTag') : $t('chat.training.result.failedTag') }}
</div>
<h3 class="mt-2.5 text-lg font-semibold text-primary md:text-xl">
{{ workspace.isPassed ? $t('chat.training.result.passTitle') : $t('chat.training.result.failTitle') }}
{{ workspace.isPassed ? (workspace.isOverseasRegulationsTraining ? $t('chat.training.result.overseasPassTitle') : $t('chat.training.result.passTitle')) : $t('chat.training.result.failTitle') }}
</h3>
<p class="mt-2 text-sm leading-6 text-secondary">
<!-- [RULE] 出国规章培训为纯视频学习(无考试),描述文案与考试语义不匹配,仅其他培训类型展示 -->
<p v-if="!workspace.isOverseasRegulationsTraining" class="mt-2 text-sm leading-6 text-secondary">
{{ workspace.isPassed ? $t('chat.training.result.passDescription') : $t('chat.training.result.failDescription', { passScore: workspace.passScore }) }}
</p>
</div>
<div class="grid grid-cols-2 gap-2 text-center">
<div v-if="!workspace.isOverseasRegulationsTraining" class="grid grid-cols-2 gap-2 text-center">
<div class="rounded-2xl bg-surface-soft px-4 py-2.5">
<div class="text-xs text-muted">{{ $t('chat.training.result.scoreLabel') }}</div>
<div class="text-xl font-semibold text-primary">{{ workspace.score }}</div>
@@ -1208,12 +1215,13 @@ const currentSafetyStageText = computed(() => {
</div>
</div>
<div class="mt-3 grid gap-2.5 md:grid-cols-3">
<div class="rounded-2xl border border-default bg-surface-soft p-3.5">
<!-- [RULE] 出国规章培训完成页仅保留与视频学习相关的完成日期,对错题数等考试统计一律隐藏 -->
<div class="mt-3 grid gap-2.5" :class="workspace.isOverseasRegulationsTraining ? '' : 'md:grid-cols-3'">
<div v-if="!workspace.isOverseasRegulationsTraining" class="rounded-2xl border border-default bg-surface-soft p-3.5">
<div class="text-xs text-muted">{{ $t('chat.training.result.correctCount') }}</div>
<div class="mt-1 text-lg font-semibold text-primary">{{ workspace.correctCount }}</div>
</div>
<div class="rounded-2xl border border-default bg-surface-soft p-3.5">
<div v-if="!workspace.isOverseasRegulationsTraining" class="rounded-2xl border border-default bg-surface-soft p-3.5">
<div class="text-xs text-muted">{{ $t('chat.training.result.wrongCount') }}</div>
<div class="mt-1 text-lg font-semibold text-primary">{{ workspace.wrongCount }}</div>
</div>
@@ -91,6 +91,18 @@ const OVERSEAS_REGULATIONS_TRAINING_TYPES = new Set([
const formatDate = (value: Date) => value.toISOString().slice(0, 10);
/**
* 将当前时刻格式化为北京时间(UTC+8)ISO 字符串,如 2026-09-22T18:47:33+08:00。
* 用途:精益培训"已观看"的本地即时回显必须与服务端展示口径(北京时间)一致;
* 此前用 toISOString()(UTC)回显,观看后立刻显示的时间比实际早 8 小时。
* 业务约束:带 +08:00 偏移,后端 save_completion 兜底入库前会归一为 UTC 存储。
*/
const formatBeijingIso = (value: Date) => {
const beijing = new Date(value.getTime() + (8 * 60 + value.getTimezoneOffset()) * 60000);
const pad = (num: number) => String(num).padStart(2, '0');
return `${beijing.getFullYear()}-${pad(beijing.getMonth() + 1)}-${pad(beijing.getDate())}T${pad(beijing.getHours())}:${pad(beijing.getMinutes())}:${pad(beijing.getSeconds())}+08:00`;
};
/**
* 按百分制计算当前答题得分。
* AI 触发时机:当题库题量改为后台可配置后,不能再假定“每题固定 5 分”,因此每次答题都要按当前题量重新折算分数。
@@ -908,7 +920,8 @@ export function useTrainingWorkspace(options: UseTrainingWorkspaceOptions) {
const markLeanVideoWatched = (taskId: number, resourceId: number) => {
const taskWatched = leanWatchedByTask.value[taskId] || {};
if (taskWatched[String(resourceId)]) return;
leanWatchedByTask.value = { ...leanWatchedByTask.value, [taskId]: { ...taskWatched, [String(resourceId)]: new Date().toISOString() } };
// 本地即时回显用北京时间,与服务端序列化口径一致;持久化失败时该值会经 save_completion 兜底入库(后端归一为 UTC)
leanWatchedByTask.value = { ...leanWatchedByTask.value, [taskId]: { ...taskWatched, [String(resourceId)]: formatBeijingIso(new Date()) } };
// 持久化失败不阻塞本地状态;下次刷新列表会以服务端记录为准,未持久化的视频需重新完整观看
void markMyLeanVideoWatched(taskId, resourceId).catch(() => {});
};