update ui

This commit is contained in:
辉鸭蛋 2024-12-08 00:46:48 +08:00
parent c2cd6dbe9c
commit dd19afaca5
4 changed files with 149 additions and 21 deletions

View File

@ -94,7 +94,7 @@ public partial class App : Application
services.AddView<CommonSettingsPage, CommonSettingsPageViewModel>();
services.AddView<TaskSettingsPage, TaskSettingsPageViewModel>();
services.AddView<HotKeyPage, HotKeyPageViewModel>();
services.AddView<NotificationSettingsPage, NotificationSettingsPageViewModel>();
// services.AddView<NotificationSettingsPage, NotificationSettingsPageViewModel>();
services.AddView<KeyMouseRecordPage, KeyMouseRecordPageViewModel>();
services.AddView<JsListPage, JsListViewModel>();
services.AddView<MapPathingPage, MapPathingViewModel>();

View File

@ -73,29 +73,25 @@
<ui:SymbolIcon Symbol="TaskListSquareLtr24" />
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="辅助操控"
NavigationCacheMode="Enabled"
TargetPageType="{x:Type pages:MacroSettingsPage}">
<ui:NavigationViewItem.Icon>
<ui:SymbolIcon Symbol="XboxController24" />
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<!--<ui:NavigationViewItemSeparator />-->
<ui:NavigationViewItem Content="一条龙"
NavigationCacheMode="Enabled"
TargetPageType="{x:Type pages:OneDragonFlowPage}"
Visibility="{markup:Converter Value={x:Static helpers:RuntimeHelper.IsDebuggerAttached},
Converter={StaticResource BooleanToVisibilityConverter}}">
<ui:NavigationViewItem.Icon>
<ui:SymbolIcon Symbol="AnimalTurtle24" />
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="全自动">
<ui:NavigationViewItem.Icon>
<ui:SymbolIcon Symbol="Bot24" />
</ui:NavigationViewItem.Icon>
<ui:NavigationViewItem.MenuItems>
<ui:NavigationViewItem Content="一条龙"
NavigationCacheMode="Enabled"
TargetPageType="{x:Type pages:OneDragonFlowPage}"
Visibility="{markup:Converter Value={x:Static helpers:RuntimeHelper.IsDebuggerAttached},
Converter={StaticResource BooleanToVisibilityConverter}}">
<ui:NavigationViewItem.Icon>
<ui:SymbolIcon Symbol="AnimalTurtle24" />
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<!--<ui:NavigationViewItemSeparator />-->
<!-- ConvertRange20 -->
<ui:NavigationViewItem Content="调度器"
@ -131,6 +127,14 @@
</ui:NavigationViewItem>
</ui:NavigationViewItem.MenuItems>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="辅助操控"
NavigationCacheMode="Enabled"
TargetPageType="{x:Type pages:MacroSettingsPage}">
<ui:NavigationViewItem.Icon>
<ui:SymbolIcon Symbol="XboxController24" />
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="快捷键"
NavigationCacheMode="Enabled"
@ -139,13 +143,13 @@
<ui:SymbolIcon Symbol="Flash24" />
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
<ui:NavigationViewItem Content="通知"
<!--<ui:NavigationViewItem Content="通知"
NavigationCacheMode="Enabled"
TargetPageType="{x:Type pages:NotificationSettingsPage}">
<ui:NavigationViewItem.Icon>
<ui:SymbolIcon Symbol="Alert24" />
</ui:NavigationViewItem.Icon>
</ui:NavigationViewItem>
</ui:NavigationViewItem>-->
</ui:NavigationView.MenuItems>
<ui:NavigationView.FooterMenuItems>
<ui:NavigationViewItem Content="设置"

View File

@ -423,6 +423,107 @@
</ui:CardControl.Header>
<ui:ToggleSwitch Margin="0,0,36,0" IsChecked="{Binding Config.CommonConfig.ExitToTray, Mode=TwoWay}" />
</ui:CardControl>
<ui:TextBlock Margin="0,0,0,8"
FontTypography="BodyStrong"
Text="通知设置" />
<!-- Webhook -->
<ui:CardExpander Margin="0,0,0,12"
ContentPadding="0"
Icon="{ui:SymbolIcon VirtualNetwork20}">
<ui:CardExpander.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="启用Webhook"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="Webhook相关设置"
TextWrapping="Wrap" />
<ui:ToggleSwitch Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Margin="0,0,24,0"
IsChecked="{Binding Config.NotificationConfig.WebhookEnabled, Mode=TwoWay}" />
</Grid>
</ui:CardExpander.Header>
<StackPanel>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="Webhook端点"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="填写Webhook端点"
TextWrapping="Wrap" />
<ui:TextBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
MinWidth="180"
MaxWidth="800"
Margin="0,0,36,0"
Text="{Binding Config.NotificationConfig.WebhookEndpoint, Mode=TwoWay}"
TextWrapping="NoWrap" />
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="测试"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="发送测试载荷"
TextWrapping="Wrap" />
<ui:Button Grid.Row="0"
Grid.Column="1"
Margin="0,0,36,0"
HorizontalAlignment="Right"
Command="{Binding TestWebhookCommand}"
Content="发送"
IsEnabled="{Binding IsLoading, Converter={StaticResource InverseBooleanConverter}}" />
<ui:TextBlock Grid.Row="1"
Grid.Column="1"
Margin="0,0,36,0"
HorizontalAlignment="Right"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="{Binding WebhookStatus}"
TextWrapping="Wrap" />
</Grid>
</StackPanel>
</ui:CardExpander>
<!-- 地图 -->
<!--<ui:CardControl Margin="0,0,0,12"

View File

@ -3,13 +3,15 @@ using BetterGenshinImpact.GameTask;
using BetterGenshinImpact.GameTask.Model.Enum;
using BetterGenshinImpact.Service.Interface;
using BetterGenshinImpact.View.Pages;
using BetterGenshinImpact.View.Windows;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using BetterGenshinImpact.Service.Notification;
using BetterGenshinImpact.Service.Notifier;
using Wpf.Ui;
using Wpf.Ui.Controls;
@ -20,11 +22,19 @@ public partial class CommonSettingsPageViewModel : ObservableObject, INavigation
public AllConfig Config { get; set; }
private readonly INavigationService _navigationService;
private readonly NotificationService _notificationService;
[ObservableProperty] private bool _isLoading;
public CommonSettingsPageViewModel(IConfigService configService, INavigationService navigationService)
[ObservableProperty] private string _webhookStatus = string.Empty;
public CommonSettingsPageViewModel(IConfigService configService, INavigationService navigationService, NotificationService notificationService)
{
Config = configService.Get();
_navigationService = navigationService;
_notificationService = notificationService;
}
public void OnNavigatedTo()
@ -82,4 +92,17 @@ public partial class CommonSettingsPageViewModel : ObservableObject, INavigation
Process.Start("explorer.exe", path);
}
[RelayCommand]
private async Task OnTestWebhook()
{
IsLoading = true;
WebhookStatus = string.Empty;
var res = await _notificationService.TestNotifierAsync<WebhookNotifier>();
WebhookStatus = res.Message;
IsLoading = false;
}
}