feat(player): 完善 H5 投注端与 API 演示数据
- 球赛/串关/优胜冠军、赛事详情、历史投注与个人资料编辑 - 固定顶栏、公告与底栏,仅内容区滚动 - 底部导航与站点 favicon 使用 logo,登录页精简 - API 种子、冠军盘与历史注单增强 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
35
apps/player/src/composables/useAnnouncements.ts
Normal file
35
apps/player/src/composables/useAnnouncements.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { ref } from 'vue';
|
||||
import api from '../api';
|
||||
import { resolveAnnouncements } from '../constants/defaultAnnouncement';
|
||||
|
||||
function collectAnnouncementLines(data: {
|
||||
ticker?: Array<{ translation?: { title?: string; body?: string } }>;
|
||||
notices?: Array<{ translation?: { title?: string; body?: string } }>;
|
||||
} | null): string[] {
|
||||
const lines: string[] = [];
|
||||
if (!data) return lines;
|
||||
for (const item of data.ticker ?? []) {
|
||||
const text = item.translation?.body || item.translation?.title;
|
||||
if (text) lines.push(text);
|
||||
}
|
||||
for (const item of data.notices ?? []) {
|
||||
const text = item.translation?.title || item.translation?.body;
|
||||
if (text) lines.push(text);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
export function useAnnouncements() {
|
||||
const items = ref<string[]>(resolveAnnouncements([]));
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
const { data } = await api.get('/player/home');
|
||||
items.value = resolveAnnouncements(collectAnnouncementLines(data.data));
|
||||
} catch {
|
||||
items.value = resolveAnnouncements([]);
|
||||
}
|
||||
}
|
||||
|
||||
return { items, load };
|
||||
}
|
||||
Reference in New Issue
Block a user