Skip to content

Commit

Permalink
🐛 修复 TaskDialog 在主窗口为null时不在抛出异常
Browse files Browse the repository at this point in the history
修复加速脚本url匹配问题
  • Loading branch information
rmbadmin committed Aug 7, 2024
1 parent d49e38f commit ae9a635
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public async Task<bool> ShowTaskDialogAsync<TPageViewModel>(
XamlRoot = GetWindowTopLevel(),
};

if (td.XamlRoot == null)
{
Toast.LogAndShowT(new Exception("在 AppWindow 为 Null 时,无法弹出 Taskdialog."));
return false;
}

if (viewModel != null)
{
if (viewModel is IWindowViewModel window)
Expand Down
14 changes: 14 additions & 0 deletions src/BD.WTTS.Client.Avalonia/UI/Styling/Controls/Button.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<StackPanel Spacing="10">
<HyperlinkButton Content="更新日志" />
<Button Content="更新日志" Theme="{StaticResource HyperlinkButton}" />
<Button Classes="TransparentAccent" Content="更新日志" />
<Button
Classes="TransparentAccent"
Content="更新日志"
IsEnabled="False" />
<Button
Content="更新日志"
IsEnabled="False"
Expand Down Expand Up @@ -221,6 +226,15 @@
<Setter Property="Background" Value="Transparent" />
</Style>

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

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

<Style Selector="Button.TransparentAccent:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonForegroundPressed}" />
</Style>
</Styles>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public HttpReverseProxyMiddleware(
/// <returns></returns>
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
var url = context.Request.GetDisplayUrl().Remove(0, context.Request.Scheme.Length + 3);
var url = context.Request.GetDisplayUrl();
//var url = context.Request.GetDisplayUrl().Remove(0, context.Request.Scheme.Length + 3);

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

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

if (TryGetDomainConfig(url, out var domainConfig) == false)
if (TryGetDomainConfig(url.Remove(0, context.Request.Scheme.Length + 3), out var domainConfig) == false)
{
if (reverseProxyConfig.Service.TwoLevelAgentEnable)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ public sealed partial class GameAcceleratorService
DeleteMyGameCommand = ReactiveCommand.Create<XunYouGameViewModel>(DeleteMyGame);
GameAcceleratorCommand = ReactiveCommand.CreateFromTask<XunYouGameViewModel>(GameAccelerator);
GameLaunchCommand = ReactiveCommand.CreateFromTask<XunYouGameViewModel>(GameLaunch);
InstallAcceleratorCommand = ReactiveCommand.CreateFromTask(InstallAccelerator);
InstallAcceleratorCommand = ReactiveCommand.CreateFromTask(async () =>
{
if (await IWindowManager.Instance.ShowTaskDialogAsync(new MessageBoxWindowViewModel(),
pageContent: new AcceleratorPathAskBox(), title: "游戏加速", isCancelButton: false, isOkButton: false))
{
await InstallAccelerator();
}
});
UninstallAcceleratorCommand = ReactiveCommand.Create(UninstallAccelerator);
AcceleratorChangeAreaCommand = ReactiveCommand.Create<XunYouGameViewModel>(AcceleratorChangeArea);

Expand Down Expand Up @@ -348,7 +355,7 @@ public async Task GameAccelerator(XunYouGameViewModel app)
//}

if (!await IWindowManager.Instance.ShowTaskDialogAsync(new MessageBoxWindowViewModel(),
pageContent: new AcceleratorPathAskBox(), title: "未安装加速插件", isCancelButton: true))
pageContent: new AcceleratorPathAskBox(), title: "游戏加速", isCancelButton: false, isOkButton: false))
{
app.IsAccelerating = false;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<StackPanel Spacing="6">
<StackPanel Spacing="15">

<TextBlock FontSize="21" TextAlignment="Center">
<Run Text="下载 Watt加速器" />
<LineBreak />
<Run Text="拒绝游戏延迟,提高稳定性" />
</TextBlock>

<ui:SettingsExpander
Description="{Binding Source={x:Static ms:GameAcceleratorSettings.WattAcceleratorDirPath}, Path=Value}"
Header="安装路径"
Expand All @@ -22,6 +29,16 @@
<Button Click="SelectWattAcceleratorInstallPath" Content="选择路径" />
</ui:SettingsExpander.Footer>
</ui:SettingsExpander>
<TextBlock Text="需要下载 Watt 加速器插件才可使用,确定要下载吗?" />

<!--<TextBlock Text="需要下载 Watt 加速器插件才可使用,确定要下载吗?" />-->

<Button
Margin="0,15"
Padding="20,10"
HorizontalAlignment="Center"
Classes="TransparentAccent"
Click="OKButton_Click"
Content="立即下载"
FontSize="14" />
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using Avalonia.Controls;
using Avalonia.Platform.Storage;
using Avalonia.ReactiveUI;

namespace BD.WTTS.UI.Views.Controls;

public partial class AcceleratorPathAskBox : UserControl
public partial class AcceleratorPathAskBox : ReactiveUserControl<MessageBoxWindowViewModel>
{
public AcceleratorPathAskBox()
{
Expand All @@ -30,4 +31,9 @@ private async void SelectWattAcceleratorInstallPath(object? sender, Avalonia.Int
GameAcceleratorSettings.WattAcceleratorDirPath.Value = Path.Combine(path, "WattAccelerator");
}
}

private void OKButton_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
this.ViewModel?.Close?.Invoke(true);
}
}

0 comments on commit ae9a635

Please sign in to comment.