feat: WC2026 赛事 seed、生产上线初始化脚本与目录归档

重构 seed 为 WC2026 72 场小组赛与 48 强优胜盘;新增 production 模式仅保留 admin 与赛事示例;提供 prod-init-db 全量重置脚本;管理端 i18n 分包与赛事归档能力。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-12 18:17:00 +08:00
parent 8f14e85ebd
commit e7e938f261
94 changed files with 12332 additions and 976 deletions

View File

@@ -4,15 +4,17 @@ import { useRoute } from 'vue-router';
import { useAdminLocale } from '../composables/useAdminLocale';
import { resolveFormError } from '../i18n/form-validation';
import api from '../api';
import { ElMessage } from 'element-plus';
import { ElMessage, ElMessageBox } from 'element-plus';
import LeagueMatchesPanel from './matches/LeagueMatchesPanel.vue';
import MatchesSubNav from '../components/MatchesSubNav.vue';
import CountryFlagSelect from '../components/outright/CountryFlagSelect.vue';
import LogoUrlField from '../components/LogoUrlField.vue';
import LeagueArchiveDialog from '../components/LeagueArchiveDialog.vue';
import { getBuiltinCountry } from '../data/builtinCountries';
import {
readMatchesListUiState,
writeMatchesListUiState,
MAX_EXPANDED_LEAGUES,
} from '../utils/matchesListState';
import { formatAmount } from '../utils/format-amount';
import {
@@ -39,6 +41,9 @@ const leagueDialogMode = ref<'create' | 'edit'>('create');
const leagueEditingId = ref('');
const leagueForm = ref({ leagueEn: '', leagueZh: '', leagueMs: '', logoUrl: '', deleteOldLogo: false, originalLogoUrl: '' });
const publishingLeagueId = ref('');
const leagueArchiveVisible = ref(false);
const leagueArchiveId = ref('');
const leagueArchiveName = ref('');
const leagueDialogTitle = computed(() =>
leagueDialogMode.value === 'edit'
@@ -155,7 +160,18 @@ function openEditLeague(row: unknown) {
async function toggleLeaguePublish(row: unknown) {
const r = rowOf(row);
const id = String(r.id ?? '');
if (leagueIsPublished(row)) return;
const published = leagueIsPublished(row);
if (published) {
try {
await ElMessageBox.confirm(t('league.confirm_unpublish'), t('common.confirm'), {
type: 'warning',
confirmButtonText: t('league.btn.unpublish'),
cancelButtonText: t('common.cancel'),
});
} catch {
return;
}
}
publishingLeagueId.value = id;
try {
await api.put(`/admin/leagues/${id}`, {
@@ -163,9 +179,9 @@ async function toggleLeaguePublish(row: unknown) {
leagueZh: String(r.leagueZh ?? ''),
leagueMs: String(r.leagueMs ?? ''),
logoUrl: String(r.logoUrl ?? '').trim() || undefined,
isActive: true,
isActive: !published,
});
ElMessage.success(t('msg.league_published'));
ElMessage.success(published ? t('msg.league_unpublished') : t('msg.league_published'));
await load({ keepExpand: true });
} catch (e: unknown) {
const err = e as { response?: { data?: { error?: string } } };
@@ -255,7 +271,7 @@ async function submitCreate() {
const lid = form.value.leagueId.trim();
await load({ keepExpand: true });
if (lid && !expandedRowKeys.value.includes(lid)) {
expandedRowKeys.value = [...expandedRowKeys.value, lid];
expandedRowKeys.value = capExpandedLeagueIds([...expandedRowKeys.value, lid]);
persistListUiState();
}
} catch (e: unknown) {
@@ -266,15 +282,24 @@ async function submitCreate() {
}
}
function capExpandedLeagueIds(ids: string[]): string[] {
return ids.slice(0, MAX_EXPANDED_LEAGUES);
}
function onExpandChange(_row: unknown, expanded: unknown[]) {
expandedRowKeys.value = expanded.map((r) => leagueId(r));
expandedRowKeys.value = capExpandedLeagueIds(expanded.map((r) => leagueId(r)));
persistListUiState();
}
function onRowClick(row: unknown, _column: unknown, event: MouseEvent) {
if ((event.target as HTMLElement).closest('.el-table__expand-icon')) return;
const id = leagueId(row);
expandedRowKeys.value = expandedRowKeys.value.includes(id) ? [] : [id];
if (expandedRowKeys.value.includes(id)) {
expandedRowKeys.value = expandedRowKeys.value.filter((k) => k !== id);
} else {
const next = [...expandedRowKeys.value, id];
expandedRowKeys.value = capExpandedLeagueIds(next);
}
persistListUiState();
}
@@ -339,6 +364,16 @@ function isLeagueExpanded(id: string) {
return expandedRowKeys.value.includes(id);
}
function openLeagueArchive(row: unknown) {
leagueArchiveId.value = leagueId(row);
leagueArchiveName.value = leagueTitle(row);
leagueArchiveVisible.value = true;
}
function onLeagueArchived() {
void load();
}
</script>
<template>
@@ -378,6 +413,7 @@ function isLeagueExpanded(id: string) {
</div>
<section class="list-panel">
<p class="list-hint">{{ t('match.expand_league_hint') }}</p>
<div class="table-wrap">
<el-table
:data="leagues"
@@ -473,6 +509,18 @@ function isLeagueExpanded(id: string) {
>
{{ t('common.publish') }}
</el-button>
<el-button
v-else
size="small"
type="warning"
:loading="publishingLeagueId === leagueId(row)"
@click.stop="toggleLeaguePublish(row)"
>
{{ t('league.btn.unpublish') }}
</el-button>
<el-button size="small" type="danger" plain @click.stop="openLeagueArchive(row)">
{{ t('common.delete') }}
</el-button>
</div>
</div>
</template>
@@ -609,6 +657,13 @@ function isLeagueExpanded(id: string) {
<el-button type="primary" :loading="createLoading" @click="submitCreate">{{ t('user.btn.create') }}</el-button>
</template>
</el-dialog>
<LeagueArchiveDialog
v-model="leagueArchiveVisible"
:league-id="leagueArchiveId"
:league-name="leagueArchiveName"
@archived="onLeagueArchived"
/>
</div>
</template>
@@ -780,4 +835,5 @@ function isLeagueExpanded(id: string) {
:deep(.logo-url-field) {
width: 100%;
}
</style>