Skip to content

Commit

Permalink
Merge pull request #520 from ywmoyue/dev
Browse files Browse the repository at this point in the history
4.6.27
  • Loading branch information
ywmoyue authored Mar 12, 2024
2 parents ac63e30 + 9a69b2e commit 4454614
Show file tree
Hide file tree
Showing 57 changed files with 2,123 additions and 706 deletions.
421 changes: 421 additions & 0 deletions src/BiliLite.UWP/Assets/GeeTest/bili_gt.cshtml

Large diffs are not rendered by default.

30 changes: 29 additions & 1 deletion src/BiliLite.UWP/BiliLite.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<ItemGroup>
<Compile Include="Controls\AttentionButton.xaml.cs">
<DependentUpon>AttentionButton.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\UserFollowingTagsFlyout.xaml.cs">
<DependentUpon>UserFollowingTagsFlyout.xaml</DependentUpon>
</Compile>
<Compile Include="Extensions\QrCodeExtensions.cs" />
<Compile Include="Models\Common\Anime\ISeasonItem.cs" />
<Compile Include="Models\Common\Dynamic\DynamicUgcSeasonCardModel.cs" />
Expand Down Expand Up @@ -187,6 +193,9 @@
<Compile Include="Models\Common\Live\RoomChangeMsgModel.cs" />
<Compile Include="Models\Common\User\SearchHistoryData.cs" />
<Compile Include="Models\Common\User\SubmitCollectionItemModel.cs" />
<Compile Include="ViewModels\User\UserAttentionButtonViewModel.cs" />
<Compile Include="ViewModels\User\UserFollowingTagsFlyoutViewModel.cs" />
<Compile Include="ViewModels\User\UserRelationFollowingTagViewModel.cs" />
<Compile Include="Models\Common\Video\BiliVideoTag.cs" />
<Compile Include="Models\Common\WbiKey.cs" />
<Compile Include="Models\Exceptions\NotFoundException.cs" />
Expand All @@ -196,6 +205,16 @@
<Compile Include="Models\Common\Download\DownloadedItem.cs" />
<Compile Include="Models\Common\Download\DownloadedSubItem.cs" />
<Compile Include="Models\Common\Home\HomeNavItem.cs" />
<Compile Include="Models\Common\User\UserDetails\UserCenterInfoLiveRoomModel.cs" />
<Compile Include="Models\Common\User\UserDetails\UserCenterInfoNameplateModel.cs" />
<Compile Include="Models\Common\User\UserDetails\UserCenterInfoOfficialModel.cs" />
<Compile Include="Models\Common\User\UserDetails\UserCenterInfoPendantModel.cs" />
<Compile Include="Models\Common\User\UserDetails\UserCenterInfoStatModel.cs" />
<Compile Include="Models\Common\User\UserDetails\UserCenterInfoVipLabelModel.cs" />
<Compile Include="Models\Common\User\UserDetails\UserCenterInfoVipModel.cs" />
<Compile Include="Models\Common\User\UserDetails\UserCenterSpaceStatModel.cs" />
<Compile Include="Models\Common\User\UserDetails\UserCenterInfoModel.cs" />
<Compile Include="ViewModels\User\UserCenterInfoViewModel.cs" />
<Compile Include="ViewModels\Home\HomeNavItemViewModel.cs" />
<Compile Include="ViewModels\Download\DownloadingItemViewModel.cs" />
<Compile Include="Player\Controllers\BasePlayerController.cs" />
Expand Down Expand Up @@ -628,7 +647,7 @@
<Compile Include="Modules\User\MyFollowVideoVM.cs" />
<Compile Include="Modules\User\SendDynamic\SendDynamicVM.cs" />
<Compile Include="Modules\User\SendDynamic\TopicVM.cs" />
<Compile Include="Modules\User\UserDetail\UserDetailVM.cs" />
<Compile Include="ViewModels\User\UserDetailViewModel.cs" />
<Compile Include="Modules\User\UserDetail\UserFavlistVM.cs" />
<Compile Include="Modules\User\UserDetail\UserFollowVM.cs" />
<Compile Include="Modules\User\UserDetail\UserSubmitArticleVM.cs" />
Expand Down Expand Up @@ -876,6 +895,7 @@
<Content Include="Assets\Fonts\vanfont.otf" />
<Content Include="Assets\Fonts\FansNum.otf" />
<Content Include="Assets\Fonts\biliicon.ttf" />
<Content Include="Assets\GeeTest\bili_gt.cshtml" />
<None Include="Assets\Text\new_version.json" />
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
Expand All @@ -895,6 +915,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="Controls\AttentionButton.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\Carousel\Carousel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand All @@ -903,6 +927,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\UserFollowingTagsFlyout.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Styles\AppBarButtonNoChevronStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
35 changes: 35 additions & 0 deletions src/BiliLite.UWP/Controls/AttentionButton.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<UserControl
x:Class="BiliLite.Controls.AttentionButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BiliLite.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="Transparent"
d:DesignHeight="300"
d:DesignWidth="400">
<UserControl.Resources>
<MenuFlyout x:Key="AttentionFlyout" x:Name="AttentionFlyout">
<MenuFlyoutItem Click="SetFollowingTag_OnClick">设置分组</MenuFlyoutItem>
<MenuFlyoutItem Command="{x:Bind m_viewModel.AttentionCommand}">取消关注</MenuFlyoutItem>
</MenuFlyout>
</UserControl.Resources>
<Grid Background="Transparent">
<local:UserFollowingTagsFlyout x:Name="UserFollowingTagsFlyout"></local:UserFollowingTagsFlyout>
<Button Width="80"
x:Name="AttendedBtn"
Visibility="{x:Bind Path=m_viewModel.Attention,Converter={StaticResource display},ConverterParameter=1,Mode=OneWay}"
Click="AttendedBtn_OnClick"
Padding="16 4" FontSize="12">已关注</Button>
<Button Width="80"
Visibility="{x:Bind Path=m_viewModel.Attention,Converter={StaticResource display},ConverterParameter=0,Mode=OneWay}"
Command="{x:Bind Path=m_viewModel.AttentionCommand}"
Padding="16 4"
BorderThickness="1"
Background="Transparent"
BorderBrush="{ThemeResource HighLightColor}"
Foreground="{ThemeResource HighLightColor}"
FontSize="12">关注</Button>
</Grid>
</UserControl>
61 changes: 61 additions & 0 deletions src/BiliLite.UWP/Controls/AttentionButton.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using BiliLite.ViewModels.User;
using Microsoft.Extensions.DependencyInjection;

//https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板

namespace BiliLite.Controls
{
public sealed partial class AttentionButton : UserControl
{
private readonly UserAttentionButtonViewModel m_viewModel;

public AttentionButton()
{
m_viewModel = App.ServiceProvider.GetRequiredService<UserAttentionButtonViewModel>();
this.InitializeComponent();
}

public static readonly DependencyProperty AttentionProperty =
DependencyProperty.Register(nameof(Attention), typeof(int), typeof(AttentionButton), new PropertyMetadata(0));

public int Attention
{
get => m_viewModel.Attention;
set => m_viewModel.Attention = value;
}

public static readonly DependencyProperty UserIdProperty =
DependencyProperty.Register(nameof(Attention), typeof(string), typeof(AttentionButton), new PropertyMetadata(default(string)));

public string UserId
{
get => m_viewModel.UserId;
set => m_viewModel.UserId = value;
}

public async Task AttentionUp()
{
await m_viewModel.AttentionUP(m_viewModel.UserId, 1);
}

private void AttendedBtn_OnClick(object sender, RoutedEventArgs e)
{
var flyoutShowOptions = new FlyoutShowOptions()
{
Placement = FlyoutPlacementMode.Bottom
};
AttentionFlyout.ShowAt(sender as DependencyObject, flyoutShowOptions);
}

private async void SetFollowingTag_OnClick(object sender, RoutedEventArgs e)
{
if(!UserFollowingTagsFlyout.HasInit)
await UserFollowingTagsFlyout.Init(m_viewModel.UserId);
UserFollowingTagsFlyout.ShowAt(AttendedBtn);
}
}
}
30 changes: 30 additions & 0 deletions src/BiliLite.UWP/Controls/UserFollowingTagsFlyout.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<UserControl
x:Class="BiliLite.Controls.UserFollowingTagsFlyout"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BiliLite.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:user="using:BiliLite.ViewModels.User"
mc:Ignorable="d"
d:DesignHeight="0"
d:DesignWidth="0">

<UserControl.ContextFlyout>
<Flyout Placement="Bottom"
x:Name="FollowingTagFlyout"
AllowFocusOnInteraction="False"
Closed="FollowingTagFlyout_OnClosed">
<StackPanel Orientation="Vertical">
<ListView ItemsSource="{x:Bind m_viewModel.FollowingTags,Mode=OneWay}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="user:UserRelationFollowingTagViewModel">
<CheckBox Content="{x:Bind Name}" IsChecked="{x:Bind UserInThisTag,Mode=TwoWay}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button x:Name="SaveFollowingTagUser" Click="SaveFollowingTagUser_OnClick" HorizontalAlignment="Right">保存</Button>
</StackPanel>
</Flyout>
</UserControl.ContextFlyout>
</UserControl>
49 changes: 49 additions & 0 deletions src/BiliLite.UWP/Controls/UserFollowingTagsFlyout.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using BiliLite.ViewModels.User;
using Microsoft.Extensions.DependencyInjection;

//https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板

namespace BiliLite.Controls
{
public sealed partial class UserFollowingTagsFlyout : UserControl
{
private readonly UserFollowingTagsFlyoutViewModel m_viewModel;

public UserFollowingTagsFlyout()
{
m_viewModel = App.ServiceProvider.GetRequiredService<UserFollowingTagsFlyoutViewModel>();
this.InitializeComponent();
}

public bool HasInit { get; set; }

private void FollowingTagFlyout_OnClosed(object sender, object e)
{
m_viewModel.CancelSaveFollowingTagUser();
}

private async void SaveFollowingTagUser_OnClick(object sender, RoutedEventArgs e)
{
await m_viewModel.SaveFollowingTagUser();
FollowingTagFlyout.Hide();
}

public async Task Init(string userId)
{
await m_viewModel.Init(userId);
HasInit = true;
}

public void ShowAt(DependencyObject target)
{
ContextFlyout.ShowAt(target, new FlyoutShowOptions()
{
Placement = FlyoutPlacementMode.Bottom
});
}
}
}
3 changes: 2 additions & 1 deletion src/BiliLite.UWP/Dialogs/LoginDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
PrimaryButtonText="登录"
SecondaryButtonText="取消"
xmlns:user="using:BiliLite.Modules.User"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
IsPrimaryButtonEnabled="{x:Bind Path=loginVM.PrimaryButtonEnable,Mode=OneWay}"
SecondaryButtonClick="ContentDialog_SecondaryButtonClick">
Expand Down Expand Up @@ -142,7 +143,7 @@

</StackPanel>
<!--WebView-->
<WebView x:Name="webView" NavigationStarting="webView_NavigationStarting" NavigationCompleted="WebView_NavigationCompleted" Height="444" Width="346" Visibility="Collapsed"></WebView>
<controls:WebView2 x:Name="webView" NavigationStarting="WebView_OnNavigationStarting" NavigationCompleted="WebView_OnNavigationCompleted" Height="444" Width="346" Visibility="Collapsed"></controls:WebView2>
</Grid>

</ContentDialog>
51 changes: 34 additions & 17 deletions src/BiliLite.UWP/Dialogs/LoginDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
using Newtonsoft.Json.Linq;
using System;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Web.WebView2.Core;
using Windows.Storage;

// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“内容对话框”项模板

Expand Down Expand Up @@ -50,9 +54,17 @@ private void _biliapp_ValidateLoginEvent(object sender, string e)
loginVM.ValidateLogin(JObject.Parse(e));

}
private void LoginVM_OpenWebView(object sender, Uri e)

private async void LoginVM_OpenWebView(object sender, Uri e)
{
webView.Source = e;
await InitWebView2();
var templateText = await FileIO.ReadTextAsync(
await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/GeeTest/bili_gt.cshtml")));

var result = templateText.Replace("@Model.Url", e.AbsoluteUri);

//webView.Source = e;
webView.NavigateToString(result);
}

private void SMSLoginDialog_Loaded(object sender, RoutedEventArgs e)
Expand All @@ -77,6 +89,11 @@ private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDia
}


private async Task InitWebView2()
{
await webView.EnsureCoreWebView2Async();
}


private void txt_Password_GotFocus(object sender, RoutedEventArgs e)
{
Expand All @@ -88,20 +105,20 @@ private void txt_Password_LostFocus(object sender, RoutedEventArgs e)
hide.Visibility = Visibility.Collapsed;
}

private async void webView_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
private async void WebView_OnNavigationStarting(WebView2 sender, CoreWebView2NavigationStartingEventArgs args)
{
if (args.Uri.AbsoluteUri.Contains("access_key="))
if (args.Uri.Contains("access_key="))
{
var access = Regex.Match(args.Uri.AbsoluteUri, "access_key=(.*?)&").Groups[1].Value;
var mid = Regex.Match(args.Uri.AbsoluteUri, "mid=(.*?)&").Groups[1].Value;
var access = Regex.Match(args.Uri, "access_key=(.*?)&").Groups[1].Value;
var mid = Regex.Match(args.Uri, "mid=(.*?)&").Groups[1].Value;
var appKey = SettingConstants.Account.DefaultLoginAppKeySecret;
await loginVM.account.SaveLogin(access, "", 0, long.Parse(mid), null, null, appKey);
this.Hide();
return;
}
if (args.Uri.AbsoluteUri.Contains("geetest.result"))
if (args.Uri.Contains("geetest.result"))
{
var success = (Regex.Match(args.Uri.AbsoluteUri, @"success=(\d)&").Groups[1].Value).ToInt32();
var success = (Regex.Match(args.Uri, @"success=(\d)&").Groups[1].Value).ToInt32();
if (success == 0)
{
//验证失败
Expand All @@ -112,10 +129,10 @@ private async void webView_NavigationStarting(WebView sender, WebViewNavigationS
{
webView.Visibility = Visibility.Collapsed;
//验证成功
var challenge = Regex.Match(args.Uri.AbsoluteUri, "geetest_challenge=(.*?)&").Groups[1].Value;
var validate = Regex.Match(args.Uri.AbsoluteUri, "geetest_validate=(.*?)&").Groups[1].Value;
var seccode = Regex.Match(args.Uri.AbsoluteUri, "geetest_seccode=(.*?)&").Groups[1].Value;
var recaptcha_token = Regex.Match(args.Uri.AbsoluteUri, "recaptcha_token=(.*?)&").Groups[1].Value;
var challenge = Regex.Match(args.Uri, "geetest_challenge=(.*?)&").Groups[1].Value;
var validate = Regex.Match(args.Uri, "geetest_validate=(.*?)&").Groups[1].Value;
var seccode = Regex.Match(args.Uri, "geetest_seccode=(.*?)&").Groups[1].Value;
var recaptcha_token = Regex.Match(args.Uri, "recaptcha_token=(.*?)&").Groups[1].Value;
loginVM.HandleGeetestSuccess(seccode, validate, challenge, recaptcha_token);
}
else if (success == 2)
Expand All @@ -129,24 +146,24 @@ private async void webView_NavigationStarting(WebView sender, WebViewNavigationS
}
try
{
this.webView.AddWebAllowedObject("biliapp", _biliapp);
this.webView.AddWebAllowedObject("secure", _secure);
//this.webView.AddWebAllowedObject("biliapp", _biliapp);
//this.webView.AddWebAllowedObject("secure", _secure);
}
catch (Exception ex)
{
logger.Log("注入JS对象失败", LogType.Error, ex);
}
}

private async void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
private async void WebView_OnNavigationCompleted(WebView2 sender, CoreWebView2NavigationCompletedEventArgs args)
{
if (args.Uri.AbsoluteUri == "https://passport.bilibili.com/ajax/miniLogin/redirect" || args.Uri.AbsoluteUri == "https://www.bilibili.com/")
if (sender.Source.AbsoluteUri == "https://passport.bilibili.com/ajax/miniLogin/redirect" || sender.Source.AbsoluteUri == "https://www.bilibili.com/")
{
var results = await $"https://passport.bilibili.com/login/app/third?appkey=&api=http%3A%2F%2Flink.acg.tv%2Fforum.php&sign=67ec798004373253d60114caaad89a8c".GetString();
var obj = JObject.Parse(results);
if (obj["code"].ToInt32() == 0)
{
webView.Navigate(new Uri(obj["data"]["confirm_uri"].ToString()));
webView.Source = new Uri(obj["data"]["confirm_uri"].ToString());
}
else
{
Expand Down
Loading

0 comments on commit 4454614

Please sign in to comment.