From 23706dae7f3dc4470de80f9988a24595878bfcc0 Mon Sep 17 00:00:00 2001 From: Richasy Date: Sun, 24 Sep 2023 15:10:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=B9=B6=E6=9B=B4=E6=96=B0=E8=AF=81=E4=B9=A6?= =?UTF-8?q?=20(#1773)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App/App.csproj | 1 + src/App/App_TemporaryKey.pfx | Bin 2520 -> 2520 bytes .../AuthorizeProvider.Extension.cs | 31 +++++++++++------- src/Lib/SignIn.Uwp/SignIn.Uwp.csproj | 6 ++-- src/Lib/SignIn.Uwp/SignInDialog.xaml.cs | 7 ++-- .../Models.App/Constants/ApiConstants.cs | 5 +-- 6 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/App/App.csproj b/src/App/App.csproj index ee13ca13b..431b28d3b 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -26,6 +26,7 @@ 0 App_TemporaryKey.pfx False + C3B9A35BB185E430F381F524A644B2598DDF2500 false diff --git a/src/App/App_TemporaryKey.pfx b/src/App/App_TemporaryKey.pfx index 2269759f8dd0c8a8ea1260ed7b9c809877145835..50b9911fabe78f53f7ca85b7996a6a3693b4d751 100644 GIT binary patch delta 2267 zcmV<12qgE|6W9}wXn(|l*Nl&(p+o`#2haq91lV!6w0o5q!50rAI*{+StIDXP@No4E z9H%CWx0+t=wAo~wf=sfx=_i*3Gbgy@0|6`&yzsH><{zOke7*8$qBKZLs%h3YB+KK` zw=&lP1}IS#rY}`w&S1i#?&t^=qFO&U02{MKZ3H?F0MJQcr+;v{N5<=z34a+8rEpzg@=$*owe;Jc2X*4y=Vf8D!GXyk&1*eU-H(ERe8RS2;FL*f)% zl0qh`Lw{(uhH9Y42?PrklBFNJzo~P%Dp5!XBZE56`N89LEy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#M(F3)GG8ED`49*7SX#ZF&LNQUqi#I*yhP_!37*R;m>``k25mZ^V7NbF|~gZ2VP0A$CdBrkbi(DGitYtRS1nX zw%yui7LDL(O*a^8M7SHCfxus%Y*o?(OwU1(eyQ{lzDyMWz!0X48=ypsvMhyZL*U|L zD%R`iW8lQpivpaBH>H}&3`5PB$YBb$i5b$b;(!lFrPu8DO_Q^sHL7(wJZCMeq<>P0 zy?(KGT(0sv4G*t#x_{`qpjTt&0jN)b@4;Z0!-B8OY#Wg&M$aI-!QsxI<5QvDDc#nE z+b;*)NhXhQEKoF=y$H|RlR)|O{}0J-#}sjzQs~J}ySpOnnl%4LNl@;Q2rL@hYl{tP z>-_n!t%!qkbGT>Zo^aH92Xa%2`w4c&Jm{K0*m8br(vU`vS%1ufK8V&$&>)uAvp=Ne zfoR(W!upI}o{~`?@`fDm!tLS#uLMU)QhZ!-l+R>YSJzLR(D0piAyytbuTqSmC5zBI zxI^JhUQ6(UEFW@HM<=ErdOcoV>re@Q+?ZtFLS?%m3IA;4ue&f^7NJ}ki}o=sO5~@J zB^lo4eXxV%XMZ;kHD=AfkF^ZS=)My`tx50qh4lJezI7g(9SX^f(J|{~NCIstggCO+ zr5xViB}q4#%F(eqKViLa<29Yl!ov9Yg;=5wFgq|GFb4(&D-Ht!8Uz%BlkYW*6Q$EJ p7&5W_u1gc5ry&>w6e2!D$&8^tdfRfD9hNheo?MQM=L7-*2hhGOMEL*! diff --git a/src/Lib/SignIn.Uwp/AuthorizeProvider/AuthorizeProvider.Extension.cs b/src/Lib/SignIn.Uwp/AuthorizeProvider/AuthorizeProvider.Extension.cs index eea101d77..2d4a310b6 100644 --- a/src/Lib/SignIn.Uwp/AuthorizeProvider/AuthorizeProvider.Extension.cs +++ b/src/Lib/SignIn.Uwp/AuthorizeProvider/AuthorizeProvider.Extension.cs @@ -2,6 +2,8 @@ using System; using System.Collections.Generic; +using System.Drawing.Imaging; +using System.IO; using System.Linq; using System.Net.Http; using System.Runtime.InteropServices.WindowsRuntime; @@ -17,13 +19,13 @@ using Bili.Models.Enums; using Bili.Toolkit.Interfaces; using Newtonsoft.Json.Linq; +using QRCoder; using Windows.Security.Cryptography.Core; using Windows.Storage; +using Windows.Storage.Streams; using Windows.UI.Xaml; using Windows.UI.Xaml.Media.Imaging; using Windows.Web.Http.Filters; -using ZXing; -using ZXing.Common; using static Bili.Models.App.Constants.ApiConstants; using static Bili.Models.App.Constants.ServiceConstants; @@ -229,7 +231,7 @@ internal async Task GetConfirmUriAsync() return null; } - internal async Task GetQRImageAsync() + internal async Task GetQRImageAsync() { try { @@ -244,17 +246,22 @@ internal async Task GetQRImageAsync() var result = await httpProvider.ParseAsync>(response); _internalQRAuthCode = result.Data.AuthCode; - var barcodeWriter = new BarcodeWriter(); - barcodeWriter.Format = BarcodeFormat.QR_CODE; - barcodeWriter.Options = new EncodingOptions() + var generator = new QRCodeGenerator(); + var data = generator.CreateQrCode(result.Data.Url, QRCodeGenerator.ECCLevel.Q); + var code = new BitmapByteQRCode(data); + var image = code.GetGraphic(20); + using (var stream = new InMemoryRandomAccessStream()) { - Margin = 1, - Height = 200, - Width = 200, - }; + using (var writer = new DataWriter(stream.GetOutputStreamAt(0))) + { + writer.WriteBytes(image); + await writer.StoreAsync(); + } - var img = barcodeWriter.Write(result.Data.Url); - return img; + var bitmap = new BitmapImage(); + await bitmap.SetSourceAsync(stream); + return bitmap; + } } catch { diff --git a/src/Lib/SignIn.Uwp/SignIn.Uwp.csproj b/src/Lib/SignIn.Uwp/SignIn.Uwp.csproj index e222b8534..56ac8056c 100644 --- a/src/Lib/SignIn.Uwp/SignIn.Uwp.csproj +++ b/src/Lib/SignIn.Uwp/SignIn.Uwp.csproj @@ -133,12 +133,12 @@ 6.2.14 + + 1.4.3 + 1.0.0 - - 0.16.8 - diff --git a/src/Lib/SignIn.Uwp/SignInDialog.xaml.cs b/src/Lib/SignIn.Uwp/SignInDialog.xaml.cs index eb82f0528..431cfc849 100644 --- a/src/Lib/SignIn.Uwp/SignInDialog.xaml.cs +++ b/src/Lib/SignIn.Uwp/SignInDialog.xaml.cs @@ -172,11 +172,12 @@ private async Task LoadQRCodeAsync() { HideQRTip(); QRLoadingRing.IsActive = true; - var imgSource = await _authorizeProvider.GetQRImageAsync(); - if (imgSource != null) + var bitmapImage = await _authorizeProvider.GetQRImageAsync(); + if (bitmapImage != null) { - QRCodeImage.Source = imgSource; + QRCodeImage.Source = bitmapImage; _authorizeProvider.StartQRLoginListener(); + QRTipBlock.Visibility = Visibility.Visible; } else { diff --git a/src/Models/Models.App/Constants/ApiConstants.cs b/src/Models/Models.App/Constants/ApiConstants.cs index 62fc6097d..e13270600 100644 --- a/src/Models/Models.App/Constants/ApiConstants.cs +++ b/src/Models/Models.App/Constants/ApiConstants.cs @@ -14,6 +14,7 @@ public static class ApiConstants public const string _vcBase = "https://api.vc.bilibili.com"; public const string _liveBase = "https://api.live.bilibili.com"; public const string _passBase = "https://passport.bilibili.com"; + public const string _passSnmBase = "https://passport.snm0516.aisee.tv"; public const string _bangumiBase = "https://bangumi.bilibili.com"; public const string _grpcBase = "https://grpc.biliapi.net"; @@ -50,12 +51,12 @@ public static class Passport /// /// 获取登录二维码. /// - public const string QRCode = _passBase + "/x/passport-tv-login/qrcode/auth_code"; + public const string QRCode = _passSnmBase + "/x/passport-tv-login/qrcode/auth_code"; /// /// 登录二维码轮询状态. /// - public const string QRCodeCheck = _passBase + "/x/passport-tv-login/qrcode/poll"; + public const string QRCodeCheck = _passSnmBase + "/x/passport-tv-login/qrcode/poll"; /// /// cookie转访问令牌.