diff --git a/server/app/api/controller/MatchController.php b/server/app/api/controller/MatchController.php
index 5222914..b1e73a3 100644
--- a/server/app/api/controller/MatchController.php
+++ b/server/app/api/controller/MatchController.php
@@ -281,7 +281,7 @@ class MatchController extends BaseApiController
return $this->fail('赛事不存在');
}
$data = $match->toArray();
- $data['live_list'] = MatchLiveService::getLiveListForApi((int) $data['id']);
+ $data['live_list'] = MatchLiveService::getMatchedLiveListForApi($data);
if (empty($data['live_url']) && !empty($data['live_list'][0]['source_url'])) {
$data['live_url'] = (string) $data['live_list'][0]['source_url'];
}
diff --git a/server/app/common/service/match/MatchLiveService.php b/server/app/common/service/match/MatchLiveService.php
index 77bc2bf..cd67634 100644
--- a/server/app/common/service/match/MatchLiveService.php
+++ b/server/app/common/service/match/MatchLiveService.php
@@ -28,6 +28,47 @@ class MatchLiveService
return $liveMap[$matchId] ?? [];
}
+ /**
+ * 获取赛事可用的直播间:优先返回已绑定赛事,未绑定的房间则按标题中的主客队名称补充匹配。
+ */
+ public static function getMatchedLiveListForApi(array $match): array
+ {
+ $matchId = (int) ($match['id'] ?? 0);
+ $liveList = $matchId > 0 ? self::getLiveListForApi($matchId) : [];
+ $knownLiveIds = array_flip(array_filter(array_map(
+ static fn(array $item): int => (int) ($item['id'] ?? 0),
+ $liveList
+ )));
+
+ $homeTeam = trim((string) ($match['home_team'] ?? ''));
+ $awayTeam = trim((string) ($match['away_team'] ?? ''));
+ if ($homeTeam === '' || $awayTeam === '') {
+ return $liveList;
+ }
+
+ $homeKeyword = '%' . addcslashes($homeTeam, '\\%_') . '%';
+ $awayKeyword = '%' . addcslashes($awayTeam, '\\%_') . '%';
+ $matchedRows = MatchLive::where('fetch_status', 1)
+ ->whereNull('delete_time')
+ ->where('title', 'like', $homeKeyword)
+ ->where('title', 'like', $awayKeyword)
+ ->order('create_time', 'asc')
+ ->order('id', 'asc')
+ ->select()
+ ->toArray();
+
+ foreach ($matchedRows as $row) {
+ $liveId = (int) ($row['id'] ?? 0);
+ if ($liveId <= 0 || isset($knownLiveIds[$liveId])) {
+ continue;
+ }
+ $liveList[] = self::decorateLiveRow($row);
+ $knownLiveIds[$liveId] = true;
+ }
+
+ return $liveList;
+ }
+
public static function getLiveMapForApi(array $matchIds): array
{
$matchIds = array_values(array_unique(array_filter(array_map('intval', $matchIds))));
@@ -44,8 +85,7 @@ class MatchLiveService
$result = [];
foreach ($rows as &$row) {
- $row['stream_options'] = self::buildStreamOptions($row);
- $row['default_play_url'] = self::resolveDefaultPlayUrl($row);
+ $row = self::decorateLiveRow($row);
$matchId = (int) ($row['match_id'] ?? 0);
if ($matchId <= 0) {
continue;
@@ -57,6 +97,14 @@ class MatchLiveService
return $result;
}
+ protected static function decorateLiveRow(array $row): array
+ {
+ $row['stream_options'] = self::buildStreamOptions($row);
+ $row['default_play_url'] = self::resolveDefaultPlayUrl($row);
+
+ return $row;
+ }
+
public static function buildStreamOptions(array $row): array
{
$definitions = [
diff --git a/uniapp/src/api/match.ts b/uniapp/src/api/match.ts
index ba746cb..a14bd9a 100644
--- a/uniapp/src/api/match.ts
+++ b/uniapp/src/api/match.ts
@@ -36,6 +36,11 @@ export interface MatchLiveLineItem {
update_time?: string | number
updated_at?: string | number
source_url?: string
+ anchor_name?: string
+ anchor_avatar?: string
+ room_view_count?: string | number
+ room_focus_count?: string | number
+ room_notice?: string
default_play_url?: string
play_url_m3u8?: string
play_url_hd_m3u8?: string
diff --git a/uniapp/src/components/match-detail-header/match-detail-header.vue b/uniapp/src/components/match-detail-header/match-detail-header.vue
index 60bbddc..f98b9d7 100644
--- a/uniapp/src/components/match-detail-header/match-detail-header.vue
+++ b/uniapp/src/components/match-detail-header/match-detail-header.vue
@@ -6,7 +6,7 @@