From e5f411dc11729b169da94423e0f670d0f799a620 Mon Sep 17 00:00:00 2001 From: Richasy Date: Tue, 28 Sep 2021 22:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=98=BE=E7=A4=BA=E5=A4=9A?= =?UTF-8?q?=E4=BD=9C=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App/Controls/App/AppTitleBar.xaml | 6 +- src/App/Controls/Player/PlayerDescriptor.xaml | 143 ++++++++++++------ .../Controls/Player/PlayerDescriptor.xaml.cs | 7 +- .../UserViewModel/UserViewModel.Properties.cs | 6 + .../Account/UserViewModel/UserViewModel.cs | 17 ++- .../PlayerViewModel.Methods.cs | 22 ++- .../PlayerViewModel.Properties.cs | 12 ++ .../Common/PlayerViewModel/PlayerViewModel.cs | 1 + 8 files changed, 157 insertions(+), 57 deletions(-) diff --git a/src/App/Controls/App/AppTitleBar.xaml b/src/App/Controls/App/AppTitleBar.xaml index d1eeda842..e4d22a793 100644 --- a/src/App/Controls/App/AppTitleBar.xaml +++ b/src/App/Controls/App/AppTitleBar.xaml @@ -82,11 +82,9 @@ - - + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/App/Controls/Player/PlayerDescriptor.xaml.cs b/src/App/Controls/Player/PlayerDescriptor.xaml.cs index 6ec8e808f..b382a74bb 100644 --- a/src/App/Controls/Player/PlayerDescriptor.xaml.cs +++ b/src/App/Controls/Player/PlayerDescriptor.xaml.cs @@ -1,5 +1,7 @@ // Copyright (c) Richasy. All rights reserved. +using Richasy.Bili.ViewModels.Uwp; +using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; namespace Richasy.Bili.App.Controls @@ -19,10 +21,11 @@ public PlayerDescriptor() private async void OnUserTappedAsync(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { - await UserView.Instance.ShowAsync(ViewModel.Publisher); + var dataContext = (sender as FrameworkElement).DataContext as UserViewModel; + await UserView.Instance.ShowAsync(dataContext); } - private async void OnFollowButtonClickAsync(object sender, Windows.UI.Xaml.RoutedEventArgs e) + private async void OnFollowButtonClickAsync(object sender, RoutedEventArgs e) { var btn = sender as Button; btn.IsEnabled = false; diff --git a/src/ViewModels/ViewModels.Uwp/Account/UserViewModel/UserViewModel.Properties.cs b/src/ViewModels/ViewModels.Uwp/Account/UserViewModel/UserViewModel.Properties.cs index c1cce6a7e..16c866ef2 100644 --- a/src/ViewModels/ViewModels.Uwp/Account/UserViewModel/UserViewModel.Properties.cs +++ b/src/ViewModels/ViewModels.Uwp/Account/UserViewModel/UserViewModel.Properties.cs @@ -81,6 +81,12 @@ public partial class UserViewModel [Reactive] public bool IsShowVideoEmpty { get; set; } + /// + /// 附加文本. + /// + [Reactive] + public string AdditionalText { get; set; } + /// /// 用户Id. /// diff --git a/src/ViewModels/ViewModels.Uwp/Account/UserViewModel/UserViewModel.cs b/src/ViewModels/ViewModels.Uwp/Account/UserViewModel/UserViewModel.cs index f610b109e..da1cf5fc9 100644 --- a/src/ViewModels/ViewModels.Uwp/Account/UserViewModel/UserViewModel.cs +++ b/src/ViewModels/ViewModels.Uwp/Account/UserViewModel/UserViewModel.cs @@ -4,6 +4,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; +using Bilibili.App.View.V1; using Richasy.Bili.Locator.Uwp; using Richasy.Bili.Models.App.Args; using Richasy.Bili.Models.BiliBili; @@ -36,7 +37,6 @@ public UserViewModel(UserSearchItem item) Level = item.Level; FollowerCount = _numberToolkit.GetCountText(item.FollowerCount); - CheckFollowButtonVisibility(); } /// @@ -52,8 +52,6 @@ public UserViewModel(RelatedUser item) { Sign = _resourceToolkit.GetLocaleString(LanguageNames.UserEmptySign); } - - CheckFollowButtonVisibility(); } /// @@ -65,6 +63,17 @@ public UserViewModel(PublisherInfo info) { } + /// + /// Initializes a new instance of the class. + /// + /// 参演人员. + public UserViewModel(Staff staff) + : this(staff.Name, staff.Face, Convert.ToInt32(staff.Mid)) + { + AdditionalText = staff.Title; + IsFollow = staff.Attention == 1; + } + /// /// Initializes a new instance of the class. /// @@ -79,6 +88,8 @@ public UserViewModel(string userName, string avatar = "", int userId = 0) { Avatar = avatar + "@60w_60h_1c_100q.jpg"; } + + CheckFollowButtonVisibility(); } /// diff --git a/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Methods.cs b/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Methods.cs index d46e45bfd..28e42819c 100644 --- a/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Methods.cs +++ b/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Methods.cs @@ -76,6 +76,7 @@ private void Reset() LiveDanmakuCollection.Clear(); FavoriteMetaCollection.Clear(); SubtitleIndexCollection.Clear(); + StaffCollection.Clear(); ReplyModuleViewModel.Instance.SetInformation(0, Models.Enums.Bili.ReplyType.None); var preferPlayerMode = _settingsToolkit.ReadLocalSetting(SettingNames.DefaultPlayerDisplayMode, PlayerDisplayMode.Default); @@ -200,8 +201,6 @@ private void InitializeVideoDetail() Title = _videoDetail.Arc.Title; Subtitle = DateTimeOffset.FromUnixTimeSeconds(_videoDetail.Arc.Pubdate).ToString("yy/MM/dd HH:mm"); Description = _videoDetail.Arc.Desc; - var author = _videoDetail.Arc.Author; - Publisher = new UserViewModel(author.Name, author.Face, Convert.ToInt32(author.Mid)); AvId = _videoDetail.Arc.Aid.ToString(); BvId = _videoDetail.Bvid; SeasonId = string.Empty; @@ -218,6 +217,24 @@ private void InitializeVideoDetail() CoverUrl = _videoDetail.Arc.Pic; ReplyModuleViewModel.Instance.SetInformation(Convert.ToInt32(_videoDetail.Arc.Aid), Models.Enums.Bili.ReplyType.Video); + if (_videoDetail.Staff.Count > 0) + { + // 联合创作. + IsShowStaff = true; + foreach (var user in _videoDetail.Staff) + { + var vm = new UserViewModel(user); + StaffCollection.Add(vm); + } + } + else + { + // 独立创作. + IsShowStaff = false; + var author = _videoDetail.Arc.Author; + Publisher = new UserViewModel(author.Name, author.Face, Convert.ToInt32(author.Mid)); + } + IsLikeChecked = _videoDetail.ReqUser.Like == 1; IsCoinChecked = _videoDetail.ReqUser.Coin == 1; IsFavoriteChecked = _videoDetail.ReqUser.Favorite == 1; @@ -674,6 +691,7 @@ private MediaPlayer InitializeMediaPlayer() private async Task InitializeUserRelationAsync() { if (AccountViewModel.Instance.Status != AccountViewModelStatus.Login || + IsShowStaff || AccountViewModel.Instance.Mid.Value == Publisher.Id) { return; diff --git a/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Properties.cs b/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Properties.cs index ef7691688..25308400f 100644 --- a/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Properties.cs +++ b/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.Properties.cs @@ -222,12 +222,24 @@ public partial class PlayerViewModel [Reactive] public UserViewModel Publisher { get; set; } + /// + /// 是否显示为参演人员列表. + /// + [Reactive] + public bool IsShowStaff { get; set; } + /// /// 音量. /// [Reactive] public double Volume { get; set; } + /// + /// 参演人员集合. + /// + [Reactive] + public ObservableCollection StaffCollection { get; set; } + /// /// 关联视频集合. /// diff --git a/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.cs b/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.cs index 82d9864d9..aab4d837d 100644 --- a/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.cs +++ b/src/ViewModels/ViewModels.Uwp/Common/PlayerViewModel/PlayerViewModel.cs @@ -40,6 +40,7 @@ public PlayerViewModel() LiveDanmakuCollection = new ObservableCollection(); FavoriteMetaCollection = new ObservableCollection(); SubtitleIndexCollection = new ObservableCollection(); + StaffCollection = new ObservableCollection(); _audioList = new List(); _videoList = new List(); _flvList = new List();