mirror of
https://github.com/BeamMP/BeamMP-Website.git
synced 2026-11-26 15:56:20 +00:00
Add event standings pages and an Events link
BeamMP now runs community events with combined leaderboards, and the site had nowhere to show them. This adds an Events page listing each event and an event page with live standings, a driver search, the servers taking part and the event rules. Standings come from the API's public events routes, so no key is ever in the browser. The page keeps the last good results on screen if a refresh fails and says the connection was lost rather than going blank. Events with an uploaded banner show it behind the card and the page header, with an overlay so the text stays readable; events without one look as plain cards. The helpers the two pages share live beside them in views/events rather than in lib, since nothing else uses them. The Events link sits before Servers in the desktop and mobile menus. All of the new text is translated into the seven site languages using literal keys, so the locale checks can see every one. The translations are machine written and want a native speaker's review. src/lib/config.js is included because the pages need the API address from it: it is the one place that reads the window.__ENV__ the container writes at start, with the real services as the defaults.
This commit is contained in:
1 parent
1488e3bbdb
commit
38955dcbfe
14 files changed
+931
-7
No files matched your search
@@ -92,6 +92,21 @@ function localRoute(path) {
|
||||
</RouterLink>
|
||||
</NavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
<NavigationMenuItem>
|
||||
<NavigationMenuLink as-child>
|
||||
<RouterLink
|
||||
:to="localRoute('events')"
|
||||
:class="
|
||||
cn(
|
||||
navigationMenuTriggerStyle(),
|
||||
'bg-transparent text-neutral-900 hover:bg-neutral-100 hover:text-neutral-900 dark:bg-transparent dark:text-white dark:hover:bg-neutral-800 dark:hover:text-white'
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ $t('message.nav.events') }}
|
||||
</RouterLink>
|
||||
</NavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
<NavigationMenuItem>
|
||||
<NavigationMenuLink as-child>
|
||||
<RouterLink
|
||||
@@ -270,6 +285,13 @@ function localRoute(path) {
|
||||
>
|
||||
{{ $t('message.nav.partners') }}
|
||||
</RouterLink>
|
||||
<RouterLink
|
||||
:to="localRoute('events')"
|
||||
class="block px-4 py-3 text-neutral-900 dark:text-white hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded-md transition-colors"
|
||||
@click="closeMobileMenu"
|
||||
>
|
||||
{{ $t('message.nav.events') }}
|
||||
</RouterLink>
|
||||
<RouterLink
|
||||
:to="localRoute('servers')"
|
||||
class="block px-4 py-3 text-neutral-900 dark:text-white hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded-md transition-colors"
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// Where BeamMP's own services live. The container writes /assets/env.js when it starts
|
||||
// (website-entrypoint.sh, from API_URL and ACCOUNTS_URL, as Accounts does); the defaults are
|
||||
// the real services.
|
||||
const trim = (url) => url.replace(/\/+$/, '')
|
||||
|
||||
export const API_BASE = trim(window.__ENV__?.API_URL || 'https://api.beammp.com')
|
||||
export const ACCOUNTS_BASE = trim(window.__ENV__?.ACCOUNTS_URL || 'https://accounts.beammp.com')
|
||||
+58
-1
@@ -22,7 +22,8 @@
|
||||
"light": "Helles Theme",
|
||||
"dark": "Dunkles Theme",
|
||||
"system": "System-Theme"
|
||||
}
|
||||
},
|
||||
"events": "Events"
|
||||
},
|
||||
"footer": {
|
||||
"support_on_patreon": "Unterstütze uns auf Patreon",
|
||||
@@ -274,6 +275,62 @@
|
||||
},
|
||||
"thank_you": "Gemeinsam bauen wir etwas Besonderes. Danke, dass du Teil der BeamMP-Community bist!"
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"title": "Events",
|
||||
"description": "Verfolge die aktuellen Ranglisten der BeamMP-Events, zusammengeführt von allen teilnehmenden Servern.",
|
||||
"loading": "Events werden geladen…",
|
||||
"empty": "Es wurden noch keine Events eingerichtet.",
|
||||
"viewTop": "Top {count} ansehen →",
|
||||
"ranked": "Gewertete Fahrer: {count}",
|
||||
"servers": "Server: {count}",
|
||||
"back": "← Alle Events",
|
||||
"loadingEvent": "Event wird geladen…",
|
||||
"standings": "Gesamtwertung",
|
||||
"topDrivers": "Top {count} Fahrer",
|
||||
"statDrivers": "Gewertete Fahrer",
|
||||
"statLaps": "Erfasste Runden",
|
||||
"statServers": "Server",
|
||||
"statPlace": "Platz {count}",
|
||||
"standingsTitle": "Rangliste",
|
||||
"search": "Fahrer suchen…",
|
||||
"pos": "Pos",
|
||||
"driver": "Fahrer",
|
||||
"bestLap": "Beste Runde",
|
||||
"gap": "Abstand",
|
||||
"pen": "Str.",
|
||||
"server": "Server",
|
||||
"leader": "Führender",
|
||||
"noMatch": "Keine passenden Fahrer.",
|
||||
"waiting": "Warte auf die ersten Ergebnisse der Event-Server.",
|
||||
"sources": "Server-Quellen",
|
||||
"lastResult": "Letztes Ergebnis: {when}",
|
||||
"none": "noch keins",
|
||||
"noServers": "Noch kein Server ist beigetreten.",
|
||||
"live": "Wird automatisch aktualisiert, sobald Server Runden melden.",
|
||||
"lost": "Verbindung verloren. Neuer Versuch…",
|
||||
"lastShown": "Zeige die zuletzt empfangenen Ergebnisse.",
|
||||
"rules": "Event-Regeln",
|
||||
"r1t": "Nur registrierte Fahrer.",
|
||||
"r1": "Gäste werden nicht gewertet.",
|
||||
"r2t": "Zeiten wie aufgezeichnet.",
|
||||
"r2": "Strafen werden vom Spielserver verhängt; die angezeigte Zeit ist die von ihm gemeldete.",
|
||||
"r3t": "Ein Platz pro Fahrer.",
|
||||
"r3": "Beste Runde über alle Event-Server.",
|
||||
"r4t": "Prüfung.",
|
||||
"r4": "Das Team kann Fahrer nach einer Prüfung ausschließen.",
|
||||
"status": {
|
||||
"qualifying": "Qualifying",
|
||||
"live": "Live-Event",
|
||||
"upcoming": "Demnächst",
|
||||
"finished": "Beendet"
|
||||
},
|
||||
"errors": {
|
||||
"notFound": "Dieses Event ist nicht verfügbar.",
|
||||
"rateLimited": "Zu viele Anfragen. Neuer Versuch in Kürze.",
|
||||
"unavailable": "Die Event-Ergebnisse sind nicht verfügbar.",
|
||||
"timeout": "Zeitüberschreitung. Automatischer neuer Versuch."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+58
-1
@@ -22,7 +22,8 @@
|
||||
"light": "Light Theme",
|
||||
"dark": "Dark Theme",
|
||||
"system": "System Theme"
|
||||
}
|
||||
},
|
||||
"events": "Events"
|
||||
},
|
||||
"footer": {
|
||||
"support_on_patreon": "Support us on Patreon",
|
||||
@@ -274,6 +275,62 @@
|
||||
},
|
||||
"thank_you": "Together, we’re building something special. Thank you for being part of the BeamMP community!"
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"title": "Events",
|
||||
"description": "Follow the latest standings for BeamMP events, combined across every server taking part.",
|
||||
"loading": "Loading events…",
|
||||
"empty": "No events have been set up yet.",
|
||||
"viewTop": "View top {count} →",
|
||||
"ranked": "Ranked drivers: {count}",
|
||||
"servers": "Servers: {count}",
|
||||
"back": "← All events",
|
||||
"loadingEvent": "Loading event…",
|
||||
"standings": "Global standings",
|
||||
"topDrivers": "Top {count} drivers",
|
||||
"statDrivers": "Ranked drivers",
|
||||
"statLaps": "Recorded laps",
|
||||
"statServers": "Servers",
|
||||
"statPlace": "Place {count}",
|
||||
"standingsTitle": "Standings",
|
||||
"search": "Search drivers…",
|
||||
"pos": "Pos",
|
||||
"driver": "Driver",
|
||||
"bestLap": "Best lap",
|
||||
"gap": "Gap",
|
||||
"pen": "Pen.",
|
||||
"server": "Server",
|
||||
"leader": "Leader",
|
||||
"noMatch": "No matching drivers.",
|
||||
"waiting": "Waiting for the first results from event servers.",
|
||||
"sources": "Server sources",
|
||||
"lastResult": "Last result: {when}",
|
||||
"none": "none yet",
|
||||
"noServers": "No servers have joined yet.",
|
||||
"live": "Updates automatically as servers report laps.",
|
||||
"lost": "Connection lost. Retrying…",
|
||||
"lastShown": "Showing the last received results.",
|
||||
"rules": "Event rules",
|
||||
"r1t": "Registered drivers only.",
|
||||
"r1": "Guests are not ranked.",
|
||||
"r2t": "Times as recorded.",
|
||||
"r2": "Penalties are applied by the game server; the time shown is the time it reported.",
|
||||
"r3t": "One place per driver.",
|
||||
"r3": "Best lap across all event servers.",
|
||||
"r4t": "Review.",
|
||||
"r4": "Staff can exclude drivers after review.",
|
||||
"status": {
|
||||
"qualifying": "Qualifying",
|
||||
"live": "Live event",
|
||||
"upcoming": "Upcoming",
|
||||
"finished": "Finished"
|
||||
},
|
||||
"errors": {
|
||||
"notFound": "This event is not available.",
|
||||
"rateLimited": "Too many requests. Retrying shortly.",
|
||||
"unavailable": "Event results are unavailable.",
|
||||
"timeout": "Connection timed out. Retrying automatically."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+58
-1
@@ -22,7 +22,8 @@
|
||||
"light": "Tema claro",
|
||||
"dark": "Tema oscuro",
|
||||
"system": "Tema del sistema"
|
||||
}
|
||||
},
|
||||
"events": "Eventos"
|
||||
},
|
||||
"footer": {
|
||||
"support_on_patreon": "Apóyanos en Patreon",
|
||||
@@ -274,6 +275,62 @@
|
||||
},
|
||||
"thank_you": "Juntos estamos construyendo algo especial. ¡Gracias por ser parte de la comunidad BeamMP!"
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"title": "Eventos",
|
||||
"description": "Sigue las clasificaciones de los eventos de BeamMP, combinadas de todos los servidores participantes.",
|
||||
"loading": "Cargando eventos…",
|
||||
"empty": "Aún no se ha creado ningún evento.",
|
||||
"viewTop": "Ver el top {count} →",
|
||||
"ranked": "Pilotos clasificados: {count}",
|
||||
"servers": "Servidores: {count}",
|
||||
"back": "← Todos los eventos",
|
||||
"loadingEvent": "Cargando evento…",
|
||||
"standings": "Clasificación global",
|
||||
"topDrivers": "Top {count} pilotos",
|
||||
"statDrivers": "Pilotos clasificados",
|
||||
"statLaps": "Vueltas registradas",
|
||||
"statServers": "Servidores",
|
||||
"statPlace": "Puesto {count}",
|
||||
"standingsTitle": "Clasificación",
|
||||
"search": "Buscar pilotos…",
|
||||
"pos": "Pos",
|
||||
"driver": "Piloto",
|
||||
"bestLap": "Mejor vuelta",
|
||||
"gap": "Diferencia",
|
||||
"pen": "Pen.",
|
||||
"server": "Servidor",
|
||||
"leader": "Líder",
|
||||
"noMatch": "Ningún piloto coincide.",
|
||||
"waiting": "Esperando los primeros resultados de los servidores del evento.",
|
||||
"sources": "Servidores de origen",
|
||||
"lastResult": "Último resultado: {when}",
|
||||
"none": "aún ninguno",
|
||||
"noServers": "Aún no se ha unido ningún servidor.",
|
||||
"live": "Se actualiza automáticamente cuando los servidores informan de vueltas.",
|
||||
"lost": "Conexión perdida. Reintentando…",
|
||||
"lastShown": "Mostrando los últimos resultados recibidos.",
|
||||
"rules": "Reglas del evento",
|
||||
"r1t": "Solo pilotos registrados.",
|
||||
"r1": "Los invitados no se clasifican.",
|
||||
"r2t": "Tiempos tal como se registran.",
|
||||
"r2": "El servidor del juego aplica las penalizaciones; el tiempo mostrado es el que informó.",
|
||||
"r3t": "Un puesto por piloto.",
|
||||
"r3": "Mejor vuelta en todos los servidores del evento.",
|
||||
"r4t": "Revisión.",
|
||||
"r4": "El personal puede excluir pilotos tras revisarlos.",
|
||||
"status": {
|
||||
"qualifying": "Clasificación previa",
|
||||
"live": "Evento en vivo",
|
||||
"upcoming": "Próximamente",
|
||||
"finished": "Finalizado"
|
||||
},
|
||||
"errors": {
|
||||
"notFound": "Este evento no está disponible.",
|
||||
"rateLimited": "Demasiadas solicitudes. Reintentando en breve.",
|
||||
"unavailable": "Los resultados del evento no están disponibles.",
|
||||
"timeout": "Se agotó el tiempo de conexión. Reintentando automáticamente."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+58
-1
@@ -22,7 +22,8 @@
|
||||
"light": "Thème clair",
|
||||
"dark": "Thème sombre",
|
||||
"system": "Thème système"
|
||||
}
|
||||
},
|
||||
"events": "Événements"
|
||||
},
|
||||
"footer": {
|
||||
"support_on_patreon": "Soutenez-nous sur notre Patreon",
|
||||
@@ -274,6 +275,62 @@
|
||||
},
|
||||
"thank_you": "Ensemble, nous construisons quelque chose de spécial. Merci de faire partie de la communauté BeamMP !"
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"title": "Événements",
|
||||
"description": "Suivez les classements des événements BeamMP, regroupés depuis tous les serveurs participants.",
|
||||
"loading": "Chargement des événements…",
|
||||
"empty": "Aucun événement n'a encore été créé.",
|
||||
"viewTop": "Voir le top {count} →",
|
||||
"ranked": "Pilotes classés: {count}",
|
||||
"servers": "Serveurs: {count}",
|
||||
"back": "← Tous les événements",
|
||||
"loadingEvent": "Chargement de l'événement…",
|
||||
"standings": "Classement général",
|
||||
"topDrivers": "Top {count} pilotes",
|
||||
"statDrivers": "Pilotes classés",
|
||||
"statLaps": "Tours enregistrés",
|
||||
"statServers": "Serveurs",
|
||||
"statPlace": "Place {count}",
|
||||
"standingsTitle": "Classement",
|
||||
"search": "Rechercher un pilote…",
|
||||
"pos": "Pos",
|
||||
"driver": "Pilote",
|
||||
"bestLap": "Meilleur tour",
|
||||
"gap": "Écart",
|
||||
"pen": "Pén.",
|
||||
"server": "Serveur",
|
||||
"leader": "Leader",
|
||||
"noMatch": "Aucun pilote correspondant.",
|
||||
"waiting": "En attente des premiers résultats des serveurs de l'événement.",
|
||||
"sources": "Serveurs sources",
|
||||
"lastResult": "Dernier résultat : {when}",
|
||||
"none": "aucun pour l'instant",
|
||||
"noServers": "Aucun serveur n'a encore rejoint l'événement.",
|
||||
"live": "Mise à jour automatique à mesure que les serveurs envoient des tours.",
|
||||
"lost": "Connexion perdue. Nouvelle tentative…",
|
||||
"lastShown": "Affichage des derniers résultats reçus.",
|
||||
"rules": "Règles de l'événement",
|
||||
"r1t": "Pilotes enregistrés uniquement.",
|
||||
"r1": "Les invités ne sont pas classés.",
|
||||
"r2t": "Temps tels qu'enregistrés.",
|
||||
"r2": "Les pénalités sont appliquées par le serveur de jeu ; le temps affiché est celui qu'il a transmis.",
|
||||
"r3t": "Une place par pilote.",
|
||||
"r3": "Meilleur tour sur tous les serveurs de l'événement.",
|
||||
"r4t": "Vérification.",
|
||||
"r4": "Le staff peut exclure des pilotes après examen.",
|
||||
"status": {
|
||||
"qualifying": "Qualifications",
|
||||
"live": "Événement en direct",
|
||||
"upcoming": "À venir",
|
||||
"finished": "Terminé"
|
||||
},
|
||||
"errors": {
|
||||
"notFound": "Cet événement n'est pas disponible.",
|
||||
"rateLimited": "Trop de requêtes. Nouvelle tentative sous peu.",
|
||||
"unavailable": "Les résultats de l'événement sont indisponibles.",
|
||||
"timeout": "Délai de connexion dépassé. Nouvelle tentative automatique."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+58
-1
@@ -22,7 +22,8 @@
|
||||
"light": "Tema chiaro",
|
||||
"dark": "Tema scuro",
|
||||
"system": "Tema di sistema"
|
||||
}
|
||||
},
|
||||
"events": "Eventi"
|
||||
},
|
||||
"footer": {
|
||||
"support_on_patreon": "Supportaci su Patreon",
|
||||
@@ -274,6 +275,62 @@
|
||||
},
|
||||
"thank_you": "Insieme stiamo costruendo qualcosa di speciale. Grazie per far parte della community BeamMP!"
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"title": "Eventi",
|
||||
"description": "Segui le classifiche degli eventi BeamMP, riunite da tutti i server partecipanti.",
|
||||
"loading": "Caricamento eventi…",
|
||||
"empty": "Nessun evento è stato ancora creato.",
|
||||
"viewTop": "Vedi la top {count} →",
|
||||
"ranked": "Piloti in classifica: {count}",
|
||||
"servers": "Server: {count}",
|
||||
"back": "← Tutti gli eventi",
|
||||
"loadingEvent": "Caricamento evento…",
|
||||
"standings": "Classifica globale",
|
||||
"topDrivers": "Top {count} piloti",
|
||||
"statDrivers": "Piloti in classifica",
|
||||
"statLaps": "Giri registrati",
|
||||
"statServers": "Server",
|
||||
"statPlace": "Posizione {count}",
|
||||
"standingsTitle": "Classifica",
|
||||
"search": "Cerca piloti…",
|
||||
"pos": "Pos",
|
||||
"driver": "Pilota",
|
||||
"bestLap": "Giro migliore",
|
||||
"gap": "Distacco",
|
||||
"pen": "Pen.",
|
||||
"server": "Server",
|
||||
"leader": "Leader",
|
||||
"noMatch": "Nessun pilota corrispondente.",
|
||||
"waiting": "In attesa dei primi risultati dai server dell'evento.",
|
||||
"sources": "Server di origine",
|
||||
"lastResult": "Ultimo risultato: {when}",
|
||||
"none": "ancora nessuno",
|
||||
"noServers": "Nessun server si è ancora unito.",
|
||||
"live": "Si aggiorna automaticamente quando i server inviano giri.",
|
||||
"lost": "Connessione persa. Nuovo tentativo…",
|
||||
"lastShown": "Mostro gli ultimi risultati ricevuti.",
|
||||
"rules": "Regole dell'evento",
|
||||
"r1t": "Solo piloti registrati.",
|
||||
"r1": "Gli ospiti non vengono classificati.",
|
||||
"r2t": "Tempi come registrati.",
|
||||
"r2": "Le penalità sono applicate dal server di gioco; il tempo mostrato è quello da lui comunicato.",
|
||||
"r3t": "Un posto per pilota.",
|
||||
"r3": "Giro migliore su tutti i server dell'evento.",
|
||||
"r4t": "Revisione.",
|
||||
"r4": "Lo staff può escludere piloti dopo una verifica.",
|
||||
"status": {
|
||||
"qualifying": "Qualifiche",
|
||||
"live": "Evento live",
|
||||
"upcoming": "In arrivo",
|
||||
"finished": "Concluso"
|
||||
},
|
||||
"errors": {
|
||||
"notFound": "Questo evento non è disponibile.",
|
||||
"rateLimited": "Troppe richieste. Nuovo tentativo a breve.",
|
||||
"unavailable": "I risultati dell'evento non sono disponibili.",
|
||||
"timeout": "Connessione scaduta. Nuovo tentativo automatico."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+58
-1
@@ -22,7 +22,8 @@
|
||||
"light": "Светлая тема",
|
||||
"dark": "Тёмная тема",
|
||||
"system": "Системная тема"
|
||||
}
|
||||
},
|
||||
"events": "События"
|
||||
},
|
||||
"footer": {
|
||||
"support_on_patreon": "Поддержите нас на Patreon",
|
||||
@@ -274,6 +275,62 @@
|
||||
},
|
||||
"thank_you": "Вместе мы строим нечто особенное. Спасибо, что вы — часть сообщества BeamMP!"
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"title": "События",
|
||||
"description": "Следите за актуальными таблицами результатов событий BeamMP, объединёнными со всех участвующих серверов.",
|
||||
"loading": "Загрузка событий…",
|
||||
"empty": "События ещё не созданы.",
|
||||
"viewTop": "Смотреть топ-{count} →",
|
||||
"ranked": "Пилотов в рейтинге: {count}",
|
||||
"servers": "Серверы: {count}",
|
||||
"back": "← Все события",
|
||||
"loadingEvent": "Загрузка события…",
|
||||
"standings": "Общий зачёт",
|
||||
"topDrivers": "Топ-{count} пилотов",
|
||||
"statDrivers": "Пилотов в рейтинге",
|
||||
"statLaps": "Записано кругов",
|
||||
"statServers": "Серверы",
|
||||
"statPlace": "{count}-е место",
|
||||
"standingsTitle": "Таблица",
|
||||
"search": "Поиск пилотов…",
|
||||
"pos": "Поз",
|
||||
"driver": "Пилот",
|
||||
"bestLap": "Лучший круг",
|
||||
"gap": "Отставание",
|
||||
"pen": "Штр.",
|
||||
"server": "Сервер",
|
||||
"leader": "Лидер",
|
||||
"noMatch": "Подходящих пилотов нет.",
|
||||
"waiting": "Ожидание первых результатов от серверов события.",
|
||||
"sources": "Серверы-источники",
|
||||
"lastResult": "Последний результат: {when}",
|
||||
"none": "пока нет",
|
||||
"noServers": "Ни один сервер ещё не присоединился.",
|
||||
"live": "Обновляется автоматически, когда серверы присылают круги.",
|
||||
"lost": "Соединение потеряно. Повторная попытка…",
|
||||
"lastShown": "Показаны последние полученные результаты.",
|
||||
"rules": "Правила события",
|
||||
"r1t": "Только зарегистрированные пилоты.",
|
||||
"r1": "Гости не учитываются в рейтинге.",
|
||||
"r2t": "Время как записано.",
|
||||
"r2": "Штрафы применяет игровой сервер; показано время, которое он передал.",
|
||||
"r3t": "Одно место на пилота.",
|
||||
"r3": "Лучший круг среди всех серверов события.",
|
||||
"r4t": "Проверка.",
|
||||
"r4": "Персонал может исключать пилотов после проверки.",
|
||||
"status": {
|
||||
"qualifying": "Квалификация",
|
||||
"live": "Событие в прямом эфире",
|
||||
"upcoming": "Скоро",
|
||||
"finished": "Завершено"
|
||||
},
|
||||
"errors": {
|
||||
"notFound": "Это событие недоступно.",
|
||||
"rateLimited": "Слишком много запросов. Скоро повторим попытку.",
|
||||
"unavailable": "Результаты события недоступны.",
|
||||
"timeout": "Превышено время ожидания. Повтор автоматически."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+58
-1
@@ -22,7 +22,8 @@
|
||||
"light": "明亮主题",
|
||||
"dark": "黑暗主题",
|
||||
"system": "跟随系统"
|
||||
}
|
||||
},
|
||||
"events": "赛事"
|
||||
},
|
||||
"footer": {
|
||||
"support_on_patreon": "Patreon",
|
||||
@@ -274,6 +275,62 @@
|
||||
},
|
||||
"thank_you": "我们正在共同打造一个独特的作品—真诚感谢您成为BeamMP社区的一员!"
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"title": "赛事",
|
||||
"description": "查看 BeamMP 赛事的最新排名,汇总所有参赛服务器的成绩。",
|
||||
"loading": "正在加载赛事…",
|
||||
"empty": "尚未创建任何赛事。",
|
||||
"viewTop": "查看前 {count} 名 →",
|
||||
"ranked": "已排名车手: {count}",
|
||||
"servers": "服务器: {count}",
|
||||
"back": "← 全部赛事",
|
||||
"loadingEvent": "正在加载赛事…",
|
||||
"standings": "总排名",
|
||||
"topDrivers": "前 {count} 名车手",
|
||||
"statDrivers": "已排名车手",
|
||||
"statLaps": "已记录圈数",
|
||||
"statServers": "服务器",
|
||||
"statPlace": "第 {count} 名",
|
||||
"standingsTitle": "排名",
|
||||
"search": "搜索车手…",
|
||||
"pos": "名次",
|
||||
"driver": "车手",
|
||||
"bestLap": "最佳圈速",
|
||||
"gap": "差距",
|
||||
"pen": "罚",
|
||||
"server": "服务器",
|
||||
"leader": "领先",
|
||||
"noMatch": "没有匹配的车手。",
|
||||
"waiting": "正在等待赛事服务器的首批成绩。",
|
||||
"sources": "服务器来源",
|
||||
"lastResult": "最近成绩:{when}",
|
||||
"none": "暂无",
|
||||
"noServers": "尚无服务器加入。",
|
||||
"live": "服务器上报圈速后自动更新。",
|
||||
"lost": "连接已断开,正在重试…",
|
||||
"lastShown": "显示最近收到的成绩。",
|
||||
"rules": "赛事规则",
|
||||
"r1t": "仅限注册车手。",
|
||||
"r1": "访客不计入排名。",
|
||||
"r2t": "按记录计时。",
|
||||
"r2": "处罚由游戏服务器执行;显示的是其上报的时间。",
|
||||
"r3t": "每位车手一个名次。",
|
||||
"r3": "取所有赛事服务器中的最佳圈速。",
|
||||
"r4t": "审核。",
|
||||
"r4": "工作人员可在审核后排除车手。",
|
||||
"status": {
|
||||
"qualifying": "排位赛",
|
||||
"live": "直播赛事",
|
||||
"upcoming": "即将开始",
|
||||
"finished": "已结束"
|
||||
},
|
||||
"errors": {
|
||||
"notFound": "此赛事不可用。",
|
||||
"rateLimited": "请求过多,稍后重试。",
|
||||
"unavailable": "赛事成绩暂不可用。",
|
||||
"timeout": "连接超时,正在自动重试。"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,27 @@ const baseRoutes = [
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
path: 'events',
|
||||
name: 'Events',
|
||||
component: () => import('@/views/events/EventList.vue'),
|
||||
meta: {
|
||||
title: 'Events - BeamMP',
|
||||
description: 'Live standings for BeamMP events',
|
||||
requiresAuth: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'events/:eventId',
|
||||
name: 'EventDetail',
|
||||
component: () => import('@/views/events/EventDetail.vue'),
|
||||
meta: {
|
||||
title: 'Event standings - BeamMP',
|
||||
description: 'Live standings for a BeamMP event',
|
||||
requiresAuth: false,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
path: 'privacy',
|
||||
name: 'Privacy',
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { bannerSrc, formatLap, formatWhen, useEventsFeed, useEventText } from './helpers'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { status, errorText } = useEventText()
|
||||
const route = useRoute()
|
||||
const locale = computed(() => route.params.locale || 'en')
|
||||
const eventId = computed(() => String(route.params.eventId || ''))
|
||||
const search = ref('')
|
||||
|
||||
const { data, error, connected, restart } = useEventsFeed(
|
||||
() => `/v1/events/${encodeURIComponent(eventId.value)}/leaderboard?mode=top&limit=100`
|
||||
)
|
||||
watch(eventId, () => {
|
||||
search.value = ''
|
||||
restart()
|
||||
})
|
||||
|
||||
const event = computed(() => data.value?.event)
|
||||
const topRows = computed(() =>
|
||||
(data.value?.rows ?? []).slice(0, event.value?.leaderboardSize ?? 100)
|
||||
)
|
||||
const rows = computed(() =>
|
||||
topRows.value.filter((r) => r.name.toLowerCase().includes(search.value.toLowerCase()))
|
||||
)
|
||||
const cutoff = computed(() => topRows.value.find((r) => r.rank === event.value?.leaderboardSize))
|
||||
const servers = computed(() => data.value?.servers ?? [])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="max-w-6xl mx-auto px-4 py-10">
|
||||
<RouterLink
|
||||
:to="`/${locale}/events`"
|
||||
class="text-sm text-neutral-600 dark:text-neutral-300 hover:text-orange-600"
|
||||
>{{ t('message.events.back') }}</RouterLink
|
||||
>
|
||||
|
||||
<p v-if="error" class="mt-4 text-sm text-red-600" role="status">
|
||||
{{ errorText(error) }}
|
||||
<span v-if="data">{{ t('message.events.lastShown') }}</span>
|
||||
</p>
|
||||
|
||||
<div v-if="!event && !error" class="py-16 text-center text-neutral-600 dark:text-neutral-300">
|
||||
{{ t('message.events.loadingEvent') }}
|
||||
</div>
|
||||
|
||||
<template v-if="event">
|
||||
<div
|
||||
:class="[
|
||||
'mt-4 mb-8',
|
||||
event.bannerVersion
|
||||
? 'relative overflow-hidden rounded-xl bg-neutral-900 px-6 py-10 sm:px-10 sm:py-16'
|
||||
: '',
|
||||
]"
|
||||
>
|
||||
<template v-if="event.bannerVersion">
|
||||
<img
|
||||
:src="bannerSrc(event, 'hero')"
|
||||
alt=""
|
||||
class="absolute inset-0 h-full w-full object-cover"
|
||||
/>
|
||||
<div
|
||||
class="absolute inset-0 bg-gradient-to-r from-black/85 via-black/60 to-black/20"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</template>
|
||||
<div class="relative">
|
||||
<div
|
||||
class="text-xs uppercase tracking-wide text-orange-600 dark:text-orange-400 font-semibold"
|
||||
>
|
||||
{{ status(event.status) }} · {{ t('message.events.standings') }}
|
||||
</div>
|
||||
<h1
|
||||
:class="[
|
||||
'mt-1 text-4xl font-extrabold tracking-tight',
|
||||
event.bannerVersion ? 'text-white' : 'text-neutral-900 dark:text-white',
|
||||
]"
|
||||
>
|
||||
{{ event.title }}
|
||||
</h1>
|
||||
<p
|
||||
:class="[
|
||||
'mt-3 max-w-2xl',
|
||||
event.bannerVersion ? 'text-white/85' : 'text-neutral-600 dark:text-neutral-300',
|
||||
]"
|
||||
>
|
||||
{{ event.subtitle }}
|
||||
<span v-if="event.subtitle">·</span>
|
||||
{{ t('message.events.topDrivers', { count: event.leaderboardSize }) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
|
||||
<div
|
||||
class="rounded-lg border border-neutral-200 dark:border-neutral-800 p-4 bg-white/70 dark:bg-neutral-900/60"
|
||||
>
|
||||
<div class="text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400">
|
||||
{{ t('message.events.statDrivers') }}
|
||||
</div>
|
||||
<div class="mt-1 text-3xl font-semibold">{{ event.stats.players.toLocaleString() }}</div>
|
||||
</div>
|
||||
<div
|
||||
class="rounded-lg border border-neutral-200 dark:border-neutral-800 p-4 bg-white/70 dark:bg-neutral-900/60"
|
||||
>
|
||||
<div class="text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400">
|
||||
{{ t('message.events.statLaps') }}
|
||||
</div>
|
||||
<div class="mt-1 text-3xl font-semibold">{{ event.stats.laps.toLocaleString() }}</div>
|
||||
</div>
|
||||
<div
|
||||
class="rounded-lg border border-neutral-200 dark:border-neutral-800 p-4 bg-white/70 dark:bg-neutral-900/60"
|
||||
>
|
||||
<div class="text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400">
|
||||
Servers
|
||||
</div>
|
||||
<div class="mt-1 text-3xl font-semibold">{{ servers.length }}</div>
|
||||
</div>
|
||||
<div
|
||||
class="rounded-lg border border-neutral-200 dark:border-neutral-800 p-4 bg-white/70 dark:bg-neutral-900/60"
|
||||
>
|
||||
<div class="text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400">
|
||||
{{ t('message.events.statPlace', { count: event.leaderboardSize }) }}
|
||||
</div>
|
||||
<div class="mt-1 text-2xl sm:text-3xl font-semibold tabular-nums">
|
||||
{{ cutoff ? formatLap(cutoff.time) : '—' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-6 lg:grid-cols-[1fr_18rem]">
|
||||
<div
|
||||
class="rounded-lg border border-neutral-200 dark:border-neutral-800 bg-white/70 dark:bg-neutral-900/60 overflow-hidden"
|
||||
>
|
||||
<div
|
||||
class="flex items-center justify-between gap-3 p-4 border-b border-neutral-200 dark:border-neutral-800"
|
||||
>
|
||||
<h2 class="font-semibold">{{ t('message.events.standingsTitle') }}</h2>
|
||||
<input
|
||||
v-model="search"
|
||||
type="search"
|
||||
:aria-label="t('message.events.search')"
|
||||
:placeholder="t('message.events.search')"
|
||||
class="w-48 rounded-md border border-neutral-300 dark:border-neutral-700 bg-transparent px-3 py-1.5 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead
|
||||
class="text-left text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400"
|
||||
>
|
||||
<tr>
|
||||
<th scope="col" class="px-4 py-2">{{ t('message.events.pos') }}</th>
|
||||
<th scope="col" class="px-4 py-2">{{ t('message.events.driver') }}</th>
|
||||
<th scope="col" class="px-4 py-2">{{ t('message.events.bestLap') }}</th>
|
||||
<th scope="col" class="px-4 py-2">{{ t('message.events.gap') }}</th>
|
||||
<th scope="col" class="px-4 py-2">{{ t('message.events.pen') }}</th>
|
||||
<th scope="col" class="px-4 py-2 hidden sm:table-cell">
|
||||
{{ t('message.events.server') }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="tabular-nums">
|
||||
<tr
|
||||
v-for="row in rows"
|
||||
:key="row.identityKey"
|
||||
class="border-t border-neutral-200 dark:border-neutral-800"
|
||||
>
|
||||
<td class="px-4 py-2 font-semibold">{{ String(row.rank).padStart(2, '0') }}</td>
|
||||
<td class="px-4 py-2">{{ row.name }}</td>
|
||||
<td class="px-4 py-2">{{ formatLap(row.time) }}</td>
|
||||
<td class="px-4 py-2 text-neutral-500 dark:text-neutral-400">
|
||||
{{ row.rank === 1 ? t('message.events.leader') : '+' + row.gap.toFixed(3) }}
|
||||
</td>
|
||||
<td class="px-4 py-2">{{ row.penalties }}</td>
|
||||
<td class="px-4 py-2 hidden sm:table-cell text-neutral-500 dark:text-neutral-400">
|
||||
{{ row.server }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p v-if="!rows.length" class="p-6 text-center text-neutral-600 dark:text-neutral-300">
|
||||
{{ topRows.length ? t('message.events.noMatch') : t('message.events.waiting') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<aside class="space-y-6">
|
||||
<div
|
||||
class="rounded-lg border border-neutral-200 dark:border-neutral-800 p-4 bg-white/70 dark:bg-neutral-900/60"
|
||||
>
|
||||
<h2 class="font-semibold">{{ t('message.events.sources') }}</h2>
|
||||
<ul class="mt-3 space-y-2 text-sm">
|
||||
<li v-for="s in servers" :key="s.id">
|
||||
{{ s.name }}
|
||||
<div class="text-xs text-neutral-500 dark:text-neutral-400">
|
||||
{{
|
||||
t('message.events.lastResult', {
|
||||
when: formatWhen(s.lastEventAt) || t('message.events.none'),
|
||||
})
|
||||
}}
|
||||
</div>
|
||||
</li>
|
||||
<li v-if="!servers.length" class="text-neutral-500">
|
||||
{{ t('message.events.noServers') }}
|
||||
</li>
|
||||
</ul>
|
||||
<p class="mt-3 text-xs text-neutral-500 dark:text-neutral-400">
|
||||
{{ connected ? t('message.events.live') : t('message.events.lost') }}
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
class="rounded-lg border border-neutral-200 dark:border-neutral-800 p-4 bg-white/70 dark:bg-neutral-900/60 text-sm space-y-3"
|
||||
>
|
||||
<h2 class="font-semibold">{{ t('message.events.rules') }}</h2>
|
||||
<p>
|
||||
<b>{{ t('message.events.r1t') }}</b> {{ t('message.events.r1') }}
|
||||
</p>
|
||||
<p>
|
||||
<b>{{ t('message.events.r2t') }}</b> {{ t('message.events.r2') }}
|
||||
</p>
|
||||
<p>
|
||||
<b>{{ t('message.events.r3t') }}</b> {{ t('message.events.r3') }}
|
||||
</p>
|
||||
<p>
|
||||
<b>{{ t('message.events.r4t') }}</b> {{ t('message.events.r4') }}
|
||||
</p>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,114 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { bannerSrc, useEventsFeed, useEventText } from './helpers'
|
||||
|
||||
const { status, errorText } = useEventText()
|
||||
const route = useRoute()
|
||||
const locale = computed(() => route.params.locale || 'en')
|
||||
const { data, error, connected } = useEventsFeed(() => '/v1/events', { intervalMs: 5000 })
|
||||
const events = computed(() => data.value?.events ?? [])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="max-w-6xl mx-auto px-4 py-10">
|
||||
<div class="mb-8">
|
||||
<h1 class="text-4xl font-extrabold tracking-tight text-neutral-900 dark:text-white">
|
||||
{{ $t('message.events.title') }}
|
||||
</h1>
|
||||
<p class="mt-3 text-neutral-600 dark:text-neutral-300 max-w-2xl">
|
||||
{{ $t('message.events.description') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p v-if="error" class="mb-6 text-sm text-red-600" role="status">
|
||||
{{ errorText(error) }}
|
||||
</p>
|
||||
|
||||
<div v-if="!data && !error" class="py-16 text-center text-neutral-600 dark:text-neutral-300">
|
||||
{{ $t('message.events.loading') }}
|
||||
</div>
|
||||
|
||||
<div v-else class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<RouterLink
|
||||
v-for="event in events"
|
||||
:key="event.id"
|
||||
:to="`/${locale}/events/${event.id}`"
|
||||
:class="[
|
||||
'group relative overflow-hidden rounded-lg border border-neutral-200 dark:border-neutral-800 p-5 hover:border-orange-500 transition-colors',
|
||||
event.bannerVersion
|
||||
? 'bg-neutral-900 min-h-[13rem]'
|
||||
: 'bg-white/70 dark:bg-neutral-900/60',
|
||||
]"
|
||||
>
|
||||
<template v-if="event.bannerVersion">
|
||||
<img
|
||||
:src="bannerSrc(event, 'card')"
|
||||
alt=""
|
||||
loading="lazy"
|
||||
class="absolute inset-0 h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
|
||||
/>
|
||||
<div
|
||||
class="absolute inset-0 bg-gradient-to-t from-black/90 via-black/55 to-black/25"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</template>
|
||||
<div class="relative flex h-full flex-col">
|
||||
<div class="flex items-center justify-between text-xs uppercase tracking-wide">
|
||||
<span class="text-orange-600 dark:text-orange-400 font-semibold">{{
|
||||
status(event.status)
|
||||
}}</span>
|
||||
<span
|
||||
v-if="event.partner === 'moza'"
|
||||
:class="
|
||||
event.bannerVersion ? 'text-white/80' : 'text-neutral-500 dark:text-neutral-400'
|
||||
"
|
||||
>MOZA × BeamMP</span
|
||||
>
|
||||
</div>
|
||||
<h2
|
||||
:class="[
|
||||
'mt-3 text-xl font-semibold',
|
||||
event.bannerVersion ? 'text-white' : 'text-neutral-900 dark:text-white',
|
||||
]"
|
||||
>
|
||||
{{ event.title }}
|
||||
</h2>
|
||||
<p
|
||||
v-if="event.subtitle"
|
||||
:class="[
|
||||
'mt-1 text-sm',
|
||||
event.bannerVersion ? 'text-white/85' : 'text-neutral-600 dark:text-neutral-300',
|
||||
]"
|
||||
>
|
||||
{{ event.subtitle }}
|
||||
</p>
|
||||
<div
|
||||
:class="[
|
||||
'mt-4 flex gap-4 text-sm',
|
||||
event.bannerVersion ? 'text-white/85' : 'text-neutral-600 dark:text-neutral-300',
|
||||
]"
|
||||
>
|
||||
<span>{{ $t('message.events.ranked', { count: event.stats.players }) }}</span>
|
||||
<span>{{ $t('message.events.servers', { count: event.serverCount }) }}</span>
|
||||
</div>
|
||||
<div
|
||||
:class="[
|
||||
'mt-4 text-sm font-medium group-hover:text-orange-500',
|
||||
event.bannerVersion ? 'text-white' : 'text-neutral-900 dark:text-white',
|
||||
]"
|
||||
>
|
||||
{{ $t('message.events.viewTop', { count: event.leaderboardSize }) }}
|
||||
</div>
|
||||
</div>
|
||||
</RouterLink>
|
||||
</div>
|
||||
|
||||
<p
|
||||
v-if="data && !events.length && connected"
|
||||
class="py-16 text-center text-neutral-600 dark:text-neutral-300"
|
||||
>
|
||||
{{ $t('message.events.empty') }}
|
||||
</p>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,104 @@
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { API_BASE } from '@/lib/config'
|
||||
|
||||
/** Seconds to m:ss.mmm, as shown on the boards. */
|
||||
export function formatLap(value) {
|
||||
const ms = Math.round(value * 1000)
|
||||
return `${Math.floor(ms / 60000)}:${String(Math.floor(ms / 1000) % 60).padStart(2, '0')}.${String(ms % 1000).padStart(3, '0')}`
|
||||
}
|
||||
|
||||
export function formatWhen(value) {
|
||||
return value
|
||||
? new Date(value)
|
||||
.toISOString()
|
||||
.replace('T', ' ')
|
||||
.replace(/\.\d+Z$/, ' UTC')
|
||||
: null
|
||||
}
|
||||
|
||||
/**
|
||||
* Polls one public events path and keeps the last good result on screen if a refresh fails.
|
||||
* The path (/v1/events/...) is served by the main API at API_BASE, which holds the read key, so no key
|
||||
* ever reaches the browser.
|
||||
*/
|
||||
export function useEventsFeed(pathGetter, { intervalMs = 2000 } = {}) {
|
||||
const data = ref(null)
|
||||
const error = ref('')
|
||||
const connected = ref(false)
|
||||
let timer
|
||||
let controller
|
||||
let generation = 0
|
||||
let stopped = false
|
||||
|
||||
async function refresh() {
|
||||
const token = ++generation
|
||||
controller?.abort()
|
||||
const mine = new window.AbortController()
|
||||
controller = mine
|
||||
const timeout = window.setTimeout(() => mine.abort(), 7000)
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}${pathGetter()}`, {
|
||||
cache: 'no-store',
|
||||
signal: mine.signal,
|
||||
})
|
||||
if (!res.ok) {
|
||||
throw new Error(
|
||||
res.status === 404 ? 'notFound' : res.status === 429 ? 'rateLimited' : 'unavailable'
|
||||
)
|
||||
}
|
||||
const json = await res.json()
|
||||
if (token !== generation || stopped) return
|
||||
data.value = json
|
||||
error.value = ''
|
||||
connected.value = true
|
||||
} catch (failure) {
|
||||
if (token !== generation || stopped) return
|
||||
connected.value = false
|
||||
error.value = failure.name === 'AbortError' ? 'timeout' : failure.message
|
||||
} finally {
|
||||
window.clearTimeout(timeout)
|
||||
if (token === generation && !stopped) timer = window.setTimeout(refresh, intervalMs)
|
||||
}
|
||||
}
|
||||
|
||||
function restart() {
|
||||
window.clearTimeout(timer)
|
||||
data.value = null
|
||||
refresh()
|
||||
}
|
||||
|
||||
onMounted(refresh)
|
||||
onBeforeUnmount(() => {
|
||||
stopped = true
|
||||
window.clearTimeout(timer)
|
||||
controller?.abort()
|
||||
})
|
||||
return { data, error, connected, restart }
|
||||
}
|
||||
|
||||
/** Translated status and error text. The keys are written out so the locale check can see them. */
|
||||
export function useEventText() {
|
||||
const { t } = useI18n()
|
||||
const status = (value) =>
|
||||
({
|
||||
qualifying: t('message.events.status.qualifying'),
|
||||
live: t('message.events.status.live'),
|
||||
upcoming: t('message.events.status.upcoming'),
|
||||
finished: t('message.events.status.finished'),
|
||||
})[value] ?? value
|
||||
const errorText = (code) =>
|
||||
({
|
||||
notFound: t('message.events.errors.notFound'),
|
||||
rateLimited: t('message.events.errors.rateLimited'),
|
||||
timeout: t('message.events.errors.timeout'),
|
||||
})[code] ?? t('message.events.errors.unavailable')
|
||||
return { status, errorText }
|
||||
}
|
||||
|
||||
/** Address of an event's banner image, or null when it has none. Images are served by the main API. */
|
||||
export function bannerSrc(event, size) {
|
||||
const version = event?.bannerVersion
|
||||
if (!version) return null
|
||||
return `${API_BASE}/v1/event-banners/${encodeURIComponent(event.id)}/${encodeURIComponent(version)}/${size}`
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, test } from 'vitest'
|
||||
import { bannerSrc, formatLap } from '@/views/events/helpers'
|
||||
|
||||
describe('event helpers', () => {
|
||||
test('banner address is built on the main API from the event id and version', () => {
|
||||
const version = 'a'.repeat(32)
|
||||
expect(bannerSrc({ id: 'hirochi', bannerVersion: version }, 'card')).toMatch(
|
||||
new RegExp(`/v1/event-banners/hirochi/${version}/card$`)
|
||||
)
|
||||
expect(bannerSrc({ id: 'a/b', bannerVersion: 'v 1' }, 'hero')).toMatch(/\/a%2Fb\/v%201\/hero$/)
|
||||
})
|
||||
test('an event without a banner has no address', () => {
|
||||
expect(bannerSrc({ id: 'x', bannerVersion: null }, 'card')).toBeNull()
|
||||
expect(bannerSrc({ id: 'x' }, 'hero')).toBeNull()
|
||||
expect(bannerSrc(undefined, 'hero')).toBeNull()
|
||||
})
|
||||
test('lap times are shown as m:ss.mmm', () => {
|
||||
expect(formatLap(80.122)).toBe('1:20.122')
|
||||
expect(formatLap(59.9996)).toBe('1:00.000')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user