直播弹幕与界面优化

- useLiveDanmaku: 重写协议解析,支持 zlib 压缩消息、token 认证、base64 帧处理
- services/bilibili: 新增 getLiveDanmakuInfo 获取弹幕服务器信息
- live/[roomId]: 使用真实 roomid 而非 URL 别名连接弹幕
- NativeVideoPlayer: 增加中文注释,移除调试日志
- video/[bvid]: UP主头像移至标题前,调整字号与样式
- index: 替换 logo 文字为下载按钮图标
- videoRows: 修复奇数视频配对,调整 BigRow 位置策略
- package.json: 移除未使用的 fast-xml-parser 和 xml2js 依赖
This commit is contained in:
Developer
2026-03-17 15:14:23 +08:00
parent a46e63f0ba
commit 6275fd0930
8 changed files with 316 additions and 155 deletions

View File

@@ -337,6 +337,18 @@ export async function searchVideos(keyword: string, page = 1): Promise<VideoItem
} as VideoItem));
}
export async function getLiveDanmakuInfo(roomId: number): Promise<{ token: string; host: string }> {
const res = await api.get(`${LIVE_BASE}/room/v1/Danmu/getConf`, {
params: { room_id: roomId, platform: 'h5' },
});
const data = res.data.data;
const hostInfo = data?.host_server_list?.[0];
const host = hostInfo
? `wss://${hostInfo.host}:${hostInfo.wss_port}/sub`
: 'wss://broadcastlv.chat.bilibili.com/sub';
return { token: data?.token ?? '', host };
}
export async function getDanmaku(cid: number): Promise<DanmakuItem[]> {
try {
if (isWeb) {
@@ -354,7 +366,7 @@ export async function getDanmaku(cid: number): Promise<DanmakuItem[]> {
responseType: 'arraybuffer',
});
const bytes = new Uint8Array(res.data as ArrayBuffer);
const bytes = new Uint8Array(res.data as ArrayBuffer);
let xmlText: string | undefined;
// 依次尝试inflate (gzip/zlib) → inflateRaw (raw deflate)