WPF: Refresh info for all rooms

This commit is contained in:
genteure 2022-06-04 02:34:09 +08:00
parent b253826dbc
commit fadb90f487
2 changed files with 24 additions and 0 deletions

View File

@ -73,6 +73,8 @@
<MenuItem Header="{l:Loc RoomListPage_Menu_AutoRecord}">
<MenuItem Header="{l:Loc RoomListPage_Menu_AutoRecord_EnableAll}" Click="MenuItem_EnableAutoRecAll_Click"/>
<MenuItem Header="{l:Loc RoomListPage_Menu_AutoRecord_DisableAll}" Click="MenuItem_DisableAutoRecAll_Click"/>
<Separator/>
<MenuItem Header="刷新全部房间信息" Click="MenuItem_RefreshAllRoomInfo_Click"/>
</MenuItem>
<MenuItem Header="{l:Loc RoomListPage_Menu_Links}">
<MenuItem Header="{l:Loc RoomListPage_Menu_Links_Website}" Command="{x:Static m:Commands.OpenLink}" CommandParameter="https://rec.danmuji.org/">

View File

@ -6,6 +6,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using BililiveRecorder.Core;
@ -328,6 +329,27 @@ namespace BililiveRecorder.WPF.Pages
catch (Exception)
{ }
}
private void MenuItem_RefreshAllRoomInfo_Click(object sender, RoutedEventArgs e)
{
_ = Task.Run(async () =>
{
await Task.Delay(200);
if (MessageBox.Show("录播姬会自动检测直播间状态,不需要手动刷新。\n录播姬主要通过接收B站服务器的推送来更新状态直播服务器会给录播姬实时发送开播通知延迟极低。\n\n" +
"频繁刷新直播间状态、短时间内大量请求B站直播 API 可能会导致你的 IP 被屏蔽,完全无法录播。\n\n本功能是特殊情况下确实需要刷新所有直播间信息时使用的。\n\n是否要刷新所有直播间的信息\n每个直播间会发送一个请求", "B站录播姬", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
return;
if (this.DataContext is IRecorder rec)
{
foreach (var room in rec.Rooms.ToArray())
{
await room.RefreshRoomInfoAsync();
await Task.Delay(500);
}
}
});
}
}
public enum SortedBy