diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/WebView3.cs b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/WebView3.cs
index ad3494a4b..247472037 100644
--- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/WebView3.cs
+++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/WebView3.cs
@@ -46,10 +46,15 @@ namespace System.Application.UI.Views.Controls
}
///
- /// 在浏览器中打开新窗口
+ /// 在浏览器中打开新窗口,所有新页面打开的Url会在浏览器中打开
///
public bool OpenInBrowser { get; set; } = true;
+ ///
+ /// 是否固定单页,为 时所有跳转都将在浏览器中打开
+ ///
+ public bool FixedSinglePage { get; set; } = false;
+
///
/// 需要拦截响应流的Url
///
@@ -170,6 +175,11 @@ namespace System.Application.UI.Views.Controls
protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref int noJavascriptAccess)
{
+ if (webView.FixedSinglePage)
+ {
+ BrowserOpen(targetUrl);
+ return true;
+ }
switch (targetDisposition)
{
case CefWindowOpenDisposition.NewForegroundTab:
@@ -183,7 +193,10 @@ namespace System.Application.UI.Views.Controls
else
{
// 禁止创建新窗口,仅在当前窗口跳转
- browser.MainFrame.LoadUrl(targetUrl);
+ if (IsHttpUrl(targetUrl))
+ {
+ browser.MainFrame.LoadUrl(targetUrl);
+ }
}
return true;
}
diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WebView3Window.axaml.cs b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WebView3Window.axaml.cs
index db4d5a0d1..5eb3586b4 100644
--- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WebView3Window.axaml.cs
+++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WebView3Window.axaml.cs
@@ -32,6 +32,7 @@ namespace System.Application.UI.Views.Windows
base.OnDataContextChanged(e);
if (DataContext is WebView3WindowViewModel vm)
{
+ if (!string.IsNullOrWhiteSpace(vm.Title)) webView.DocumentTitleChanged -= WebView_DocumentTitleChanged;
vm.WhenAnyValue(x => x.Url).WhereNotNull().Subscribe(x =>
{
if (x == WebView3WindowViewModel.AboutBlank)
@@ -56,10 +57,8 @@ namespace System.Application.UI.Views.Windows
}
}
}).AddTo(vm);
- vm.WhenAnyValue(x => x.StreamResponseFilterUrls).Subscribe(x =>
- {
- webView.StreamResponseFilterUrls = x;
- }).AddTo(vm);
+ vm.WhenAnyValue(x => x.StreamResponseFilterUrls).Subscribe(x => webView.StreamResponseFilterUrls = x).AddTo(vm);
+ vm.WhenAnyValue(x => x.FixedSinglePage).Subscribe(x => webView.FixedSinglePage = x).AddTo(vm);
webView.OnStreamResponseFilterResourceLoadComplete += vm.OnStreamResponseFilterResourceLoadComplete;
}
}
diff --git a/src/ST.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs
index f0c6361a0..3b6cbc67c 100644
--- a/src/ST.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs
+++ b/src/ST.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs
@@ -16,6 +16,7 @@ using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
using static Newtonsoft.Json.JsonConvert;
namespace System.Application.UI.ViewModels
@@ -209,15 +210,34 @@ namespace System.Application.UI.ViewModels
DebugString = @string.ToString();
}
- public async void ShowDialogButton_Click()
+ public /*async*/ void ShowDialogButton_Click()
{
- DI.Get().OpenDesktopIconsSettings();
+#if DEBUG
+ var apiBaseUrl = ICloudServiceClient.Instance.ApiBaseUrl;
+ var vm = new WebView3WindowViewModel
+ {
+ Url = apiBaseUrl + "/ExternalLogin",
+ StreamResponseFilterUrls = new[]
+ {
+ apiBaseUrl + "/ExternalLoginCallback"
+ },
+ OnStreamResponseFilterResourceLoadComplete = (url, data) =>
+ {
- ToastService.Current.Notify("中文测试繁體測試🎉🧨🎇🎆🎄🖼🖼🖼🖼");
- DebugString += ToastService.Current.Message + Environment.NewLine;
- DebugString += ToastService.Current.IsVisible + Environment.NewLine;
+ },
+ FixedSinglePage = true,
+ Title = "Steam 快速登录",
+ };
+ IShowWindowService.Instance.Show(CustomWindow.WebView3, vm, resizeMode: ResizeModeCompat.NoResize);
+#endif
- await IShowWindowService.Instance.Show(typeof(object), CustomWindow.NewVersion);
+ //DI.Get().OpenDesktopIconsSettings();
+
+ //ToastService.Current.Notify("中文测试繁體測試🎉🧨🎇🎆🎄🖼🖼🖼🖼");
+ //DebugString += ToastService.Current.Message + Environment.NewLine;
+ //DebugString += ToastService.Current.IsVisible + Environment.NewLine;
+
+ //await IShowWindowService.Instance.Show(typeof(object), CustomWindow.NewVersion);
// var r = await MessageBoxCompat.ShowAsync(@"Steam++ v1.1.2 2021-01-29
//更新内容
diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/WebView3WindowViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/WebView3WindowViewModel.cs
index 764f3bc9a..175dd8213 100644
--- a/src/ST.Client.Desktop/UI/ViewModels/Windows/WebView3WindowViewModel.cs
+++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/WebView3WindowViewModel.cs
@@ -21,5 +21,7 @@ namespace System.Application.UI.ViewModels
}
public Action? OnStreamResponseFilterResourceLoadComplete { get; set; }
+
+ public bool FixedSinglePage { get; set; }
}
}
\ No newline at end of file