Skip to content

Commit ae9a635

Browse files
committed
🐛 修复 TaskDialog 在主窗口为null时不在抛出异常
修复加速脚本url匹配问题
1 parent d49e38f commit ae9a635

6 files changed

Lines changed: 58 additions & 7 deletions

File tree

src/BD.WTTS.Client.Avalonia/Services.Implementation/UI/Views/Windows/AvaloniaWindowManagerImpl.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ public async Task<bool> ShowTaskDialogAsync<TPageViewModel>(
111111
XamlRoot = GetWindowTopLevel(),
112112
};
113113

114+
if (td.XamlRoot == null)
115+
{
116+
Toast.LogAndShowT(new Exception("在 AppWindow 为 Null 时,无法弹出 Taskdialog."));
117+
return false;
118+
}
119+
114120
if (viewModel != null)
115121
{
116122
if (viewModel is IWindowViewModel window)

src/BD.WTTS.Client.Avalonia/UI/Styling/Controls/Button.axaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
<StackPanel Spacing="10">
1010
<HyperlinkButton Content="更新日志" />
1111
<Button Content="更新日志" Theme="{StaticResource HyperlinkButton}" />
12+
<Button Classes="TransparentAccent" Content="更新日志" />
13+
<Button
14+
Classes="TransparentAccent"
15+
Content="更新日志"
16+
IsEnabled="False" />
1217
<Button
1318
Content="更新日志"
1419
IsEnabled="False"
@@ -221,6 +226,15 @@
221226
<Setter Property="Background" Value="Transparent" />
222227
</Style>
223228

229+
<Style Selector="Button.TransparentAccent /template/ ContentPresenter#PART_ContentPresenter">
230+
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonForeground}" />
231+
</Style>
224232

233+
<Style Selector="Button.TransparentAccent:pointerover /template/ ContentPresenter#PART_ContentPresenter">
234+
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonForegroundPointerOver}" />
235+
</Style>
225236

237+
<Style Selector="Button.TransparentAccent:pressed /template/ ContentPresenter#PART_ContentPresenter">
238+
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonForegroundPressed}" />
239+
</Style>
226240
</Styles>

src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/HttpServer/Middleware/HttpReverseProxyMiddleware.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public HttpReverseProxyMiddleware(
3838
/// <returns></returns>
3939
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
4040
{
41-
var url = context.Request.GetDisplayUrl().Remove(0, context.Request.Scheme.Length + 3);
41+
var url = context.Request.GetDisplayUrl();
42+
//var url = context.Request.GetDisplayUrl().Remove(0, context.Request.Scheme.Length + 3);
4243

4344
var isScriptInject = reverseProxyConfig.TryGetScriptConfig(url, out var scriptConfigs);
4445

@@ -51,7 +52,7 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next)
5152
context.Response.Body = memoryStream;
5253
}
5354

54-
if (TryGetDomainConfig(url, out var domainConfig) == false)
55+
if (TryGetDomainConfig(url.Remove(0, context.Request.Scheme.Length + 3), out var domainConfig) == false)
5556
{
5657
if (reverseProxyConfig.Service.TwoLevelAgentEnable)
5758
{

src/BD.WTTS.Client.Plugins.Accelerator/Services/Mvvm/GameAcceleratorService.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ public sealed partial class GameAcceleratorService
6666
DeleteMyGameCommand = ReactiveCommand.Create<XunYouGameViewModel>(DeleteMyGame);
6767
GameAcceleratorCommand = ReactiveCommand.CreateFromTask<XunYouGameViewModel>(GameAccelerator);
6868
GameLaunchCommand = ReactiveCommand.CreateFromTask<XunYouGameViewModel>(GameLaunch);
69-
InstallAcceleratorCommand = ReactiveCommand.CreateFromTask(InstallAccelerator);
69+
InstallAcceleratorCommand = ReactiveCommand.CreateFromTask(async () =>
70+
{
71+
if (await IWindowManager.Instance.ShowTaskDialogAsync(new MessageBoxWindowViewModel(),
72+
pageContent: new AcceleratorPathAskBox(), title: "游戏加速", isCancelButton: false, isOkButton: false))
73+
{
74+
await InstallAccelerator();
75+
}
76+
});
7077
UninstallAcceleratorCommand = ReactiveCommand.Create(UninstallAccelerator);
7178
AcceleratorChangeAreaCommand = ReactiveCommand.Create<XunYouGameViewModel>(AcceleratorChangeArea);
7279

@@ -348,7 +355,7 @@ public async Task GameAccelerator(XunYouGameViewModel app)
348355
//}
349356

350357
if (!await IWindowManager.Instance.ShowTaskDialogAsync(new MessageBoxWindowViewModel(),
351-
pageContent: new AcceleratorPathAskBox(), title: "未安装加速插件", isCancelButton: true))
358+
pageContent: new AcceleratorPathAskBox(), title: "游戏加速", isCancelButton: false, isOkButton: false))
352359
{
353360
app.IsAccelerating = false;
354361
return;

src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorPathAskBox.axaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
d:DesignHeight="450"
1111
d:DesignWidth="800"
1212
mc:Ignorable="d">
13-
<StackPanel Spacing="6">
13+
<StackPanel Spacing="15">
14+
15+
<TextBlock FontSize="21" TextAlignment="Center">
16+
<Run Text="下载 Watt加速器" />
17+
<LineBreak />
18+
<Run Text="拒绝游戏延迟,提高稳定性" />
19+
</TextBlock>
20+
1421
<ui:SettingsExpander
1522
Description="{Binding Source={x:Static ms:GameAcceleratorSettings.WattAcceleratorDirPath}, Path=Value}"
1623
Header="安装路径"
@@ -22,6 +29,16 @@
2229
<Button Click="SelectWattAcceleratorInstallPath" Content="选择路径" />
2330
</ui:SettingsExpander.Footer>
2431
</ui:SettingsExpander>
25-
<TextBlock Text="需要下载 Watt 加速器插件才可使用,确定要下载吗?" />
32+
33+
<!--<TextBlock Text="需要下载 Watt 加速器插件才可使用,确定要下载吗?" />-->
34+
35+
<Button
36+
Margin="0,15"
37+
Padding="20,10"
38+
HorizontalAlignment="Center"
39+
Classes="TransparentAccent"
40+
Click="OKButton_Click"
41+
Content="立即下载"
42+
FontSize="14" />
2643
</StackPanel>
2744
</UserControl>

src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorPathAskBox.axaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using Avalonia.Controls;
22
using Avalonia.Platform.Storage;
3+
using Avalonia.ReactiveUI;
34

45
namespace BD.WTTS.UI.Views.Controls;
56

6-
public partial class AcceleratorPathAskBox : UserControl
7+
public partial class AcceleratorPathAskBox : ReactiveUserControl<MessageBoxWindowViewModel>
78
{
89
public AcceleratorPathAskBox()
910
{
@@ -30,4 +31,9 @@ private async void SelectWattAcceleratorInstallPath(object? sender, Avalonia.Int
3031
GameAcceleratorSettings.WattAcceleratorDirPath.Value = Path.Combine(path, "WattAccelerator");
3132
}
3233
}
34+
35+
private void OKButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
36+
{
37+
this.ViewModel?.Close?.Invoke(true);
38+
}
3339
}

0 commit comments

Comments
 (0)