feat(training): 培训配置改造

This commit is contained in:
runny committed 2026-09-03 08:45:05 +08:00
1 parent d21c83433e
commit 15225ef1ce
15 files changed
+602 -56

No files matched your search

@@ -64,19 +64,39 @@ const showVideoModal = computed({
});
const lastVideoTime = ref(0);
const stageStep = computed(() => {
if (workspace.stage === 'video') return 1;
if (workspace.stage === 'summary') return 2;
if (workspace.stage === 'exam') return 3;
return 4;
const learnerStageOrder = ['video', 'summary', 'exam', 'result'] as const;
const learnerStageIconMap = {
video: PlayCircle,
summary: BookOpen,
exam: ClipboardCheck,
result: ShieldCheck,
} as const;
const currentLearnerStageIndex = computed(() => learnerStageOrder.indexOf(workspace.stage));
const showLearnerProgressModule = computed(() => workspace.learnerProgressItems.length > 0);
const learnerProgressItems = computed(() => workspace.learnerProgressItems.map((item, index) => {
const stageIndex = learnerStageOrder.indexOf(item.stage as typeof learnerStageOrder[number]);
const status = stageIndex >= 0 && currentLearnerStageIndex.value >= 0
? currentLearnerStageIndex.value > stageIndex
? 'completed'
: currentLearnerStageIndex.value === stageIndex
? 'active'
: 'pending'
: 'pending';
return {
...item,
icon: learnerStageIconMap[item.stage as keyof typeof learnerStageIconMap] || BookOpen,
orderLabel: String(index + 1).padStart(2, '0'),
status,
};
}));
const learnerStepIntroTitle = computed(() => {
const [title] = String(workspace.learnerStepIntroText || '').split(/\r?\n/);
return title?.trim() || '';
});
const learnerStepIntroDescription = computed(() => {
const [, ...restLines] = String(workspace.learnerStepIntroText || '').split(/\r?\n/);
return restLines.join('\n').trim();
});
const stageItems = computed(() => ([
{ key: 'video', label: 'chat.training.steps.video', icon: PlayCircle },
{ key: 'summary', label: 'chat.training.steps.summary', icon: BookOpen },
{ key: 'exam', label: 'chat.training.steps.exam', icon: ClipboardCheck },
{ key: 'result', label: 'chat.training.steps.result', icon: ShieldCheck },
]));
const userExpandedOverride = ref<boolean | null>(null);
// HR 管理员与普通员工首次进入培训 Agent 时都默认展开工作区;新建对话仍按既有约束强制收起。
@@ -327,7 +347,9 @@ watch(
const isCompactMode = computed(() => !workspaceExpanded.value);
const isLearnerExamStage = computed(() => !isCompactMode.value && workspace.activeView === 'learner' && workspace.stage === 'exam');
const learnerWorkspaceGridClass = computed(() => (
'grid gap-2.5 p-3 md:grid-cols-[minmax(0,1.7fr)_208px] md:p-4 lg:gap-3 lg:grid-cols-[minmax(0,1.85fr)_220px] 2xl:grid-cols-[minmax(0,1.95fr)_240px]'
workspace.stage === 'exam' || workspace.stage === 'result' || showLearnerProgressModule.value
? 'grid gap-2.5 p-3 md:grid-cols-[minmax(0,1.7fr)_208px] md:p-4 lg:gap-3 lg:grid-cols-[minmax(0,1.85fr)_220px] 2xl:grid-cols-[minmax(0,1.95fr)_240px]'
: 'grid gap-2.5 p-3 md:p-4'
));
const learnerWorkspaceMainClass = computed(() => 'min-w-0 space-y-3');
const progressCardClass = computed(() => 'rounded-2xl border border-default bg-white p-2.5 shadow-sm');
@@ -344,7 +366,7 @@ const compactSummary = computed(() => {
if (workspace.activeView === 'admin') {
return `${workspace.stats.total}${t('chat.training.hr.stats.total')} / ${workspace.stats.passRate}% ${t('chat.training.hr.stats.passRate')}`;
}
if (workspace.stage === 'video') return t('chat.training.video.title');
if (workspace.stage === 'video') return learnerStepIntroTitle.value || t('chat.training.video.title');
if (workspace.stage === 'summary') return t('chat.training.summary.title');
if (workspace.stage === 'exam') {
return t('chat.training.exam.questionCounter', {
@@ -688,14 +710,14 @@ const currentSafetyStageText = computed(() => {
</div>
<template v-else-if="workspace.learnerTab !== 'safety'">
<div :class="learnerWorkspaceMainClass">
<div :class="progressCardClass">
<div v-if="showLearnerProgressModule" :class="progressCardClass">
<div class="flex flex-col gap-1.5 lg:flex-row lg:items-start lg:justify-between">
<div>
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-brand-600">
{{ $t('chat.training.progressLabel') }}
</div>
<div class="mt-0.5 text-[11px] leading-4.5 text-secondary md:text-xs">
{{ $t('chat.training.progressHint') }}
<div v-if="workspace.learnerProgressHintText" class="mt-0.5 text-[11px] leading-4.5 text-secondary md:text-xs">
{{ workspace.learnerProgressHintText }}
</div>
</div>
<div class="rounded-lg bg-surface-soft px-2.5 py-1 text-center">
@@ -706,27 +728,27 @@ const currentSafetyStageText = computed(() => {
<div class="mt-2 grid grid-cols-2 gap-1 lg:grid-cols-4">
<div
v-for="(item, index) in stageItems"
:key="item.key"
v-for="item in learnerProgressItems"
:key="item.stage"
class="cursor-pointer rounded-xl border px-2 py-1.5 transition hover:border-brand-300"
:class="[
stageStep >= index + 1 ? 'border-brand-200 bg-brand-50/70' : 'border-default bg-surface-soft/70',
canSwitchToStage(String(item.key)) ? 'cursor-pointer hover:border-brand-300' : 'cursor-not-allowed opacity-60',
item.status === 'completed' || item.status === 'active' ? 'border-brand-200 bg-brand-50/70' : 'border-default bg-surface-soft/70',
canSwitchToStage(String(item.stage)) ? 'cursor-pointer hover:border-brand-300' : 'cursor-not-allowed opacity-60',
]"
@click="handleStageCardClick(String(item.key))"
@click="handleStageCardClick(String(item.stage))"
>
<div class="flex items-center gap-2">
<div
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-lg"
:class="stageStep >= index + 1 ? 'bg-brand-600 text-white' : 'bg-white text-muted'"
:class="item.status === 'completed' || item.status === 'active' ? 'bg-brand-600 text-white' : 'bg-white text-muted'"
>
<component :is="item.icon" class="h-3 w-3" />
</div>
<div class="min-w-0">
<div class="text-[10px] font-semibold uppercase tracking-[0.14em] text-muted">
{{ String(index + 1).padStart(2, '0') }}
{{ item.orderLabel }}
</div>
<div class="whitespace-normal text-[12px] font-medium leading-4 text-primary">{{ $t(item.label) }}</div>
<div class="whitespace-normal text-[12px] font-medium leading-4 text-primary">{{ item.label }}</div>
</div>
</div>
</div>
@@ -734,10 +756,10 @@ const currentSafetyStageText = computed(() => {
</div>
<div v-if="workspace.stage === 'video'" class="rounded-2xl border border-default bg-white p-4 shadow-sm">
<div>
<div v-if="learnerStepIntroTitle || learnerStepIntroDescription">
<div>
<h3 class="text-base font-semibold text-primary md:text-lg">{{ $t('chat.training.video.title') }}</h3>
<p class="mt-1 text-sm leading-6 text-secondary">{{ $t('chat.training.video.description') }}</p>
<h3 v-if="learnerStepIntroTitle" class="text-base font-semibold text-primary md:text-lg">{{ learnerStepIntroTitle }}</h3>
<p v-if="learnerStepIntroDescription" class="mt-1 whitespace-pre-line text-sm leading-6 text-secondary">{{ learnerStepIntroDescription }}</p>
</div>
</div>
<div class="mt-3">
@@ -983,30 +1005,30 @@ const currentSafetyStageText = computed(() => {
<div class="min-w-0 md:sticky md:top-3 md:self-start space-y-4">
<!-- 流程进度面板 (仅在非考试阶段展示) -->
<div v-if="workspace.stage !== 'exam' && workspace.stage !== 'result'" :class="questionNavPanelClass">
<div v-if="showLearnerProgressModule && workspace.stage !== 'exam' && workspace.stage !== 'result'" :class="questionNavPanelClass">
<div class="flex items-center gap-2 mb-3">
<Target class="h-4 w-4 text-brand-600" />
<div class="text-sm font-semibold text-primary">{{ $t('chat.training.progressLabel') }}</div>
</div>
<div class="space-y-2">
<div
v-for="(item, index) in stageItems"
:key="item.key"
v-for="item in learnerProgressItems"
:key="item.stage"
class="flex items-center gap-3 p-2 rounded-lg border transition"
:class="[
stageStep > index + 1 ? 'border-emerald-200 bg-emerald-50/50' :
stageStep === index + 1 ? 'border-brand-300 bg-brand-50' :
item.status === 'completed' ? 'border-emerald-200 bg-emerald-50/50' :
item.status === 'active' ? 'border-brand-300 bg-brand-50' :
'border-slate-100 bg-slate-50/50 opacity-70'
]"
>
<div class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full"
:class="stageStep > index + 1 ? 'bg-emerald-500 text-white' : stageStep === index + 1 ? 'bg-brand-500 text-white shadow-sm' : 'bg-slate-200 text-slate-400'"
:class="item.status === 'completed' ? 'bg-emerald-500 text-white' : item.status === 'active' ? 'bg-brand-500 text-white shadow-sm' : 'bg-slate-200 text-slate-400'"
>
<CheckCircle2 v-if="stageStep > index + 1" class="h-4 w-4" />
<span v-else class="text-xs font-bold">{{ index + 1 }}</span>
<CheckCircle2 v-if="item.status === 'completed'" class="h-4 w-4" />
<span v-else class="text-xs font-bold">{{ Number(item.orderLabel) }}</span>
</div>
<div class="min-w-0 flex-1">
<div class="text-xs font-semibold" :class="stageStep === index + 1 ? 'text-brand-700' : 'text-slate-700'">{{ $t(item.label) }}</div>
<div class="text-xs font-semibold" :class="item.status === 'active' ? 'text-brand-700' : 'text-slate-700'">{{ item.label }}</div>
</div>
</div>
</div>