From 980b019809bd36c3f7b0f2ac3e14460f9d9dadaa Mon Sep 17 00:00:00 2001 From: hajimi Date: Sun, 21 Jun 2026 17:56:21 +0800 Subject: [PATCH] deploy: auto commit repo-root changes 2026-06-21 17:56:21 --- server/app/api/controller/MatchController.php | 12 + .../common/service/match/MatchLiveService.php | 40 +- .../match-live-popup/match-live-popup.vue | 231 +++++---- .../components/WorldCupPanel.vue | 253 +++++++++- .../src/pages/match_detail/match_detail.vue | 475 ++++++++++++++++-- 5 files changed, 836 insertions(+), 175 deletions(-) diff --git a/server/app/api/controller/MatchController.php b/server/app/api/controller/MatchController.php index e0a44fc..7be6b1c 100644 --- a/server/app/api/controller/MatchController.php +++ b/server/app/api/controller/MatchController.php @@ -428,10 +428,20 @@ class MatchController extends BaseApiController ->order('id asc') ->select() ->toArray(); + $liveMap = MatchLiveService::getLiveMapForApi(array_column($rows, 'id')); $scheduleMap = []; foreach ($rows as $row) { $roundName = $row['round_name'] ?: '未分轮次'; + $liveList = $liveMap[(int) $row['id']] ?? []; + $defaultLiveUrl = ''; + foreach ($liveList as $line) { + $candidate = trim((string) ($line['default_play_url'] ?? '')); + if ($candidate !== '') { + $defaultLiveUrl = $candidate; + break; + } + } if (!isset($scheduleMap[$roundName])) { $scheduleMap[$roundName] = [ 'round_name' => $roundName, @@ -456,6 +466,8 @@ class MatchController extends BaseApiController 'match_time' => (int) $row['match_time'], 'current_minute' => $row['current_minute'], 'half_score' => $row['half_score'], + 'live_list' => $liveList, + 'default_live_url' => $defaultLiveUrl, ]; } diff --git a/server/app/common/service/match/MatchLiveService.php b/server/app/common/service/match/MatchLiveService.php index 45712bc..8e7a208 100644 --- a/server/app/common/service/match/MatchLiveService.php +++ b/server/app/common/service/match/MatchLiveService.php @@ -23,20 +23,38 @@ class MatchLiveService public static function getLiveListForApi(int $matchId): array { - $rows = MatchLive::where('match_id', $matchId) + $liveMap = self::getLiveMapForApi([$matchId]); + + return $liveMap[$matchId] ?? []; + } + + public static function getLiveMapForApi(array $matchIds): array + { + $matchIds = array_values(array_unique(array_filter(array_map('intval', $matchIds)))); + if (empty($matchIds)) { + return []; + } + + $rows = MatchLive::whereIn('match_id', $matchIds) ->whereNull('delete_time') ->order('create_time', 'asc') ->order('id', 'asc') ->select() ->toArray(); + $result = []; foreach ($rows as &$row) { $row['stream_options'] = self::buildStreamOptions($row); - $row['default_play_url'] = $row['stream_options'][0]['url'] ?? ''; + $row['default_play_url'] = self::resolveDefaultPlayUrl($row); + $matchId = (int) ($row['match_id'] ?? 0); + if ($matchId <= 0) { + continue; + } + $result[$matchId][] = $row; } unset($row); - return $rows; + return $result; } public static function buildStreamOptions(array $row): array @@ -62,4 +80,20 @@ class MatchLiveService return $options; } + + protected static function resolveDefaultPlayUrl(array $row): string + { + if (!empty($row['stream_options'][0]['url'])) { + return trim((string) $row['stream_options'][0]['url']); + } + + foreach (['play_url_m3u8', 'play_url_hd_m3u8', 'play_url_flv', 'play_url_hd_flv'] as $field) { + $url = trim((string) ($row[$field] ?? '')); + if ($url !== '') { + return $url; + } + } + + return ''; + } } diff --git a/uniapp/src/components/match-live-popup/match-live-popup.vue b/uniapp/src/components/match-live-popup/match-live-popup.vue index 2c23caa..8fb3d0d 100644 --- a/uniapp/src/components/match-live-popup/match-live-popup.vue +++ b/uniapp/src/components/match-live-popup/match-live-popup.vue @@ -2,25 +2,26 @@ - {{ lineTitle }} - {{ lineMetaText }} + {{ popupTitle }} + {{ popupDesc }} 直播线路 - + - {{ item.label }} + {{ item.title }} + {{ item.meta }} {{ item.url }} - 当前 + 当前 @@ -38,17 +39,21 @@