diff --git a/app/index.tsx b/app/index.tsx index e13b3a7..767631c 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -39,6 +39,7 @@ import { type LiveRow, } from "../utils/videoRows"; import { BigVideoCard } from "../components/BigVideoCard"; +import { FollowedLiveStrip } from "../components/FollowedLiveStrip"; import type { LiveRoom } from "../services/types"; const HEADER_H = 44; @@ -339,33 +340,36 @@ export default function HomeScreen() { }} renderItem={renderLiveItem} ListHeaderComponent={ - - {LIVE_AREAS.map((area) => ( - handleLiveAreaPress(area.id)} - activeOpacity={0.7} - > - + + + {LIVE_AREAS.map((area) => ( + handleLiveAreaPress(area.id)} + activeOpacity={0.7} > - {area.name} - - - ))} - + + {area.name} + + + ))} + + } refreshControl={ ([]); + const router = useRouter(); + + useEffect(() => { + if (!sessdata) return; + getFollowedLiveRooms().then(setRooms).catch(() => {}); + }, [sessdata]); + + if (!sessdata || rooms.length === 0) return null; + + return ( + + 我关注的直播 + + {rooms.map((room) => ( + router.push(`/live/${room.roomid}` as any)} + activeOpacity={0.7} + > + + + + + + {room.uname.length > 5 ? room.uname.slice(0, 5) : room.uname} + + + ))} + + + ); +} + +const styles = StyleSheet.create({ + container: { + backgroundColor: '#f4f4f4', + paddingHorizontal: 12, + paddingVertical: 8, + }, + title: { + fontSize: 12, + color: '#999', + marginBottom: 6, + }, + scrollContent: { + gap: 12, + alignItems: 'center', + }, + item: { + alignItems: 'center', + width: 56, + }, + pulseRow: { + height: 16, + justifyContent: 'center', + alignItems: 'center', + marginBottom: 4, + }, + avatar: { + width: 44, + height: 44, + borderRadius: 22, + backgroundColor: '#eee', + }, + name: { + fontSize: 11, + color: '#333', + marginTop: 4, + textAlign: 'center', + width: 56, + }, +}); diff --git a/services/bilibili.ts b/services/bilibili.ts index f16f139..a104f19 100644 --- a/services/bilibili.ts +++ b/services/bilibili.ts @@ -425,3 +425,21 @@ export async function getDanmaku(cid: number): Promise { return []; } } + +export async function getFollowedLiveRooms(): Promise { + const res = await api.get(`${LIVE_BASE}/xlive/web-ucenter/v1/xfetter/FeedList`, { + params: { page: 1, page_size: 10, platform: 'web' }, + }); + const list = res.data?.data?.list ?? []; + return list.map((r: any) => ({ + roomid: r.room_id, + uid: r.uid, + title: r.title, + uname: r.uname, + face: r.face, + cover: r.cover || r.keyframe || '', + online: r.online ?? 0, + area_name: r.area_v2_name ?? '', + parent_area_name: r.area_v2_parent_name ?? '', + })); +}