Skip to content

Commit

Permalink
修复个人主页点击进入直播间按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
GD-Slime committed May 27, 2024
1 parent 79fd1df commit 8bdc79b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/BiliLite.UWP/Pages/UserInfoPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@

<AppBarButton x:Name="btnChat" Click="btnChat_Click" Label="私信" Icon="Message">
</AppBarButton>
<AppBarButton x:Name="btnLiveRoom" Click="btnLiveRoom_Click" Label="直播间" >

<AppBarButton x:Name="btnLiveRoom" Click="btnLiveRoom_Click" Visibility="{x:Bind Path=m_viewModel.HaveLiveRoom,Mode=OneWay}" Label="直播间" >
<AppBarButton.Icon>
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE960;" />
</AppBarButton.Icon>
Expand Down
3 changes: 2 additions & 1 deletion src/BiliLite.UWP/Pages/UserInfoPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public UserInfoPage()
followVM = new UserFollowVM(false);
m_userDynamicViewModel.OpenCommentEvent += UserDynamicViewModelOpenCommentEvent;
splitView.PaneClosed += SplitView_PaneClosed;
m_viewModel.LiveStreaming += (_, e) => btnLiveRoom.Label = "正在直播";
}
private void SplitView_PaneClosed(SplitView sender, object args)
{
Expand Down Expand Up @@ -189,7 +190,7 @@ private async void SubmitVideo_ItemClick(object sender, ItemClickEventArgs e)

private void btnLiveRoom_Click(object sender, RoutedEventArgs e)
{
if (m_viewModel.UserInfo == null) return;
if (!m_viewModel.HaveLiveRoom) return;
MessageCenter.NavigateToPage(this, new NavigationInfo()
{
icon = Symbol.Video,
Expand Down
9 changes: 8 additions & 1 deletion src/BiliLite.UWP/ViewModels/User/UserDetailViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,28 @@ public UserDetailViewModel(IMapper mapper)

public UserCenterInfoViewModel UserInfo { get; set; }

public bool HaveLiveRoom => UserInfo != null && UserInfo.LiveRoom != null;

public EventHandler LiveStreaming;

#endregion

#region Private Methods

private async Task GetUserInfoCore()
{
var api = await m_userDetailApi.UserInfo(Mid);
var result = await api.Request();

var result = await api.Request();
if (!result.status) throw new CustomizedErrorException(result.message);

var data = await result.GetData<UserCenterInfoModel>();
if (!data.success) throw new CustomizedErrorException(data.message);

data.data.Stat = await GetSpaceStat();
UserInfo = m_mapper.Map<UserCenterInfoViewModel>(data.data);

if (HaveLiveRoom && UserInfo.LiveRoom.LiveStatus == 1) LiveStreaming?.Invoke(this, null);
}

private async Task<UserCenterInfoStatModel> GetStatCore()
Expand Down

0 comments on commit 8bdc79b

Please sign in to comment.