Skip to content

Commit

Permalink
新增快捷键Ctrl+S保存收藏选择,保存视频收藏后自动隐藏收藏夹选择菜单
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Jun 23, 2024
1 parent 159fd15 commit 9877038
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/BiliLite.UWP/BiliLite.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@
<Compile Include="Models\Common\Rank\RankItemModel.cs" />
<Compile Include="Models\Common\Rank\RankItemOwnerModel.cs" />
<Compile Include="Models\Common\Rank\RankItemStatModel.cs" />
<Compile Include="Models\Functions\SaveFunction.cs" />
<Compile Include="Pages\ISavablePage.cs" />
<Compile Include="Services\Biz\MediaListService.cs" />
<Compile Include="Services\PlaySpeedMenuService.cs" />
<Compile Include="ViewModels\Rank\RankRegionViewModel.cs" />
Expand Down
16 changes: 16 additions & 0 deletions src/BiliLite.UWP/Models/Functions/SaveFunction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using BiliLite.Pages;
using System.Threading.Tasks;

namespace BiliLite.Models.Functions
{
public class SaveFunction : IShortcutFunction
{
public string Name { get; } = "保存操作";

public async Task Action(object param)
{
if (!(param is ISavablePage page)) return;
await page.Save();
}
}
}
9 changes: 9 additions & 0 deletions src/BiliLite.UWP/Pages/ISavablePage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Threading.Tasks;

namespace BiliLite.Pages
{
public interface ISavablePage
{
public Task Save();
}
}
13 changes: 11 additions & 2 deletions src/BiliLite.UWP/Pages/VideoDetailPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace BiliLite.Pages
{
public sealed partial class VideoDetailPage : PlayPage, IRefreshablePage
public sealed partial class VideoDetailPage : PlayPage, IRefreshablePage, ISavablePage
{
private static readonly ILogger logger = GlobalLogger.FromCurrentType();

Expand Down Expand Up @@ -725,7 +725,16 @@ private void VideoDetailPage_OnSizeChanged(object sender, SizeChangedEventArgs e

private async void SaveFavList_OnClick(object sender, RoutedEventArgs e)
{
await m_viewModel.UpdateFav(m_viewModel.VideoInfo.Aid);
await Save();
}

public async Task Save()
{
if (BtnFav.Flyout.IsOpen)
{
await m_viewModel.UpdateFav(m_viewModel.VideoInfo.Aid);
BtnFav.Flyout.Hide();
}
}
}
}
1 change: 1 addition & 0 deletions src/BiliLite.UWP/Services/ShortcutKeyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public ShortcutKeyService()
m_shortcutKeyMaps.Add(new AddVolumeFunction(), new List<VirtualKey>() { VirtualKey.Up });
m_shortcutKeyMaps.Add(new MinusVolumeFunction(), new List<VirtualKey>() { VirtualKey.Down });
m_shortcutKeyMaps.Add(new CancelFullscreenFunction(), new List<VirtualKey>() { VirtualKey.Escape });
m_shortcutKeyMaps.Add(new SaveFunction(), new List<VirtualKey>() { VirtualKey.Control, VirtualKey.S });
}

public void SetMainPage(IMainPage mainPage)
Expand Down

0 comments on commit 9877038

Please sign in to comment.