diff --git a/src/BiliLite.UWP/Models/Common/Enumerates.cs b/src/BiliLite.UWP/Models/Common/Enumerates.cs index 1a5abb62..8fa093ce 100644 --- a/src/BiliLite.UWP/Models/Common/Enumerates.cs +++ b/src/BiliLite.UWP/Models/Common/Enumerates.cs @@ -395,5 +395,10 @@ public enum MessageType /// 红包抽奖赢家 /// RedPocketLotteryWinner, + + /// + /// 高能榜变动 + /// + OnlineRankChange, } } \ No newline at end of file diff --git a/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs b/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs index 35d274c0..b4d580f2 100644 --- a/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs +++ b/src/BiliLite.UWP/Models/Common/Live/LiveMessageHandleActionsMap.cs @@ -33,6 +33,7 @@ public LiveMessageHandleActionsMap() { MessageType.WatchedChange, WatchedChange }, { MessageType.RedPocketLotteryStart, RedPocketLotteryStart}, { MessageType.RedPocketLotteryWinner, RedPocketLotteryWinner}, + { MessageType.OnlineRankChange, OnlineRankChange}, }; } @@ -210,7 +211,7 @@ private void WaringOrCutOff(LiveRoomViewModel viewModel, object message) { UserName = info.Command switch { - "WARNING" => "⛔直播间警告", + "WARNING" => "⚠️直播间警告", "CUT_OFF" => "⛔直播间切断", _ => null, }, @@ -231,5 +232,10 @@ private async void StartLive(LiveRoomViewModel viewModel, object room_Id) UserName = $"{room_Id} 直播间开始直播", }); } + + private void OnlineRankChange(LiveRoomViewModel viewModel, object message) + { + viewModel.Ranks.Where(rank => rank.RankType == "contribution-rank").ToList()?[0]?.ReloadData().RunWithoutAwait(); + } } } diff --git a/src/BiliLite.UWP/Modules/Live/LiveMessage.cs b/src/BiliLite.UWP/Modules/Live/LiveMessage.cs index 450a5c1b..48329c8c 100644 --- a/src/BiliLite.UWP/Modules/Live/LiveMessage.cs +++ b/src/BiliLite.UWP/Modules/Live/LiveMessage.cs @@ -444,12 +444,19 @@ private void ParseMessage(string jsonMessage) NewMessage?.Invoke(MessageType.WatchedChange, obj["data"]["text_large"].ToString()); } } + else if (cmd == "ONLINE_RANK_V2") + { + if (obj["data"] != null) + { + NewMessage?.Invoke(MessageType.OnlineRankChange, obj["data"]["list"].ToString()); + } + } } catch (Exception ex) { if (ex is JsonReaderException) { - logger.Error("直播解析JSON包出错", ex); + logger.Log("直播解析JSON包出错", LogType.Error ,ex); } } } diff --git a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs index 1533c664..35eb97d2 100644 --- a/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/LiveDetailPage.xaml.cs @@ -132,7 +132,7 @@ private void Timer_focus_Tick(object sender, object e) private void LiveRoomViewModelAnchorLotteryStart(object sender, LiveRoomAnchorLotteryInfoModel e) { AnchorLotteryWinnerList.Content = e.WinnerList; - m_liveRoomViewModel.ShowAnchorLotteryWinnerList = e.AwardUsers.Count > 0; + m_liveRoomViewModel.ShowAnchorLotteryWinnerList = e.AwardUsers != null && e.AwardUsers.Count > 0; } private void LiveRoomViewModelAnchorLotteryEnd(object sender, LiveRoomEndAnchorLotteryInfoModel e) diff --git a/src/BiliLite.UWP/ViewModels/Live/LiveRoomRankViewModel.cs b/src/BiliLite.UWP/ViewModels/Live/LiveRoomRankViewModel.cs index c8a58dbc..11224ecf 100644 --- a/src/BiliLite.UWP/ViewModels/Live/LiveRoomRankViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/Live/LiveRoomRankViewModel.cs @@ -60,7 +60,7 @@ public LiveRoomRankViewModel(int roomId, long uid, string title, string type) public bool CanLoadMore { get; set; } - public int Next { get; set; } = 0; + public int ReloadFlag { get; set; } = 0; #endregion @@ -137,6 +137,20 @@ public async Task LoadData() } } + public async Task ReloadData() + { + if (ReloadFlag > 5) // 大约三分钟刷新一次 + { + Items.Clear(); + Page = 1; + await LoadData(); + ReloadFlag = 0; + } else + { + ReloadFlag++; + } + } + #endregion } } \ No newline at end of file