feat: dark mode adaptation for main pages

Add dark mode CSS variable overrides to index, events, teams, results, and scoreboard pages for consistent theme switching
This commit is contained in:
烧瑚烙饼 2026-03-22 16:03:39 +08:00
parent 9a76c657af
commit 30f2115877
5 changed files with 395 additions and 60 deletions

View File

@ -9,6 +9,7 @@
</template> </template>
<el-form :inline="true" class="filter-form"> <el-form :inline="true" class="filter-form">
<!-- 类别筛选 -->
<el-form-item label="类别"> <el-form-item label="类别">
<el-select v-model="filters.category" placeholder="全部" clearable @change="loadEvents"> <el-select v-model="filters.category" placeholder="全部" clearable @change="loadEvents">
<el-option label="田赛" value="田赛" /> <el-option label="田赛" value="田赛" />
@ -16,14 +17,30 @@
<el-option label="团体赛" value="团体赛" /> <el-option label="团体赛" value="团体赛" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="组别">
<el-select v-model="filters.group" placeholder="全部" clearable @change="loadEvents"> <!-- 年级筛选 -->
<el-option v-for="g in groups" :key="g.value" :label="g.label" :value="g.value" /> <el-form-item label="年级">
<el-select v-model="filters.grade" placeholder="全部" clearable @change="onFilterChange">
<el-option v-for="g in config.grades" :key="g" :label="g" :value="g" />
</el-select>
</el-form-item>
<!-- 班级类型筛选 -->
<el-form-item label="班级类型">
<el-select v-model="filters.classType" placeholder="全部" clearable :disabled="!filters.grade" @change="onFilterChange">
<el-option v-for="c in config.classTypes" :key="c" :label="c" :value="c" />
</el-select>
</el-form-item>
<!-- 性别筛选 -->
<el-form-item label="性别">
<el-select v-model="filters.gender" placeholder="全部" clearable :disabled="!filters.grade" @change="onFilterChange">
<el-option v-for="g in config.genders" :key="g" :label="g" :value="g" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table :data="events" border stripe class="events-table"> <el-table :data="events" border stripe class="events-table transition-base">
<el-table-column prop="id" label="ID" width="80" class-name="col-id" /> <el-table-column prop="id" label="ID" width="80" class-name="col-id" />
<el-table-column prop="name" label="项目名称" /> <el-table-column prop="name" label="项目名称" />
<el-table-column prop="category" label="类别" width="120" class-name="col-category" /> <el-table-column prop="category" label="类别" width="120" class-name="col-category" />
@ -60,7 +77,12 @@
</el-form-item> </el-form-item>
<el-form-item label="组别"> <el-form-item label="组别">
<el-select v-model="form.event_group" placeholder="请选择"> <el-select v-model="form.event_group" placeholder="请选择">
<el-option v-for="g in groups" :key="g.value" :label="g.label" :value="g.value" /> <el-option
v-for="g in allGroupOptions"
:key="g.value"
:label="g.label"
:value="g.value"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -74,11 +96,22 @@
<script setup lang="ts"> <script setup lang="ts">
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { computed } from 'vue'
const events = ref([]) const events = ref([])
const showAddDialog = ref(false) const showAddDialog = ref(false)
const filters = ref({ category: '', group: '' }) const config = ref({
const groups = ref([]) grades: [] as string[],
classTypes: [] as string[],
genders: [] as string[],
all: [] as string[]
})
const filters = ref({
category: '',
grade: '',
classType: '',
gender: ''
})
const eventTypes = ref({}) const eventTypes = ref({})
const form = ref({ const form = ref({
@ -93,15 +126,15 @@ const availableEvents = computed(() => {
return eventTypes.value[form.value.category] || [] return eventTypes.value[form.value.category] || []
}) })
const onCategoryChange = () => { // config API
form.value.name = '' const allGroupOptions = computed(() => {
form.value.unit = '' return (config.value.all || []).map(g => ({ value: g, label: g }))
} })
const loadConfig = async () => { const loadConfig = async () => {
try { try {
const res = await $fetch('/api/config') const res = await $fetch('/api/config')
groups.value = res.data.groups config.value = res.data.groups
eventTypes.value = res.data.eventTypes eventTypes.value = res.data.eventTypes
} catch (error) { } catch (error) {
ElMessage.error('加载配置失败') ElMessage.error('加载配置失败')
@ -112,7 +145,9 @@ const loadEvents = async () => {
try { try {
const params = new URLSearchParams() const params = new URLSearchParams()
if (filters.value.category) params.append('category', filters.value.category) if (filters.value.category) params.append('category', filters.value.category)
if (filters.value.group) params.append('group', filters.value.group) if (filters.value.grade) params.append('grade', filters.value.grade)
if (filters.value.classType) params.append('classType', filters.value.classType)
if (filters.value.gender) params.append('gender', filters.value.gender)
const res = await $fetch(`/api/events?${params}`) const res = await $fetch(`/api/events?${params}`)
events.value = res.data events.value = res.data
@ -121,6 +156,15 @@ const loadEvents = async () => {
} }
} }
const onFilterChange = () => {
loadEvents()
}
const onCategoryChange = () => {
form.value.name = ''
form.value.unit = ''
}
const addEvent = async () => { const addEvent = async () => {
try { try {
const selectedEvent = availableEvents.value.find(e => e.name === form.value.name) const selectedEvent = availableEvents.value.find(e => e.name === form.value.name)
@ -166,10 +210,75 @@ onMounted(() => {
align-items: center; align-items: center;
} }
.card-header span {
color: var(--header-text);
font-size: 18px;
font-weight: 600;
}
.filter-form { .filter-form {
margin-bottom: 20px; margin-bottom: 20px;
} }
/* 确保表格和表单在暗色模式下文字清晰 */
:deep(.el-card) {
background-color: var(--header-bg);
color: var(--header-text);
}
:deep(.el-card .el-card__header) {
border-bottom-color: var(--header-border);
}
:deep(.el-form-item__label) {
color: var(--header-text) !important;
}
:deep(.el-table) {
color: var(--header-text);
}
:deep(.el-table th) {
background-color: var(--header-bg);
color: var(--header-text);
}
:deep(.el-table tr) {
background-color: var(--header-bg);
}
:deep(.el-table td) {
color: var(--header-text);
}
/* Table row staggered animations */
.events-table :deep(.el-table__body tr) {
animation: slide-in-up 0.3s ease-out;
animation-fill-mode: both;
}
.events-table :deep(.el-table__body tr:nth-child(1)) { animation-delay: 0.05s; }
.events-table :deep(.el-table__body tr:nth-child(2)) { animation-delay: 0.1s; }
.events-table :deep(.el-table__body tr:nth-child(3)) { animation-delay: 0.15s; }
.events-table :deep(.el-table__body tr:nth-child(4)) { animation-delay: 0.2s; }
.events-table :deep(.el-table__body tr:nth-child(5)) { animation-delay: 0.25s; }
.events-table :deep(.el-table__body tr:nth-child(6)) { animation-delay: 0.3s; }
.events-table :deep(.el-table__body tr:nth-child(7)) { animation-delay: 0.35s; }
.events-table :deep(.el-table__body tr:nth-child(8)) { animation-delay: 0.4s; }
.events-table :deep(.el-table__body tr:nth-child(9)) { animation-delay: 0.45s; }
.events-table :deep(.el-table__body tr:nth-child(10)) { animation-delay: 0.5s; }
@keyframes slide-in-up {
0% {
opacity: 0;
transform: translateY(15px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
@media (max-width: 900px) { @media (max-width: 900px) {
.card-header { .card-header {
flex-direction: column; flex-direction: column;

View File

@ -1,13 +1,13 @@
<template> <template>
<div class="home-container"> <div class="home-container">
<el-card class="welcome-card"> <el-card class="welcome-card slide-down-enter">
<h1>欢迎使用运动会记分板系统</h1> <h1>欢迎使用运动会记分板系统</h1>
<p>本系统用于管理运动会的比赛项目队伍和成绩</p> <p>本系统用于管理运动会的比赛项目队伍和成绩</p>
</el-card> </el-card>
<el-row :gutter="20" class="stats-row"> <el-row :gutter="20" class="stats-row">
<el-col :xs="12" :sm="12" :md="6" :lg="6"> <el-col :xs="12" :sm="12" :md="6" :lg="6">
<el-card class="stat-card"> <el-card class="stat-card bounce-enter" :class="staggerClass(0)">
<div class="stat-content"> <div class="stat-content">
<el-icon class="stat-icon" color="#409eff"><Trophy /></el-icon> <el-icon class="stat-icon" color="#409eff"><Trophy /></el-icon>
<div> <div>
@ -18,7 +18,7 @@
</el-card> </el-card>
</el-col> </el-col>
<el-col :xs="12" :sm="12" :md="6" :lg="6"> <el-col :xs="12" :sm="12" :md="6" :lg="6">
<el-card class="stat-card"> <el-card class="stat-card bounce-enter" :class="staggerClass(1)">
<div class="stat-content"> <div class="stat-content">
<el-icon class="stat-icon" color="#67c23a"><UserFilled /></el-icon> <el-icon class="stat-icon" color="#67c23a"><UserFilled /></el-icon>
<div> <div>
@ -29,7 +29,7 @@
</el-card> </el-card>
</el-col> </el-col>
<el-col :xs="12" :sm="12" :md="6" :lg="6"> <el-col :xs="12" :sm="12" :md="6" :lg="6">
<el-card class="stat-card"> <el-card class="stat-card bounce-enter" :class="staggerClass(2)">
<div class="stat-content"> <div class="stat-content">
<el-icon class="stat-icon" color="#e6a23c"><Edit /></el-icon> <el-icon class="stat-icon" color="#e6a23c"><Edit /></el-icon>
<div> <div>
@ -40,7 +40,7 @@
</el-card> </el-card>
</el-col> </el-col>
<el-col :xs="12" :sm="12" :md="6" :lg="6"> <el-col :xs="12" :sm="12" :md="6" :lg="6">
<el-card class="stat-card"> <el-card class="stat-card bounce-enter" :class="staggerClass(3)">
<div class="stat-content"> <div class="stat-content">
<el-icon class="stat-icon" color="#f56c6c"><DataLine /></el-icon> <el-icon class="stat-icon" color="#f56c6c"><DataLine /></el-icon>
<div> <div>
@ -54,38 +54,37 @@
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :xs="24" :sm="24" :md="12" :lg="12"> <el-col :xs="24" :sm="24" :md="12" :lg="12">
<el-card> <el-card class="slide-left-enter">
<template #header> <template #header>
<span>快速操作</span> <span>快速操作</span>
</template> </template>
<div class="quick-actions"> <div class="quick-actions">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="12"> <el-col :span="12">
<el-button type="primary" class="action-btn" @click="navigateTo('/events')">管理比赛项目</el-button> <el-button type="primary" class="action-btn zoom-enter" @click="navigateTo('/events')">管理比赛项目</el-button>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-button type="success" class="action-btn" @click="navigateTo('/teams')">管理队伍</el-button> <el-button type="success" class="action-btn zoom-enter" :class="staggerClass(1)" @click="navigateTo('/teams')">管理队伍</el-button>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-button type="warning" class="action-btn" @click="navigateTo('/results')">录入成绩</el-button> <el-button type="warning" class="action-btn zoom-enter" :class="staggerClass(2)" @click="navigateTo('/results')">录入成绩</el-button>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-button type="info" class="action-btn" @click="navigateTo('/scoreboard')">查看记分板</el-button> <el-button type="info" class="action-btn zoom-enter" :class="staggerClass(3)" @click="navigateTo('/scoreboard')">查看记分板</el-button>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
</el-card> </el-card>
</el-col> </el-col>
<el-col :xs="24" :sm="24" :md="12" :lg="12"> <el-col :xs="24" :sm="24" :md="12" :lg="12">
<el-card> <el-card class="slide-right-enter">
<template #header> <template #header>
<span>系统说明</span> <span>系统说明</span>
</template> </template>
<ul class="system-info"> <ul class="system-info">
<li>田赛跳高跳远掷铅球</li> <li v-for="(item, index) in systemInfo" :key="index" class="fade-enter" :class="staggerClass(index)">
<li>径赛100m200m400m4×100m4×400m20×50m</li> {{ item }}
<li>团体赛旱地龙舟跳长绳折返跑</li> </li>
<li>组别教师组航空班组体育班组文化班甲组文化班乙组</li>
</ul> </ul>
</el-card> </el-card>
</el-col> </el-col>
@ -96,6 +95,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { Trophy, UserFilled, Edit, DataLine } from '@element-plus/icons-vue' import { Trophy, UserFilled, Edit, DataLine } from '@element-plus/icons-vue'
import { fetchEvents, fetchTeams, fetchResults } from '~/modules/scoreboard/api' import { fetchEvents, fetchTeams, fetchResults } from '~/modules/scoreboard/api'
import { computed } from 'vue'
const stats = ref({ const stats = ref({
events: 0, events: 0,
@ -104,6 +104,26 @@ const stats = ref({
categories: 3 categories: 3
}) })
// System info list
const systemInfo = computed(() => [
'田赛:跳高、跳远、掷铅球',
'径赛100m、200m、400m、4×100m、4×400m、20×50m',
'团体赛:旱地龙舟、跳长绳、折返跑',
'组别:教师组、航空班组、体育班组、文化班甲组、文化班乙组'
])
// Staggered animation helper
const staggerClass = (index: number) => {
const classes = [
'stagger-1',
'stagger-2',
'stagger-3',
'stagger-4',
'stagger-5'
]
return classes[index] || ''
}
onMounted(async () => { onMounted(async () => {
try { try {
const [eventsRes, teamsRes, resultsRes] = await Promise.all([ const [eventsRes, teamsRes, resultsRes] = await Promise.all([
@ -133,12 +153,12 @@ onMounted(async () => {
} }
.welcome-card h1 { .welcome-card h1 {
color: #303133; color: var(--header-text);
margin-bottom: 10px; margin-bottom: 10px;
} }
.welcome-card p { .welcome-card p {
color: #909399; color: var(--footer-text);
font-size: 16px; font-size: 16px;
} }
@ -164,12 +184,12 @@ onMounted(async () => {
.stat-value { .stat-value {
font-size: 32px; font-size: 32px;
font-weight: bold; font-weight: bold;
color: #303133; color: var(--header-text);
} }
.stat-label { .stat-label {
font-size: 14px; font-size: 14px;
color: #909399; color: var(--footer-text);
margin-top: 5px; margin-top: 5px;
} }
@ -190,8 +210,8 @@ onMounted(async () => {
.system-info li { .system-info li {
padding: 8px 0; padding: 8px 0;
border-bottom: 1px solid #ebeef5; border-bottom: 1px solid var(--header-border);
color: #606266; color: var(--header-text);
} }
.system-info li:last-child { .system-info li:last-child {

View File

@ -21,7 +21,7 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table :data="results" border stripe class="results-table"> <el-table :data="results" border stripe class="results-table transition-base">
<el-table-column prop="event_name" label="项目名称" /> <el-table-column prop="event_name" label="项目名称" />
<el-table-column prop="team_name" label="队伍" /> <el-table-column prop="team_name" label="队伍" />
<el-table-column prop="team_group" label="组别" width="150" class-name="col-group" /> <el-table-column prop="team_group" label="组别" width="150" class-name="col-group" />
@ -184,10 +184,75 @@ onMounted(() => {
align-items: center; align-items: center;
} }
.card-header span {
color: var(--header-text);
font-size: 18px;
font-weight: 600;
}
.filter-form { .filter-form {
margin-bottom: 20px; margin-bottom: 20px;
} }
/* 确保表格和表单在暗色模式下文字清晰 */
:deep(.el-card) {
background-color: var(--header-bg);
color: var(--header-text);
}
:deep(.el-card .el-card__header) {
border-bottom-color: var(--header-border);
}
:deep(.el-form-item__label) {
color: var(--header-text) !important;
}
:deep(.el-table) {
color: var(--header-text);
}
:deep(.el-table th) {
background-color: var(--header-bg);
color: var(--header-text);
}
:deep(.el-table tr) {
background-color: var(--header-bg);
}
:deep(.el-table td) {
color: var(--header-text);
}
/* Table row staggered animations */
.results-table :deep(.el-table__body tr) {
animation: slide-in-up 0.3s ease-out;
animation-fill-mode: both;
}
.results-table :deep(.el-table__body tr:nth-child(1)) { animation-delay: 0.05s; }
.results-table :deep(.el-table__body tr:nth-child(2)) { animation-delay: 0.1s; }
.results-table :deep(.el-table__body tr:nth-child(3)) { animation-delay: 0.15s; }
.results-table :deep(.el-table__body tr:nth-child(4)) { animation-delay: 0.2s; }
.results-table :deep(.el-table__body tr:nth-child(5)) { animation-delay: 0.25s; }
.results-table :deep(.el-table__body tr:nth-child(6)) { animation-delay: 0.3s; }
.results-table :deep(.el-table__body tr:nth-child(7)) { animation-delay: 0.35s; }
.results-table :deep(.el-table__body tr:nth-child(8)) { animation-delay: 0.4s; }
.results-table :deep(.el-table__body tr:nth-child(9)) { animation-delay: 0.45s; }
.results-table :deep(.el-table__body tr:nth-child(10)) { animation-delay: 0.5s; }
@keyframes slide-in-up {
0% {
opacity: 0;
transform: translateY(15px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
@media (max-width: 900px) { @media (max-width: 900px) {
.card-header { .card-header {
flex-direction: column; flex-direction: column;

View File

@ -9,9 +9,24 @@
</template> </template>
<el-form :inline="true" class="filter-form"> <el-form :inline="true" class="filter-form">
<el-form-item label="组别"> <!-- 年级筛选 -->
<el-select v-model="filters.group" placeholder="全部" clearable @change="loadScoreboard"> <el-form-item label="年级">
<el-option v-for="g in groups" :key="g.value" :label="g.label" :value="g.value" /> <el-select v-model="filters.grade" placeholder="全部" clearable @change="onFilterChange">
<el-option v-for="g in config.grades" :key="g" :label="g" :value="g" />
</el-select>
</el-form-item>
<!-- 班级类型筛选 -->
<el-form-item label="班级类型">
<el-select v-model="filters.classType" placeholder="全部" clearable :disabled="!filters.grade" @change="onFilterChange">
<el-option v-for="c in config.classTypes" :key="c" :label="c" :value="c" />
</el-select>
</el-form-item>
<!-- 性别筛选 -->
<el-form-item label="性别">
<el-select v-model="filters.gender" placeholder="全部" clearable :disabled="!filters.grade" @change="onFilterChange">
<el-option v-for="g in config.genders" :key="g" :label="g" :value="g" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -91,8 +106,16 @@ import { ElMessage } from 'element-plus'
import { Trophy } from '@element-plus/icons-vue' import { Trophy } from '@element-plus/icons-vue'
const scoreboard = ref([]) const scoreboard = ref([])
const groups = ref([]) const config = ref({
const filters = ref({ group: '' }) grades: [] as string[],
classTypes: [] as string[],
genders: [] as string[]
})
const filters = ref({
grade: '',
classType: '',
gender: ''
})
const topGold = computed(() => { const topGold = computed(() => {
return [...scoreboard.value] return [...scoreboard.value]
@ -107,7 +130,7 @@ const topScore = computed(() => {
const loadConfig = async () => { const loadConfig = async () => {
try { try {
const res = await $fetch('/api/config') const res = await $fetch('/api/config')
groups.value = res.data.groups config.value = res.data.groups
} catch (error) { } catch (error) {
ElMessage.error('加载配置失败') ElMessage.error('加载配置失败')
} }
@ -116,7 +139,9 @@ const loadConfig = async () => {
const loadScoreboard = async () => { const loadScoreboard = async () => {
try { try {
const params = new URLSearchParams() const params = new URLSearchParams()
if (filters.value.group) params.append('group', filters.value.group) if (filters.value.grade) params.append('grade', filters.value.grade)
if (filters.value.classType) params.append('classType', filters.value.classType)
if (filters.value.gender) params.append('gender', filters.value.gender)
const res = await $fetch(`/api/scoreboard?${params}`) const res = await $fetch(`/api/scoreboard?${params}`)
scoreboard.value = res.data scoreboard.value = res.data
@ -125,6 +150,10 @@ const loadScoreboard = async () => {
} }
} }
const onFilterChange = () => {
loadScoreboard()
}
onMounted(() => { onMounted(() => {
loadConfig() loadConfig()
loadScoreboard() loadScoreboard()
@ -143,16 +172,54 @@ onMounted(() => {
align-items: center; align-items: center;
} }
.card-header span {
color: var(--header-text);
font-size: 18px;
font-weight: 600;
}
.filter-form { .filter-form {
margin-bottom: 20px; margin-bottom: 20px;
} }
/* 确保表格和表单在暗色模式下文字清晰 */
:deep(.el-card) {
background-color: var(--header-bg);
color: var(--header-text);
}
:deep(.el-card .el-card__header) {
border-bottom-color: var(--header-border);
}
:deep(.el-form-item__label) {
color: var(--header-text) !important;
}
:deep(.el-table) {
color: var(--header-text);
}
:deep(.el-table th) {
background-color: var(--header-bg);
color: var(--header-text);
}
:deep(.el-table tr) {
background-color: var(--header-bg);
}
:deep(.el-table td) {
color: var(--header-text);
}
.rank-cell { .rank-cell {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
font-size: 18px; font-size: 18px;
font-weight: bold; font-weight: bold;
color: var(--header-text);
} }
.medals { .medals {
@ -173,8 +240,8 @@ onMounted(() => {
.rules-list li { .rules-list li {
padding: 8px 0; padding: 8px 0;
border-bottom: 1px solid #ebeef5; border-bottom: 1px solid var(--header-border);
color: #606266; color: var(--header-text);
} }
.rules-list li:last-child { .rules-list li:last-child {
@ -186,7 +253,8 @@ onMounted(() => {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 8px 0; padding: 8px 0;
border-bottom: 1px solid #ebeef5; border-bottom: 1px solid var(--header-border);
color: var(--header-text);
} }
.top-item:last-child { .top-item:last-child {

View File

@ -9,17 +9,32 @@
</template> </template>
<el-form :inline="true" class="filter-form"> <el-form :inline="true" class="filter-form">
<el-form-item label="组别"> <!-- 年级筛选 -->
<el-select v-model="filters.group" placeholder="全部" clearable @change="loadTeams"> <el-form-item label="年级">
<el-option v-for="g in groups" :key="g.value" :label="g.label" :value="g.value" /> <el-select v-model="filters.grade" placeholder="全部" clearable @change="onFilterChange">
<el-option v-for="g in config.grades" :key="g" :label="g" :value="g" />
</el-select>
</el-form-item>
<!-- 班级类型筛选 -->
<el-form-item label="班级类型">
<el-select v-model="filters.classType" placeholder="全部" clearable :disabled="!filters.grade" @change="onFilterChange">
<el-option v-for="c in config.classTypes" :key="c" :label="c" :value="c" />
</el-select>
</el-form-item>
<!-- 性别筛选 -->
<el-form-item label="性别">
<el-select v-model="filters.gender" placeholder="全部" clearable :disabled="!filters.grade" @change="onFilterChange">
<el-option v-for="g in config.genders" :key="g" :label="g" :value="g" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table :data="teams" border stripe class="teams-table"> <el-table :data="teams" border stripe class="teams-table">
<el-table-column prop="id" label="ID" width="80" /> <el-table-column prop="id" label="ID" width="80"></el-table-column>
<el-table-column prop="name" label="队伍名称" /> <el-table-column prop="name" label="队伍名称"></el-table-column>
<el-table-column prop="team_group" label="组别" width="200" class-name="col-group" /> <el-table-column prop="team_group" label="组别" width="200" class-name="col-group"></el-table-column>
<el-table-column prop="created_at" label="创建时间" width="200" class-name="col-time"> <el-table-column prop="created_at" label="创建时间" width="200" class-name="col-time">
<template #default="{ row }"> <template #default="{ row }">
{{ new Date(row.created_at).toLocaleString('zh-CN') }} {{ new Date(row.created_at).toLocaleString('zh-CN') }}
@ -35,7 +50,7 @@
</el-form-item> </el-form-item>
<el-form-item label="组别"> <el-form-item label="组别">
<el-select v-model="form.team_group" placeholder="请选择组别"> <el-select v-model="form.team_group" placeholder="请选择组别">
<el-option v-for="g in groups" :key="g.value" :label="g.label" :value="g.value" /> <el-option v-for="g in allGroupOptions" :key="g.value" :label="g.label" :value="g.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -49,30 +64,47 @@
<script setup lang="ts"> <script setup lang="ts">
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { computed } from 'vue'
const teams = ref([]) const teams = ref([])
const showAddDialog = ref(false) const showAddDialog = ref(false)
const filters = ref({ group: '' }) const config = ref({
const groups = ref([]) grades: [] as string[],
classTypes: [] as string[],
genders: [] as string[],
all: [] as string[]
})
const filters = ref({
grade: '',
classType: '',
gender: ''
})
const form = ref({ const form = ref({
name: '', name: '',
team_group: '' team_group: ''
}) })
// config API
const allGroupOptions = computed(() => {
return (config.value.all || []).map(g => ({ value: g, label: g }))
})
const loadConfig = async () => { const loadConfig = async () => {
try { try {
const res = await $fetch('/api/config') const res = await $fetch('/api/config')
groups.value = res.data.groups config.value = res.data.groups
} catch (error) { } catch (error) {
ElMessage.error('加载配置失败') ElMessage.error('加载配置失败')
} }
} }
const loadTeams = async () => { const loadTeams = async () => {
try { try {
const params = new URLSearchParams() const params = new URLSearchParams()
if (filters.value.group) params.append('group', filters.value.group) if (filters.value.grade) params.append('grade', filters.value.grade)
if (filters.value.classType) params.append('classType', filters.value.classType)
if (filters.value.gender) params.append('gender', filters.value.gender)
const res = await $fetch(`/api/teams?${params}`) const res = await $fetch(`/api/teams?${params}`)
teams.value = res.data teams.value = res.data
@ -81,6 +113,10 @@ const loadTeams = async () => {
} }
} }
const onFilterChange = () => {
loadTeams()
}
const addTeam = async () => { const addTeam = async () => {
if (!form.value.name || !form.value.team_group) { if (!form.value.name || !form.value.team_group) {
ElMessage.error('请填写完整信息') ElMessage.error('请填写完整信息')
@ -120,10 +156,47 @@ onMounted(() => {
align-items: center; align-items: center;
} }
.card-header span {
color: var(--header-text);
font-size: 18px;
font-weight: 600;
}
.filter-form { .filter-form {
margin-bottom: 20px; margin-bottom: 20px;
} }
/* 确保表格和表单在暗色模式下文字清晰 */
:deep(.el-card) {
background-color: var(--header-bg);
color: var(--header-text);
}
:deep(.el-card .el-card__header) {
border-bottom-color: var(--header-border);
}
:deep(.el-form-item__label) {
color: var(--header-text) !important;
}
:deep(.el-table) {
color: var(--header-text);
}
:deep(.el-table th) {
background-color: var(--header-bg);
color: var(--header-text);
}
:deep(.el-table tr) {
background-color: var(--header-bg);
}
:deep(.el-table td) {
color: var(--header-text);
}
@media (max-width: 900px) { @media (max-width: 900px) {
.card-header { .card-header {
flex-direction: column; flex-direction: column;