Files
ai_academy/frontend/src/views/training/components/LearningPanel.vue
T
runny 7ec21f35b0 chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、
Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。
今日开发的培训推送管理改动随后单独提交。
2026-11-16 18:12:23 +08:00

151 lines
5.0 KiB
Vue

<template>
<div class="learning-panel">
<div class="panel-grid">
<div class="panel-box">
<div class="panel-box__header">
<span class="panel-box__title">我的线上学习任务</span>
</div>
<t-table :data="tasks" :columns="taskColumns" row-key="id" size="small">
<template #status="{ row }">
<t-tag :theme="taskTheme(row.status)" variant="light" size="small">{{ taskText(row.status) }}</t-tag>
</template>
<template #op="{ row }">
<t-button variant="text" theme="primary" size="small" @click="goLearn(row.course_id)">去学习</t-button>
</template>
</t-table>
<t-empty v-if="!tasks.length" description="暂无学习任务" />
</div>
<div class="panel-box">
<div class="panel-box__header">
<span class="panel-box__title">我的错题本</span>
</div>
<t-table :data="wrongBook" :columns="wrongColumns" row-key="id" size="small">
<template #knowledge_point="{ row }">
<t-tag v-if="row.knowledge_point" variant="light" size="small">{{ row.knowledge_point }}</t-tag>
<span v-else>—</span>
</template>
</t-table>
<t-empty v-if="!wrongBook.length" description="错题本为空,继续保持" />
</div>
</div>
<div class="panel-box">
<div class="panel-box__header">
<span class="panel-box__title">我的能力画像</span>
</div>
<div v-if="profile" class="profile-grid">
<div class="profile-item">
<div class="profile-item__label">岗位胜任度</div>
<div class="profile-item__value" :class="profile.competency >= profile.pass_line ? 'tone-good' : 'tone-bad'">
{{ profile.competency }} 分
</div>
<div class="profile-item__sub">达标线 {{ profile.pass_line }} 分</div>
</div>
<div class="profile-item">
<div class="profile-item__label">累计积分</div>
<div class="profile-item__value">{{ profile.points }}</div>
</div>
<div class="profile-item">
<div class="profile-item__label">平均成绩</div>
<div class="profile-item__value">{{ profile.avg_score }}</div>
</div>
<div class="profile-item">
<div class="profile-item__label">学习时长</div>
<div class="profile-item__value">{{ profile.study_hours }} h</div>
</div>
<div class="profile-item">
<div class="profile-item__label">课程数</div>
<div class="profile-item__value">{{ profile.course_count }}</div>
</div>
</div>
<t-empty v-else description="暂无画像数据" />
</div>
</div>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import {
getMyAbilityProfile,
listMyLearningTasks,
listWrongBook,
type LearningTask,
type TrainingProfile,
type WrongBookItem,
unwrap,
} from '@/api/training'
const router = useRouter()
// 任务行「去学习」→ 课程学习详情页。
const goLearn = (courseId: string) => router.push(`/platform/training/course/${courseId}`)
const tasks = ref<LearningTask[]>([])
const wrongBook = ref<WrongBookItem[]>([])
const profile = ref<TrainingProfile | null>(null)
const taskColumns = [
{ colKey: 'course_name', title: '课程' },
{ colKey: 'deadline', title: '完成期限', width: 180 },
{ colKey: 'status', title: '状态', width: 90 },
{ colKey: 'op', title: '操作', width: 90 },
]
const wrongColumns = [
{ colKey: 'stem', title: '题干' },
{ colKey: 'knowledge_point', title: '知识点', width: 140 },
{ colKey: 'wrong_count', title: '错误次数', width: 90 },
]
const taskText = (s: string) => ({ pending: '待学习', doing: '学习中', done: '已完成', overdue: '已逾期' }[s] || s)
const taskTheme = (s: string) => ({ pending: 'default', doing: 'primary', done: 'success', overdue: 'danger' }[s] || 'default')
const loadAll = async () => {
try {
const [t, w, p] = await Promise.all([
listMyLearningTasks(),
listWrongBook(),
getMyAbilityProfile(),
])
tasks.value = unwrap(t) || []
wrongBook.value = unwrap(w) || []
profile.value = unwrap(p) || null
} catch { /* keep empty */ }
}
onMounted(loadAll)
</script>
<style lang="less" scoped>
@import (reference) '../training.less';
.panel-grid {
.training-panel-grid();
}
.panel-box {
.training-panel-box();
}
.profile-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 12px;
}
.profile-item {
background: var(--td-bg-color-secondarycontainer);
border-radius: var(--app-radius-md);
padding: 12px 14px;
text-align: center;
&__label { color: var(--td-text-color-secondary); font-size: var(--app-text-md); }
&__value { font-size: 22px; font-weight: 700; margin-top: 4px; }
&__sub { color: var(--td-text-color-placeholder); font-size: var(--app-text-sm); margin-top: 2px; }
}
.tone-good { color: var(--td-success-color); }
.tone-bad { color: var(--td-error-color); }
</style>