From 4ee00b6617b7f1d0b9798b6c19d6f5b2b19b277b Mon Sep 17 00:00:00 2001 From: Richasy Date: Sat, 7 Dec 2024 16:41:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A5=E4=BD=8E=E4=BC=98=E5=85=88=E7=BA=A7?= =?UTF-8?q?=E6=B8=85=E9=99=A4=E9=9B=86=E5=90=88=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?COM=E9=94=99=E8=AF=AF=20(#938)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Desktop/BiliCopilot.UI/App.xaml | 1 - .../BiliCopilot.UI/BiliCopilot.UI.csproj | 28 ++- .../BiliCopilot.UI/BiliCopilot.UI.csproj.user | 3 - .../BiliCopilot.UI/Controls/AI/AIBody.xaml | 4 +- .../Controls/Components/AppSearchBox.xaml.cs | 2 +- .../ArticleCardControl.xaml | 12 +- .../Components/CardControl/CardControl.cs | 160 ------------------ .../Components/CardControl/CardControl.xaml | 122 ------------- .../LiveCardControl/LiveCardControl.xaml | 20 +-- .../MomentCardControl/MomentCardControl.xaml | 16 +- .../NotifyMessageCardControl.xaml | 4 +- .../SeasonCardControl/SeasonCardControl.xaml | 12 +- .../UserCardControl/UserCardControl.xaml | 4 +- .../VideoCardControl/VideoCardControl.xaml | 40 ++--- .../Moment/ComprehensiveMainBody.xaml.cs | 4 +- .../Controls/Player/UpSectionControl.xaml | 4 +- .../Controls/Popular/PopularMainBody.xaml.cs | 7 + .../WebDav/WebDavStorageItemControl.xaml | 5 +- .../PublishProfiles/win-arm64.pubxml | 5 +- .../Properties/PublishProfiles/win-x64.pubxml | 5 +- .../Properties/PublishProfiles/win-x86.pubxml | 7 +- .../AnimeTimelineViewModel.cs | 5 + .../ArticlePartitionDetailViewModel.cs | 72 ++++---- .../ArticleSearchSectionDetailViewModel.cs | 3 +- .../CommentDetailViewModel.cs | 7 +- .../CommentMainViewModel.cs | 3 +- ...mprehensiveMomentSectionDetailViewModel.cs | 14 +- .../EntertainmentIndexViewModel.cs | 21 ++- .../LiveChatSectionDetailViewModel.cs | 3 +- .../LiveHistorySectionDetailViewModel.cs | 14 +- .../LivePartitionDetailViewModel.cs | 46 ++--- .../LiveSearchSectionDetailViewModel.cs | 3 +- .../PgcSearchSectionDetailViewModel.cs | 3 +- .../UserSearchSectionDetailViewModel.cs | 3 +- .../VideoMomentSectionDetailViewModel.cs | 11 +- .../VideoSearchSectionDetailViewModel.cs | 45 +++-- .../Core/AIViewModel/AIViewModel.cs | 21 ++- .../Items/IMomentSectionDetailViewModel.cs | 2 +- .../MomentUperSectionViewModel.cs | 22 ++- .../AnimePageViewModel/AnimePageViewModel.cs | 11 +- .../ArticlePartitionPageViewModel.cs | 13 +- .../CinemaPageViewModel.cs | 11 +- .../FansPageViewModel/FansPageViewModel.cs | 10 +- .../FavoritesPageViewModel.cs | 10 +- .../FollowsPageViewModel.cs | 48 +++--- .../HistoryPageViewModel.cs | 3 +- .../LivePartitionPageViewModel.cs | 49 +++--- .../MomentPageViewModel.cs | 6 +- .../PopularPageViewModel.cs | 32 ++-- src/Directory.Packages.props | 16 +- src/Libs/WinUI.Share | 2 +- 51 files changed, 391 insertions(+), 583 deletions(-) delete mode 100644 src/Desktop/BiliCopilot.UI/Controls/Components/CardControl/CardControl.cs delete mode 100644 src/Desktop/BiliCopilot.UI/Controls/Components/CardControl/CardControl.xaml diff --git a/src/Desktop/BiliCopilot.UI/App.xaml b/src/Desktop/BiliCopilot.UI/App.xaml index 3928ec4f..8863ac4d 100644 --- a/src/Desktop/BiliCopilot.UI/App.xaml +++ b/src/Desktop/BiliCopilot.UI/App.xaml @@ -13,7 +13,6 @@ - diff --git a/src/Desktop/BiliCopilot.UI/BiliCopilot.UI.csproj b/src/Desktop/BiliCopilot.UI/BiliCopilot.UI.csproj index 345103ad..0b3aa76b 100644 --- a/src/Desktop/BiliCopilot.UI/BiliCopilot.UI.csproj +++ b/src/Desktop/BiliCopilot.UI/BiliCopilot.UI.csproj @@ -3,20 +3,17 @@ WinExe net9.0-windows10.0.22621.0 10.0.19041.0 - 10.0.22621.38 BiliCopilot.UI app.manifest x86;x64;ARM64 - win-x86;win-x64;win-arm64 - win10-x86;win10-x64;win10-arm64 + win-x86;win-x64;win-arm64 win-$(Platform).pubxml true true enable zh-CN $(NoWarn);CS1591;NU1903;NU1902;IL2059;NU1900;MVVMTK0046;MVVMTK0045;MVVMTK0047;MVVMTK0048 - Debug;Release;Publish - Assets\logo.ico + false False @@ -219,9 +216,7 @@ - - @@ -396,6 +391,7 @@ + @@ -419,10 +415,6 @@ - - $(DefaultXamlRuntime) - Designer - MSBuild:Compile @@ -632,11 +624,6 @@ MSBuild:Compile - - - MSBuild:Compile - - MSBuild:Compile @@ -1572,4 +1559,13 @@ MSBuild:Compile + + + + False + True + False + False + Assets\logo.ico + \ No newline at end of file diff --git a/src/Desktop/BiliCopilot.UI/BiliCopilot.UI.csproj.user b/src/Desktop/BiliCopilot.UI/BiliCopilot.UI.csproj.user index 3db4039a..6480ad1b 100644 --- a/src/Desktop/BiliCopilot.UI/BiliCopilot.UI.csproj.user +++ b/src/Desktop/BiliCopilot.UI/BiliCopilot.UI.csproj.user @@ -633,9 +633,6 @@ Designer - - Designer - Designer diff --git a/src/Desktop/BiliCopilot.UI/Controls/AI/AIBody.xaml b/src/Desktop/BiliCopilot.UI/Controls/AI/AIBody.xaml index 87fa016d..d7265dec 100644 --- a/src/Desktop/BiliCopilot.UI/Controls/AI/AIBody.xaml +++ b/src/Desktop/BiliCopilot.UI/Controls/AI/AIBody.xaml @@ -15,7 +15,7 @@ - + @@ -40,7 +40,7 @@ TextWrapping="Wrap" /> - + diff --git a/src/Desktop/BiliCopilot.UI/Controls/Components/AppSearchBox.xaml.cs b/src/Desktop/BiliCopilot.UI/Controls/Components/AppSearchBox.xaml.cs index a02919d8..b51911c3 100644 --- a/src/Desktop/BiliCopilot.UI/Controls/Components/AppSearchBox.xaml.cs +++ b/src/Desktop/BiliCopilot.UI/Controls/Components/AppSearchBox.xaml.cs @@ -66,7 +66,7 @@ private void OnQuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmitte } ViewModel.TryCancelSuggestCommand.Execute(default); - ViewModel.Suggestion.Clear(); + DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Low, ViewModel.Suggestion.Clear); } } diff --git a/src/Desktop/BiliCopilot.UI/Controls/Components/ArticleCardControl/ArticleCardControl.xaml b/src/Desktop/BiliCopilot.UI/Controls/Components/ArticleCardControl/ArticleCardControl.xaml index e0dbb63c..79927acf 100644 --- a/src/Desktop/BiliCopilot.UI/Controls/Components/ArticleCardControl/ArticleCardControl.xaml +++ b/src/Desktop/BiliCopilot.UI/Controls/Components/ArticleCardControl/ArticleCardControl.xaml @@ -11,7 +11,7 @@ - + @@ -75,7 +75,7 @@ Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Title}" /> - + @@ -85,7 +85,7 @@ - + @@ -138,7 +138,7 @@ Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Title}" /> - + @@ -148,7 +148,7 @@ - + @@ -181,7 +181,7 @@ - + diff --git a/src/Desktop/BiliCopilot.UI/Controls/Components/CardControl/CardControl.cs b/src/Desktop/BiliCopilot.UI/Controls/Components/CardControl/CardControl.cs deleted file mode 100644 index 81f86f15..00000000 --- a/src/Desktop/BiliCopilot.UI/Controls/Components/CardControl/CardControl.cs +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (c) Bili Copilot. All rights reserved. - -using System.Numerics; -using BiliCopilot.UI.ViewModels.Core; -using CommunityToolkit.WinUI; -using CommunityToolkit.WinUI.Animations; -using Microsoft.UI.Composition; -using Microsoft.UI.Xaml.Hosting; - -namespace BiliCopilot.UI.Controls.Components; - -/// -/// 卡片控件. -/// -public sealed partial class CardControl : Button -{ - private const float PointerOverOffsetY = -4f; - - private static readonly TimeSpan _pointerOverShadowDuration = TimeSpan.FromMilliseconds(240); - private static readonly TimeSpan _pressedShadowDuration = TimeSpan.FromMilliseconds(50); - private static readonly TimeSpan _restShadowDuration = TimeSpan.FromMilliseconds(250); - - private Compositor _compositor; - private FrameworkElement _shadowContainer; - private AttachedShadowBase _initialShadow; - private bool _loaded; - private bool _templateApplied; - private bool _shadowCreated; - private bool _shouldDestoryShadow; - private long _pointerOverToken; - private long _pressedToken; - - /// - /// Initializes a new instance of the class. - /// - public CardControl() - { - DefaultStyleKey = typeof(CardControl); - _compositor = this.Get().ActivatedWindow.Compositor; - Loaded += OnLoaded; - Unloaded += OnUnloaded; - } - - /// - protected override void OnApplyTemplate() - { - _shadowContainer = GetTemplateChild("ShadowContainer") as FrameworkElement; - ElementCompositionPreview.SetIsTranslationEnabled(_shadowContainer, true); - - _initialShadow = CommunityToolkit.WinUI.Effects.GetShadow(_shadowContainer); - _templateApplied = true; - ApplyShadowAnimation(); - } - - private void OnUnloaded(object sender, RoutedEventArgs e) - { - Loaded -= OnLoaded; - Unloaded -= OnUnloaded; - - UnregisterPropertyChangedCallback(IsPointerOverProperty, _pointerOverToken); - UnregisterPropertyChangedCallback(IsPressedProperty, _pressedToken); - _loaded = false; - _initialShadow = default; - - DestroyShadow(); - } - - private void OnLoaded(object sender, RoutedEventArgs e) - { - _pointerOverToken = RegisterPropertyChangedCallback(IsPointerOverProperty, OnButtonStateChanged); - _pressedToken = RegisterPropertyChangedCallback(IsPressedProperty, OnButtonStateChanged); - _loaded = true; - - ApplyShadowAnimation(); - } - - private void OnButtonStateChanged(DependencyObject sender, DependencyProperty dp) - => ApplyShadowAnimation(); - - private void CreateShadow() - { - if (_shadowCreated || !_loaded || !_templateApplied) - { - return; - } - - Effects.SetShadow(_shadowContainer, _initialShadow); - var shadowContext = _initialShadow.GetElementContext(_shadowContainer); - shadowContext.CreateResources(); - - if (shadowContext.Shadow is DropShadow dropShadow) - { - dropShadow.Offset = GetShadowOffset(); - dropShadow.BlurRadius = GetShadowRadius(); - dropShadow.Opacity = GetShadowOpacity(); - } - - _shadowCreated = true; - } - - private void DestroyShadow() - { - if (!_shadowCreated) - { - return; - } - - _shadowCreated = false; - Effects.SetShadow(_shadowContainer, default); - _compositor = default; - } - - private void ApplyShadowAnimation() - { - if (!_templateApplied) - { - return; - } - - var duration = IsPressed ? _pressedShadowDuration : IsPointerOver ? _pointerOverShadowDuration : _restShadowDuration; - var offset = IsPressed ? -2f : IsPointerOver ? PointerOverOffsetY : 0f; -#pragma warning disable VSTHRD103 // Call async methods when in an async method - AnimationBuilder.Create().Translation(Axis.Y, offset, duration: duration, easingMode: Microsoft.UI.Xaml.Media.Animation.EasingMode.EaseInOut).Start(this); -#pragma warning restore VSTHRD103 // Call async methods when in an async method - var shadowOpacity = GetShadowOpacity(); - var shadowRadius = GetShadowRadius(); - var shadowOffset = GetShadowOffset(); - - _shouldDestoryShadow = shadowOpacity <= 0; - if (!_shouldDestoryShadow) - { - CreateShadow(); - } - - var shadowContext = _initialShadow.GetElementContext(_shadowContainer); - if (shadowContext.Shadow is DropShadow dropShadow) - { - using var batch = _compositor.CreateScopedBatch(CompositionBatchTypes.Animation); - var shadowAnimationGroup = _compositor.CreateAnimationGroup(); - shadowAnimationGroup.Add(_compositor.CreateScalarKeyFrameAnimation(nameof(DropShadow.BlurRadius), shadowRadius, duration: duration)); - shadowAnimationGroup.Add(_compositor.CreateVector3KeyFrameAnimation(nameof(DropShadow.Offset), shadowOffset, duration: duration)); - shadowAnimationGroup.Add(_compositor.CreateScalarKeyFrameAnimation(nameof(DropShadow.Opacity), shadowOpacity, duration: duration)); - dropShadow.StartAnimationGroup(shadowAnimationGroup); - - if (_shouldDestoryShadow) - { - DestroyShadow(); - } - } - } - - private float GetShadowRadius() - => IsPointerOver ? 12f : IsPressed ? 2f : 6f; - - private float GetShadowOpacity() - => IsPointerOver ? 0.14f : IsPressed ? 0.09f : 0.02f; - - private Vector3 GetShadowOffset() - => new Vector3(0, IsPointerOver ? 4f : IsPressed ? 0f : 2f, 0); -} diff --git a/src/Desktop/BiliCopilot.UI/Controls/Components/CardControl/CardControl.xaml b/src/Desktop/BiliCopilot.UI/Controls/Components/CardControl/CardControl.xaml deleted file mode 100644 index f9597aa0..00000000 --- a/src/Desktop/BiliCopilot.UI/Controls/Components/CardControl/CardControl.xaml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - -