feat(admin): 新增用户端答题流程页面与相关功能模块

- 新增用户端答题流程主页面,包含封面、介绍、答题、答题图解四个状态
- 新增用户端组件:封面、介绍页、答题页、答题图解页、题目渲染器及通用布局组件
- 新增用户端类型定义、模拟数据及业务常量
- 新增用户路由及类型声明,包含组别和队伍选择页面
- 新增管理端首页模块:数据卡片、头部横幅、折线图、饼图、创意横幅和项目新闻
- 新增富文本编辑器组件,支持图片和视频上传至OSS
- 优化题库分类树,改为扁平化列表结构
- 完善比赛创建功能,增加轮次类型、题目分数类型及关联AP字段
- 修复模板删除函数调用参数错误
- 添加 pinyin-pro 依赖以支持拼音处理功能
This commit is contained in:
2026-02-05 18:00:11 +08:00
parent ce5ee2a289
commit ca42c6a876
49 changed files with 3569 additions and 179 deletions

View File

@ -0,0 +1,46 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useAppStore } from '@/store/modules/app'
import CardData from './modules/card-data.vue'
import CreativityBanner from './modules/creativity-banner.vue'
import HeaderBanner from './modules/header-banner.vue'
import LineChart from './modules/line-chart.vue'
import PieChart from './modules/pie-chart.vue'
import ProjectNews from './modules/project-news.vue'
const appStore = useAppStore()
const gap = computed(() => (appStore.isMobile ? 0 : 16))
</script>
<template>
<NSpace vertical :size="16">
<NAlert :title="$t('common.tip')" type="warning">
{{ $t('page.home.branchDesc') }}
</NAlert>
<HeaderBanner />
<CardData />
<NGrid :x-gap="gap" :y-gap="16" responsive="screen" item-responsive>
<NGi span="24 s:24 m:14">
<NCard :bordered="false" class="card-wrapper">
<LineChart />
</NCard>
</NGi>
<NGi span="24 s:24 m:10">
<NCard :bordered="false" class="card-wrapper">
<PieChart />
</NCard>
</NGi>
</NGrid>
<NGrid :x-gap="gap" :y-gap="16" responsive="screen" item-responsive>
<NGi span="24 s:24 m:14">
<ProjectNews />
</NGi>
<NGi span="24 s:24 m:10">
<CreativityBanner />
</NGi>
</NGrid>
</NSpace>
</template>
<style scoped></style>

View File

@ -0,0 +1,112 @@
<script setup lang="ts">
import { createReusableTemplate } from '@vueuse/core'
import { computed } from 'vue'
import { $t } from '@/locales'
import { useThemeStore } from '@/store/modules/theme'
defineOptions({
name: 'CardData',
})
interface CardData {
key: string
title: string
value: number
unit: string
color: {
start: string
end: string
}
icon: string
}
const cardData = computed<CardData[]>(() => [
{
key: 'visitCount',
title: $t('page.home.visitCount'),
value: 9725,
unit: '',
color: {
start: '#ec4786',
end: '#b955a4',
},
icon: 'ant-design:bar-chart-outlined',
},
{
key: 'turnover',
title: $t('page.home.turnover'),
value: 1026,
unit: '$',
color: {
start: '#865ec0',
end: '#5144b4',
},
icon: 'ant-design:money-collect-outlined',
},
{
key: 'downloadCount',
title: $t('page.home.downloadCount'),
value: 970925,
unit: '',
color: {
start: '#56cdf3',
end: '#719de3',
},
icon: 'carbon:document-download',
},
{
key: 'dealCount',
title: $t('page.home.dealCount'),
value: 9527,
unit: '',
color: {
start: '#fcbc25',
end: '#f68057',
},
icon: 'ant-design:trademark-circle-outlined',
},
])
interface GradientBgProps {
gradientColor: string
}
const [DefineGradientBg, GradientBg] = createReusableTemplate<GradientBgProps>()
const themeStore = useThemeStore()
function getGradientColor(color: CardData['color']) {
return `linear-gradient(to bottom right, ${color.start}, ${color.end})`
}
</script>
<template>
<NCard :bordered="false" size="small" class="card-wrapper">
<DefineGradientBg v-slot="{ $slots, gradientColor }">
<div
class="px-16px pb-4px pt-8px text-white"
:style="{ backgroundImage: gradientColor, borderRadius: `${themeStore.themeRadius}px` }"
>
<component :is="$slots.default" />
</div>
</DefineGradientBg>
<NGrid cols="s:1 m:2 l:4" responsive="screen" :x-gap="16" :y-gap="16">
<NGi v-for="item in cardData" :key="item.key">
<GradientBg :gradient-color="getGradientColor(item.color)" class="flex-1">
<h3 class="text-16px">
{{ item.title }}
</h3>
<div class="flex justify-between pt-12px">
<SvgIcon :icon="item.icon" class="text-32px" />
<CountTo
:prefix="item.unit" :start-value="1" :end-value="item.value"
class="text-30px text-white dark:text-dark"
/>
</div>
</GradientBg>
</NGi>
</NGrid>
</NCard>
</template>
<style scoped></style>

View File

@ -0,0 +1,17 @@
<script setup lang="ts">
import { $t } from '@/locales'
defineOptions({
name: 'CreativityBanner',
})
</script>
<template>
<NCard :title="$t('page.home.creativity')" :bordered="false" size="small" class="h-full card-wrapper">
<div class="h-full flex-center">
<icon-local-banner class="text-400px text-primary sm:text-320px" />
</div>
</NCard>
</template>
<style scoped></style>

View File

@ -0,0 +1,68 @@
<script setup lang="ts">
import { computed } from 'vue'
import { $t } from '@/locales'
import { useAppStore } from '@/store/modules/app'
import { useAuthStore } from '@/store/modules/auth'
defineOptions({
name: 'HeaderBanner',
})
const appStore = useAppStore()
const authStore = useAuthStore()
const gap = computed(() => (appStore.isMobile ? 0 : 16))
interface StatisticData {
id: number
label: string
value: string
}
const statisticData = computed<StatisticData[]>(() => [
{
id: 0,
label: $t('page.home.projectCount'),
value: '25',
},
{
id: 1,
label: $t('page.home.todo'),
value: '4/16',
},
{
id: 2,
label: $t('page.home.message'),
value: '12',
},
])
</script>
<template>
<NCard :bordered="false" class="card-wrapper">
<NGrid :x-gap="gap" :y-gap="16" responsive="screen" item-responsive>
<NGi span="24 s:24 m:18">
<div class="flex-y-center">
<div class="size-72px shrink-0 overflow-hidden rd-1/2">
<img src="@/assets/imgs/reader-star.jpg" class="size-full">
</div>
<div class="pl-12px">
<h3 class="text-18px font-semibold">
{{ $t('page.home.greeting', { userName: authStore.userInfo.userName }) }}
</h3>
<p class="text-#999 leading-30px">
{{ $t('page.home.weatherDesc') }}
</p>
</div>
</div>
</NGi>
<NGi span="24 s:24 m:6">
<NSpace :size="24" justify="end">
<NStatistic v-for="item in statisticData" :key="item.id" class="whitespace-nowrap" v-bind="item" />
</NSpace>
</NGi>
</NGrid>
</NCard>
</template>
<style scoped></style>

View File

@ -0,0 +1,152 @@
<script setup lang="ts">
import { watch } from 'vue'
import { useEcharts } from '@/hooks/common/echarts'
import { $t } from '@/locales'
import { useAppStore } from '@/store/modules/app'
defineOptions({
name: 'LineChart',
})
const appStore = useAppStore()
const { domRef, updateOptions } = useEcharts(() => ({
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985',
},
},
},
legend: {
data: [$t('page.home.downloadCount'), $t('page.home.registerCount')],
top: '0',
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
top: '15%',
},
xAxis: {
type: 'category',
boundaryGap: false,
data: [] as string[],
},
yAxis: {
type: 'value',
},
series: [
{
color: '#8e9dff',
name: $t('page.home.downloadCount'),
type: 'line',
smooth: true,
stack: 'Total',
areaStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0.25,
color: '#8e9dff',
},
{
offset: 1,
color: '#fff',
},
],
},
},
emphasis: {
focus: 'series',
},
data: [] as number[],
},
{
color: '#26deca',
name: $t('page.home.registerCount'),
type: 'line',
smooth: true,
stack: 'Total',
areaStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0.25,
color: '#26deca',
},
{
offset: 1,
color: '#fff',
},
],
},
},
emphasis: {
focus: 'series',
},
data: [],
},
],
}))
async function mockData() {
await new Promise((resolve) => {
setTimeout(resolve, 1000)
})
updateOptions((opts) => {
opts.xAxis.data = ['06:00', '08:00', '10:00', '12:00', '14:00', '16:00', '18:00', '20:00', '22:00', '24:00']
opts.series[0].data = [4623, 6145, 6268, 6411, 1890, 4251, 2978, 3880, 3606, 4311]
opts.series[1].data = [2208, 2016, 2916, 4512, 8281, 2008, 1963, 2367, 2956, 678]
return opts
})
}
function updateLocale() {
updateOptions((opts, factory) => {
const originOpts = factory()
opts.legend.data = originOpts.legend.data
opts.series[0].name = originOpts.series[0].name
opts.series[1].name = originOpts.series[1].name
return opts
})
}
async function init() {
mockData()
}
watch(
() => appStore.locale,
() => {
updateLocale()
},
)
// init
init()
</script>
<template>
<NCard :bordered="false" class="card-wrapper">
<div ref="domRef" class="h-360px overflow-hidden" />
</NCard>
</template>
<style scoped></style>

View File

@ -0,0 +1,109 @@
<script setup lang="ts">
import { watch } from 'vue'
import { useEcharts } from '@/hooks/common/echarts'
import { $t } from '@/locales'
import { useAppStore } from '@/store/modules/app'
defineOptions({
name: 'PieChart',
})
const appStore = useAppStore()
const { domRef, updateOptions } = useEcharts(() => ({
tooltip: {
trigger: 'item',
},
legend: {
bottom: '1%',
left: 'center',
itemStyle: {
borderWidth: 0,
},
},
series: [
{
color: ['#5da8ff', '#8e9dff', '#fedc69', '#26deca'],
name: $t('page.home.schedule'),
type: 'pie',
radius: ['45%', '75%'],
avoidLabelOverlap: false,
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 1,
},
label: {
show: false,
position: 'center',
},
emphasis: {
label: {
show: true,
fontSize: '12',
},
},
labelLine: {
show: false,
},
data: [] as { name: string, value: number }[],
},
],
}))
async function mockData() {
await new Promise((resolve) => {
setTimeout(resolve, 1000)
})
updateOptions((opts) => {
opts.series[0].data = [
{ name: $t('page.home.study'), value: 20 },
{ name: $t('page.home.entertainment'), value: 10 },
{ name: $t('page.home.work'), value: 40 },
{ name: $t('page.home.rest'), value: 30 },
]
return opts
})
}
function updateLocale() {
updateOptions((opts, factory) => {
const originOpts = factory()
opts.series[0].name = originOpts.series[0].name
opts.series[0].data = [
{ name: $t('page.home.study'), value: 20 },
{ name: $t('page.home.entertainment'), value: 10 },
{ name: $t('page.home.work'), value: 40 },
{ name: $t('page.home.rest'), value: 30 },
]
return opts
})
}
async function init() {
mockData()
}
watch(
() => appStore.locale,
() => {
updateLocale()
},
)
// init
init()
</script>
<template>
<NCard :bordered="false" class="card-wrapper">
<div ref="domRef" class="h-360px overflow-hidden" />
</NCard>
</template>
<style scoped></style>

View File

@ -0,0 +1,40 @@
<script setup lang="ts">
import { computed } from 'vue'
import { $t } from '@/locales'
defineOptions({
name: 'ProjectNews',
})
interface NewsItem {
id: number
content: string
time: string
}
const newses = computed<NewsItem[]>(() => [
{ id: 1, content: $t('page.home.projectNews.desc1'), time: '2021-05-28 22:22:22' },
{ id: 2, content: $t('page.home.projectNews.desc2'), time: '2021-10-27 10:24:54' },
{ id: 3, content: $t('page.home.projectNews.desc3'), time: '2021-10-31 22:43:12' },
{ id: 4, content: $t('page.home.projectNews.desc4'), time: '2021-11-03 20:33:31' },
{ id: 5, content: $t('page.home.projectNews.desc5'), time: '2021-11-07 22:45:32' },
])
</script>
<template>
<NCard :title="$t('page.home.projectNews.title')" :bordered="false" size="small" segmented class="card-wrapper">
<template #header-extra>
<a class="text-primary" href="javascript:;">{{ $t('page.home.projectNews.moreNews') }}</a>
</template>
<NList>
<NListItem v-for="item in newses" :key="item.id">
<template #prefix>
<ReaderStarAvatar class="size-48px!" />
</template>
<NThing :title="item.content" :description="item.time" />
</NListItem>
</NList>
</NCard>
</template>
<style scoped></style>