/** * 企业培训工作台预览 harness(仅本地视觉验证用,不参与生产路由): * 复刻 Training.vue 页头与页签切换,覆盖工作台三视图/培训计划/培训课程/ * 题库与考试/配置中心等子页,验证本次改动(模板下载、配置中心改名等)。 * 启动:npx vite --config vite.training-preview.config.ts */ import { createApp, computed, ref, h, defineComponent } from 'vue' import { createPinia } from 'pinia' import TDesign from 'tdesign-vue-next' import 'tdesign-vue-next/dist/tdesign.css' import '@/assets/theme/theme.css' import '@/assets/theme/tdesign-overrides.less' import { useAuthStore } from '@/stores/auth' import WorkbenchPanel from '@/views/training/components/WorkbenchPanel.vue' import PlanPanel from '@/views/training/components/PlanPanel.vue' import CoursePanel from '@/views/training/components/CoursePanel.vue' import LibraryPanel from '@/views/training/components/LibraryPanel.vue' import StudyPanel from '@/views/training/components/StudyPanel.vue' import RulePanel from '@/views/training/components/RulePanel.vue' import ResourceIcon from '@/components/icons/ResourceIcon.vue' const HARNESS_APP = defineComponent({ setup() { const authStore = useAuthStore() authStore.user = { id: 'u1', username: '林知夏', email: 'lin@example.com', tenant_id: '1', created_at: '', updated_at: '', } as any // trainee = 普通员工(仅课程/个人成长);hr = 培训运营(含数据驾驶舱) const preset = ref<'trainee' | 'hr'>('hr') type WorkbenchView = 'course' | 'growth' | 'dashboard' const workbenchTab = ref('course') // 子页:培训中心 / 年培训计划 / 月培训计划 / 课程管理 / 学习考试 / 配置中心 const page = ref<'workbench' | 'plan' | 'course' | 'library' | 'study' | 'rules'>('workbench') const PAGES = [ { key: 'workbench', title: '培训中心' }, { key: 'plan', title: '年培训计划' }, { key: 'course', title: '月培训计划' }, { key: 'library', title: '课程管理' }, { key: 'study', title: '学习考试' }, { key: 'rules', title: '配置中心' }, ] as const const roles = computed(() => (preset.value === 'hr' ? ['hr'] : ['trainee'])) const canSeeDashboard = computed(() => preset.value === 'hr') const isWorkbench = computed(() => page.value === 'workbench') const workbenchTabs = computed(() => { const list: { key: WorkbenchView; label: string }[] = [ { key: 'course', label: '课程' }, { key: 'growth', label: '个人成长' }, ] if (canSeeDashboard.value) list.push({ key: 'dashboard', label: '数据驾驶舱' }) return list }) const meta = computed(() => { if (isWorkbench.value) { if (workbenchTab.value === 'course') return { title: '培训课程', desc: '课程/课件上传后自动转入课件库并智能归档' } if (workbenchTab.value === 'growth') return { title: '培训中心', desc: '个人成长进阶 · 能力模型与成就任务总览' } return { title: '培训中心', desc: '培训运营总览、待办与达成率一览' } } const found = PAGES.find((p) => p.key === page.value) return { title: found?.title || '', desc: '' } }) const panelFor = (key: typeof page.value) => { const common = { roles: roles.value, admin: false } switch (key) { case 'plan': return h(PlanPanel, common) case 'course': return h(CoursePanel, common) case 'library': return h(LibraryPanel, common) case 'study': return h(StudyPanel, common) case 'rules': return h(RulePanel, common) default: return h(WorkbenchPanel, { ...common, tab: workbenchTab.value }) } } return () => h('div', { class: 'preview-page' }, [ h('div', { class: 'preview-preset' }, [ '角色视角:', h('button', { class: ['pv-btn', preset.value === 'trainee' ? 'on' : ''], onClick: () => (preset.value = 'trainee'), }, '普通员工'), h('button', { class: ['pv-btn', preset.value === 'hr' ? 'on' : ''], onClick: () => (preset.value = 'hr'), }, '人事·培训运营'), h('span', { class: 'pv-divider' }), '子页:', ...PAGES.map((p) => h('button', { key: p.key, class: ['pv-btn', page.value === p.key ? 'on' : ''], onClick: () => (page.value = p.key), }, p.title)), ]), h('header', { class: 'preview-header' }, [ h('div', { class: 'preview-title-row' }, [ h('div', { class: 'preview-title-group' }, [ h('h2', {}, [h(ResourceIcon, { type: 'training', size: 24 }), ` ${meta.value.title}`]), h('span', { class: 'pv-role-tag' }, preset.value === 'hr' ? '人事 · 培训运营' : '学员'), ]), isWorkbench.value ? h('nav', { class: 'workbench-switch' }, workbenchTabs.value.map((t) => h('button', { key: t.key, type: 'button', class: ['workbench-switch__tab', workbenchTab.value === t.key ? 'is-active' : ''], onClick: () => (workbenchTab.value = t.key), }, t.label))) : null, ]), h('p', { class: 'preview-subtitle' }, meta.value.desc), ]), h('div', { class: 'preview-body' }, [panelFor(page.value)]), ]) }, }) const app = createApp(HARNESS_APP) app.use(TDesign) app.use(createPinia()) app.mount('#app')