From 54fc1e3593d9b6ec69f02e91c18849fcbdc9c840 Mon Sep 17 00:00:00 2001 From: Mossimo Date: Sat, 28 Oct 2023 19:06:48 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Mac=20=E6=94=AF=E6=8C=81=20UrlSchem?= =?UTF-8?q?es=20=E5=8D=8F=E8=AE=AE=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ref/WTTS.MicroServices.ClientSDK | 2 +- .../UI/Views/Pages/User/LoginOrRegisterPage.axaml.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ref/WTTS.MicroServices.ClientSDK b/ref/WTTS.MicroServices.ClientSDK index 0f04842586c..d38c205b170 160000 --- a/ref/WTTS.MicroServices.ClientSDK +++ b/ref/WTTS.MicroServices.ClientSDK @@ -1 +1 @@ -Subproject commit 0f04842586c2f7a6517ad24f22ec1f9736756ed8 +Subproject commit d38c205b1701e8f40747ba4d46a96d65be864c9b diff --git a/src/BD.WTTS.Client.Avalonia/UI/Views/Pages/User/LoginOrRegisterPage.axaml.cs b/src/BD.WTTS.Client.Avalonia/UI/Views/Pages/User/LoginOrRegisterPage.axaml.cs index be3ac8f0588..ab1a1cd6e09 100644 --- a/src/BD.WTTS.Client.Avalonia/UI/Views/Pages/User/LoginOrRegisterPage.axaml.cs +++ b/src/BD.WTTS.Client.Avalonia/UI/Views/Pages/User/LoginOrRegisterPage.axaml.cs @@ -45,6 +45,17 @@ protected override void OnLoaded(RoutedEventArgs e) this.ViewModel.Close(); } } + Application.Current!.UrlsOpened += Current_UrlsOpened; + } + + private async void Current_UrlsOpened(object? sender, UrlOpenedEventArgs e) + { + var loginUrl = e.Urls.Where(x => x.StartsWith(Constants.UrlSchemes.Login)).FirstOrDefault(); + if (loginUrl != null) + { + var token = loginUrl.Substring(Constants.UrlSchemes.Login.Length, loginUrl.Length - 1); + await ThirdPartyLoginHelper.OnMessageAsync(token); + } } protected override void OnDataContextChanged(EventArgs e) @@ -64,5 +75,6 @@ protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e { vm.RemoveAllDelegate(); } + Application.Current!.UrlsOpened -= Current_UrlsOpened; } }